=Paper=
{{Paper
|id=Vol-3284/3328
|storemode=property
|title=On Counting k-Convex Polyominoes
|pdfUrl=https://ceur-ws.org/Vol-3284/3328.pdf
|volume=Vol-3284
|authors=Paolo Massazza
|dblpUrl=https://dblp.org/rec/conf/ictcs/Massazza22
}}
==On Counting k-Convex Polyominoes==
On Counting k-Convex Polyominoes (Short Paper) Paolo Massazza1 1 University of Insubria, Italy Abstract We show that, for any fixed integer π > 2, the problem of computing the number of π-convex polyominoes of area π is in P. Keywords polyominoes, counting problem, integer sequence 1. Introduction A polyomino is a geometrical figure consisting of a finite set of connected unit squares (called cells) in the plane Z Γ Z, considered up to translations. Polyominoes gained popularity after the paper of S. W. Golomb [1]. Nowadays they are widely studied by physicists, mathemati- cians, computer scientists and also by biologists. The problem of counting the number ππ of polyominoes with π cells (i.e. of area π) is probably one of the fundamental open problems in combinatorial geometry (see problem 37 in [2]). Due to the difficulty of the problem, simpler classes of polyominoes have been introduced. In particular, the class of convex polyominoes (polyominoes where the intersection with an infinite horizontal or vertical stripe is a finite segment) and some of its subclasses have been investigated [3, 4, 5, 6, 7]. In this paper, we consider the class Convπ [8] containing all convex polyominoes π with the property that any two cells of π can be joined by a path in π with at most π changes of direction, where π is a fixed integer greater than 2. We show that, for any fixed π > 2, the algorithm presented in [9] leads to a set of recurrence equations for computing the number of π-convex polyominoes of area π in polynomial time, using π(π5 ) space. 2. Notation and preliminaries Let π be a polyomino with an π Γ π minimal bounding rectangle. The rows (resp., columns) of π are numbered from bottom to top (resp., from left to right). The area A(π ) of π is the number of its cells. A cell of π is identified by a pair of integers (π, π), where π (resp., π) is the row (resp., column) index. Two cells π = (π, π) and πβ² = (πβ² , π β² ) are adjacent if |π β πβ² | + |π β π β² | = 1. Given two cells π and π of π , a path in π from π to π is a sequence π1 , π2 , . . . , ππ of cells of π , with π1 = π and ππ = π, such that ππ and ππ+1 are adjacent for all π with 1 β€ π < π. A Proceedings of the 23rd Italian Conference on Theoretical Computer Science, Rome, Italy, September 7-9, 2022 " paolo.massazza@uninsubria.it (P. Massazza) Β© 2021 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). CEUR Workshop Proceedings http://ceur-ws.org ISSN 1613-0073 CEUR Workshop Proceedings (CEUR-WS.org) step is a sequence of two adjacent cells (π, π), (πβ² , π β² ). Steps are distinguished according to the directions N (North), W (West), S (South) and E (East). The number of changes of direction in a path π½ β {N, W, S, E}+ is defined as the number of indices π such that π½π ΜΈ= π½π+1 , with 1 β€ π < |π½|. A path is monotone if π½ β {N, W}+ (NW-path) or π½ β {N, E}+ (NE-path) or π½ β {S, E}+ (SE-path) or π½ β {S, W}+ (SW-path). A polyomino π is horizontally convex (resp., vertically convex) if any row (resp. column) of π consists of one segment. The class of convex polyominoes contains all polyominoes that are both horizontally and vertically convex. It has been proved [10, Proposition 1] that a polyomino π is convex if and only if any two cells of π are joined by a monotone path in π . The degree of convexity of π , denoted by degπ (π ), is defined as the least integer π such that any two cells of π can be joined by a monotone path in π with at most π changes of direction. A convex polyomino is called π-convex if its degree of convexity is at most π. Given a convex polyomino π and its minimal bounding rectangle π΅, we say that π is a stack (resp., Ferrers diagram, parallelogram, rectangle) if it shares exactly two adjacent (resp., three, two opposite, four) vertices with π΅. A stack π is a left (resp., right) stack if the column with the largest area is the last (resp., first) one. Analogously, in a left (resp., right) Ferrers diagram the largest column is the last (resp., first) one. We denote by L (resp., R) the set of left (resp., right) stacks. FπΏ (resp., Fπ ) is the set of left (resp., right) Ferrers diagrams. Furthermore, we indicate by C (resp., T) the set of parallelograms (resp., rectangles). For a class A of polyominoes, A(π) is the set of polyominoes in A of area π. By low(π) (resp., high(π)) we denote the row index of the bottom (resp., top) cell of column π. Similarly, left(π) denotes the column index of the leftmost cell of row π. Lastly, first(π ) (resp., last(π )) indicates the first (resp., last) column of π . Given two columns π and π, we say that π and π are overlapping (resp., disjoint), denoted by π π (resp., π β π), if and only if β low(π) < low(π) β€ high(π) < high(π) or low(π) < low(π) β€ high(π) < high(π) (resp., low(π) > high(π) or low(π) > high(π)). Moreover, we say that π includes π, denoted by π β π, if and only if low(π) β€ low(π) and high(π) β₯ high(π). Given a convex polyomino π , let π be the rightmost column of π such that π β π for 1 β€ π < π. Then, π is called descending (resp., ascending) if there exists a column π such that π > π, π π and low(π) > low(π) (resp., β low(π) < low(π)). The set of descending (resp., ascending) π-convex polyominoes is indicated by DConvπ (resp., AConvπ ). The set of all descening polyominoes is DConv. If π is neither descending nor ascending then π β T βͺ FπΏ βͺ Fπ βͺ L βͺ R or it belongs to the class LR containing all convex polyominoes that are the concatenation of two polyominoes, π = π1 Β· π2 , where π1 β L βͺ FπΏ , π2 β T βͺ R βͺ Fπ and first(π2 ) β last(π1 ). Notice that any π β LR contains a column Β―π₯ such that π β Β―π₯ for all columns π, hence degπ (π ) β€ 2. Lastly, a cell (π, π) of π is a NW-corner if (π, π β 1) and (π + 1, π) are not cells of π . Analogously, we define NE-corners, SE-corners and SW-corners. Two corners are called opposite if either one is a NW-corner and the other is a SE-corner, or one is a NE-corner and the other is a SW-corner. Clearly, one has Convπ = T βͺ FπΏ βͺ Fπ βͺ L βͺ R βͺ LR βͺ AConvπ βͺ DConvπ and (because of symmetry) |DConvπ (π)| = |AConvπ (π)|, |L(π)| = |R(π)|, |FπΏ (π)| = |Fπ (π)|. Since all unions are disjoint, it follows that |Convπ (π)| = |T(π)| + 2 Β· |FπΏ (π)| + 2 Β· |L(π)| + |LR(π)| + 2 Β· |DConvπ (π)|. (1) Thus, the counting problem for Convπ is reduced to computing |DConvπ (π)| and to some other counting problems that are immediately solved in polynomial time. In particular, we can 0 0 1 1 2 2 2 3 3 3 3 Figure 1: The arrows show the first steps of the paths determined by [9, Lemma 8] and associated with a SW corner. The integer below a column indicates its degree of convexity. compute |LR(π)| in polynomial time as shown in [11]. In order to compute |DConvπ (π)| we define a decomposition for descending polyominoes. Definition 2.1 (standard decomposition). A polyomino π β DConv can be decomposed as π = πΏ Β· πΉ Β· πΆ Β· π (with πΉ , π possibly empty) for suitable polyominoes πΏ β L βͺ T βͺ FπΏ , πΉ β Fπ , πΆ β C βͺ T βͺ Fπ , and π β R βͺ T βͺ Fπ such that: first(πΉ ) β last(πΏ), low(last(πΏ)) = low(first(πΉ )), last(πΉ ) first(πΆ) (or last(πΏ) first(πΆ) if πΉ = π), low(last(πΏ)) > β β low(first(πΆ)) and (if π ΜΈ= π) first(π ) β last(πΆ), low(last(πΆ)) < low(first(π )). We stress that the standard decomposition of π is unique (e.g. last(πΏ) is the rightmost column Β―π₯ of π such that π β Β―π₯ for π < Β―π₯). The subset of DConv2 containing polyominoes decomposed as πΏ Β· πΆ Β· π (resp., πΏ Β· πΆ, πΏ Β· πΉ Β· πΆ Β· π , πΏ Β· πΉ Β· πΆ) is LCR2 (resp., LC2 , LFCR2 , LFC2 ). Thus, for any π > 2 one has the partition DConvπ = LFCRπ βͺ LFCπ βͺ LCRπ βͺ LCπ . By [9, Thm. 6], the degree of convexity of π β DConv depends on the number π of changes of direction in a particular NW-path that starts at a SE-corner π and ends at a NW-corner π. This is a path where the first π β 1 changes of direction always occur on the boundary of π , whereas the πth one possibly occurs on a cell that is not on the boundary. Furthermore, from [9, Thm. 6] it follows that the degree of convexity of the πth column of π is degπ (π, π) = max{π·(π, π)|π = (low(π) , π), π is a NW-corner of π }, where π·(π, π), is the least integer k such that there exists a monotone path in π from π to π with k changes of direction. Given π = πΏ Β· πΉ Β· πΆ Β· π and a column π in πΉ Β· πΆ Β· π , we know from [9, Lemma 8] that degπ (π, π) = min(degπ (π, π β² ) + 2, degπ (π, π β²β² ) + 1), where π β² = left(high(π)) and π β²β² = left(low(π)). see Fig. 1 for an example. In the sequel, we consider each column π of π as the concatenation of vertical segments associated with different degrees of convexity. These segments are identified by considering the degrees of convexity of the leftmost columns that are reached by W-paths starting from cells of π. Definition 2.2 (π½-segment). A cell (π, π) of π β DConv belongs to a π½-segment if and only if either π½ > 0 β§ π < low(first(π )) and the cell (π, left(π)) belongs to a column of degree of convexity π½, or π½ = 0 β§ π β₯ low(first(π )). From [9, Lemma 8], if degπ (π, π) = πΌ then column π may contain only π½-segments with πΌ β 2 β€ π½ β€ πΌ. Notice that (π, π) belongs to a π½-segment if and only if (π, π β 1) belongs to a π½-segment or (π, π β 1) is not in π and degπ (π, π) = π½. Fig. 1 shows how the columns of a polyomino in DConv consist of at most three π½-segments (depicted as vertical segments comprising cells of the same color). Figure 2: A polyomino counted by πΆ(16, 5, 3, 3, 1, 2). 3. Counting We focus on computing |DConvπ (π)| since the remaining values in (1) are easily computed in polynomial time (see, for instance, [11]). Given π, π, π, π₯, π¦, π β N, with π, π > 0 and π₯ + π¦ β€ π, let πΆ(π, π, π, π₯, π¦, π) be the number of polyominoes π in LFCπ (π) βͺ LCπ (π) such that A(last(π )) = π, degπ (π, last(π )) = π, low(last(π ) β 1) β low(last(π )) = π, and where last(π ) contains a π-segment of area π₯, a (π β 1)-segment of area π¦βοΈand a (π β 2)-segment of area πβπ₯βπ¦, see Fig. 2. Obviously, one has |LFCπ (π)|+|LCπ (π)| = π,π,π₯,π¦,π πΆ(π, π, π, π₯, π¦, π), and the problem boils down to compute πΆ(π, π, π, π₯, π¦, π) efficiently. Consider the standard decomposition of a polyomino π counted by πΆ(π, π, π, π₯, π¦, π), π = πΏ Β· πΉ Β· πΆ or π = πΏ Β· πΆ. If the second to last column of π belongs to πΆ then πΆ(π, π, π, π₯, π¦, π) depends on πΆ(π β π, πβ² , π β² , π₯β² , π¦ β² , πβ² ) for suitable πβ² , π β² , π₯β² , π¦ β² , πβ² . Otherwise, the second to last column of π is in πΉ or in πΏ, and πΆ(π, π, π, π₯, π¦, π) is computed using the values πΏ(πβ² , πβ² , π β² , π¦ β² ) and πΉ (πβ² , πβ² , π β² ), where πΏ(πβ² , πβ² , π β² , π¦ β² ) (resp., πΉ (πβ² , πβ² , π β² )) is the number of π β L(πβ² ) βͺ FπΏ (πβ² ) βͺ T(πβ² ) (resp. π β Fπ (πβ² )) such that A(first(π )) = πβ² , A(last(π )) = π β² and low(first(π ))βlow(last(π )) = π¦ β² . Here we consider only the case when column last(π )β 1 is in πΆ (we refer to the full paper for the remaining cases). This is the most complex case as it leads to four different equations, depending on the conditions π₯ > π (1), π₯ = π β§ π¦ = 0 (2), π₯ = π β§ π¦ > 0 β§ π > 0 (3) and π₯ = π β§ π¦ > 0 β§ π = 0 (4). In case (1), column last(π ) β 1 always has degree of convexity π, since the relation π₯ > π implies the existence of a column of degree of convexity π to the left of last(π ), and the sequence of degrees of convexity of columns in πΆ is not decreasing by [9, Thm. 9]. Furthermore, one necessarily has π₯ + π¦ < π because βοΈπβπβ2last(π βοΈπ₯βπ ) contains β²a (π β 2)-segment, see Fig. 3. So, it follows that πΆ(π, π, π, π₯, π¦, π) = πΆ(π β π, π , π, π₯ β π, π¦, π β² ). In case (3) (see Fig. 4) the recurrence equation is β² π =πβπ β² π =0 βοΈπβ² βπ+πβ1 βοΈπ¦ πΆ(π, π, π, π, π¦, π) = πβπβ2 βοΈ β² β² β² βοΈπβπβ2 πβ² =πβπ+1 π¦ β² =πβπβπ¦ πβ² =0 πΆ(π β π, π , π β 1, π¦, π¦ , π ) + πβ² =πβπ πΆ(π β π, π , π, 0, π¦, 0). In fact, the second to last column of a polyomino π counted by πΆ(π, π, π, π, π¦, π) β² may have degree of convexity π β1 or π, but not π β2. Indeed, if one had degπ (π, last(π )β1) = πβ2 then the sequence of degrees of convexity in πΆ would be decreasing, since last(π ) contains a (π β 1)-segment and this implies the existence of a column π to the left of last(π ) such that degπ (π, π) = π β 1. Furthermore, π₯ = π β§ π > 0 implies that last(π ) contains a (π β 2)- segment. As a consequence the (π β 1)-segments in last(π ) β 1 and in last(π ) have the same area. So, if degπ (π, last(π ) β 1) = π β 1 we sum the values πΆ(π β π, πβ² , π β 1, π¦, π¦ β² , πβ² ) on all πβ² , π¦ β² , πβ² such that: Figure 3: Possible configurations when π₯ > π. Figure 4: Possible configurations when π₯ = π and π₯, π¦ > 0. β’ the area πβ² of column last(π ) β 1 is at least π β π + 1 (since πβ² must contain a (π β 3)- segment) and at most π β π β 2 (since A(πΏ) β₯ 2); β’ the area π¦ β² of the (π β 2)-segment in last(π ) β 1 is at least π β π β π¦ (the area of the (π β 2)-segment in last(π )) and at most πβ² β π + π β 1 (because column last(π ) β 1 must contain a (π β 3)-segment); β’ πβ² is at least 0 and at most π¦ (the lower πβ² cells of last(π ) β 1 has degree π β 1 since left(low(last(π ) β 1) + π) = last(π ) β 1 for 0 β€ π < πβ² ). Otherwise, if degπ (π, last(π ) β 1) = π we sum the values πΆ(π β π, πβ² , π, 0, π¦, 0) on all πβ² no smaller than π β π and no greater than π β π β 2. From the existence of a (π β 1)-segment in last(π ) and degπ (π, last(π )β1) = π, it follows low(last(π ) β 2)βlow(last(π ) β 1) = 0. Hence, last(π ) β 1 cannot contain a π-segment. The recurrence equations for cases (2) and (4), as well as for the cases associated with the set LCRπ βͺ LFCRπ , are obtained by a similar reasoning. Based on these equations, we have developed a C++ program to compute |Convπ (π)| for π > 2 and π > 0. This program has space complexity π(π5 ) (coming from the size of the table containing the values πΆ(π, π, π, π₯, π¦, π)) and produced Table 1 in few minutes (on a Macbook Pro). We point out that this integer sequence does not appear in OEIS. References [1] S. W. Golomb, Checker boards and polyominoes, Amer. Math. Monthly 61 (1954) 675β682. [2] E. D. Demaine, J. S. B. Mitchell, J. OβRourke, The open problems project, last update 2020. URL: http://cs.smith.edu/~jorourke/TOPP. Table 1 The number of 3-convex polyominoes of area π for 0 β€ π β€ 40. 0, 1, 2, 6, 19, 59, 172, 470, 1206, 2934, 6812, 15192, 32709, 68282, 138678, 274822, 532719, 1012144 1888226, 3464168, 6258249, 11146013, 19590450, 34011064, 58371083, 99103808, 166563604, 277281796, 457451501, 748274488, 1214117566, 1954879052, 3124637754, 4959621329, 7819943680, 12251575214, 19077932142, 29534613958, 45466767846, 69616951878, 106043316448 [3] M. Bousquet-MΓ©lou, Convex polyominoes and heaps of segments, Journal of Physics A: Mathematical and General 25 (1992) 1925β1934. URL: https://doi.org/10.1088/0305-4470/ 25/7/031. doi:10.1088/0305-4470/25/7/031. [4] E. Barcucci, R. Pinzani, R. Sprugnoli, Directed column-convex polyominoes by recurrence relations, in: M. C. Gaudel, J. P. Jouannaud (Eds.), TAPSOFTβ93: Theory and Practice of Software Development, Springer Berlin Heidelberg, Berlin, Heidelberg, 1993, pp. 282β298. [5] M. Bousquet-MΓ©lou, A method for the enumeration of various classes of column-convex polygons., Discrete Math. 154 (1996) 1β25. [6] A. Del Lungo, M. Nivat, R. Pinzani, S. Rinaldi, A bijection for the total area of parallelogram polyominoes, Discret. Appl. Math. 144 (2004) 291β302. URL: https://doi.org/10.1016/j.dam. 2003.11.007. doi:10.1016/j.dam.2003.11.007. [7] G. Castiglione, A. Restivo, Ordering and convex polyominoes, in: MCU 2004, volume 3354 of Lecture Notes in Comput. Sci., Springer, 2005, pp. 128β139. [8] A. Micheli, D. Rossin, Counting k-convex polyominoes, Electron. J. Comb. 20 (2013). [9] S. Brocchi, G. Castiglione, P. Massazza, On the exhaustive generation of k-convex poly- ominoes, Theor. Comput. Sci. 664 (2017) 54β66. [10] G. Castiglione, A. Restivo, Reconstruction of l-convex polyominoes, Electronic Notes in Dis- crete Mathematics 12 (2003) 290 β 301. URL: http://www.sciencedirect.com/science/article/ pii/S1571065304004949. doi:https://doi.org/10.1016/S1571-0653(04)00494-9, 9th International Workshop on Combinatorial Image Analysis. [11] V. Dorigatti, P. Massazza, On counting l-convex polyominoes, in: 22nd Italian Conference on Theoretical Computer Science, 2021, volume 3072 of CEUR Proceedings, 2021, pp. 193β 198.