<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>An efficient algorithm for generating symmetric ice piles?</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Roberto Mantaci</string-name>
          <email>Roberto.Mantaci@liafa.univ-paris-diderot.fr</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Paolo Massazza</string-name>
          <email>paolo.massazza@uninsubria.it</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jean-Baptiste Yunès</string-name>
          <email>Jean-Baptiste.Yunes@univ-paris-diderot.fr</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>LIAFA, Université Paris 7 Denis Diderot</institution>
          ,
          <addr-line>Case 7014, 75205 Paris Cedex 13</addr-line>
          ,
          <country country="FR">France</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Università degli Studi dell'Insubria, Dipartimento di Scienze Teoriche e Applicate - Sezione Informatica</institution>
          ,
          <addr-line>Via Mazzini 5, 21100 Varese</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
      </contrib-group>
      <fpage>159</fpage>
      <lpage>170</lpage>
      <abstract>
        <p>We define the Symmetric Ice Pile Model SIPMk(n), a generalization of the Ice Pile Model IPMk(n), and we show an efficient algorithm for generating the symmetric ice piles with n grains. More precisely, we show how to exploit an existing algorithm for generating IPMk(n) in order to generate SIPMk(n) in amortized time O(1) and in space O(√kn).</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>In this paper, we consider the problem of generating particular unimodal
sequences that describe the reachable states of the symmetric version of the
wellknown Ice Pile Model IPMk(n), a discrete dynamical system introduced by Goles
Morvan and Phan [7] as a restriction of the discrete dynamical model proposed
in 1973 by Brylawski [2] in order to study linear partitions of an integer n.</p>
      <p>IPMk(n) admits a description in terms of a simple game that simulates the
movements of ice grains organized into adjacent columns of decreasing heights. If
there are two adjacent columns, say i and i + 1, with heights differing by at least
2, a grain can fall down from column i to column i + 1 (the game starts with n
grains stacked in column 0). Moreover, if a column i of height p is separated from
a column j of height p − 2 by a plateau of at most k − 1 columns of height p − 1,
then a grain can slide from i to j crossing the plateau. IPMk(n) is an extension
of the Sand Pile Model SPM(n), in which only the fall rule is permitted. SPM(n)
has been widely studied in combinatorics, poset theory, physics, and in the theory
of cellular automata to represent granular objects, see [1], [6], [7], [8].</p>
      <p>A natural extension of SPM(n) has been introduced [5], [12] in order to fix
the lack of symmetry (grains either stay or move to the right). Thus, a grain
possibly falls down nondeterministically from column i either to column i − 1 or
to column i+1. This new model, called Symmetric Sand Pile Model and denoted
by SSPM(n), consists of all the integer sequences describing the reachable states
of a system starting with n grains in column 0 (the index of a column can be
negative).</p>
      <p>Despite the simplicity of this rule, the underlying structure drastically changes.
While SPM(n) turns out to be a distributive lattice with exactly one fixed point
(the bottom, easily characterized), SSPM(n) is neither a lattice nor admits a
unique fixed point. Nevertheless, a characterization of fixed points exists [5,
Section 3.2], [12, Th. 2] and their number is known [5, Lemmas 15,16,17].</p>
      <p>In this paper we introduce the symmetric version of IPMk(n), denoted by
SIPMk(n), where left and right slide moves on plateaux of length smaller than
or equal to k − 1 are also permitted, in addition to the left and right fall rules.
In particular, we show that SIPMk(n) can be generated by means of a CAT
(Constant Amortized Time) algorithm. We recall that CAT algorithms for
generating sand and ice piles have been presented in [9] and [10], and that a CAT
algorithm for generating symmetric sand piles has been proposed in [11], where
a decomposition property of symmetric sand piles in terms of product of sand
piles is exploited. We prove that a similar decomposition property holds for
symmetric ice piles: this lets us design a CAT algorithm that sequentially generates
the elements of SIPMk(n) using O(√kn) space.</p>
      <p>In Section 2 we lay down preliminaries such as definitions as well as properties
and characteristics of unimodal sequences and generalized unimodal sequences,
the combinatorial objects used for modeling symmetric ice piles. We also recall
some properties of sand and ice piles, as well as the basics of the CAT algorithm
used to generate IPMk(n). In Section 3 we characterize unimodal sequences that
can be forms of symmetric ice piles and generalized unimodal sequences that can
be configurations of SIPMk(n). These properties are the key for proving that our
algorithm is correct and computing its complexity. The algorithm is outlined in
Section 4 whereas its complexity is analysed in Section 5.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Preliminaries</title>
      <p>A linear partition of n is a non-increasing sequence of strictly positive integers,
s = (s0, . . . , sl), such that Pli=0 si = n; the height, the length and the weight
of s are h(s) = s0, l(s) = l + 1 and w(s) = n, respectively. We consider the
set LP(n) of linear partitions of n equipped with the negative lexicographic or
neglex ordering, &lt;nlex, defined as follows: (s0, . . . , sl) &lt;nlex (t0, . . . , tm) if and
only if there exists i, 0 ≤ i ≤ min(l, m) such that si &gt; ti and sj = tj for j &lt; i. A
unimodal sequence of n is a sequence of strictly positive integers, a = (a0, . . . , al),
such that Pli=0 ai = n and a0 ≤ a1 ≤ . . . ≤ aj ≥ aj+i ≥ . . . ≥ al for some j.
The smallest index q such that aq−1 ≤ aq ≥ aq+1 ≥ · · · ≥ al is called the center
of a, noted by c(a). Obviously, h(a) = ac(a) and, if a is a constant sequence
then c(a) = 0. From here on, for i ≥ 0 we let a&lt;i = (a0, a1 . . . , ai−1) and a≥i =
(ai, ai+1, . . . , al). Given h &gt; 1, we indicate by p[h] the sequence (p, p, . . . , p),
| {hz }
interpreted as a plateau of h columns of height p. The catenation product of
sequences is denoted by “ · ”, (a0, . . . , al) · (b0, . . . , bp) = (a0, . . . , al, b0, . . . , bp),
and the reversal of a by a = (al, . . . , a0). If a = b · c we say that b and c are a
prefix and a suffix of a, respectively.</p>
      <p>We equip the set US(n) of unimodal sequences of n with a particular linear
