Theoretical Computer Science 346 (2005) 183 www.elsevier.com/locate/tcs
Preface With the publication of this special issue the community of Theoretical Computer Science aims at commemorating the sudden and unexpected death of Prof. Alberto Del Lungo, on 1st June, 2003. This volume contains a biographical contribution, written by the Guest Editors, and a collection of 15 invited papers, referred at the usual high level journal standard. The scientific contributions range, mainly, but not exclusively in the areas of Alberto’s research interests: enumeration of combinatorial objects, random and exhaustive generation of combinatorial objects, algebraic and bijective combinatorics, discrete tomography, discrete geometry and topology, computational complexity, tilings and patterns, combinatorial mathematical biology. As Guest Editors we would like to thank the authors who contributed to the issue, and the referees for their careful and invaluable work. Special thanks are due Andrea Frosini, in preparing the final version of this issue, and to the Editor in Chief of Theoretical Computer Science—A, Prof. Giorgio Ausiello for the help and advice he gave us through all the steps necessary to the preparation of this volume. Elisa Pergola Dipartimento di Sistemi e Informatica Universita di Firenze, Viale Mrgagni, 65 50134 Firenze, Italy E-mail address:
[email protected]fi.it Simone Rinaldi Dipartimento di Scienze Matematiche ed Informatiche ‘‘R.Magari’’ Universita di Siena, Pian dei Mantellini 44 53100 Siena, Italy E-mail address:
[email protected] 0304-3975/$ - see front matter © 2005 Elsevier B.V. All rights reserved. doi:10.1016/j.tcs.2005.08.022
Theoretical Computer Science 346 (2005) 184 – 188 www.elsevier.com/locate/tcs
Editorial
In memoriam: Alberto Del Lungo (1965–2003) Monimentis, quae consecravit sapientia, vetustas nocere non potest, nulla abolebit aetas nulla deminuet (Seneca, De brev. vit., 15,4) Caro Alberto, ............ How often we have written these two words at the beginning of our conversations dealing with the most varied subjects: from our own daily routines to organization problems and above all scientific matters. These are the very words we have decided to start this book with, as this volume is dedicated to you. Alberto del Lungo was born in Pelago (Florence) on July 8th, 1965. He grew up in the tranquillity of the surrounding countryside, living his happy childhood in the serene atmosphere provided by his loving family which supported him throughout his school years. In 1984 he took a secondary-school diploma in Engineering at the Istituto Tecnico Industriale (technical school) “Leonardo da Vinci” in Florence and in 1992 he graduated at the University of Florence with a degree in Mathematics. Alberto’s degree thesis brought him closer to Professor Renzo Pinzani, with whom he immediately established a strong relationship based on mutual respect and esteem. In 1993 Alberto began studying for his research doctorate in Automation and Information Technology at the Department of Systems Analysis and Computer Science (DSI) of the University of Florence together with the research team headed by Professor Pinzani, finally getting his PhD in 1995. In the month of February of the following year, Alberto starts working as a researcher at the Faculty of Natural, Physical and Mathematical Sciences, where he tirelessly keeps on doing research and cooperating with an increasing number of scientists and colleagues no matter the additional teaching and bureaucratic activities deriving from his new position. In 1999 Alberto married Marina Giordano in a small church, in the countryside near his hometown. Marina had become his ever-present companion since the very first time they met, as she was always ready to support and encourage him at any time in their life as a married couple. On the other hand Alberto himself “could not even think of his life without Marina”. In 1998 Alberto left DSI to join the Department of Mathematics and Computer Science of the University of Siena where he was appointed associate professor at the Faculty of Natural, Physical and Mathematical Science. Although the new environment initially worried him, Alberto soon recovered his self-confidence, thus perfectly integrating with the new
0304-3975/$ - see front matter © 2005 Elsevier B.V. All rights reserved. doi:10.1016/j.tcs.2005.08.021
Editorial / Theoretical Computer Science 346 (2005) 184 – 188
185
department where he became a central point of reference both for his own colleagues and for the other workers of the faculty and of the entire university, who turned to him for advice not only in scientific matters but also in case of organization problems. Alberto divided his energies between his research activity, publishing activity for TCS (Series A) (indeed he had become part of the Editorial Board in 2000), the development of the university course in Computer Science in Siena, and the setting up of a master in bioinformatics, which still carries his name. In December 2002 Alberto was appointed tenured professor at the Faculty of Natural, Physical and Mathematical Science of the University of Siena. Alberto had now realized his dream, and it was a remarkable achievement which rewarded him for his hard and brilliant work and for all the energies he had devoted to his career. Alberto’s renewed enthusiasm led to intense and fruitful research activities and to the cooperation with an increasing number of scientists both at national and international level. Alberto died on June 1st, 2003 of a heart attack. The book on bioinformatics he had been reading the night before was still on his bed-side table, together with a plane ticket for Paris, where he should have flown on a mission the following day. The incredulity of Alberto’s relatives, friends and colleagues following his untimely death was soon replaced by the bitter awareness of the gap he had left in their hearts, which nobody could ever fill again. At Alberto’s funeral in the main church in his hometown, Professor Maurice Nivat suggested publishing a special issue of TCS-A dedicated to Alberto Del Lungo. Professor Giorgio Ausiello, editor in chief of TCS-A, reacted enthusiastically to this suggestion and supported the publication of this volume, as during his short period of cooperation with Alberto, Professor Ausiello had already begun to appreciate his great qualities. Alberto’s brilliant career is characterized by a remarkable scientific activity. Alberto’s interest in combinatorial analysis started in 1991, when he started working on his degree thesis on “Algorithms for the Generation of Directed Animals”, which laid the foundations of the ECO method. ECO is a constructive method to produce all the objects of a given class, according to the growth of a certain parameter (the size) of the objects. Basically, the idea is to perform local expansions on each object of size n, thus constructing a set of objects of the successive size. This construction should induce a partition of all the objects of any given size (that is, all the objects of a given size are produced exactly once from the objects of immediately lower size, thorough the ECO construction). If an ECO construction is sufficiently regular, then it is often possible to describe it using a succession rule, and to define those functional equations which comply with the multi-varied generating function of the class of these same objects, taking into consideration different enumeration parameters. Alberto’s doctorate gave excellent results, resulting from his fruitful cooperation with the research team he worked with at DSI as well as with a great number of international scientific connections. Professor Pinzani enthusiastically encouraged Alberto to carry out research in new sectors with tireless energy while, the reflexive attitude of Professor Elena Barcucci helped him express his original results with a rigorous and thorough method. While working at DSI, Alberto also dealt with enumerating combinatorial analysis and random generation of combinatorial structures. The ECO method was formalized and applied to a great number of combinatorial structures [5]. In order to meet the demands voiced by the scientific community, he also studied permutations with forbidden patterns, enumerating, through different parameters, classes of parameterized excluded-pattern permutations, thus developing a general method to study some permutations characterized by excluded patterns
186
Editorial / Theoretical Computer Science 346 (2005) 184 – 188
of increasing length [7,8]. The potential of the ECO method is also analyzed bijectively as studied in [6] and used as a general instrument to obtain the random generation of objects [1]. “He was my best student. . .” These few words uttered by Professor Renzo Pinzani simply account for such remarkable and diversified achievements and make it clear how difficult it is to meet such an exceptional person as Alberto, endowed with a rare mixture of good qualities, including intelligence, obstinacy, strength, understanding, fancy, and concreteness. . . On his turn Alberto himself used to say the following sentence: “Renzo?!. . . how could you ever quarrel with him. . .” Indeed Alberto and Renzo often argued about political matters concerning the university as well as about other scientific issues. Every discussion helped Alberto grow in different ways and this fact, together with the great affection, esteem and trust that bounded Alberto to Renzo contributed to the ensuing steady and strong relationship which linked them, untouched by time or distance, even when Alberto was in Siena and could not simply knock on Renzo’s door every morning to discuss about the latest news. During one of his frequent trips to France, Professor Jean-Guy Penaud of LaBRI (Laboratoire Bordelais de Recherche Informatique) presented to Alberto the problem of giving a bijective proof of the enumerative formula regarding non-separable rooted planar maps, which had been determined analytically by Tutte. After a few days of drawing and writing formulas on the blackboard, Alberto solves the problems, coming up with a bijection between non-separable rooted planar maps and left ternary trees, that is to say ternary trees that are designed so as to grow exclusively on their left side, as determined by straight vertical line passing through its root [11]. Such work greatly influenced the following studies on planar maps as far as both their random generation and their enumeration are concerned. At a seminar held at the Dipartimento di Sistemi e Informatica di Firenze, on September 1992, Alberto met Professor Maurice Nivat, who illustrated him the problem of establishing the existence of a polyomino with a given number of cells in every column and every row. Alberto was always ready to take up new challenges, his enthusiasm and thirst for knowledge as well as his firmness and the awareness of his own capabilities (he used to say: “I have a slow, sequential brain”) helped him work out a solution for Professor Nivat’s problem for several classes of polyominoes [9]. This event marked the beginning of a long-term friendship and a profitable cooperation. Professor Nivat acquainted Alberto with Discrete Tomography and Alberto did not take long to make his own contributions to this sector. Alberto knew that the reconstruction of convex polynomials in lines or columns through their orthogonal projections was an NP-complete problem, but he was not at all discouraged and in [3] is developed a polynomial algorithm for reconstructing convex polyominoes from their horizontal and vertical projections. In [4] the execution time of the previous algorithm is lowered thanks to some properties of convex polyominoes. The problem of reconstructing a sum of k permutation matrices from its diagonal sums is known to be NP-complete. In [10], Alberto proves that a simple variant of this problem in which the permutation matrices lie on a cylinder instead of on a plane can be solved in polynomial time, and he furnishes the corresponding algorithm. He obtains these results by means of a generalization of a classical theorem of Hall on the finite abelian groups. The above-mentioned episodes are just a few examples of the great results obtained by Alberto in the field of Discrete Tomography. The great importance of Alberto’s remarkable achievements in this sector is further stressed by the authoritative position he had gained
Editorial / Theoretical Computer Science 346 (2005) 184 – 188
187
in this field in Italy and by the request of his contribution in [14], while his doctoral thesis “Discrete Tomography: reconstructing digital pictures from their projections” testifies to his passion for this subject. “It’s difficult to keep pace with Maurice, but if you are able to do so, you will be spellbound. . .” These were the words he used to describe Professor Nivat, when we first met him at DSI. They were uttered with a sweet smile of affection and an intense, deep look. It took us a while to understand that Alberto was not only talking about Maurice as a scientist, but as a man too. In Siena Alberto further demonstrated that he was not only an excellent researcher but also a good teacher. A good small team of well integrated researchers soon gathers around him, the young students are eager to learn from him and the first scientific results of this cooperation are soon visible. Just to give a few examples, we could mention [2], and [12]. The first article was born as an answer to Propp’s question appeared on the “domino” forum: “Is there a technology for reverse-engineering a combinatorial problem from a rational generating function?” Making use of some results from the theory of N-rational series the authors obtained an automatic interpretation of recurrence relations with constant coefficients in terms of regular languages and a characterization of the set of generating functions of regular languages. It is thus possible, through an algorithm, to pass from a rational function in this set to a regular expression whose generating function is this same function. In the second paper [12] Alberto and his collaborators developed a general methodology for the generation and enumeration of some classes of convex polyominoes. In practice, they first determine ECO constructions which apply to all these classes, and the associated succession rules. The enumeration is then derived in novel fashion, starting from a method proposed by Fédou and Garcia, for some algebraic succession rules, and extending it to the present case on noting that a convex polyomino with semi-perimeter n + 2 has a representation as a word of length n of a non-commutative formal power series over an infinite alphabet; this non-commutative power series admits a decomposition in terms of some auxiliary power series which yields an algebraic system of equations on taking commutative images; and the solution of this system is then the desired generating function. The Editors would like to thank all the people who have made the publication of this volume possible, starting with the authors who have provided high-quality works and have followed with precision the referees’ suggestions; the referees who have improved the quality of the original manuscripts and have promptly satisfied our requests; the Editor in Chief, Professor Giorgio Ausiello, who has constantly encouraged us, downplaying difficulties and misunderstandings and following every step of our work. We owe a special thank-you also to Andrea Frosini, whose material and moral support has played an essential role right from the start. This issue does not only illustrate the results achieved by Professor Alberto del Lungo in his specific field of research but also shows his efforts in other sectors of Combinatorial analysis and of Discrete Geometry so as to demonstrate how highly esteemed he was by the entire international scientific community. This homage will not certainly fill the gap left by Alberto but it can help us revive his smile forever, and remember his readiness to help, his enthusiasm and his capabilities. His works and the memory of Alberto as a man will certainly represent a guiding presence for the future, as he will be walking by our side along the difficult paths of scientific research and of our personal lives. We cannot deny the difficulties we have gone through while writing this volume: it has been hard to relive,
188
Editorial / Theoretical Computer Science 346 (2005) 184 – 188
in a very short time, long years of common interests, little shared secrets, and past daily routines. . . . It has been difficult not to give way to despair when we had the illusion of writing to Alberto to ask for his advice, as we used to do in the past, when at the end of all our conversations we would ask him: “. . .what do you think about it?” Ciao Alberto, Elisa and Simone References [1] E. Barcucci, A. Del Lungo (Eds.), Random generation of combinatorial objects and bijective combinatorics, Theoretical Computer Science, Vol. 307(2), Elsevier, Amsterdam, The Netherlands, 2003, pp. i–iv, 219–453. [2] E. Barcucci, A. Del Lungo, A. Frosini, S. Rinaldi, A technology for reverse-engineering a combinatorial problem from a rational generating function, Adv. Appl. Math. 26 (2001) 129–153. [3] E. Barcucci, A. Del Lungo, M. Nivat, R. Pinzani, Reconstructing convex polyominoes from horizontal and vertical projections, Theoret. Comput. Sci. 155 (1996) 321–347. [4] E. Barcucci, A. Del Lungo, M. Nivat, R. Pinzani, Reconstructing convex polyominoes from horizontal and vertical projections II, in: Discrete Geometry for Computer Imagery, Lyon, 1996, Lecture Notes in Computer Science, Vol. 1176, Springer, Berlin, 1996, pp. 295–306. [5] E. Barcucci, A. Del Lungo, E. Pergola, R. Pinzani, ECO: a general methodology for the enumeration of combinatorial objects, J. Differential Equations Appl. 5 (1999) 435–490. [6] E. Barcucci, A. Del Lungo, E. Pergola, R. Pinzani, Directed animals forests of trees and permutations, Discrete Math. 204 (1999) 41–71. [7] E. Barcucci, A. Del Lungo, E. Pergola, R. Pinzani, From motzkin to catalan permutations, Discrete Math. 217 (2000) 33–49. [8] E. Barcucci, A. Del Lungo, E. Pergola, R. Pinzani, Permutations avoiding an increasing number of lengthincreasing forbidden subsequences, Discrete Math. Theoret. Comput. Sci. 4 (2000) 31–44. [9] A. Del Lungo, Polyominoes defined by two vectors, Theoret. Comput. Sci. 127 (1994) 187–198. [10] A. Del Lungo, Reconstructing permutation matrices from diagonal sums, Theoret. Comput. Sci. 281 (2002) 235–249. [11] A. Del Lungo, F. Del Ristoro, J.G. Penaud, Left ternary trees and non-separable rooted planar maps, Theoret. Comput. Sci. 233 (2000) 201–215. [12] A. Del Lungo, E. Duchi, A. Frosini, S. Rinaldi, On the generation and enumeration of some classes of convex polyominoes, Electronic J. Combinatorics 11 (2004) #R60. [14] A. Del Lungo, M. Nivat, Reconstruction of connected sets from two projections, in: G.T. Herman, A. Kuba (Eds.), Discrete Tomography: Foundations, Algorithms, and Applications, Birkhäuser, Boston, Cambridge, MA, 1999 (Chapter 7).
E. Pergola Università di Firenze, Dipartimento di Sistemi e Informatica, Viale Morgagni, 65, 50134, Firenze, Italy E-mail address:
[email protected]fi.it S. Rinaldi Università di Siena, Dipartimento di Scienze Matematiche e Informatiche, Pian dei Mantellini, 44, 53100, Siena, Italy E-mail address:
[email protected] Theoretical Computer Science 346 (2005) 189 – 199 www.elsevier.com/locate/tcs
Minimal change list for Lucas strings and some graph theoretic consequences Jean-Luc Baril, Vincent Vajnovszki∗ LE2I– CNRS UMR 5158, Université de Bourgogne B.P. 47 870, 21078 Dijon-Cedex, France
Abstract We give a minimal change list for the set of order p length-n Lucas strings, i.e., the set of length-n binary strings with no p consecutive 1’s nor a 1 prefix and a 1m suffix with +m p. The construction of this list proves also that the order p n-dimensional Lucas cube has a Hamiltonian path if and only if n is not a multiple of p + 1, and its second power always has a Hamiltonian path. © 2005 Elsevier B.V. All rights reserved. Keywords: Minimal change list; Gray code; Fibonacci and Lucas string; Lucas cube; Hamiltonian path
1. Introduction The Hamming distance between two strings in {0, 1}n is the number of positions in which they differ. A k-Gray code for a set of binary strings B ⊂ {0, 1}n is an ordered list B for B, such that the Hamming distance d between any two consecutive strings in B is at most k. In addition, if the list B minimizes both k = max d(x, x ) and d(x, x ), where (x, x ) ranges over all pairs of successive strings in B, then it is called minimal change list or minimal Gray code. Obviously, a 1-Gray code is a minimal change list. We call Hamiltonian a graph having a Hamiltonian path and a k-Gray code is a Hamiltonian path in Qkn |B, the restriction of the kth power of the hypercube Qn to the set B. The set Fn,p , of order p length-n Fibonacci strings, is the set of length-n binary strings such that there are no p consecutive 1’s. The set Ln,p , of order p length-n Lucas strings, is the set of all strings in Fn,p which do not begin by 1 and end by 1m with + m p. ∗ Corresponding author.
E-mail addresses:
[email protected] (J.-L. Baril),
[email protected] (V. Vajnovszki). 0304-3975/$ - see front matter © 2005 Elsevier B.V. All rights reserved. doi:10.1016/j.tcs.2005.08.020
190
J.-L. Baril, V. Vajnovszki / Theoretical Computer Science 346 (2005) 189 – 199
In other words, Ln,p is the set of length-n binary strings such that there are no 1p factors if strings are regarded circularly, i.e., the last entry of a string is followed by the first one. A number of papers concerning the Fibonacci and Lucas strings have been published [3,6–9,13,15]. In the present one we introduce an order relation on {0, 1}n which induces a minimal change list on Ln,p . Note that this order relation yields a 1-Gray code on the set Fn,p , of order p length-n Fibonacci strings [13]. This paper is the extended version of [2] and the remaining is organized as follows. In the next section we prove that a 1-Gray code for Ln,p is possible only if (p + 1) does not divide n. In Section 3 we give such a Gray code and a 2-Gray code when (p + 1) divides n; both of them are minimal change lists. Few graph theoretic consequences are presented in Section 4 and in the final part some algorithmic considerations are given. 2. Parity difference relation For a binary string set B we denote by B (resp. B ) the subset of B of strings with an odd (resp. even) number of 1’s. Let Q(Ln,p ) be the order p n-dimensional Lucas cube, i.e., the restriction of the hypercube Qn to the set Ln,p . The graph Q(Ln,p ) is bipartite, and with the notations above {Ln,p , Ln,p } is a bipartition. No Hamiltonian path is possible in Q(Ln,p ) (or equivalently, 1-Gray code for Ln,p ) if |card(Ln,p ) − card(Ln,p )| > 1, i.e., the number of vertices in the two bipartitions differs by more than one. The main result of this section is Theorem 5. In the following we suppose p > 1 fixed and more often in this section we will omit the subscript p for the sets Fn,p , Ln,p and other related things. Let {n }n 0 and {n }n 0 be the parity difference integer sequences corresponding to Fibonacci and Lucas strings defined by • n = card(F n ) − card(Fn ), and • n = card(Ln ) − card(Ln ). Lemma 1. (1) n satisfies n = n−1 − n−2 + · · · + (−1)p+1 n−p
for n p + 1.
(1)
(2) n is related to n by n = n−2 − 2 · n−3 + · · · + (−1)p+1 p · n−p−1
for n p + 2.
Proof. 1. The recursive definition in [13] Fn = 0 · Fn−1 ∪ 10 · Fn−2 ∪ 110 · Fn−3 ∪ · · · ∪ 1p−1 0 · Fn−p can be expanded as Fn = 0 · Fn−1 ∪ 10 · F n−2 ∪ 110 · Fn−3 ∪ ···,
and F n = 0 · F n−1 ∪ 10 · Fn−2 ∪ 110 · F n−3 ∪ · · · ,
and (1) holds.
for n p + 1
(2)
J.-L. Baril, V. Vajnovszki / Theoretical Computer Science 346 (2005) 189 – 199
191
2. When np + 2 the set Ln is the union of the sets in the table below, where the strings with prefix 1i−1 0 are in the ith line and those with the suffix 01j −1 are in the jth column, 1i, j p. 0 · Fn−2 · 0, 10 · Fn−3 · 0, .. . 1p−2 0 · Fn−p · 0, 1p−1 0 · Fn−p−1 · 0
0 · Fn−3 · 01, 10 · Fn−p−4 · 01, .. . 1p−2 0 · Fn−p−1 · 01
· · · 0 · Fn−p · 01p−2 , · · · 10 · Fn−p−1 · 01p−2 .. .
0 · Fn−p−1 · 01p−1
In this decomposition, each Fn−k−1 occurs exactly k times, and reading this table diagonally one has card(Ln ) =
p j =1
j · card(Fn−j −1 ),
and Fn−k−1 appears as 1s 0 · Fn−k−1 · 01t , with s + t = k − 1, thus card(Ln ) = card(Fn−2 ) + 2 · card(F n−3 ) + 3 · card(Fn−4 )...,
and card(Ln ) = card(F n−2 ) + 2 · card(Fn−3 ) + 3 · card(F n−4 ) . . . ,
so (2) holds.
The next proposition gives the generating function for the sequences {n }n 0 (except its first term) and {n }n 0 (except its p + 2 first terms). Proposition 2. If (z) and (z) denote the generating functions for the sequences {n }n 0 and {n }n 0 , respectively, then (1) (z) = 0 + z · (−z)p−1 ·
1+z , 1 − (−z)p+1
(3)
(2) (z) =
p+1 j =0
j zj + zp+2 · (−1)p+1 ·
1 − (p + 1)(−z)p + p(−z)p+1 . (1 − (−z)p+1 ) · (1 + z)
(4)
Proof. 1. For i = 1, 2, . . . , p − 1 all strings in {0, 1}i are in Fi , and half of them are in Fi and other half are in F i , so 1 = 2 = · · · = p−1 = 0. If i = p, then a single string in {0, 1}p does not belong to Fp , namely 1p , so p = (−1)p+1 . By relation (1) we have (z) = 0 + z ·
f (z) , (1 − (−z)p+1 )/(1 + z)
where f (z) = (−z)p−1 is given by the values of 1 , 2 , . . . , p . See for instance Flajolet and Sedgewick’s seminal book [4, p. 79].
192
J.-L. Baril, V. Vajnovszki / Theoretical Computer Science 346 (2005) 189 – 199
2. If ∗ (z) = (z) −
p+1 j =0
j zj , then relation (2) gives (see again [4])
∗ (z) = ((z) − 0 ) · (z2 − 2z3 + · · · + (−1)p+1 pzp+1 ) and finally ∗ (z) = zp+2 · (−1)p+1 ·
1 − (p + 1)(−z)p + p(−z)p+1 . (1 − (−z)p+1 ) · (1 + z)
(5)
For np + 2, n is given by the coefficient of zn in (4). The next corollary shows that the sequence {n }n 0 is periodic from n p + 1 and gives its generating function if it is extended by periodicity to 0 , 1 , . . . , p+1 . Corollary 3. The sequence {n }n p+2 has the period 2(p + 1). In addition, if one defines n = n+2(p+1) for all n = 0, 1, . . . , p + 1 then its generating function becomes (z) =
(−z)p+1 + (p + 1)z + p . (1 − (−z)p+1 ) · (1 + z)
(6)
Proof. For ∗ (z) given by relation (5) it is easy to show that (∗ (z)/zp+2 )(1 − z2(p+1) ) is a polynomial of degree less than 2p + 2. Thus ∗ (z)/zp+2 is the generating function for a periodic integer sequence with the period 2(p + 1), and so is (z) assuming it is extended by periodicity. For (6) it is enough to find a polynomial g(z) of degree less than p+2 such that ∗ (z)−g(z) is divisible by z2(p+1) , and in this case (z) = (∗ (z) − g(z))/z2(p+1) . It is not hard to check that g(z) = (−z)p+2 ((−z)p − 1)/(z + 1) satisfies this and we obtain (6). Corollary 4. The parity difference integer sequence corresponding to Lucas strings satisfies n,p =
(−1)n+1 if (p + 1) |n, (−1)n · p if (p + 1)|n.
(7)
Proof. (z) in relation (6) can be expressed as p+1 1 − 1 − (−z)p+1 1+z = (p + 1) · (−z)k(p+1) − (−z)n
(z) =
k 0
and n,p is the coefficient of zn in (z).
n0
Observe that the choice of i,p , i = 1, 2, . . . , p + 1, in Corollary 3 seems arbitrary since extended by periodicity. In fact, for i = 1, 2, . . . , p all the 2i strings in {0, 1}i
J.-L. Baril, V. Vajnovszki / Theoretical Computer Science 346 (2005) 189 – 199
193
are in Li,p , except 1i which contains p consecutive 1’s if strings are regarded circularly. In this case i,p = (−1)i+1 , and similarly, p+1,p = (−1)p+1 p, which are in accord with (7). Theorem 5. If Q(Ln,p ) is Hamiltonian then (p + 1) |n. Proof. If Q(Ln,p ) is Hamiltonian then |n,p | 1, so (p + 1) |n. The Hamiltonism of Q(Ln,p ), when (p + 1) |n, is shown constructively in the next section. 3. The Gray codes We adopt the convention that lower case bold letters represent length-n binary strings, e.g., x = x1 x2 . . . xn ; and we use the same group of letters to denote a set A and an ordered list A for a set A. A list A for the set A ⊂ {0, 1}n is equivalent to an order relation on A: x < y iff x precedes y in A. For example, if x = y ∈ {0, 1}n and i is the leftmost position with xi = yi then: • the lexicographic order is given by: x < y iff xi is even (= 0), and yi is odd (= 1); i • the reflected Gray code order due to Frank Gray in 1953 [5] is given by: x < y iff j =1 xj i is even (and j =1 yj is odd). We say that an order relation < on a set of strings induces a k-Gray code if the set listed in < order yields a k-Gray code, i.e., successive strings differ in at most k positions. So, the reflected Gray code order above induces a 1-Gray code on {0, 1}n ; and its restriction to the strings with fixed density (i.e., strings in {0, 1}n with a constant number of 1’s) induces a 2-Gray code, called revolving door code by Nijenhuis and Wilf [10]. According to [13] we recall the following definition which gives another order relation on binary strings and all of those presented here are particular cases of genlex order [14], that is, any set of strings listed in such an order has the property that strings with a common prefix are contiguous. Definition 6. We say that xis less than y in local reflected order, denoted by x ≺ y, if i i j =1 (1 − xj ) is odd and j =1 (1 − yj ) is even, where i is the leftmost position with xi = yi . Remark 7. (1) x ≺ y iff the prefix x1 x2 . . . xi contains an odd number of 0’s. (2) x ≺ y iff x > y in reflected Gray code order, with x and y the bitwise complement of x and y. (3) As the reflected Gray code order, the local reflected order ≺ induces a 1-Gray code on {0, 1}n and a 2-Gray code on length-n binary strings with fixed density. (4) In [13] it is shown that, unlike the reflected Gray code order, the local reflected order ≺ induces a 1-Gray code on the set Fn,p . The main result of this section is Corollary 12 and Theorem 13 which say that ≺ induces also a minimal Gray on the set Ln,p , of order p length-n Lucas strings.
194
J.-L. Baril, V. Vajnovszki / Theoretical Computer Science 346 (2005) 189 – 199
If z is a length-k string, we denote by zn/k the length-n prefix of the infinite string zzz . . ., or equivalently, zn/k = zz . . . z zr , n/k
where r = n mod k, and zr is the length-r prefix of z. In the following, the length-(p + 1) binary string = 1 . . . 1 00 p−1
plays a central role for our purposes. Let Fn,p and Ln,p be the lists obtained by ordering the sets Fn,p and Ln,p , respectively, by the relation ≺. In [13] it is proved that the first and the last strings of Fn,p are first(Fn,p ) = 0(n−1)/(p+1) and last(Fn,p ) = n/(p+1) . The next lemma gives similar results for Ln,p . Lemma 8. (1) first(Ln,p ) = 0(n−1)/(p+1) . (2) last(Ln,p ) = (n−1)/(p+1) 0. j Proof. 1. Let f1 f2 . . . fn = 0(n−1)/(p+1) and 1 j n such that i=1 (1 − fi ) is even, then: (1) j > 0 and fj = 0, and (2) fj −1 is the rightmost 1 bit in a contiguous 1’s sequence of length p − 1 and, by Definition 6, 0(n−1)/(p+1) has no predecessor in Ln,p in ≺ order. The proof of 2 is similar, the string (n−1)/(p+1) 0 has no successor in Ln,p . Now we describe how we compute the successor of a string in the lists Fn,p and Ln,p . Since in the lists Fn,p and Ln,p strings with a common prefix are contiguous, the successor of x ∈ Fn,p (resp. of x ∈ Ln,p ) is given by changing the rightmost bit in x such that the obtained string remains in Fn,p (resp. in Ln,p ), and it is greater than x in ≺ order. More formally we have: Lemma 9. Let x = last(Fn,p ) and s(x) its successor in Fn,p , then either 1, 2 or 3 below holds. (1) x contains an odd number of 0’s and it has not a suffix of the form 1p−1 0. In this case s(x) = x1 . . . xn−1 (1 − xn ). (2) x contains an even number of 0’s and ends by 1p−1 0. Then s(x) = x1 . . . xn−2 0xn . (3) x contains an even number of 0’s and does not end by 1p−1 0, or it contains an odd number of 0’s and ends by 1p−1 0. Let x1 x2 . . . xk−1 xk be the length minimal prefix of x with an odd number of 0’s and such that x = x1 x2 . . . xk−1 xk 0(n−k−1)/(p+1) (with (n−k−1)/(p+1) possibly empty). In this case s(x) = x1 x2 . . . xk−1 (1 − xk )0 (n−k−1)/(p+1) . Note that if x is like described in point 3 of Lemma 9 then the required prefix x1 x2 . . . xk−1 xk always exists. For example, in F6,3 we have: by point 1, s(010011) = 010010; by point 2, s(000110) = 000100; and by point 3, s(100100) = 100110 and s(100110) = 110110. In
J.-L. Baril, V. Vajnovszki / Theoretical Computer Science 346 (2005) 189 – 199
195
[13] a similar idea is used to compute, in constant time, the successor s(x) of a Fibonacci string x. Obviously, if x is a Lucas string then s(x) is a Fibonacci string but not necessarily a Lucas string too. The next proposition states that if we denote by succ(x) the successor of x ∈ Ln,p in the list Ln,p then succ(x) is either s(x), s 2 (x) = s(s(x)) or s 3 (x) = s(s(s(x))). Proposition 10. Let x ∈ Ln,p , x = last(Ln,p ) and s(x) ∈ Ln,p ; then either 1 or 2 below holds. (1) (p + 1)|n and x = 1k 00(n−k−2)/(p+1) with 0 k < p − 1. In this case succ(x) = 1k+1 0(n−k−3)/(p+1) 0 = s 2 (x). (2) x = 1k z1 0 with 0 < k, < p − 1 and k + p − 1. In this case succ(x) = 1k s(z)1 0 = s 3 (x). Proof. When s(x) is not a Lucas string then it is obtained from x by changing the 0 bit which either follows a 1’s prefix or is in the last position. Remark 11. (1) If (p + 1)|n then there exist exactly p − 1 Lucas strings as in point 1 of Proposition 10, one for each k, 0 k < p − 1. In addition, if x is such a string and d denotes the Hamming distance then (a) d(x, succ(x)) = d(x, s 2 (x)) = 2, (b) the string v = 1k 00(n−k−3)/(p+1) 0 ∈ Ln,p is the predecessor of x in ≺ order (i.e., succ(v) = x) and d(v, succ(x)) = 1. (In fact v = x · succ(x), the bitwise product of x and succ(x).) (2) If x is a Lucas string as in point 2 of Proposition 10 then d(x, succ(x)) = d(1k z1 0, 1k z 1 0) = d(z, z ) = 1. This remark proves the following: Corollary 12. (1) If (p + 1) |n then Ln,p is a 1-Gray code for Ln,p . (2) If (p + 1)|n then Ln,p is a 2-Gray code for Ln,p and there are exactly p − 1 strings with d(x, succ(x)) = 2.
196
J.-L. Baril, V. Vajnovszki / Theoretical Computer Science 346 (2005) 189 – 199
Table 1 The lists L4,2 and L4,3 L4,2
L4,3
0100 0101 0001 0000 0010 1010 1000
0110 0100 0101 0001 0000 0010 0011 1010 1000 1001 1100
Changed bits are in bold-face.
0110
0110 0101
1100
1101
0100
0011
0010 0000
0001
1010
1000
1011
1001
(a)
0000
0110 1100
0101
0100
1010
0011
0010
0001
1000
0011
0010
1001
(b)
0000
1100
0101
0100
0001
1010
1000
1001
(c)
Fig. 1. (a) The Hamiltonian path F4,3 in Q(F4,3 ). (b) The ‘path’ L4,3 in Q(L4,3 ), dashed arcs connect distance-2 vertices. (c) An H(1, 2)-path in Q(L4,3 ).
Theorem 13. Ln,p is a minimal change list for the set Ln,p . Proof. By Corollary 4, there are no more restrictive Gray code as Ln,p .
See Table 1 and Fig. 1(b) for the list L4,2 and L4,3 .
4. Graph theoretic issues Here we present some graph theoretic consequences of the previous results. 4.1. Hamiltonicity For a graph G let Gk be its kth power, where edges connect vertices which are linked by a path in G of length at most k. A k-Gray code for B ⊂ {0, 1}n is a Hamiltonian path for Qkn |B, the restriction of the kth power of the hypercube to the set B. Generally, (Qn |B)k is a subgraph of Qkn |B and equality holds if Hamming distance and the shortest path length coincide on Qn |B; this is the case for B = Fn,p or Ln,p , but not for Dyck words for instance, since the restriction of Qn to length-n Dyck words is not a connected graph.
J.-L. Baril, V. Vajnovszki / Theoretical Computer Science 346 (2005) 189 – 199
197
As in Section 2, let Q(Ln,p ) = Qn |Ln,p denote the Lucas cube. Corollary 12 says that Ln,p is a Hamiltonian path in: • the Lucas cube iff (p + 1) |n; • the second power of the Lucas cube elsewhere. (In general, Q(Ln,p ) is not 2-connected as it may be checked for L3,2 , and so, the Hamiltonicity of its second power cannot be obtained trivially from a well-known result in graph theory). Corollary 14. If (p + 1)|n then (1) the minimal number of paths covering Q(Ln,p ) is p; (2) the length of the maximal path in Q(Ln,p ) is card(Ln,p ) − p + 1. Proof. Point 1 follows from Corollary 12. For point 2, from Remark 11, it results that by bypassing in Ln,p the p − 1 strings y = succ(x), with d(x, y) = 2, we obtain a maximal length path in Q(Ln,p ). When a graph does not have a Hamiltonian path it may be desirable to visit each vertex but not necessarily once, such that the Hamming distance between two successive vertices is one. Following [12], a graph is in the class H(s, t) if it has a path that visits every vertex at least s times and at most t times, and such a path is called H(s, t)-path. Thus a graph is in H(1, 1) exactly if it is Hamiltonian. In this context, we have: Corollary 15. If (p + 1)|n then Q(Ln,p ) is in H(1, 2). Proof. When (p+1)|n, by point 1(a) of Remark 11, in the list Ln,p there are strings x which differ from succ(x) in two positions. For each such string, we insert v—the predecessor of x, see point 1(b) of Remark 11—between x and succ(x) and one obtains an H(1, 2) path in Q(Ln,p ). Notice that in the H(1, 2) paths above exactly p − 1 strings are visited twice, and this is optimal. See Fig. 1(c) for an H(1, 2) path in Q(L4,3 ). 4.2. Some structural properties Let us now recall some definitions concerning a connected graph G with vertices set V : • the eccentricity of a vertex v is e(v) = maxu∈V d(u, v), • the diameter of G is diam(G) = maxu,v∈V d(u, v) = maxv∈V e(v), • the radius of G is rad(G) = minv∈V e(v), and • the center of G is Z(G) = {u ∈ G | e(u) = rad(G)}. The next proposition generalizes similar results presented in [9] for Ln,2 . Proposition 16. Let n1, p 2. n − 1 if p = 2 and n odd, (1) diam(Q(Ln,p )) = n otherwise, (2) e(0n ) = n − pn , (3) rad(Q(Ln,p )) = n − pn and Z(Q(Ln,p )) = {0n }.
198
J.-L. Baril, V. Vajnovszki / Theoretical Computer Science 346 (2005) 189 – 199
Proof. 1. Let x = 1010 . . . (xi = 1 iff i is odd) and y = 0101 . . . (yi = 1 iff i is even). If p = 2 and n is even or if p > 2 then x, y ∈ Ln,p and they are at maximal distance equal to n. If p = 2 and n is odd there does not exist a pair of strings in Ln,p at distance n and it is easy to find two strings at distance n − 1. 2. Let v = 1p−1 0 . . . 1p−1 01k 0 with 0 k p−1. Clearly, v ∈ Ln,p and it has a minimum number of 0’s, namely n/p, or equivalently, a maximal number of 1’s, equal to n− n/p, So, e(0n ) = d(0n , v) = n − n/p. The same result can be obtained by replacing v by any of its circular shifts. 3. For any Lucas string u = 0n we construct another Lucas string at distance greater than n − n/p to u. The bitwise product v · x of a Lucas string v by a binary (not necessarily Lucas) string x is a Lucas string and d(x, v · x) equals the number of positions i where vi = 0 and xi = 1. Let u ∈ Ln,p , u = 0n , u its bitwise complement and v a circular permutation of the string 1p−1 0 . . . 1p−1 01k 0 given in point 2, such that u and v have at least one 0 in the same position. v · u ∈ Ln,p and since v has exactly n/p 0’s and at least one of them corresponds to a 0 in u one has d(u, v · u) < n/p. By the triangle inequality d(u, v · u) + d(v · u, u) d(u, u) = n and so d(u, v · u) n − d(u, v · u) > n −
n . p
A stable set of a graph is a subset of vertices such that there are not two adjacent vertices and the stability number, denoted by (G), is the number of vertices in a stable set of maximum cardinality. Proposition 17. (Q(Ln,p )) = max(card(Ln,p ), card(Ln,p )) where {Ln,p , Ln,p } is the bipartition of Ln,p . Proof. Let A be the set of maximum cardinality between Ln,p and Ln,p , and B the other set. Clearly, A is stable and we will prove that any stable set has at most the same cardinality as A. By Corollaries 4 and 12, the successor succ(x) of x in the list Ln,p induces an injective function succ : B → A; in addition, x ∈ B and succ(x) ∈ A are connected in Q(Ln,p ). Thus, if a stable set contains x ∈ B then it must not contain succ(x) ∈ A, and so the cardinality of a stable set does not exceed that of A. 5. Algorithmic considerations In [13] is given an exhaustive generating algorithm for the list Fn,p which runs with constant delay between any two successive strings. Now we show how one can modify this algorithm in order to produce efficiently the list Ln,p . Proposition 10 guarantees that at most two Fibonacci strings exist between any two consecutive Lucas string in Ln,p ; and by point 2 of Lemma 8 the last string in Ln,p is followed by at most one Fibonacci string. So, the algorithm in [13] can be modified to
J.-L. Baril, V. Vajnovszki / Theoretical Computer Science 346 (2005) 189 – 199
199
generate the list Ln,p by simply bypassing the Fibonacci strings which are not Lucas strings. The obtained algorithm inherits the constant delay property if one can decide, in constant time, if the current generated Fibonacci string is also a Lucas string. Additional variables, as (1) the length of the contiguous prefix of 1’s and (2) the length and the first position of the rightmost contiguous sequence of 1’s, can be used to distinguish in constant time Fibonacci from Lucas strings. Acknowledgements We thank Olivier Togni who presented us the problem we deal with in this paper and for some technical suggestions. References [2] J.-L. Baril, V. Vajnovszki, Gray codes for order p Lucas strings, in: T. Harju, J. Karhumäki (Eds.), Proc. 4th Internat. Conf. on Combinatorics on Words, September 2003, Turku, Finland, TUCS General Publication, No. 27, August 2003, pp. 149–158. [3] E. Dedó, D. Torri, N. Zagaglia Salvi, The observability of the Fibonacci and the Lucas cubes, Combinatorics ’98 (Palermo), Discrete Math. 255 (1–3) (2002) 55–63. [4] P. Flajolet, R. Sedgewick, Introduction à l’analyse des algorithmes, Thomson Publishing, 1996. [5] F. Gray, Pulse code communication, US Patent 2632058, 1953. [6] W.-J. Hsu, Fibonacci cubes—a new interconnection topology, IEEE Trans. Parallel Distrib. Systems 4 (1) (1993) 3–12. [7] J.C. Lagarias, D.P. Weisser, Fibonacci and Lucas cubes, Fibonacci Quart. 19 (1) (1981) 39–43. [8] J. Liu, W.-J. Hsu, M.J. Chung, Generalized Fibonacci cubes are mostly Hamiltonian, J. Graph Theory 18 (8) (1994) 817–829. [9] E. Munarini, C. Perelli Cippo, N. Zagaglia Salvi, On the Lucas cubes, Fibonacci Quart. 39 (1) (2001) 12–21. [10] A. Nijenhuis, H.S. Wilf, Combinatorial Algorithms for Computers and Calculators, Academic Press, New York, 1978. [12] G. Pruesse, F. Ruskey, Generating linear extensions fast, SIAM J. Comput. 23 (1994) 373–386. [13] V. Vajnovszki, A loopless generation of bitstrings without p consecutive ones, Discrete Mathematics and Theoretical Computer Science, Springer, Berlin, 2001, pp. 227–240. [14] T.R. Walsh, Generating Gray codes in O(1) worst-case time per word, DMTCS03, Lecture Notes in Computer Science, Vol. 2731, Springer, Berlin, 2003, pp. 72–88. [15] J. Wu, Extended Fibonacci cubes, IEEE Trans. Parallel Distrib. Systems 8 (12) (1997) 1203–1210.
Theoretical Computer Science 346 (2005) 200 – 225 www.elsevier.com/locate/tcs
The discrete Green Theorem and some applications in discrete geometry夡 S. Brlek, G. Labelle, A. Lacasse∗ LaCIM, Université du Québec à Montréal, C. P. 8888 Succursale “Centre-Ville”, Montréal (QC), Canada H3C 3P8
Dedicated to the memory of Alberto Del Lungo
Abstract The discrete version of Green’s Theorem and bivariate difference calculus provide a general and unifying framework for the description and generation of incremental algorithms. It may be used to compute various statistics about regions bounded by a finite and closed polygonal path. More specifically, we illustrate its use for designing algorithms computing many statistics about polyominoes, regions whose boundary is encoded by four letter words: area, coordinates of the center of gravity, moment of inertia, set characteristic function, the intersection with a given set of pixels, hook-lengths, higher order moments and also q-statistics for projections. © 2005 Published by Elsevier B.V. Keywords: Discrete Green Theorem; Discrete geometry; Polyominoes
1. Introduction The classical Green’s Theorem may be seen as a generalization of the Fundamental Theorem of Calculus and links surface integrals to contour integrals. More precisely, for
夡 The
work was supported by NSERC (Canada).
∗ Corresponding author.
E-mail addresses:
[email protected] (S. Brlek),
[email protected] (G. Labelle),
[email protected] (A. Lacasse). 0304-3975/$ - see front matter © 2005 Published by Elsevier B.V. doi:10.1016/j.tcs.2005.08.019
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
201
s=(0,0) (a)
(b)
Fig. 1. (a) A typical polyomino; (b) a closed curve but not a polyomino.
any convenient closed region of the plane with boundary () we have jQ jP − dx dy = P (x, y) dx + Q(x, y) dy. jy jx () This is particularly true for regions defined on regular lattices such as square, hexagonal or triangular lattices of the plane. On the other hand, many basic parameters associated with closed regions are represented by surface integrals. For instance, the area A(), center of gravity CG(), moment of inertia I(), of a closed region are defined by the double integrals x dx dy y dx dy dx dy, CG() = (x, ¯ y) ¯ = A() = , , A() A() ((x − x) ¯ 2 +(y − y) ¯ 2 ) dx dy= (x 2 +y 2 ) dx dy − (x¯ 2 + y¯ 2 )A(). I()=
In this paper we restrict the study to regions that are commonly used in discrete geometry, namely the polyominos, but one should keep in mind that a more general formulation could be presented. A polyomino P is a finite union of closed cells in the unit lattice square (pixels) of the plane whose boundary (P) consists of a simple closed polygonal path (see Fig. 1(a)). In particular, our polyominoes are simply connected (contain no holes), and have no multiple points (see Fig. 1(b)). The polygonal path (contour) of a polyomino is encoded by an ordered pair (s, w) where s is a lattice point belonging to and w is a word over the 4-letter alphabet A = {r, u, l, d} = {r :→
u :↑
l :←
d :↓}
also known as the Freeman chain code [9,10], where the letters correspond to the unit translations in the lattice directions: right, up, left and down. The word w represents the perimeter of the polyomino read in a counterclockwise way starting from the point s. The use of s may be avoided in the encodings by assuming that s is always the lowest left most point of the polyomino and that s = (0, 0) by using a suitable translation. In this way, the polyomino of Fig. 1(a) is encoded by the single word w = rrddrurruurdruururullldluululldddldldd.
202
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
Area= 26 Center of gravity = (3.65, 1.54) Moment of inertia = 152.68 Horizontal projections = (1,2,3,4,5,5,3,2,1) Vertical projections = (1,2,4,9,6,3,1)
Fig. 2. Some parameters for polyominoes.
Since polyominoes are given by words describing their contours, it is natural to use Green’s Theorem for the construction of our first general algorithms in order to compute not only some basic statistics such as the area, center of gravity, moment of inertia, projections (see Fig. 2) but the boolean operations on the underlying sets as well. In Section 2, we introduce the notion of incremental algorithm for polyominoes given by their contour and show how Green’s Theorem can be used to generate families of such algorithms. In Section 3, we drop the continuity conditions of Green’s Theorem and deal with general additive incremental algorithms for which the output associated with the sum of two polyominoes is the sum of the outputs associated to each polyomino. More general algorithms are then obtained by the use of weight functions W : Z × Z − → A. In particular, if W is the boolean valued characteristic function of a point, then the output of the algorithm is boolean valued and decides if a given pixel belongs to a given polyomino. This result extends to sets of pixels, providing the computation of the set characteristic function and some particular instances such as the size of hook-lengths. Higher order moments are also obtained in this way when the weight function involves Stirling numbers of the second kind. When A is a ring of formal Laurent power series, the use of q-analogues yields the simultaneous computation of both the horizontal and vertical projections. The power and effectiveness of Green’s Theorem already appeared in the literature. More precisely, it is useful for region filling (see for example [15]) and also for the efficient computation of the moments of closed regions [14,17,18]. Our present approach is similar to the one given in [14,17,18], but differs by the choice of the Stirling numbers instead of the Bernouilli numbers. For a general presentation of polyominoes and their properties see [11]. A survey of enumerative results concerning polyominoes can be found in [16] (see also [2,4,7]). The core of the third author’s Master thesis [12] contains in full detail—but is not limited to—the results presented here with numerous examples. 2. Green’s Theorem and incremental algorithms The following version of Green’s Theorem [13] is sufficient to start our analysis. Theorem 1. Let P (x, y), Q(x, y) be two continuously differentiable functions on an open set containing a simply connected region bounded by a simple piecewise continuously
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
203
differentiable positively oriented curve . Then jQ jP P (x, y) dx + Q(x, y) dy. − dx dy = jy jx Since the above parameters involve integrals of the form f (x, y) dx dy,
where will be a polyomino, our next step is to choose P (x, y) and Q(x, y), in Green’s Theorem, such that (jQ/jx − jP /jy) = f . There are many ways to achieve this and three solutions are provided in the following useful lemma. Lemma 2. Let P be a polyomino with contour , and let f (x, y) be a R-valued continuous function. Then, f (x, y) dx dy = f1 (x, y) dy (1) P = − f2 (x, y) dx (2) = F (x, y)(x dy − y dx), (3)
where
x
f1 (x, y)= F (x, y) =
1
f (u, y) du,
f2 (x, y) =
y
f (x, v) dv,
f (sx, sy)s ds.
0
t dt means indefinite integration. The notation denotes a line integral along while Proof. For (1), take P = 0, Q = f1 in Green’s Theorem. For (2), take P = −f2 , Q = 0. Formula (3) is more delicate and can be established as follows. Take, in Green’s Theorem, P (x, y) = −yF (x, y) and Q(x, y) = xF (x, y). We must show that (jQ/jx − jP /jy) = f . In order to do this, note first that jQ jP jF jF − = 2F + x +y . jx jy jx jy Next, consider an extra variable u such that 0 < u1. Then, 1 2 2 u F (ux, uy) = u f (sux, suy)s ds u0 = f (x, y) d (via = su). 0
Differentiating with respect to u gives 2uF (ux, uy) + u2
jF jF (ux, uy)x + u2 (ux, uy)y = uf (ux, uy). jx jy
204
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
vi+1
vi
vi
vi+1 0
0
Fig. 3. A positive and a negative triangle.
Finally, taking u = 1, one obtains the desired equality jF jF 2F + x +y = f. jx jy Remark 3. The above proof of (3) uses Green’s Theorem but it is more algebraic than geometric. An alternate geometric proof of (3), not using Green’s Theorem, is provided now. Its advantage relies on the fact that it may be adapted to any piecewise continuously differentiable curve . Alternate geometric proof of (3): Let v0 , v1 , . . . , vn be the successive vertices of the contour of P. For any two successive vertices vi and vi+1 on , consider the triangle Ti whose vertices are 0, vi and vi+1 taken in this order. The triangle Ti is considered to be positive if the angle defined by the vectors vi and vi+1 is positive and Ti is negative otherwise (see Fig. 3). We obviously have, n−1 f (x, y) dx dy = f (x, y) dx dy. P
i=0
Ti
Now let vi = (xi , yi ) and vi+1 = (xi+1 , yi+1 ) = (xi +xi , yi +yi ) and take the following parametrization for the triangle Ti : x = x(s, t) = s(xi + txi ),
y = y(s, t) = s(yi + tyi ),
where 0 s 1 and 0 t 1. The Jacobian of this transformation is j(x, y) = s(xi yi − yi xi ). j(s, t) By the change of variables for double integrals, we have, for i = 0, 1, . . . , n − 1 : 1 1 j(x, y) f (x, y) dx dy = f (x(s, t), y(s, t)) ds dt j(s, t) Ti 0 0 1 1 f (s(xi + txi ), s(yi + tyi ))s(xi yi − yi xi ) ds dt = 0 0 1 F (xi + txi , yi + tyi )(xi yi − yi xi ) dt = 0 = F (x, y)(x dy − y dx). [vi ,vi+1 ]
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
205
2.1. Incremental algorithms The evaluation of each line integral (1)–(3) of Lemma 2 can be broken into simpler integrals over successive unit (horizontal or vertical) line segments forming : n−1 = ,
i=0
[vi ,vi+1 ]
where vi = (xi , yi ), i = 0, . . . , n − 1, denote the successive vertices of the contour of P, and satisfy vn = v0 , vi+1 = vi + vi = (xi + xi , yi + yi ). Since polyominoes are coded by (s, w) where s ∈ Z × Z is the starting point and w is a word over the alphabet A = {r, u, l, d}, the translation into incremental algorithms follows easily: start from the source point s and traverse the contour (P ) = by reading w letter by letter. At each step, the performed action depends only on the current position on (P ) and on the letter read. More precisely, consider four vectors identified with the letters of A r = (1, 0),
u = (0, 1),
l = (−1, 0),
d = (0, −1)
and take four functions indexed by A, r (x, y),
u (x, y),
l (x, y),
d (x, y).
Now read the word w = w1 w2 . . . wn sequentially from the left, cumulating the partial sums as follows, where wi is the vector corresponding to the letter wi : v := (x0 , y0 ); S := 0; for i := 1 to n do S := S + wi (v); v := v + wi end for return S. Hereafter an incremental algorithm is denoted by • = d , h , g , b and the following suggestive notation represents its output: Output(•, P) = r (xi , yi ) + u (xi , yi ) + l (xi , yi ) + d (xi , yi ). →
←
↑
↓
The formulas (1), (2) and (3) of Lemma 2 yield the corresponding incremental algorithms called, respectively, V-algorithm, H-algorithm and VH-algorithm, where the letters V and H stand for the vertical and horizontal directions: in a V-algorithm (resp. H-algorithm) only vertical (resp. horizontal) sides of the polyomino are used, while in a VH-algorithm both vertical and horizontal sides are used. Proposition 4 (Green’s type algorithms). Let P = (s, w) and f (x, y) be continuous. Then, f (x, y) dx dy = r (xi , yi ) + u (xi , yi ) + l (xi , yi ) + d (xi , yi ), P
→
↑
←
↓
206
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
where the functions r , u , l , d are taken from any of the following three sets of possibilities: 1 1 V-algo. r = 0, u = 0 f1 (x, y + t) dt, l = 0, d = − 0 f1 (x, y − t) dt. 1 1 H-algo. r = − 0 f2 (x + t, y) dt, u = 0, l = 0 f2 (x − t, y) dt, d = 0. 1 1 VH-algo. r = −y 0 F (x + t, y) dt, u = x 0 F (x, y + t) dt, 1 1 d = −x 0 F (x, y − t) dt, l = y 0 F (x − t, y) dt, where f1 (x, y), f2 (x, y) and F (x, y) are defined by Lemma 2. Proof. Let be any one of the three differential forms f1 (x, y)dy,
−f2 (x, y) dx,
F (x, y)(x dy − y dx)
appearing in the line integrals (1), (2), (3) of Lemma 2. Then,
f (x, y) dx dy = P
=
n−1 i=0
[vi ,vi+1 ]
,
where v0 , v1 , . . . , vn−1 , vn (= v0 ) are the vertices of the contour of P. Now if (s, w) encodes P, with the starting point (x0 , y0 ) and the 4-letter word w = w1 w2 . . . wn , then the side [vi , vi+1 ] of the contour is parametrized by (x, y) = (x(t), y(t)), 0 t 1, where x = x(t) = xi + t,
y = y(t) = yi
(dx = dtdy = 0)
if wi+1 = r,
x = x(t) = xi ,
y = y(t) = yi + t
(dx = 0dy = dt)
if wi+1 = u,
x = x(t) = xi − t,
y = y(t) = yi
(dx = −dt, dy = 0)
if wi+1 = l,
x = x(t) = xi ,
y = y(t) = yi − t
(dx = 0, dy = −dt) if wi+1 = d.
We conclude by evaluating the line integrals (1), (2), (3) of Lemma 2 using the corresponding parametrizations. 2.2. Elementary applications and examples The tables below contain elementary instances of these algorithms for the computation of P f (x, y) dx dy and some computations are carried out on the simple polyomino w = rrdrrululululddd and s = (0, 0):
Below are listed the algorithms for the area (Table 1), where f (x, y) = 1; for the center of gravity (Table 2), where f (x, y) = x and f (x, y) = y; and for the moment of inertia
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
207
Table 1 Area Algorithm
r
u
l
d
V H VH
0 −y −y/2
x 0 x/2
0 y y/2
−x 0 −x/2
2 2 (Table 3), where f (x, y) = x +y . • V-algo for the area: → 0 + ↑ xi + ← 0 + ↓ − xi , 1 dx dy = 0 + 0 − x3 + 0 + 0 + x5 + 0 + x7 + 0 + x9 + 0 + x11 P
+ 0 − x13 − x14 − x15 = −2 + 4 + 3 + 2 + 1 − 0 − 0 − 0 = 8. • VH-algo for the area: → − yi /2 + ↑ xi /2 + ← yi /2 + ↓ − xi /2, 1 dx dy = −y0 /2−y1 /2−x2 /2 − y3 /2 − y4 /2 + x5 /2 + y6 /2 − y7 /2 + y8 /2 P
−x9 /2 + y10 /2 + x11 /2 + y12 /2 − x13 /2 − x14 /2 − x15 /2 = −1 + 1/2 + 1/2 + 2 + 3/2 + 1/2 + 1 + 1 + 1/2 + 3/2 = 8. • V-algo for x¯ of the center of gravity: → 0 + ↑ xi2 /2 + ← 0 + ↓ − xi2 /2, P
x dx dy = 0 + 0 − x22 /2 + 0 + 0 + x52 /2 + 0 + x72 /2 + 0 + x92 /2 + 0 2 2 2 2 + x11 /2 + 0 − x13 /2 − x14 /2 − x15 /2
= (−22 + 42 + 32 + 22 + 12 )/2 = 26/2 = 13. • V-algo for the integral involved in the moment of inertia: (x 2 + y 2 ) dx dy = xi3 /3 + xi yi2 + xi yi + xi /3 P
↑
+
↓
− xi3 /3 − xi yi2 + xi yi − xi /3 = 425/24.
• We compute now the probability that a random point (x, y) ∈ R × R, under a normal bivariate probability distribution, f (x, y) = (1/) exp(−x 2 − y 2 ), falls in a given polyomino P. In this case the VH-algorithm is complicated and only the V and H-algorithms are given (Table 4). Discrete probability distributions (such as uniform distributions over rectangles) will be considered in the next section. Due to its formulation, the VH-algorithm is in general more complicated than the corresponding V and H-algorithms. There is, however, an important class of functions for which the VH-algorithm is generally preferable: the class of homogeneous functions, i.e. functions f (x, y), satisfying a functional equation of the form f (sx, sy) = s k f (x, y) for a constant k, called the degree of homogeneity. The VH-algorithm is given now.
208
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
Table 2 Center of gravity Algorithm
r
u
l
d
V (num x) ¯ (num y) ¯
0 0
x 2 /2 x/2 + xy
0 0
−x 2 /2 x/2 − xy
H (num x) ¯ (num y) ¯
−y/2 − xy −y 2 /2
0 0
−y/2 + xy y 2 /2
0 0
VH (num x) ¯ (num y) ¯
−xy/3 − y/6 −y 2 /3
x 2 /3 xy/3 + x/6
xy/3 − y/6 y 2 /3
−x 2 /3 −xy/3 + x/6
Table 3 Moment of inertia V
r = 0 l = 0
u = x/3 + xy + x 3 /3 + xy 2 d = −x/3 + xy − x 3 /3 − xy 2
H
r = −y/3 − xy − x 2 y − y 3 /3 l = y/3 − xy + x 2 y + y 3 /3 r = −y/12 − xy/4 − x 2 y/4 − y 3 /4 l = y/12 − xy/4 + x 2 y/4 + y 3 /4
u d u d
VH
=0 =0 = x/12 + xy/4 + x 3 /4 + xy 2 /4 = −x/12 + xy/4 − x 3 /4 − xy 2 /4
Table 4 √ f (x, y) = (1/) exp(−x 2 − y 2 ), erf(x) = (2/ ) 0x exp(−t 2 ) dt V
H
r = 0
u = 41 erf(x)(erf(y + 1) − erf(y))
l = 0
d = 41 erf(x)(erf(y − 1) − erf(y))
r = − 41 erf(y)(erf(x + 1) − erf(x))
u = 0
l = − 41 erf(y)(erf(x − 1) − erf(x))
d = 0
Corollary 5. Let f (x, y) be continuous and homogeneous of degree k > −2. Assume that r = −
y (f1 (x + 1, y) − f1 (x, y)), k+2
u =
x (f2 (x, y + 1) − f2 (x, y)), k+2
l = −
y (f1 (x − 1, y) − f1 (x, y)), k+2
d =
x (f2 (x, y − 1) − f2 (x, y)), k+2
where f1 (x, y) and f2 (x,y) are defined in Lemma 2. Then the corresponding incremental VH-algorithm computes P f (x, y) dx dy, for any polyomino P. Proof. Let f (x, y) be homogeneous of degree k. Then the function F (x, y) of Proposition 4 takes the very simple form F (x, y) = 0
1
f (sx, sy)s ds = 0
1
s k+1 f (x, y) ds =
1 f (x, y). k+2
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
209
Hence, for the corresponding VH-algorithm, we have, 1 1 y r (x, y) = − F (x + t, y)y dt = − f (x + t, y) dt k+2 0 0 x+1 y y f (x, y) dx = − (f1 (x + 1, y) − f1 (x, y)), =− k+2 x k+2 by definition of f1 (x, y). The verification of the formulas for u , l and d is left to the reader. A typical illustration of Corollary 5, for which the VH-algorithm is simpler than the corresponding V or H-algorithms, is provided by the computation of the average euclidean distance from a given point (a, b) ∈ Z × Z to a random point in a polyomino P is given by the formula 2 2 P (x − a) + (y − b) dx dy , A(P) where A(P) is computed by some of our previous algorithms. We only need to compute the integral P f (x, y) dx dy. This is achieved easily by replacing the starting point s = (x0 , y0 ) by s − (a, b) = (x0 − a, y0 − b). It corresponds to the choice f (x, y) = x 2 + y 2 and k = 1 in Corollary 5. In this case, the functions f1 (x, y) and f2 (x, y) are given by the formulas 1 if y = 0, 2 x|x| f1 (x, y) = 1 1 2 2 2 2 2 otherwise, 2 x x + y + 2 y ln(x + x + y ) 1 if x = 0, 2 y|y| f2 (x, y) = 1 1 2 2 2 2 2 otherwise. 2 y x + y + 2 x ln(y + x + y ) Note that f1 (0, 0) = f2 (0, 0) = 0 by taking limits. 3. Additive incremental algorithms and applications In the foreseen examples, the function f (x, y) was assumed to be continuous. Nevertheless this much restrictive condition may be dropped by assuming, for example, that f is piecewise continuous in each variable, and we still may use Proposition 4 as a guideline for producing corresponding algorithms. Indeed, algorithms for the computation of horizontal and vertical projections of a polyomino can be found in this way: fix an integer and define f by f (x, y) = ( x < + 1),
where denotes the characteristic function. Then, P f (x, y) dx dy is clearly the -vertical projection of the polyomino P: f (x, y) dx dy = #{ ∈ Z|Pix, ⊆ P} = v (P), P
210
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
where Pix, denotes the unit pixel of the plane having the point (, ) ∈ Z × Z as its lowest left corner, that is:
Pix, = {(x, y) ∈ R × R|x < + 1, y < + 1}, and its closure (with condition x +1, y +1) is denoted Pix, . In this case, following Proposition 4, we find that x if x < , 0 (x < + 1) dx = x − if x < + 1, f1 (x, y) = 1 if + 1 x. This gives the following algorithm as the reader can easily check: V-algorithm for the vertical projection v (P): r = 0,
u = (x + 1),
l = 0,
d = − (x + 1).
Similarly, taking f (x, y) = ( y < + 1), the -horizontal projection of P #{ ∈ Z | Pix, ⊆ P} = h (P), is computed by the following algorithm: H-Algorithm for the horizontal projection h (P): r = − (y + 1),
u = 0,
l = (y + 1),
d = 0.
These algorithms for the projections are special instances of the general notion of additive incremental algorithm which we now define. Definition 6. An incremental algorithm • = r , u , l , d is additive if, whenever P = P1 ∪ P2 with disjoint interiors (see Fig. 4), we have Output(•, P) = Output(•, P1 ∪ P2 ) = Output(•, P1 ) + Output(•, P2 ). An example of a nonadditive incremental algorithm is given by the computation of a polyomino’s perimeter in which case r = u = l = d = 1. Proposition 7. An incremental algorithm • = r , u , l , d , where the ’s are Rvalued (or more generally A-valued where A is a ring) is additive if and only if l (x, y) = −r (x − 1, y) and
d (x, y) = −u (x, y − 1).
(4)
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
211
Fig. 4. P = P1 ∪ P2 with disjoint interiors.
( x,y)
P1 (x-1,y)
(x,y)
P1
( x,y +1)
( x +1,y +1)
P2
P2
( x,y)
( x+1,y)
(x,y-1) (a)
(b)
(c)
Fig. 5. (a) Vertical domino, (b) horizontal domino, (c) a pixel Pixx,y .
Moreover, the output of an additive incremental algorithm •, on a polyomino P is given by Output(•, P) = x u (, ) − y r (, ), (5) Pix, ⊆P
where x (x, y) = (x + 1, y) − (x, y) and y (x, y) = (x, y + 1) − (x, y). Proof. Since any polyomino P can be written as a finite union of the closure Pix, of its pixels P= Pix, , Pix, ⊆P
the output of an additive incremental algorithm satisfies Output(•, Pix, ). Output(•, P) = Pix, ⊆P
In particular, if P1 , P2 are both single pixels and P is a vertical domino as in Fig. 5(a), then, Output(•, P) = Output(•, P1 ∪ P2 ) = Output(•, P1 ) + Output(•, P2 ). Hence l (x, y) = −r (x − 1, y) in order to cancel the contribution of the common horizontal edge of the domino P. A similar argument (see Fig. 5(b)) shows that using an horizontal domino d (x, y) = −u (x, y − 1). This shows that the stated conditions are necessary for additivity. Their sufficiency follows from the automatic cancellation of the common boundaries of P1 and P2 (see Fig. 5)
212
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
for general polyominoes with disjoint interiors such that P = P1 ∪ P2 . The formula for Output(•, P) also follows from these conditions since for any closed pixel Pix, , we must have (see Fig. 5(c)), for any additive incremental algorithm, Output(•, Pix, ) = r (, ) + u ( + 1, ) + l ( + 1, + 1) + d (, + 1) = r (, ) + u ( + 1, ) − r (, + 1) − u (, ) = x u (, ) − y r (, ).
Proposition 7 may be used for proving, for instance, that a given additive incremental algorithm is actually correct. Indeed, one can check by using it, that the above algorithms for the projection v (P) and h (P) are valid. The validity of the boolean valued additive incremental algorithms in the next sections can also be checked with it. Another use of this proposition is to produce new algorithms starting first from an arbitrary choice of functions r (x, y), u (x, y); secondly, by defining the associated functions l (x, y), d (x, y) from (4); and, finally, by computing the corresponding output using (5). See Section 3.4 for such an example. The next corollary may be considered as an inverse of Proposition 7. It shows how to find r (x, y), u (x, y), l (x, y), d (x, y) starting from the desired output. It also describes a close connection between general additive incremental algorithms and the bivariate calculus of finite differences. Corollary 8. Let A be a ring and W : Z × Z → A be a weight function associated with each pixel Pixx,y in the plane. Then, the most general additive incremental algorithm, • = r , u , l , d having the output W (x, y) ∈ A, Pixx,y ⊆P
for each polyomino P, is of the form r (x, y) = V 0 (x, y) + (x, y − 1) − (x − 1, y − 1), u (x, y) = U 0 (x, y) + (x − 1, y) − (x − 1, y − 1), l (x, y) = −r (x − 1, y), d (x, y) = −u (x, y − 1), where (U 0 (x, y), V 0 (x, y)) is a particular solution of the difference equation x U (x, y) − y V (x, y) = W (x, y) and : Z × Z → A is arbitrary. Proof. Since the difference equation is linear, it is sufficient to show (see Proposition 7) that the general solution of the associated homogeneous equation x U (x, y) − y V (x, y) = 0
(6)
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
213
is given by U (x, y) = (x − 1, y) − (x − 1, y − 1), V (x, y) = (x, y − 1) − (x − 1, y − 1),
(7) (8)
where (x, y) is arbitrary. Indeed, substituting (7) in (6) gives x U − y V = [((x, y) − (x, y − 1)) − ((x − 1, y) − (x − 1, y − 1))] −[((x, y) − (x − 1, y)) − ((x, y − 1) − (x − 1, y − 1))] = 0. Conversely, in order to show that for any solution (U, V ) of the homogeneous equation there corresponds a function , we introduce two auxiliary summation operators, x1 and y 1 , defined on functions g : Z × Z → A, by x g(k, y) if x > 0, k=1 x if x = 0, 1 g(x, y) = 0 − −x−1 k=0 g(−k, y) if x < 0, y
and similarly for 1 g(x, y). The reader can check that, for any function (x, y), we have, ∇ x (x, y) = (x, y)− (x − 1, y) = g(x, y) ⇐⇒ (x, y) = (0, y)+ x1 g(x, y), y ∇ y (x, y) = (x, y)− (x, y − 1) = g(x, y) ⇐⇒ (x, y) = (x, 0)+ 1 g(x, y), and that the required function (x, y) can be taken as y
(x, y) = c + 1 U (1, y) + x1 V (x, y + 1), where c is an arbitrary constant (c = (0, 0), in fact).
There exist many ways to find a particular solution (U 0 , V 0 ) of the equation x U − y V = W . One way is to force V 0 (resp. U 0 ) to be 0 and take U 0 (resp. V 0 ) to be a particular solution of the simpler difference equation x U (x, y) = W (x, y)
(resp. − y V (x, y) = W (x, y)),
with particular solution U 0 = x1 W (x − 1, y),
V0 = 0
y
(resp. U 0 = 0, V 0 = − 1 W (x, y − 1)).
This method provides a particular V-algorithm (resp. H-algorithm). Formal power series may also be used: let z1 and z2 be formal variables and consider the formal Laurent series
(z1 , z2 ) = U (x, y)zx zy , U 1 2 x,y
(z1 , z2 ) = V
(z1 , z2 ) = W
x,y
y
V (x, y)z1x z2 ,
x,y
y
W (x, y)z1x z2 .
214
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
Then the difference equation x U (x, y) − y V (x, y) = W (x, y) rewrites as
(z1 , z2 ) − (1 − z2 )z1 V
(z1 , z2 ) = z1 z2 W
(z1 , z2 ), (1 − z1 )z2 U
(z1 , z2 ) and V
(z1 , z2 ) by using algebraic manipulations. In fact, which is solved for U we used this method to find the general solution of the homogeneous equation appearing in the proof of Corollary 8. Another way to find solutions to the difference equation of Corollary 8 is to express, if possible, W (x, y) in the basis x (i) y (j ) , i, j 0, where t (k) = t (t − 1) . . . (t − k + 1) is the kth falling factorial power of t. Since t t (k) = kt (k−1) , this basis is well adapted to difference equations. This method is illustrated in Section 3.4 below for the computation of higher moments of a polyomino. 3.1. Deciding if a polyomino contains a given pixel Let (, ) ∈ Z × Z and consider the following boolean-valued function W, (x, y) = (x = ) (y = ). Since Pixx,y ⊆P
W, (x, y) = (Pix, ⊆ P) =
1 if Pix, ⊆ P, 0 otherwise,
then, the following additive incremental algorithms can be used to decide whether the pixel determined by (, ) belongs or not to a polyomino P. V-algorithm: r = 0, u = (x + 1) (y = ), l = 0, d = − (x + 1) (y = + 1). H-algorithm: r = − (x = ) (y + 1), u = 0, l = (x = + 1) (y + 1), d = 0. For example, the V-algorithm applied to Fig. 6(a) with (, ) = (3, 2) gives (only nonzero terms are listed): (Pix3,2 ⊆ P) = (x14 4) (y14 = 2) − (x16 4) (y16 = 3) + (x26 4) (y26 = 2) = 1 − 1 + 1 = 1 (since, Pix3,2 ⊆ P) and to Fig. 6(b) with (, ) = (6, 0) (Pix6,0 ⊆ P) = − (x18 7) (y18 = 1) + (x24 7) (y24 = 0) = −1 + 1 = 0 (since, Pix6,0 ⊆ P). ,
,
Of course, from Corollary 8, there is an uncountable family of algorithms r , u , ,
,
l , d from which one can compute (Pix, ⊆ P).
S. Brlek et al. / Theoretical Computer Science 346 (2005) 200 – 225
(a)
215
(b)
Fig. 6. (a) Pixel Pix3,2 in the polyomino (b) pixel Pix6,0 not in the polyomino.
vi′
vi′ (a)
vj′′
vj′′
vj′′
vi′
vj′′
vi′ (b)
(c)
(d)
Fig. 7. Matching pairs.
3.2. Boolean operations From the characteristic function , it is now straightforward to define formulas for the boolean operators on polyominoes. However, better results may be achieved with a bit of care. Let P1 and P2 be two polyominoes whose contours are given respectively by vi = (xi , yi ), for i = 0, 1, . . . , n1 − 1, and vj = (xj , yj ) for j = 0, 1, . . . , n2 − 1. Proposition 9. The number of pixels in P1 ∩ P2 is given by min(xi , xj )yi yj , #(P1 ∩ P2 ) = A(P1 ∩ P2 ) = 0 i f () > f () or f () > f () > f ()) then Increase the f ()th component of trans by one; resu ← resu ∪ {({f (), f ()}, trans )}; current ← current ∪ {(v , trans )}; Mark v ; current ← current \ {v}; Return (resu); end This result shows that all the information contained in a 2D-gon tiling is encoded in its de Bruijn graph. However, we will show that the de Bruijn graph contains much more
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
233
Fig. 6. Two tilings and their graphs with origins. Notice that, if one removes the origins, then the two graphs are isomorphic.
information than really needed to construct the tiling. Actually, we will show that the adjacency graph contains almost all the information we need. Indeed, it suffices to add two marks to the adjacency graph of T to be able to reconstruct the tiling T. This leads to the definition of the graph with origins of a tiling T. Definition 5 (Graph with origins of a tiling). Let T be a tiling of a 2D-gon, A = (V , E) its adjacency graph. The graph with origins associated with T is G = (V , E, v1 , v2 ), where v1 and v2 are two vertices in V called the origins of G and defined as follows. v1 is the tile of T on the first side of P with translation vector (0, . . . , 0). v2 is the tile having an edge on the hull of P, adjacent to v1 by a vertex on the hull of P and whose translation vector is either (1, 1, 0, . . . , 0) if v1 belongs also to the second side of the hull of P, or (1, 0, . . . , 0) otherwise. See Fig. 6 for an example. Notice that the addition of the two origins makes it possible to distinguish two different tilings which have isomorphic adjacency graphs, as shown for example in Fig. 6. We will show in the following that this is always true: the correspondence between the graphs with origins we defined and the 2D-gon tilings is one-to-one. 3. Duality In this section, we give an algorithm which computes the de Bruijn graph of a tiling from its graph with origins. This correspondence is one-to-one, therefore, together with Algorithm 1 and Theorem 1, it shows that the graphs we introduced can be considered as dual of the considered tilings, despite the fact that they are very close to adjacency graphs (they only have two additional marks). Our algorithm has complexity O(n · m), where n is the number of vertices of the graph, or equivalently the number of tiles of the tiling, and m is the sum of the multiplicities used to define the 2D-gon. In order to build the algorithm and prove its correctness, we will first prove some properties linking tilings of 2D-gons and their adjacency graphs. In particular, some special substructures, namely borders and fans, will play a very important role. We introduce them now, and prove some of their basic properties. Definition 6 (Border of a tiling). Let T be a tiling of a 2D-gon P. Let C ⊆ T be the set of tiles of T which have at least one point in H (P ). We define the border of T, denoted by B(T ) = (C, E), as follows: (t, t ) ∈ E if and only if t and t have one edge in common
234
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
Fig. 7. Left: a tiling. Right: its border and the border of its adjacency graph.
Fig. 8. Particular cases and their adjacency graphs. Bold is the border.
and if this common edge has at least one point in H (P ). Notice that this is a subgraph of the adjacency graph of T, but it is not the subgraph induced by C (some edges are missing). See Fig. 7. A remarkable property is that the border contains all vertices of degree less than 4 of the graph (i.e. degree 2 or 3), plus possibly some of the vertices of degree 4. In the following, we make no difference between the border of a tiling T and the associated path in the adjacency graph of T, called the border of the graph. 3.1. Properties of the border Every vertex of degree 2 or 3 is in the border. Moreover, there are vertices whose degree is 4. Particular cases can occur. The border of a tiling can thus have 3 possible shapes: • if there is a vertex whose degree for the border is 1, then M = (1, n). The tiling is just a juxtaposition of tiles of the same type, and the border is a line. See Fig. 8(left). • if there is a unique vertex of degree 4, then M = (1, 1, n), the tiling is an hexagon whose sides lengths are 1,1 and n. Then the border is the disjoint union of two cycles connected by the only vertex whose degree is 4. See Fig. 8(right). • in any other case, the border of the tiling is a cycle. The two first cases are easy to recognize: we are in the first one if and only if the adjacency graph is reduced to a path, we are in the second one if and only if the adjacency graph contains a cut node (i.e. a vertex whose deletion disconnects the graph). In those cases, the tiling is then easy to construct. In the following, we assume that we are not in one of those (pathological) cases. There is no loss of generality, from the remarks just above.
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
L1
L4
L2
L3
235
+ +
L3 L4
+
L2
+
Lp
L1 L
Fig. 9. A fan, and its corresponding half-lines.
Definition 7 (Fan). Given a tiling T of a 2D-gon P, a fan F of T is a p-tuple (f1 , f2 , . . . , fp ) of tiles in T such that: • ∀i p∈ {1, . . . , p − 1} fi and fi+1 have an edge in common, • i=1 fi is a point of H (P ), called the head of the fan, • f1 and fp have one edge on the hull of the 2D-gon. The tiles f1 and fp are called the endpoints of F , and the integer p − 1 is called the length of F . Moreover, we say that a fan F belongs to one side of P if one of its endpoints has an edge included in this side of P. Notice that two adjacent tiles on the hull having one edge in common constitute a particular fan of size 1. Informally, a fan can be seen as the neighborhood of its head. Remark. The border of a tiling is a concatenation of all the fans of the tiling. Moreover, the two origins given in the graph are the endpoints of a particular fan. For convenience, we introduce some notations about fans. Notation: Let F = (f1 , . . . , fp ) be a fan of a 2D-gon tiling T. For all i such that 1i p − 1, since fi and fi+1 have exactly one edge in common, there is a de Bruijn line, denoted by Li , which contains both fi and fi+1 . In addition, each Li can be split into two distinct parts, called half-lines, one containing fi and the other containing fi+1 . We denote − the part containing fi by L+ i , and the other one by Li . See Fig. 9. Notice that L (respectively Lp ), the Bruijn line different from L1 (respectively Lp−1 ) + + passing in f1 (respectively fp ), crosses L+ 1 , L2 , . . . , Lp−1 , in the order of increasing (respectively decreasing) indices starting from the fan. + + Finally, we remark that, starting from the fan, L− i successively crosses Li+1 , Li+2 , . . . , + + − − − Lp−1 and Lp , Li successively crosses Li−1 , Li−2 , . . . , L1 and L. Thus, two half-lines having same sign do not cross each other. Moreover, by construction, one may notice that, as a de Bruijn line, a half-line separates the set of tiles not contained in itself into two parts (formally, we first define, for each tile t of Li , the representing line segment of t as the closed line segment linking centers of edges of t whose type is {vi } (where vi is the common vector defining the family of Li ). + + For L+ i , consider the set Si formed by the union of representing segments of tiles of Li
236
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
4 t'
t'
4 t'
4 3
3 2 3/2 υ4
υ3
1 υ2 υ1
t
0 t
2
1 0 t
Fig. 10. Two paths with same endpoints, and the values associated with each vertex, B being the set of all lines not in the family defined by v1 .
and the line segment common to fi and fi+1 . By definition, two tiles t and t (not in L+ i ) are in the same part if there exists a continuous function f from [0, 1] to the 2D-gon P such that, f (0) is the center of the tile t, f (1) is the center of the tile t , and for each real number x ∈ [0, 1], f (x) is not element of the set Si+ ). 3.2. Shortest paths We first define some material broadly used in the following proofs. Definition 8 (Line index, line value). Let T be a tiling, L be a de Bruijn line of T or a halfline as above, and t1 , t2 be two tiles of T. As seen before, L induces a partition of T into three parts T + , T − and L. We define the line index indL (t1 , t2 ) as follows: • if t1 ∈ L and t2 ∈ T + ∪ T − , then ind L (t1 , t2 ) = 1/2, • if t1 ∈ T + and t2 ∈ T − , or t1 ∈ T − and t2 ∈ T + , then ind L (t1 , t2 ) = 1, • in the other cases, ind L (t1 , t2 ) = 0. Let B = {L1 , . . . , Lq } be a set of de Bruijn lines and half-lines of T. The line value q ind B (t1 , t2 ) is the sum k=1 ind Lk (t1 , t2 ). Intuitively, the line value from t1 to t2 counts the number of lines of B crossed by a path from t1 to t2 . Let (t0 , t1 , . . . , tr ) be a path of tiles (i.e. two consecutive tiles are adjacent) and consider the sequence (a0 , a1 , . . . , ar ) such that for each integer i, 0 i r, ai = ind B (t1 , ti ) (see Fig. 10). We assume that B is correctly constructed, i.e. for each half-line L+ , at most one element of {L− , L+ , L} is in B, and if L+ (or L− ) is in B, then the endpoint of this half-line in the fan is not element of another line (or half-line) of B. Remark that for each integer i such that 1 i < r, ind L (t1 , ti ) = ind L (t1 , ti+1 ), except if L is a line containing one of the tiles ti or ti+1 and not the other one. Since B is correctly constructed, in any case, there are at most two of these exceptions, for each of which the index can change of 1/2 unit. Thus, |ai − ai+1 | 1. Moreover we have a0 = 0. Thus, we have: • r ar , the line value is a lower bound for the distance between two tiles, • the equivalence: r = ar if and only if for each integer i such that 0 i r, ai+1 − ai = 1.
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
237
L+4 L+3 L+2 L+1
Lp
L
Fig. 11. A fan and the unique shortest path between its endpoints (Lemma 2).
Lemma 1. Let t and t be two tiles of the border linked by a de Bruijn line L, and let (t0 , t1 , . . . , tr ) be the path of tiles starting in t = t0 induced by L (i.e. t0 = t, tr = t and all tiles ti are in L). The path (t0 , t1 , . . . , tr ) is the unique shortest path between t and t . Proof. We take B as the set of the r de Bruijn lines which cut the line L. With the above notations, we have ar = r which proves that the path is a shortest path. Now, assuming the shortest path from t to t is not unique, let p be another path of length r from t to t . The paths p and (t0 , t1 , . . . , tr ) have a common prefix (maybe only t). Let c be the last vertex in both paths, and let d be the first vertex of p not in L. Let Lc be the line crossed by L in c. The tile d necessarily is also in Lc . Then ind {Lc } (t, c) = ind {Lc } (t, d). Thus |ind B (t, c)−ind B (t, d)| 1/2, which contradicts the hypothesis that p is of length r. Lemma 2. Let T be a tiling of a 2D-gon, t, t be two tiles of T having exactly one point in common and having one edge included in a given side of the 2D-gon. The common point is assumed to belong to the hull of the 2D-gon. The unique shortest path between t and t is the fan (t = f1 , f2 , . . . , fr = t ), from t to t . See Fig. 11. Proof. The argument is exactly the same as in Lemma 1, using the set formed by {L+ i |1 i p − 1} ∪ {Lp }, (we recall that Lp is defined by the edge of t which is on the hull). 3.3. Constructing the border The first step of algorithm to construct a tiling equivalent to a tiling T starting from the graph with origins of T will be to construct its border. The vertices having degree 2 or 3 are obviously part of the border. The point is first to find the vertices of degree 4 which also belong to the border, then to find the succession between vertices along the border. We first show some properties of the graph allowing to make both these at the same time. We then give an algorithm to compute the border of the adjacency graph (Theorem 2), which completes the first step of the construction of T from its graph with origins. Having shown the shortest path properties, we turn now to the main part of the algorithm. In the following, by “successive tiles” we mean two tiles of the border having degree 2 or
238
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253 L'
L tL L+ t12
T−
T+
L−
t1
t2
Fig. 12. The general case. Light grey: L+ ; Dark grey: L− .
3 and adjacent by a point of the hull of the tiling. This corresponds to two tiles which are endpoints of a same fan. The algorithm we want to build is a greedy one, which, starting with two successive tiles of the border, finds a tile successive to one of them. Hence, starting with the origins, this constructs locally the paths between successive tiles of the border, leading to a complete construction of the border. Let T be a tiling, and t1 , t2 , t3 be three tiles such that: • t1 and t3 are endpoints of a fan, whose head is a point v (i.e. v = t1 ∩ t3 ∩ H (T )), • t1 and t2 are endpoints of a fan, whose head is a point v = v (i.e. v = t1 ∩ t2 ∩ H (T )). We assume the fan whose head is v has already been constructed, and we want to construct the fan whose head is v. Let c0 be the edge of t1 on the hull and containing v. c0 induces a de Bruijn line L, which cuts the tiling into 3 parts: T + , T − and L. We assume, without loss of generality, that t3 ∈ T − . Let c be the side of t2 on the hull and containing v . c induces a de Bruijn line L . Let cp be the side of t3 on the hull and containing v. cp induces a de Bruijn line Lp . Let t12 be the tile at the crossing between L and L , if it exists. This tile separates in particular L into L+ and L− , L− being the part from t1 and t12 excluded, and L+ being the other part of L. t1 being one endpoint of L, we denote by tL its other endpoint. Hence L+ is the part of L from t12 to tL . See Fig. 12. Let t1 , t2 , . . . , tp be the tiles of the fan induced by v, in such a way that the path from t1 to t3 is t1 = t1 , t2 , . . . , tp = t3 . Let ci be the edge in common to ti+1 and ti . We call Li the de Bruijn line induced by ci . See Fig. 13. Notice that c0 and cp are the sides on the hull induced by v. We make the assumption that t1 and t3 are not adjacent (otherwise the search for t3 is obvious). For further convenience, we call this the fan search situation, and we introduce some notations: A1 is the set of tiles closer to t1 than to t2 , i.e. A1 = {t ∈ T , dist(t, t1 ) < dist(t, t2 )}. In the same way, A2 = {t ∈ T , dist(t, t2 ) < dist(t, t1 )}. A= will be the set of tiles whose distance to both t1 and t2 is the same.
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
239
L5=Lp
L' L L1 L2 L3 L4 t3
v
t1
v'
t2
Fig. 13. The fan search situation, and the numbering of the lines.
3.3.1. General case: t2 ∈ T + This induces two different cases. Either L, L and Lp are parallel (which means c0 , cp and c have same support), or at least two of them cross each other in the tiling. We start with the last case, which is the general case. (a) c0 , cp and c do not all have same support. We assume here that c0 , cp and c do not all have same support (at least two of the lines L, Lp and L cross each other). + Proposition 3. In the general fan search situation, let Thull = {t ∈ T + , deg(t) < 4}. We have: (1) L− ⊆ A1 , + ⊆ A2 ∪ A = , (2) L+ ∪ Thull (3) if L and L are parallel (i.e. c0 and c have same support), then L ∪ T − ⊆ A1 . − As a consequence of the second item, if we state: Thull = {t ∈ T − |deg(t) < 4} and − ∪ {tL } where tL denotes the A1,hull = {t ∈ A1 |deg(t) < 4}, then we have A1,hull ⊆ Thull − endpoint of L different from t1 . Moreover, when L and L are not parallel, A1,hull ⊆ Thull .
Proof. Let ui be the ith tile of L, starting from t1 , and Mi be the line crossing L on ui . We take Bi = {Mj |1j i}. We first prove dist(ui , t2 ) dist(ui , t1 ). Lemma 1 implies that dist(t1 , ui ) = i − 1. For 1 j < i, we have ind {Mj } (ui , t2 ) = 1/2 if t2 ∈ Mj , and ind {Mj } (ui , t2 ) = 1 otherwise (since ui ∈ / Mj for i = j ). Moreover, we have: ind {Mi } (ui , t2 ) = 0 if t2 ∈ Mi , ind {Mi } (ui , t2 ) = 1/2 otherwise. Since t2 is crossed by two de Bruijn lines, at most two of the preceding values are minimal. This induces that ind Bi (ui , t2 ) (i −1/2)−2 ×1/2, thus dist(ui , t2 ) i −1. Hence dist(ui , t2 ) dist(ui , t1 ). (1) Let ui ∈ L− . Assume dist(t2 , ui ) = i − 1, and let (ui = r0 , r1 , r2 , . . . , ri−1 , ri = t2 be a (i − 1)-long path from ui to t2 . We necessarily have: ind Bi (ui , rj ) = j . We easily prove by induction that, for 0 j i, rj = ui−j : the initialization of the induction is obvious, and assuming rj = ui−j , since ind B (ui , rj +1 ) = ind B (ui , rj ) + 1, one has to leave Mj , i.e. rj +1 ∈ L, thus rj +1 = ui−j −1 . This induces t2 = t1 , which contradicts the assumptions. Hence dist(ui , t2 ) > dist(ui , t1 ).
240
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
L Lp L4+ L3+ L2+ L1+ t2
t3 t1
Fig. 14. The lines that have to be crossed to reach the hull, in the fan search situation.
(2) Let t ∈ L+ . The unique shortest path from t to t1 is following L. Moreover, the path from t to t2 consisting in following L+ until t12 , then L until t2 , has length dist(t, t1 ), because t12 ∈ A= (since each line crosses L− if and only if it crosses L− ). Then L+ ⊆ A= ∪ A2 . + . Let now t ∈ Thull (a) either the shortest path from t to t1 contains at least one tile of L+ (in this case a suffix of this path is a part of L), and one can construct a path of same length leading from t to t2 by replacing the part from t12 to t1 by the path from t12 to t2 as above. Thus t ∈ A= ∪ A2 (there may exist a shorter path from t to t2 ). (b) in the other case, the shortest path from t to t1 necessarily crosses L on a tile tL of L− (the part of L from t2 to t12 , with t12 excluded). The argument used in 1 just above induces tL ∈ A2 . Hence t ∈ A2 . This leads to the result. (3) If L and L are parallel, L = L− , and 1 induces the result for L. For T − , the case is symmetrical to 2(b). The same argument leads to the conclusion (just exchange L and L , and T + and T − ). Lemma 4. Let A1,hull = {t ∈ A1 , deg(t) < 4}. We have: (1) ∀t ∈ A1,hull , dist(t, t1 ) dist(t3 , t1 ). (2) If dist(t, t1 ) = dist(t3 , t1 ) then t ∈ Lp . − Proof. Let t ∈ A1,hull . From the preceding lemma, either t ∈ Thull , or t = tL . − If t ∈ Thull : • ind L+ (t, t1 ) = 1/2, 1 • ind L+ (t, t1 ) = 1 for 2 i p − 1, i • ind Lp (t, t1 ) = 1/2 if t ∈ Lp , 1 otherwise. Then, if B is the union of the preceding lines, we have ind B (t, t1 ) p−3+1+1/2+1/2 = p − 1, i.e. dist(t, t1 ) dist(t3 , t1 ) (Fig. 14). Moreover, the equality can be obtained only for ind Lp (t, t1 ) = 1/2, i.e. t ∈ Lp .
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
241
t
t3
t1
Fig. 15. Proof of Lemma 5: the unitary zonotope (bold), gray is the geodesic from t1 to t. The fan from t1 to t3 enforces the tiling of the whole unitary zonotope, which gives the result.
If t = tL , L and L are parallel, otherwise t ∈ A2 ∪ A= . Then L and Lp cross each other (we are not in the case where L, L and Lp are parallel), and ind Lp (t, t1 ) 1/2. This leads directly to the same result as the previous case. Lemma 5. Let t ∈ A1,hull such that dist(t, t1 ) = dist(t3 , t1 ). Let (t3 = r0 , r1 , . . . , rk = t) be the geodesic from t3 to t. For each integer i such that 0 i k, ri ∈ A1,hull . Proof. Let t ∈ Lp such that dist(t, t1 ) = dist(t3 , t1 ), and let (t1 = s0 , s1 , . . . , sp−1 = t) be a geodesic from t1 to t. + + This geodesic meets successively L+ 1 , L2 , . . . , Lp−1 , Lp . Since dist(t, t1 ) = p − 1, no + other line is crossed by the geodesic, thus s0 is necessarily on L+ 1 , s1 is on L2 , . . . and sp−1 is on Lp . Let j denote the index of the last si of the fan. Assume that j < p − 1. From the condition − above, sj +1 is on L+ j +2 , thus sj +1 necessarily is in Lj , as sj . For the same reason (if − j + 1 < p − 1), sj +2 is also in Lj , and so on until sp−1 is reached. The set of de Bruijn lines crossing the geodesic (i.e. L− j ) from sj to t is {Lj +1 , Lj +2 , . . . , Lp }. Moreover these lines are exactly those which reach the hull on the part of T − between t and t3 (Fig. 15). Thus, starting from the fan, L− j +1 successively crosses Lj +2 , Lj +3 , . . . and Lp , and no − other line is crossed by Lj +1 . One can repeat the argument: starting from the fan, L− j +2 successively crosses Lj +3 , Lj +4 . . . and Lp , and no other line is crossed by L− . j +2 On the other side, for j j p − 1, from sj to the fan, the line L+ j +1 successively meets Lj , Lj +1 , . . . , Lj and no other line is crossed by L+ j +1 between sj and the fan (with the + convention Lp = Lp for j = p − 1). This induces the result: the line Lp follows the hull between t3 and t and, for each integer i such that 0 i k, one easily constructs a path of length p − 1 from t1 to ri . Proposition 6. Let X3 denote the subset of A1,hull formed by tiles t such that dist(t, t1 ) = dist(t3 , t1 ). The tile t3 is the unique element of X3 whose degree is lower than the degree of all the other tiles of X3 .
242
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
Proof. This is obvious, from the previous lemma once it has been seen that tLp , the other endpoint of Lp , cannot be in X3 : if Lp and L cross each other, then Lp is not in A1 , from Lemma 1; otherwise, Lp and L cross each other, which implies that dist(tLp , t1 ) > dist(t3 , t1 ), using the set formed by the lines L+ i for 1 i p − 1, and L . (b) c0 , cp and c have same support. We first prove a particular property of this case, and then show some particular situations leading to a further study. All takes place in the fan search situation, with c0 , cp and c having same support. Lemma 7. Let A1,hull = {t ∈ A1 , deg(t) < 4}. Then ∀t ∈ A1,hull , dist(t, t1 ) dist(t3 , t1 )− 1. Moreover, if there exists t such that dist(t, t1 ) = dist(t3 , t1 ) − 1, then t = tL , tL being the endpoint of L opposite to t1 . Proof. We can use the arguments of the similar lemma of the previous case, except when t = tL : in this case only, it is possible to have ind L+ (t, t1 ) = 1/2. Thus we obtain p−1 ind B (t, t1 ) p − 3 + 1/2 + 1/2, which gives dist (t, t1 ) dist (t3 , t1 ) − 1 and the equality can be obtained only for tL . Two particular cases may occur, which we study now, keeping the same notations as for the preceding lemma: (1) dist(tL , t1 ) = dist(t3 , t1 ) − 1. This case corresponds to the situation described in Fig. 16: since L is crossed by each half-line L+ i on a tile ui , the geodesic from t1 to tL is necessarily (u1 , u2 , . . . , up−1 ), (t1 = u1 and tL = up−1 ). Since L and Lp are parallel, Lp also contains p − 1 tiles. Moreover, starting from t3 , Lp successively crosses Lp−1 , Lp−2 . . . .L1 . Starting from t2 , L successively crosses L1 , L2 . . . .Lp−1 . An important point for the following is that u2 is adjacent to a tile of A2 . This fact allows to discover that we are in this case. Let X3 denote the set {t ∈ A1 , dist(t, t1 ) = dist(t3 , t1 )} and Xmin denote the set of elements of X3 of minimal degree. We have: t3 ∈ Xmin , card(Xmin ) = 2, and the element t4 of Xmin different from t3 is the other endpoint of Lp . Notice that dist(t4 , tL ) = 2, and dist(t3 , tL ) = p − 1, which is at least 3, since we have dropped the particular cases when the border is not a cycle. (2) dist(tL , t1 ) = dist(t3 , t1 ). In this case, from the previous situation, a de Bruijn line L non-parallel to L, L and Lp is added to the tiling, since L contains all the tiles ui as above and one other tile. This situation can be seen in Fig. 17. The space between L and L only contains some tiles of L , and those tiles are in A= . With the notations above card(Xmin ) 2, and, if card(Xmin ) = 2, the element of Xmin different from t3 is tL . One can notice that the tile of L adjacent to t1 is adjacent to a tile of A2 ∪ A= , and that the tile of the fan adjacent to t1 has not the same property, since it is in T − .
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
243
tL
t3
t1
t2
Fig. 16. The particular case in which tL is closer to t1 than t3 , and all the tiles of Lp (in gray) are at same distance of t1 .
tL
t
L"
t' t3
t2
t1
Fig. 17. Particular case with a line crossing L. Notice that the tile adjacent to t (in gray) is in A= ∪ A2 , while none of the tiles adjacent to t .
3.3.2. Particular case: t2 ∈ L Now we have seen how to find the successor of a tile on the border in the case t2 ∈ T + , we have to study the particular case t2 ∈ L. We proceed as in the general case. The difference comes from the criterion allowing to exclude tiles in T + . Lemma 8. Considering the fan search situation, if t2 ∈ L, then: (1) let tx be a tile of T + ∪ L\{t1 }. Then tx ∈ A2 . More precisely, each geodesic from t1 to tx contains t2 , (2) t3 ∈ A1 ∪ A= . Proof. (1) If tx ∈ L, then the geodesic from tx to t1 is included in L. Since the only tile of L adjacent to t1 is t2 , tx ∈ A2 . Hence L\{t1 } ⊆ A2 . If tx ∈ T + , consider a shortest path from t1 to tx . Assume this path does not start by (t1 , t2 , . . .). Then it starts by (t1 , t , ..), with t ∈ T − . Thus the path contains a tile t (different from t1 ) which is in L, since tx ∈ T + . By Lemma 1, the unique shortest path from t1 to t follows L, which contradicts the assumption, and tx ∈ A2 .
244
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
(2) It is clear that ind L (t2 , t3 ) = ind Lp (t2 , t3 ) = 1/2. Moreover, for 3i p − 1, ind L+ (t2 ,t3 ) = 1, and ind L+ (t2 , t3 ) 1/2. Thus, considering the set B of all these lines, we 2 i obtain: ind B (t2 , t3 ) p − 3 + 3 × 1/2. This gives dist(t2 , t3 ) p − 1. Lemma 9. Let A1,=,hull = {t ∈ A1 ∪ A= , deg(t) < 4}. Then: (1) ∀t ∈ A1,=,hull , dist(t, t1 ) dist(t3 , t1 ), (2) If dist(t, t1 ) = dist(t3 , t1 ) then t ∈ Lp . We do not give the proof since it is very similar to Lemma 4. This lemma induces in particular that card(Xmin ) 2, where Xmin is defined in an analogous way as in the previous case. Since the elements such that dist(t, t1 ) = dist(t3 , t1 ) are in Lp , the two possible elements of Xmin are t3 and tLp . If card(Xmin ) = 2, we are in a case similar to Fig. 16, and there is a unitary zonotope between L and Lp . Lemma 9 underlines the fact that L \ {t1 } ∈ A2 . By construction dist(tLp , tL ) = 2, i.e. dist(tLp , A2 ) = 2. Moreover, with the same notations as previously, taking B as the set {L− i |1i p − 1} together with Lp , we have ind B (t3 , tL ) p − 1 + 1/2, since ind Lp (t3 , tL ) = 1/2, ∀i, ind L− (t3 , tL ) = 1. Moreover, p − 1 2 (otherwise there i is one tile in the fan, which is adjacent to t1 , t3 , tL and tLp , and this particular case has been excluded). Then dist(t3 , A2 ) 3, since all other tiles of A2 are further from t3 than L (see Lemma 8).
3.3.3. Algorithm for constructing the border We have now all the preliminary results necessary to write an algorithm which constructs the border of the adjacency graph of a 2D-gon tiling (Algorithm 2). In the fan search situation, we make a breadth first search in A1 , starting from t1 , and select the tiles closest to t1 with degree < 4. This gives a set of tiles, one of which is t3 in most of the cases; we call these candidates. In the general case, either there is only one candidate, and it is t3 , or there are several, and the one with minimal degree is t3 . The preceding study enlightens particular cases: • There may exist a unique candidate which is not t3 (see Lemma 7). This is the case of Fig. 16, and the candidate is tL . Then there exists a tile neighbor to both t2 and the successor of t1 on the path from t1 to tL . We can perform another breadth first search in A1 \L, since L is the path from t1 to tL . • There may exist two candidates with minimal degree, one of them is t3 . Two cases occur: ◦ if the other candidate is tLp , then we are in the case of Fig. 16 (after having performed a breadth first search in A1 \L). Thus there is a 2-long path from tLp to tL , which allows to find t3 . This can also occur in the particular case of Lemma 9, and the wrong candidate is a distance-2 neighbor of a tile of A2 . ◦ in the other case, the candidate is tL , and we are in the case of Fig. 17. Then one can find t3 in the search tree induced by the breadth first search, by starting at t1 and selecting at each step the successor having degree 3 (i.e. having 2 successors). One thus obtains two vertices, the one having degree < 4 is t3 .
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
245
These remarks lead to the following procedure: (1) if t3 and t1 are adjacent, then the result is obvious, (2) if t2 and t1 are adjacent, and t1 has degree 2, then t2 ∈ L. We make a breadth first search to find Xmin = {t ∈ A1,= , deg(t) < 4, dist(t, t1 ) minimal}. We have the alternatives below: (a) Xmin is reduced to one single element, and this one is t3 , (b) Xmin has two elements. Thus, L and Lp are parallel, and Lemma 7 induces that there exists a unique t in Xmin such that dist(t, A2 ) 3. This one is t3 . (3) in other cases, t2 ∈ T + , we make a breadth first search to find Xmin = {t ∈ A1 , deg(t) < 4, dist(t, t1 ) minimal}. We have the following alternatives: (a) Xmin has one element t. We make a test to know whether this element is t3 . Let ttest be the first tile in the shortest path from t1 to t found previously. (i) If ∃t = t1 such that t is adjacent to t2 and ttest , then t = t3 : we are in the case of Fig. 17. We make a new breadth first search to find Xmin2 = {t ∈ A1 \ L, deg(t) < 4, dist(t, t1 ) minimal}. Then Xmin2 has two elements. One of them is at distance 2 of t. The other one is t3 . (ii) otherwise, t = t3 . (b) Xmin has two elements. Then Xmin = {t3 , tL }, and L, L and Lp are parallel. We make a test to recognize t3 . Let t be a tile of Xmin and ttest be the first tile in the shortest path from t1 to t found previously. If there exists one tile of A= ∪ A2 adjacent to ttest , then t = tL , otherwise t = t3 . Theorem 2. Given the adjacency graph of a 2D-gon tiling, Algorithm 2 computes its border in time O(m · n) where n is the number of vertices of the graph, and m is the sum of the multiplicities defining the 2D-gon. Proof. The basic complexity of this greedy algorithm is O(n · m), where n is the number of vertices and m the sum of the multiplicities, because it is just visiting all the vertices with degree at most 3, and builds a breadth first search in the rest of the graph, where every vertex has degree at most 4. Then, starting with one origin, it only has to follow the distance 1 vertices until there is none. The treatment of the particular cases can also be done in O(n · m). This leads to a global time complexity O(n · m). 3.4. Constructing de Bruijn lines We will now show that, when one knows the border of the graph with origins of a 2Dgon tiling T, then one can construct the de Bruijn lines of T by computing shortest paths in the graph. Indeed, when the border is constructed, one knows the succession of tiles along the hull of the tiling. Then, one can find the jth tile for each j ∈ 1, . . . , m, m being the sum of the multiplicities (with the convention that a tile with two edges on the hull is simultaneously the jth and the (j + 1)th of the sequence, the first tile is the origin v1 ). By the construction of the tiling, one can easily check that the jth and the (m + j )th tile correspond to endpoints of lines of a same family.
246
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
Algorithm 2: Construction of the border of the adjacency graph of a 2D-gon tiling. Input: G = (V , E, v1 , v2 ) the graph with origins of a 2D-gon tiling. Output: The border of G, B(G), as an ordered list of vertices. begin // we assume the function BF S(X, t) computes the set of // closest vertices to t in X with degree size(B)/2; Return (V , E, , v1 ); end
250
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
Fig. 20. A tiling of an octagon (D = 4) (left) and two other tilings of the same octagon obtained from the first one by a flip (the shaded tiles are the ones which moved during the flip).
then compute the de Bruijn graph with Algorithm 3, and finally obtain the tiling using Algorithm 1. Therefore, we can finally combine Theorems 1–3 to obtain: Theorem 4. Given the graph with origins of a 2D-gon tiling T, there is an algorithm which constructs a 2D-gon tiling equivalent to T in time O(m · n), where n is its number of tiles, and m the sum of the multiplicities of the vectors used to define the 2D-gon. This result not only gives an efficient and simple way to encode and manipulate 2D-gon tilings; it also clarifies the relation that exists between the adjacency graph of a tiling and the tiling itself. In particular, it proves that, despite the fact that there is no one-to-one correspondence between adjacency graphs and tilings, the adjacency graph contains almost all the information on the tiling. 4. An application: random tilings Tilings of 2D-gons are an important model of quasicrystals in physics. In this context, it is very important to be able to sample random tilings, which helps the study of the entropy of the quasicrystal [15]. The sampling uses the key notion of flip: given a 2D-gon tiling, one may rearrange locally three tiles (which form an hexagon) in order to obtain a new tiling of the same 2D-gon (see Fig. 20). This enables the random generation of tilings of a 2D-gon: it is shown in [9,10] that one can obtain all the tilings of a 2D-gon from a given one by iterating the flip operation. When one wants to obtain a random tiling, one then has to choose a particular tiling and then iterate the flip operation until the obtained tiling can be considered as random. This notion of when one can stop the process is central when one wants to sample random tilings with the uniform distribution. It is possible to sample perfectly random tilings of hexagons because of the distributive lattice structure of the set of all the tilings [12]. This technique can no longer be used for octagon, but a recent study explains how long the process has to be continued in order to be as close as one may want of the uniform distribution [8]. For the other 2D-gons, i.e. when D > 4, there are no known results [15]. Therefore, when one wants to sample a random tiling of a given 2D-gon P, the only solution is to construct a particular tiling of P and iterate the flip operation. To achieve this, one can use the graphs encodings we proposed above: the flip operation can be encoded on the graph, as shown in Fig. 21. The vertices which correspond to the tiles to flip form a triangle in the graph, and conversely, all the triangles in the graph correspond to a possible flip
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
251
Fig. 21. A flip on a 2D-gon, and on its graph.
Fig. 22. A random tiling of a 5 → 2 tiling with side size 16, obtained after 100 million flips.
in the tiling. Moreover, the transformation on the graph is a local rearrangement of vertices. The flip just exchanges the links of edges having the same label. Indeed, it just corresponds to exchanging the order between tiles within each de Bruijn line. Hence, considering a line, the tiles are exchanged during a flip, which corresponds to linking each tile with the preceding neighbor of the other tile. Notice however that this operation needs the labels, and cannot be performed on the adjacency graph, which is unlabeled. This makes it possible to implement the flip operation very efficiently and so to iterate it a very high number of times. We show in Fig. 22 a random tilings of a decagon obtained this way.
252
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
5. Perspectives The algorithmic study of tilings of 2D-gons is only at its beginning, and many open problems still exist. We cited the problem of knowing how many flips have to be done in order to obtain random tilings with a distribution close to the uniform distribution. Another important area is the generation of all the tilings of a 2D-gon, and their enumeration. The encodings with graphs may be used to study these problems. For example, one may obtain a characterization of which graphs are the graphs associated with a 2D-gon tiling: these graphs are planar, the degree of each vertex is at most four, and they may have many other properties which could help in generating and counting them. Moreover, 2D-gons are a special class (the dimension 2 case) of a very important class of objects, namely zonotopes [16]. These objects can be viewed as generalizations of 2D-gons in higher dimensions, and they play an important role in combinatorics and physics. They are also strongly related to oriented matroid theory [13]. Many studies already deal with these objects, but their algorithmic manipulation is still a problem, while it would help a lot in verifying conjectures, compute special tilings, and compute some statistics over them. The results presented here may be extended to this more general case, leading to other classes of graphs with interesting properties. Notice however that this generalization is not obvious, since our proofs deeply use properties related to the dimension 2. It is well known in zonotopes theory that there is a gap of complexity between 2-dimensional zonotopes (2D-gons) and 3-dimensional ones [16].
Acknowledgments The authors are very grateful with the anonymous referee, who suggested a lot of improvements and accepted to carefully and quickly read the successive manuscripts.
References [1] E. Babson, L. Finschi, K. Fukuda, Cocircuit graphs and efficient orientation reconstruction in oriented matroids, European J. Combin. 22 (2001) 587–600. [2] G.D. Bailey, Coherence and enumeration of tilings of 3-zonotopes, Discrete Comput. Geom. 22 (1999) 119–147. [3] R. Berger, The undecidability of the domino problem, Mem. Amer. Math. Soc. 66 (1966). [4] A. Björner, M. Las Vergnas, B. Sturmfels, N. White, G.M. Ziegler, Oriented Matroids, Encyclopedia of Mathematics, Vol. 46, second ed., Cambridge University Press, Cambridge, 1999. [5] R. Codovil, K. Fukuda, A. Guedes de Oliveira, On the cocircuit-graph of an oriented matroid, Discrete Comput. Geom. 24 (2000) 257–265. [6] N.G. de Bruijn, Dualization of multigrids, J. Phys. France C 47 (1981) 3–9. [7] N. Destainville, Entropie configurationnelle des pavages aléatoires et des membranes dirigées, Ph.D. Thesis, University Paris VI, 1997. [8] N. Destainville, Mixing times of plane random rhombus tilings, in: Proc. Conf. DM-CCG: Discrete Models: Combinatorics, Computation, and Geometry, 2001, pp. 1–22. [9] S. Elnitsky, Rhombic tilings of polygons and classes of reduced words in Coxeter groups, J. Combin. Theory 77 (1997) 193–221. [10] R. Kenyon, Tiling a polygon with parallelograms, Algorithmica 9 (1993) 382–397.
F. Chavanon et al. / Theoretical Computer Science 346 (2005) 226 – 253
253
[11] M. Latapy, Generalized integer partitions, tilings of zonotopes and lattices, in: A.A. Mikhalev, D. Krob, E.V. Mikhalev (Eds.), Proc. 12th Internat. Conf. on Formal Power Series and Algebraic Combinatorics, FPSAC’00, Springer, Berlin, 2000, pp. 256–267, preprint available at http://www.liafa.jussieu.fr/∼latapy/. [12] J. Propp, Generating random elements of finite distributive lattices, Electron. J. Combin. 4 (1998). [13] J. Richter-Gebert, G. Ziegler, Zonotopal tilings and the Bohne–Dress theorem, Contemp. Math. 178 (1994) 211–232. [14] M. Senechal, Quasicrystals and Geometry, Cambridge University Press, Cambridge, 1995. [15] M. Widom, R. Mosseri, N. Destainville, F. Bailly, Arctic octahedron in three-dimensional rhombus tilings and related integer solid partitions, J. Statist. Phys. 109 (2002) 945–965. [16] G. Ziegler, Lectures on Polytopes, Graduate Texts in Mathematics, Springer, Berlin, 1995.
Theoretical Computer Science 346 (2005) 254 – 264 www.elsevier.com/locate/tcs
A solution to the tennis ball problem夡 Anna de Mier∗ , Marc Noy Departament de Matemàtica Aplicada II, Universitat Politècnica de Catalunya, Jordi Girona 1-3, 08034 Barcelona, Spain
Abstract We present a complete solution to the so-called tennis ball problem, which is equivalent to counting the number of lattice paths in the plane that use North and East steps and lie between certain boundaries. The solution takes the form of explicit expressions for the corresponding generating functions. Our method is based on the properties of Tutte polynomials of matroids associated to lattice paths. We also show how the same method provides a solution to a wide generalization of the problem. © 2005 Elsevier B.V. All rights reserved. Keywords: Lattice path; Tutte polynomial; Kernel method
1. Introduction The statement of the tennis ball problem is the following. There are 2n balls numbered 1, 2, 3, . . . , 2n. In the first turn, balls 1 and 2 are put into a basket and one of them is removed. In the second turn, balls 3 and 4 are put into the basket and one of the three remaining balls is removed. Next, balls 5 and 6 go in and one of the four remaining balls is removed. The game is played n turns and at the end there are exactly n balls outside the basket. The question is how many different sets of balls we may have at the end outside the basket. It is easy to reformulate the problem in terms of lattice paths in the plane that use steps E = (1, 0) and N = (0, 1). It amounts to counting the number of lattice paths from (0, 0) to 夡
Research partially supported by projects BFM2001-2340 and CUR Gen. Cat.1999SGR00356.
∗ Corresponding author.
E-mail addresses:
[email protected] (A. de Mier),
[email protected] (M. Noy). 0304-3975/$ - see front matter © 2005 Elsevier B.V. All rights reserved. doi:10.1016/j.tcs.2005.08.017
A. de Mier, M. Noy / Theoretical Computer Science 346 (2005) 254 – 264
255
P π
Fig. 1. The path = EEN N N EEEEN N N N N EE not above P = (N 2 E 2 )4 . It has i() = 3 and e() = 2, corresponding to the steps underlined.
(n, n) that never go above the path N E · · · N E = (N E)n . Indeed, if = 1 2 . . . 2n−1 2n is such a path, a moment’s thought shows that we can identify the indices i such that 2n−i+1 is a N step with the labels of balls that end up outside the basket. The number of such paths is well-known to be a Catalan number, and this is the answer obtained in [4]. The problem can be generalized as follows [6]. We are given positive integers t < s and sn labelled balls. In the first turn, balls 1, . . . , s go into the basket and t of them are removed. In the second turn, balls s + 1, . . . , 2s go into the basket and t among the remaining ones are removed. After n turns, tn balls lie outside the basket, and again the question is how many different sets of balls we may have at the end. Letting k = t, l = s − t, the problem is seen as before to be equivalent to counting the number of lattice paths from (0, 0) to (ln, kn) that use N and E steps and never go above the path N k E l · · · N k E l = (N k E l )n . This is the version of the problem we solve in this paper. From now on we concentrate on lattice paths that use N and E steps. To our knowledge, the only cases solved so far are k = 1 and k = l = 2. The case k = 1 is straightforward, the answer being a generalized Catalan number 1/(l(n + 1) + 1) (l+1)(n+1) . The case n+1 k = l = 2 (corresponding to the original problem when s = 4, t = 2) is solved in [6] using recurrence equations; here we include a direct solution. This case is illustrated in Fig. 1, to which we refer next. A path not above (N 2 E 2 )n is “almost” a Catalan path, in the sense that it can raise above the dashed diagonal line only through the dotted points. But clearly between two consecutive dotted points hit by we must have an E step, followed by a Catalan path of odd semilength, followed by a N step. Thus, is a sequence 2nessentially n of Catalan paths of odd semilength. If G(z) = n 1/(n + 1) n z is the generating function for the Catalan numbers, take the odd part Go (z) = (G(z) − G(−z))/2. Then expand 1/(1 − zGo (z)) to obtain the sequence 1, 6, 53, 554, 6363, . . . , which agrees with the results in [6]. Let P be a lattice path from (0, 0) to (m, r), and let b(P ) be the number of paths from (0, 0) to (m, r) that never go above P. If P N denotes the path obtained from P by adding a N step at the end of P, then clearly b(P ) = b(P N ). However, it is not possible to express
256
A. de Mier, M. Noy / Theoretical Computer Science 346 (2005) 254 – 264
b(P E) simply in terms of b(P ), where P E has the obvious meaning. As is often the case in counting problems, one has to enrich the objects under enumeration with additional parameters that allow suitable recursive decompositions. This is precisely what is done here: Eqs. (2) and (3) in the next section contain variables x and y, corresponding to two parameters that we define on lattice paths not above a given path P. These equations are the key to our solution. The basis of our approach is the connection between lattice paths and matroids established in [2], where the link with the tennis ball problem was already remarked. For completeness, we recall the basic facts needed from [2] in the next section. In Section 3, we present our solution to the tennis ball problem, in the form of explicit expressions for the corresponding generating functions; see Theorem 1. In Section 4, we show how the same method can be applied to a more general problem. We conclude with some remarks.
2. Preliminaries The contents of this section are taken mainly from [2], where the reader can find additional background and references on matroids, Tutte polynomials, and lattice path enumeration. A matroid is a pair (E, B) consisting of a finite set E and a nonempty collection B of subsets of E, called bases of the matroid, that satisfy the following conditions: (1) no set in B properly contains another set in B, and (2) for each pair of distinct sets B, B in B and for each element x ∈ B − B , there is an element y ∈ B − B such that (B − x) ∪ y is in B. Let P be a lattice path from (0, 0) to (m, r). Associated to P there is a matroid M[P ] on the set {1, 2, . . . , m + r} whose bases are in one-to-one correspondence with the paths from (0, 0) to (m, r) that never go above P. Given such a path = 1 2 . . . m+r , the basis corresponding to consists of the indices i such that i is a N step. Hence, counting bases of M[P ] is the same as counting lattice paths that never go above P. For any matroid M there is a two-variable polynomial with nonnegative integer coefficients, the Tutte polynomial t (M; x, y). It was introduced by Tutte [9] and presently plays an important role in combinatorics and related areas (see [11]). The key property in this context is that t (M; 1, 1) equals the number of bases of M. Given a path P as above, there is a direct combinatorial interpretation of the coefficients of t (M[P ]; x, y). For a path not above P, let i() be the number of N steps that has in common with P, and let e() be the number of E steps of before the first N step, which is 0 if starts with a N step. See Fig. 1 for an illustration. Then we have (see [2, Theorem 5.4]) t (M[P ]; x, y) =
x i() y e() ,
(1)
where the sum is over all paths that do not go above P. A direct consequence is that t (M[P ]; 1, 1) is the number of such paths. Furthermore, for the matroids M[P ] there is a rule for computing the Tutte polynomial that we use repeatedly (see [2, Section 6]). If P N and P E denote the paths obtained from
A. de Mier, M. Noy / Theoretical Computer Science 346 (2005) 254 – 264
257
P by adding a N step and an E step at the end of P, respectively, then t (M[P N ]; x, y) = x t (M[P ], x, y), t (M[P E]; x, y) =
x x t (M[P ], x, y) + y − t (M[P ]; 1, y). x−1 x−1
(2) (3)
The right-hand side of (3) is actually a polynomial, since x − 1 divides t (M[P ]; x, y) − t (M[P ]; 1, y). The key observation here is that we cannot simply set x = y = 1 in (3) to obtain an equation linking t (M[P E]; 1, 1) and t (M[P ]; 1, 1). For those familiar with matroid theory, we remark that i() and e() correspond to the internal and external activities of the basis associated to with respect to the order 1 < 2 < · · · < m + r of the ground set of M[P ]. Also, the matroids M[P N ] and M[P E] are obtained from M[P ] by adding an isthmus and taking a free extension, respectively; it is known that formulas (2) and (3) correspond precisely to the effect these two operations have on the Tutte polynomial of an arbitrary matroid. From (1) and the definition of i() and e(), Eq. (2) is clear, since any path associated to M[P N ] has to use the last N step. For completeness, we include a direct proof of Eq. (3). We first rewrite the right-hand side of (3) as x (t (M[P ]; x, y) − t (M[P ]; 1, y)) + yt (M[P ]; 1, y) x−1 x = y e() (x i() − 1) + y e()+1 x − 1 = y e() (y + x + x 2 + · · · + x i() ),
where the sums are taken over all paths that do not go above P. To prove the formula, for each path not above P we find i() + 1 paths not above P E such that their total contribution to t (M[P E]; x, y) is y e() (y + x + x 2 + · · · + x i() ). Consider first the path 0 = E; it clearly does not go above P E and its contribution to the Tutte polynomial is y e()+1 . Now, for each j with 1 j i(), define the path j as the path obtained from by inserting an E step after the jth N step that has in common with P (see Fig. 2). The path j has exactly j N steps in common with P E, and begins with e() E steps. Observe also that, if the jth N step of is the kth step, then and j agree on the first k and on the last m + r − k steps. It remains only to show that each contribution to the Tutte polynomial of M[P E] arises as described above. Let be a path that never goes above P E and consider the last N step that has in common with P E; clearly the next step must be E (in the case where and P E have no N steps in common, this would be the initial E step of ). Let be the path obtained after removing this E step. Since had no N steps in common with P E after the removed E step, the path does not go above P. Thus, the path can be obtained from by adding an E step after the i( )th N step that has in common with P, and hence arises from as above. By the remarks at the end of the previous paragraph, it is clear that cannot be obtained in any other way by applying the procedure described above, and this finishes the proof.
258
A. de Mier, M. Noy / Theoretical Computer Science 346 (2005) 254 – 264
P π
PE
PE
PE π1
π0
π2
Fig. 2. Illustrating the combinatorial proof of formula (3).
3. Main result Let k, l be fixed positive integers, and let Pn = (N k E l )n . Our goal is to count the number of lattice paths from (0, 0) to (ln, kn) that never go above Pn . From the considerations in the previous section, this is the same as computing t (M[Pn ]; 1, 1). Let An = An (x, y) = t (M[Pn ]; x, y). By convention, P0 is the empty path and A0 = 1. In order to simplify the notation we introduce the following operator on two-variable polynomials: x x A(x, y) = A(x, y) + y − A(1, y). x−1 x−1 Then, by Eqs. (2) and (3) we have An+1 = l (x k An ), where i denotes the operator applied i times. For each n0 and i = 1, . . . , l, we define polynomials Bi,n (x, y) and Ci,n (y) as Bi,n = i x k An (x, y) , Ci,n = Bi,n (1, y). We also set C0,n (y) = An (1, y). Note that Bl,n = An+1 and C0,n (1) = An (1, 1) is the quantity we wish to compute.
A. de Mier, M. Noy / Theoretical Computer Science 346 (2005) 254 – 264
259
Then, by the definition of , we have x x k x An + y − C0,n , B1,n = x−1 x−1 x x B2,n = B1,n + y − C1,n , x−1 x−1 .. . x x Bl,n = Bl−1,n + y − Cl−1,n , x−1 x−1 An+1 = Bl,n . In order to solve these equations, we introduce the following generating functions in the variable z (but recall that the coefficients are polynomials in x and y): An zn , Ci = Ci,n zn , i = 0, . . . , l. A= n0
n0
We start from the last equation An+1 = Bl,n and substitute repeatedly the value of Bi,n from the previous equation. Taking into account that n An+1 zn = (A − 1)/z, a simple computation yields l A−1 x i−1 x k+l A + (yx − y − x) C . = l i l−i z (x − 1) i=1 (x − 1)
(4)
We now set y = 1 and obtain l x i−1 (x − 1)l−i Cl−i , A (x − 1)l − zx k+l = (x − 1)l − z i=1
(5)
where it is understood that from now on we have set y = 1 in the series A and Ci . By Puiseux’s theorem (see [8, Chapter 6]), the algebraic equation in w (w − 1)l − zw k+l = 0
(6) has k + l solutions in the field Cfra ((z)) = { n n0 an zn/N } of fractional Laurent series. Proposition 6.1.8 in [8] tells us that exactly l of them are fractional power series (without negative powers of z); let them be w1 (z), . . . , wl (z). We substitute x = wj in (5) for j = 1, . . . , l, so that the left-hand side vanishes, and obtain a system of l linear equations in C0 , C1 , . . . , Cl−1 , whose coefficients are expressions in the wj , namely l i=1
wji−1 (wj − 1)l−i zCl−i = (wj − 1)l ,
j = 1, . . . , l.
(7)
Note that, in order of the product in the left-hand side of (5) to be defined, the solutions of (6) that we substitute in (5) cannot have negative powers of z, hence they must be w1 , . . . , wl . The method of pairing two variables so that one side of an equation vanishes is presently called the kernel method; in our case, the kernel of the equation is (x − 1)l − zx k+l .
260
A. de Mier, M. Noy / Theoretical Computer Science 346 (2005) 254 – 264
We refer the reader to [1] for a list of references on the kernel method, and also to [3,7] for further examples and variations. It remains only to solve (7) to obtain the desired series C0 = n An (1, 1)zn . System (7) can we written as i l−1 wj zCl−i−1 = wj − 1, j = 1, . . . , l. i=0 wj − 1 The left-hand equations can be viewed as the result of evaluating the sides of the previous i of degree l − 1 at X = w /(w − 1), for j with 1 j l. polynomial l−1 (zC )X l−i−1 j j i=0 Using Lagrange’s interpolation formulas, we get that the coefficient of X l−1 in this polynomial is zC0 =
l j =1
i=j
wj − 1 wj wj −1 −
wi wi −1
.
By straightforward manipulation this last expression is equal to −
l
j =1
(1 − wj )
l (wj − 1)l−1 (1 − wj ), =− j =1 j =1 i=j (wj − wi ) l
where the last equality follows from an identity on symmetric functions (set r = 0 in Exercise 7.4 in [8]). Thus, we have proved the following result. Theorem 1. Let k, l be positive integers. Let qn be the number of lattice paths from (0, 0) to (ln, kn) that never go above the path (N k E l )n , and let w1 , . . . , wl be the unique solutions of the equation (w − 1)l − zw k+l = 0 that are fractional power series. Then the generating function Q(z) = given by Q(z) =
n 0 qn z
n
is
−1 (1 − w1 ) · · · (1 − wl ). z
Remark that, by symmetry, the number of paths not above (N l E k )n must be the same as in Theorem 1, although the algebraic functions involved in the solution are roots of a different equation. In the particular case k = be expressed directly in terms of the can l, the solution n for the Catalan numbers, which satisfies generating function G(z) = n 1/(n + 1) 2n z n the quadratic equation G(z) = 1 + zG(z)2 . Indeed, (6) can be rewritten as w = 1 + z1/k w 2 ,
A. de Mier, M. Noy / Theoretical Computer Science 346 (2005) 254 – 264
261
whose (fractional) power series solutions are G(j z1/k ), j = 0, . . . , k − 1, where is a primitive kth root of unity. For instance, for k = l = 3 (corresponding to s = 6, t = 3 in the original problem), = exp(2i/3) and we obtain the solution −1 (1 − G(z1/3 ))(1 − G(z1/3 ))(1 − G(2 z1/3 )) z = 1 + 20z + 662z2 + 26780z3 + 1205961z4 + 58050204z5 + · · · . In the same way, if l divides k and we can be expressed set p = (k + l)/ l, the solution n in terms of the generating function n 1/((p − 1)n + 1) pn n z for generalized Catalan numbers; the details are left to the reader. As an example, for k = 4, l = 2, we obtain the series −1 (1 − H (z1/2 ))(1 − H (−z1/2 )) z = 1 + 15z + 360z2 + 10463z3 + 337269z4 + 11599668z5 + · · · , 3 where H (z) = n 1/(2n + 1) 3n n satisfies H (z) = 1 + zH (z) .
4. A further generalization In this section, we solve a further generalization of the tennis Given fixed ball problem. positive integers s1 , t1 , . . . , sr , tr with ti < si for all i, let s = si , t = ti . There are sn labelled balls. In the first turn we do the following: balls 1, . . . , s1 go into the basket and t1 of them are removed; then balls s1 + 1, . . . , s1 + s2 go into the basket and among the remaining ones t2 are removed; this goes on until we introduce balls s − sr + 1, . . . , s, and remove tr balls. In each successive turn we perform r steps in a similar manner, putting a total of s balls into the basket and removing t. After n turns there are tn balls outside the basket and the question is again how many different sets of tn balls we may have at the end. The equivalent path counting problem is: given k1 , l1 , . . . , kr , lr positive integers with k = ki , l = li , count the number of lattice paths from (0, 0) to (ln, kn) that never go above the path Pn = (N k1 E l1 · · · N kr E lr )n . The solution parallels the one presented in Section 3. We keep the notation and let An = t (M[Pn ]; x, y), so that An+1 = lr (x kr · · · l1 (x k1 An ) · · ·). As before, we introduce l polynomials Bi,n (x, y) and Ci,n (y) = Bi,n (1, y), but the definition here is a bit more involved: Bi,n = i (x k1 An ), i = 1, . . . , l1 , Bl1 +i,n = i (x k2 Bl1 ,n ), i = 1, . . . , l2 , Bl1 +l2 +i,n = i (x k3 Bl1 +l2 ,n ), i = 1, . . . , l3 , .. . Bl−lr +i,n = i (x kr Bl−lr ,n ), i = 1, . . . , lr .
(8)
262
A. de Mier, M. Noy / Theoretical Computer Science 346 (2005) 254 – 264
We also set C0,n (y) = An (1, y). Again, from the definition of , we obtain a set of equations involving An , An+1 = Bl,n , the Bi,n and the Ci,n . We define generating functions A and Ci (i = 0, . . . , l) as in Section 3. Starting with An+1 = Bl,n , we substitute repeatedly the values of the Bi,n from previous equations and set y = 1. After a simple computation we arrive at A (x − 1)l − zx k+l = (x − 1)l + z U (x, C0 , . . . , Cl−1 ),
(9)
where U is a polynomial in the variables x, C0 , . . . , Cl−1 that depends linearly on each Ci . Observe that the difference between (9) and Eq. (5) is that now U is not a concrete expression but a certain polynomial that depends on the particular values of the ki and li . Let w1 , . . . , wl be again the power series solutions of (6). Substituting x = wj in (9) for j = 1, . . . , l, we obtain a system of linear equations in the Ci . Since the coefficients are rational functions in the wj , the solution consists also of rational functions; they are necessarily symmetric since the wj , being conjugate roots of the same algebraic equation, are indistinguishable. Thus, we have proved the following result. Theorem 2. Let k1 , l1 , . . . , kr , lr be positive integers, and let k = ki , l = li . Let qn be the number of lattice paths from (0, 0) to (ln, kn) that never go above the path (N k1 E l1 · · · N kr E lr )n , and let w1 , . . . , wl be the unique solutions of the equation (w − 1)l − zw k+l = 0 that are fractional power series. Then the generating function Q(z) = given by Q(z) =
n 0 qn z
n
is
1 R(w1 , . . . , wl ), z
where R is a computable symmetric rational function of w1 , . . . , wl . As an example, let r = 2 and (k1 , l1 , k2 , l2 ) = (2, 2, 1, 1), so that k = l = 3. Solving the corresponding linear system we obtain R=
(1 − w1 )(1 − w2 )(1 − w3 ) 2w1 w2 w3 − (w1 w2 + w1 w3 + w2 w3 )
and Q(z) =
1 R = 1 + 16z + 503z2 + 19904z3 + 885500z4 + 42298944z5 + · · · . z
It should be clear that for any values of the ki and li the rational function R can be computed effectively. In fact, a simple computer program could be written that on input k1 , l1 , . . . , kr , lr , outputs R.
A. de Mier, M. Noy / Theoretical Computer Science 346 (2005) 254 – 264
263
5. Concluding remarks It is possible to obtain an expression for the generating function of the full Tutte polynomials An (x, y) defined in Section 3. We outline the proof of the formula n0
An (x, y)zn =
−(x − w1 ) · · · (x − wl ) . (zx k+l − (x − 1)l )(y + w1 − yw1 ) · · · (y + wl − ywl )
(10)
Note that taking x = y = 1 we recover the formula stated in Theorem 1 and that this formula generalizes Theorem 5.6 of [2]. From (4), we obtain A((x − 1)l − zx k+l ) = (x − 1)l + z(yx − y − x)
l i=1
x i−1 (x − 1)l Cl−i ,
(11)
where A and the Ci are power series in z whose coefficients are polynomials in x, y and y, respectively. Note that the kernel of the equation is the same as in (5), so it has l roots that are fractional power series, w1 , . . . , wl . Observe that the right-hand side of (11) is a polynomial in x of degreel that vanishes at w1 , . . . , wl ; the leading coefficient of this polynomial is 1 + z(y − 1) l−1 i=0 Ci . Hence, (x − w1 ) · · · (x − wl )(1 + z(y − 1) l−1 i=0 Ci ) A= . (x − 1)l − zx k+l To show thatthis expression is indeed equal to (10), we use again polynomial interpolation to evaluate l−1 i=0 zCi . We obtain that l−1 i=0
zCi =
l i=1
1 − wi ywi − y − wi
wj wj −1 wj wi j =i wi −1 − wj −1
1−
.
After some algebraic manipulation and using again [8, Exercise 7.4], we get that this last expression equals
1 1 −1 + l , y−1 j =1 (y + wj − ywj ) from which (10) follows. On the other hand, Refs. [5,6] also study a different question on the tennis ball problem, namely to compute the sum of the labels of the balls outside the basket for all possible configurations. For a given lattice path Pn , this amounts to computing the sum of all elements in all bases of the matroid M[Pn ]. We remark that this quantity does not appear to be computable from the corresponding Tutte polynomials alone. References [1] C. Banderier, M. Bousquet-Mélou, A. Denise, P. Flajolet, D. Gardy, D. Gouyou-Beauchamps, Generating functions for generating trees, Discrete Math. 246 (2002) 29–55.
264
A. de Mier, M. Noy / Theoretical Computer Science 346 (2005) 254 – 264
[2] J. Bonin, A. de Mier, M. Noy, Lattice path matroids: enumerative aspects and Tutte polynomials, J. Combin. Theory Ser. A 104 (2003) 63–94. [3] M. Bousquet-Mélou, Walks in the quarter plane: Kreweras’ algebraic model, arXiv:math.CO/0401067. [4] R. Grimaldi, J. Moser, The Catalan numbers and the tennis ball problem, Congr. Numer. 125 (1997) 65–71. [5] C.L. Mallows, L.W. Shapiro, Balls in the lawn, J. Integer Sequences 2 (1999). [6] D. Merlini, R. Sprugnoli, M.C. Verri, The tennis ball problem, J. Combin. Theory Ser. A 99 (2002) 307–344. [7] H. Prodinger, The kernel method: a collection of examples, Séminaire Lotharingien Combinatoire 50 (2004) Article B50f. [8] R.P. Stanley, Enumerative Combinatorics, Vol. 2, Cambridge University Press, Cambridge, 1999. [9] W.T. Tutte, A contribution to the theory of chromatic polynomials, Canad. J. Math. 6 (1954) 80–91. [11] D.J.A. Welsh, Complexity: Knots, Colourings and Counting, Cambridge University Press, Cambridge, 1993.
Theoretical Computer Science 346 (2005) 265 – 280 www.elsevier.com/locate/tcs
A multidimensional critical factorization theorem夡 Chiara Epifanio∗ , Filippo Mignosi Dipartimento di Matematica ed Applicazioni, Università degli Studi di Palermo
Abstract The Critical Factorization Theorem is one of the principal results in combinatorics on words. It relates local periodicities of a word to its global periodicity. In this paper we give a multidimensional extension of it. More precisely, we give a new proof of the Critical Factorization Theorem, but in a weak form, where the weakness is due to the fact that we loose the tightness of the local repetition order. In exchange, we gain the possibility of extending our proof to the multidimensional case. Indeed, this new proof makes use of the Theorem of Fine and Wilf, that has several classical generalizations to the multidimensional case. © 2005 Elsevier B.V. All rights reserved. Keywords: Combinatorics on words; Periodicity; Multidimensional words
1. Introduction As Professor M.P. Schutzenberger wrote in 1983, “Periodicity is an important property of words that is often used in applications of combinatorics on words. The main results concerning it are the theorem of Fine and Wilf [. . .] and the Critical Factorization Theorem” (cf. [27]). Since then, combinatorics on words has expanded a great deal and now other results may be added to the previous ones. Among them even an older result that became important because the well-known Sturmian words represent an extremal case for it, the
夡 Partially supported by MIUR National Project PRIN “Linguaggi Formali e Automi: teoria ed applicazioni” and University of Palermo Research Project (ex 60%) “Tecniche per lo sviluppo e l’analisi di algoritmi e strutture dati”.
∗ Corresponding author.
E-mail addresses:
[email protected] (C. Epifanio),
[email protected] (F. Mignosi). 0304-3975/$ - see front matter © 2005 Elsevier B.V. All rights reserved. doi:10.1016/j.tcs.2005.08.012
266
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
Morse-Hedlund Theorem (cf. [35] and see also [28,17,37,23] and references therein). Another important result is a periodicity theorem proved in [31] (cf. also for instance [11,26]), which is a “tight evolution” of a combinatorial lemma firstly proved in [20], used in the design and analysis of a famous string matching algorithm described in the same article (cf. also [13]). In this paper, we will focus on one of the results mentioned by Schutzenberger, the critical factorization theorem, found out by Césari and Vincent in [10] and developed by Duval in [15]. It relates local periodicities of a word to its global periodicity. For a reference on it and on other combinatorial results, see also [11, Chapter 6], [28, Chapter 8], [7, Chapter 3], [26,25], and references therein. For what concerns Computer Science and the theory of Combinatorics on Words, this problem has a long tradition and it is an active research field (cf. for instance [11,27,7,9,15,16,28,26,31,36] and references therein).Among the applications of the critical factorization theorem in this field we recall a famous string matching algorithm, described in [12], and an algorithm that finds a short superstring (cf. [8]). This theorem is also deeply linked with longest unbordered factors of a word and a recently solved famous conjecture by Duval (cf. [22,27,28,33] and references therein). Concerning other fields, the same problem appears also in the theory of long-range order for discrete structures in Rd . Indeed, the recent discovery and study of quasicrystals (cf. [41] and [14]) raises the question: what geometric and physical conditions force a structure to be crystalline rather than quasi-crystalline. Some answers to previous question have been given in [14] where some conditions on “local rules” imply a “global” crystalline structure. (cf. also [14,41,34,38,39,5,24] and references therein). The same problem appears also in [6] with applications in Biology and in the study of spatial structure of proteins. The solution proposed in this paper has been applied in several research studies. The aim of this paper is to give a first generalization of the critical factorization theorem to the multidimensional domain. Up to our knowledge, no such generalization exists in the scientific literature. The techniques used here for proving the first generalization to multidimensional words come from the theory of multidimensional periodicities, that was introduced in their seminal and fundamental work by Amir and Benson in [1–3] (cf. also [4,19,21,40,43,17]). In particular our techniques make use of some results developed in [21]. Recently, we have been able to give a proof of a weak form of the Critical Factorization Theorem, by using the Theorem of Fine and Wilf. For this last theorem, which is the tight version of the periodicity lemma, there exist generalizations to the multidimensional case (cf. [21,32,40,42]). This fact has suggested us to try to extend our proof to the multidimensional case. The paper is organized as follows. In the next section we give some basic definitions and state some fundamental theorems in the unidimensional case. Moreover, we state and prove a weak form of the critical factorization theorem. This proof, as already stressed, will be essential for the demonstration of the main result of the paper. In Section 3, we examine the multidimensional case. Firstly, we give some fundamental definitions and we extend some unidimensional lemmas to this case. Afterwards, we prove our main theorem in the bidimensional case. In fact the proof in this case is simpler to read
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
267
and the one in the d-dimensional case is only a trivial generalization of it that follows the same steps. In Section 4, we describe some research directions that are related to the results of this paper and we state some open problems.
2. Basic definitions and the unidimensional case For any notation not explicitly defined in this paper we refer to [21,27–29]. We begin this paper by considering unidimensional case for words, because it is in some sense the simpler and most deeply studied case and it can help the intuition. Indeed, we will state a weak form of the critical factorization theorem. The alphabet we are considering here is any set, but it is usually finite. We want just to observe that the main results of this paper are alphabet-independent. A bi-infinite word w is a function from Z to the alphabet A. Therefore w(i) is a letter of A that is the image of i by the function w. The set of all bi-infinite words is AZ . Definition 1. Let w be a bi-infinite word. A factor of length n (or block of n consecutive letters, or subword of length n) of w is a word of the form x = w(l)w(l + 1) · · · w(u), such that u − l = n − 1. We accept l to be −∞ and u to be +∞, and not just integers, i.e. we consider also, as factors of w, infinite words. A bi-infinite word w has period p ∈ N, p > 0, or equivalently, p is a period of w if for any i ∈ Z, w(i) = w(i + p). A finite word x has period p if it is a factor of a bi-infinite word having period p, or, equivalently, if w(i) = w(i + p), for any i ∈ Z such that both w(i) and w(i + p) belong to x. If the bi-infinite word w has a period, the smallest of all its periods is called the period of w. If w has no periods, w is called aperiodic and its period is considered to be +∞. Note that for a finite word x, the above definition of periodicity differs from the classical one by the fact that any p greater than the length of x is considered to be a period of x, while it is not in the classical definition. If x is a finite word, we denote by x(i) the ith letter of x. Thus we can write x = x(1) . . . x(n), where n is the length of x. We define the numbers from 1 up to n − 1 to be the positions of x. Roughly speaking, position i lies between letters x(i) and x(i + 1). The set of positions of a bi-infinite word is Z. We now define repetitions and central local periods. Definition 2. Let w be a finite or infinite word.A factor of length n (or block of n consecutive letters) of w, w(j )w(j + 1) · · · w(j + n − 1), is a repetition of order , with 1 a real number, if there exists a natural number p, 0 < p n such that w(i) = w(i + p) for i = j, . . . , j + n − 1 − p and such that n/p . The number p is called a period of the repetition. The smallest of all periods is called the period of the repetition. Note that if a factor of length n is a repetition of order then it is trivially also a repetition of order for any 1 of the same period, because the definition of repetition involves an
268
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
inequality. Any word of length n and period p n has order n/p. Note also that a repetition can have more than one period. Consequently, if a factor x of length n is a repetition of order and period p and if it has also period q, then factor x is a repetition of order (p/q) and period q. As an example let us consider the word w = abaaba. It is a repetition of length 6 and has order 1 with period 6, order 65 with period 5 and order 2 with period 3. In particular the length of the repetition is always a period and, so, any factor is a repetition of order 1 and period its length. We refer to [28] for a formal definition of local period c (w, i) of order in position i of the word w. Roughly speaking c (w, i) is the period of the smallest repetition of order that matches w when the center of the repetition is placed in position i. The match can be virtual, in the sense that it is considered valid also when there are no more letters to match in w. Definition 3. A position i is -critical (or just critical, when is fixed) if c (w, i) coincides with the period of the whole word w. Above definition slightly differs from the corresponding one given in [28], where a critical position represents the maximum of the local periods. Remark 1. Note that if w has period p (where p can also be +∞) then for any and for any i ∈ Z, c (w, i) p. This inequality can be strict for all i, i.e. it may be that there are no -critical points. For instance, if w is the periodic word with period 4 w = . . . 1000100010001000 . . . and if = 43 , then no position is -critical. Indeed the period of w is 4, while w has in every position i a central repetition of order greater than or equal to 43 and period smaller than or equal to 3. In fact, if i is between two 0s, then the central repetition in position i of order greater than or equal to 43 is 00, that has order 2 and period equal to 1. If i has a 1 immediately to the right (resp. left), then the central repetition in position i of order greater than or equal to 43 is 0010 (resp. 0100), that has order exactly equal to 43 and period 3. For another more complex example, we refer to Chapter 8 of [28] where it is shown that if w is the Fibonacci bi-infinite word (that has period +∞), then for any , 1 < 2 and for any i one has that c (w, i) k (w), where k (w) is a constant depending on . In this section, we give a new proof of a weak form of the critical factorization theorem. The weakness is due to the fact that we loose the tightness of the local repetition order. In exchange, we gain the possibility of extending our proof to two dimensions. Indeed, this new proof makes use of the Theorem of Fine and Wilf, that has several classical generalizations to the bidimensional case. Let us, firstly, state two lemmas and the Theorem of Fine and Wilf, that will be helpful for our new proof (see [28, Lemma 8.1.2, Lemma 8.1.3, Theorem 8.1.4]). Lemma 1. Let u, v, w be words such that uv and vw have period p and | v | p. Then the word uvw has period p.
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
269
Lemma 2. Suppose that w has period q and that there exists a factor v of w with | v | q that has period r, where r divides q. Then w has period r. Theorem 1 (Fine and Wilf [18]). Let w be a word having periods p and q, being q p two positive integers. If |w|p + q − gcd(p, q), then w has also period gcd(p, q). Before stating and proving the weak form of the critical factorization theorem, let us give a definition that we will use in our proof. Definition 4. Let w be a word and i, j be two positions of w. We define P (i, j ) = sup{c (w, l) | i l j }. If i and j coincide, respectively, with the first and last positions in w (including the case i = −∞ and j = +∞), we denote P (w) = P (i, j ). The following theorem is, for = 2, the critical factorization theorem. We will prove it for = 4, because under this hypothesis we will be able to use the Theorem of Fine and Wilf. An interval of positions [i, j ], i j of a word w is the set of integers {i, . . . j } that are also positions of w. Its size is its cardinality, that is j − i + 1. Theorem2. Let w be a (finite or infinite) word, [i, j ] be an interval of positions in w, i, j ∈ Z {−∞, +∞} and = 4. (1) Every interval [t1 , t2 ] ⊆ [i, j ], t1 , t2 ∈ Z, of size t2 − t1 + 1 = max(1, P (i, j ) − 1) contains a position l such that c (w, l) = P (i, j ). (2) If i = inf l − · c (w, l) i l j, 2 where l is such that c (w, l) = P (i, j ) , · c (w, l) − 1 i l j, j = sup l + 2 where l is such that c (w, l) = P (i, j ) , then w has period P (i, j ) in [i , j ], where if i is a position in w, i i = the first position in w otherwise, if j is a position in w, j j = the first position in w otherwise. Proof. The proof is by induction on P (i, j ). • If P (i, j ) = 1, c (w, l) = 1 whenever in [i, j ] and then there is only one letter labelling all the positions in this interval. Thus, w has period P (i, j ) = c (w, l) = 1 in the whole [i, j ] and the assertion is trivially true. ˆ jˆ] such • Let us suppose that both assertions of the theorem hold true for all intervals [i, ˆ jˆ)n, n1. Let [i, j ] be an interval such that P (i, j ) = n. We shall prove that that P (i, both statements hold true even in [i, j ].
270
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
Let us assume that there exists, by contradiction, an interval [t1 , t2 ] ⊆ [i, j ] of size equal to max(1, P (i, j ) − 1) = n − 1 that does not contain any position k such that c (w, k) = n. Let us slide this interval to the left or to the right until we find [t1 , t2 ] of size t2 − t1 + 1 = n − 1 such that the first position k , i k j to the left or to the right of [t1 , t2 ] verifies c (w, k ) = n and P (t1 , t2 ) = q < n. This k must exists because P (i, j ) = n. Let us suppose that k is to the left (the proof being analogous in the other case) of the interval, i.e. k = t1 − 1. By the inductive hypothesis we know that each subinterval of size max(1, q − 1) contains a position l such that c (w, l) = P (t1 , t2 ) = q. In particular, there exists at least one such l among the first max(1, q − 1) positions of [t1 , t2 ]. Let l be the smallest among them. By the inductive hypothesis, on the interval [i , t2 ], with if i is a position in w, i i = the first position in w otherwise and
i = inf l − · c (w, l) i l j, where l is such that c (w, l) = P (i, j ) , 2
w is periodic of period q. Claim. Position i belongs to the domain of the word w and, therefore, i = i . Proof of the Claim. Let us suppose, on the contrary, that the claim is false. Since i is the first position in w and l t1 > k , there exists in position k an -local repetition of period q, contradicting the fact that c (w, k ) = n and the claim is proved. By hypothesis, i = l − /2 · c (w, l) = l − 2q. Thus, interval [i , t2 ] has size t2 −i +1 = t2 −(l−2q)+1 t2 −(t1 +q−1−2q)+1 = t2 −t1 +q+2 n−2+q+2 = n+q. Hence the word x = w(i ) . . . w(t2 ) has length greater than or equal to n + q. But x has also period n because it is contained in the repetition of order centered in k . Therefore, we can apply the Theorem of Fine and Wilf to x and we conclude that the word x has period an integer d that divides both n and q. By Lemma 2 this implies that the whole word centered in k has period d, which is absurd because of the minimality of c (w, k ) = n. Therefore, the distance between two different positions l1 and l2 such that c (w, l1 ) = c (w, l2 ) = P (i, j ) = n is at most n − 1 and the first assertion of the theorem is proved. By Lemma 1 the word w has period n in the interval [i , j ], and this concludes the proof. Recall that a critical position l is defined, in this paper, to be a position where the local period c (w, l) is equal to the global period p(w) of the word w. The first part of previous theorem tell us that in every interval of length max(1, P (w) − 1) there is a critical position, while the second part implies that P (w) is equal to p(w). Therefore, the following corollary is straigtforward. Corollary 1. Every interval [t1 , t2 ], with t1 , t2 ∈ Z positions in w, of size t2 − t1 + 1 = max(1, p(w) − 1) contains a critical position.
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
271
3. The multidimensional case and the critical factorization theorem Let us consider, now, the multidimensional case. Analogously to the unidimensional case we may define a d-dimensional word w as a function from a subset X ⊆ Zd to an alphabet A. The set X is called the shape of w and it is denoted by sh(w). A factor v of a multidimensional word w is any restriction of w to any subset Y ⊆ X and clearly sh(v) = Y . A word w is called an n-cubic word or simply a cubic word if its shape sh(w) is either an hypercube of Zd , i.e. it is of the form {j1 , . . . , j1 + n − 1} × · · · × {jd , . . . , jd + n − 1} for some natural number n, or a translate of a quadrant, or the whole Zd . Let us give the definition of multidimensional periodicity for words. Definition 5. Let H be an additive subgroup of Zd , different from 0d = {0d } (the zero subgroup). A multidimensional word w having shape Zd has period H, or equivalently H is a period of w, if for any i ∈ Zd and for any element g of the subgroup H one has that w(i) = w(i + g). A multidimensional word w has period H if it is a factor of a multidimensional word w having shape Zd that has period H. If w has no periods, w is called aperiodic and its period is considered to be +∞. Note that for d = 1, the above definition of periodicity is equivalent to the one given in the unidimensional case, if we consider equivalent the two properties of having period p and having period the subgroup H = p generated by p > 0 (recall that all subgroups of Z can be generated by only one element, that is unique up to a factor ±1). The non-zero subgroups of Zd can only have dimension an integer d , with 1 d d. For instance the word w from Z2 to A = Z defined by w(i1 , i2 ) = i2 has period H1 , where H1 is generated by the element (1, 0) (in short H1 = (1, 0)) and has dimension 1. The word w from Z2 to A = {0, 1, 2, 3} defined by w(i1 , i2 ) = x, where x is the decimal corresponding to the binary number composed of two digits, the first being i1 (mod 2) and the second i2 (mod 2), has period H2 , where H2 is generated by the elements (2, 0) and (0, 2) (in short H2 = (2, 0), (0, 2)). Subgroup H2 has dimension 2. The subgroups of Zd of dimension d are called lattices or fully dimensional subgroups. They are the only subgroups that have finite index. If a factor has period a lattice H, it is called fully periodic. Another remarkable class of subgroups is that of subgroups of dimension 1. They are generated by only one element. Trivially, if H = q then H = −q, and q and −q are the only generators of H. Suppose that H has dimension 1, q is its generator and it is also a period of a factor v. The element q is called periodicity vector of v. It is easy to see that q ∈ Zd is a periodicity vector of v if and only if for any z ∈ Z and for any i ∈ sh(v), such that i + zq ∈ sh(v), one has that v(i) = v(i + zq). Remark 2. If a factor v has period H and if H is a subgroup of H then v has also period H . In particular, if v has period H, for any q ∈ H one has that q is a periodicity vector of v. In the unidimensional case this is equivalent to say that if v has period p then every multiple of p is a period.
272
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
Note that if w is an application from Zd to A and has period H and if g is an application from A to any set B, the word g · w, composition of w and g, from Zd to B has also period H. In other terms, projections preserve the period. Recall that any subgroup H of dimension d > 1 has infinitely many bases, where a basis of H is any set consisting of a minimal number of generators. We give now the classical definition of transversal of a subgroup. Definition 6. Given a subgroup H, a transversal TH of H is a subset of Zd such that for any element i ∈ Z d , there exists an unique element j ∈ TH such that i − j ∈ H . Remark 3. Note that if TH is a transversal of H then for any q ∈ Zd the set q + TH is also a transversal of H. Indeed for any element i ∈ Z d , let us consider i − q. Since TH is a transversal there exists an unique element j ∈ TH such that i − q − j = i − (q + j ) ∈ H . The unique element j = q + j belongs to q + TH , and so q + TH satisfies previous definition. We now define the order of periodicity of factors of w that have an “hypercube” as “shape”. These factors will be used to define what is a local periodicity in the multidimensional case of words. Definition 7. An n-cubic factor v is a repetition of order , with 1 a real number, (or an -repetition), if (1) v is L periodic, where L is a full dimensional subgroup of Zd ; (2) n is such that n/ hL , where hL is the smallest integer such that every hypercube of side length hL contains a transversal of L. The lattice L is called a period of the -repetition v. Definition 8. The word w has a central repetition v of order in position j = (j1 , . . . , jd ) ∈ Zd , if v is a 2n-cubic word that is a repetition of order and shape {−n + 1, . . . , n − 1, n}d that matches w when its center is placed in position j, i.e., more formally, if for any i ∈ sh(v) such that j + i ∈ sh(w) one has that w(j + i) = v(i). We say also that the repetition v is centered in position j. If w has at least a central repetition of order and period L in position j ∈ Zd , the set H of all hL such that every hypercube of side length hL contains a transversal of L is non-empty. We will denote by c (w, j ) the minimum of this set H. If w has no central repetitions of order in position j, we set c (w, j ) = +∞. Note that if an n-cubic factor is a repetition of order then it is also a repetition of order for any 1 of same period because we used an inequality in the definition of repetition. Note also that a factor, and, as well, repetitions can have more than one period. Note also that it is possible to give geometrical properties of the basis vectors of L to satisfy condition 2. For instance, in dimension d = 1, L = p and the property is that hL p. For dimension d = 2, L = (a, b), (c, d), with a > 0 and c > 0 and the requirement is that hL a + c and hL | b | + | d | (cf. [1]).
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
273
We have now all notions necessary to state and prove the main result of the paper. We only need some more “tools” that will play an important role in the proof of it. Let us start by stating a result that is analogous for the multidimensional case to the Periodicity Lemma (cf. [30]). It is an immediate consequence of the generalization to the multidimensional case of the Theorem of Fine and Wilf given in [21]. Let H be a subgroup of Zd , q an element of Zd and v a word and let sh(v) be its shape. Theorem 3. Suppose that v is H-periodic and that q is a periodicity vector for v. If sh(v) ∩ (sh(v) + q) contains a transversal of H then v is also H -periodic, where H = H, q is the lattice generated by H and q. Next two lemmas are the d-dimensional generalizations, respectively of Lemmas 1 and 2. They will be necessary for the proof of Theorem 4, as the unidimensional corresponding ones were necessary for proving Theorem 2. Lemma 3. Let v1 and v2 be two factors of same word w of Zd that have both period the subgroup H. If sh(v1 ) ∩ sh(v2 ) contains a transversal of H then the factor v that has shape sh(v) = sh(v1 ) ∪ sh(v2 ) has also period H. Proof. We have to prove that for any i, j ∈ sh(v), if i − j ∈ H then v(i) = v(j ). Previous equality trivially holds if both i, j belong to sh(v1 ) or to sh(v2 ). We can suppose now, without loss of generality, that i ∈ sh(v1 ) and j ∈ sh(v2 ). Since sh(v1 ) ∩ sh(v2 ) contains a transversal of H, there exists i ∈ sh(v1 ) ∩ sh(v2 ) such that i − i ∈ H . Since v1 has period H and also i ∈ sh(v1 ), v(i) = v1 (i) = v1 (i ) = v(i ). But i belongs also to sh(v2 ), and, moreover i − j = i − i + i − j that belongs to H because both i − i and i − j belong to H. Since v2 has period H and also i ∈ sh(v2 ), v(i ) = v1 (i ) = v1 (j ) = v(j ) and the lemma is proved. Lemma 4. Let v1 and v2 be two factors of the same word w on Zd with sh(v2 ) ⊆ sh(v1 ). Suppose that v1 has period H1 and that v2 has period H2 , with H1 a subgroup of H2 , and that sh(v2 ) contains a transversal of H1 . Under these hypotheses v1 has period H2 . Proof. We have to prove that for any i, j ∈ sh(v1 ), if i − j = h ∈ H2 then v1 (i) = v1 (j ). Since sh(v2 ) contains a transversal of H1 , there exist i , j ∈ sh(v2 ) such that i − i = li ∈ H1 and j −j = lj ∈ H1 . Since sh(v2 ) ⊆ sh(v1 ) and since v1 has period H1 , v1 (i) = v1 (i ) and v1 (j ) = v1 (j ). But i − j = i − i + i − j + j − j = li + lj + h. Since H1 is a subgroup of H2 , li + lj + h ∈ H2 . Since i , j ∈ sh(v2 ), i − j ∈ H2 and v2 has period H2 , v1 (i ) = v2 (i ) = v2 (j ) = v1 (j ) and the lemma is proved. From now on we will deal with bidimensional words and we will state and prove the main result of this paper in that case. In fact, the proof is in this case simpler to read. The proof in the d-dimensional case follows the same steps and it will be not reported here. Moreover, we will focus on squared words. Our result will be proved only in this case.
274
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
X
sh(w) Fig. 1. -repetitions such that c (w, l) = P (X), for = 2.
Definition 9. Let w be a word and X be a square contained in sh(w). We define P (X) = sup{c (w, l) | l ∈ X}. We call a position l critical if there exists a period L of w such that every square of side length c (w, l) contains a transversal of L. Remark 4. We notice that lattice L in above definition depends only on w and c (w, l) and not directly on . Roughly speaking, a position is critical if a local period is also a global period. Theorem 4. Let w be a (finite or infinite) squared bidimensional word, X be a square contained in the shape of w and = 4. (1) Every square T ⊆ X, of side length sd(T ) = max(1, P (X) − 1) contains a position l such that c (w, l) = P (X). (2) Let v be the factor of w the shape of which is the intersection of sh(w) and the union of the shapes of the -repetitions centered in positions l ∈ X such that c (w, l) = P (X). Then v has period L, where L is a subgroup such that every square of side length P (X) contains a transversal of L (Figs. 1, 2). Proof. The proof is by induction on P (X). Let X be the union of the shapes of the repetitions centered in position l ∈ X. If P (X) = 1, there is only one letter labelling all the positions in X and the assertions are trivially true.
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
275
X′
sh(w) Fig. 2. Intersection of sh(w) and the union of the shapes of the -repetitions centered in position l ∈ X.
Let us suppose that the statements of the theorem hold true for all squares T such that P (T )n, n1. Let X be a square such that P (X) = n. Let us assume that there exists, on the contrary, a square T ⊆ X having side length equal to max(1, P (X) − 1) = n − 1 that does not contain any position k such that c (w, k) = n. Let us slide this square in any possible direction until we find a square T such that there exists a position k ∈ X just out, at distance one (by using the distance induced by the sup norm) from the perimeter of T, such that c (w, k) = n. This k must exist because P (X) = n. Notice that P (T ) is smaller than n. We denote this value P (T ) by q. By the inductive hypothesis we know that v has period L2 , where v is the factor of w the shape of which is the intersection of sh(w) and the union T of the shapes of the repetitions centered in position l ∈ T such that c (w, l) = P (T ) = q and L2 is such that every square of side length q contains a transversal of it. Again by the inductive hypothesis, the square C, that has side length sd(T ) + 2(q + 1) and centre T (see Fig. 3) is contained in T . We know that the factor of w that has shape C ∩ sh(w) has period L2 . We know that sh(w) contains both T and the position k. We want to prove that C ∩ sh(w) encloses a square of side length at least sd(T ) + q + 1.
276
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
k
q+1 T
C Fig. 3. Square C, that has side length sd(T ) + 2(q + 1) and center T.
Claim 1. sh(w) is not contained in C. Proof of the Claim 1. Let us suppose, on the contrary, that the claim is false. Since sh(w) is contained in C ∩ sh(w), it has period L2 . Therefore, there exists in position k an local repetition of period L2 , where L2 is such that every square of side length q contains a transversal of it. This contradicts the fact that c (w, k) = n > q and the claim is proved. The shape sh(w) is not contained in C, but encloses T. Hence, it extends at least beyond one side of C. Therefore the side length of sh(w) must be greater than sd(T ) + q + 1. Any intersection of C and a square of side length greater than sd(T ) + q + 1 that contains T must contain a square of side length at least sd(T ) + q + 1. This implies that the intersection of sh(w) and C contains a square C1 of side length at least sd(T ) + q + 1 (see Fig. 4). Notice that C1 can be chosen in such a way that it contains position k. Let us consider the intersection C2 between C1 and the shape of the central -repetition in position k. This is a square of side length 4n, because = 4 and k is such that c (w, k) = n. Since k belongs to C1 and since sd(T )n, this intersection is a square of side length greater than or equal to n + q + 1. This square has periods both L and L2 . The scheme is the same as in the unidimensional case, even if a bit more complicated. We want to apply Theorem 3 in order to prove that this square has a period lattice L4 = L, L2 , generated by both L and L2 and this is proved in the following claim. Claim 2. C2 has period L4 = L, L2 . Proof of the Claim 2. Since every square of side length n contains a transversal of L, there exists a basis {b1 , b2 } of L, L = b1 , b2 , such that every coordinate of both b1 and b2 has
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
k
277
k
q+1
q+1 T
T
C
C sh(w)
sh(w)
k k q+1
q+1 T T
sh(w) sh(w)
C C Fig. 4. All possible locations of C and sh(w). All intersections between C and sh(w) contain a square C1 of side length at least sd(T ) + q + 1.
absolute value smaller than or equal to n. This implies that both b1 and b2 are periodicity vectors for the restriction v of w to the shape C2 . Hence C2 ∩ (C2 + b1 ) and C2 ∩ (C2 + b2 ) contain a square of side length q. We can now apply Theorem 3 to the factor v, having shape C2 , periodicity vector b1 and period lattice L2 and we obtain that v has period lattice the lattice L3 = L2 , b1 . Since L2 is a subgroup of L3 , every square of side length q contains a transversal of L3 . We can again apply Theorem 3 to the factor v, but this time referring to periodicity vector b2 and period lattice L3 . We obtain that v has lattice periodicity the lattice L4 = L3 , b2 = L, L2 and Claim 2 is proved. Since L is a subgroup of L4 and v contains a transversal of L, by Lemma 4 we have that the whole central -repetition in position k has period L4 . This is absurd because, since L2
278
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
is a subgroup of L4 , every square of side length q contains a transversal of L4 , and this contradicts the minimality of c (w, k) = n > q. Therefore, we have proved statement 1 of the theorem. Let l1 and l2 be a couple of positions such that the distance (induced by the sup norm) between them is at most n−1, such that c (w, l1 ) = c (w, l2 ) = P (X) = n. Denote by L1 and L2 the two periods corresponding to the two central -repetitions v1 and v2 . We want to prove that v1 and v2 are -repetitions with the same period L . Since the intersection of the shapes of the two central -repetitions in positions l1 and l2 contains a square having side length at least 3n, we can apply the reasoning used above to prove Claim 2 to conclude that this intersection has period L = L1 , L2 . By Lemma 4 both v1 and v2 are -repetitions with period L . Since every square T ⊆ X, of side length sd(T ) = max(1, P (X)−1) contains a position l such that c (w, l) = P (X), we can iteratively apply this result and conclude that there exists a lattice L that is a period for all -repetitions with centre in a position l ∈ X such that c (w, l) = P (X). We can now iteratively apply Lemma 3 and obtain that L is a period for the restriction of w to sh(w) ∩ X , where X is the union of the shapes of the -repetitions centered in position l ∈ X such that c (w, l) = P (X). Corollary 2. Every square T, with T enclosed in sh(w), of side length sd(T ) = max(1, P (sh(w)) − 1) contains a critical position. 4. Conclusions and open problems It is known that in the unidimensional case the tight value for the critical factorization theorem is = 2. It still remains an open problem to find the tight value of for any dimension d > 1. Is it = 2, as in the unidimensional case? The original critical factorization theorem was the main theoretic tool in a famous string matching algorithm (see [12]) that works with constant additional space. We hope that our results can be helpful in the design and analysis of multidimensional pattern matching algorithms. A further problem is to extend results from the case of multidimensional words to the case of Delone sets, in particular, to extend Theorem 4 (cf. [14] and references therein). Last, but not least, it would be interesting to see if it is possible to extend the Duval Conjecture, or Harju–Nowotka Theorem, to the multidimensional case. This problem is not trivial because it involves the generalization of unidimensional notions, such as the one of unbordered words (cf. [22] and references therein). References [1] A. Amir, G.E. Benson. Two-Dimensional Periodicity and its Applications. Proc. third ACM-SIAM Symp. on Discrete Algorithms, 1992, pp. 440–452.
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
279
[2] A. Amir, G.E. Benson, Alphabet Independent Two-Dimensional Pattern Matching. Proc. 24th ACM Symp. Theory on Computation, 1992, pp. 59–68. [3] A. Amir, G.E. Benson, Two-dimensional periodicity in rectangular arrays, SIAM J. Comput. 27 (1) (1998) 90–106. [4] A. Amir, G.E. Benson, M. Farach, An alphabet independent approach to two dimensional pattern matching, SIAM J. Comput. 23 (2) (1994) 313–323 (preliminary version appeared in STOC 92). [5] F. Axel, D. Gratias, Beyond Quasicrystals, Springer-Verlag and Les Editions de Physiques Les Ulis, 1995. [6] B. Berger, P. Shor, L. Tucker-Kellogg, J. King, Local rule-based theory of virus shell assembly, Proc. Natl. Acad. Sci. USA 91 (1994) 7732–7736. [7] J. Berstel, J. Karhumäki, Combinatorics on Words—A Tutorial, TUCS Technical Report, No. 530, 2003. [8] D. Breslauer, T. Jiang, Z. Jiang, Rotations of Periodic Strings and Short Superstring, J. Algorithms 24 (2) (1997) 340–353. [9] V. Bruyère, G. Hansel, C. Michaux, R. Villemaire, Logic and p-recognizable sets of integers, Bull. Belgium Math. Soc. 1 (1994) 191–238. [10] Y. Césari, M. Vincent, Une caractérisation des mots périodiques, C. R. Acad. Sci. Paris 286A (1978) 1175–1177. [11] C. Choffrut, J. Karhumäki, Combinatorics on Words, in: G. Rozenberg, A. Salomaa (Eds.), Handbook of Formal Languages, Springer, Berlin, 1997. [12] M. Crochemore, D. Perrin, Two-way string-matching, J. Assoc. Comput. Mach. 38 (3) (1991) 651–675. [13] M. Crochemore, W. Rytter, Squares, cubes and time-space efficient string-searching, Algorithmica 13 (1995) 405–425. [14] N. Dolbilin, J. Lagarias, M. Senechal, Multiregular point systems, Discrete & Comput. Geom. 20 (4) (1998) 477–498. [15] J.P. Duval, Périodes et répétitions des mots du monoı¨de libre, Theoret. Comput. Sci. 9 (1979) 17–26. [16] J.P. Duval, Périodes locales et propagation de périodes dans un mot, Theoret. Comput. Sci. 204 (1–2) (1998) 87–98. [17] C. Epifanio, M. Koskas, F. Mignosi, On a conjecture on bidimensional words, Theoret. Comput. Sci. 299 (1–3) (2003) 123–150. [18] N.J. Fine, H.S. Wilf, Uniqueness Theorem for Periodic Functions, Proc. Amer. Math. Soc. 16 (1965) 109–114. [19] Z. Galil, K. Park,Alphabet-independent two-dimensional witness computation, Siam J. Comput. 25 (5) (1996) 907–935. [20] Z. Galil, J. Seiferas, Time-space optimal string matching, J. Comput. and Systems Sci. 26 (1983) 280–294. [21] R. Giancarlo, F. Mignosi, Generalizations of the Periodicity Theorem of Fine and Wilf, CAAP94, Lecture Notes in Computer Science, Vol. 787, pp. 130–141. [22] H. Harju, D. Nowotka, Periodicity and Unbordered Words—A Proof of Duval’s Conjecture, Lecture Notes in Computer Science, Vol. 2996, 2004, pp. 294–304. [23] R. Klette, A. Rosenfeld, Digital straightness—a review, Discrete Appl. Math. 139 (1–3) (2004) 197–230. [24] D. Lenz, Aperiodic linearly repetitive Delone sets are densely repetitive, Discrete & Comput. Geom. 31 (2004) 323–326. [25] A. Lepistö, On Relations between local and global periodicity, Ph.D. Thesis, TUCS Dissertation No. 43, 2002. [26] A. Lepistö, Relations between local and global periodicity of words, in: J. Wiedermann, P. vam Emde Boas, M. Nielsen (Eds.), Proc. ICALP’99, Lecture Notes in Computer Science, Springer, Berlin, Vol. 1664, 1999. [27] M. Lothaire, Combinatorics on Words, Encyclopedia of Mathematics and its Applications, Vol. 17, AddisonWesley, Reading, MA, 1983. [28] M. Lothaire, Algebraic Combinatorics on Words, Encyclopedia of Mathematics and its Applications, Vol. 90, Cambridge University Press, Cambridge, 2002. [29] R.C. Lyndon, P.E. Schupp, Combinatorial Group Theory, Springer, Berlin, 1977. [30] R.C. Lyndon, M.P. Schutzenberger, The equation a m = bn cp in a Free Group, Michigan Math. J. 9 (4) (1962) 289–298. [31] F. Mignosi, A. Restivo, S. Salemi, Periodicity and the golden ratio, Theoret. Comput. Sci. 204 (1–2) (1998) 87–98. [32] F. Mignosi, A. Restivo, P.V. Silva, On fine and Wilf’s theorem for bidimensional words, Theoret. Comput. Sci. 292 (2003) 245–262.
280
C. Epifanio, F. Mignosi / Theoretical Computer Science 346 (2005) 265 – 280
[33] F. Mignosi, L. Zamboni, A note on a Conjecture of Duval and Sturmian Words, RAIRO Theoret. Inform. Appl., 36 (1) (2002) 1–3. [34] R.V. Moody, The Mathematics of long-range aperiodic order, NATO ASI Series, Vol. 489, Kluwer Academic Publishers, Dordrecht, 1997. [35] M. Morse, G.A. Hedlund, Symbolic dynamics II. Sturmian trajectories, Amer. J. Math. 62 (1940) 1–42. [36] A. Muchnik, The definable criterion for definability in Presburger arithmetic and its applications, Theoret. Comput. Sci. 290 (3) (2003) 1433–1444. [37] A. Quas, L. Zamboni, Periodicity and local complexity, Theoret. Comput. Sci. 319 (2004) 229–240. [38] C. Radin, Global order from local sources, Bull. Amer. Math. Soc. 25 (2) (1991) 335–364. [39] C. Radin, The pinwheel tilings of the plane, Ann. Math. 139 (1994) 661–702. [40] M. Regnier, L. Rostami, A Unifying Look at d-Dimensional Periodicities and Space Coverings, Proc. fourth Symp. on Combinatorial Pattern Matching, 1993, pp. 215–227. [41] M. Senechal, Quasicrystals and Geometry, Cambridge University Press, Cambridge, 1995. [42] R.J. Simpson, R. Tijdeman, Multi-dimensional versions of a theorem of Fine and Wilf and a Formula of Sylvester, Proc. Amer. Math. Soc., to appear. [43] L. Vuillon, Local configurations in a discrete plane, Bull. Belgium Math. Soc. 6 (1999) 625–636.
Theoretical Computer Science 346 (2005) 281 – 299 www.elsevier.com/locate/tcs
Implicit surface visualization of reconstructed biological molecules夡 Edgar Garduñoa,∗ , Gabor T. Hermanb a National Center for Microscopy and Imaging Research at the University of California, San Diego, CA, USA b Department of Computer Science, The Graduate Center, City University of New York, New York, USA
Dedicated to the memory of Alberto Del Lungo, friend and collaborator. We miss his smile
Abstract An implicit surface of a density function is the set of points at which the value of the function is equal to a fixed threshold. An object that is defined as the collection of points at which the density function value is above the threshold can be visualized by displaying the implicit surface. Some methods for the reconstruction of biological macromolecules from their electron microscopic projections produce density functions that are specified by a linear combination of smoothly-varying radially-symmetric basis functions of finite support, also known as blobs. When density functions are determined by such a blob representation, the implicit surfaces are smoothly varying and the normal at any point on such a surface can be analytically calculated. This property can be utilized to produce high-quality visualizations by raycasting. While raycasting tends to be computationally expensive, we present a methodology that uses techniques of computer graphics and image processing to significantly reduce the cost of visualization. © 2005 Elsevier B.V. All rights reserved. Keywords: Implicit surfaces; Body-centered cubic grid; Spherically symmetric basis functions; Generalized Kaiser–Bessel functions; Blobs; Algebraic reconstruction techniques; Raycasting
夡
This work has been supported by NIH Grant HL70472.
∗ Corresponding author.
E-mail addresses:
[email protected] (E. Garduño),
[email protected] (G.T. Herman). 0304-3975/$ - see front matter © 2005 Elsevier B.V. All rights reserved. doi:10.1016/j.tcs.2005.08.027
282
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
1. Introduction An essential tool toward the understanding of how living systems function is the visualization of the molecules from which they are constructed. Such molecules cannot be seen directly. A standard device for collecting information about them is the electron microscope. This instrument can be used to obtain projected images of a particular kind of molecule from a number of directions; such images are similar in nature to X-ray images of the human body (but are much noisier and, relative to the size of the molecules, are much less detailed). Multiple images of a molecule are then processed by a reconstruction algorithm, the output of which is a function of three variables that approximates the electron-density distribution in space associated with the molecule. (The molecule is typically distinguishable from its background by having a higher electron density.) Such a function is typically represented as a linear combination of some fixed basis functions; in order to obtain the necessary details, the number of such basis functions tends to be well over a million. A successful choice for the basis functions are the so-called blobs (to be defined below); these are spatially limited and continuously differentiable functions for which closed-form formulas exist to calculate their gradients at any point in space. A consequence of this is that, once the coefficients of the blob decomposition have been obtained by the reconstruction algorithm, the gradient of the reconstructed electron-density distribution can be analytically calculated at any point of the implicit surface that separates the values associated with the molecule from the values associated with its background. This provides us with the ability to visualize the shape of the molecule without having to make approximations in addition to those that were unavoidably introduced by the electron microscopic reconstruction process. (Compare this, for example, with a polygonal approximation of the implicit surface prior to visualization: the display of such a polygonal approximation contains additional inaccuracies both in the location of the implicit surface and in the normal to it.) This paper is devoted to the discussion of how computer graphics techniques can be applied to achieve accurate visualization of biological molecules based on reconstructions that are presented to us as linear combinations of well over a million blobs. This application is essentially different from the constructive solid geometry applications that are the main motivations for many implicit surface visualization papers in the literature (e.g., [16]): we are not trying to design a surface, rather we are trying to accurately visualize a particular surface that exists in nature, based on a representation that is imposed on us by the electron microscopic reconstruction process. What we present below in detail will be one approach to visualizing density functions by two-dimensional (2D) images (generated on a computer screen) that use depth cues to deliver the three-dimensional (3D) information contained in the density functions. Volume and surface rendering (also referred to as direct and indirect volume rendering, respectively) are commonly used in biomedical imaging to create such representations of density functions. Volume rendering is a technique that assumes that the density function to be imaged is made up of one or several translucent objects. The resulting 2D image is a projection of the translucent density function onto the screen. To create this image, the reconstructed density function is discretized into small volume elements (voxels, which can be simple abutting cubes or overlapping ellipsoids [51]), and then the opacities and colors of every object in the density function are computed locally for every voxel.
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
283
Surface rendering assumes that the objects embodied in the density function can be represented by the surfaces enclosing them. The estimation of the surfaces defining the objects generally requires some preprocessing of the density function. One of the common approaches to surface rendering is the polygon-projection method that explicitly approximates an object’s surface by a collection of polygons or other patches [2,5,14,19,20,36,48]. The advantages of one of these two approaches over the other are open to question; both have their strengths and weaknesses [44,46]. A preliminary process of object delineation and identification is assumed in surface rendering, this task is typically challenging and in many occasions does not produce the desired results. Moreover, there are natural objects whose surface representation does not accurately reflect its real structure (e.g., a cloud of particles). Volume rendering, on the other hand, leaves the task of structure recognition to the observer by projecting all the voxels onto the screen; in this case, the identification of structures may be difficult due to the presence of occluding objects. (However, some approaches allow automatic assignment of opacities to voxels so that there is no obstruction to “important” regions of the volume and also provide clues for better interpretation of the information contained within the visible regions [24,25]). In computational terms, identifying the surface of an object can be costly, but once the surface representation is available it is possible to rapidly generate images from any viewpoint (this is particularly true for surfaces approximated by polygons as there exists specialized hardware for polygon projection operations). As opposed to surface rendering, volume rendering is in general a computationally demanding task as it requires the projection of all the voxels in the data set every time the observer’s point of view changes and the computation of absorption, emission and color for every object in the density function can be challenging [43]. Techniques exist, nevertheless, for the combination of object rendering and surface rendering to produce a single image [17,26]. In this paper we use a modality of an algorithm known as raycasting for surface rendering which uses implicit surfaces. This approach is known to produce high quality images (a reason why we selected this modality), but also for its slow performance. (Other approaches using raycasting, but with polygons modeling the surfaces, have been shown to produce high quality images in interactive times [47].) We present a methodology that uses techniques of computer graphics and image processing to significantly reduce the cost of visualizing macromolecular complexes by raycasting. The methodology slightly increases the use of memory but, as we show later, the cost is minimal as compared to the memory use by polygonal methods. In the next section we introduce some basic concepts such as implicit surfaces, basis functions, linear approximation by basis functions, grids, and projections. In Section 3 we present our particular choice for the basis functions. In Sections 4 and 5 we introduce a basic method to visualize implicit surfaces by raycasting with smooth basis functions and apply it to electron microscopy. Section 6 presents our approach to improving the raycasting method and some results. We summarize the paper in Section 7. 2. Background and related work Several techniques have been used to model surfaces, e.g., fractals, hypertextures, particle systems, parametric surfaces. Here we adopt the use of implicit surfaces (also
284
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
called isosurfaces or isointensity surfaces). These are appropriate for objects with complex topologies and geometries, such as organic objects or man-made shapes (see [10] and its references), and therefore have been used to visualize objects of interest in many areas of science. An implicit surface S of a density function is defined as S = {x | (x) = t},
(1)
where x denotes a point in space (mathematically x ∈ R3 ). The assumption is that there is a threshold t such that the object of interest consists of exactly those points at which the value of is greater than the threshold. If the total volume of the object of interest is known (as is the case in some applications, such as electron microscopy), then t is uniquely determined by the criterion that S should enclose exactly the known volume. Consequently, it is sufficient to display the surface S, as defined by (1), of the object of interest for its visualization. A standard way of specifying a density function is by a linear combination (x) =
J
cj bj (x) ,
(2)
j =1
where bj is a set of basis functions, each of which is weighted by a coefficient cj . While the basis functions are selected a priori, the coefficients vary with the density function . In the computer graphics field Blinn introduced the so-called blobby model [9] that uses Gaussians for the basis function. Other basis functions have been suggested since; some examples include multiscale wavelets [39], piecewise quadratics [40], splines [45] and polynomials [49]. In practice, the basis functions have to drop to a negligible value beyond a moderate radius. The idea of using basis functions that are smooth (in the sense of being multiply differentiable everywhere) has been suggested by several authors, motivated by the belief that implicit surfaces of the resulting density functions would reflect more accurately the smoothness of natural objects. This idea has been also adopted in the field of reconstructing surfaces from point sets, typically generated by high resolution scanners, where (2) is used to smoothly approximate the surface represented by the data [3,11,19,30,50]. In the field of reconstruction from projections Lewitt [28,29] and Matej [35] proposed the generalized Kaiser–Bessel window functions, also referred to as blobs, as basis functions. These are functions with compact support, spherical symmetry, and a smooth transition from one to zero. They have proved to be efficacious for a number of reconstruction tasks [18,23,34] and, in particular, the authors of [31,33] obtained results suggesting that the combined use of the so-called algebraic reconstruction techniques (ART) and blobs produce better reconstructions than (or at least as good reconstructions as) those produced by other algorithms. (In both papers, the authors compare ART with other reconstruction algorithms, based on transform methods, using several figures of merit—FOMs—that permit the quantification of the quality of reconstructions of mathematical phantoms. Such FOMs can measure the mean error between a phantom and its reconstruction and, as is more relevant in practice, the success in recovering interesting features of the phantom. For each FOM, a level of statistical significance is assigned to the claim of superiority of one reconstruction method over another.)
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
285
Fig. 1. In the series expansion methods a density function is approximated by the linear combination of basis functions. Smooth basis functions, such as blobs, may reflect more accurately the smoothness of natural objects. The support of a blob is a sphere that we indicate transparently. To approximate a density function, each basis functions bj is weighted by a coefficient cj . The coefficients cj are associated with points p j , which are the centers of the basis functions bj ; we represent these points by small solid spheres. Under this model, a line along which the integral [P ]i is calculated will intersect only a few basis functions.
While the basis functions of (2) are preselected and fixed, the coefficients have to be determined by the reconstruction algorithm. For reconstruction purposes, we consider a projection to be a collection of line integrals. For a function over R3 we define the ray transform as o, x) = (x + o) d. (3) [P] ( R
The operator P provides all the integrated densities along all the lines defined by x + o, where o is a unit vector and ∈ R (see Fig. 1). It follows from (3) and (2) that, for any o, x), ( o, x) = [P] (
J
o, x) . cj Pbj (
(4)
j =1
Suppose that our measurements are made for I lines, characterized by ( oi , x i ), for 1 i I . Then we get yi ≈
J
i,j cj ,
j =1
(5)
where yi is the ith measurement and i,j = Pbj ( oi , x i ), a value that can usually be determined analytically. The reason for the ≈ in (5) is that yi is not exactly [P] ( oi , x i ),
286
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
due to noise in the measurements and the fact that the physical object can only be approximated by an expansion of the form given in (2). Thus (5) is approximately a system of linear equations y = Lc that can be solved either by some sort of direct inversion method or by an iterative method. In practice, the system y = Lc is often overdetermined (to compensate for the noise in the measurements, typically many more measurements are taken than there are unknowns cj ). A particular iterative method to solve the system y = Lc is a generalization of Kaczmarz’s method [21] for solving both over- and underdetermined linear systems of equations. For this generalization, we consider that the matrix L can be divided in N blocks (n denotes the number of a block, 1 n N ) with M rows in each block, and so I = M × N . The kth iterative step of the method is c(k+1) = c(k) + (k)
nM
y −i ,c(k) 2 i=(n−1)M+1 j =1 i,j i J
i , for n = [k (mod N )] + 1,
(6)
where i is a J-dimensional vector whose jth component is i,j and (k) is a relaxation parameter that determines how much the solution is updated in the kth iteration. In practice, the blocks are chosen to correspond to single projections; thus oi has the same value for all i’s in a single block. (N is the number of projections and M is the number of sample points in a projection.) It turns out that, in our application, solving the linear system by (6) is faster than inverting the matrix L because a line intersects only a very few basis functions (see Fig. 1), resulting in a matrix that is sparse (most of its entries are zero valued) whereas a generalized inverse L+ [7] (typically L is not invertible) has mostly non-zero entries. The sparsity of L implies that (6) can be efficiently implemented [35]. When this approach is taken, the result is a representation of a biological molecule that uses blobs to specify density functions. To visualize the molecule we need to render an implicit surface (1), the threshold t for which is determined by the total volume of the molecule (known to us from other sources). To avoid introducing approximations in addition to those that had to be made in the electron microscopic reconstruction process, we desire to visualize the implicit surface directly, without making additional approximations to it. This can be achieved by raycasting, similar to that suggested in [9], with adjustments suitable for data sets produced by reconstruction methods such as ART. 3. Blobs and grids The general form of a single blob is [28]: ⎧ ⎪ ⎨ Im 1 − r 2 r 2 m a b(m, , a; r) = 1− , if ⎪ ⎩ Im () a
0 r a,
(7)
where r is the radial distance from the blob center, Im denotes the modified Bessel function of order m, a is the radius of the blob (the value of b is zero for r > a), and is a parameter controlling the blob shape. The three parameters m (a non-negative integer), a and (nonnegative real numbers) control the smoothness and shape of a blob and influence the results
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
287
yielded by reconstruction and visualization algorithms; therefore, the appropriate selection of them is highly important. Hereafter we set m equal to 2, which makes the blobs to have continuous first derivatives everywhere. The individualblobs bj of (2) are shifted versions of the blob b defined in (7). We refer to the set of points pj to which the centers of the blobs are shifted in such a representation as a grid. As an example for (2) using blobs as basis functions we refer to Fig. 1, in which a density function describing the donut-shaped object is to be approximated by a linear combination of blobs. The grid is represented by the small spheres in Fig. 1. The choice of the grid pj is important. It is shown in [38,42] that the body-centered cubic (bcc) grids provide the most “efficient” sampling of R3 . The bcc grids are defined by B = {k | k ∈ Z3 and k1 ≡ k2 ≡ k3 (mod 2)},
(8)
where k is the transpose of the 3-tuple (k1 , k2 , k3 ) (i.e., a three-dimensional vector), whose components belong to the set of integers denoted by Z and is a positive real number (the sampling distance). In order to visualize this grid, we can use a small portion of it and take advantage of its periodic repetition; see Fig. 2. For reconstruction purposes, Matej and Lewitt [35] demonstrated that whenever a linear combination of blobs is employed to obtain a reconstruction, the bcc grids provide desirable sets of locations for the centers of the blobs. In what follows we will use for p j the set obtained by the intersection of some finite convex region of space with a B of (8). Having decided that we use m = 2 and the bcc grid, there are three parameters to be chosen: , a, and . Clearly, to be able to approximate arbitrary distributions using (2), the value of should be small. However, in a fixed volume of space, the number of grid points (and consequently the cost of a reconstruction algorithm) is proportional to 13 and so practical considerations do not allow us to choose to be very small. The cost of reconstruction (in our implementation using footprints [29,35]) is also proportional to a 2 . The computational cost does not depend on , and so this parameter may be chosen purely based on the quality of the resulting reconstructions. In [35] a method was proposed for the selection of the parameters , a, and with the aim of ensuring that ART will produce “good” reconstructions. This method selects the blob parameters by assuming that a linear combination of blobs with cj = 1, for 1j J , should approximate a constant valued function. For this case, the right hand side of (2) is a convolution of the blob b in (7) with a truncated version of the train of pulses IIIB (pulses arranged on the bcc grid). The Fourier transform of such convolution is approximately F b ∗ IIIB = F {b} × F IIIB . Since F IIIB is also a train of pulses (on a so-called face-centered cubic grid), for this to best approximate the Fourier transform of a constantvalued function (an impulse at the origin) it is useful to select b in such a way that F{b} is zero-valued at the locations of the pulses in F IIIB that have the smallest positive distance from the origin. It follows from this discussion and from the analytic formula for F{b}, available from [29], that we should select =
22
a 2
− 6.9879322 .
(9)
288
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
Fig. 2. Points in the body-centered cubic grid in a 2 × 2 × 2 portion of space (assuming = 1). The rest of the points can be obtained by filling in space by the most natural repetition of the indicated 2 × 2 × 2 portion.
In [15] it was reported that the parameters yielded by the methodology suggested in [35] produced in some cases nonconvex reconstructions from data obtained from convex density functions; causing a significant inaccuracy in the visualization of the resulting implicit surfaces, see Fig. 3. To correct this problem [15] proposes an additional criterion for the selection of the parameters , a, and : a should be chosen as small as possible consistent with both satisfying (9) √ and achieving that if two blobs at nearest grid points in the grid B (those separated by 3) are given coefficients 1 with all other blobs given coefficients 0, then the implicit surface thresholded at t = 0.5 should enclose a convex set, see Fig. 4. The selection of the latter criterion is not arbitrary but is based on the principle that the grid spacing should limit the resolution: nearest grid points should not be resolvable from each other. Using such a second criterion determines a single pair (a, ) among all those that satisfy (9). This is the methodology used in the rest of this paper. 4. A basic raycasting-blobs technique for visualization A suitable method for visualizing the surface in (1) is raycasting. In general, raycasting is slower than the polygon-projection methods. However, an accurate visualization of an implicit surface requires a careful selection of polygons, something that is avoided by raycasting whose accuracy is automatically determined by the pixel locations on the computer screen. Furthermore, implicit surfaces are particularly well suited for ray-intersection processing, since the density function defining the implicit surface enables us to compute the intersection between a ray and the surface by standard numerical zero-finding methods. Raycasting produces a projection of S onto the screen by casting a finite number of rays toward S. In one of its forms, the rays are perpendicular to the plane representing the plane of view, typically the computer screen. In order to produce a foreshortening effect in the
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
289
Fig. 3. Visualization of the implicit surfaces of a reconstructed sphere-shaped “molecule” using parameters (a) = √1 , a = 1.25 and = 3.60 and (b) = √1 , a = 2.40 and = 13.36. (Both these choices satisfy (9).) 2
2
The reconstructed values for the two choices are practically identical, see (c) and (d) for gray-value displays of the central slices of the reconstructions. The artifact in (a) is due not so much to the location of the implicit surface (which is nearly identical for the two cases), but to the directions of the normals at the implicit surface.
final image (the farther the object, the smaller it appears) it is possible to use a perspective projection in which all the rays cast from the screen intersect in a point called the center of projection [48]. Because for the visualization of biological molecules foreshortening does not appear to be important, we present only orthogonal projections. For every ray R that intersects S, we need to find the point q in R ∩ S nearest to the screen, and compute its distance from the screen and the normal to S at q (these are used to assign an intensity value on the computer screen [48]). In practice, the finding of the points q is computationally expensive. In general there is no prior estimate of how far q is from the screen. Clever procedures have been published in the literature that guarantee finding the intersection (if there is one). In most cases these require calculating derivatives associated with the density function ; this, in principle, is not a problem for us since is defined by (2) and the basis functions bj can be analytically differentiated based on (7). Such procedures include ones based on interval analysis [37] and ones that compute a (local) Lipshitz constant [16,22]. A practical difficulty that we perceived with such approaches when applied to our application is that we may end up with such small step sizes for the search as to make the procedure computationally unacceptable. For example, the sphere tracing procedure as described in [16] produces a step size that is inversely proportional to the Lipschitz constant. For our choices of the parameters , a, and , there maybe more than 50 basis functions
290
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
Fig. 4. Representations of the implicit surface at level t = 0.5 for the combination of two blobs whose centers are immediate neighbors in the bcc grid B1/√2 and whose coefficients are 1. We show three surfaces with different values of a and satisfying (9) that produce a concave, a “just convex” and a “too convex” objects, respectively. The parameters , a, and used for (a) and (b) are the same as used for (a) and (b) in Fig. 3. The parameters used for (c) would also result in a smooth-looking visualization of the reconstructed sphere-shaped “molecule,” but it would appear larger than it should be.
making a nonzero contribution to (x) as defined by (2). Using the estimate provided by the fact that the Lipshitz constant of the sum is bounded by the sum of the Lipshitz constants (as suggested in Appendix D.1 of [16]), we get that the step size to be used in the search is inversely proportional to the sum of the 50 or so largest absolute values of the coefficients cj in (2). For this reason we looked for an alternative methodology that makes specific use of the nature of the representation (2) that is the output of the electron microscopic reconstruction process. We first do a preprocessing of the set of grid points pj at the end of which, for every pixel on the screen from which we cast a ray, we have the list of those grid points (arranged in order of increasing distance from the screen) whose associated coefficients can possibly influence the value of the distribution anywhere along the ray. (These grid points all lie within a cylinder of radius a whose central axis is the ray in question.) This preprocessing is easily done by identifying on the screen the shadows of the blobs centered at the grid points, one-by-one in an appropriate order. In locating q for a particular ray, we make use of the associated list of grid points. For all grid points in the list (recall that these are arranged in order of increasing distance from the screen), we evaluate at the projection of the grid point onto the ray (for this we need the blob coefficients for only a few grid points, all of which are at similar positions in the list), until we find (if ever) two consecutive projections onto the ray, qa and qb , such that the value of is below the threshold at qa and is above it at qb . In fact, with the previously discussed methodology for the selection of the parameters , a, and , there are up to only 51 values cj that contribute to the value of at any given point along a ray. Thanks to the radial symmetry and compact support of our basis functions, it is possible to create (just once) a 1D look-up table to represent the blob (7) at a very fine sampling of the radial distance r and so rapidly compute the cj contributions. (Note that it is theoretically possible that there are two consecutive projections of grid points onto the ray such that the value of is below the threshold at both and yet it is above the threshold at some point between them. In this situation, our algorithm will miss this point of the surface and this will cause an inaccuracy in the displayed image of the surface. However the nature
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
291
of our blobs, as defined by (7), makes such an event unlikely: the values of the blobs peak at the grid points and they are circularly symmetric, consequently the contribution of any blob to the value of on the ray is strongest at the projection onto the ray of the grid point that is at the center of the circular support of that blob.) This initial search for qa and qb is limited by a not very large constant (that is the same for all rays). Once two such points qa and qb are found, then q is located by a combination of the Newton–Raphson and the bisection methods [41] within the interval [qa , qb ] (for this we need the coefficients of only those blobs which were used for calculating at qa and at qb ). Under the right circumstances, the Newton–Raphson method has a quadratic rate of convergence, but it can also happen that it moves outside the interval [qa , qb ]. In such a case, we continue our search for q using the bisection method (which is slower but guarantees convergence) within the refined interval produced by the Newton–Raphson method. With our choice of the basis functions bj , a function defined by (2) is continuously differentiable and its gradient, at any point x, is given by ∇ (x) =
J
cj ∇bj (x) .
(10)
j =1
In our application, the set cj is produced by the reconstruction algorithm and we have a closed formula to compute the ∇bj [28]. The visualization obtained by raycasting is therefore an accurate representation of the object of interest, limited only by the reconstruction process and the accuracy of the t in (1). 5. Visualization of reconstructed molecules We obtained from the authors of [6] electron microscopic projections of the complex DnaB·DnaC of Escherichia coli; see Fig. 5. (DnaB and DnaC are two proteins that dock during DNA replication.) We applied the reconstruction method ART with blobs to these data using = √1 , a = 2.40 and = 13.36 (the selection of these values is justified by 2 the discussion in Section 3; see, especially, Figs. 3 and 4). The reconstruction process took 65 h 22 min 48 s and produced a set cj with 1,600,065 values. After reconstruction we applied the raycasting-blobs method just described. The display of the surface, at 512 × 512 pixels resolution, took 1 h 28 min 12 s (all times are for a single-Pentium4䉸 -processor based computer with 2 GHz and 1 Gbytes of RAM operated under Linux© ); see Fig. 6. (We consider that displaying the implicit surface at a resolution higher than 512 × 512
Fig. 5. Four of the images obtained by transmission electron microscopy (i.e., micrographs) of specimens of the DnaB ·DnaC complex of Escherichia coli [6].
292
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
Fig. 6. Three dimensional representation of the reconstructed macromolecular complex DnaB·DnaC produced by the raycasting-blobs method.
is not justified by the quality of the data from which the reconstructions were produced; see Fig. 5.) Because the exact shape of the DnaB·DnaC complex is unknown (i.e., there is no alternative gold-standard methodology which identifies the exact positions of its atoms), we decided to obtain also data from the molecule bacteriorhodopsin [27], for which there is a model of its atoms available in the protein data bank (PDB) [8]. This allows us to compare the rendering of the reconstructed surface with that based on the atomic model. We used the PDB description file to simulate the acquisition process in transmission electron microscopy [12] with programs that permit us to calculate projections with noise from PDB models [13,32]. We utilized the conical tilt scheme (a common geometry in electron microscopy [12]) to create the projections. For the uncertainty of angles we used ±5 degrees for rotation and ±1 degree for tilt, these values are suggested in [31]. For the level of noise in the pixels, we selected the value of 0.5 SNR (see Fig. 7), a value within the range presented in [12] for uncorrelated additive noise with zero mean. We applied ART with blobs to the bacteriorhodopsin data (using the same parameters as used for the DnaB·DnaC reconstruction). The reconstruction process took 36 h 13 min 36 s and produced a set cj with 1,482,624 values. Once again, we applied the raycasting-blobs method described above. In this case, the display of the surface took 1 h 37 min 55 s; see Fig. 8(b). The raycasting method of Section 4 for visualizing implicit surfaces is computationally demanding because of the search, for every ray, for the intersection point q. The times just reported above (over 90 min in both cases) are too long for routine generation of multiple views. In the next section we consider a method to accelerate the raycasting-blobs technique by taking advantage of the properties of the representation in (2) when the bj s are blobs based on (7).
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
293
Fig. 7. Projections (a) without noise and (b) with noise of the molecule bacteriorhodopsin created using an atomic description [8] and simulation programs [13,32].
Fig. 8. (a) Rendering of an implicit surface of the bacteriorhodopsin reconstructed from noiseless projections, some of which are shown in Fig. 7(a). The surface has the same orientation and encloses the same volume as that shown in (b), and serves as the representation of truth. (b) Rendering of an implicit surface of the bacteriorhodopsin reconstructed from noisy projections, some of which are shown in Fig. 7(b). We can compare (b) with the “real” shape of the molecule in (a).
6. Method to speed up the raycasting-blobs technique Our original implementation of the raycasting-blobs method searches, for every pixel of the image displaying the surface, for two points qa and qb that are end points of a line segment containing the point q such that (q) = t. This search is computationally expensive as there are no prior estimates of how far the points qa and qb are from the screen. In fact, the most computationally intensive part of the whole raycasting process is the identification of the interval [qa , qb ] that contains an intersection (if there is such an interval); the actual search for the intersection within the interval can be done in a stable and efficient manner.
294
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
We now introduce a preprocessing method that finds an estimate of the point q, for every casted ray in the image. It first calculates, for every grid point pj , vj = p j and then proceeds to utilize both the set vj and a list of all the j, such that vj t in a z-buffer algorithm [48] that operates as follows. A value is assigned to every ray of the original raycasting-blobs algorithm of Section 4. Initially this value is “infinity” (in practice, a very large number). Then we loop through all j such that vj t. For each corresponding blob, we calculate the distance dj of pj from the screen and, for all rays which intersect the blob, we replace the currently assigned value by dj if, and only if, dj is smaller than the currently assigned value. Upon completion of this process, the value assigned to any ray will be an approximation to the distance qb for that ray in the raycasting algorithm. The new raycasting-blob method utilizes only those rays whose corresponding value in the z-buffer is different from infinity. For every ray of this set, we assume that the value stored in the z-buffer provides a point qc that in most of the cases is near to point qb . We check whether the condition (qc ) t is true. When the condition is not true, we search for qa and qb as we did in the original implementation but starting from the point qc (which is a projection of a grid point in the list associated with the casted ray). In the alternate case, we search for the points qa and qb in the direction toward the plane, again starting from qc . Once the points qa and qb are found, the point q is located as in the original implementation in Section 4. The preprocessing (the calculation of the vj ) took 5 s for the set cj corresponding to the DnaB·DnaC and 6 s for the bacteriorhodopsin. After creating the set vj , we used our modified raycasting method to obtain the computer representation of both the macromolecular complexes DnaB·DnaC and bacteriorhodopsin. When compared pointby-point with those created with the raycasting-blobs method introduced in Section 4 (see Figs. 6 and 8(b)), we found that the images are exactly the same. However, the times to generate the images in Figs. 6 and 8(b) by the original method are around 1.5 h, while the times to generate them by the new method are 94 s and 86 s, respectively; thus reducing the computing time by a factor between 57 and 69, see Table 1. In order to analyze the speed of the new ray casting algorithm, we assume that there are J blobs produced by the reconstruction algorithm and N × N pixels in the image to be displayed. The z-buffer algorithm runs linearly in J. After that, for each of the N 2 rays, we do calculations that is proportionately bounded above by the number of blobs intersected 1 by the ray, and this is of the order J 3 . Assuming, as is reasonable, that N is also of the order 1 J 3 , the whole algorithm is seen to be linear in J. We also compared the results of our approach to those produced by two software packages: OpenDX [1] (a freely-available and popular package, formerly IBM DataExplorer) and Amira䉸 [4] (an integrated software package for 3D visualization and volume modeling that is frequently used in engineering, biological and medical laboratories). Both of these can produce renderings of polygonal approximations of surfaces. The input to the programs requires evaluating at points of a simple cubic grid; such can easily be achieved using (2). We found that in order to obtain image quality similar to what was obtained using our raycasting-blobs algorithms, we needed to create the input to both programs at a minimum of 400 × 400 × 400 points. The resulting images (to be compared
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
295
Table 1 Times necessary to generate images of the complex DnaB·DnaC and the bacteriorhodopsin by both raycastingblobs implementations and by two programs for scientific visualization: OpenDX and Amira䉸 Time Method
Process
DnaB·DnaC
Bacteriorhodopsin
OpenDX
Loading Polygonization Rendering Loading Polygonization Rendering Loading Raycasting Rendering Loading PreProcessing Raycasting Rendering
12 s 43 s 1s 6s 34 s 1s 1s 1 h 28 min 12 s 1s 1s 5s 1 min 27 s 1s
10 s 45 s 1s 6s 33 s 1s 1s 1 h 37 min 55 s 1s 1s 6s 1 min 18 s 1s
Amira䉸
Raycasting-blobs original
Raycasting-blobs speeded
with Figs. 6 and 8(b)) are shown in Fig. 9. The timings for this software are also reported in Table 1. While the total time for generating a single view is only about twice as fast when using OpenDX or Amira䉸 than when using the speeded raycasting-blobs method, if multiple views are desired then the polygon-based techniques are much faster, since (once the polygonization is completed) the projection of the polygons for a new point of view requires only approximately a second. We also compared the memory requirements of the various approaches; see Table 2. We found that our new (speeded) implementation requires actually less memory than the original raycasting-blobs approach and that both raycasting-blobs methods require significantly less memory than the programs OpenDX and Amira䉸 . It is easy to see that, under the same assumptions that were made for the time-complexity analysis, the space-complexity of the raycasting-blobs algorithms is also linear in J.
7. Summary At the end of the electron microscopic reconstruction process, biological macromolecules are often represented as linear combinations of well over a million special basis functions called blobs. The implicit surface separating the reconstructed molecule from its background can be accurately visualized by raycasting. Our initial implementation of this was too slow to allow user interaction. However, one can take advantage of the nature of the blob representation to reduce the time required to visualize molecules by more than a factor of fifty. Compared to popular visualization programs that produce renderings of polygonal approximations of the surfaces, our new implementation is slower but requires less memory to display the implicit surface (rather than a polygonal approximation of it).
296
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
Fig. 9. Visualizations of the explicit surfaces obtained from the reconstructions of the macromolecular complexes DnaB·DnaC (upper row) and bacteriorhodopsin (bottom row). Images in (a) and (c) were produced using the software OpenDX [1] while those in (b) and (d) were produced with Amira䉸 [4], based in both cases on a 400 × 400 × 400 voxelized distribution.
An important advantage of using direct methods to visualize implicit surfaces is that surfaces in nature are frequently highly complex and in some circumstances the programs in charge of polygonization of the implicit surface might generate the wrong representation of the underlying surface or violate the underlying topology of the natural surface. Since the method presented here relies in the model used to reconstruct the biological object, the final representation will depend only on the sampling used between pixels; thus producing, in principle, an accurate representation of the biological surface.
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
297
Table 2 Memory used to generate images of the complex DnaB·DnaC and the bacteriorhodopsin by both raycasting-blobs implementations and by two programs for scientific visualization: OpenDX and Amira䉸 Memory Method
Process
DnaB·DnaC
Bacteriorhodopsin
OpenDX
Digitization
Amira䉸
Loading Polygonization Rendering Digitization
Raycasting-blobs original
Loading Polygonization Rendering Set of coefficients
Raycasting-blobs speeded
Loading Raycasting Rendering Set of coefficients
400 × 400 × 400 16-bit floats 254 Mbytes 514 Mbytes 518 Mbytes 400 × 400 × 400 16-bit floats 245 Mbytes 292 Mbytes 292 Mbytes 1,600,065 16-bit floats 9028 bytes 47,152 bytes 11,956 bytes 1,600,065 16-bit floats 12,062 16-bit floats 15,312 bytes 16,164 bytes 45,292 bytes 18,248 bytes
400 × 400 × 400 16-bit floats 254 Mbytes 512 Mbytes 516 Mbytes 400 × 400 × 400 16-bit floats 245 Mbytes 293 Mbytes 293 Mbytes 1,482,624 16-bit floats 8536 bytes 43,596 bytes 11,548 bytes 1,482,624 16-bit floats 10,566 16-bit floats 14,484 bytes 15,284 bytes 41,688 bytes 17,364 bytes
Reduced set of coeff. Loading PreProcessing Raycasting Rendering
Acknowledgements We thank Carlos Oscar Sánchez Sorzano and José Jesús Fernández for helpful advice regarding this manuscript. We appreciate the assistance of Montserrat Bárcena in providing us with data and information regarding the macromolecular complex DnaB·DnaC.
References [1] G.D. Abram, L. Treinish, An extended data flow architecture for data analysis and visualization, in: Proceedings of IEEE Visualization 1995, IEEE Computer Society, 1995, pp. 263–269. [2] S. Akkouche, E. Galin, Adaptive implicit surface polygonization using marching triangles, Comput. Graphics Forum 20 (2001) 67–80. [3] M. Alexa, J. Behr, D. Cohen-Or, S. Fleishman, D. Levin, C.T. Silva, Computing and rendering point set surfaces, IEEE Trans. Visualization Comput. Graphics 9 (2003) 3–15. [4] Amira: An advanced 3D visualization and volume modeling system, Department for Scientific Visualization of the Konrad-Zuse-Zentrum für Informationstechnik, Berlin, 2001 (http://www.amiravis.com). [5] C.L. Bajaj, G. Xu, Spline approximations of real algebraic surfaces, J. Symbolic Comput. 23 (1997) 315–333.
298
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
[6] M. Bárcena, T. Ruiz, L.E. Donate, S.E. Brown, N.E. Dixon, M. Radermacher, J.M. Carazo, The DnaB·DnaC complex: a structure based on dimers assembled around an occluded channel, European Mol. Biol. Organization J. 20 (2001) 1462–1468. [7] A. Ben-Israel, T.N.E. Greville, Generalized Inverses: Theory and Applications, second ed., Wiley, New York, 2001. [8] F.C. Bernstein, T.F. Koetzle, G.J. Williams, E. Meyer, M.D. Brice, J.R. Rodgers, O. Kennard, T. Shimanouchi, M. Tasumi, The protein data bank, a computer-based archival file for macromolecular structures, J. Mol. Biol. 112 (1977) 535–542. [9] J.F. Blinn, A generalization of algebraic surface drawing, ACM Trans. Graphics 1 (1982) 235–256. [10] J. Bloomenthal, Introduction to Implicit Surfaces, Morgan Kaufmann, San Francisco, 1997. [11] J.C. Carr, R.K. Beatson, J.C. Cherrie, T.J. Mitchell, W.R. Fright, B.C. McCallum, Reconstruction and representation of 3D objects with radial basis functions, in: Proc. 28th Ann. Conf. on Computer Graphics and Interactive Techniques, 2001, pp. 67–76. [12] J. Frank, Three-Dimensional Electron Microscopy of Macromolecular Assemblies, Academic Press, New York, 1995. [13] J. Frank, M. Radermacher, P. Penczek, J. Zhu, M. Ladjadj, A. Leith, SPIDER and WEB: processing and visualization of images in 3D electron microscopy and related fields, J. Struct. Biol. 116 (1996) 190–199. [14] E. Galin, S. Akkouche, Incremental polygonization of implicit surfaces, Graphical Models 69 (2000) 19–39. [15] E. Garduño, G.T. Herman, Optimization of basis functions for both reconstruction and visualization, Discrete Appl. Math. 139 (2004) 95–111. [16] J.C. Hart, Sphere tracing: a geometric method for the antialiased ray tracing of implicit surfaces, Visual Comput. 12 (1996) 527–545. [17] H. Hauser, L. Mroz, G.I. Bischi, M.E. Groller, Two-level volume rendering, IEEE Trans. Visualization Comput. Graphics 7 (2001) 242–252. [18] G.T. Herman, Algebraic reconstruction techniques in medical imaging, in: C.T. Leondes (Ed.), Medical Imaging Systems Techniques and Applications—Computational Techniques, Gordon and Breach Science Publishers, Amsterdam, 1997, pp. 1–42. [19] M. Jackowski, M. Satter, A. Goshtasby, Approximating digital 3D shapes by rotational Gaussian surfaces, IEEE Trans. Visualization Comput. Graphics 9 (2003) 56–69. [20] X. Jin, H. Sun, Q. Peng, Subdivision interpolating implicit surfaces, Comput. Graphics 27 (2003) 763–772. [21] S. Kaczmarz, Angenäherte Auflösung von Systemen Linearer Gleichungen, Bull. Acad. Polonaise Sci. Lett. Ser. A 35 (1937) 355–357. [22] D. Kalra, A.H. Barr, Guaranteed ray intersections with implicit surfaces, ACM SIGGRAPH Comput. Graphics 23 (1989) 297–306. [23] P.E. Kinahan, S. Matej, J.S. Karp, G.T. Herman, R.M. Lewitt, A comparison of transform and iterative techniques for a volume-imaging PET scanner with a large acceptance angle, IEEE Trans. Nucl. Sci. 42 (1995) 2281–2287. [24] G. Kindlmann, D. Weinstein, Hue-balls and lit-tensors for direct volume rendering of diffusion tensor fields, in: Proceedings of IEEE Visualization 1999, IEEE Computer Society, 1999, pp. 183–189. [25] G. Kindlmann, D. Weinstein, D. Hart, Strategies for direct volume rendering of diffusion tensor fields, IEEE Tran. Visualization Comput. Graphics 6 (2000) 124–138. [26] K. Kreeger, A. Kaufman, Mixing translucent polygons with volumes, in: Proceedings of IEEE Visualization 1999, IEEE Computer Society, 1999, pp. 191–199. [27] W. Kühlbrandt, Bacteriorhodopsin—the movie, Nature 406 (2000) 569–570. [28] R.M. Lewitt, Multidimensional digital image representations using generalized Kaiser–Bessel window functions, J. Opt. Soc. Amer. A: Opt. Image Sci. Vision 7 (1990) 1834–1846. [29] R.M. Lewitt, Alternatives to voxels for image representation in iterative reconstruction algorithms, Phys. Med. Biol. 37 (1992) 705–716. [30] Q. Li, D. Wills, R. Phillips, W.J. Viant, J.G. Griffiths, J. Ward, Implicit fitting using radial basis functions with ellipsoid constraint, Comput. Graphics Forum 23 (2004) 55–69. [31] R. Marabini, G.T. Herman, J.M. Carazo, 3D reconstruction in electron microscopy using ART with smooth spherically symmetric volume elements (blobs), Ultramicroscopy 72 (1998) 53–65. [32] R. Marabini, I.M. Masegosa, M.C. San Martin, S. Marco, J.J. Fernández, L.G. de la Fraga, C. Vaquerizo, J.M. Carazo, Xmipp: an image processing package for electron microscopy, J. Struct. Biol. 116 (1996) 237–240.
E. Garduño, G.T. Herman / Theoretical Computer Science 346 (2005) 281 – 299
299
[33] R. Marabini, E. Rietzel, R. Schröder, G.T. Herman, J.M. Carazo, Three-dimensional reconstruction from reduced sets of very noisy images acquired following a single-axis tilt schema: application of a new threedimensional reconstruction algorithm and objective comparison with weighted backprojection, J. Struct. Biol. 120 (1997) 363–371. [34] S. Matej, G.T. Herman, T.K. Narayan, S.S. Furuie, R.M. Lewitt, P.E. Kinahan, Evaluation of task-oriented performance of several fully 3D PET reconstruction algorithms, Phys. Med. Biol. 39 (1994) 355–367. [35] S. Matej, R.M. Lewitt, Practical considerations for 3-D image reconstruction using spherically symmetric volume elements, IEEE Trans. Med. Imaging 15 (1996) 68–78. [36] K.H. Min, I.-K. Lee, C.-M. Park, Component-based polygonal approximation of soft objects, Comput. Graphics 25 (2001) 245–257. [37] D.P. Mitchell, Robust ray intersection with interval arithmetic, in: Proceedings of Graphics Interface, 1990, pp. 68–74. [38] H. Miyakawa, Sampling theorem of stationary stochastic variables in multi-dimensional space, J. Inst. Electron. Commun. Eng. Jpn. 42 (1959) 421–427. [39] S. Muraki, Multiscale volume representation by a DoG wavelet, IEEE Trans. Visualization Comput. Graphics 1 (1995) 109–116. [40] H. Nishimura, M. Hirai, T. Kawai, T. Kawata, I. Shirakawa, K. Omura, Object modeling by distribution function and a method of image generation, Trans. Inst. Electron. Commun. Eng. Jpn. J68-D (4) (1985) 718–725. [41] C.E. Pearson, Numerical Methods in Engineering and Science, Van Reinhold Company, Inc., New York, 1986. [42] D.P. Petersen, D. Middleton, Sampling and reconstruction of wave-number-limited functions in N-dimensional Euclidean spaces, Inform. Control 5 (1962) 279–323. [43] H. Pfister, B. Lorensen, C. Bajaj, G. Kindlmann, W. Schroeder, L.S. Avila, K.M. Raghu, R. Machiraju, J. Lee, The transfer function bake-off, IEEE Comput. Graphics Appl. 21 (3) (2001) 16–22. [44] R. Shahidi, Surface rendering versus volume rendering in medical imaging: techniques and applications (panel), in: Proceedings of IEEE Visualization 1996, IEEE Computer Society, 1996, pp. 439–440. [45] G. Turk, J.F. O’Brien, Shape transformation using variational implicit functions, in: Proc. 26th Ann. Conf. on Computer Graphics and Interactive Techniques, 1999, pp. 335–342. [46] J.K. Udupa, H. Hung, K. Chuang, Surface and volume rendering in three-dimensional imaging: a comparison, J. Digital Imaging 4 (1991) 159–168. [47] I. Wald, P. Slusallek, C. Benthin, M. Wagner, Interactive rendering with coherent ray tracing, in: Proceedings of EUROGRAPHICS 2001, Vol. 20, 2001, pp. 153–164. [48] A.H. Watt, 3D Computer Graphics, second ed., Addison-Wesley Pub. Co., Reading, Mass., 1993. [49] G. Wyvill, C. McPheeters, B. Wyvill, Data structure for soft objects, Visual Comput. 2 (1986) 227–234. [50] M. Zwicker, H. Pfister, J. van Baar, M. Gross, Surface splatting, in: Proc. 28th Ann. Conf. on Computer Graphics and Interactive Techniques, 2001, pp. 371–378. [51] M. Zwicker, H. Pfister, J. van Baar, M. Gross, EWA splatting, IEEE Trans. Visualization Comput. Graphics 8 (2002) 223–238.
Theoretical Computer Science 346 (2005) 300 – 306 www.elsevier.com/locate/tcs
Reduction from three-dimensional discrete tomography to multicommodity flow problem Y. Gerard∗ LLAIC, IUT, Ensemble Universitaire des Cézeaux, 63172 Aubière, France
Abstract The reduction from two-dimensional-discrete tomography to max-flow problem is well-known [Gale, A theorem on flows in networks, Pacific J. Math. 7 (1957) 1073–1082]. This approach is based on the natural correspondence between two-dimensional lattices and bipartite graphs. We extend this result in dimension 3 by reducing three-dimensional discrete tomography to multicommodity flow problems. Two reductions are presented, one considering discrete tomography with multisets while the other one works with sets. © 2005 Elsevier B.V. All rights reserved. Keywords: Multiset; Flow-max problem; Integer multicommodity flow problem
1. Introduction The expression of two-dimensional-discrete tomography in terms of graphs is known since the first steps of this field [4,6,8]. The numbers of points of a lattice set belonging to each row and column correspond with the numbers of edges issued from the vertices of the corresponding subgraph (Fig. 1). This correspondence provides a reduction from two-dimensional-discrete tomography to flow-max problem (Fig. 2). The purpose of this paper is to extend this reduction to three-dimensional discrete tomography according to three linearly independent directions (a problem that we call 3DT) (Fig. 3). ∗ Tel./fax: +33 (0)4 73 17 71 39.
E-mail address:
[email protected]. 0304-3975/$ - see front matter © 2005 Elsevier B.V. All rights reserved. doi:10.1016/j.tcs.2005.08.016
Y. Gerard / Theoretical Computer Science 346 (2005) 300 – 306
301
Fig. 1. A two-dimensional lattice set and its corresponding graph. The number of points of the lattice set in row Ri (with 1 i 5) is equal to the number of edges of the graph issued from vertex Ri . The number of points of the lattice set in column Cj (with 1 j 6) is the number of edges of the graph issued from vertex Cj .
Fig. 2. An instance of two-dimensional discrete tomography and its encoding in a flow-max instance. The capacities of the edges of the bipartite graph (from the left to the right) are all 1. With this instance, the maximal flow is bounded by 1 + 3 + 2 + 3 + 1 = 1 + 2 + 1 + 2 + 2 + 2 = 10. A solution of the discrete tomography problem is given by the set of edges involved in a flow equal to 10.
Fig. 3. An instance of 3DT.
Problem 1 (3DT). Given: three positive integers m, n, l and three positive integer matrices (ri,k )1 i m,1 k l , (cj,k )1 j n,1 k l and (vi,j )1 i m,1 j n verifying lk=1 ri,k = m l n m n j =1 vi,j , i=1 vi,j = k=1 cj,k and j =1 cj,k = i=1 ri,k . Question: existence of a lattice set of [1..m] × [1..n] × [1..l] having for any (i, j, k) ∈ [1..m] × [1..n] × [1..l] exactly ri,k points verifying x = i and z = k, cj,k points verifying y = j and z = k and vi,j points verifying x = i and y = j ?
302
Y. Gerard / Theoretical Computer Science 346 (2005) 300 – 306
We reduce problem 3DT to an extension of flow-max problem called integer multicommodity flow (MCF) [1] problem. We begin in next section with a natural reduction from 3DT to MCF. This reduction works if l = 2 or if one of the matrices is binary but unfortunately, in the general case, it provides multisets instead of sets. This result being not satisfying, we provide in Section 3 another reduction supplying real sets of solutions with a heavier device.
2. Reduction from 3DT to MCF in the framework of multisets 2.1. Multicommodity flow problem The source and the terminal of a flow-max instance are not enough for encoding the variable number of levels of a 3DT instance. A reduction requires more sources and more terminals. It is the framework of a classical problem of combinatorial optimization called integer multicommodity flow and denoted MCF: Problem 2 (MCF). Given: (1) G(V , E) a directed finite graph of vertices V and of edges E (the edge from u to v is denoted u → v). (2) a capacity function (capacity : E → N). (3) an integer K providing the number of commodities. (4) a list of K vertices (sk )1 k K called “sources”. (5) a list of K vertices (tk )1 k K called “terminals”. (6) a list of K positive integers (f mink )1 k K providing the required flow of each commodity. Question: Does there exist a function fk : E → N of indices between 1 and K verifying (a) for any edge u → v ∈ E, K k=1 fk (u → v)capacity(u → v) (b) for any vertex v ∈ V /{sk ,tk /1 k K} and any index k ∈ {1 · · · K}, we have u→v∈E × fk (u → v) = v→w∈E fk (v → w) (c) Fk = sk →v∈E f (sk → v) f mink (we have also Fk = u→tk ∈E fk (u → tk )). MCF is a problem of flow where each commodity issued from a given source sk is directed towards the corresponding terminal tk , the final value of the flow being Fk (Fig. 4). This class of problems is proved to be NP-complete since 1976 by Even, Itai, and Shamir in a paper also proving the NP-completeness of 3DT with l = 3 and binary matrices [2,5]. The original proofs of these two results are independent, whereas we are going to show that 3DT can be reduced to MCF.
Fig. 4. An instance of MCF with three commodities and a solution represented with three grey levels on the right.
Y. Gerard / Theoretical Computer Science 346 (2005) 300 – 306
303
Fig. 5. The instance of MCF built from the 3DT instance drawn in Fig. 3.
2.2. Reduction with multiplicities From an instance of three-dimensional discrete tomography 3DT, we build an instance of MCF problem (we assume that l > 1) as follows: • Take K = l − 1 as number of commodities. • Put in V the vertices Ri corresponding to the rows (with 1 i m), the vertices Cj corresponding to the columns (with 1 j n) and 2.K other vertices denoted sk and tk with 1k K. • Put in E the mK edges going from vertices sk (with 1 k K) to the vertices Ri (with 1 i m) and choose capacity(sk → Ri ) = ri,k . • Add in E all the nK edges going from the vertices Cj (with 1 j n) to the vertices tk (with 1k K) and choose Cj → tk namely capacity(Cj → tk ) = cj,k . • Add in E the mn edges going from the vertices Ri to the vertices Cj with 1 i m, 1 j n and choose capacity(R n i → Cj ) = vi,j . r = • Take f mink = m i,k i=1 j =1 cj,k for any index k between 1 and l − 1. It provides a multicommodity instance of MCF (Fig. 5). Let us assume now that the MCF instance built from the 3DT instance has a solution (fk )1 k K . We define from this solution a multiset S of the lattice [1..m]×[1..n]×[1..l]: the multiplicity (i, j, k) of the point (i, j, k) in S is (i, j, k) = fk (Ri → Cj ) if 1 k l − 1 while (i, j, l) = vi,j − K k=1 fk (Ri → Cj ) if k = l (condition (a) guarantees that it is a positive integer). Let us prove that the multiset S is a solution of the instance of 3DT. The satisfaction of the vertical constraints lk=1 (i, j, k) = vi,j is a direct consequence of the definition of the multiplicities of thepoints (i, j, l). For any index 1k l − 1, the satisfaction m of the horizontal constraints m i=1 (i, j, k) = cj,k comes from the opposite inequalim ties k (Ri → Cj ) = fk (Cj → tk ) capacity(Cj→ tk ) = i=1 (i, j, k) = i=1 f m,n n cj,k and m,n (i, j, k) = j =1 cj,k . i=1,j =1 i=1,j =1 fk (Ri → Cj ) = Fk f mink = m l−1 m About the points in level k = l, we have i=1 (i, j, l) = i=1 (vi,j − k=1 fk (Ri → m,l−1 m l Cj )) = m i=1 vi,j − i=1 (i, j, l) = k=1 cj,k − i=1,k=1 fk (Ri → Cj ). It leads to l−1,m l l−1 n (i, j, k) = c − c = c . Symmetric arguments prove j,l k=1 j,k j =1 k=1 j,k k=1,i=1 (i, j, k) = ri,k for any pair of indices (i, k) ∈ [1..m] × [1..l].
304
Y. Gerard / Theoretical Computer Science 346 (2005) 300 – 306
Conversely, there is no difficulty to verify that a multiset solution of a 3DT instance provides a flow fk (Ri → Cj ) = (i, j, k) verifying all conditions (a)–(c) of the corresponding MCF instance. As the time of computation of the MCF instance is linear in the size of the 3DT instance, we have proved the following proposition: Proposition 3. 3DT with multisets can be polynomially reduced to MCF with l − 1 commodities. In several cases, this reduction allows to obtain multisets with binary multiplicities namely sets. It is the case if one of the matrices (ri,k ), (ci,k ) or (vi,j ) is binary. Then a corollary of Proposition 3 and of the NP-completeness of 3DT with l = 3 and binary matrices [2] is the NP-completeness of MCF with only two commodities (see [2] for the original proof). Another case where this reduction can be used is l = 2. In this framework, the feasible values vi,j are 0, 1 and 2, but when a value vi,j is 2, there is no ambiguity about the points: we can delete them temporarily by replacing the value vi,j by 0 and decrementing ri,k and cj,k . It reduces problem 3DT with l = 2 to an instance of 3DT with l = 2 and a binary matrix (vi,j ). The reduction to MCF leads to an instance of MCF problem with only one commodity. This problem can be solved in polynomial time by any max-flow algorithms and, for instance, by the augmenting path method [3]. It proves the following result: Proposition 4. 3DT with l = 2 can be solved in polynomial time. This result was already given in [2], where a direct polynomial algorithm is presented without any reference to max-flow algorithms.
3. Reduction from 3DT to MCF in the framework of sets If l > 2 and if there is no binary matrix in (ri,k ), (ci,k ) or (vi,j ), the previous reduction from 3DT to MCF provides multisets. The constraint to supply sets requires another reduction based on a more complex device. This new reduction is again built on the principle of reduction of two-dimensional-discrete tomography but it requires now more vertices and more edges (Fig. 6): • Take K = l as number of commodities. • Put in V 2.l vertices denoted sk and tk with 1 k l, lm vertices Ri,k corresponding to the rows (with 1i m and 1k l), ln vertices Cj,k corresponding to the columns (with corresponding to the vertical lines 1 j n and 1k l), and 2mn vertices Vi,j and Vi,j (with 1i m and 1 j n). • Put in E the ml edges going from vertices sk to the vertices Ri,k with capacity capacity(sk → Ri,k ) = ri,k . • Add in E the nl edges going from the vertices Cj,k to the vertices tk with capacity capacity(Cj,k → tk ) = cj,k . • Add in E the mnl edges going from the vertices Ri,k to the vertices Vi,j with capacity capacity(Ri,k → Vi,j ) = 1.
Y. Gerard / Theoretical Computer Science 346 (2005) 300 – 306
305
Fig. 6. The MCF instance built from the 3DT instance drawn in Fig. 3.
with capacity • Add in E the mn edges going from the vertices Vi,j to the vertices Vi,j )=v . capacity(Vi,j → Vi,j i,j to the vertices C • Add in E the mnl edges going from the vertices Vi,j j,k with capacity capacity(Vi,j → Ck,j ) = 1. n • Take f mink = m i=1 ri,k = j =1 cj,k for any index k between 1 and l. Each commodity corresponds to a level k of the 3DT instance and we are not very far to solve each one independently as in dimension 2 with vertices sk , Ri,k , Cj,k and tk . For any pair (i, j ), we take care of the vertical projection by concentrating the flows going from whose capacity is exactly v vertices Ri,k to vertices Cj,k through the edge Vi,j → Vi,j i,j (Fig. 6). This structure controls the numbers of points in the vertical lines. A solution of the 3DT instance is obtained from a solution of the corresponding MCF instance by taking as ) = f (V → C ). The multiplicities (i, j, k) = fk (Ri,k → Vi,j ) = fk (Vi,j → Vi,j k i,j k,j multiplicity of (i, j, k) is now guaranteed to be 0 or 1 by the capacities of edges Ri,k → Vi,j → C or Vi,j k,j equal to 1. Conversely, a solution of the 3DT instance provides a solution of the corresponding MCF instance by taking the flows fk (Ri,k → Vi,j ) = fk (Vi,j → ) = f (V → C ) = (i, j, k). This sketch of proof leads to the following result: Vi,j k i,j k,j
Proposition 5. 3DT with sets can be polynomially reduced to MCF with K = l commodities.
306
Y. Gerard / Theoretical Computer Science 346 (2005) 300 – 306
4. Conclusion The second reduction from 3DT to MCF is more complicated than the first method but it yields only sets, whereas the first coding provides multisets. In the cases where they both provide sets namely if one of the matrices of the instance of 3DT is binary or if l = 2, the first reduction should be chosen rather than the other one because it requires one commodity less without speaking about the numbers of edges and vertices which are significantly smaller. This reduction is more efficient. These two encodings translate three-dimensional discrete tomography instances in MCF problems which can be solved by any method of this field. References [1] R.K. Ahuja, T.L. Magnanti, J.B. Orlin, Network Flows: Theory, Algorithms, and Applications, Prentice-Hall, Englewood Cliffs, NJ, 1993. [2] S. Even, A. Itai, A. Shamir, On the complexity of timetable and multicommodity flow problems, SIAM J. Comput. 5 (1976) 691–703. [3] L.R. Ford, D.R. Fulkerson, Flows in Networks, Princeton University Press, Princeton, NJ, 1962. [4] D. Gale, A theorem on flows in networks, Pacific J. Math. 7 (1957) 1073–1082. [5] M.R. Garey, D.S. Johnson, Computer and Intractability: A Guide to the Theory of NP-Completeness, W.H. Freeman, New York, 1979. [6] G.T. Herman, A. Kuba, Discrete Tomography: Foundations, Algorithms and Applications, Birkhaüser, Basel, 1999. [8] H.J. Ryser, Combinatorial properties of matrices of zeros and ones, Canad. J. Math. 9 (1957) 371–377.
Theoretical Computer Science 346 (2005) 307 – 334 www.elsevier.com/locate/tcs
Enumeration of symmetry classes of convex polyominoes on the honeycomb lattice夡 Dominique Gouyou-Beauchampsa , Pierre Lerouxb,∗ a LRI, CNRS—Université Paris-Sud 11, France b LaCIM, UQAM, Dept. de Mathematiques, C.P. 8888 Succursale Centre-Ville, Montreal (QC),
Canada H3C 3P8
Abstract We enumerate the symmetry classes of convex polyominoes on the hexagonal (honeycomb) lattice. Here convexity is to be understood as convexity along the three main column directions. We deduce the generating series of free (i.e. up to reflection and rotation) and of asymmetric convex hexagonal polyominoes, according to area and half-perimeter. We give explicit formulas or implicit functional equations for the generating series, which are convenient for computer algebra. Thus, computations can be carried out up to area 70. © 2005 Elsevier B.V. All rights reserved.
1. Introduction A hexagonal polyomino is a finite connected set of basic cells of the honeycomb lattice in the plane. Note that the hexagons of our lattice have two sides parallel to the horizontal axis. See Fig. 1. Unless otherwise stated, all the polyominoes considered here are hexagonal. The area of a polyomino is the number of cells composing it. Its perimeter is the number of line segments on its boundary. We say that a polyomino is convex along a direction if the intersection with any line parallel to this direction and passing through the center of a cell 夡 With the partial support of CNRS (France), NSERC (Canada) and FCAR (Québec). This is the full version of a paper presented at the FPSAC Conference in Vancouver, Canada, June 28–July 2, 2004 (see [3]).
∗ Corresponding author. Tel.: 514 987 3000 3236; fax: 514 987 8274.
E-mail address:
[email protected] (P. Leroux). 0304-3975/$ - see front matter © 2005 Elsevier B.V. All rights reserved. doi:10.1016/j.tcs.2005.08.025
308
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
Fig. 1. A convex polyomino and its convexity directions.
is connected. The convexity directions are characterized by the angle (0 ) which they form with the positive horizontal axis. Various convexity concepts have been introduced in the literature for hexagonal polyominoes, depending on the required convexity directions. Following the nomenclature of Denise et al., [2], we mention the EG-convex polyominoes, where = 0 and /2, studied by Guttmann and Enting [5] and by Lin and Chang [10], the C 1 -convex polyominoes, where = /2, enumerated according to many parameters by Lin and Wu [11] and by Fereti´c and Svrtan [4], the strongly convex polyominoes, where = 0, /3 and 2/3, introduced by Hassani [7] and studied in [7,2], and finally the C- or C 3 -convex polyominoes, where = /6, /2 and 5/6, introduced and enumerated according to perimeter in [7,2]. In particular, Hassani gives explicitly the algebraic generating function for C-convex polyominoes according to half perimeter. It is this last class that interests us here, and that we call simply convex polyminoes. See Fig. 1 for an example. This concept is a natural extension of (row and column) convexity on the square lattice. These polyominoes are traditionally taken up to translation. However it is natural to consider them also up to rotation and reflection, as objects living freely in space. Following Vöge et al. [6], we call these equivalence classes free polyominoes. In organic chemistry, free polyminoes (without holes) represent benzenoid hydrocarbons. See [6] where these molecules (without the convexity property) are enumerated by an exhaustive generation approach. Our objective is to enumerate free convex polyominoes, according to area and half perimeter. Following the approach of Leroux et al. [9] for the square lattice, we consider them as orbits of the dihedral group D6 (the group of isometries of the regular hexagon), acting on convex polyominoes. The Cauchy–Frobenius Formula (alias Burnside’s Lemma) can be used to count the orbits and we are thus lead to enumerate the symmetry classes Fix(h) of convex polyominoes, for each element h of the group D6 . It is also possible to enumerate convex polyominoes which are asymmetric or which have exactly the symmetries of a given subgroup H of D6 , using Möbius inversion in the lattice
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
309
of subgroups of D6 . For this purpose, we also enumerate the symmetry classes F H for each subgroup H of D6 . For any class F of convex polyominoes, we denote its generating series by F(x, q, u, v, t), where the variable x marks the number of columns, q marks the area, u marks the size of the first column (on the left), v the size of the last column, and t the half perimeter; for example, the polyomino of Fig. 1 has weight x 14 q 64 u2 v 3 t 35 . It is possible that some variables do not appear in some generating series. The generating series will be given by explicit formulas or implicit functional equations, which are convenient for computer algebra. Thus, computations can be carried out up to area 70. The rest of the paper is organized as follows. In the next section, we present some preliminary results. This includes the enumeration of familiar classes of convex polyominoes on the square lattice which are also found on the honeycomb lattice, such as partition and staircase polyominoes and a special class of stack polyominoes. Also, the dihedral group D6 is presented here, together with its lattice of subgroups and the associated Möbius function. Finally, the growth phases, from left to right, of the upper and lower boundaries of convex polyominoes are examined and enumerated. In Section 3, we enumerate the complete class of convex polyominoes according to area and half-perimeter, following essentially the method of Hassani [7], and also a special class of directed convex polyominoes which is needed afterwards. The reflexive symmetry classes, the rotational symmetry classes, and the two-generator symmetry classes are treated successively in the following sections. All these results are put together in a concluding section, where some tables are given. 2. Preliminaries 2.1. Particular classes of convex polyominoes Some familiar classes of convex polyominoes of the square lattice are naturally found on the honeycomb lattice and are useful. It is the case notably of partition and staircase (or parallelogram) polyominoes and of a variant of stack polyominoes. 2.1.1. Partition polyominoes Fig. 2a represents the partition (4, 2, 2) contained in (a shape equivalent to) a rectangle of size 5 × 4 in the honeycomb lattice. It is well known that the area-generating for function partitions that fit in a k × n rectangle is given by the q-binomial coefficient k+n . k q
Fig. 2b represents the distinct part partition (5, 4, 2, 1), with parts bounded by 6. We denote by Dm (u, q) the generating polynomial of distinct part partitions with parts bounded by m. Here the variable u marks the number of parts. We have Dm (u, q) = (1 + uq)(1 + uq 2 ) · · · (1 + uq m ) and D0 (u, q) = 1.
(1)
2.1.2. Staircase polyominoes Fig. 3 represents a staircase polyomino from the square lattice (see for example [1] or [8]) redrawn on the honeycomb lattice. Observe that the half perimeter is equal to 2p −1 where p is the half perimeter on the square lattice. It is known that these polyominoes are enumerated
310
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
(a)
(b) Fig. 2. Partition polyominoes.
Fig. 3. A staircase polyomino.
according to half perimeter by the Catalan numbers and according to area by the sequence M1175 of [14] (A006958 of [13]) whose generating series is a quotient of two q-Bessel functions. We review this latter result here. Let Pa denote the set of staircase polyominoes (Pa for Parallelogram) on the honeycomb lattice and Pa(x, q, u, v, t), their generating series. An analysis of the situation where a column is added on the right, following the method of Bousquet–Melou (compare with [1, Lemma 3.1]), gives, for Pa(v) = Pa(x, q, u, v, t), the functional equation Pa(v) =
xquvt 3 xqvt 2 + (Pa(1) − Pa(vq)) . 1 − quvt 2 (1 − qvt 2 )(1 − qv)
(2)
Indeed, the first term of (2) corresponds to polyominoes with a single column. If a staircase polyomino P has more than one column, then, as shown in Fig. 4, the last (right) column can be obtained by adding first a single cell to the northeast of the previous column and then by xqvt 2 completing arbitrarily on top and bottom of this cell. This gives the term (1−qvt 2 )(1−qv) Pa(1). However, the bottom part is not aloud to exceed the previous column and a correction term, xqvt 2 counting the cases where an excess does occur, namely (1−qvt 2 )(1−qv) Pa(vq), must be subtracted.
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
311
−
=
3 Fig. 4. Pa(v) = xquvt 2 +
1−quvt
xqvt 2 (Pa(1) − Pa(vq)). (1−qvt 2 )(1−qv)
It follows (see [1]) that Pa(v) =
J1 (1) + J1 (v)J0 (1) − J1 (1)J0 (v) , J0 (1)
(3)
where J1 (v) =
(−1)n
n+2 x n+1 v n+1 ut 2n+3 q ( 2 ) (qvt 2 ; q)n (qv; q)n (1 − q n+1 uvt 2 )
(−1)n
n+1 x n v n t 2n q ( 2 ) . (qvt 2 ; q)n (qv; q)n
n0
and J0 (v) =
n0
Here we have used the familiar notation (a; q)n = (1 − a)(1 − aq) · · · (1 − aq n−1 ). We set Pa(x, q, u, v, t) = Pai,j (x, q, t)ui v j . (4) i 1j 1
2.1.3. Stack polyominoes There exists a specific variant of stack polyominoes on the honeycomb lattice. They consist of pyramidal stackings of hexagons, viewed sideways for our purposes. A first class (see Fig. 5a), denoted by T (for French tas), appears in the literature under the name of pyramidal stacking of circles; see [12]. Their generating series according to area is referenced as number M0687 in [14] and A001524 in [13]. Let T (x, u, q) be the generating series of stack polyominoes according to the number of columns (the width, marked by x), the size of the first column (the height, marked by u) and the area, and let Tn (x, q) = [un ]T (x, u, q) be the generating series of stacks whose first
312
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
(a)
(b)
(c)
(d)
Fig. 5. Stacks and symmetric stacks.
column is of size n. Note that the half perimeter is equal to twice the height plus the width so that the series T (xt, ut 2 , q) also keeps track of this parameter. It can be readily seen that
T (x, u, q) =
m1
m+1 x m q ( 2 ) um , (uq; q)m−1 (uq; q)m
(5)
where m denotes the number of columns, and also that Tn (x, q) =
n
m n+(m 2)
x q
m=1
n−m j =0
m+j −1 n−j −2 m−1 q m−2 q
.
(6)
The polynomials Tn (x, q) can be rapidly computed using the class T0n of stack polyominoes whose first column is of size n, including possibly empty cells (not contributing to the area) at the two extremities. See Fig. 5b. Indeed, we have Tn (x, q) = xq n T0n−1 (x, q).
(7)
with T00 (x, q) = 1, T01 (x, q) = 1 + xq, and, arguing on the existence of empty cells at each extremity, T0n (x, q) = (2 + xq n )T0n−1 − T0n−2 .
(8)
Notice that the T0n are q-analogues of a variant of Tchebichev polynomials. 2.1.4. Symmetric stacks Horizontally symmetric stacks (see Figs. 5c and d), constitute the families TS and TS0. Using the same notation as for stacks, we have TS(x, u, q) =
m1
x m um q m(m+1)/2 (1 + uq m ) . (1 − u2 q 2 )(1 − u2 q 4 ) · · · (1 − u2 q 2m )
(9)
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
ds1
da2 = v
313
ds2 da3
da1
ds3 = h
Fig. 6. The reflections of D6 .
Moreover, TSn (x, q) = xq n TS0n−1 (x, q).
(10)
where TS00 (x, q) = TS0−1 (x, q) = 1, and TS0n (x, q) = xq n TS0n−1 (x, q) + TS0n−2 (x, q).
(11)
2.2. The dihedral group D6 The dihedral group D6 is defined algebraically by D6 = , | 6 = 1, 2 = 1, = −1 . Here D6 is realized as the group of isometries of a regular hexagon, with = r = the (clockwise) rotation of /3 radian and = ds3 = h, the horizontal reflection. We have D6 = {id, r, r 2 , r 3 , r 4 , r 5 , da1 , da2 , da3 , ds1 , ds2 , ds3 }, where ds2 = r 2 , ds1 = r 4 , reflections according to vertex–vertex axes, and da3 = r, da2 = r 3 , and da1 = r 5 , reflections according to the edge–edge axes. See Fig. 6. The dihedral group D6 acts naturally on (hexagonal) polyominoes, by rotation or reflection. For any class F of polyominoes, with a monomial weigh w corresponding to certain parameters, we denote by |F|w the total weight (i.e. the generating series) of this class. If F is invariant under the action of D6 , then the set of orbits of this action is denoted by F/D6 . Burnside’s Lemma enumerates these orbits in terms of the sets Fix(g) of fixed points of each of the elements g of D6 , the symmetry classes of F. We write fix(g) = |Fix(g)|w . Clearly we have fix(r) = fix(r 5 ), fix(r 2 ) = fix(r 4 ) and, for symmetry reasons, fix(da1 ) = fix(da2 ) = fix(da3 ) and fix(ds1 ) = fix(ds2 ) = fix(ds3 ). In the following, we will choose v = da2 , the vertical axis, and h = ds3 , the horizontal axis. By Burnside’s Lemma, we have 1 fix(g) |F/D6 |w = 12 g∈D6 1 |F|w + 2 fix(r) + 2 fix(r 2 ) + fix(r 3 ) + 3 fix(v) + 3 fix(h) . (12) = 12
314
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
2.2.1. The lattice of subgroups of D6 It is also possible to enumerate the convex polyominoes which are asymmetric or which have exactly the symmetries of a given subgroup H of D6 , with the help of Möbius inversion in the lattice of subgroups of D6 . This lattice and its Möbius function are well described in Stockmeyer’s Ph.D. Thesis [15], for any dihedral group Dn . We follow his nomenclature. Apart from the trivial subgroups 0 = {id} and 1 = D6 = r, h, we have the cyclic subgroups C6 = r = {1, r, r 2 , r 3 , r 4 , r 5 }, C3 = r 2 = {1, r 2 , r 4 } and C2 = r 3 = {1, r 3 }, F1,1 = ds2 = {1, ds2 }, F1,2 = ds1 = {1, ds1 }, and F1,3 = h = {1, h}, H1,1 = da3 = {1, da3 }, H1,2 = v = {1, v} and H1,3 = da1 = {1, da1 }, as well as the two generator subgroups F3,1 = r 2 , ds2 = {1, r 2 , r 4 , ds1 , ds2 , h} = r 2 , h, H3,1 = r 2 , da3 = {1, r 2 , r 4 , da1 , v, da3 } = r 2 , v, and the D2,j = r 3 , r 2j , j = 1, 2, 3, that is D2,1 = r 3 , ds2 = {1, r 3 , ds2 , da1 }, D2,2 = r 3 , ds1 = {1, r 3 , ds1 , da3 }, and D2,3 = r 3 , h = {1, r 3 , h, v} = r 3 , h. The lattice of subgroups of D6 is represented in Fig. 7. For any subgroup H of D6 (H D6 ), we set F H = |{s ∈ F | stab(s)H }|w = |{s ∈ F | h ∈ H ⇒ h · s = s}|w
(13)
F=H = |{s ∈ F | stab(s) = H }|w = |{s ∈ F | h ∈ H ⇔ h · s = s}|w
(14)
and
We have clearly, for any H D6 FH = F=K H K D6
and, by Möbius inversion, F=H = (H, K)F K . H K D6
In particular, the total weight of asymmetric polyominoes is given by F=0 = (0, K)F K .
(15)
K D6
Note that F 0 = |F|w and that for any cyclic subgroup H = h, F H = fix(h). For reasons of symmetry (or by conjugation), we have F D2,1 = F D2,2 = F D2,3 .
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
315
Fig. 7. The lattice of subgroups of D6 ((0, H ) in parenthesis).
In the following, we will take D2,3 = r 3 , h. Formula (15) then yields F=0 = |F|w − 3 fix(h) − 3 fix(v) − fix(r 2 ) − fix(r 3 ) + fix(r) +6F D2,3 + 3F F3,1 + 3F H3,1 − 6F D6 .
(16)
For any subgroup H of D6 , we sometimes write |Fix(H )|q,t = F H when the weight is given by the area and the half perimeter. 2.3. Growth phases of convex polyominoes Any convex polyomino can be decomposed into blocks according to the growth phases, from left to right, of its upper and lower profiles. Fig. 8 gives an example of this decomposition. The upper profile is represented by the path from A to B along the upper boundary, and the lower profile, by the path from C to D. On the upper profile, we speak of a weak increase if the level rises by a half hexagon only with respect to the preceding column, and of a strong increase if the level rises by more than a half hexagon. We define analogously a weak or strong decrease. On the lower profile, an increase corresponds to a descent and a decrease, to a rise. The state in which a column lies is described by an ordered pair (i, j ), i, j = 0, 1, 2; the first component corresponds to the upper profile and the second, to the lower profile. The state 0 corresponds to a (weak or strong) increase, at the start of the polyomino, the state 1 to a weak increase or decrease, in an oscillation phase, and the state 2, to a strong or weak
316
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
Fig. 8. Growth phases of a convex polyomino.
decrease, in the last part of the polyomino. To pass from the state 0 to the state 1, there must be a first weak decrease, and to pass from the state 0 or 1 to the state 2, there must be a strong decrease. Finally, the transitions from the state 1 to the state 0 and from the state 2 to the state 1 or 0 are impossible. Now, a block Hij is characterized by a maximal sequence of consecutive columns which are in the state (i, j ). We can then view a convex polyomino as an assemblage of blocks and we will first enumerate these blocks Hij . In what follows, we give the various generating series of the form Hij (x, q, u, v, t). 2.3.1. The families H00 and H22 The two classes of polyominoes H00 and H22 are equivalent since one can be obtained from the other by a vertical reflection. They are easy to enumerate since H22 -polyominoes are in fact stack polyominoes (see Fig. 5a). Here, only one of the two variables u and v is used at a time. We have H22 (x, q, u, t) = T (xt, ut 2 , q) and H00 (x, q, v, t) = T (xt, vt 2 , q),
(17)
where T (x, u, q) is given by (5). 2.3.2. The families H01 , H10 , H12 , and H21 The classes H01 , H10 , H12 , and H21 of polyominoes are in bijection with each other by horizontal and vertical reflections and are thus equinumerous. Fig. 9 shows a polyomino in H10 . An analysis of the situation where a column is added on the right to an H10 -polyomino leads to the functional equation H10 (x, q, u, v, t) =
xquvt 3 xt 2 (1 + qvt) + H10 (x, q, u, vq, t). 2 1 − quvt 1 − qvt 2
(18)
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
317
i
m
h
j
Fig. 9. Polyomino of H10 .
Solving by iteration, we find x m q m uvt 2m+1 (−qvt; q)m−1 . H10 (x, q, u, v, t) = (1 − q m uvt 2 )(qvt 2 ; q)m−1
(19)
m1
Formula (19) can be seen directly on Fig. 9. Indeed, with m columns an H10 -polyomino x m q m uvt 2m+1 consists of a central rectangle of size m × h, h 1 the factor (1−q m uvt 2 ) , with a distinct part partition on top and a general partition underneath, with parts at most m − 1 (the factors (−qvt; q)m−1 and 1/(qvt 2 ; q)m−1 , respectively. We also see that H10 (x, q, u, v, t) =
uh v h
h1
×
j 0
m1
x m q mh
m−1 i=0
i+1 vi q ( 2 )
m−2+j v j q j t 2m+2h+i+2j −1 j q
m−1 i q
.
(20)
Finally H01 (x, q, u, v, t) = H10 (x, q, u, v, t) and H12 (x, q, u, v, t) = H21 (x, q, u, v, t) = H10 (x, q, v, u, t).
2.3.3. The families H02 and H20 The class H02 coincides with staircase polyominoes (see Fig. 3) and the two classes H02 and H20 are equivalent to each other, via an horizontal reflection: H02 (x, q, u, v, t) = Pa(x, q, u, v, t) = H20 (x, q, u, v, t).
(21)
2.3.4. The family H11 The class H11 contains the convex polyominoes whose upper and lower profiles are both oscillating. When we examine the diagonal row of hexagons in the da3 axis (see Fig. 6)
318
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
i
j n
(a)
(b) Fig. 10. Polyominoes of H11 .
containing the first column’s lower cell, two subclasses of H11 appear. In the first class, denoted by H11a , this diagonal row and those to its right (up to the last column) form a staircase polyomino (rotated clockwise by a /3 angle); see Fig. 10a. In the second class, denoted by H11b , this diagonal is the basis of a rectangle of height at least 2; see Fig. 10b. In both cases, we find, above and below these objects (staircase or rectangle), distinct part partitions which are left and right justified, respectively. Recall that in the series Pai,j (x, q, t), defined by (4), the variable x marks the number of columns of the (unrotated) staircase polyomino. We rather use the link between its width , when rotated, and its half-perimeter p: p = 2 + 1. Hence we have H11 (x, q, u, v, t) = H11a (x, q, u, v, t) + H11b (x, q, u, v, t) with H11a (x, q, u, v, t) =
1
(22)
1
x − 2 uv Pai,j (1, q, tx 2 )Di−1 (ut, q)Dj −1 (vt, q) (23)
i 1j 1
and H11b (x, q, u, v, t) =
x n q 2n u2 v 2 t 2n+3 Dn−1 (ut, q)Dn−1 (vt, q) . 1 − q n uvt 2
(24)
n1
3. Convex and directed convex polyominoes 3.1. Convex polyominoes We denote by C, the class of all convex polyominoes and by Cij , the subclass of polyominoes whose last column is in the state (i, j ), i, j = 0, 1, 2. This determines a partition of C. To enumerate C, we must enumerate each of the classes Cij . We give the generating series Cij (x, q, v, t), using the growth phase decomposition of a convex polyomino, following essentially the method of Hassani [7]. We use the notation Cij ⊗ Hi j for the set of convex polyominoes obtained by gluing together in all possible legal ways a polyomino of Cij with one of Hi j . We introduce the
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
319
series Cij,n (x, q, t) and Hij,n (x, q, v, t) by the coefficient extractions Cij,n (x, q, t) = [v n ]Cij (x, q, v, t) and Hij,n (x, q, v, t) = [un ]Hij (x, q, u, v, t).
(25)
For example, we have C00 = H00 , C10 = C00 ⊗ H10 and n 1 C10 (x, q, v, t) = C00,k (x, q, t) H10,n (x, q, v, t) t 2k−1 n 1 k=1 n = tTk (xt, q) H10,n (x, q, v, t) n1
k=1
= C01 (x, q, v, t).
(26)
Likewise, C11 = (C00 + C10 + C01 ) ⊗ H11 = C00 ⊗ H11 + C10 ⊗ H11 + C01 ⊗ H11 and C00 ⊗ H11 (x, q, v, t) =
n2
C10 ⊗ H11 (x, q, v, t) =
1 C00,n (x, q, t)H11,n−1 (x, q, v, t), t 2n−2
(27)
1 C10,n (x, q, t)H11,n (x, q, v, t) t 2n−1 n1 1 + C10,n (x, q, t)H11,n−1 (x, q, v, t). t 2n−2
(28)
n2
We have also C02 = (C00 + C01 ) ⊗ H02 , C12 = (C00 + C01 + C10 + C11 + C02 ) ⊗ H12 , C22 = (C00 + C01 + C10 + C11 + C02 + C02 ) ⊗ H22 . Finally, C(x, q, v, t) = (C00 + 2C10 + C11 + 2C02 + 2C12 + C22 )(x, q, v, t).
(29)
Using these equations, the area generating function A(q) = C(1, q, 1, 1) of convex polyominoes on the honeycomb lattice can be computed easily up to area 70: A(q) = 93521821034090198077138307 q 70 + 40500739671610157834435402 q 69 +17539328210367276357231264 q 68 + 7595615205191062899011838 q 67 +3289371728119140331192848 q 66 + 1424501646472485669061275 q 65 +616897422526383132078929 q 64 + 267154784175652277208577 q 63 +115694564610291544986219 q 62 + 50102910647125753823048 q 61 +21697662840186809215730 q 60 + 9396431597658317037336 q 59 +4069236738707717909198 q 58 + 1762231488064295148820 q 57 +763155357452132873277 q 56 + 330493526907262008000 q 55 +143124162458250124557 q 54 + 61981625120377313718 q 53
320
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
+26841881829357335687 q 52 + 11624197004721262104 q 51 +5033997137232724122 q 50 + 2180032500563641911 q 49 +944089080678393018 q 48 + 408849042325490952 q 47 +177056959135248647 q 46 + 76676631829002129 q 45 +33205732845460311 q 44 + 14380140755028117 q 43 +6227492958077133 q 42 +2696891148564180 q 41 + 1167921607616731 q 40 +505782887350567 q 39 +219035659925172 q 38 + 94856243572216 q 37 + 41078790416848 q 36 +17789770663899 q 35 + 7704147029616 q 34 + 3336422923431 q 33 +1444911247194 q 32 + 625758286777 q 31 + 271006745255 q 30 +117372288297 q 29 + 50835685427 q 28 + 22018993552 q 27 +9538127076 q 26 +4132195707 q 25 + 1790486717 q 24 + 775996665 q 23 + 336418179 q 22 +145903992 q 21 + 63308532 q 20 + 27485271 q 19 + 11939804 q 18 +5189577 q 17 +2256420 q 16 + 980961 q 15 + 426036 q 14 + 184588 q 13 + 79602 q 12 +34056 q 11 +14394 q 10 + 5973 q 9 + 2412 q 8 + 939 q 7 + 348 q 6 + 120 q 5 + 38 q 4 +11 q 3 +3 q 2 + q.
If only the half-perimeter is taken into account, then the preceding equations can be explicitly solved: Theorem 3.1 (Hassani, [7]). The generating function of convex hexagonal polyominoes according to perimeter is algebraic. It is explicitly given by C(1, 1, 1, t) =
√ t 3 ( − 3t 4 (1 + t)2 (1 − 2t)2 1 − 4t 2 ) , 2((1 − 2t)(1 + t))4
where = 2 − 8t + 2t 2 + 20t 3 + t 4 − 34t 5 − 19t 6 + 28t 7 + 32t 8 − 12t 9 − 6t 10 .
Here are the first terms of this series: t 3 + 3t 5 + 2t 6 + 12t 7 + 18t 8 + 59t 9 + 120t 10 + 318t 11 + 714t 12 +1743t 13 + · · · .
(30)
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
321
H2
H1 H0
Fig. 11. Directed convex polyomino.
Corollary 3.2 (Hassani [7]). The asymptotic number of convex hexagonal polyominoes according to perimeter is equal to 1 2 n n3 . 27 × 210
3.2. Directed convex polyominoes There is a special class of convex polyominoes which will be particularly useful below, namely those which are directed according to the North direction with a diagonal basis. See Fig. 11. We call them simply directed convex, and denote this class by D. Analogously to convex polyominoes, any polyomino in D can be decomposed into blocks Hi according to the growth phases i = 0, 1, or 2, of its upper profile. Their generating series can be computed directly by observation. Since the half perimeter can be deduced from the other parameters, the variable t does not appear here. For example, a polyomino in H0 is identified with a partition and we find H0 (x, q, v) =
v l x k q l+k−1
l 1 k 1
l+k−2 l−1 q
.
(31)
A polyomino in H1 can be decomposed into pieces as shown in Fig. 12a, yielding H1 (x, q, u, v) =
l 1
vl
m0
ul+m
k m+1
x k q kl+
(m)(m+1) 2
k−1 m
q
.
(32)
322
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
m m
l
l k k
(a)
(b)
Fig. 12. Directed convex polyominos in H1 and in H2 .
Likewise, for H2 , we find (see Fig. 12b) H2 (x, q, u, v) ⎛ ⎞ k(k+2l−1) ⎠. = v l ⎝xq l ul + xk ul+k+m−1 q 2 +m m+k−2 k−2 l 1
k 2
m0
q
(33)
We denote by Di , the class of directed convex polyominoes whose last column is in the state i, i = 0, 1, 2, and we introduce the notation Di,n (x, q, t) = [v n ]Di (x, q, v, t) and Hi,n (x, q, v) = [un ]Hi (x, q, u, v).
(34)
We have D0 (x, q, v, t) =
1 H0 (xt 2 , q, vt 2 ), t
(35)
1 D0,m+1 (x, q, t)H1,m (xt 2 , q, vt), tm
(36)
D1 = D0 ⊗ H1 and D1 (x, q, v, t) =
m1
and finally, D2 = (D0 + D1 ) ⊗ H2 and D2 (x, q, v, t) 1 = (D0,m+h (x, q, t) + D1,m+h (x, q, t))H2,m (xt 2 , q, vt). tm m1 h2
(37)
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
323
K
v Fig. 13. v-symmetric convex polyomino.
4. Reflexive symmetry classes 4.1. Vertical symmetry Consider a vertically symmetric (v-symmetric) convex polyomino P. We see that the symmetry axis goes through a central column. Denote by K the left fundamental region of P, including the central column. See Fig. 13. Then K is a convex polyomino which can only belong to the classes C00 , C10 , C01 , or C11 and we have K(x, q, v, t) = C00 (x, q, v, t) + 2C10 (x, q, v, t) + C11 (x, q, v, t) = Km (x, q, t)v m
(38)
m1
and |Fix(v)|q,t =
m1
1 q m t 2m+1
Km (1, q 2 , t 2 ).
(39)
4.2. Horizontal symmetry The class S of h-symmetric convex polyominoes is partitioned into three classes: Sa and Sb , whether or not we can find an arrowhead polyomino in the oscillating part (see Figs. 14a and b) and the class Sc , if there does not exist an oscillating part. In order to construct a polyomino of the class arrrowhead, denoted by A, we start with a triangle of side n, to which a symmetric stack is possibly attached to form the H22 phase; denote by B, this starting class of polyominoes. From B, we construct A by successively attaching V-shaped bands on the left, as illustrated in Fig. 14a. Let the variable s mark the size of the last attached V’s upper left part. We have B(s, x, q, t) = sxqt 3 + s n x n q n(n+1)/2 t 3n T SOn−3 (xt, q) (40) n2
324
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
h n h m n
B
A
k
(a)
(b) Fig. 14. h-symmetric convex polyominoes.
and the generating series A(s) = A(s, x, q, t) is characterized by the following functional equation, which can be solved by the usual method: s2x2q 3t 4 A(1) − A(sq 2 ). (41) 1 − sq 2 We set A(s, x, q, t) = m 1 Am (x, t, q)s m . To complete the polyomino, we must take into account the parity of the first oscillating column. The first case, illustrated in Fig. 14a, is when this column is of odd size. In the second case, this even column is placed in front of the arrrowhead. In conclusion, we obtain m−1 q h(h+1) t 2h+2 TS2h+2 (xt, q) Am (x, t, q) Sa (x, t, q) = h 2 A(s) = B(s) +
h0
+
q
m h+1
q h(h+1) t 2h+3 TS2h+1 (xt, q)
m
mh
h1
h q2
Am (x, t, q).
(42)
The computations for Sb (x, t, q) and Sc (x, t, q) are simpler. For Sb , there are also two parity cases and we find directly n+1 x n q ( 2 ) t 3n q 2kn t 4k TS0n+2k−3 (xt, q) Sb (x, t, q) = n1
×
n−1
k 1
t 2h+2 q h(h+1)
h=0
+ ×
xnq (
n0 n
n+1 2
) t 3n
t 2h+2 q h(h+1)
h=0
n−1 h q2
TS2k+2h+2 (x, t, q)
q 2k(n+1) t 4k+1 TS0n+2k−3 (xt, q)
k 1
n
h q2
TS2k+2h+1 (x, t, q)
(43)
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
325
and
Sc (x, t, q) =
t 2h TSh (xt, q)TS0h−3 (xt, q).
(44)
h1
Finally, |Fix(h)|q,t = Sa (1, t, q) + Sb (1, t, q) + Sc (1, t, q).
(45)
5. Rotational symmetry classes 5.1. Symmetry with respect to the /3 radian rotation r The polyominoes which are symmetric with respect to the /3 rotation (r-symmetric) are essentially formed of large hexagons decorated by stack polyominoes of the class T0. See Fig. 15. We find |Fix(r)|q,t =
t 3(2h−1) q 3h(h−1)+1 T0h−1 (t 6 , q 6 ),
(46)
h1
the series T0n (x, q) being defined by (8). 5.2. Symmetry with respect to the 2/3 radian rotation r 2 The situation is more complex here. First we must distinguish the case where the rotation center is in the middle of an hexagon from the one where it is on a vertex. This determines two subclasses, denoted by P and Q. 5.2.1. The rotation center is in the middle of an hexagon When the rotation center is in the middle of an hexagon, we consider the fundamental region formed by the upper third of the r 2 -symmetric polyomino. The parameters h1 and h2 are defined as the extent of the fundamental region in the directions da2 = v and da1 (or da3 ), respectively. There are three subcases according to whether h1 > h2 , h2 > h1 or h1 = h2 , giving three subclasses denoted by P1 , P2 and P3 . Fig. 16 illustrates the first subcase P1 . In this figure, there is a basis formed of (one third of) a super-hexagon of radius h = h2 , on top of which are placed a directed convex polyomino D (see Section 3.2) and the image D ∗ under v of another directed convex polyomino, these two polyominoes sharing a common column. Let be the size of this common column, so that h1 = h + . We must consider all such legal combinations D ⊗ D∗ and take into account the added area and half perimeter over that of the super-hexagon. For i = 0, 1, 2, we set Di,r,n (q, t) =
1 1 [x r ]Di,n (x, q, t) = 2r+n−1 [x r ][v n ]Di (x, q, v, t) t 2r+n−1 t
326
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
Fig. 15. An r-symmetric convex polyomino.
D
D* s
r h1
h2
h2
Fig. 16. Fundamental region of an r 2 -symmetric convex polyomino in P1 .
and Dr,n (q, t) = (D0,r,n + D1,r,n + D2,r,n )(q, t). We then have P1 (q, t) = t 3(2h−1) q 3h(h−1)+1 h1
×
h h 1 D0,r,l (q 3 , t 3 )D0,s,l (q 3 , t 3 ) q 3l
l 1 r=1 s=1
+2D0,r,l (q 3 , t 3 )D1,s,l (q 3 , t 3 ) + 2D0,r,l (q 3 , t 3 )D2,s,l (q 3 , t 3 ) +D1,r,l (q 3 , t 3 )D1,s,l (q 3 , t 3 ) .
(47)
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
C
B
C
327
Bh D
A
A
r
A∩B
D C∩D r h
h h
h
h
h
(a)
(b) Fig. 17. Fundamental regions of r 2 -symmetric convex polyominoes in P3 .
For reasons of symmetry (a /3 rotation), we see that P2 (q, t) = P1 (q, t). Let us now consider the class P3 of r 2 -symmetric convex polyominoes with h1 = h2 = h. In this case, the added decorations on the super-hexagon can only occupy one of the sectors A, B, C or D shown in Fig. 17, with the exception of the sectors A ∩ B and C ∩ D which can be simultaneously occupied. Denote by Bh the class of admissible decorations in the sector B over an hexagon of side h, and by Bh (q, t) its generating series, where the variables q and t mark the added area and half perimeter, respectively. We have Bh (q, t) =
h−1
⎛
⎝(h − r) q r t + D1,r,1 (q, t) + D2,r,1 (q, t) +
⎞ t j −1 Dr,j (q, t)⎠ . (48)
j 2
r=1
The generating series will be the same for the decorations located in the sectors A, C or D, for symmetry reasons. However, in the term 4Bh (q, t), the decorations which, like the one shown in Fig. 17b, are located in the intersection sectors A ∩ B or C ∩ D, are counted twice. Observe that these decorations are in fact stack polyominoes of the class T0 with generating series T0h−1 (t, q) − 1, whence the correcting term −2(T0h−1 (t, q) − 1). Lastly, the term (T0h−1 (t, q) − 1)2 counts the simultaneous decorations in the sectors A ∩ B and C ∩ D and the term 1 is added for the empty decoration. Globally, we obtain P3 (q, t) = t 3(2h−1) q 3h(h−1)+1 h1
2 × 4Bh (q 3 , t 3 ) − 4T Oh−1 (t 3 , q 3 ) + T Oh−1 (t 3 , q 3 ) + 4 .
(49)
5.2.2. The rotation center is on a vertex The class of r 2 -symmetric convex polyominoes whose rotation center is on a vertex is denoted by Q. There are three cases: h1 > h2 , h2 > h1 and h1 = h2 to which correspond three series Q1 (q, t), Q2 (q, t) and Q3 (q, t) and two types of central vertices as in
328
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
h1 h2
Fig. 18. r 2 -symmetric convex polyominoes in Q1 .
Fig. 18. The computations are similar to the preceding case. The decorations are placed over a pseudo-hexagon and we find Q1 (q, t) = 2
2
t 6h q 3h
h1
h+1 h 1 (D0,r,l (q 3 , t 3 )D0,s,l (q 3 , t 3 ) q 3l
l 1 r=1 s=1 +D0,r,l (q , t )D1,s,l (q 3 , t 3 ) +D0,r,l (q 3 , t 3 )D2,s,l (q 3 , t 3 ) + D1,r,l (q 3 , t 3 )D1,s,l (q 3 , t 3 ) +D1,r,l (q 3 , t 3 )D0,s,l (q 3 , t 3 ) + D2,r,l (q 3 , t 3 )D0,s,l (q 3 , t 3 )) 3
3
= Q2 (q, t) and Q3 (q, t) = 2
(50) 2
t 6h q 3h
4 + 2Bh (q 3 , t 3 ) + 2Bh+1 (q 3 , t 3 ) − 2T Oh−1 (t 3 , q 3 )
h1
− 2T Oh (t 3 , q 3 ) + T Oh−1 (t 3 , q 3 )T Oh (t 3 , q 3 ) .
(51)
5.2.3. Global result Finally, |Fix(r 2 )|q,t = 2P1 (q, t) + P3 (q, t) + 2Q1 (q, t) + Q3 (q, t).
(52)
5.3. Symmetry with respect to the radian rotation r 3 Here, the rotation center can be in the middle of an edge or of an hexagon. See Fig. 19. If the rotation center is in the middle of an edge, there are three similar cases corresponding to the three types of edges. Consider the case of the horizontal edge and denote by A, the corresponding class. Such a polyomino P is shown in Fig. 19a. Denote by K the left fundamental region of P, including the central column. Note that this column is of even length.
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
329
K K
(a)
(b) Fig. 19. r 3 -symmetric convex polyominoes.
If the rotation center is the middle of an hexagon, we denote by H the corresponding class. In this case, the central column is of odd length. See Fig. 19b. The polyominoes K which can occur as a fundamental region in one of these two cases are K = C00 + C01 + C10 + C11 + C02 + C20 .
(53)
Recall that the series Cij,n (x, q, t) is defined by Eq. (25), with the index n representing the size of the last column. We then have 1 A(x, q, t) = (C00,2k + 2C01,2k + C11,2k + 2C02,2k )(x 2 , q 2 , t 2 ). (54) 2k xq t 4k+1 k 1
and H(x, q, t) =
k 0
1 xq 2k+1 t 4k+3
×(C00,2k+1 + 2C01,2k+1 + C11,2k+1 + 2C02,2k+1 )(x 2 , q 2 , t 2 ).
(55)
Finally, |Fix(r 3 )|q,t = 3A(1, q, t) + H(1, q, t).
(56)
6. Two-generator symmetry classes 6.1. Symmetry with respect to D6 Since D6 = r, ds2 , convex polyominoes belonging to Fix(D6 ) consist of super-hexagons with symmetric stack decorations (see the Section 5.1). We obtain |Fix(D6 )|q,t = t 3(2h−1) q 3h(h−1)+1 T S0h−1 (t 6 , q 6 ). (57) h1
330
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
A∩B C∩D
h h h
Fig. 20. Fundamental region of an F3,1 -symmetric convex polyominoes in P3 .
6.2. Symmetry with respect to F3,1 = r 2 , ds2 We are guided by the 2/3 rotation symmetry class studied in Section 5.2. The cases h1 > h2 and h2 > h1 are impossible because of the ds2 -symmetry. There remains the case h1 = h2 = h. If the rotation center is in the middle of an hexagon (case P3 ), the sides of the superhexagon are decorated by symmetric stacks of type TS0. Moreover the ds2 -symmetry implies that the decorations are in the sectors A ∩ B and C ∩ D. See Fig. 20. By r 2 -symmetry, three of these stacks are identical and the three others also, whence the formula (T SOh−1 (t 3 , q 3 ))2 . If the rotation center is a vertex (case Q3 ), we rather find T SOh−1 (t 3 , q 3 )T SOh (t 3 , q 3 ). Consequently, t 3(2h−1) q 3h(h−1)+1 (T SOh−1 (t 3 , q 3 ))2 |Fix(F3,1 )|q,t = h1
+2
2
t 6h q 3h T SOh−1 (t 3 , q 3 )T SOh (t 3 , q 3 ).
(58)
h1
6.3. Symmetry with respect to H3,1 = r 2 , v We refer again to Section 5.2. The case where the center is a vertex is impossible because of the vertical symmetry. There remains the case where the center is an hexagon and the three subcases h1 > h2 , h2 > h1 and h1 = h2 define three subclasses R1 , R2 and R3 , respectively. For the case where h1 > h2 , the part D ∗ of the decoration (see Fig. 16) is in fact the mirror image v · D of D. Hence we obtain R1 (q, t) =
h1
t 3(2h−1) q 3h(h−1)+1
= R2 (q, t).
h 1 D0,r,l (q 6 , t 6 ) + D1,r,l (q 6 , t 6 ) 3l q
l 1 r=1
(59)
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
331
If h1 = h2 = h, the decorations in the sectors A ∩ B and C ∩ D are mirror images of each other and we find R3 (q, t) =
t 3(2h−1) q 3h(h−1)+1 T0h−1 (t 6 , q 6 ).
(60)
h1
Finally, |Fix(H3,1 )|q,t = 2R1 (q, t) + R3 (q, t).
(61)
6.4. Symmetry with respect to D2,3 = r 3 , h Observe that D2,3 = h, v. We thus refer to Sections 4.1 and 4.2 on v- and h-symmetric polyominoes, respectively. In order to obtain a D2,3 -symmetric convex polyomino, it suffices to take a v-symmetric polyomino whose fundamental region K (see Fig. 13) is itself h-symmetric. The series CS00 (x, q, v, t), HS11 (x, q, u, v, t) and CS11 (x, q, v, t) are the h-symmetric analogues of the series C00 (x, q, v, t), H11 (x, q, u, v, t) and C11 (x, q, v, t) of Sections 2.3.4 and 3.1. We have CS00,k (x, q, t) = [v k ]CS00 (x, q, v, t) = t 2k TSk (xt, q),
(62)
xquvt 3 + xqvt 3 HS11 (x, q, u, vq, t) 1 − quvt 2 HS11 (x, q, u, v, t) xt HS11 (x, q, u, vq, t) − v + v qv v=0 = HS11,k (x, q, v, t)uk , (63)
HS11 (x, q, u, v, t) =
k 1
CS11 (x, q, v, t) =
i 2
=
1 t 2i−2
CS00,i (x, q, t)HS11,i−1 (x, q, v, t)
CS11,k (x, q, t)v k ,
(64)
k 1
and finally |Fix(D2,3 )|q,t =
i 1
1 q i t 2i+1
CS00,i (1, q 2 , t 2 ) + CS11,i (1, q 2 , t 2 ) .
(65)
332
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
7. Conclusion It is now possible to use Burnside’s formula (12), with F = C, to enumerate the free convex polyominoes, according to area and half perimeter. Some numerical results are given in Tables 1 and 2, according to area only (up to area 20) or to half perimeter only (up to half perimeter 16). See under the column “Orbits”. Computations can be carried out up to area 70. For example, the area generating function O(q) for free convex polyominoes is given by O(q) = 7793485086177320116383190 q 70 + 3375061639302474977759459 q 69 +1461610684198631521434604 q 68 + 632967933766627146424740 q 67 +274114310677183339289743 q 66 + 118708470539679217896007 q 65 +51408118544120036869792 q 64 + 22262898681436619043371 q 63 +9641213717634629469342 q 62 + 4175242553984424220331 q 61 +1808138570063349142550 q 60 + 783035966496331488936 q 59 +339103061579669091397 q 58 + 146852624016100144541 q 57 +63596279796639028453 q 56 + 27541127246923937999 q 55 +11927013542068382458 q 54 + 5165135428712800678 q 53 +2236823487460490930 q 52 + 968683084599288074 q 51 +419499762163951475 q 50 + 181669375424844915 q 49 +78674090371781710 q 48 + 34070753690782346 q 47 +14754746731145007 q 46 +6389719389968340 q 45 + 2767144462931933 q 44 +1198345093623976 q 43 +518957772128292 q 42 + 224740942349340 q 41 + 97326811736713 q 40 +42148579710335 q 39 + 18252976472430 q 38 + 7904689463224 q 37 +3423234621528 q 36 + 1482481972527 q 35 + 642013158078 q 34 +278035714218 q 33 + 120409664036 q 32 + 52146728481 q 31 +22584066680 q 30 +9781113135 q 29 + 4236381815 q 28 + 1834955080 q 27 + 794876602 q 26 +344366727 q 25 + 149221608 q 24 + 64673919 q 23 + 28041203 q 22 +12162019 q 21 + 5278535 q 20 + 2291941 q 19 + 996255 q 18 + 433140 q 17 +188607 q 16 + 82057 q 15 + 35759 q 14 + 15525 q 13 + 6751 q 12 + 2902 q 11 +1250 q 10 + 528 q 9 + 222 q 8 + 91 q 7 + 38 q 6 + 15 q 5 + 6 q 4 + 3 q 3 +q 2 + q It is also possible to enumerate asymmetric convex polyominoes with the help of formula (16), with F = C. Some results are found in Tables 1 and 2. It is clear from these tables that almost all convex polyominoes are asymmetric. These numerical results were verified experimentally by an exhaustive computerized enumeration up to area 20.
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
333
Table 1 Symmetry classes of convex (hexagonal) polyominoes according to area Area
id
h
v
r
r2
r3
Orbits
D6
F31
H31
D21
Asym
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 3 11 38 120 348 939 2412 5973 14 394 34 056 79 602 1 84 588 4 26 036 9 80 961 2 256 420 5 189 577 11 939 804 27 485 271 63 308 532
1 1 3 2 6 6 9 12 17 20 30 38 46 62 69 100 115 154 175 238
1 1 3 4 10 12 27 30 63 66 142 140 310 286 665 580 1441 1184 3145 2458
1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0
1 0 2 2 0 6 3 0 12 6 0 18 13 0 30 18 0 50 27 0
1 3 3 12 12 42 37 126 99 336 252 840 616 2028 1461 4788 3435 11 142 8005 25 800
1 1 3 6 15 38 91 222 528 1250 2902 6751 15 525 35 759 82 057 1 88 607 4 33 140 9 96 255 2 291 941 52 78 535
1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0
1 0 2 0 0 2 1 0 0 2 0 2 1 0 2 0 0 2 1 0
1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 6 0 0 7 0
1 1 1 2 2 2 3 4 3 4 6 4 8 8 7 8 11 12 13 16
0 0 0 24 72 264 816 2184 5640 13 836 33 324 78 240 1 82 952 4 23 012 9 77 316 2 249 640 5 181 540 11 924 676 27 467 376 63 274 740
Table 2 Symmetry classes of convex (hexagonal) polyominoes according to half perimeter 1 2 per.
id
h
v
r
r2
r3
Orbits
D6
F31
H31
D21
Asym
3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 0 3 2 12 18 59 120 318 714 1743 4008 9433 21 672
1 0 1 2 2 2 5 8 10 14 25 36 53 76
1 0 1 0 4 0 9 0 24 0 59 0 143 0
1 0 0 0 0 0 1 0 0 0 0 0 2 0
1 0 0 2 0 0 5 0 0 12 0 0 28 0
1 0 3 0 6 0 19 0 48 0 129 0 323 0
1 0 1 1 3 2 11 12 39 65 177 343 867 1825
1 0 0 0 0 0 1 0 0 0 0 0 2 0
1 0 0 2 0 0 3 0 0 4 0 0 6 0
1 0 0 0 0 0 3 0 0 0 0 0 8 0
1 0 1 0 2 0 3 0 6 0 7 0 15 0
0 0 0 0 0 12 24 96 204 672 1368 3900 8616 21 444
References [1] M. Bousquet-Mélou, A method for the enumeration of various classes of column-convex polygons, Discrete Math. 154 (1996) 1–25.
334
D. Gouyou-Beauchamps, P. Leroux / Theoretical Computer Science 346 (2005) 307 – 334
[2] A. Denise, C. Dürr, F.I.-M. Hassani, Enumération et génération aléatoire de polyominos convexes en réseau hexagonal, in: Proc. Ninth Conf. on Formal Power Series and Algebraic Combinatorics, FPSAC’97, Universität Wien, 1997, pp. 222–234. [3] Dominique Gouyou-Beauchamps et Pierre Leroux, Dénombrement des classes de symétries des polyominos hexagonaux convexes, in: Proc. 16th Conf. on Formal Power Series and Algebraic Combinatorics, FPSAC’04, University of British Columbia, Canada, 2004. [4] S. Fereti´c, D. Svrtan, On the number of column-convex polyominoes with given perimeter and number of columns, in: Proc. Fifth Conf. on Formal Power Series and Algebraic Combinatorics, FPSAC’93, University of Florence, 1993, pp. 201–214. [5] A.J. Guttmann, I.G. Enting, The number of convex polygons on the square and honeycomb lattices, J. Phys. A 21 (1988) L467–L474. [6] A.J. Guttmann, M. Vöge, I. Jensen, On the number of benzenoid hydrocarbons, J. Chem. Inform. Comput. Sci. 42 (2002) 456–466. [7] F. Ibn-Majdoub-Hassani, Combinatoire des polyominos et des tableaux décalés oscillants, Ph.D. Thesis, Université de Paris Sud, Orsay, November, 1996. [8] P. Leroux, É. Rassart, Enumeration of symmetry classes of parallelogram polyominoes, Ann. Sci. Math. Québec 25 (1) (2000) 71–90. [9] P. Leroux, É. Rassart, A. Robitaille, Enumeration of symmetry classes of convex polyominoes in the square lattice, Adv. in Appl. Math. 21 (1998) 343–380. [10] K.Y. Lin, S.J. Chang, Rigorous results for the number of convex polygons on the square and honeycomb lattices, J. Phys. A 21 (1988) 2635–2642. [11] K.Y. Lin, F.Y. Wu, Unidirectional convex polygons on the honeycomb lattice, J. Phys. A 23 (1990) 5003–5010. ˇ [12] V. Privman, N.M. Svraki´ c, Directed models of polymers, interfaces, and clusters: scaling and finite-size properties, Lecture Notes in Physics, Vol. 338, Springer, Berlin, 1989. [13] N.J.A. Sloane, The On-Line Encyclopedia of Integer Sequences, Published electronically at http://www.research.att.com/∼njas/sequences/, 2003. [14] N.J.A. Sloane, S. Plouffe, The Encyclopedia of Integer Sequences, Academic Press Inc., New York, 1995. [15] P.K. Stockmeyer, Enumeration of graphs with prescribed automorphism group, Ph.D. Thesis, University of Michigan, Ann Arbor, 1971.
Theoretical Computer Science 346 (2005) 335 – 357 www.elsevier.com/locate/tcs
A sufficient condition for non-uniqueness in binary tomography with absorption Attila Kubaa,∗ , Murice Nivatb a Department of Image Processing and Computer Graphics, University of Szeged, Árpád tér 2,
H-6720 Szeged, Hungary b Laboratoire d’Informatique Algorithmique: Fondements et Applications, Université Paris 7 Denis-Diderot,
Paris, France
Abstract A new kind of discrete tomography problem is introduced: the reconstruction of discrete sets from their absorbed projections. A special case of this problem is discussed, namely, the uniqueness of the binary matrices with √ respect to their absorbed row and column sums when the absorption coefficient is = log((1 + 5)/2). It is proved that if a binary matrix contains a special structure of 0s and 1s, called alternatively corner-connected component, then this binary matrix is non-unique with respect to its absorbed row and column sums. Since it has been proved in another paper [A. Kuba, M. Nivat, Reconstruction of discrete sets with absorption, Linear Algebra Appl. 339 (2001) 171–194] that this condition is also necessary, the existence of alternatively corner-connected component in a binary matrix gives a characterization of the non-uniqueness in this case of absorbed projections. © 2005 Elsevier B.V. All rights reserved. Keywords: Discrete tomography; Binary matrices; Absorbed projection
1. Introduction Discrete tomography (DT) deals with the problem of reconstructing functions with given discrete ranges from weighted sums/integrals over subsets/subspaces (e.g., straight lines
∗ Corresponding author.
E-mail addresses:
[email protected] (A. Kuba),
[email protected] (M. Nivat). 0304-3975/$ - see front matter © 2005 Elsevier B.V. All rights reserved. doi:10.1016/j.tcs.2005.08.024
336
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
or planes) of their domain. It has applications, for example, in electron microscopy [7,13] and medicine [9]. The book [6] provides an overview of the foundations, algorithms, and applications of discrete tomography. In this paper we consider a generalisation of the DT problem. Let us suppose that the function to be reconstructed represents a discrete set, which is in some known absorbing material and, accordingly, the measurements are the absorbed sums taken on straight lines. It can be considered as the basic model of the emission discrete tomography, or EDT, where the elements of the discrete set are discrete sources emitting unit energy and the measurements represent the partially absorbed energy detected along straight lines. (In this sense the classical model of DT can be considered as the special case of the EDT when there is no absorption.) In the last 2 years a few other papers have been published related to EDT, see, for example [2,3]. First, we pose the reconstruction problem of discrete sets with absorption in Section √ 2. Then we select a mathematically interesting special absorption value = log((1 + 5)/2) and investigate the question of uniqueness when the discrete set can be represented by a binary matrix and the absorbed row and column sums of this matrix are given. In Section 3 we show that in this case the absorbed row and column sums can be considered as finite 0 -representations (a terminology used in numeration systems), where 0 = e . Section 4 deals with those transformations, called switchings, when the 0s and 1s of a certain subset (called switching pattern) are switched to each other but the absorbed projections of the subset remain the same. Clearly, if a binary matrix contains a switching pattern then it is non-unique, because we can get another binary matrix with the same absorbed projections by switching transformation. We determine the switching patterns in both one-dimensional (1D) and two-dimensional (2D) cases. It is also shown how more complex switching patterns, like alternatively corner-connected components, can be created from simple, elementary switching patterns. In another paper [10] we have proved that the existence of alternatively corner-connected components in a binary matrix is necessary for the non-uniqueness, therefore it is necessary and sufficient for the non-uniqueness of binary matrices with respect to their absorbed row and column sums.
2. Absorption and reconstruction of discrete sets 2.1. Absorption Consider a ray (e.g, light or X-ray) passing through a homogeneous material. It is wellknown that a part of the ray will be absorbed in the material. Quantitatively, let I0 and I denote the initial and the detected intensities (number of photons/s) of the ray. Then I = I0 e−x ,
(1)
where 0 denotes the absorption coefficient of the material and x is the length of the path of the ray in the material (see Fig. 1).
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357 x I0
u
337
detector I
Fig. 1. A part of the initial intensity I0 of the ray is absorbed in the homogeneous material having absorption coefficient .
2.2. The reconstruction problem for discrete sets Let Zd denote the d-dimensional integer lattice (d 2). The non-zero vectors of Zd are the lattice directions. The lattice lines are the lines of the d-dimensional Euclidean space which are parallel to a lattice direction and pass through at least one lattice point in Zd . The finite subsets of Zd are called discrete sets. Let F be a discrete set. The projection of F along a lattice line is defined as [PF ]() = |F ∩ |, where |.| denotes the cardinality of the argument set. Let E be a class of discrete sets and L be a finite collection of lattice lines. Then the reconstruction problem for E and L can be posed as RECONSTRUCTION D(E, L). Given: Function p : L −→ N0 (N0 denotes the set of nonnegative integers). Task: Construct a discrete set F ∈ E such that [PF ]() = p() for all ∈ L. Many results connected to this reconstruction problem have been published in the last years. A summary of these results are in [6]. Consider, for example, the problem of uniqueness in the case of (2D) binary matrices. UNIQUENESS D2D(A). Given: m, n ∈ N, and a binary matrix A with size m × n. Question: Does there exist a different binary matrix A with the same size such that the row and column sums of A and A are the same? It has been shown [12] that a binary matrix is non-unique with respect to its row and column sums if and only if it has a sub-matrix 0 1 1 0 or 1 0 0 1 called switching component. A new kind of DT problem, the reconstruction of discrete sets from their absorbed projections, was introduced in [10]. A special case of this problem was discussed, namely, the
338
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
G1 x(G1)
F G2 x(G2)
detector Fig. 2. Computation of the projection of the discrete set F along the lattice line . The elements of F are denoted by bold points. Here F ∩ = {G1 , G2 }.
uniqueness of 2D binary matrices with respect to their absorbed row and column sums when the absorption is represented by the constant 0 of (7). 2.3. The reconstruction problem for discrete sets with absorption Consider now the corresponding reconstruction problem in the case of absorption. For the sake of simplicity we suppose that the whole d-dimensional Euclidean space is uniformly filled with the material having absorption coefficient 0. Then the projection with absorption of a discrete set F along a lattice line is defined according to (1) by −·x(G) e , (2) [P F ]() = G∈F ∩
where x(G) denotes the distance between the point G and the detector placed on the lattice line (see Fig. 2). The reconstruction problem with absorption for a class of discrete sets, E, knowing the projections along all directed lines of L (we have to have a detector location for each line ) can be posed as RECONSTRUCTION DA(, E, L). Given: Function p : L −→ R0 (R0 denotes the set of nonnegative real numbers). Task: Construct a discrete set F ∈ E such that [P F ]() = p() for all ∈ L. 2.4. Reconstruction of 2D discrete sets with absorption Consider now the 2D integer lattice Z2 . Let m and n be positive integers. A discrete rectangle with size m × n is a special discrete set of Z2 determined as the intersection of m consecutive horizontal lattice lines with n consecutive vertical lattice lines. If F is a
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357 s1
detectors r1 F
1
s2 s3 s4 0
1
0
r2
0
1
1
0
r3
1
0
0
1
339
S(A)
A
R(A) (b)
(a)
Fig. 3. A 2D discrete set F, the corresponding binary matrix A, and their horizontal and vertical projections. (a) The set F and the detectors measuring its horizontal and vertical projections. (b) The binary matrix A and its absorbed row and column sums.
discrete set in Z2 , then there is an m×n discrete rectangle containing F, it is called containing (discrete) rectangle. (For the sake of simplicity we can take the smallest containing rectangle in the following.) Let us suppose that the horizontal and vertical projections of F are measured by detectors placed in the next column to left and in the next row to above, respectively, of the containing rectangle (see Fig. 3(a)). Then the absorbed projections can be computed according to (2). For example, in the case of the discrete set F given in Fig. 3(a), the absorbed projections along the horizontal lattice lines of the containing rectangle are r1 = e−·1 + e−·3 , r2 = e−·2 + e−·3 , and r3 = e−·1 + e−·4 . Now, we introduce an equivalent representation of the 2D discrete sets and their absorbed horizontal and vertical projections. The containing rectangle including F can be represented by a binary matrix A = (aij )m×n as follows: aij = 1 if the lattice point corresponding to (i, j ) is an element of F, aij = 0 otherwise. In order to use the generally accepted notation of numeration systems [11], let us introduce = e .
(3)
Clearly, 1. Then we can define the absorbed row and column sums of A, R (A) and S (A), respectively, as R (A) = (r1 , . . . , rm ),
(4)
where ri =
n j =1
aij −j ,
i = 1, . . . , m
and S (A) = (s1 , . . . , sn ), where sj =
m i=1
aij −i ,
j = 1, . . . , n.
(5)
340
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
For example, in the case of matrix A given in Fig. 3(b) R (A) = (−1 + −3 , −2 + −3 , −1 + −4 ) and S (A) = (−1 + −3 , −2 , −1 + −2 , −3 ). We say that two binary matrices with the same sizes are tomographically equivalent if they have the same absorbed row and column sums. Then the uniqueness problem of 2D discrete sets (or, equivalently, of binary matrices) with absorption knowing the absorbed projections along horizontal and vertical lines can be posed as UNIQUENESS DA2D(, A). Given: 1, m, n, and a binary matrix A with size m × n. Question: Does there exist a different binary matrix A with the same size such that A and A are tomographically equivalent with respect to their absorbed projections R and S ? If = 1 then we have the classical uniqueness problem of binary matrices without absorption (see e.g. [4,8]). Binary matrices with absorption can be reconstructed even only from their row sums in certain cases. For example, if and n have the following property: for any positive integers t, z, and 1p1 < · · · < pt n, 1q1 < · · · < qz n −p1 + · · · + −pt = −q1 + · · · + −qz implies that t =z
and
p1 = q1 , . . . , pt = qt .
In this case each row of A is uniquely determined by its absorbed row sum, and so A is uniquely determined by R (A). For example, if 2 then we have this property for any n1. But how can we do reconstruction if and n do not have this property? Select, for example, the case = 0 , where −2 −3 −1 0 = 0 + 0
(6)
giving √ 1+ 5 . 0 = 2
(7)
√ (The other solutions of (6), namely √ (1 − 5)/2 and 0, are not applicable in this case; c.f., (3).) In this case = log((1 + 5)/2) which gives a mathematically interesting case that will be analysed in detail in this paper.
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
341
3. 0 -representation Consider the absorbed row and column sums of the binary matrix A in the case of = 0 : ri =
n j =1
−j
aij 0 ,
i = 1, . . . , m
(8)
aij −i 0 ,
j = 1, . . . , n.
(9)
and sj =
m i=1
Using the terminology of numeration systems [11] we can say that the finite (binary) word ai1 · · · ain is a (finite) representation in base 0 (or a finite 0 -representation) of ri for each i = 1, . . . , m, and, similarly, a1j · · · anj is a 0 -representation of sj for each j = 1, . . . , n. The Eqs. (8) and (9) mean also that the absorbed row and column sums of A are nonnegative real numbers having a finite 0 -representation with n and m binary digits, respectively (including the eventually ending zeros). Since we deal only with finite length 0 -representations in this paper, the 0 -representation always means finite length 0 -representation. Let Bk denote the set of nonnegative real numbers having a 0 -representation with k binary digits (k > 1), formally, Bk =
k i=1
ai −i 0 | ai ∈ {0, 1} .
Then ri ∈ Bn ,
i = 1, . . . , m
and s j ∈ Bm ,
j = 1, . . . , n,
are necessary conditions for the existence of a matrix A with R0 (A) = (r1 , . . . , rm ) and
S0 (A) = (s1 , . . . , sn ).
4. Switchings Switching is, roughly, a transformation of 0 -representations by which certain 0s and 1s are replaced to each other such that the represented values remain the same. As it will be proven in this section, switchings play a basic role in the uniqueness problem DA2D(0 , A). 4.1. 1D switchings The 0 -representation is generally nonunique, because there are binary words with the same length representing the same number. For example, on the base of (6), it is easy to
342
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
check the following equality between the 3-digit-length 0 -representations of 1/0 100 = 011
(10)
which is the most simple example of switching. Furthermore (6) may allow us to define more general switchings: Let a1 · · · ak be a kdigit-length 0 -representation and let I be a subset of {1, . . . , k}. We say that I is a set of switching positions of a1 · · · ak if by replacing (switching) the 1s and 0s to each other in the positions of I the new (switched) word represents the same number as a1 · · · ak . This transformation of the 0 -representations is called 1D switching. As an example, let us take Eq. (10). Here all positions, 1, 2, and 3, are switching positions of 100. Another example can be shown by using 100 00. Since 100 00 = 010 11, I = {1, 2, 4, 5} is a set of switching positions of 100 00 (and of 010 11). If there is one of the sub-words 011 and 100 in a 0 -representation then it can be replaced by the other one without changing the value of the representation, i.e., it is a special kind of switching. It is called 1D elementary switching. For example, a 1D elementary switching can be done in the positions 2, 3, and 4 of the word 010 00 getting the word 001 10 representing the same number. The words 011 and 100 are called 0-type and 1-type 1D elementary switching words, respectively, also the switching pair expression can be used. As direct consequences of (10), it is easy to see that 011 01x3 11 01x3 1x5 11 01x3 1x5 1x7 11
= = = =
100, 10x3 00, 10x3 0x5 00, 10x3 0x5 0x7 00, . . .
(11)
where x3 , x5 , x7 , . . . denotes the positions where both 0 -representations have the same (but otherwise arbitrary) binary digit. For example, the second equality of (11) can be proved as follows: if then
x3 = 0, 01x3 11 = 010 11 = 011 00 = 100 00 = 10x3 00,
if then
x3 = 1, 01x3 11 = 011 11 = 100 11 = 101 00 = 10x3 00,
(12)
that is, we got the necessary representation after two consecutive 1D elementary switchings in both cases. The third, fourth, etc. equalities of (11) can be proved similarly by applying three, four, etc. 1D elementary switchings. Accordingly, if in a 0 -representation there is one of the words listed in either side of the Eq. (11) then it can be replaced (switched) by the word on the other side of the corresponding Eq. (11) without changing the value of the representation. This transformation of binary words is called 1D composite switching. The words starting with 0 (resp. 1) in the Eq. (11) will be called 0-type (resp., 1-type) 1D composite switching words, respectively.
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
343
For example, 101 00 is a 1-type composite switching word being on the left side of the second equation of (11). Now we are going to show that the 1D composite switchings can be composed from 1D elementary switchings as follows. Let a1 · · · ak and b1 · · · bl (k and l are positive odd integers) be two 1D switching words of the same type (i.e., either a1 = b1 = 0 or a1 = b1 = 1). Their composition, denoted by ∗, is defined as a1 · · · ak ∗ b1 · · · bl = a1 · · · ak−1 _ _b2 · · · bl , where _ _ indicates that the kth position of the resulting composition word is undefined. For example, 011 ∗ 011 100 ∗ 100 01x3 11 ∗ 011 10x3 0x5 0x7 00 ∗ 10y3 0y5 00
= = = =
01_ _11, 10_ _00, 01x3 1_ _11, 10x3 0x5 0x7 0_ _0y3 0y5 00,
where x3 , x5 , x7 , and y3 , y5 denotes the positions where both 0 -representations have the same (but otherwise arbitrary) binary digit. Now, we are going to prove that any finite 0 -representation of a number can be got from its any other 0 -representation by 1D elementary switchings. Lemma 1. Let a1 · · · ak and b1 · · · bk be different, k-digit-length 0 -representations of the same number. Then b1 · · · bk can be get from a1 · · · ak by a finite number of switchings. Proof. We are going to give a procedure by which suitable switching sub-words can be found in a1 · · · ak and, by switching them, the number of different positions between a1 · · · ak and b1 · · · bk can be decreased until there is no different position. Let i be the first position (1 i k) where the two representations are different, that is, a1 · · · an = x1 · · · xi−1 ai · · · ak = x1 · · · xi−1 bi · · · bk = b1 · · · bk ,
(13)
where x1 , . . . , xi−1 denote positions where the two representations have the same binary digit. Furthermore, let us suppose that ai = 1 and bi = 0, that is, ai · · · ak = 1ai+1 · · · ak , bi · · · bk = 0bi+1 · · · bk . Note that k = i (for otherwise it would follow from (13) that 1 = 0) and that k = i + 1 (for otherwise it would follow from (13) that 0 is an integer). Hence k > i + 1. Then ai+1 = 0 and bi+1 = 1, as it can be seen indirectly in the following. Otherwise there are two cases: Case 1: If ai+1 = 1 then ai · · · ak = 11ai+2 · · · ak 110 · · · 0.
(14)
Let us write as many 0’s to the end of the binary word on the right side of (14) (if it is not so yet) that the length of the padded binary word is an even number being not less than 4.
344
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
Then 1100 · · · 00 = 1010 · · · 011 > 1010 · · · 001 = 011 · · · 11,
(15)
where we have equalities by switchings and strict inequality by changing the 1 to 0 in position last but one (denoted by underlined digit). Since 011 · · · 11bi · · · bk
(16)
from (14)–(16) we got the contradiction ai · · · ak > bi · · · bk . Case 2: If bi+1 = 0 then let us follow a similar idea as in Case 1: ai · · · ak = 1ai+1 · · · ak 100 · · · 0.
(17)
Let us write as many 0’s to the end of the binary word on the right side of (17) (if it is not so yet) that the length of the padded binary word is an even number being not less than 4. Then 1000 · · · 00 = 0101 · · · 0110 > 0101 · · · 0100 = 0011 · · · 11,
(18)
where we have equalities by switchings and strict inequality by changing the 1 to 0 in position last but one (denoted by underlined digits). Since 0011 · · · 1100bi+2 · · · bk = bi · · · bk
(19)
from (17)–(19) we got again the contradiction ai · · · ak > bi · · · bk . Therefore, ai+1 = 0 and bi+1 = 1. That is, if ai · · · ak and bi · · · bk represent the same number then ai · · · ak = 10ai+2 · · · ak , bi · · · bk = 01bi+2 · · · bk necessarily. Consider now the next position, i + 2, in ai · · · ak and bi · · · bk . Then there are three cases to be studied. Case 1: If ai+2 = 0 and bi+2 = 1 then we have the switching sub-words ai ai+1 ai+2 = 100 and bi bi+1 bi+2 = 011. Therefore ai ai+1 ai+2 can be switched to bi bi+1 bi+2 getting a new representation a1 · · · ai−1 bi bi+1 bi+2 ai+3 · · · ak which can be different from b1 · · · bk only from the position i + 3. If a1 · · · ai−1 bi bi+1 bi+2 ai+3 · · · ak and b1 · · · bk are different then we can start the same procedure to find a switching in ai+3 · · · ak and bi+3 · · · bk , but now we have shorter representations to prove the lemma. Otherwise the two representations are the same, so we got b1 · · · bk from a1 · · · ak by one switching which means that the lemma is satisfied. Case 2: If ai+2 = 1 and bi+2 = 0 then ai · · · ak = 101ai+3 · · · ak 101 00 · · · 0.
(20)
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
345
Let us write as many 0’s to the end of the binary word on the right side of (20) (if it is not so yet) that the length of the padded binary word is an even number being not less than 6. Then 101 00 · · · 00 = 011 10 · · · 0110 > 011 10 · · · 0100 = 011011 · · · 111 > 010111 · · · 11,
(21)
where we have equalities by switchings and strict inequalities by changing the corresponding underlined digits in both sides. Since 010 11 · · · 11 010bi+3 · · · bk = bi · · · bk
(22)
from (20)–(22) we got the contradiction ai · · · ak > bi · · · bk . That is, this case is impossible. Case 3: The last case is when ai+2 = bi+2 , that is ai+2 = bi+2 = 0 or ai+2 = bi+2 = 1. Let us denote this common binary digit by xi+2 . In this case we have to continue the search for a composite switching word. That is, let us continue the procedure with the sub-words ai · · · ak = 10xi+2 ai+3 · · · ak , bi · · · bk = 01xi+2 bi+3 · · · bk , where xi+2 denotes the position where the two representations have the same binary digit. Now, we are going to show that ai+3 = 0 and bi+3 = 1 (note that k > i +2, for otherwise it would follow that 10xi+2 = 01xi+2 ). Otherwise, there are two cases. Case 1: If ai+3 = 1 then ai · · · ak = 10xi+2 1ai+4 · · · ak 10xi+2 10 · · · 0.
(23)
Let us write as many 0’s to the end of the binary word on the right side of (23) (if it is not so yet) that the length of the padded binary word is an even number being not less than 6. Then 10xi+2 100 · · · 000 = 10xi+2 010 · · · 011 > 10xi+2 010 · · · 001 = 10xi+2 0011 · · · 11 = 01xi+2 111 · · · 11,
(24)
where we have equalities by switchings and strict inequality by changing the 1 to 0 in position indicated by underlined digit. Since 01xi+2 11 · · · 1101xi+2 bi+3 · · · bk = bi · · · bk
(25)
from (23)–(25) we got the contradiction ai · · · ak > bi · · · bk . That is, this case is impossible. Case 2: If bi+3 = 0 then let us follow a similar idea as in Case 1: ai · · · ak = 10xi+2 ai+3 · · · ak 10xi+2 0 · · · 0.
(26)
Let us write as many 0’s to the end of the binary word on the right side of (26) (if it is not so yet) that the length of the padded binary word is an even number being not less than 7.
346
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
Then 10xi+2 0000 · · · 000 = 01xi+2 1100 · · · 000 = 01xi+2 1010 · · · 011 > 01xi+2 1010 · · · 001 = 01xi+2 0011 · · · 111,
(27)
where we have equalities by switchings and strict inequality by changing the 1 to 0 (in position indicated by underlined digit). Since 01xi+2 011 · · · 11 = 01xi+2 0bi+4 · · · bk bi · · · bk
(28)
from (26)–(28) we got the contradiction ai · · · ak > bi · · · bk . That is, this case is also impossible. Therefore, ai+3 = 0 and bi+3 = 1. In the following we have to study the possibilities when ai · · · ak = 10xi+2 0ai+4 · · · ak , bi · · · bk = 01xi+2 1bi+4 · · · bk . Consider now the next position, i + 4, in ai · · · ak and bi · · · bk (note that k > i + 3, for otherwise it would follow that 10xi+2 0 = 01xi+2 1). Then there are three cases to be studied. Case 1: If ai+4 = 0 and bi+4 = 1 then we have the switching sub-words ai ai+1 ai+2 ai+3 ai+4 = 10xi+2 00 and bi bi+1 bi+2 bi+3 bi+4 = 01xi+2 11 (see (11)) and we can switch ai ai+1 ai+2 ai+3 ai+4 and bi bi+1 bi+2 bi+3 bi+4 getting a new representation, a1 · · · ai−1 bi bi+1 bi+2 bi+3 bi+4 ai+5 · · · ak , which can be different from b1 · · · bk only from the position i + 5. If the new representation is different from b1 · · · bk then we can start the same procedure to find a switching in ai+5 · · · ak and bi+5 · · · bk , but now we have shorter representations to prove the lemma. Otherwise, the two representations are the same, so we got b1 · · · bk from a1 · · · ak by one switching which means that the lemma is satisfied. Case 2: If ai+4 = 1 and bi+4 = 0 then we get a contradiction in the same way as in the case of ai+2 = 1 and bi+2 = 0. That is, this case is impossible. Case 3: The last case is when ai+4 = bi+4 . In this case we have to continue the search for a composite switching word. That is, we have to continue the procedure according to Case 3 with the sub-words ai · · · ak = 10xi+2 0xi+4 ai+5 · · · ak , bi · · · bk = 01xi+2 1xi+4 bi+5 · · · bk , where xi+2 and xi+4 are in the positions where the two representations have the same binary digits. Then we can show that ai+5 = 0 and bi+5 = 1 as it was in the case of ai+3 = 0 and bi+3 = 1. That is, ai · · · ak = 10xi+2 0xi+4 0ai+6 · · · ak , bi · · · bk = 01xi+2 1xi+4 1bi+6 · · · bk . And so on. Generally, ai+2l = bi+2l (= xi+2l ), ai+2l+1 = 0, and bi+2l+1 = 1 for l = 1, 2, . . . . But this procedure is finished after a finite number of steps, therefore, there is an
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
347
index value l such that ai+2l+1 = ai+2l+2 = 0 and bi+2l+1 = bi+2l+2 = 1: ai · · · ak = 10xi+2 0xi+4 0 · · · 0xi+2l 00ai+2l+3 · · · ak , bi · · · bk = 01xi+2 1xi+4 1 · · · 1xi+2l 11bi+2l+3 · · · bk . Then we have the switching sub-words 10xi+2 0xi+4 0 · · · 0xi+2l 00 and 01xi+2 1xi+4 1xi+6 1 · · · 1xi+2l 11 (see (11)) and we can switch ai · · · ai+2l+2 and bi · · · bi+2l+2 getting a new representation, a1 · · · ai−1 bi bi+1 · · · bi+2l+2 ai+2l+3 · · · ak which can be different from b1 · · · bk only from the position i + 2l + 3. If the new representation is different from b1 · · · bk then we can start the same procedure to find a switching in ai+2l+3 · · · ak and bi+2l+3 · · · bk , but now we have shorter representations to prove the lemma. Otherwise, the two representations are the same after this switching. As a result of this procedure we can say that since the number of different positions of a1 · · · ak and b1 · · · bk decreases by each switchings, we get b1 · · · bk from a1 · · · ak after a finite number of switchings. Consequences (i) If a1 · · · ak and b1 · · · bk are different, k-digit-length 0 -representations of the same number, then there are positions i, . . . , i + 2l + 2 (l 0, 1 i, i + 2l + 2 k − 2) such that there is a switching between a1 · · · ak and b1 · · · bk on these positions. (ii) Let a1 , . . . , ak ∈ {0, 1} (k 3). a1 · · · ak is the only k-digit-length 0 -representation of a real number if and only if it has no switching, or equivalently, it has no sub-word 100 or 011. 4.2. 2D switchings In this subsection we determine the 2D switchings, i.e., the transformations of binary matrices by which some of their 0s and 1s can be switched to each other such that the absorbed row and column sums remain the same. 4.2.1. Connectedness Consider now the class of m × n (m, n 3) binary matrices with given row and column sum vectors in the case of absorption 0 . Let Q(i,j ) (1 < i < m, 1 < j < n) denote the 3 × 3 discrete square Q(i,j ) = {i − 1, i, i + 1} × {j − 1, j, j + 1}. Let be a set of 3×3 discrete squares of {1, . . . , m}×{1, . . . , n} and let Q(i,j ) , Q(i ,j ) ∈ . Two kinds of connectedness will be defined on 3 × 3 discrete squares: side-connectedness and corner-connectedness. There is a side-connection between Q(i,j ) and Q(i ,j ) if (i , j ) ∈ {(i − 2, j ), (i, j − 2), (i, j + 2), (i + 2, j )}. The four squares being side-connected to Q(i,j ) are called the side-neighbours of Q(i,j ) . As an illustration see Fig. 4(a). Q(i,j ) and Q(i ,j ) are corner-connected if (i , j ) ∈ {(i −2, j −2), (i −2, j +2), (i +2, j −2), (i +2, j +2)}. The four squares being corner-connected to Q(i,j ) are called the corner-neighbours of Q(i,j ) (see Fig. 4(b)). There is a side-chain between Q(i,j ) and Q(i ,j ) in if a sequence of elements of can be selected such that the first element is Q(i,j ) and the last element is Q(i ,j ) and any two
348
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
(i,j)
(i,j)
(a)
(b)
Fig. 4. Q(i,j ) and (a) its side-neighbours and (b) its corner-neighbours.
Q(i, j)
Q(i', j')
(a)
(b)
Fig. 5. Side-connected sets of discrete squares. The set (a) is not strongly side connected because Q(i,j ) ∩ Q(i ,j ) = ∅ but they are not side-connected and they have no common side-neighbour. (b) A strongly side-connected set.
consecutive elements of the sequence are side-connected. (A sequence consisting of only one square is a side-chain by definition.) The set is side-connected if there is a side-chain in between its any two different elements (see Fig. 5(a)). A maximal side-connected subset of is called a side-connected component of . Clearly, the side connected components of give a partition of . A side-connected set is strongly side-connected if whenever Q(i,j ) , Q(i ,j ) ∈ and Q(i,j ) ∩ Q(i ,j ) = ∅ then they are side-connected or they have a common side-connected neighbour (see Fig. 5(b)). Let be a set of strongly side-connected components (1) , . . . , (k) (k 1) of the same set . Let (l) , (l ) ∈ (1l, l k). (l) and (l ) are corner-connected if whenever Q ∈ (l) and Q ∈ (l ) have a common position then Q and Q are corner-connected squares. (Since (l) and (l ) are maximal, Q and Q cannot be side-connected squares.) There is a corner-chain between (l) and (l ) in if a sequence of elements of can be selected such that the first element is (l) and the last element is (l ) and any two consecutive elements of the sequence are corner-connected. (A sequence consisting of only one component is a corner-chain by definition.) The set is corner-connected if there is a corner-chain in between its any two elements (see Fig. 6(a)). 4.2.2. Switching patterns In order to identify not necessarily rectangular parts of binary matrices, we introduce the concept of the binary pattern (or shortly, pattern) as binary valued function defined on an
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
(a)
349
(b)
Fig. 6. Two corner-connected sets, both of them have two strongly side-connected components.
arbitrary non-empty subset of {1, . . . , m} × {1, . . . , n}. (In this terminology binary matrices are binary patterns on discrete rectangles.) Let P be a binary pattern, its domain will be denoted by dom(P ). The absorbed row and column sums of P are denoted by R0 (P ) and S0 (P ), respectively, where the ith component of R0 (P ) is −j P (i, j )0 (i,j )∈dom(P )
for 1i m and the jth component of S0 (P ) is P (i, j )−i 0 (i,j )∈dom(P )
for 1j n. Let us define the binary pattern P as P (i, j ) = 1 − P (i, j ) on dom(P ). By definition, P is a switching pattern if R0 (P ) = R0 (P )
and
S0 (P ) = S0 (P ).
In this case we say that P and P are a switching pair. That is, the patterns of a switching pair can be get from each other by switching their 0s and 1s and still they have the same absorbed row and column sums. As an example, consider the following binary patterns: 0 (0) E(i,j ) = 1 1
1 0 0
1 0 0
and
1 (1) E(i,j ) = 0 0
0 1 1
0 1 1
(29) (0)
both of them are defined on the discrete square Q(i,j ) . It is easy to check that E(i,j ) and (1)
E(i,j ) are a switching pair. They play an important role in the generation of switching
350
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357 (0)
(1)
patterns, E(i,j ) and E(i,j ) are called the 0-type and 1-type elementary switching patterns, respectively. 4.2.3. Composition of patterns The composition of two patterns P and P is the function P ∗ P : dom(P) dom(P ) −→ {0, 1} ( denotes the symmetric difference) such that P (i, j ), if(i, j ) ∈ dom(P ) \ dom(P ), [P ∗ P ](i, j ) = P (i, j ), if(i, j ) ∈ dom(P ) \ dom(P ). (That is, P ∗ P is undefined on dom(P ) ∩ dom(P ).) For example,
(0)
(0)
E(i,j ) ∗ E(i+2,j )
0 1 1 1 0 0 = __ __ __ 1 0 0 1 0 0
(30)
defined on Q(i,j ) Q(i+2,j ) = {i − 1, i, i + 2, i + 3} × {j − 1, j, j + 1}. (Just for the sake of simple presentation, on the right side of (30) the whole sub-matrix on the rectangle {i −1, . . . , i +3}×{j −1, j, j +1} is indicated and—denotes the positions in the sub-matrix where the composition is undefined.) Similarly, 0 (0) (0) E(i,j ) ∗ E(i,j +2) = 1 1
1 0 0
__ 1 __ 0 __ 0
1 0 0
(31)
defined on Q(i,j ) Q(i,j +2) = {i − 1, i, i + 1} × {j − 1, j, j + 2, j + 3}. It is easy to see (0)
(0)
(0)
(0)
that E(i,j ) ∗ E(i+2,j ) and E(i,j ) ∗ E(i,j +2) are switching patterns, their switching pairs are (1)
(1)
(1)
(1)
E(i,j ) ∗ E(i+2,j ) and E(i,j ) ∗ E(i,j +2) , respectively, where 1 0 0 0 1 1 (1) (1) E(i,j ) ∗ E(i+2,j ) = _ _ _ _ _ _ 0 1 1 0 1 1
and
1 (1) (1) E(i,j ) ∗ E(i,j +2) = 0 0
0 1 1
__ 0 __ 1 __ 1
0 1 1.
(32)
These examples show how new switching patterns can be created from elementary switching patterns by composition. The following lemma gives a more general way to show how two (not only elementary) switching patterns can be used to generate another switching pattern.
Lemma 2. Let P1 and P2 be switching patterns. If P1 = 1 − P 2 on dom(P1 ) ∩ dom(P2 ) then P1 ∗ P2 is also a switching pattern.
(33)
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
351
Proof. Let I1 = dom(P1 ), I2 = dom(P2 ), and P = P1 ∗ P2 on I = I1 I2 . Let, furthermore, P1 = 1 − P1 ,
P2 = 1 − P2
P = 1 − P
and
on I1 , I2 , and I, respectively. It is easy to see that P = P1 ∗ P2 , on I, and P1 = 1 − P2 ,
(34)
on I1 ∩ I2 . We are going to show that R0 (P ) = R0 (P ).
(35)
According to the definitions, the ith components of R0 (P ) = (1 , . . . , m ), 1 i m, can be written as −j −j i = P (i, j )0 = [P1 ∗ P2 ](i, j )0 I
(i,j )∈I
=
I \I2
−j P1 (i, j )0
1
=
−
I1
I1 ∩I2
+
I2 \I1
−j
P2 (i, j )0
−j P1 (i, j )0
+
−
I2
−j
P2 (i, j )0 .
I2 ∩I1
P1
Since P1 and are a switching pair on I1 and P2 and P2 are a switching pair on I2 , we get that −j −j −j −j i = P1 (i, j )0 − P1 (i, j )0 + P2 (i, j )0 − P2 (i, j )0 I1 ∩I2
I1
=
I1
−j P1 (i, j )0
+
I2
I2
−j P2 (i, j )0
−
I1 ∩I2
I1 ∩I2
−j P1 (i, j ) + P2 (i, j ) 0 .
After partitioning I1 and I2 and ordering the new terms we get
−j −j −j i = P1 (i, j )0 + P2 (i, j )0 + P1 (i, j ) + P2 (i, j ) 0 I1 \I2
−
I2 \I1
I1 ∩I2
I1 ∩I2
P1 (i, j ) + P2 (i, j )
−j 0 .
Then from the definition of the composition (33), and (34) we have −j −j −j i = [P1 ∗ P2 ](i, j )0 + 10 − 10 I
=
(i,j )∈I
I1 ∩I2
P
I1 ∩I2
−j (i, j )0 .
That is, the ith component of R0 (P ) is the same as the ith component of R0 (P ). In this way (35) is proved. The equality S0 (P ) = S0 (P ) can be proved similarly.
352
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
Remark 1. In the case of the compositions of (30) the condition (33) is satisfied, i.e., (0)
(0)
E(i,j ) = 1 − E(i+2,j ) (0)
(0)
on Q(i,j ) ∩ Q(i+2,j ) , therefore E(i,j ) ∗ E(i+2,j ) is a switching pattern, as we have seen it soon before the proof of Lemma 2. Similar statements are true in the cases of (31) and (32). 4.2.4. Composition of elementary switching patterns Let E = {E1 , . . . , Ek } (k 1) be a set of elementary switching patterns of the same type on a strongly side-connected set = {Q1 , . . . , Qk }. The composition of E on , denoted by C(E), is defined as follows. If k = 1 then C(E) = E1 . If k > 1 then let us suppose that Q1 , . . . , Qk are indexed such that for each l(< k) {Q1 , . . . , Ql } is a strongly side-connected set and one of its squares is side-connected with Ql+1 . (It is easy to see that such an indexing exists.) Then let C = C(E) = ((E1 ∗ E2 ) ∗ · · ·) ∗ Ek . Now, we are going to show that this definition is independent from the indexing of = {Q1 , . . . , Qk }. There are four cases depending on how many times a position (i, j ) is in the sets {Q1 , . . . , Qk }: (i) If there is exactly one l such that (i, j ) ∈ Ql , then (l)
C(i, j ) = eij , (l)
where eij denotes the value of El in the position (i, j ). (ii) If there are exactly two different l1 and l2 such that (i, j ) ∈ Ql1 and (i, j ) ∈ Ql2 , then C(i, j ) is undefined. (iii) If there are exactly three different l1 , l2 , and l3 such that (i, j ) ∈ Ql1 ∩ Ql2 ∩ Ql3 , then two of the elementary switching patterns (say, El1 and El3 ) has the same value in the position (i, j ) and the other one (El2 ) has a different value in the position (i, j ), i.e., (l ) (l ) (l ) eij1 = eij3 = 1 − eij2 . In this case (l )
(l )
C(i, j ) = eij1 = eij3 . (iv) If there are exactly four different l1 , l2 , l3 , and l4 such that (i, j ) ∈ Ql1 ∩Ql2 ∩Ql3 ∩Ql4 , then C(i, j ) is undefined. That is, the value of C(i, j ) can be decided simply on the base of the parity of the number of discrete squares of covering (i, j ) (independently from the indexing of ). Accordingly, if E is the set of 2D elementary switching patterns of the same type on a strongly sideconnected set, then we can simply write C(E) to denote the compositions of the elements of E. As an example, see Fig. 7. Lemma 3. Let E be a set of elementary switching patterns of the same type on a strongly side-connected set of 3 × 3 squares. Then C(E) is a switching pattern. Proof. The lemma will be proved by induction according to the number of elementary switching patterns in E. Let E1 , . . . , Ek (k 1) denote the elementary switching patterns
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
0
1
1
0
1
0
1 0 1
1 0 0
0 0
1 1
0 1 0
353
1 1 0
0
0
0
0 0
(0)
(0)
(0)
(0)
(0)
Fig. 7. The composition of the elementary switching patterns E(2,2) , E(2,4) , E(4,4) , E(4,6) , and E(6,4) . _ _ denotes the positions where the composition is undefined.
(0)
of E on the strongly side-connected set = {Q1 , . . . , Qk }. If k = 1, i.e., E = {E(i,j ) } or (1)
E = {E(i,j ) } for some (i, j ), then Lemma 3 is trivially true. (If k = 2 then the possible compositions are just given by (30), (31), and (32), all of them are switching patterns.) Generally, let us suppose that Lemma 3 is proved for any set E consisting of k number of elementary switching patterns. Let Ek+1 be an elementary switching pattern having the same type as E1 , . . . , Ek such that {Q1 , . . . , Qk , Qk+1 } is also a strongly side-connected set. Let C = C(E) and D = C ∗ Ek+1 . By induction C is a switching pattern on dom(C). In order to apply Lemma 2 we have to show that C(i, j ) = 1 − Ek+1 (i, j )
(36)
for all (i, j ) ∈ dom(C) ∩ Qk+1 . There are two cases depending on how many times such a position (i, j ) is in the sets Q1 , . . . , Qk : (i) There is exactly one l(∈ {1, . . . , k}) such that (i, j ) ∈ Ql . Then Ql and Qk+1 are side-connected. Since El and Ek+1 are elementary switching patterns of the same type, it is easy to check that (36) is satisfied if Qk+1 is either north, east, south, or west side-connected to Ql (see Fig. 8). (ii) There are exactly three l1 , l2 , and l3 , all of them from {1, . . . , k}, such that (i, j ) ∈ Ql1 ∩Ql2 ∩Ql3 . Then one of them, say, Ql2 is side-connected to the other two squares and Ql1 and Ql3 are corner-connected squares. Since El1 , El2 , El3 , and Ek+1 are elementary switching patterns of the same type, it is easy to check that (36) is satisfied if Qk+1 is either north-east, south-east, south-west, or north-west corner-connected to Ql (see Fig. 9). (If (i, j ) is in even number of squares of Q1 , . . . , Qk then (i, j ) ∈ dom(C) ∩ Qk+1 , see the cases (ii) and (iv) in the paragraph introducing the definition of the composition of elementary switching patterns.) That is, (36) is proved for every possible cases. Then Lemma 2 can be applied, therefore, D is a switching pattern. Henceforth, the switching patterns constructed from elementary switching patterns of the same type by composition are called composite switching patterns. We say that the
354
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
El 1 0
1 0
11 0 0
0 C
0
0 0 1 0 0
C 0 1 1 0 0 0 0 0 0 1 0 00 00 1 0 El
0 1 1 1 0 0 1 0 0 Ek+1
0 1 1 10 0 1 00 Ek+1
El Ek+1 01 1 1 0 0 10 0
Ek+1 0 1 1 10 0 10 0
El 01 1 0 1 1 0 0 1 C
11 0 0
0 1 1 0
1 0
0 0 0 0
1 0 0 1 0 0 10 C
Fig. 8. Illustration of the fact that Eq. (36) is satisfied if exactly one of the elementary switching patterns of C, say El , has common positions with the elementary switching pattern Ek+1 (the binary values at the common positions are indicated by bold digits) and El and Ek+1 have the same type (here: 0-type; 1-type patterns can be checked similarly). The positions indicated by “_ _” do not belong to the domain of C.
C 0
0
0
0
0
0 0 1 0 0 0 0
0
0 0
0
0 0
0
0 0 0 1 1 0 0 0
0 C 0
0
1 0
0 0 Ek+1
0 1 1 1 0 0 1 0 0
0 1 1 1 0 0 1 0 0 Ek+1
0 1 1 1 0 0 1 0 0 Ek+1
0 0
0 C
1 0 0 1 0 0 1 0
0
1 0
0
1 0
1 0
0 1 1 0 1 1 0 0
0
0
0
0
Ek+1
0 1 1 1 0 0 1 0 0
0
0
0
C
Fig. 9. Illustration of the fact that Eq. (36) is satisfied if exactly three of the elementary switching patterns of C have common positions with the elementary switching pattern Ek+1 (the binary value at the common position is indicated by bold digit) and all three elementary switching patterns of C and Ek+1 have the same type (here: 0-type; 1-type patterns can be checked similarly). The positions indicated by “_ _” do not belong to the domain of C.
composite switching pattern has 0-type/1-type if it is the composition of 0-type/1-type elementary switching patterns, respectively. For example, (30)–(32) and Fig. 7 show composite switching patterns of types 0, 0, 1, 1, and 0, respectively. 4.2.5. Composition of corner-connected components Lemma 4. Let (0) and (1) be corner-connected components. Let C (0) and C (1) be 0-type and 1-type 2D composite switching patterns on (0) and on (1) , respectively. Then C (0) ∗ C (1) is a switching pattern.
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357 C (0) 0 0 0
00
1 0
0 C (0)
0 0 0 0
1 0 1 0
0 0
1 0 0 1
0 1
0 1
0 1
0 0 1 1
1 C (1)
C (1) 1
1 1
0 1
1 C (1)
C (1) 1
1 1
0 1 0 11
1
1 1
1 1 1 1
355
C (0)
C (0) 1 0
1 1 0 0
0 1 1 0
1 0
0
0 0
1 0
0
Fig. 10. Illustration of the fact that Eq. (37) is satisfied in the common position of corner-connected components. The domains of E and E are indicated in C (0) and C (1) , respectively, by bold squares with solid lines.
Proof. In order to use Lemma 2 we have to show that C (0) = 1 − C (1)
(37)
on dom(C (0) ) ∩ dom(C (1) ). Since (0) and (1) are corner-connected components, dom(C (0) ) ∩ dom(C (1) ) consists of the common positions of corner-connected squares of (0) and (1) . Formally, if (i, j ) ∈ dom(C (0) ) ∩ dom(C (1) ) then there are 2D elementary switching patterns E and E such that (i, j ) ∈ dom(E ) ∩ dom(E ). It is easy to check that for such a position (i, j ) E (i, j ) = 1 − E (i, j ) in all possible cases (see Fig. 10). That is, (37) is satisfied. Then applying Lemma 2 to the 2D composite switching patterns C (0) and C (1) we get that C (0) ∗ C (1) is a switching pattern. Let be a corner-connected set of the strongly side-connected components (1) , . . . , (k) (k 1). Let C (1) , . . . , C (k) be 0- or 1-type composite switching patterns on (l) , . . . , (k) , respectively. Let us suppose also that if (l) and (l ) are corner-connected then C (l) and C (l ) have different type. In this case we say that = {C (1) , . . . , C (k) } is a set of alternatively corner-connected components on . The composition of on , denoted by C(), is defined as follows. If k = 1 then C() = C (1) . If k > 1 then let us suppose that (1) , . . . , (k) are indexed such that for each l (l < k) {(1) , . . . , (k) } is a corner-connected set and one of its elements is corner-connected with (l+1) . (It is easy to see that such an indexing exists.) Then let C = C() = ((C (1) ∗ C (2) ) ∗ · · ·) ∗ C (k) .
356
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
1 0 0 1 0 1 0 1
0 1 1 0 0 1 1 0 1 1
1 0
1 1 0 0
0 1 0 0 1 1
0 0 00
Fig. 11. Composition of two alternatively corner-connected components.
It is easy to show that this definition is independent from the indexing of , because dom(C) = ∪l (l) \ ∪l,l ((l) ∩ (l ) ) and C(i, j ) = C (l) (i, j ), where l ∈ {1, . . . , k} is the only index such that (i, j ) ∈ (l) . Henceforth, we may simply write C() to denote the composition of the elements of . As an example, see Fig. 11. Theorem 1. Let = {C (1) , . . . , C (k) } (k 1) be a set of alternatively corner-connected components. Then C() is a composite switching pattern. Proof. It follows from Lemma 4 directly.
5. Discussion A new kind of discrete tomography problem was introduced, the reconstruction of discrete sets from their absorbed projections. A special case of this problem was discussed in this paper, namely, the uniqueness of 2D binary matrices with respect to their absorbed row and column sums when the absorption is represented by the constant 0 of (7). It was shown that the uniqueness in this case could be characterised similarly as in the classical case of reconstruction without absorption, because similar elementary switchings could be given (0) (1) by E(i,j ) and E(i,j ) . We have shown that there is a hierarchy of 2D switching patterns in the case of absorption. The most simple kind of switching patterns are the 0-type and 1-type elementary switching patterns given by (29). More complicated switching patterns, so-called 0- and 1-type composite switching patterns can be constructed from 0-type and 1-type elementary switching patterns, respectively, defined on strongly side-connected components of 3 × 3 discrete squares by composition (Lemma 3). Finally, we get the most complex composite switching patterns as the composition of alternatively corner-connected components (Lemma 4). Theorem 1 also means that if a binary matrix contains an alternatively corner-connected component then it is non-uniquely determined with respect to its absorbed row and column sums. That is, the existence of an alternatively corner-connected component is sufficient for the non-uniqueness in the case of problem UNIQUENESS DA2D(0 , A). In another paper [10] we could prove that this condition is also necessary for the non-uniqueness, that is, since this condition is necessary and sufficient for the non-uniqueness, we have also that the compositions of alternatively corner-connected components are the most general switching patterns.
A. Kuba, M. Nivat / Theoretical Computer Science 346 (2005) 335 – 357
357
Acknowledgements A part of this research was done while the first author visited the Laboratoire d’Informatique Algorithmique: Fondements et Applications, Université Paris 7 Denis-Diderot, Paris, France. Special thanks to Prof. Gabor T. Herman (Graduate College, City University of New York) and Laurent Vuillon (LIAFA, Université Paris 7) for their valuable comments and discussions. This work was supported by the Grant OTKA T 032241 and NSF Grant DMS 0306215 (Aspects of Discrete Tomography). References [2] E. Balogh, A. Kuba, A. Del Lungo, M. Nivat, Reconstruction of binary matrices from absorbed projections, in: A. Braquelaire, J.-O. Lachaud, A. Vialard (Eds.), Discrete Geometry for Computer Imagery, Lecture Notes in Computer Science, Vol. 2301, Springer, Berlin, 2002, pp. 392–403. [3] E. Barcucci, A. Frosini, S. Rinaldi, Reconstruction of discrete sets from two absorbed projections: an algorithm, Electron. Notes Discrete Math. 12 (2003) 12. [4] R.A. Brualdi, Matrices of zeros and ones with fixed row and column sums, Linear Algebra Appl. 33 (1980) 159–231. [6] G.T. Herman, A. Kuba (Eds.), Discrete Tomography: Foundations, Algorithms and Applications, Birkhäuser, Boston, 1999. [7] G.T. Herman, R. Marabini, J.-M. Carazo, E. Garduno, R.M. Lewitt, S. Matej, Image processing approaches to biological three-dimensional electron microscopy, Int. J. Imaging Syst. Technol. 11 (2000) 12–29. [8] A. Kuba, G.T. Herman, Discrete tomography: A historical overview, in: Discrete Tomography: Foundations Algorithms and Applications, Birkhäuser, Boston, 1999, pp. 3–34. [9] A. Kuba, G.T. Herman, S. Matej, A. Todd-Pokropek, Medical applications of discrete tomography, in: D.Z. Du, P.M. Pardalos, J. Wang (Eds.), Discrete Mathematical Problems with Medical Applications, DIMACS Series in Discrete Mathematics and Theoretical Computer Science, Vol. 55, AMS, Rhode Island, 2000, pp. 195–208. [10] A. Kuba, M. Nivat, Reconstruction of discrete sets with absorption, Linear Algebra Appl. 339 (2001) 171–194. [11] M. Lothaire, Combinatorics on Words, Cambridge University Press, Cambridge, 1997. [12] H.J. Ryser, Combinatorial properties of matrices of zeros and ones, Canad. J. Math. 9 (1957) 371–377. [13] P. Schwander, C. Kisielowski, M. Seibt, F.H. Baumann, Y. Kim, A. Ourmazd, Mapping projected potential, interfacial roughness, and composition in general crystalline solids by quantitative transmission electron microscopy, Phys. Rev. Lett. 71 (1993) 4150–4153.
Theoretical Computer Science 346 (2005) 358 – 387 www.elsevier.com/locate/tcs
Monotone runs of uniformly distributed integer random variables: A probabilistic analysis Guy Louchard∗ Département d’Informatique, Université Libre de Bruxelles, CP 212, Boulevard du Triomphe, B-1050 Brusselles, Belgium
Abstract Using a Markov chain approach and a polyomino-like description, we study some asymptotic properties of monotone increasing runs of uniformly distributed integer random variables. We analyze the limiting trajectories, which after suitable normalization, lead to a Brownian motion, the number of runs, which is asymptotically Gaussian, the run length distribution, the hitting time to a large length k run, which is asymptotically exponential, and the maximum run length which is related to the Gumbel extreme-value distribution function. A preliminary application to DNA analysis is also given. © 2005 Elsevier B.V. All rights reserved. Keywords: Monotone increasing runs; Markov chains; Polyominoes
1. Introduction We consider i.i.d. integer random variables with the distribution I (s) given by p(i) = 1/s, i = 1 . . . s. Assume that we have a sequence x[i], i = 1 . . . n, constructed from independent I (s) random variables. A run is a maximal (contiguous) increasing monotone subsequence. A maximum is a position i such that x[i − 1] x[i] > x[i + 1]. For instance, with s = 4, the sequence 23241321224421321242 has 10 runs, with a maximal run length of 5. A first approach to the runs analysis was given in Crescenzi et al. [5]. We observe that a Markov chain approach can lead to asymptotic results on the runs. In this paper, continuing an approach we had started in [15,17–20], we consider the runs either as a stochastic ∗ Tel./fax: +322 6505613.
E-mail address:
[email protected]. 0304-3975/$ - see front matter © 2005 Elsevier B.V. All rights reserved. doi:10.1016/j.tcs.2005.08.015
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
359
process or as a polyomino. This allows the derivation of several asymptotic distributions of random variables and processes such as: the limiting trajectories, which after suitable normalization, lead to a Brownian motion, the number of runs, which is asymptotically Gaussian, the run length distribution, the hitting time to a large length k run, which is asymptotically exponential, and the maximum run length, which is related to the Gumbel extreme-value distribution function. Our results are in some sense similar to what we have obtained in [18] where we analyzed geometrically distributed random variables, and [19], where we considered Carlitz compositions. Let us already mention that, as s → ∞, all properties related to the ranked I (s) random variables have the same distributions as in the model of random permutations. For more details on the analysis of algorithms on sequences, the interested reader should consult Szpankowski [23]. The paper is organized as follows: in Section 2, we present the associated Markov chain and the limiting trajectories. Section 3 is devoted to some simulations and the maximum run length distribution. Section 4 provides a preliminary application to DNA analysis. Section 5 concludes the paper. Appendix A–C provide some technical tools which are useful in Section 3.1. This work emaned from the fruitful discussions we had with A. Del Lungo, during the 2003 summer. The paper was nearly completed when Alberto suddenly died on June 1, 2003. We present this work as a tribute to his memory. 2. Associated Markov chain and limiting trajectories In this section, we first describe the runs process as a Markov chain. We then study the run length distribution. We finally analyze the limiting trajectories and the number of runs distribution. 2.1. Stochastic analysis It is immediately checked that we can see the runs as a Markov chain, the states of which are given by the possible values i of the I (s) random variables starting a run, together with the run length. The following notations will be used in the sequel: L(i) := length of an ascending run starting with value i, (i, l, j ) := Pr[L(i) = l, x[l + 1] = j ] l 1 = , s i i2 ··· il >j (i, l) := Pr[L(i) = l] = (i, l, j ) j
= l
i i2 ··· il
(i, l) = 1,
l−1 il − 1 1 , s s
note that
360
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
[i, l], [j, ] := Pr[next run starts at j, has length , given that the previous run was starting at i and had length l] = (i, l, j )(j, )/(i, l). Two other transition matrices are given by [i, l], j := Pr[next run starts at value j, given that the previous run was starting at i and had length l] = [i, l], [j, ]
= (i, l, j )/(i, l), hence
[i, l], [j, ] = [i, l], j (j, ), [i, j ] := Pr[next run starts at j, given that the previous run was starting at i] = (i, l, j ). l
The stationary distribution of [i, j ] will be denoted by (j ). Note that (i, l) can be computed directly. Indeed set, 1 l−1 1 1 (i, l) := (i, w) = s wl i i2 ··· il s−i+1 1 1 s−i+l−1 l−1 . = [z ] = l−1 l−1 1 − z/s s We derive (i, l) = 1 (i, l) − 1 (i, l + 1) =
1 s l−1
s−i+l s−i+l−1 1− . l−1 ls
(1)
(2)
Also, for further use, we define 2 (i, l) := 1 (i, w), wl
3 (i, l) :=
2 (i, w).
wl
These expressions are easily seen to converge. Also, by Stirling formula, or better, by singularity analysis, (see [9]), with the well-known formula 1 1 n−1 n [z ] 1+O , n → ∞, ∼ 1−z () n 1 We use the notation [zk ]f (z) to denote the coefficient of zk in the power expansion of f (z).
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
361
we obtain
1 (k − 1)s−i 1+O . 1 (i, k) ∼ k−1 (s − i)!s k
(3)
Let us denote by Fj (z) the generating function of j (i, l). We know already that
1 F1 (i, z) = z 1 − z/s
s−i+1 (4)
.
The generating function of 2 (i, l) is given by F2 (i, z) = z
F1 (i, z) − F1 (i, 1) z−1
and, by singularity analysis (the dominant singularity of F2 is at z = s), we obtain 1 (k − 1)s−i 1+O 2 (i, k) ∼ . k−2 (s − 1)(s − i)!s k
(5)
Similarly, we derive 3 (i, k) ∼
1 (k − 1)s−i 1 + O . 2 k−3 (s − 1) (s − i)!s k
(6)
2.2. Some generating functions and their applications In this subsection, we first construct the generating functions of some probability transition matrices and stationary distributions. Next, we compute some stationary parameters distributions related to run lengths. Then we analyze the asymptotics of m successive runs. 2.2.1. One ascending run We build a corresponding polyomino as follows: we choose a starting integer i, and construct a monotone sequence of l integers, i = i1 · · · il , followed by a last integer j with j < il . We mark each integer by z, the last monotone integer il is marked by , and j is marked by . (For this kind of construction, see, for instance, [16].) The trivariate generating function (, , z|i) that comprises all such polyominoes, labelled as described, can be computed as follows: set g1 := zi ,
and, for k 1, ⎤ ⎡ s s
−1 gk+1 (, , z) = [ ]gk (, 0, z)z ⎣ r + j ⎦
=1
r=
j =1
1 − s = gk (1, 0, z)z 1−
s s− +1 s− +1 − 1 −1
+ − . [ ]gk (, 0, z)z −1 −1
=1
362
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
This sequence describes the effect of “adding a new slice.” The generating function gk corresponds to a polyomino of k integers (each integer marked by z), where the last integer is marked either by , if it is still monotone, or by , if it is smaller than the previous integer. Hence (, , z|i) :=
∞
gk (, , z)
k=1
1 − s s+1 +z (1, 0, z|i) 1− −1 s+1 z z (, 0, z|i) − (1, 0, z|i) + (, 0, z|i). − −1 −1 −1
= g1 + (1, 0, z|i)z
Set A1 := (1, 0, z|i). (To ease the notation, we usually drop the variables list, except when the context is not sufficiently clear). Setting = 0, = 0, we immediately check that (0, 0, z|i) = 0. Set now = 0. We obtain z s+1 A1 − (, 0, z|i), (, 0, z|i) = z i + −1 −1 which gives s+1 −1 i + A1 (, 0, z|i) = z −1+z −1 and
s+1 1 A1 + (, 0, z|i) (, , z|i) = z + −1 −1 A1 z z2 s+1 i + − + A1 . 1− −1+z −1
(7)
i
(8)
We also derive from (7)
s+1 z( − 1) i + A1 (, 0, z|i) = −1+z −1 and, finally
z2 s+1 s+1 i A1 − + A1 (, , z|i) = z + −1 −1+z −1
z2 A1 z s+1 + i + A1 + −1+z −1 1− s+1 z( − 1) = i + A1 −1+z −1
z2 A1 z s+1 i + + A1 + . −1+z −1 1−
i
(9)
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
363
It remains to compute A1 . But the first part of (9) has a singularity in the denominator at = 1 − z. This leads to (1 − z)s+1 ∗i A1 = 0 + 1−z−1 or A1 = z(1 − z)i−s−1
(which leads again to (1)),
and is completely determined. Set now (, z|i) = (0, , z|i)
A1 z s+1 z2 i = + + A1 1− −1+z −1
(10)
and, as → 1, this leads to (1, z|i) = z + (zs − 1)A1 . The generating function “contains” the quantities of interest, as described in the next proposition which gives all useful distributions in terms of Proposition 1.
1 l+1 j z (, z|i), sl 1 (i, l) = l zl+1 (1, z|i), s [i, j ] = j s(, 1/s|i).
(i, l, j ) =
It is convenient to set A2 (|i) := (1 − /s)i−s−1 ,
/s s+1 /s i A3 (, |i) := A2 + + A2 , 1 − − 1 + /s −1 s A4 (|i) := A3 (1, |i) = 1 + ( − 1)A2 . This leads to (i, l, j ) = [l j ]A3 (, |i), (i, l) = [l ]A4 (|i) (which leads again to (2)), [i, j ] = [j ]A3 (, 1|i), A3 (, 1|i) = (1 − 1/s)i−s−1 s(1 − )
s+1 1 i i−s−1 . + + (1 − 1/s) s( − 1 + 1/s) s( − 1)
364
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
It is an easy check to derive that j [i, j ] = 1, which follows from j [i, j ] = s(1, 1/s|i). To obtain (i), we start from the stationary equation (j ) = (i)[ j ]A3 ( , 1|i). i
We now compute the generating function of (i), () := sj =1 (j )j , and (1) = 1
() = (i)A3 (, 1|i) = (1 − 1/s)−s−1 ((1 − 1/s)) s(1 − ) i
1 s+1 −s−1 +
() + (1 − 1/s)
((1 − 1/s)) . (11) s( − 1 + 1/s) s( − 1) Solving (11) w.r.t. () and letting → 1; we obtain
((1 − 1/s)) = 2(1 − 1/s)s and, finally,
() = 2
s − s + s − 1 , s(1 − )2 (s − 1)
(12)
from which we derive s−i . s(s − 1) Of course, (s) = 0 and s−1 (i) = 1. 1 (i) = 2
2.2.2. Some stationary parameters distributions related to the run length As in [18], we need to compute the following averages and second moments: ¯ = (i, l)l, L(i) l
L2 (i) =
(i, l)l 2 ,
l
L¯ =
¯ (i)L(i).
i
For instance (differentiation is w.r.t. ), we obtain the following results: Proposition 2.
i−s−1 ¯ = A4 , L(i) =1 = (1 − 1/s) (1 − 1/s)i−s s(−2i + 3s + 1) ¯ L2 (i) = A4 =1 + L(i) = , (s − 1)2
(13)
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
365
and L¯ = L2 =
¯ (i)L(i) = 2/(1 − 1/s), (i)s 2 (i) =
2s(2(1 − 1/s)−s − 3) . s−1
The expressionfor L¯ is easy to check: this corresponds, by examining couples of random variables, to s 2 / si=2 (i − 1). The stationary generating function of the run length is given by H () =
(i)A4 = 1 + ( − 1)(1 − /s)−s−1 (1 − /s),
(14)
from which we derive, for instance, the following first three values of the stationary run length distribution: Proposition 3. Pr[L = 1] =
s−2 , 3s
5s 2 − s − 6 , 12s 2 (11s − 12)(s + 1)(s + 2) Pr[L = 3] = . 60s 3
Pr[L = 2] =
The stationary run length probability is geometrically decreasing. Note that, as s → ∞, ¯ L ∼ 2, L2 ∼ 4e −6. This is clear from the following result: as s → ∞, our model turns into the model of random permutations, with the stationary expressions L¯ = 2, L2 = 4e − 6. (see [20] for details). For further use, let us define the truncated mean run length, starting from i: ¯ l) := L(i,
w(i, w).
wk−2
w(i, w),
w>k−1
l1 (i, l + 1)
l>k−1
= (k − 1)1 (i, k) + 2 (i, k) = k1 (i, k) + 2 (i, k + 1).
(15)
366
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
A next useful quantity is given, with (12) and (4), by s+1 1 k−1 H1 (k) := (i)1 (i, k) = [z ]
(1 − z/s) 1 − z/s s 1 = [zk+1 ]2s 1 + (z − 1) (s − 1) 1 − z/s 2 s+k−1 s+k = s − (s − 1)s k k k+1 2k s+k−1 = . s−2 (s − 1)s k Asymptotically, singularity analysis leads to 1 2 s−1 1 + O k , H1 (k) ∼ (s − 1)!s k k
k → ∞.
(16)
(17)
(18)
A last useful equivalent concerns (i, l, j )/1 (i, k), k → ∞, l≥k
i.e. the asymptotic distribution of a run starting value, J, after a long run. Setting A5 (, |i) :=
(A3 (, |i) − A3 (, 1|i)) , −1
we see that (i, l, j ) = [k j ]A5 (, |i). l≥k
But it is readily checked that neither = s(1 − ) nor = 1 are singularities of A5 , the only singularity is at = s. Hence we obtain the equivalent A5 (, |i) ∼
s(s − ) (1 − /s)i−s−1 , (s − 1)( − 1)
→ s.
Now, 1 (i, k) ∼ [k−1 ](1 − /s)i−s−1 ,
k→∞
and the generating function of J is asymptotically given by s − 1 1+O . (s − 1)( − 1) k
(19)
But this intuitively evident: the long runs are followed by an integer asymptotically uniformly distributed on [1 . . . s − 1]. We could continue the asymptotics: the next correction
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
367
term is given by a matrix (we do not need its explicit value here): (20)
εN (i, j )
with ε := ((k − 1)s−1 )/s k−1 (the choice of ε is justified in Section 3.1). Note that N1 = 0. 2.2.3. m ascending runs We will analyze the total length X(m) (number of I (s) random variables) of m runs. We have X(m) =
m
L(ik ),
k=1
where ik is the starting value of run k. This corresponds to the length of a word where each letter is a I (s) random variable. By the ergodic theorem, we know that ¯ E(X(m)) ∼ mL, VAR(X(m)) ∼ m L2 − L¯ 2 + 2mS = m2 , say (see, for instance, [3, p. 172]), where S :=
∞
¯ v [[i, l], [j, ]]( − L) ¯ (i)(i, l)(l − L)
v=1 i,l,j,
=
¯ (i)(i, l)(l − L)
[[i, l], w1 ][w1 , w2 ] · · · [wv−2 , wv−1 ]
w1 ,w2 ,...,wv−1
v,i,l
×
¯ ) − L). ¯ [wv−1 , j ](L(j
j
To compute S, we first analyze f0 () :=
(i)(i, l, k)lk =
(i) A3 =1 .
k,i,l
To simplify further expressions, we set = (1 − 1/s). This leads to f˜0 () =
2 s((1 − 1/s) − 1)
s−1 −1 −s . +s (s − 1) − (1 − 1/s) −1
The first term of S is related to ¯ [k ]f˜0 ()L(k)/(1 − 1/s)k = (1 − 1/s)−s−1 f˜0 (1). k
368
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
Now define
f˜1 () :=
(i)(i, l, k)l(k, j )j
k,i,l,j
=
(1 − 1/s)−s ˜ f0 (1) s(1 − (1 − 1/s)) 1 s+1 ˜ ˜ + f0 () + f0 (1) , s(1 − 1/s)( − 1) s((1 − 1/s) − 1)
by (11). The second term of S is now related to (1 − 1/s)−s−1 f˜1 (1). We see now how to proceed: S is given by ˜ 1) − L¯ 2 /(1 − w) , S = lim (1 − 1/s)−s−1 (w, w→1
where ˜ (w, ) :=
∞
w i f˜i ().
0
˜ (w, ) can be computed as follows. We obtain w(1 − 1/s)−s ˜ ˜ (w, ) = f˜0 () + (w, 1) s(1 − (1 − 1/s)) w s+1 ˜ ˜ + (w, 1) (w, ) + s((1 − 1/s) − 1) s(1 − 1/s)( − 1) or (1 − 1/s)( − 1) − w/s ˜ (w, ) (1 − 1/s)( − 1) s w −s ˜ ˜ (w, 1). = f0 () + − (1 − 1/s) s((1 − 1/s) − 1) s(1 − 1/s)( − 1) ˜ ˜ To compute (w, 1), we note that the denominator of the expression for (w, ) has a singularity at = 1 + w/(s(1 − 1/s)), hence the numerator must be 0 for this value, which leads to −(1 − 1/s)s + w(1 − 1/s)s + ((s + w − 1)/s)s − w ˜ (w, 1) = 2 . w[w − ((s + w − 1)/s)s ] This gives ˜ 1) = L¯ 2 /(1 − w) (1 − 1/s)−s−1 (w, 2s[3(1 − 1/s)−s (s − 1) − 8s + 4] − + O(1 − w), 3(s − 1)2
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
369
and the singularity (at w = 1) in S is removed. Finally, 2s(s + 1) 2 = L2 − L¯ 2 + 2S = . 3(s − 1)2 Again, as s → ∞, we obtain the limiting value 2/3 which corresponds to a permutation. 2.3. Limiting trajectories Let us denote by M the number of runs. Let us first fix M to m and let us consider the total length X(m) (the number of I (s) random variables, i.e. the length of the word) of m runs X(m) =
m
L(ik ),
k=1
where i1 , . . . , im are the successive starting values of the runs. We can check that our Markov chain is -mixing (see, for instance, [3, p. 168] and the Appendix) and we apply the Functional Central Limit Theorem [3, p. 174, Theorem 20.1]. We obtain the following result, where B(t) is the standard Brownian Motion and ⇒ denotes the weak convergence of random functions in the space of all right-continuous functions that have right limits and are endowed with the Skorohod metric. This gives the limiting trajectories corresponding to a fixed number of runs. Theorem 4. ¯ X(mt ) − Lmt ⇒ B(t), √ m
m → ∞, t ∈ [0, 1].
(21)
Let us now condition on X(m) = n. M becomes a random variable. A realization of X for fixed n is given by Theorem 4, where we stop at a random time m such that X(m) = n. Proceeding as in [15] it is easy to check that this amounts to fix m = n/L in the denominator of (21), and we obtain the following result related to n random variables, with m runs. Theorem 5. Conditioned on X(m) = n, ¯ X(mt ) − Lmt ⇒ B(t). n/L¯ Moreover, from [22], the random variable M := number of runs satisfies the following Gaussian property: Proposition 6. M ∼ N (n1 , n21 ),
(22)
370
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
0.4
0.3
0.2
0.1
0
1
2
3
4
5
6
7
8
Fig. 1. Run length distribution (observed = circle, asymptotic = line).
10000
8000
6000
4000
2000
0
1000
2000
3000
4000
Fig. 2. Unnormalized X(·).
where N := a Gaussian (normal) random variable, s−1 , 1 = 1/L¯ = 2s 21 = 2 /L¯ 3 . This is actually an application of the generalized Renewal Theorem: the hitting time of ¯ is easily seen to lead the Brownian Motion B(t) of (21) to the barrier n(1 − t)/( n/L) asymptotically to a Gaussian random variable.
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
371
0.4 0.2 1000
0
2000
3000
4000
-0.2 -0.4 -0.6 -0.8
Fig. 3. Normalized X(·), with run length.
270
260
250
240
230
100
105
110
115
120
Fig. 4. Unnormalized X(·), with run length (zoom).
When s → ∞, we obtain 1 ∼ 1/2, 21 ∼ 1/12. We have done a simulation of U = 2000 sequences of n = 10 000 I (10) random variables (this simulation will be extensively used in Section 3), leading to 9 002 231 runs. The observed and limiting run length distributions are given in Fig. 1. (The limiting distribution is given by Proposition 3). The fit is quite good. A typical trajectory for X(i) for n = 10 000, s = 10 has given M = 4499 runs. The unnormalized trajectory is given in√ Fig. ¯ 2, which shows a “filament √ silhouette.” The normalized trajectory for (X(i) − Li)/ M ¯ and (X(i − 1) − Li)/ M, showing the run length is given in Fig. 3. Of course, both trajectories are asymptotically equivalent for n → ∞. A zoom on i = [100 . . . 120] is given in Fig. 4. We have also checked the asymptotic Gaussian property of M as given by (22). This
372
G. Louchard / Theoretical Computer Science 346 (2005) 358 – 387
1
0.8
0.6
0.4
0.2
0 4400
4450
4500 x
4550
4600
Fig. 5. Observed and limiting Gaussian M distribution function.
is shown in Fig. 5. The asymptotic mean and variance 1 , 21 are given by 0.4500, 0.0825 . . . and the observed mean and variance by 0.4501 . . . , 0.0840 . . . .
3. Hitting time and maximum run length distribution In this section, we study the hitting time to a large length k run and the maximum run length distribution. All vectors and matrices will be written in bold. 3.1. Large run in a sequence constructed from independent I (s) random variables, for fixed s Let us define Tk := the time (counted in terms of number of I (s) random variables, i.e. the length of the word) necessary to obtain a run of large length k. We set hi := Ei (Tk ), (when possible, we drop the k for ease of notation). We derive ¯ k) + k1 (i, k)] + (i, l, u)hu hi = [L(i, l