order “ &lt; ”. Thus, let a, b ∈ US(n), x1 = h(a), x2 = h(b) and consider the
(unique) factorizations a = c · x[1p1] · d, b = e · x[2p2] · f with h(c), h(d) &lt; x1
and h(e), h(f ) &lt; x2. We say that a &lt; b if and only if either (x1 &gt; x2) or
(x1 = x2, p1 &gt; p2) or (x1 = x2, p1 = p2, w(d) &gt; w(f )) or (x1 = x2, p1 =
p2, w(d) = w(f ), d &lt;nlex f ) or (x1 = x2, p1 = p2, d = f, c &lt;nlex e).</p>
      <p>By possibly considering negative indices, we say that (aj, aj+1 . . . , al) is a
generalized unimodal sequence of form b = (b0, . . . , bl−j) if and only if b is a
unimodal sequence and bi = ai+j, 0 ≤ i ≤ l − j. Index j is the position of
a. In other words, a generalized unimodal sequence is obtained by a unimodal
sequence by (right- or left-) shifting all its entries by j places. We identify a
generalized unimodal sequence by means of a pair (a, j) where a is a unimodal
sequence (the form) and j an integer (the position). We also write a to indicate
a generalized unimodal sequence whenever the value j does not matter.</p>
      <p>We extend the linear order &lt; to the set GUS(n) of generalized unimodal
sequences of n by setting (a, i) &lt; (b, j) if and only if either a &lt; b or a = b and
i &lt; j. Trivially, one has LP(n) ⊂ US(n) ⊂ GUS(n). If a = (a, j) ∈ GUS(n)
then for any i with j ≤ i ≤ j + l(a) − 1 we set a&lt;i = (aj, . . . , ai−1) and
a≥i = (ai, . . . , aj+1(a)−1). The right height difference of a = (a, j) at i is defined
as δr(a, i) = ai − ai+1 (assume ai = 0 for i &gt; j + l(a) − 1 or i &lt; j). Analogously,
the left height difference of a at i is δl(a, i) = ai − ai−1.</p>
      <p>We interpret the elements of GUS(n) as blocks of n grains disposed into
adjacent columns and define four (partial) functions called moves. Let a = (a, j) ∈
GUS(n), then the right fall of a grain in column i with j ≤ i ≤ j + l(a) − 1 is
RFall(a, i) =</p>
      <p>⊥
(aj, . . . , ai−1, ai − 1, ai+1 + 1, . . . , aj+l(a)−1) if δr(a, i) &gt; 1,
otherwise
The function RSlidek allows the crossing of a plateau of length at most k − 1:
RSlidek(a, i) = (aj, . . . , ai−1, p, p, . . . , p, ai+k0+2, . . . , aj+l(a)−1)</p>
      <p>| k{0+z2 }
if there is k0 &lt; k such that
a = (aj, . . . , ai−1, p + 1, p, p, . . . , p, p − 1, ai+k0+2, . . . , aj+l(a)−1)</p>
      <p>| {kz0 }
otherwise RSlidek(a, i) = ⊥. The functions LFall(a, i), and LSlidek(a, i) are
defined symmetrically.
i b if either b =</p>
      <p>Whenever the value k is obvious, we simply write a ⇒
LFall(a, i) or b = RFall(a, i) or b = LSlidek(a, i) or b = RSlidek(a, i). In general,
we write a ⇒? b if there is a sequence of moves leading from a to b.
2.1</p>
      <p>The Ice Pile Model
IPMk(n) consists of the closure of {(n)} under RFall and RSlidek. Linear
partitions of IPMk(n) have been characterized combinatorially in [7, Th. 3].
LFall(a,−1)</p>
      <p>RFall(a,0)
– For any ice pile a with height h one has w(a) ≤ h + k (h+1)h .
– For any ice pile a ∈ IPMk(n) one has l(a) ≤ O(√kn). 2</p>
      <p>Given a, b ∈ IPMk(n) we say that b dominates a, noted by a ≺ b, if and only
if for all e ≥ 0 one has Pie=0 bi ≥ Pie=0 ai. Note that a ≺ b implies b &lt;nlex a.
The dominance order ≺ is related to the order induced by ⇒. Indeed, if a ≺ b
then b ⇒? a (see [7]).</p>
      <p>An ice pile a is called a staircase of height h if and only if either a = h[k0] ·
(h − j0), with 0 &lt; k0 &lt; k and 0 ≤ j0 ≤ h, or</p>
      <p>a = h[k] · (h − 1)[k] · (h − 2)[k] · · · (h − i)[k] · (h − i − 1)[k1] · (h − i − 1 − j)
min &lt;nlex (IPMk,h(n)) is
with i ≥ 0, 0 ≤ k1 &lt; k and j &gt; 0. We indicate by IPMk,h(n) the set of ice
piles of height at most h with n grains, IPMk,h(n) = {a ∈ IPMk(n) | h(a) ≤
h}. Note that for a suitable n with (k + 1)h &lt; n ≤ h + k (h+1)h , the ice pile
2
h[k+1] · (h − 1)[k] · (h − 2)[k] · · · (h − i)[k] · (h − i − 1)[k1] · (h − i − 1 − j).
Definition 1. For any h &gt; 0, we call h-critical an ice pile a ∈ IPMk,h−1(n))
such that h[k+1] · a is not an ice pile.</p>
      <p>An ice pile a ∈ IPMk,h(n)) is (h + 1)-critical if and only if it has a prefix in the
set of ice piles
Πh = {a ∈ IPMk(r)|r &gt; 0 ∧ ∃e, 0 ≤ e &lt; h, a =
e
Y(h − i)[k](h − e)}.
i=0
The set of moves of a is M(a) = {i|0 ≤ i ≤ l(a), RFall(a, i) 6= ⊥ or RSlidek(a, i) 6=
⊥}. If a is a staircase or a = min &lt;nlex (IPMk,h(n)) then |M(a)| ≤ 3, indeed
M(a) ⊆ {l(a) − j, l(a) − 2, l(a) − 1} for a suitable j ≤ k. If M(a) = ∅ then a is a
fixed point . We denote by a(e) the eth ice pile of IPMk(n) (w.r.t. &lt;nlex) and by
G(a) the set of ice piles generated from a, G(a) = {b|a ⇒? b}.</p>
      <p>Lemma 1. Let a = min &lt;nlex (IPMk,h(n)). Then G(a) = IPMk,h(n).</p>
      <p>All ice piles of height h which are smaller than a staircase of height h are
(h + 1)-critical:
k
k
k
k
k1</p>
      <p>l(a)−1
l(a)−j l(a)−2</p>
      <p>Lemma 2. Let a, b ∈ IPMk,h(n) and suppose that a is a staircase of height h.
Then (b &lt;nlex a) ⇐⇒ b is (h + 1)-critical.</p>
      <p>Corollary 1. Let a ∈ IPMk,h(n) be a staircase of height h. Then,</p>
      <p>G(a) = {b ∈ IPMk,h(n)|b is not (h + 1)-critical}.</p>
      <p>For complexity evaluation purposes, we give a bound for the number of ice piles
generated by a staircase or by the smallest ice pile of given height. (see fig. 3).
Lemma 3. Let a be either min &lt;nlex (IPMk,h(n)) or a staircase in IPMk,h(n).
If a is not a fixed point then |G(a)| = Ω( l(ka) ).</p>
      <p>k
k
k</p>
      <p>k</p>
      <p>Lemma 4. For any e &gt; 0, let ie = max(M(a(e))). Then we have
(e)
where A(a(e)) = min &lt;nlex {a ∈ IPMk(n) | a&lt;ie+1 = a&lt;ie+1, ie ∈ M (a)}.</p>
      <p>A(a(e)) ⇒ie a(e+1)
We consider a function Next : IPMk(n) 7→ IPMk(n) such that for e &gt; 0,
Next(a(e)) = a(e+1) (Next(a(e)) = ⊥ if a(e) is a fixed point). In [10] it is shown
how this function can be implemented so that if a = (n) then, for any fixed
integer k, the iteration of the instruction a:=Next(a) (until M(a) 6= ∅)
generates IPMk(n) = G((n)) in time O(|G((n))|) (and so is a CAT algorithm) using
O(√n) space. More generally, for any a ∈ IPMk(n) one can generate G(a) in
time O(|G(a)|).
3</p>
    </sec>
    <sec id="sec-3">
      <title>The Symmetric Ice Pile Model</title>
      <p>In [5] and [12] the Symmetric Sand Pile Model SSPM(n) (obtained by closing
{(n)} with respect to RFall and LFall) has been studied and its relation with
SPM(n) analysed. Here we define the Symmetric Ice Pile Model SIPMk(n) as the
set of integer sequences (called symmetric ice piles) obtained by closing {(n)} w.
r. t. RFall, RSlidek, LFall and LSlidek. Note that if (a, j) = (aj, . . . , al(a)+j−1) ∈
GUS(n) is reached from the initial configuration (n) (all the grains in column
0) then one has j ≤ 0 ≤ l(a) + j − 1, since the evolution rules never empty a
column completely (positions j of sequences in SIPMk(n) are nonpositive).</p>
      <p>
        (
        <xref ref-type="bibr" rid="ref7">7</xref>
        )
1(
        <xref ref-type="bibr" rid="ref6">6</xref>
        )
      </p>
      <p>
        (
        <xref ref-type="bibr" rid="ref6">6</xref>
        )1
2(
        <xref ref-type="bibr" rid="ref5">5</xref>
        )
1(
        <xref ref-type="bibr" rid="ref5">5</xref>
        )1
      </p>
      <p>
        (
        <xref ref-type="bibr" rid="ref5">5</xref>
        )2
11(
        <xref ref-type="bibr" rid="ref5">5</xref>
        ) 3(
        <xref ref-type="bibr" rid="ref4">4</xref>
        ) 2(
        <xref ref-type="bibr" rid="ref4">4</xref>
        )1
      </p>
      <p>
        1(
        <xref ref-type="bibr" rid="ref4">4</xref>
        )2 (
        <xref ref-type="bibr" rid="ref4">4</xref>
        )3 (
        <xref ref-type="bibr" rid="ref5">5</xref>
        )11
12(
        <xref ref-type="bibr" rid="ref4">4</xref>
        ) 11(
        <xref ref-type="bibr" rid="ref4">4</xref>
        )1 3(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )1 2(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )2 1(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )3
      </p>
      <p>
        1(
        <xref ref-type="bibr" rid="ref4">4</xref>
        )11 (
        <xref ref-type="bibr" rid="ref4">4</xref>
        )21
111(
        <xref ref-type="bibr" rid="ref4">4</xref>
        ) 13(
        <xref ref-type="bibr" rid="ref3">3</xref>
        ) 12(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )1 11(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )2 3(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )2 2(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )11 2(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )3 1(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )21
(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )31 (
        <xref ref-type="bibr" rid="ref4">4</xref>
        )111
112(
        <xref ref-type="bibr" rid="ref3">3</xref>
        ) 111(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )1 22(
        <xref ref-type="bibr" rid="ref3">3</xref>
        ) 13(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )1
12(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )2
11(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )11 3(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )11
2(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )21
11(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )3 1(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )31 (
        <xref ref-type="bibr" rid="ref3">3</xref>
        )22 1(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )111 (
        <xref ref-type="bibr" rid="ref3">3</xref>
        )211
122(
        <xref ref-type="bibr" rid="ref2">2</xref>
        ) 111(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )2 112(
        <xref ref-type="bibr" rid="ref3">3</xref>
        ) 22(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )1 13(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )11
12(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )11
      </p>
      <p>
        11(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )21 11(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )31 1(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )22 (
        <xref ref-type="bibr" rid="ref3">3</xref>
        )211 2(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )111 (
        <xref ref-type="bibr" rid="ref2">2</xref>
        )221
1112(
        <xref ref-type="bibr" rid="ref2">2</xref>
        ) 122(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )1 112(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )1 122(
        <xref ref-type="bibr" rid="ref2">2</xref>
        ) 22(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )11
      </p>
      <p>
        111(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )11
1112(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )1
112(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )11
11(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )111
      </p>
      <p>
        1(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )211 1(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )221 (
        <xref ref-type="bibr" rid="ref2">2</xref>
        )2111
11(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )22
11(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )211
1(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )2111
      </p>
      <p>As a matter of fact, symmetric ice piles are closely related to ice piles.
Definition 2. Let a = (a0, . . . , al) be a unimodal sequence. Then a is
decomposable at i if and only if ai = h(a) and a&lt;i, a≥i are ice piles.</p>
      <p>The elements of SIPMk(n) have a form which can be decomposed into the
concatenation of a reversed ice pile with an ice pile. More precisely, we extend
to SIPMk(n) a decomposition property proved for SSPM(n) in [12, Lemma 3].
Lemma 5. Let a ∈ US(n), then the two following conditions are equivalent:
1. there is an integer i such that a is decomposable at i, with a&lt;i ∈ IPMk(r),
a≥i ∈ IPMk(s) and r + s = n;
2. there is an integer j such that (a, j) ∈ SIPMk(n).</p>
      <p>Definition 3. For a ∈ US(n) (resp. a ∈ GUS(n)) we denote by D(a) (resp.
D(a)) the set of all indices i such that a (resp. a) admits a decomposition at i
(or equivalently, is decomposable at i).</p>
      <p>Remark 1. Obviously, if a = (a, j) ∈ GUS(n), one has D(a) = D(a) + j =
{i + j | i ∈ D(a)}. Note also that D(a) is always an integer interval. Indeed,
the set {e | ae = h(a)} is an integer interval [e1, e2] (with e1 = c(a)) and then
D(a) = [i1, i2] where :
i1 =
i2 =
(max(e1, e2 − k + 1),
(min(e2, e1 + k − 1),
max(e1, e2 − (k + 1) + 1) = max(e1, e2 − k), otherwise</p>
      <p>min(e2, e1 + (k + 1) − 1) = min(e2, e1 + k), otherwise</p>
      <p>Now, we want to determine when a generalized unimodal sequence belongs
to SIPMk(n). Following [12], we start defining a unilateral (possibly reversed)
ice pile f (a, i) associated with a pair a ∈ GUS(n) and i ∈ D(a).</p>
      <p>Definition 4. Let a ∈ GUS(n) and i ∈ D(a). If i ≥ 0, we define f (a, i),
called the completion of a at i, as the ice pile s = (s0, s1, . . .) of minimal weight
such that s≥i = a≥i. In this case we will call complement of a at i the ice pile
c(a, i) = (s0, s1, . . . , si−1).</p>
      <p>
        Similarly, if i &lt; 0, we define f (a, i) as the generalized unimodal sequence s =
(. . . , s−2, s−1, s0) such that s is the reversed ice pile of minimal weight with
s&lt;i = a&lt;i. In this case the complement of a at i is the reversed ice pile c(a, i) =
(si, si+1, . . . , s−1, s0). In either case, w(a, i) denotes the weight of f (a, i).
Example 1. Let n = 21, k = 2, a = (
        <xref ref-type="bibr" rid="ref1 ref1 ref2 ref2 ref3 ref4 ref4 ref4">1, 2, 2, 3, 4, 4, 4, 1</xref>
        ) and a = (a, −1).
Then c(a, 3) = (
        <xref ref-type="bibr" rid="ref5 ref5 ref6">6, 5, 5</xref>
        ) and hence f (a, 3) = (
        <xref ref-type="bibr" rid="ref1 ref4 ref4 ref4 ref5 ref5 ref6">6, 5, 5, 4, 4, 4, 1</xref>
        ), while c(a, 5) =
(
        <xref ref-type="bibr" rid="ref4 ref4 ref5 ref5 ref6">6, 5, 5, 4, 4</xref>
        ) but still the same completion f (a, 5) = (
        <xref ref-type="bibr" rid="ref1 ref4 ref4 ref4 ref5 ref5 ref6">6, 5, 5, 4, 4, 4, 1</xref>
        ) = f (a, 3).
To study a case with i &lt; 0, let b = (
        <xref ref-type="bibr" rid="ref1 ref1 ref2 ref2 ref3 ref4 ref4 ref4">1, 2, 2, 3, 4, 4, 4, 1</xref>
        ) and b = (b, −7). Then
f (b, −2) = ((
        <xref ref-type="bibr" rid="ref1 ref2 ref2 ref3 ref4 ref4 ref4 ref5">1, 2, 2, 3, 4, 4, 4, 5</xref>
        ), −7) = f (b, −1) = f (b, −3).
      </p>
      <p>
        For any symmetric ice pile a which is decomposable at i, the weight of c(a, i) is
uniquely determined by either a&lt;i (i &lt; 0) or a≥i (i ≥ 0) and easily computed.
Lemma 6. Let a = (a, j) ∈ GUS(n) be decomposable at i. Then w(c(a, i)) can
be computed in time O(
        <xref ref-type="bibr" rid="ref1">1</xref>
        ).
      </p>
      <p>The following Lemma is used for proving Lemma 8, which provides a
characterization for the configurations of SIPMk(n).</p>
      <p>Lemma 7. Let t ∈ SIPMk(n) such that t = (t, 0) and let a = (a, j) be another
generalized unimodal sequence such that j &lt; 0, l(a) = |j| + l(t), a ∈ IPMk(n)
and such that for all i with 0 ≤ i &lt; l(t) one has ai ≤ ti. Then a is reachable
from t.</p>
      <p>Lemma 8. A sequence a = (a, j) ∈ GUS(n) belongs to SIPMk(n) if and only if
∃ i with j ≤ i ≤ l(a) − 1 + j such that a is decomposable at i and w(a, i) ≤ n.</p>
      <p>The condition of the previous lemma characterizing generalized unimodal
sequences belonging to SIPMk(n), can be replaced by an equivalent (although
apparently stronger) condition.</p>
      <p>Lemma 9. Let a = (a, j) ∈ GUS(n). Then, there exists an integer i0 ∈ D(a)
such that w(a, i0) ≤ n if and only if for all i ∈ D(a), one has w(a, i) ≤ n.
Corollary 2. Let a ∈ GUS(n). If 0 ∈ D(a) then a ∈ SIPMk(n).</p>
      <p>Lemma 9 also allows to deduce that for all unimodal sequence a, the set S(a)
of integers j such that (a, j) is in SIPMk(n) is an integer interval.
Corollary 3. Given a ∈ US(n), let j1, j2 be two integers such that (a, j1), (a, j2) ∈
SIPMk(n). Then for all j with j1 ≤ j ≤ j2 one has (a, j) ∈ SIPMk(n).</p>
      <p>Our algorithm generates all possible unimodal sequences a that are form of
some symmetric ice pile, and, for each form, all integers j such that (a, j) ∈
SIPMk(n). We only need to determine the bounds of S(a).</p>
      <p>
        Corollary 4. Let a ∈ US(n) Then (a, j) ∈ SIPMk(n) if and only if j ∈ [jmin, jmax]
with jmin = min{j|(a, j) ∈ SIPMk(n)} and jmax = max{j|(a, j) ∈ SIPMk(n)}.
For the computation of the two integers jmin, jmax we have:
Corollary 5. Let a ∈ US(n) Then jmin = min{j|(a, j) ∈ SIPMk(n)} and
jmax = max{j|(a, j) ∈ SIPMk(n)} are computed in time O(
        <xref ref-type="bibr" rid="ref1">1</xref>
        ).
      </p>
      <p>
        Example 2. Let n = 21, k = 2 and a = (
        <xref ref-type="bibr" rid="ref1 ref1 ref2 ref2 ref3 ref4 ref4 ref4">1, 2, 2, 3, 4, 4, 4, 1</xref>
        ) with D(a) = [i1, i2] =
[4, 6]. Clearly [jmin, jmax] ⊇ [−i2, −i1] = [−6, −4] because (a, −6) and (a, −4) are
decomposable at 0. However the largest δ &gt; 0 such that (a, −4 + δ) ∈ SIPM2(21)
is 1. Indeed, (a, −3) is decomposable at 1 and w((a, −3), 1) = 18 &lt; 21, whereas
(a, −2) is decomposable only at j, 2 ≤ j ≤ 4, but with weight w((a, −2), 2) =
23 &gt; 21. On the other hand, (a, −7) ∈/ SIPM2(21) since it is decomposable only
at j, −3 ≤ j ≤ −1 with w((a, −7), −1) = 25 &gt; 21. Therefore (a, j) ∈ SIPM2(21)
if and only if j ∈ [−6, −3].
      </p>
      <p>
        We conclude this section with a slightly different characterization of forms of
symmetric ice piles which is more suitable for our generation algorithm.
Lemma 10. A unimodal sequence a is the form of an element in SIPMk(n)
if and only if a = c · x[p] · d with c¯ ∈ IPMk(t1), d ∈ IPMk(t2), h(c¯), h(d) &lt; x,
t1 +t2 +xp = n and either p &lt; 2k +1 (
        <xref ref-type="bibr" rid="ref1">1</xref>
        ) or p = 2k +2 and c¯, d are not x-critical
(
        <xref ref-type="bibr" rid="ref2">2</xref>
        ) or p = 2k + 1 and at least one of c¯, d is not x-critical (
        <xref ref-type="bibr" rid="ref3">3</xref>
        ).
      </p>
      <p>Given a unimodal sequence a = c · x[p] · d that is the form of an element in
SIPMk(n), the triple (x, p, w(d)) is said the type of a (by Lemma 10 p ≤ 2k + 2).
In other words, a triple of integers (x, y, z) is a type for SIPMk(n) if and only if
there are a unimodal sequence a = c · x[y] · d, with c¯ ∈ IPMk(n − xy − z) and
d ∈ IPMk(z), and an integer j such that (a, j) ∈ SIPMk(n). Obviously one has
√n − 1 ≤ x ≤ n, 1 ≤ p ≤ min(bn/xc, 2k + 2) and 0 ≤ r ≤ kx(x − 1)/2 + x − 1.
4</p>
    </sec>
    <sec id="sec-4">
      <title>The algorithm</title>
      <p>The idea is that of generating in order (with respect to &lt;) all unimodal sequences
that are forms of elements in SIPMk(n). By Lemma 10, such forms are the
product of three sequences, c · x[p] · d, which satisfy suitable constraints. Thus,
we consider all the triples (x, p, r) corresponding to types, then we generate all
the forms associated with each type, and lastly, for each form, we compute all
the positions of the symmetric ice piles having that form. So, consider a type
(x, p, r) and distinguish three cases depending on p.</p>
      <p>When p ≤ 2k all the forms can be written as a = c · x[p] · d where c¯ and d
are arbitrary ice piles in IPMk,x−1(n − px − r) and IPMk,x−1(r), respectively.
In fact, x[j1] · c¯ and x[j2] · d are always ice piles for all j1, j2 ≤ k. By choosing
two values such that j1 + j2 = p we can guarantee the existence of a value i
such that a&lt;i and a≥i are ice piles. Then, Lemma 5 states that the unimodal
sequence c · x[p] · d is the form of an element in SIPMk(n).</p>
      <p>Obviously, c · x[p]d 6= c0 · x[p] · d0 if h(c), h(d), h(c0), h(d0) &lt; x and c0 6= c or
d0 6= d. Thus, we get all the forms of this type, if we generate all the elements of
IPMk,x−1(r) and, for each of these, all the ice piles in IPMk,x−1(n − px − r).</p>
      <p>
        Consider the case p = 2k + 2. In order to get all the forms c · x[2k+2] · d, by
condition (
        <xref ref-type="bibr" rid="ref2">2</xref>
        ) in Lemma 10 we need to generate all ice piles c¯ and d that are not
x-critical. By Corollary 1 these are the ice piles in G(s) and G(t), where s and t
are the highest staircases in IPMk,x−1(n − px − r) and IPMk,x−1(r), respectively.
      </p>
      <p>
        Lastly, let p = 2k + 1. If r &lt; (k + 1)(x − 1) it is sufficient to generate all d in
IPMk,x−1(r) and (for each of these) all c¯ ∈ IPMk,x−1(n − (2k + 1)x − r). Observe
that d is not x-critical and thus condition (
        <xref ref-type="bibr" rid="ref3">3</xref>
        ) of Lemma 10 is satisfied. Otherwise
(r ≥ (k + 1)(x − 1)), let t be the staircase of height x − 1 in IPMk,x−1(r) and
consider the partition A∪B = IPMk,x−1(r) where A = {a ∈ IPMk,x−1(r)|a &lt;nlex
t} and B = {b ∈ IPMk,x−1(r)|t ≤nlex b}. By Lemma 2 each element of A is
xcritical and then for each d ∈ A we have to generate all ice piles c¯ that are not
x-critical (so that x[k+1] · c¯ is an ice pile): these are exactly the ice piles c¯ ∈ G(s)
where s is the staircase of height x − 1 in IPMk,x−1(n − (2k + 1)x − r). Then,
for each d ∈ B we generate all c¯ ∈ IPMk,x−1(n − (2k + 1)x − r) (x[k+1] · d is an
ice pile). Observe that by Lemma 1 and Corollary 1 one has A = G(g) \ G(t),
where g = min &lt;nlex (IPMk,x−1(r)), and B = G(t).
      </p>
      <p>Once a form c · x[p]d has been generated, all the positions j such that (c · x[p] ·
d, j) ∈ SIPMk(n) are computed using Corollary 5.</p>
      <p>This idea leads immediately to Algorithm 1. We represent ice piles in IPMk(r)
as structures with six fields: the number of grains r, the current length, the linear
partition (an array of integers), the set of moves (an ordered stack of integers),
the integer k and a flag which is on if and only if the ice pile is x-critical. This
last field is included only to simplify the computation of the positions.</p>
      <p>The algorithm consists of three nested loops (associated with the three entries
of a type (x, p, r)). The repeat-loop is used to set the height x of the symmetric ice
pile, starting from the initial value n. The for-loop sets the number p of columns
of height x, from the the largest allowed value min(bn/xc, 2k + 2) downto 1.
Lastly, the while-loop sets the weight r of the ice pile d in c · x[p] · d, from the
largest admissible value (the smallest between the number of available grains
n − px and either kx(x − 1)/2 or kx(x − 1)/2 + x − 1, depending on p) downto
the smallest one (i.e. a value r such that (x, p, r) is a type for SIPMk(n) while
(x, p, r − 1) is not).</p>
      <p>At each iteration, the value p determines which case of Lemma 10 occurs.</p>
      <p>When p &lt; 2k + 1 the call Gen1(m − r,r,x − 1,p,k) generates all symmetric ice
piles having the form c · x[p] · d with c¯ ∈ IPMk,x−1(m − r) and d ∈ IPMk,x−1(r).
Similarly, if p = 2k + 2 Gen2(m − r,r,x − 1,k) generates all symmetric ice
piles having the form c · x[2k+2] · d with c¯ ∈ G(s), and d ∈ G(t), where s and
t are the highest staircases in IPMk,x−1(m − r) and IPMk,x−1(r), respectively.
Lastly, when p = 2k + 1, the call Gen3(m − r,r,x − 1,k) generates all symmetric
ice piles having the form c · x[2k+1] · d and such that c¯ ∈ IPMk,x−1(m − r) or
d ∈ IPMk,x−1(r) is not x-critical.</p>
      <p>The algorithm halts as soon as a value x is reached such that no symmetric ice
pile of height x exists (TooLow(n,k,x) at line 24 returns true iff IPMk,x(n) = ∅).</p>
      <p>Procedures Gen [1-3] are easily developed by means of the following functions
and procedures. MinIcePile(x,r,k) costructs the smallest ice pile in IPMk,x(r)
while Staircase(x,r,k) constructs the highest staircase in IPMk,x(r). Both
functions return a reference to an ice pile (the former possibly sets the flag indicating
x-criticality). IsStaircase(a) (IsBottom(a)) returns the boolean value true iff
a is a staircase (fixed point). The generation of the ice piles c¯ and d which
appear in c · x[p] · d is done by means of Next. This function sets its argument to
the next ice pile in the neglex order, and returns a reference to it (see Section
2.1). Once the components c, x, p and d of a form are known, the Procedure
Positions computes the range of positions for that form.</p>
      <p>
        Example 3. SIPGeneration(
        <xref ref-type="bibr" rid="ref2 ref7">7, 2</xref>
        ) produces the following sequence of
symmetric ice piles (see Fig. 4): (
        <xref ref-type="bibr" rid="ref7">7</xref>
        ), (
        <xref ref-type="bibr" rid="ref6">6</xref>
        )1, 1(
        <xref ref-type="bibr" rid="ref6">6</xref>
        ), (
        <xref ref-type="bibr" rid="ref5">5</xref>
        )2, (
        <xref ref-type="bibr" rid="ref5">5</xref>
        )11, 1(
        <xref ref-type="bibr" rid="ref5">5</xref>
        )1, . . . , 111(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )11, 11(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )211.
5
      </p>
    </sec>
    <sec id="sec-5">
      <title>Complexity</title>
      <p>With respect to the space complexity, we point out that the algorithm uses
O(√kn) space, since to represent a form c · x[p] · d we need only two ice piles c¯, d
(represented by two structures of size O(√kn)) and two integers x, p. Moreover,
recall that for any a ∈ IPMk(n) the generation of G(a) requires O(|G(a)|) time
and O(√kn) space (see section 2.1).</p>
      <p>
        Procedures MinIcePile and Staircase have a cost which grows as the
length l = O(√kn) of the returned ice pile, whereas IsBottom and
IsStaircase run in time O(
        <xref ref-type="bibr" rid="ref1">1</xref>
        ). Indeed, these two functions simply check the stack ST
representing the moves of the ice pile ( ST = ∅, ST ⊆ {l − 2, l − 1}).
Functions IsType and TooLow run in time O(
        <xref ref-type="bibr" rid="ref1">1</xref>
        ) too. In fact, IsType(n, k, x, p, r)
when p ≤ 2k simply checks whether the two values r and n − px − r are
both smaller than kx(x − 1)/2 + x. Similarly, if p = 2k + 2 it verifies that
r, n − (2k + 2)x − r ≤ kx(x − 1)/2. Lastly, if p = 2k + 1 it checks whether
r ≤ kx(x − 1)/2 + x − 1 and n − (2k + 1)x − r ≤ kx(x − 1)/2 or r ≤ kx(x − 1)/2
and n − (2k + 1)x − r ≤ kx(x − 1)/2 + x − 1. TooLow(n, k, x) returns false if
2kx(x − 1)/2 ≤ n − (2k + 2)x, true otherwise. At last, Corollary 5 lets us develop
a procedure Positions(c¯, x, p, d) which runs in time O(
        <xref ref-type="bibr" rid="ref1">1</xref>
        ).
      </p>
      <p>In Procedure SIPGeneration, the repeat-loop iterates O(n) times, the
forloop iterates O(k) times and the while-loop iterates O(kn2) times. Then the
overall cost is O(k2n3) plus the cost of O(k2n3) calls to Gen[1-3]. Thus, we
consider:
Lemma 11. Let C(l, r, x, p, k) be the number of symmetric ice piles generated
by either Gen1(l,r,x,p,k) (if p ≤ 2k) or Gen3(l,r,x,k) (if p = 2k + 1) or
Gen2(l,r,x,k) (if p = 2k + 2). Then, the running time of Gen1(l,r,x,p,k),
Gen2(l,r,x,k) and Gen3(l,r,x,k) is O(C(l, r, x, p, k)) + O(√kn).</p>
      <p>
        We can now prove the main result.
Theorem 1. SIPGeneration is a CAT algorithm and uses O(√kn) space.
Proof. Note that all the instructions of SIPGeneration have cost O(
        <xref ref-type="bibr" rid="ref1">1</xref>
        ) except
the calls to Gen[1-3]. Thus, the cost T (n) of SIPGeneration(n,k) is O(k2n3)
(due to the three nested loops) plus the cost of O(k2n3) calls to Gen[1-3].
Therefore, by Lemma 11 one has
      </p>
      <p>T (n) = O(k2n3) + X O(C(l, r, x, p, k)) = O(k2n3) + O(|SIPMk(n)|).
Since k2n3 = O(|SPM(n)|) and |SPM(n)| ≤ |IPMk(n)| ≤ |SIPMk(n)| (see [3]
for bounds for |SPM(n)|), SIPGeneration turns out to be a CAT algorithm.
With respect to the space complexity, note that the necessary space for storing
two ice piles at a time is (O(√kn)). tu</p>
      <p>As an extension of this work, it is quite natural to ask whether a similar
approach can be applied to deal with the exhaustive generating problem for
other (similar) discrete models. In particular, the discrete models BSPM and
BIPM (Bidimensional Sand and Ice Pile Model) have been introduced in [4] by
adding a further dimension to SPM(n) and IPMk(n), respectively. Thus, the
elements of BSPM and BIPM are plane partitions, that is, matrices of
nonnegative integers that are nonincreasing from top to bottom and from left to
right. These models are not lattices and admit several fixed points but, unlike
SIPMk(n), no characterization is known for reachable states and fixed points.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>P.</given-names>
            <surname>Bak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Tang</surname>
          </string-name>
          and
          <string-name>
            <given-names>K.</given-names>
            <surname>Wiesenfeld</surname>
          </string-name>
          ,
          <article-title>Self-organized criticality</article-title>
          ,
          <source>Phys. Rev. A</source>
          <volume>38</volume>
          (
          <year>1988</year>
          ),
          <fpage>364</fpage>
          -
          <lpage>374</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>T.</given-names>
            <surname>Brylawski</surname>
          </string-name>
          ,
          <article-title>The lattice of integer partitions</article-title>
          ,
          <source>Discrete Math. 6</source>
          (
          <issue>1973</issue>
          ),
          <fpage>201</fpage>
          -
          <lpage>219</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>S.</given-names>
            <surname>Corteel</surname>
          </string-name>
          ,
          <string-name>
            <surname>D.</surname>
          </string-name>
          Gouyou-Beauchamps,
          <article-title>Enumeration of sand piles</article-title>
          ,
          <source>Discrete Math. 256 n.3</source>
          (
          <issue>2002</issue>
          ),
          <fpage>625</fpage>
          -
          <lpage>643</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>E.</given-names>
            <surname>Duchi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Mantaci</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H. D.</given-names>
            <surname>Phan</surname>
          </string-name>
          and
          <string-name>
            <given-names>D.</given-names>
            <surname>Rossin</surname>
          </string-name>
          ,
          <article-title>Bidimensional sand pile and ice pile models, PU.M.A</article-title>
          . vol.
          <volume>17</volume>
          (
          <year>2007</year>
          ) n.
          <issue>1-2</issue>
          ,
          <fpage>71</fpage>
          -
          <lpage>96</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>E.</given-names>
            <surname>Formenti</surname>
          </string-name>
          , B. Masson and
          <string-name>
            <given-names>T.</given-names>
            <surname>Pisokas</surname>
          </string-name>
          , Advances in symmetric sandpiles,
          <source>Fundamenta Informaticae</source>
          <volume>20</volume>
          (
          <year>2006</year>
          ),
          <fpage>1</fpage>
          -
          <lpage>22</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>E.</given-names>
            <surname>Goles and M.</surname>
          </string-name>
          <article-title>A. Kiwi, Games on line graphs and sand piles</article-title>
          ,
          <source>Theoret. Comput. Sci</source>
          .
          <volume>115</volume>
          (
          <year>1993</year>
          ),
          <fpage>321</fpage>
          -
          <lpage>349</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>E.</given-names>
            <surname>Goles</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Morvan and H. D. Phan</surname>
          </string-name>
          ,
          <article-title>Sandpiles and order structure of integer partitions</article-title>
          ,
          <source>Discrete Appl. Math</source>
          .
          <volume>117</volume>
          (
          <year>2002</year>
          ),
          <fpage>51</fpage>
          -
          <lpage>64</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>M.</given-names>
            <surname>Latapy</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Mantaci</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Morvan and H. D. Phan</surname>
          </string-name>
          ,
          <article-title>Structure of same sand piles model</article-title>
          ,
          <source>Theoret. Comput. Sci</source>
          .
          <volume>262</volume>
          (
          <year>2001</year>
          ),
          <fpage>525</fpage>
          -
          <lpage>556</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>P.</given-names>
            <surname>Massazza</surname>
          </string-name>
          ,
          <article-title>A CAT algorithm for sand piles, PU.M.A</article-title>
          . vol.
          <volume>19</volume>
          (
          <year>2008</year>
          ) n.
          <issue>2-3</issue>
          ,
          <fpage>147</fpage>
          -
          <lpage>158</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <given-names>P.</given-names>
            <surname>Massazza</surname>
          </string-name>
          and
          <string-name>
            <given-names>R.</given-names>
            <surname>Radicioni</surname>
          </string-name>
          <article-title>A CAT algorithm for the exhautive generation of ice piles</article-title>
          ,
          <source>RAIRO Informatique théorique 44</source>
          (
          <year>2010</year>
          ),
          <fpage>525</fpage>
          -
          <lpage>543</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11. P. Massazza,
          <article-title>On the Exhaustive Generation of Symmetric Sand Piles</article-title>
          ,
          <source>Proc. of GASCom</source>
          <year>2010</year>
          , Montréal,
          <fpage>2</fpage>
          -
          <issue>4</issue>
          <year>September 2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>H. D. Phan</surname>
          </string-name>
          ,
          <article-title>Two sided sand piles model and unimodal sequences</article-title>
          ,
          <source>RAIRO Informatique théorique 42</source>
          (
          <year>2008</year>
          ),
          <fpage>631</fpage>
          -
          <lpage>646</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>