Indian Institute of Technology Kharagpur, [email protected] Institute of Technology Kharagpur, [email protected] Indian Institute of Technology Kharagpur, [email protected] \CopyrightAnubhav Dhar, Subham Ghosh, Sudeshna Kolay \ccsdescTheory of computation Computational geometry \relatedversion \hideLIPIcs

Efficient Exact Algorithms for Minimum Covering of Orthogonal Polygons with Squares

Anubhav Dhar    Subham Ghosh    Sudeshna Kolay
Abstract

The Orthogonal Polygon Covering with Squares (OPCS) problem takes as input an orthogonal polygon without holes where vertices have integral coordinates i.e. a polygon P𝑃Pitalic_P without any holes, and with n𝑛nitalic_n vertices and axis-parallel edges. Moreover, each vertex has integer-valued x𝑥xitalic_x- and y𝑦yitalic_y-coordinates. The aim is to find a minimum number of axis-parallel, possibly overlap** squares which lie completely inside P𝑃Pitalic_P, such that their union covers the entire region inside P𝑃Pitalic_P. Aupperle et. al [3] provide an 𝒪(N1.5)𝒪superscript𝑁1.5\mathcal{O}(N^{1.5})caligraphic_O ( italic_N start_POSTSUPERSCRIPT 1.5 end_POSTSUPERSCRIPT )-time algorithm to solve OPCS for orthogonal polygons without holes, where N𝑁Nitalic_N is the number of integral lattice points lying in the interior or on the boundary of P𝑃Pitalic_P. Moreover, designing algorithms for OPCS with a running time polynomial in n𝑛nitalic_n (the number of vertices of P𝑃Pitalic_P) was discussed as an open question in [3], since N𝑁Nitalic_N can be exponentially larger than n𝑛nitalic_n. In this paper we design a polynomial-time exact algorithm for OPCS with a running time of 𝒪(n14)𝒪superscript𝑛14\mathcal{O}(n^{14})caligraphic_O ( italic_n start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ).

We also consider the following structural parameterized version of the problem. A knob in an orthogonal polygon is a polygon edge whose both endpoints are convex polygon vertices. Given an input orthogonal polygon without holes that has n𝑛nitalic_n vertices and k𝑘kitalic_k knobs, we design an algorithm for OPCS with running time 𝒪(n2+k14n)𝒪superscript𝑛2superscript𝑘14𝑛\mathcal{O}(n^{2}+k^{14}\cdot n)caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + italic_k start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ⋅ italic_n ). This algorithm is more efficient than the above exact algorithm when k=o(n13/14)𝑘𝑜superscript𝑛1314k=o(n^{13/14})italic_k = italic_o ( italic_n start_POSTSUPERSCRIPT 13 / 14 end_POSTSUPERSCRIPT ).

In [3], the Orthogonal Polygon with Holes Covering with Squares (OPCSH) problem is also studied. Here, the input is an an orthogonal polygon which could have holes and the objective is to find a minimum square covering of the input polygon. This version where the orthogonal polygon is allowed to have holes is shown to be NP-complete (even when all lattice points in the interior or on the boundary of the polygon constitute the input). We think there is an error in the existing proof in [3], where a reduction from Planar 3-CNF is shown. We fix this error in the proof with an alternate construction of one of the gadgets used in the reduction, hence completing the proof of NP-completeness of OPCSH, when all lattice points in the interior or on the boundary of the polygon are given as input.

keywords:
Orthogonal polygon covering, Square covering, Exact algorithm, NP-hardness
category:

1 Introduction

We consider the problem of covering orthogonal polygons with a minimum number of (possibly overlap**) axis-parallel squares.

An orthogonal polygon is a simple polygon such that every polygon-edge is parallel to either the x-axis or the y-axis (Figure 1(a)). We wish to cover a given orthogonal polygon with a minimum number of (possibly overlap**) axis-parallel squares, i.e. given an orthogonal polygon P𝑃Pitalic_P we wish to find a minimum number of squares such that every square lies inside the region of P𝑃Pitalic_P and the union of the regions of the plane covered by these squares is the region of the plane covered by polygon P𝑃Pitalic_P itself (Figure 1(b) and Figure 1(c)).

Refer to caption
(a) Orthogonal Polygon
Refer to caption
(b) Valid Covering
Refer to caption
(c) Invalid Coverings. Left: A chosen square not contained in polygon (largest square in the diagram). Right: squares not covering entire polygon
Figure 1: Orthogonal Polygons and Covering with Squares

In general, an orthogonal polygon P𝑃Pitalic_P may contain holes. However, for most of the paper, we deal with problems where the input is an orthogonal polygon without any holes. First, we define the problem of Orthogonal Polygon Covering with Squares (OPCS) formally as follows.

Orthogonal Polygon Covering with Squares (OPCS) Input: An orthogonal polygon P𝑃Pitalic_P where its n𝑛nitalic_n vertices have integral coordinates and P𝑃Pitalic_P does not have any holes Question: Find the minimum number of axis-parallel squares contained in P𝑃Pitalic_P, such that P𝑃Pitalic_P is entirely covered by these squares

Note that for this problem, it is possible that the input polygon is given in terms of its n𝑛nitalic_n vertices and their coordinates. Since the polygon is such that all vertices have integral coordinates, it is also possible that the input polygon is given in terms of its boundary vertices as well as all lattice points contained inside P𝑃Pitalic_P. Let this set of lattice points lying on the boundary of P𝑃Pitalic_P or inside P𝑃Pitalic_P be of size N𝑁Nitalic_N. Note that there could be an exponential factor difference between the values of N𝑁Nitalic_N and n𝑛nitalic_n.

We also study a parameterized version of OPCS, called p𝑝pitalic_p-OPCS. Before we define the problem, let us consider a knob as a structure occurring in an orthogonal polygon P𝑃Pitalic_P. A knob is an edge where both endpoints are convex vertices of P𝑃Pitalic_P (the formal definition of knobs is given in Section 2).

p𝑝pitalic_p-Orthogonal Polygon Covering with Squares (p𝑝pitalic_p-OPCS) Parameter: k𝑘kitalic_k Input: An orthogonal polygon P𝑃Pitalic_P where its n𝑛nitalic_n vertices have integral coordinates and P𝑃Pitalic_P does not have any holes, a non-negative integer k𝑘kitalic_k such that P𝑃Pitalic_P has at most k𝑘kitalic_k knobs Question: Find the minimum number of axis-parallel squares contained in P𝑃Pitalic_P, such that P𝑃Pitalic_P is entirely covered by these squares

The parameterized problem of p𝑝pitalic_p-OPCS takes the number of knobs in the input orthogonal polygon to be a structural parameter, to be utilized when designing parameterized algorithms.

The final variant that we consider in this paper is the following variant of OPCS where the input orthogonal polygon is allowed to have holes.

Square Covering of Orthogonal Polygons with Holes (OPCSH) Input: An orthogonal polygon P𝑃Pitalic_P (possibly with holes) where all boundary vertices have integral coordinates Question: Find the minimum number of axis-parallel squares contained in P𝑃Pitalic_P, such that P𝑃Pitalic_P is entirely covered by these squares

Once again, the polygon P𝑃Pitalic_P could be described in terms of its n𝑛nitalic_n boundary vertices, or in terms of the N𝑁Nitalic_N lattice vertices that lie on the boundary of P𝑃Pitalic_P or inside P𝑃Pitalic_P.

Previous Results.

The OPCS problem originates from image processing and further finds its application in VLSI mask generation, incremental update of raster displays, and image compression [9]. Moitra [9] considers the problem of a minimal covering of squares (i.e. no subset of the cover is also a cover) for covering a binary image N×N𝑁𝑁\sqrt{N}\times\sqrt{N}square-root start_ARG italic_N end_ARG × square-root start_ARG italic_N end_ARG pixels; and presents a parallel algorithm running on EREW PRAM which takes time T[logN,N]𝑇𝑁𝑁T\in[\log N,N]italic_T ∈ [ roman_log italic_N , italic_N ] with (N/T)𝑁𝑇(N/T)( italic_N / italic_T ) processors.

In [3], exact polynomial time solutions of OPCS are discussed, where the input is considered to be the set of all N𝑁Nitalic_N lattice points inside (in the interior and the boundary of) P𝑃Pitalic_P. The algorithms crucially use following associated graph G(P)𝐺𝑃G(P)italic_G ( italic_P ).

Definition 1.1 (Associated graph G(P)𝐺𝑃G(P)italic_G ( italic_P )).

A unit square region inside an orthogonal polygon P𝑃Pitalic_P with corners on lattice points is called a block. An associated graph G(P)𝐺𝑃G(P)italic_G ( italic_P ) is constructed with the set of nodes as the set of blocks inside P𝑃Pitalic_P; two blocks p1subscript𝑝1p_{1}italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and p2subscript𝑝2p_{2}italic_p start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT are connected by an undirected edge if there is an axis parallel square lying inside P𝑃Pitalic_P that simultaneously covers p1subscript𝑝1p_{1}italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and p2subscript𝑝2p_{2}italic_p start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT.

Clearly from the definition, we know that any set of blocks covered simultaneously by a single square shall form a clique. Further, [1] shows the converse as well.

Proposition 1.2.

A subset of blocks inside an orthogonal polygon P𝑃Pitalic_P can be covered by a square if and only if they induce a clique in G(P)𝐺𝑃G(P)italic_G ( italic_P ).

In [3], G(P)𝐺𝑃G(P)italic_G ( italic_P ) is shown to be a chordal graph (please refer to Definition 2.13 for the definition of a chordal graph) if P𝑃Pitalic_P does not have holes. In [3] it is further shown that using the polynomial time algorithm for minimum clique covering in chordal graphs (discussed in [7]), OPCS can be solved in polynomial time. If the number of lattice points inside P𝑃Pitalic_P is N𝑁Nitalic_N, then the algorithm takes 𝒪(N2.5)𝒪superscript𝑁2.5\mathcal{O}(N^{2.5})caligraphic_O ( italic_N start_POSTSUPERSCRIPT 2.5 end_POSTSUPERSCRIPT ) time. In [3], there is also references provided that would result in an algorithm with complexity 𝒪(N1.5)𝒪superscript𝑁1.5\mathcal{O}(N^{1.5})caligraphic_O ( italic_N start_POSTSUPERSCRIPT 1.5 end_POSTSUPERSCRIPT ) to solve minimum clique cover in the associated chordal graph G(P)𝐺𝑃G(P)italic_G ( italic_P ) using more structural properties of the orthogonal polygon P𝑃Pitalic_P.

Aupperle et. al [3] also prove that OPCSH is NP-Hard if the input orthogonal polygon P𝑃Pitalic_P with possible holes is described in terms if the N𝑁Nitalic_N lattice points lying on the boundary of P𝑃Pitalic_P as well as inside P𝑃Pitalic_P. The paper reduces Planar 3-CNF [8] to this problem in order to prove its NP-Hardness.

Bar-Yehuda [4] describes an 𝒪(nlogn+OPT)𝒪𝑛𝑛OPT\mathcal{O}(n\log n+\textsc{OPT})caligraphic_O ( italic_n roman_log italic_n + OPT ) 2222-factor approximation algorithm to solve this problem where n𝑛nitalic_n is the number of vertices and OPT is the minimum number of squares to cover P𝑃Pitalic_P.

Culberson and Reckhow [6] proves that the problem of minimum covering of orthogonal polygons with rectangles is NP-hard. Kumar and Ramesh [2] provide a polynomial time approximation algorithm with approximation factor of 𝒪(logN)𝒪𝑁\mathcal{O}(\sqrt{\log N})caligraphic_O ( square-root start_ARG roman_log italic_N end_ARG ) for the problem of covering orthogonal polygons (with or without holes) with rectangles. Most of the other geometric minimum cover problems for orthogonal polygons are NP-complete as well [10].

Our Results.

In the results due to [3], the input size is considered to be the number of lattice points inside P𝑃Pitalic_P or lying on the boundary of P𝑃Pitalic_P. However, it is inefficient to represent orthogonal polygons with all the lattice points inside it. Rather, it would be more efficient to take an orthogonal polygon P𝑃Pitalic_P as a sequence of the boundary vertex points of P𝑃Pitalic_P (in either clockwise or counter-clockwise direction). In case P𝑃Pitalic_P has one or more holes, then this kind of input lists the sequence of vertices on the outer boundary, followed by the sequence of vertices on the boundary of each hole of P𝑃Pitalic_P.

As an example, if P𝑃Pitalic_P is itself a large square with vertices (0,0)00(0,0)( 0 , 0 ), (0,2t)0superscript2𝑡(0,2^{t})( 0 , 2 start_POSTSUPERSCRIPT italic_t end_POSTSUPERSCRIPT ), (2t,0)superscript2𝑡0(2^{t},0)( 2 start_POSTSUPERSCRIPT italic_t end_POSTSUPERSCRIPT , 0 ), (2t,2t)superscript2𝑡superscript2𝑡(2^{t},2^{t})( 2 start_POSTSUPERSCRIPT italic_t end_POSTSUPERSCRIPT , 2 start_POSTSUPERSCRIPT italic_t end_POSTSUPERSCRIPT ), then even though it can be represented by just O(t)𝑂𝑡O(t)italic_O ( italic_t ) bits by simply listing down the vertices in order, we would need Ω(4t)Ωsuperscript4𝑡\Omega(4^{t})roman_Ω ( 4 start_POSTSUPERSCRIPT italic_t end_POSTSUPERSCRIPT ) bits to actually represent all lattice points that lie inside or on the boundary of P𝑃Pitalic_P. Moreover, if OPT is the actual minimum number of squares to completely cover P𝑃Pitalic_P, OPT𝑂𝑃𝑇OPTitalic_O italic_P italic_T can also potentially be exponential in the number of bits needed to represent the vertices (e.g. P𝑃Pitalic_P is a 1×2t1superscript2𝑡1\times 2^{t}1 × 2 start_POSTSUPERSCRIPT italic_t end_POSTSUPERSCRIPT rectangle).

In this paper we consider the input size n𝑛nitalic_n as the number of polygon vertices of P𝑃Pitalic_P and then design efficient algorithms for minimum square covering with respect to n𝑛nitalic_n. Note that the algorithm in [3] becomes exponential now, as there can be exponentially many points inside P𝑃Pitalic_P. Designing algorithms which are polynomial in the number n𝑛nitalic_n of polygon vertices was stated as an open question in [3]. To the best of our knowledge, this is the first study to answer these questions. This algorithm with a running time of 𝒪(n14)𝒪superscript𝑛14\mathcal{O}(n^{14})caligraphic_O ( italic_n start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ), where n𝑛nitalic_n is the number of vertices of the input polygon, and related structural results are given in Section 3 and Section 4. Moreover, our algorithm also works for polygons with rational coordinates as we can simply scale up the polygon by an appropriate denominator without changing the number of vertices n𝑛nitalic_n.

In Section 5, we consider the p𝑝pitalic_p-OPCS problem and further optimize the above algorithm, considering the polygon to have n𝑛nitalic_n vertices and k𝑘kitalic_k knobs (edges with both endpoints subtending 90superscript9090^{\circ}90 start_POSTSUPERSCRIPT ∘ end_POSTSUPERSCRIPT to the interior of the polygon, formally defined in Definition 2.1). We design a recursive algorithm running in time 𝒪(n2+k14n)𝒪superscript𝑛2superscript𝑘14𝑛\mathcal{O}(n^{2}+k^{14}\cdot n)caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + italic_k start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ⋅ italic_n ). This algorithm is more efficient than the above exact algorithm if k=o(n13/14)𝑘𝑜superscript𝑛1314k=o(n^{13/14})italic_k = italic_o ( italic_n start_POSTSUPERSCRIPT 13 / 14 end_POSTSUPERSCRIPT ).

Finally in Section 6, we fix an error in the proof discussed in [3] of NP-completeness of minimum square covering of orthogonal polygons with holes. Note that such a result implies that we do not expect an algorithm for OPCSH that has a running time polynomial in the number n𝑛nitalic_n of boundary vertices of the input orthogonal polygon P𝑃Pitalic_P which may have holes.

All other notations and definitions used in the paper can be found in Section 2.

2 Preliminaries

Orthogonal Polygons.

We denote by P𝑃Pitalic_P our input polygon with n𝑛nitalic_n vertices. In the entire paper, we always consider the vertices of the polygon to have integral coordinates. Unless mentioned otherwise, the polygon P𝑃Pitalic_P is assumed to not have any holes. Let the vertices of P𝑃Pitalic_P in order be v1,v2,,vnsubscript𝑣1subscript𝑣2subscript𝑣𝑛v_{1},v_{2},\ldots,v_{n}italic_v start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT , … , italic_v start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT, where vi=(xi,yi)subscript𝑣𝑖subscript𝑥𝑖subscript𝑦𝑖v_{i}=(x_{i},y_{i})italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_y start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) with xisubscript𝑥𝑖x_{i}italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT and yisubscript𝑦𝑖y_{i}italic_y start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT being integer coordinates. For convenience, we define v0:=vnassignsubscript𝑣0subscript𝑣𝑛v_{0}:=v_{n}italic_v start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT := italic_v start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT and vn+1:=v1assignsubscript𝑣𝑛1subscript𝑣1v_{n+1}:=v_{1}italic_v start_POSTSUBSCRIPT italic_n + 1 end_POSTSUBSCRIPT := italic_v start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT. Therefore (vi,vi+1)subscript𝑣𝑖subscript𝑣𝑖1(v_{i},v_{i+1})( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ) is a polygon edge of P𝑃Pitalic_P for all i{1,2,,n}𝑖12𝑛i\in\{1,2,\ldots,n\}italic_i ∈ { 1 , 2 , … , italic_n }. For any natural number d𝑑ditalic_d, we denote the set {1,2,,d}12𝑑\{1,2,\ldots,d\}{ 1 , 2 , … , italic_d } by the notation [d]delimited-[]𝑑[d][ italic_d ]. Next, let the minimum number of squares required to cover P𝑃Pitalic_P be denoted by OPCS(P)OPCS𝑃\textsc{{OPCS}}(P)OPCS ( italic_P ). We use the terms left, right, top, bottom, vertical, horizontal to indicate greater x-coordinate, smaller x-coordinate, greater y-coordinate, smaller y-coordinate, parallel to y-axis, and parallel to x-axis, respectively. By boundary of a square (rectangle), we mean its four sides. A block lying on the boundary of a square is one which lies inside the square and where the boundary of the block overlaps with the boundary of the square. We assume that arithmetic and logic operations on two numbers take constant time. For any two points a𝑎aitalic_a, b𝑏bitalic_b on the plane, we denote the (Euclidean) length of the line segment joining a𝑎aitalic_a and b𝑏bitalic_b as ab¯¯𝑎𝑏\overline{ab}over¯ start_ARG italic_a italic_b end_ARG.

{observation}

Given an input polygon P𝑃Pitalic_P of OPCS, the minimum number of squares to cover P𝑃Pitalic_P remains the same, even if P𝑃Pitalic_P is scaled up by an integral factor and/or rotated 90superscript9090^{\circ}90 start_POSTSUPERSCRIPT ∘ end_POSTSUPERSCRIPT (clockwise/counter-clockwise).

Let us formally define convex and concave vertices of an orthogonal polygon.

Definition 2.1 (Concave and Convex vertices of P𝑃Pitalic_P).

A vertex visubscript𝑣𝑖v_{i}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT of an orthogonal polygon P𝑃Pitalic_P is a convex vertex if visubscript𝑣𝑖v_{i}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT subtends an angle of 90superscript9090^{\circ}90 start_POSTSUPERSCRIPT ∘ end_POSTSUPERSCRIPT to the interior of P𝑃Pitalic_P. A vertex vjsubscript𝑣𝑗v_{j}italic_v start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT of P𝑃Pitalic_P is a concave vertex if it subtends an angle of 270superscript270270^{\circ}270 start_POSTSUPERSCRIPT ∘ end_POSTSUPERSCRIPT to the interior of P𝑃Pitalic_P(Figure 2).

Refer to caption
Figure 2: Convex vertices: {v1,v2,v3,v5,v6,v8,v10,v12,v13}subscript𝑣1subscript𝑣2subscript𝑣3subscript𝑣5subscript𝑣6subscript𝑣8subscript𝑣10subscript𝑣12subscript𝑣13\{v_{1},v_{2},v_{3},v_{5},v_{6},v_{8},v_{10},v_{12},v_{13}\}{ italic_v start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT 3 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT 5 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT 6 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT 8 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT 10 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT 12 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT 13 end_POSTSUBSCRIPT }, concave vertices: {v4,v7,v9,v11,v14}subscript𝑣4subscript𝑣7subscript𝑣9subscript𝑣11subscript𝑣14\{v_{4},v_{7},v_{9},v_{11},v_{14}\}{ italic_v start_POSTSUBSCRIPT 4 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT 7 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT 9 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT 11 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT 14 end_POSTSUBSCRIPT }

For the OPCS problem, we are only interested in maximal squares that are completely contained in the region of the input polygon.

Definition 2.2 (Valid Square).

An axis parallel square S𝑆Sitalic_S is called a valid covering square of of an orthogonal polygon P𝑃Pitalic_P or simply a valid square if S𝑆Sitalic_S is fully contained in the region of P𝑃Pitalic_P.

Definition 2.3 (Maximal Square).

A valid square S𝑆Sitalic_S is a maximal valid square or simply a maximal square, if no other valid square with a larger area contains S𝑆Sitalic_S entirely(Figure 3).

Refer to caption
(a) Some maximal squares
Refer to caption
(b) Valid squares which are not maximal
Figure 3: Orthogonal Polygons and Covering with Squares

Note that for a given minimum square covering of an input orthogonal polygon P𝑃Pitalic_P, some squares may be maximal squares (Definition 2.2) while the other squares may be valid squares which are not maximal. However, for each such valid square S𝑆Sitalic_S which is not maximal, we can replace it with any maximal square containing S𝑆Sitalic_S (this exists as S𝑆Sitalic_S is not maximal and the interior of P𝑃Pitalic_P is a bounded region with finite area) to obtain another minimum square covering of P𝑃Pitalic_P. Since this process does not change the count of the squares used to cover P𝑃Pitalic_P and since the newly introduced squares cover the entire area of the removed squares, the new covering is a minimum covering with maximal squares. {observation} There exists a minimum square covering of any orthogonal polygon P𝑃Pitalic_P where every square of the covering is a maximal square.

The paper [3] defines a structure called knobs. We define knobs slightly differently but they essentially are the same.

Definition 2.4 (Knob).

A knob in an orthogonal polygon P𝑃Pitalic_P is an edge (vi,vi+1)subscript𝑣𝑖subscript𝑣𝑖1(v_{i},v_{i+1})( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ) of P𝑃Pitalic_P such that visubscript𝑣𝑖v_{i}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT and vi+1subscript𝑣𝑖1v_{i+1}italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT are both convex vertices of P𝑃Pitalic_P (Figure 4(a)). Suppose visubscript𝑣𝑖v_{i}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT and vi+1subscript𝑣𝑖1v_{i+1}italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT share the same x coordinate. Then we say that they form a left knob if (vi,vi+1)subscript𝑣𝑖subscript𝑣𝑖1(v_{i},v_{i+1})( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ) is a left boundary edge (i.e. all points just to the left of the edge are in the exterior of P𝑃Pitalic_P), otherwise they form a right knob. Similarly, when visubscript𝑣𝑖v_{i}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT and vi+1subscript𝑣𝑖1v_{i+1}italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT share the same y coordinate, then we say that they form a top knob if (vi,vi+1)subscript𝑣𝑖subscript𝑣𝑖1(v_{i},v_{i+1})( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ) is a top boundary edge (i.e. all points just to the top of the edge are in the exterior of P𝑃Pitalic_P), otherwise they form a bottom knob.

Next, we define a non-knob convex vertex.

Definition 2.5 (Non-Knob Convex Vertex).

Given an orthogonal polygon P𝑃Pitalic_P, a convex vertex visubscript𝑣𝑖v_{i}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT is said to be a non-knob convex vertex if neither (vi,vi+1)subscript𝑣𝑖subscript𝑣𝑖1(v_{i},v_{i+1})( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ) nor (vi1,vi)subscript𝑣𝑖1subscript𝑣𝑖(v_{i-1},v_{i})( italic_v start_POSTSUBSCRIPT italic_i - 1 end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) is a knob (i.e. both vi1subscript𝑣𝑖1v_{i-1}italic_v start_POSTSUBSCRIPT italic_i - 1 end_POSTSUBSCRIPT and vi+1subscript𝑣𝑖1v_{i+1}italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT are concave vertices).

We further introduce strips as follows.

Definition 2.6 (Strip).

A strip of an orthogonal polygon P𝑃Pitalic_P is a maximal axis-parallel non-square rectangular region Y𝑌Yitalic_Y lying inside P𝑃Pitalic_P such that each side in the longer set of parallel sides of Y𝑌Yitalic_Y is contained entirely in a polygon edge of P𝑃Pitalic_P (Figure 4(b)).

Refer to caption
(a) (vt,vt+1)subscript𝑣𝑡subscript𝑣𝑡1(v_{t},v_{t+1})( italic_v start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_t + 1 end_POSTSUBSCRIPT ) is a top knob, (vl,vl+1)subscript𝑣𝑙subscript𝑣𝑙1(v_{l},v_{l+1})( italic_v start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_l + 1 end_POSTSUBSCRIPT ) is a left knob, (vr,vr+1)subscript𝑣𝑟subscript𝑣𝑟1(v_{r},v_{r+1})( italic_v start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_r + 1 end_POSTSUBSCRIPT ) is a right knob, (vb,vb+1)subscript𝑣𝑏subscript𝑣𝑏1(v_{b},v_{b+1})( italic_v start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_b + 1 end_POSTSUBSCRIPT ) is a bottom knob
Refer to caption
(b) Strip Y𝑌Yitalic_Y of the polygon P𝑃Pitalic_P
Figure 4: Knobs and Strips

We make the following observation

{observation}

Given an orthogonal polygon P𝑃Pitalic_P, for any pair of parallel polygon edges e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT, there can be at most one strip with its longer sides lying inside e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT respectively.

Efficient Representation of Squares.

We introduce the following notations to represent a sequence of squares placed side by side. We start by defining a rec-pack, which is a t×ηt𝑡𝜂𝑡t\times\eta titalic_t × italic_η italic_t or ηt×t𝜂𝑡𝑡\eta t\times titalic_η italic_t × italic_t rectangle lying inside the given orthogonal polygon P𝑃Pitalic_P, where η𝜂\eta\in\mathbb{N}italic_η ∈ blackboard_N.

Definition 2.7 (Rec-pack).

Given an orthogonal polygon P𝑃Pitalic_P, a rec-pack of P𝑃Pitalic_P is an axis parallel rectangle R𝑅Ritalic_R (of dimension t×ηt𝑡𝜂𝑡t\times\eta titalic_t × italic_η italic_t or ηt×t𝜂𝑡𝑡\eta t\times titalic_η italic_t × italic_t) with integer aspect ratio η𝜂\etaitalic_η (i.e. ratio of the lengths of the longer side to its shorter side) that lies completely inside P𝑃Pitalic_P (Figure 5(a)). We define the length t𝑡titalic_t of the shorter side of the rec-pack R𝑅Ritalic_R to be the width of R𝑅Ritalic_R and the aspect ratio η𝜂\etaitalic_η to be the strength of R𝑅Ritalic_R.

Remark 2.8.

A valid square is a rec-pack of strength 1111. We consider any square to be a trivial rec-pack.

For a rec-pack R𝑅Ritalic_R with width t𝑡titalic_t and strength η𝜂\etaitalic_η, it can be covered with exactly η𝜂\etaitalic_η many t×t𝑡𝑡t\times titalic_t × italic_t valid squares. We formally define this operation in the next definition.

Definition 2.9 (Extraction of rec-pack).

Given an orthogonal polygon P𝑃Pitalic_P and a rec-pack R𝑅Ritalic_R of width t𝑡titalic_t and strength η𝜂\etaitalic_η in P𝑃Pitalic_P, we define the extraction of R𝑅Ritalic_R, (R)𝑅\mathcal{E}(R)caligraphic_E ( italic_R ) to be the sequence of η𝜂\etaitalic_η valid squares of size t×t𝑡𝑡t\times titalic_t × italic_t placed side by side to cover the entire region of R𝑅Ritalic_R (Figure 5(b)). Moreover, for a set of rec-packs \mathcal{R}caligraphic_R, we define its extraction ()\mathcal{E}(\mathcal{R})caligraphic_E ( caligraphic_R ) to be the union of the extraction of each rec-pack in \mathcal{R}caligraphic_R.

()=R(R)subscript𝑅𝑅\mathcal{E}(\mathcal{R})=\bigcup\limits_{R\in\mathcal{R}}\mathcal{E}(R)caligraphic_E ( caligraphic_R ) = ⋃ start_POSTSUBSCRIPT italic_R ∈ caligraphic_R end_POSTSUBSCRIPT caligraphic_E ( italic_R )
Refer to caption
(a) Rec-pack R𝑅Ritalic_R with strength 4444
Refer to caption
(b) Extraction (R)𝑅\mathcal{E}(R)caligraphic_E ( italic_R ) of rec-pack R𝑅Ritalic_R
Figure 5: Rec-packs and Extractions
Remark 2.10.

For a square S𝑆Sitalic_S (a trivial rec-pack), the extraction is a singleton set containing S𝑆Sitalic_S itself, i.e. (S)={S}𝑆𝑆\mathcal{E}(S)=\{S\}caligraphic_E ( italic_S ) = { italic_S }. Moreover, for any set 𝒮𝒮\mathcal{S}caligraphic_S of squares, we have (𝒮)=𝒮𝒮𝒮\mathcal{E}(\mathcal{S})=\mathcal{S}caligraphic_E ( caligraphic_S ) = caligraphic_S.

Note that any side-by-side placed sequence of η𝜂\etaitalic_η many t×t𝑡𝑡t\times titalic_t × italic_t valid squares covers up a rec-pack of width t𝑡titalic_t and strength η𝜂\etaitalic_η. Therefore, whenever there is a solution with a side-by-side placed sequence of congruent squares, we can keep track of the rec-pack which gives the set of these congruent squares upon extraction. But first, we need to define a covering using rec-packs.

Definition 2.11.

A set of rec-packs \mathcal{R}caligraphic_R is said to cover the input orthogonal polygon P𝑃Pitalic_P if the set of squares in ()\mathcal{E}(\mathcal{R})caligraphic_E ( caligraphic_R ) cover the polygon P𝑃Pitalic_P. Moreover, we say \mathcal{R}caligraphic_R to be a minimum covering, if ()\mathcal{E}(\mathcal{R})caligraphic_E ( caligraphic_R ) is a minimum cardinality set of squares covering P𝑃Pitalic_P and no two rec-packs R1,R2subscript𝑅1subscript𝑅2R_{1},R_{2}\in\mathcal{R}italic_R start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_R start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ∈ caligraphic_R have (R1)(R2)subscript𝑅1subscript𝑅2\mathcal{E}(R_{1})\cap\mathcal{E}(R_{2})\neq\emptysetcaligraphic_E ( italic_R start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) ∩ caligraphic_E ( italic_R start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) ≠ ∅ (i.e. produce some common square).

Remark 2.12.

For any set 𝒮𝒮\mathcal{S}caligraphic_S of squares covering P𝑃Pitalic_P, 𝒮𝒮\mathcal{S}caligraphic_S is also a set of rec-packs covering P𝑃Pitalic_P. Similarly, for any minimum cardinality set of squares 𝒮𝒮\mathcal{S}caligraphic_S covering P𝑃Pitalic_P, 𝒮𝒮\mathcal{S}caligraphic_S is also a set of rec-packs which is a minimum covering of P𝑃Pitalic_P. Finally, if a set of rec-packs \mathcal{R}caligraphic_R is a covering (minimum covering) of P𝑃Pitalic_P, then the set of squares ()\mathcal{E}(\mathcal{R})caligraphic_E ( caligraphic_R ) is a set of trivial rec-packs which is also a covering (minimum covering).

We also state the following observation.

{observation}

A set of rec-packs \mathcal{R}caligraphic_R covers an orthogonal polygon P𝑃Pitalic_P if and only if all the rec-packs in P𝑃Pitalic_P together form a set of rectangles covering P𝑃Pitalic_P.

Graph Theory.

Given a graph G𝐺Gitalic_G, we denote the vertex set by V(G)𝑉𝐺V(G)italic_V ( italic_G ) and the edge set by E(G)𝐸𝐺E(G)italic_E ( italic_G ). The neighbourhood of a vertex vV(G)𝑣𝑉𝐺v\in V(G)italic_v ∈ italic_V ( italic_G ) is denoted by N(v)𝑁𝑣N(v)italic_N ( italic_v ). The closed neighbourhood of v𝑣vitalic_v is denoted by N[v]𝑁delimited-[]𝑣N[v]italic_N [ italic_v ]. Given a graph G𝐺Gitalic_G, a subgraph H𝐻Hitalic_H is an induced subgraph of G𝐺Gitalic_G if V(H)V(G)𝑉𝐻𝑉𝐺V(H)\subseteq V(G)italic_V ( italic_H ) ⊆ italic_V ( italic_G ) and E(H)𝐸𝐻E(H)italic_E ( italic_H ) contains all edges of E(G)𝐸𝐺E(G)italic_E ( italic_G ) such that both endpoints are in V(H)𝑉𝐻V(H)italic_V ( italic_H ). In this case, we also say that the vertex set V(H)𝑉𝐻V(H)italic_V ( italic_H ) induces the subgraph H𝐻Hitalic_H. Recall the definition of chordal graphs and simplicial nodes [5].

Definition 2.13 (Chordal graphs and simplicial nodes).

A chordal graph G𝐺Gitalic_G is a simple graph in which every cycle of length at least four has a chord. A node vV(G)𝑣𝑉𝐺v\in V(G)italic_v ∈ italic_V ( italic_G ) is simplicial if N[v]𝑁delimited-[]𝑣N[v]italic_N [ italic_v ] induces a complete graph.

We get the following result directly from the definition.

Proposition 2.14.

Any induced subgraph of a chordal graph is also chordal.

We now state Dirac’s Lemma on chordal graphs [5].

Proposition 2.15 (Dirac’s Lemma).

Every chordal graph has a simplicial node. Morever, if a chordal graph is not a complete graph, it has at least two non-adjacent simplicial nodes.

We finally reiterate one of the major results of [3].

Proposition 2.16.

For a simple orthogonal polygon P𝑃Pitalic_P (without holes), the associated graph G(P)𝐺𝑃G(P)italic_G ( italic_P ) is chordal.

3 Structural and Geometric Results

In this section, we prove some structural and geometric results of a minimum square covering of an orthogonal polygon P𝑃Pitalic_P, as well as a set of rec-packs which is a minimum covering of P𝑃Pitalic_P.

3.1 Structure of Minimum Coverings

Due to Figure 3 we assume that we are looking for a minimum covering where every square is a maximal square. First, let us define how a maximal square can be obtained from a convex vertex of the given orthogonal polygon P𝑃Pitalic_P.

Definition 3.1.

Given an orthogonal polygon P𝑃Pitalic_P and a point v𝑣vitalic_v, the following process is called growing of a square with one corner fixed at v𝑣vitalic_v:

  • start with S1subscript𝑆1S_{1}italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT being the 1×1111\times 11 × 1 valid square covering v𝑣vitalic_v (and has v𝑣vitalic_v as one of its corners).

  • for t𝑡titalic_t in 2,3,232,3,\ldots2 , 3 , …, from St1subscript𝑆𝑡1S_{t-1}italic_S start_POSTSUBSCRIPT italic_t - 1 end_POSTSUBSCRIPT, which is a (t1)×(t1)𝑡1𝑡1(t-1)\times(t-1)( italic_t - 1 ) × ( italic_t - 1 ) square with v𝑣vitalic_v as one of its corners, construct T𝑇Titalic_T to be a t×t𝑡𝑡t\times titalic_t × italic_t square by kee** one of its vertex fixed at v𝑣vitalic_v and changing both the x𝑥xitalic_x- and y𝑦yitalic_y-coordinates of the diagonally opposite vertex in St1subscript𝑆𝑡1S_{t-1}italic_S start_POSTSUBSCRIPT italic_t - 1 end_POSTSUBSCRIPT by 1111 to obtain the corresponding diagonally opposite vertex in T𝑇Titalic_T. If T𝑇Titalic_T is a valid square, set StTsubscript𝑆𝑡𝑇S_{t}\leftarrow Titalic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT ← italic_T; else terminate the process and set S=St1𝑆subscript𝑆𝑡1S=S_{t-1}italic_S = italic_S start_POSTSUBSCRIPT italic_t - 1 end_POSTSUBSCRIPT.

S𝑆Sitalic_S is said to be the square grown from the point v𝑣vitalic_v.

We now discuss the following result.

Lemma 3.2.

Given an orthogonal polygon P𝑃Pitalic_P, the maximal square covering a convex vertex is unique. Further, for a given convex vertex v𝑣vitalic_v, the unique maximal square can be found in 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ).

Proof 3.3.

Given a convex vertex v𝑣vitalic_v in an orthogonal polygon P𝑃Pitalic_P, let S𝑆Sitalic_S be the vertex grown from v𝑣vitalic_v. As all other squares covering v𝑣vitalic_v strictly lie inside S𝑆Sitalic_S, S𝑆Sitalic_S must be the unique maximal square covering v𝑣vitalic_v.

Let \mathcal{R}caligraphic_R denote the region defined by the interior of the 90superscript9090^{\circ}90 start_POSTSUPERSCRIPT ∘ end_POSTSUPERSCRIPT angle between the rays formed by extending the two edges adjacent to v𝑣vitalic_v (i.e. a quadrant). To find S𝑆Sitalic_S in 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) time, we can iterate over all polygon edges (vi,vi+1)subscript𝑣𝑖subscript𝑣𝑖1(v_{i},v_{i+1})( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ), and check the following:

  • if (vi,vi+1)subscript𝑣𝑖subscript𝑣𝑖1(v_{i},v_{i+1})( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ) lies entirely outside \mathcal{R}caligraphic_R, it can never constrain the maximal square covering v𝑣vitalic_v, so we continue to the next iteration

  • if some portion of (vi,vi+1)subscript𝑣𝑖subscript𝑣𝑖1(v_{i},v_{i+1})( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ) lies inside \mathcal{R}caligraphic_R, then find in 𝒪(1)𝒪1\mathcal{O}(1)caligraphic_O ( 1 ), the largest square in \mathcal{R}caligraphic_R, with one vertex at v𝑣vitalic_v and the strict interior of the square does not contain any portion of (vi,vi+1)subscript𝑣𝑖subscript𝑣𝑖1(v_{i},v_{i+1})( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ). This can be done in 𝒪(1)𝒪1\mathcal{O}(1)caligraphic_O ( 1 ), just by comparing the coordinates of visubscript𝑣𝑖v_{i}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT, vi+1subscript𝑣𝑖1v_{i+1}italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT and v𝑣vitalic_v.

Finally, the square with the minimum area is the unique maximal square covering v𝑣vitalic_v, as all other edges allow larger (or equally large) squares.

We now define a maximal corner square of a vertex as follows.

Definition 3.4 (Maximal Corner Square of a vertex).

The Maximal Corner Square of a convex vertex v𝑣vitalic_v, or MCS(v)𝑀𝐶𝑆𝑣MCS(v)italic_M italic_C italic_S ( italic_v ) is the unique maximal square covering v𝑣vitalic_v.

Remark 3.5.

Due to Proposition 3 and Lemma 3.2, there is a minimum square covering of an orthogonal polygon P𝑃Pitalic_P such that for each of the convex vertices v𝑣vitalic_v, MCS(v)𝑀𝐶𝑆𝑣MCS(v)italic_M italic_C italic_S ( italic_v ) is one of the squares in the minimum covering.

Note that any maximal square should be bounded by either two vertical polygon edges or two horizontal polygon edges.

Lemma 3.6.

If S𝑆Sitalic_S is a maximal square of an orthogonal polygon P𝑃Pitalic_P, then either both the vertical sides of S𝑆Sitalic_S overlap fully or partially with some polygon edges in P𝑃Pitalic_P or both the horizontal sides of S𝑆Sitalic_S overlap fully or partially with some polygon edges of P𝑃Pitalic_P.

Proof 3.7.

Assume the contrary. Suppose for some maximal square S𝑆Sitalic_S there is one horizontal edge and one vertical edge which does not overlap fully or partially with any polygon edges of P𝑃Pitalic_P. Further, we can assume that these are the top and the right edges of S𝑆Sitalic_S (we can rotate P𝑃Pitalic_P along with S𝑆Sitalic_S appropriately if this is not the case). Then we can further grow S𝑆Sitalic_S fixing its bottom-left corner, which contradicts that S𝑆Sitalic_S is a maximal square.

3.2 Simplicial Nodes in the Associated Graph and Partial Solutions

We define a partial solution for OPCS to be a subset of a set of rec-packs which is a minimum covering of P𝑃Pitalic_P.

Definition 3.8 (Partial Solution).

Given an orthogonal polygon P𝑃Pitalic_P, a set of rec-packs \mathcal{R}caligraphic_R is a partial solution for OPCS if there is a minimum covering set of rec-packs superscript\mathcal{R}^{\prime}caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT with superscript\mathcal{R}\subseteq\mathcal{R}^{\prime}caligraphic_R ⊆ caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT.

Now consider a partial solution \mathcal{R}caligraphic_R. We define G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) as follows.

Definition 3.9.

Let G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) denote the induced subgraph of the associated graph 𝒢(P)𝒢𝑃\mathcal{G}(P)caligraphic_G ( italic_P ) consisting of nodes which correspond to blocks in P𝑃Pitalic_P which are not covered by any rec-pack in \mathcal{R}caligraphic_R.

From Proposition 2.16 and Proposition 2.14, we get that G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) is chordal, and from Proposition 2.15 we get that G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) has a simplicial node p𝑝pitalic_p if G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) is non-empty. Let A𝐴Aitalic_A denote the union of the block p𝑝pitalic_p and its neighbouring blocks in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ). By Definition 2.13, A𝐴Aitalic_A induces a clique in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) and hence in G(P)𝐺𝑃G(P)italic_G ( italic_P ). Therefore, by Proposition 1.2, there exists a maximal square SAsubscript𝑆𝐴S_{A}italic_S start_POSTSUBSCRIPT italic_A end_POSTSUBSCRIPT that covers all blocks in A𝐴Aitalic_A. Next, we define unambiguous squares given a partial solution \mathcal{R}caligraphic_R.

Definition 3.10 (Unambiguous squares given a partial solution).

Let \mathcal{R}caligraphic_R be a partial solution for OPCS in an orthogonal polygon P𝑃Pitalic_P. We call a maximal square S𝑆Sitalic_S to be an unambiguous square given \mathcal{R}caligraphic_R, if there is simplicial node p𝑝pitalic_p in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) such that S𝑆Sitalic_S covers p𝑝pitalic_p and all its neighbours in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ).

Remark 3.11.

For a given simplicial node p𝑝pitalic_p in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ), there can be multiple maximal squares that cover p𝑝pitalic_p and all its neighbours in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ).

We now justify the naming of unambiguous squares.

Lemma 3.12.

If \mathcal{R}caligraphic_R is a partial solution for OPCS in an orthogonal polygon P𝑃Pitalic_P and S𝑆Sitalic_S is an unambiguous square given \mathcal{R}caligraphic_R, then {S}𝑆\mathcal{R}\cup\{S\}caligraphic_R ∪ { italic_S } is also a partial solution.

Proof 3.13.

Let p𝑝pitalic_p be a simplicial node in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) such that S𝑆Sitalic_S covers p𝑝pitalic_p and its neighbours in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ). Since \mathcal{R}caligraphic_R is a partial solution, there exists a minimum cover superscript\mathcal{R}^{\prime}caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT covering P𝑃Pitalic_P with superscript\mathcal{R}\subseteq\mathcal{R}^{\prime}caligraphic_R ⊆ caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT. This implies ()()superscript\mathcal{E}(\mathcal{R})\subseteq\mathcal{E}(\mathcal{R}^{\prime})caligraphic_E ( caligraphic_R ) ⊆ caligraphic_E ( caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) from Definition 2.9. Let S()superscript𝑆superscriptS^{\prime}\in\mathcal{E}(\mathcal{R}^{\prime})italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ∈ caligraphic_E ( caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) be a maximal square covering p𝑝pitalic_p. We have S()superscript𝑆S^{\prime}\notin\mathcal{E}(\mathcal{R})italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ∉ caligraphic_E ( caligraphic_R ) as p𝑝pitalic_p is in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ). This implies that ()(){S}superscriptsuperscript𝑆\mathcal{E}(\mathcal{R})\subseteq\mathcal{E}(\mathcal{R}^{\prime})\setminus\{S% ^{\prime}\}caligraphic_E ( caligraphic_R ) ⊆ caligraphic_E ( caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) ∖ { italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT }. However, since Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT covers an induced clique of G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) including p𝑝pitalic_p (Proposition 1.2) and possibly some blocks already covered by squares in ()\mathcal{E}(\mathcal{R})caligraphic_E ( caligraphic_R ), this means that Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT covers p𝑝pitalic_p and a subset of its neighbours in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) along with some blocks already covered by squares in ()\mathcal{E}(\mathcal{R})caligraphic_E ( caligraphic_R ). On the other hand, recall that S𝑆Sitalic_S covers p𝑝pitalic_p and all its neighbours in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ). This means (){S}superscript𝑆\mathcal{E}(\mathcal{R})\cup\{S^{\prime}\}caligraphic_E ( caligraphic_R ) ∪ { italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT } covers a subset of points covered by (){S}𝑆\mathcal{E}(\mathcal{R})\cup\{S\}caligraphic_E ( caligraphic_R ) ∪ { italic_S }. This means ((){S}){S}superscriptsuperscript𝑆𝑆(\mathcal{E}(\mathcal{R}^{\prime})\setminus\{S^{\prime}\})\cup\{S\}( caligraphic_E ( caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) ∖ { italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT } ) ∪ { italic_S } is also a minimum cardinality set of squares covering the entire polygon P𝑃Pitalic_P. Let 𝒵=((){S}){S}𝒵superscriptsuperscript𝑆𝑆\mathcal{Z}=(\mathcal{E}(\mathcal{R}^{\prime})\setminus\{S^{\prime}\})\cup\{S\}caligraphic_Z = ( caligraphic_E ( caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) ∖ { italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT } ) ∪ { italic_S }.

We rewrite 𝒵=((){S}){S}=(()𝒯){S}𝒵superscriptsuperscript𝑆𝑆𝒯𝑆\mathcal{Z}=(\mathcal{E}(\mathcal{R}^{\prime})\setminus\{S^{\prime}\})\cup\{S% \}=(\mathcal{E}(\mathcal{R})\cup\mathcal{T})\cup\{S\}caligraphic_Z = ( caligraphic_E ( caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) ∖ { italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT } ) ∪ { italic_S } = ( caligraphic_E ( caligraphic_R ) ∪ caligraphic_T ) ∪ { italic_S }, where 𝒯=((){S})()𝒯superscriptsuperscript𝑆\mathcal{T}=(\mathcal{E}(\mathcal{R}^{\prime})\setminus\{S^{\prime}\})% \setminus\mathcal{E}(\mathcal{R})caligraphic_T = ( caligraphic_E ( caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) ∖ { italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT } ) ∖ caligraphic_E ( caligraphic_R ). Consider 𝒵1=𝒯{S}subscript𝒵1𝒯𝑆\mathcal{Z}_{1}=\mathcal{R}\cup\mathcal{T}\cup\{S\}caligraphic_Z start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT = caligraphic_R ∪ caligraphic_T ∪ { italic_S } to be a set of rec-packs (where 𝒯𝒯\mathcal{T}caligraphic_T and {S}𝑆\{S\}{ italic_S } are considered to be sets of trivial rec-packs). Since (𝒵1)=(𝒯{S})=()𝒯{S}=𝒵subscript𝒵1𝒯𝑆𝒯𝑆𝒵\mathcal{E}(\mathcal{Z}_{1})=\mathcal{E}(\mathcal{R}\cup\mathcal{T}\cup\{S\})=% \mathcal{E}(\mathcal{R})\cup\mathcal{T}\cup\{S\}=\mathcal{Z}caligraphic_E ( caligraphic_Z start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) = caligraphic_E ( caligraphic_R ∪ caligraphic_T ∪ { italic_S } ) = caligraphic_E ( caligraphic_R ) ∪ caligraphic_T ∪ { italic_S } = caligraphic_Z is a minimum cardinality set of squares covering P𝑃Pitalic_P, 𝒵1subscript𝒵1\mathcal{Z}_{1}caligraphic_Z start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT is a minimum covering. Moreover, as {S}𝒵1𝑆subscript𝒵1\mathcal{R}\cup\{S\}\subseteq\mathcal{Z}_{1}caligraphic_R ∪ { italic_S } ⊆ caligraphic_Z start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, {S}𝑆\mathcal{R}\cup\{S\}caligraphic_R ∪ { italic_S } is a partial solution. Hence, we are done.

Now, we prove that we can always find an unambiguous square which follows a particular structure.

Lemma 3.14.

Let \mathcal{R}caligraphic_R be a partial solution of OPCS in an orthogonal polygon P𝑃Pitalic_P such that ()\mathcal{E}(\mathcal{R})caligraphic_E ( caligraphic_R ) does not completely cover P𝑃Pitalic_P. We define Cxsubscript𝐶𝑥C_{x}italic_C start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT and Cysubscript𝐶𝑦C_{y}italic_C start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT as a set of lattice points as follows.

Cx:={\displaystyle C_{x}:=\{italic_C start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT := { (x,y)2|x is an x-coordinate of a vertex of P,𝑥𝑦conditionalsuperscript2𝑥 is an x-coordinate of a vertex of 𝑃\displaystyle(x,y)\in\mathbb{Z}^{2}|x\text{ is an x-coordinate of a vertex of % }P,( italic_x , italic_y ) ∈ blackboard_Z start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT | italic_x is an x-coordinate of a vertex of italic_P ,
y is a y-coordinate of a vertex of P or a corner of a rec-pack in }\displaystyle y\text{ is a y-coordinate of a vertex of }P\text{ or a corner of% a rec-pack in }\mathcal{R}\}italic_y is a y-coordinate of a vertex of italic_P or a corner of a rec-pack in caligraphic_R }
Cy:={\displaystyle C_{y}:=\{italic_C start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT := { (x,y)2|x is an x-coordinate of a vertex of P or a corner of a rec-pack in ,𝑥𝑦conditionalsuperscript2𝑥 is an x-coordinate of a vertex of 𝑃 or a corner of a rec-pack in \displaystyle(x,y)\in\mathbb{Z}^{2}|x\text{ is an x-coordinate of a vertex of % }P\text{ or a corner of a rec-pack in }\mathcal{R},( italic_x , italic_y ) ∈ blackboard_Z start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT | italic_x is an x-coordinate of a vertex of italic_P or a corner of a rec-pack in caligraphic_R ,
y is a y-coordinate of a vertex of P}\displaystyle y\text{ is a y-coordinate of a vertex of }P\}italic_y is a y-coordinate of a vertex of italic_P }

Then there exists an unambiguous square S𝑆Sitalic_S given \mathcal{R}caligraphic_R which has one corner in CxCysubscript𝐶𝑥subscript𝐶𝑦C_{x}\cup C_{y}italic_C start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT ∪ italic_C start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT.

Proof 3.15.

Let p𝑝pitalic_p be a simplicial node in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) with the largest number of neighbours, and such that among the topmost such simplicial nodes it is the leftmost. Let A𝐴Aitalic_A denote the following set of nodes (blocks in P𝑃Pitalic_P): p𝑝pitalic_p and its neighbours in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ). Let S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT be a maximal square that covers all blocks in A𝐴Aitalic_A, such that the position of the top-left corner of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT is leftmost among the topmost of all such squares covering A𝐴Aitalic_A. By Lemma 3.6, we know that either the horizontal sides of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT overlaps (completely or partially) with two horizontal polygon edges, or the vertical sides of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT overlaps (completely or partially) with two vertical polygon edges.

Assume that the horizontal sides of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT overlaps (completely or partially) with two horizontal polygon edges. We consider two cases.

Case-I: S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT is a 1×1111\times 11 × 1 square.

Since p𝑝pitalic_p is a simplicial node with the largest number of neighbours in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ), all simplicial nodes (in fact all nodes) in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) must be isolated. Further, p𝑝pitalic_p is the leftmost among the topmost such simplicial nodes. This means that the immediate left block psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT of p𝑝pitalic_p is either covered by a rec-pack in \mathcal{R}caligraphic_R or is outside the polygon. Therefore, the left side of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT is either a polygon edge (if p𝑝pitalic_p is in the polygon but psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT is not) or a vertical side of some rec-pack in \mathcal{R}caligraphic_R (if p𝑝pitalic_p is uncovered, but psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT is covered), respectively. Therefore, the top-left corner of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT must share the x-coordinate of either a corner of a rec-pack in \mathcal{R}caligraphic_R or a polygon vertex. Further, the top-left corner of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT shares a y-coordinate of a polygon vertex as the horizontal sides (top and bottom) of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT overlap with polygon edges. This means that the top-left vertex of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT is in Cysubscript𝐶𝑦C_{y}italic_C start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT

Case-II: S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT is not a 1×1111\times 11 × 1 square.

We already know that the horizontal sides (top and bottom) of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT overlap with polygon edges. If the left (or right) side of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT shares x-coordinate of some polygon edge or a corner of some rec-pack in \mathcal{R}caligraphic_R, then the top-left (or top-right) corner of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT is in Cysubscript𝐶𝑦C_{y}italic_C start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT; and then we are done.

Now, we assume the contrary. Suppose neither the left or right sides of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT share an x-coordinate with a polygon edge or a corner of some rec-pack in \mathcal{R}caligraphic_R. In particular, if Slsubscript𝑆𝑙S_{l}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT and Srsubscript𝑆𝑟S_{r}italic_S start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT are squares congruent to S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT but are shifted one unit to the left and right respectively, then Slsubscript𝑆𝑙S_{l}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT and Srsubscript𝑆𝑟S_{r}italic_S start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT are maximal valid squares (Figure 6(a)). They are valid as the left and right sides of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT do not overlap with any polygon edge. They are also maximal as the same polygon edges overlap** horizontal sides of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT also overlap the horizontal sides of Slsubscript𝑆𝑙S_{l}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT and Srsubscript𝑆𝑟S_{r}italic_S start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT (this would not be the case if the horizontal polygon edges only overlap horizontal sides of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT at just a point — i.e. a corner of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT overlaps with a vertex of P𝑃Pitalic_P; but then the vertical side of that corner of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT would share the x-coordinate of the vertex of P𝑃Pitalic_P, contradicting our assumption). We further consider three more subcases.

  • Case II(a): All blocks in S0subscriptS0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT along its right boundary are also covered by some rec-pack in \mathcal{R}caligraphic_R. This case is impossible as Slsubscript𝑆𝑙S_{l}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT covers the same set of uncovered blocks but has a top-left corner which lies even to the left of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT contradicting the definition of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT.

  • Case II(b): All blocks in S0subscriptS0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT along its left boundary are also covered by some rec-pack in \mathcal{R}caligraphic_R. We keep moving S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT horizontally to the right till one of the following happens:

    • (i) it is obstructed by a polygon edge to its right (then the right side would share x-coordinate of a polygon edge)

    • (ii) moving it any further uncovers some previously covered portion (then the left side would be overlap** with the right side of some rec-pack in \mathcal{R}caligraphic_R, hence sharing the x-coordinate of a corner of some rec-pack in \mathcal{R}caligraphic_R)

    • (iii) it is about to be no longer overlap** with the horizontal polygon edges of P𝑃Pitalic_P which overlapped horizontal sides of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT (then there would be a corner of the square that overlaps with the endpoint of the horizontal polygon edge which was about to lose overlap and hence they share the x-coordinate)

    Since the horizontal sides (top and bottom) of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT overlap with polygon edges, in each of the above cases there is a corner of the newly moved square which lies in 𝒞ysubscript𝒞𝑦\mathcal{C}_{y}caligraphic_C start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT.

    Refer to caption
    (a) Construction of Sl,Srsubscript𝑆𝑙subscript𝑆𝑟S_{l},S_{r}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT , italic_S start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT given S,P𝑆𝑃S,Pitalic_S , italic_P
    Refer to caption
    (b) Blocks pl,pll,pr,prrsubscript𝑝𝑙subscript𝑝𝑙𝑙subscript𝑝𝑟subscript𝑝𝑟𝑟p_{l},p_{ll},p_{r},p_{rr}italic_p start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT , italic_p start_POSTSUBSCRIPT italic_l italic_l end_POSTSUBSCRIPT , italic_p start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT , italic_p start_POSTSUBSCRIPT italic_r italic_r end_POSTSUBSCRIPT given S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT and rec-packs in \mathcal{R}caligraphic_R
    Figure 6: Cases in proof of Lemma 3.14
  • Case II(c): There is a block plsubscriptplp_{l}italic_p start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT in S0subscriptS0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT along its left boundary and a block prsubscriptprp_{r}italic_p start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT in S0subscriptS0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT along its right that are both not covered by any rec-pack in \mathcal{R}caligraphic_R (Figure 6(b)). Let pllsubscript𝑝𝑙𝑙p_{ll}italic_p start_POSTSUBSCRIPT italic_l italic_l end_POSTSUBSCRIPT be the block immediately to the left of plsubscript𝑝𝑙p_{l}italic_p start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT and prrsubscript𝑝𝑟𝑟p_{rr}italic_p start_POSTSUBSCRIPT italic_r italic_r end_POSTSUBSCRIPT be the block immediately to the right of prsubscript𝑝𝑟p_{r}italic_p start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT. The blocks pllsubscript𝑝𝑙𝑙p_{ll}italic_p start_POSTSUBSCRIPT italic_l italic_l end_POSTSUBSCRIPT and prrsubscript𝑝𝑟𝑟p_{rr}italic_p start_POSTSUBSCRIPT italic_r italic_r end_POSTSUBSCRIPT must be uncovered blocks lying inside P𝑃Pitalic_P (as we assumed the vertical sides of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT to not overlap with the vertical sides of any rec-pack in \mathcal{R}caligraphic_R or any vertical polygon edges). Clearly Slsubscript𝑆𝑙S_{l}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT covers pllsubscript𝑝𝑙𝑙p_{ll}italic_p start_POSTSUBSCRIPT italic_l italic_l end_POSTSUBSCRIPT and Srsubscript𝑆𝑟S_{r}italic_S start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT covers prrsubscript𝑝𝑟𝑟p_{rr}italic_p start_POSTSUBSCRIPT italic_r italic_r end_POSTSUBSCRIPT. However if p𝑝pitalic_p is not on the left boundary of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT, then p𝑝pitalic_p is covered by Srsubscript𝑆𝑟S_{r}italic_S start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT (which also covers prrsubscript𝑝𝑟𝑟p_{rr}italic_p start_POSTSUBSCRIPT italic_r italic_r end_POSTSUBSCRIPT). This implies that p𝑝pitalic_p and prrsubscript𝑝𝑟𝑟p_{rr}italic_p start_POSTSUBSCRIPT italic_r italic_r end_POSTSUBSCRIPT are adjacent in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ). Otherwise, if p𝑝pitalic_p is on the left boundary of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT, p𝑝pitalic_p cannot be on the right boundary of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT (as S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT is not a unit square). This implies that p𝑝pitalic_p is covered by Slsubscript𝑆𝑙S_{l}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT (which also covers pllsubscript𝑝𝑙𝑙p_{ll}italic_p start_POSTSUBSCRIPT italic_l italic_l end_POSTSUBSCRIPT) and this means that p𝑝pitalic_p and pllsubscript𝑝𝑙𝑙p_{ll}italic_p start_POSTSUBSCRIPT italic_l italic_l end_POSTSUBSCRIPT are adjacent in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ). Therefore in either case there is some node psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT which is not covered by S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT but adjacent to p𝑝pitalic_p in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ). This contradicts the definition of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT and therefore such a case does not arise.

This completes the proof that there is a maximal square S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT with one corner in Cysubscript𝐶𝑦C_{y}italic_C start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT which covers p𝑝pitalic_p and all its neighbours in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) (hence an unambiguous square given \mathcal{R}caligraphic_R), provided that horizontal sides of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT overlap with some horizontal polygon edges. Moreover, if vertical sides of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT overlap with vertical polygon edges, then a similar argument implies the existence of an unambiguous square which has a corner in Cxsubscript𝐶𝑥C_{x}italic_C start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT. This completes the proof.

We now state another result which helps us detect unambiguous squares later on.

Lemma 3.16.

Given an orthogonal polygon P𝑃Pitalic_P, let \mathcal{R}caligraphic_R be a partial solution of OPCS where ()\mathcal{E}(\mathcal{R})caligraphic_E ( caligraphic_R ) does not completely cover P𝑃Pitalic_P. Let S𝑆Sitalic_S be any valid square. We define Dxsubscript𝐷𝑥D_{x}italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT and Dysubscript𝐷𝑦D_{y}italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT as a set of lattice points as follows.

Dxsubscript𝐷𝑥\displaystyle D_{x}italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT :={(x,y)2|x which is an x-coordinate of a vertex of P or a corner of a\displaystyle:=\{(x,y)\in\mathbb{Z}^{2}|\exists x^{\prime}\text{ which is an x% -coordinate of a vertex of }P\text{ or a corner of a}:= { ( italic_x , italic_y ) ∈ blackboard_Z start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT | ∃ italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT which is an x-coordinate of a vertex of italic_P or a corner of a
rec-pack in {S} such that |xx|1,y is the y-coordinate of a vertex in P}\displaystyle\text{ rec-pack in }\mathcal{R}\cup\{S\}\text{ such that }|x-x^{% \prime}|\leq 1,y\text{ is the y-coordinate of a vertex in }P\}rec-pack in caligraphic_R ∪ { italic_S } such that | italic_x - italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | ≤ 1 , italic_y is the y-coordinate of a vertex in italic_P }
Dysubscript𝐷𝑦\displaystyle D_{y}italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT :={(x,y)2|y which is a y-coordinate of a vertex of P or a corner of a\displaystyle:=\{(x,y)\in\mathbb{Z}^{2}|\exists y^{\prime}\text{ which is a y-% coordinate of a vertex of }P\text{ or a corner of a}:= { ( italic_x , italic_y ) ∈ blackboard_Z start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT | ∃ italic_y start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT which is a y-coordinate of a vertex of italic_P or a corner of a
rec-pack in {S} such that |yy|1,x is the x-coordinate of a vertex in P}\displaystyle\text{ rec-pack in }\mathcal{R}\cup\{S\}\text{ such that }|y-y^{% \prime}|\leq 1,x\text{ is the x-coordinate of a vertex in }P\}rec-pack in caligraphic_R ∪ { italic_S } such that | italic_y - italic_y start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | ≤ 1 , italic_x is the x-coordinate of a vertex in italic_P }

Let p𝑝pitalic_p be a node in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) where pS𝑝𝑆p\in Sitalic_p ∈ italic_S and p𝑝pitalic_p has a neighbour p1Ssubscript𝑝1𝑆p_{1}\notin Sitalic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ∉ italic_S in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ). Then there is a neighbour pSsuperscript𝑝𝑆p^{\prime}\notin Sitalic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ∉ italic_S of p𝑝pitalic_p such that p,p𝑝superscript𝑝p,p^{\prime}italic_p , italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT are covered by a maximal square Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT having a corner in DxDysubscript𝐷𝑥subscript𝐷𝑦D_{x}\cup D_{y}italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT ∪ italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT.

In other words, Dxsubscript𝐷𝑥D_{x}italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT and Dysubscript𝐷𝑦D_{y}italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT are x𝑥xitalic_x- and y𝑦yitalic_y- coordinates appearing in P𝑃Pitalic_P, \mathcal{R}caligraphic_R or S𝑆Sitalic_S as well as the coordinates which differ by at most 1111 from coordinate values in the above set and intersect with y𝑦yitalic_y and x𝑥xitalic_x coordinates of the polygon vertices.

Proof 3.17.

We observe that all the blocks in the axis-parallel rectangle with p𝑝pitalic_p and p1subscript𝑝1p_{1}italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT lying on opposite corners lie inside P𝑃Pitalic_P and are also adjacent to p𝑝pitalic_p in G(P)𝐺𝑃G(P)italic_G ( italic_P ) (any square covering p1subscript𝑝1p_{1}italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and p𝑝pitalic_p also covers these blocks). Consider we have a token on p1subscript𝑝1p_{1}italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and we move the token to the block immediately below/above it, whichever decreases the difference of the x-coordinate with p𝑝pitalic_p, if the block is not covered by any rec-pack in {S}𝑆\mathcal{R}\cup\{S\}caligraphic_R ∪ { italic_S }. If this is not possible or if the difference of x𝑥xitalic_x-coordinates is already 00, we move the token to the block immediately to the left/right of it, whichever decreases the difference of the y-coordinate with p𝑝pitalic_p, if the block is not covered by any rec-pack in {S}𝑆\mathcal{R}\cup\{S\}caligraphic_R ∪ { italic_S }. We continue to execute these moves till (i) the difference in x𝑥xitalic_x-coordinates is 00 and a move to reduce the difference in the y𝑦yitalic_y-coordinates is not possible because of a covered block, (ii) the difference in y𝑦yitalic_y-coordinates is 00 and a move to reduce the difference in the x𝑥xitalic_x-coordinates is not possible because of a covered block, or (iii) a move to reduce the difference in the x𝑥xitalic_x-coordinates is not possible because of a covered block and a move to reduce the difference in the y𝑦yitalic_y-coordinates is not possible because of a covered block. Note that the token stays in the axis-parallel rectangle with p𝑝pitalic_p and p1subscript𝑝1p_{1}italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT lying on opposite corners. Let psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT be the block where the token finally ends up, then psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT must be a node in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ); and psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT must be adjacent to p𝑝pitalic_p in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ). We consider the following cases.

Case I: p𝑝pitalic_p and psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT differ in both x𝑥xitalic_x- and y𝑦yitalic_y-coordinates (Figure 7(a)).

Without loss of generality, we assume psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT has a larger x𝑥xitalic_x-coordinate and a larger y𝑦yitalic_y-coordinate than p𝑝pitalic_p. Let Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT be a maximal square covering both p𝑝pitalic_p and psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT. Assume that (Lemma 3.6) Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT has horizontal sides overlap** with horizontal polygon edges (a similar argument can be made for a vertical overlap). We keep moving Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT to the left until:

  • (i) it gets obstructed by a polygon edge to its left

  • (ii) overlaps with some horizontal polygon edge at just a point

  • (iii) psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT is on the right boundary of the square

Let this new square be S′′superscript𝑆′′S^{\prime\prime}italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT. In the first two sub-cases, a horizontal side of S′′superscript𝑆′′S^{\prime\prime}italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT overlaps with some polygon edge (possibly at just a point). In the third case, since the process stopped with the token on psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT, both blocks immediately to the left and the bottom of psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT are covered by some rec-pack in {S}𝑆\mathcal{R}\cup\{S\}caligraphic_R ∪ { italic_S }, and hence S′′superscript𝑆′′S^{\prime\prime}italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT has its right side one unit to the right of a vertical side of some edge of rec-pack in {S}𝑆\mathcal{R}\cup\{S\}caligraphic_R ∪ { italic_S } (the square that covers the immediate left block of psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT but not psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT). Therefore in all cases, S′′superscript𝑆′′S^{\prime\prime}italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT has a vertical side with x-coordinate which is either the same of that of a polygon vertex or differs by at most 1111 with x-coordinate of a corner of some rec-pack in {S}𝑆\mathcal{R}\cup\{S\}caligraphic_R ∪ { italic_S }. Moreover, as S′′superscript𝑆′′S^{\prime\prime}italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT has its horizontal sides overlap** with polygon edges, S′′superscript𝑆′′S^{\prime\prime}italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT has at least one corner in Dysubscript𝐷𝑦D_{y}italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT, such that S′′superscript𝑆′′S^{\prime\prime}italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT contains both p𝑝pitalic_p and psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT.

Refer to caption
(a) Case I in proof of Lemma 3.16
Refer to caption
(b) Case II in proof of Lemma 3.16
Figure 7: Cases in proof of Lemma 3.16
Case II: p𝑝pitalic_p and psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT have the same y𝑦yitalic_y-coordinate.

Without loss of generality, let psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT have a larger x𝑥xitalic_x-coordinate than p𝑝pitalic_p. Let Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT be a maximal square covering both p𝑝pitalic_p and psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT. If Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT has its horizontal sides overlap** with polygon edges, we have an identical argument as before to prove that there is another maximal square S′′superscript𝑆′′S^{\prime\prime}italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT that covers p𝑝pitalic_p and psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT with a corner in Dysubscript𝐷𝑦D_{y}italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT. Therefore, we only consider the case when Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT has vertical sides that overlap with polygon edges (Figure 7(b)). Now, we move Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT to the top until:

  • it gets obstructed by a polygon edge to its top

  • overlaps with some vertical polygon edge at just a point

  • psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT (and hence p𝑝pitalic_p) is on the bottom boundary of the square

Let the square obtained be Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT. In the first two cases, Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT has a vertical edge overlap** with some vertical polygon edge (hence would have a corner in Dxsubscript𝐷𝑥D_{x}italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT, proving what we want). Therefore we only consider the third case: p,p𝑝superscript𝑝p,p^{\prime}italic_p , italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT are on the bottom boundary of Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT. We similarly construct Sbsubscript𝑆𝑏S_{b}italic_S start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT by moving Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT to the bottom until either it gets obstructed by (i) a polygon edge to its bottom, (ii) overlaps with some vertical polygon edge at just a point, or (iii) psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT (and hence p𝑝pitalic_p) is on the top boundary of the Sbsubscript𝑆𝑏S_{b}italic_S start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT. Again as the first two of these cases already achieve Sbsubscript𝑆𝑏S_{b}italic_S start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT having a corner in Dxsubscript𝐷𝑥D_{x}italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT, we consider the third case: p,p𝑝superscript𝑝p,p^{\prime}italic_p , italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT are on the top boundary of Sbsubscript𝑆𝑏S_{b}italic_S start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT. We observe that the bottom side of Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT lies above or on the bottom side of S𝑆Sitalic_S (as p,p𝑝superscript𝑝p,p^{\prime}italic_p , italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT are on the bottom boundary of Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT), and similarly the top side of Sbsubscript𝑆𝑏S_{b}italic_S start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT lies below or on the top side of S𝑆Sitalic_S. Again if Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT has its bottom side lying on the bottom side of S𝑆Sitalic_S, Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT would have a corner in Dxsubscript𝐷𝑥D_{x}italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT and we would be done; hence we consider that Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT has its bottom side lying above the bottom side of S𝑆Sitalic_S (and Sbsubscript𝑆𝑏S_{b}italic_S start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT has its top side lying below the top side of S𝑆Sitalic_S). Further, the top side of Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT must lie above or on the top side of S𝑆Sitalic_S (otherwise both the top side and the bottom edge of Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT lie between the top side and bottom side of S𝑆Sitalic_S; but Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT covers psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT which lies to the right of the right side of S𝑆Sitalic_S; which means Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT has its left side lying completely in the interior of S𝑆Sitalic_S, contradicting that Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT has vertical sides overlap** with polygon edges). However, this means if we were to vertically move a square initially positioned as Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT (top side of Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT above or on top side of S𝑆Sitalic_S) to Sbsubscript𝑆𝑏S_{b}italic_S start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT (top side of Sbsubscript𝑆𝑏S_{b}italic_S start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT below top side of S𝑆Sitalic_S), there would be a square S1subscript𝑆1S_{1}italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT with its top side lying on the top side of S𝑆Sitalic_S which contains p𝑝pitalic_p and psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT. Moreover, as S1subscript𝑆1S_{1}italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT has its vertical sides overlap** with polygon edges (same polygon edges which were overlap** with the vertical sides of Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT, Stsubscript𝑆𝑡S_{t}italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT and Sbsubscript𝑆𝑏S_{b}italic_S start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT), S1subscript𝑆1S_{1}italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT has a corner in Dxsubscript𝐷𝑥D_{x}italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT.

Case II: p𝑝pitalic_p and psuperscript𝑝p^{\prime}italic_p start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT have the same x𝑥xitalic_x-coordinate.

An argument similar to the previous argument works.

This completes the proof.

3.3 Placing Rec-packs given a Partial Solution

We start with a result regarding placement of maximal squares to extend partial solutions.

Lemma 3.18.

Let S𝑆Sitalic_S be a maximal square of an orthogonal polygon P𝑃Pitalic_P with side length d𝑑ditalic_d such that

  • The top and bottom edges of S𝑆Sitalic_S overlaps with horizontal polygon edges e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT respectively.

  • e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT contains the top right corner of S𝑆Sitalic_S and the distance between the top right corner of S𝑆Sitalic_S and the right endpoint e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT is more than d𝑑ditalic_d.

  • e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT contains the bottom right corner of S𝑆Sitalic_S and the distance between the bottom right corner of S𝑆Sitalic_S and the right endpoint of e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT is more than d𝑑ditalic_d.

  • There is a strip between e1,e2subscript𝑒1subscript𝑒2e_{1},e_{2}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT, and the right side of the strip is more than d𝑑ditalic_d distance away from the right side of S𝑆Sitalic_S.

Let Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT be the square generated by reflecting S𝑆Sitalic_S with respect to its right edge. Then, if there is a set of rec-packs \mathcal{R}caligraphic_R which is a partial solution of OPCS with S𝑆S\in\mathcal{R}italic_S ∈ caligraphic_R and if Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT does not overlap with any rec-pack in \mathcal{R}caligraphic_R, then {S}superscript𝑆\mathcal{R}\cup\{S^{\prime}\}caligraphic_R ∪ { italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT } is also a partial solution.

Proof 3.19.

Clearly Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT is a valid square as it is bounded by the region in the polygon in between e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT. Let Y𝑌Yitalic_Y be strip the between e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT.

Let p𝑝pitalic_p be the block inside Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT which is located at the top-left corner of Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT. Since p𝑝pitalic_p is in the strip Y𝑌Yitalic_Y defined by the region between e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT, any valid square S′′superscript𝑆′′S^{\prime\prime}italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT covering p𝑝pitalic_p must have side length at most d𝑑ditalic_d. Therefore, S′′superscript𝑆′′S^{\prime\prime}italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT must completely lie inside the union of the regions covered by S𝑆Sitalic_S and Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT.

Let superscript\mathcal{R}^{\prime}caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT be a minimum cover of P𝑃Pitalic_P with superscript\mathcal{R}\subset\mathcal{R}^{\prime}caligraphic_R ⊂ caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT. Let 𝒯=𝒯superscript\mathcal{T}=\mathcal{R}^{\prime}\setminus\mathcal{R}caligraphic_T = caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ∖ caligraphic_R. Therefore ′′=(𝒯)superscript′′𝒯\mathcal{R}^{\prime\prime}=\mathcal{R}\cup\mathcal{E}(\mathcal{T})caligraphic_R start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT = caligraphic_R ∪ caligraphic_E ( caligraphic_T ) is also a minimum covering (as (′′)=()=()(𝒯)superscript′′superscript𝒯\mathcal{E}(\mathcal{R}^{\prime\prime})=\mathcal{E}(\mathcal{R}^{\prime})=% \mathcal{E}(\mathcal{R})\cup\mathcal{E}(\mathcal{T})caligraphic_E ( caligraphic_R start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT ) = caligraphic_E ( caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) = caligraphic_E ( caligraphic_R ) ∪ caligraphic_E ( caligraphic_T )). Since Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT does not overlap with any rec-pack in \mathcal{R}caligraphic_R, there must be a square S′′(𝒯)superscript𝑆′′𝒯S^{\prime\prime}\in\mathcal{E}(\mathcal{T})italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT ∈ caligraphic_E ( caligraphic_T ) which covers p𝑝pitalic_p (top-left block of Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT). However, {S,S}𝑆superscript𝑆\{S,S^{\prime}\}{ italic_S , italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT } covers a superset of the area that {S′′,S}superscript𝑆′′𝑆\{S^{\prime\prime},S\}{ italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT , italic_S } covers (as S′′superscript𝑆′′S^{\prime\prime}italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT has side length at most d𝑑ditalic_d). Therefore, we can remove S′′superscript𝑆′′S^{\prime\prime}italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT and add Ssuperscript𝑆S^{\prime}italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT to ′′superscript′′\mathcal{R}^{\prime\prime}caligraphic_R start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT (giving us ′′′=({S′′}){S}superscript′′′superscriptsuperscript𝑆′′superscript𝑆\mathcal{R}^{\prime\prime\prime}=(\mathcal{R}^{\prime}\setminus\{S^{\prime% \prime}\})\cup\{S^{\prime}\}caligraphic_R start_POSTSUPERSCRIPT ′ ′ ′ end_POSTSUPERSCRIPT = ( caligraphic_R start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ∖ { italic_S start_POSTSUPERSCRIPT ′ ′ end_POSTSUPERSCRIPT } ) ∪ { italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT }) and this will still be a minimum cover. As {S}′′′superscript𝑆superscript′′′\mathcal{R}\cup\{S^{\prime}\}\subseteq\mathcal{R}^{\prime\prime\prime}caligraphic_R ∪ { italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT } ⊆ caligraphic_R start_POSTSUPERSCRIPT ′ ′ ′ end_POSTSUPERSCRIPT, {S}superscript𝑆\mathcal{R}\cup\{S^{\prime}\}caligraphic_R ∪ { italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT } is a partial solution.

Remark 3.20.

This result symmetrically holds true for all four directions.

We can easily extend this result to placing a rec-pack to the right of the given square S𝑆Sitalic_S.

Lemma 3.21.

Let S𝑆Sitalic_S be a maximal square of an orthogonal polygon P𝑃Pitalic_P with side length d𝑑ditalic_d such that, for some natural number η𝜂\eta\in\mathbb{N}italic_η ∈ blackboard_N,

  • The top and bottom edges of S𝑆Sitalic_S overlaps with horizontal polygon edges e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT respectively.

  • e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT contains the top right corner of S𝑆Sitalic_S and the distance between the top right corner of S𝑆Sitalic_S and the right endpoint e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT is more than ηd𝜂𝑑\eta ditalic_η italic_d.

  • e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT contains the bottom right corner of S𝑆Sitalic_S and the distance between the bottom right corner of S𝑆Sitalic_S and the right endpoint of e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT is more than ηd𝜂𝑑\eta ditalic_η italic_d.

  • There is a strip between e1,e2subscript𝑒1subscript𝑒2e_{1},e_{2}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT, and the right side of the strip is more than ηd𝜂𝑑\eta ditalic_η italic_d distance away from the right side of S𝑆Sitalic_S.

Let R𝑅Ritalic_R be the rec-pack of width d𝑑ditalic_d and strength η𝜂\etaitalic_η, such that the the vertical sides of R𝑅Ritalic_R are of length d𝑑ditalic_d and the right side of the square S𝑆Sitalic_S coincides with the left side of R𝑅Ritalic_R. Then, if there is a partial solution \mathcal{R}caligraphic_R of OPCS, where S𝑆S\in\mathcal{R}italic_S ∈ caligraphic_R and R𝑅Ritalic_R does not overlap with any rec-pack in \mathcal{R}caligraphic_R, then {R}𝑅\mathcal{R}\cup\{R\}caligraphic_R ∪ { italic_R } is also a partial solution.

Proof 3.22.

We observe that R𝑅Ritalic_R lies completely inside the strip Y𝑌Yitalic_Y in between e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT. Further, we generate η𝜂\etaitalic_η squares of the same size as S𝑆Sitalic_S as follows: S1subscript𝑆1S_{1}italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT is the square generated by reflecting S𝑆Sitalic_S by its right side, S2subscript𝑆2S_{2}italic_S start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT is the square generated by reflecting S1subscript𝑆1S_{1}italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT by its right side, and for any i{3,η}𝑖3𝜂i\in\{3,\ldots\eta\}italic_i ∈ { 3 , … italic_η }, Sisubscript𝑆𝑖S_{i}italic_S start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT is the square generated by reflecting Si1subscript𝑆𝑖1S_{i-1}italic_S start_POSTSUBSCRIPT italic_i - 1 end_POSTSUBSCRIPT by its right side. Therefore, Sηsubscript𝑆𝜂S_{\eta}italic_S start_POSTSUBSCRIPT italic_η end_POSTSUBSCRIPT is the square generated by reflecting Sη1subscript𝑆𝜂1S_{\eta-1}italic_S start_POSTSUBSCRIPT italic_η - 1 end_POSTSUBSCRIPT by its right side. Then clearly, R𝑅Ritalic_R covers the exact area covered by {S1,,Sη}subscript𝑆1subscript𝑆𝜂\{S_{1},\ldots,S_{\eta}\}{ italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_S start_POSTSUBSCRIPT italic_η end_POSTSUBSCRIPT }. Precisely, we have (R)={S1,,Sη}𝑅subscript𝑆1subscript𝑆𝜂\mathcal{E}(R)=\{S_{1},\ldots,S_{\eta}\}caligraphic_E ( italic_R ) = { italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_S start_POSTSUBSCRIPT italic_η end_POSTSUBSCRIPT }. Moreover, as R𝑅Ritalic_R does not overlap with any rec-pack in \mathcal{R}caligraphic_R, none of {S1,,Sη}subscript𝑆1subscript𝑆𝜂\{S_{1},\ldots,S_{\eta}\}{ italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_S start_POSTSUBSCRIPT italic_η end_POSTSUBSCRIPT } overlaps with any rec-pack in \mathcal{R}caligraphic_R. This setting now allows us to use Lemma 3.18 repeatedly.

Since S𝑆S\in\mathcal{R}italic_S ∈ caligraphic_R, by Lemma 3.18, {S1}subscript𝑆1\mathcal{R}\cup\{S_{1}\}caligraphic_R ∪ { italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT } is a partial solution. Again, as {S1}{S1}subscript𝑆1subscript𝑆1\{S_{1}\}\in\mathcal{R}\cup\{S_{1}\}{ italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT } ∈ caligraphic_R ∪ { italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT }, by Lemma 3.18, {S1,S2}subscript𝑆1subscript𝑆2\mathcal{R}\cup\{S_{1},S_{2}\}caligraphic_R ∪ { italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_S start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT } is a partial solution. Continuing, for any i{1,,η1}𝑖1𝜂1i\in\{1,\ldots,\eta-1\}italic_i ∈ { 1 , … , italic_η - 1 }, as {S1,,Si}subscript𝑆1subscript𝑆𝑖\mathcal{R}\cup\{S_{1},\ldots,S_{i}\}caligraphic_R ∪ { italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_S start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT } is a partial solution, by Lemma 3.21 {S1,,Si,Si+1}subscript𝑆1subscript𝑆𝑖subscript𝑆𝑖1\mathcal{R}\cup\{S_{1},\ldots,S_{i},S_{i+1}\}caligraphic_R ∪ { italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_S start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_S start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT } is a partial solution. In particular, {S1,,Sη}=(R)subscript𝑆1subscript𝑆𝜂𝑅\mathcal{R}\cup\{S_{1},\ldots,S_{\eta}\}=\mathcal{R}\cup\mathcal{E}(R)caligraphic_R ∪ { italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_S start_POSTSUBSCRIPT italic_η end_POSTSUBSCRIPT } = caligraphic_R ∪ caligraphic_E ( italic_R ) is a partial solution. This means R𝑅\mathcal{R}\cup Rcaligraphic_R ∪ italic_R is also a partial solution.

Remark 3.23.

Again, this result symmetrically holds true for all four directions.

We will use Lemma 3.21 in the subsequent section to efficiently obtain a large number of squares which are also a part of a partial solution.

4 Polynomial Time Algorithm for OPCS w.r.t the Number of Polygonal Vertices

In this Section, we design an algorithm for OPCS such that the input polygon is taken in terms of its n𝑛nitalic_n vertices. The algorithm runs in 𝒪(n14)𝒪superscript𝑛14\mathcal{O}(n^{14})caligraphic_O ( italic_n start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ) time. We first start with some subroutines which we use for our algorithm, followed by the algorithm itself. Finally, we give the running time analysis for the algorithm.

4.1 Checking if a Set of Rec-Packs covers the Input Orthogonal Polygon

We design an algorithm that checks whether a given set of rec-packs completely covers an orthogonal polygon P𝑃Pitalic_P.

Lemma 4.1.

Given an orthogonal polygon P𝑃Pitalic_P and a set \mathcal{R}caligraphic_R of ||=D𝐷|\mathcal{R}|=D| caligraphic_R | = italic_D rec-packs, where ={R1,R2,,RD}subscript𝑅1subscript𝑅2subscript𝑅𝐷\mathcal{R}=\{R_{1},R_{2},\ldots,R_{D}\}caligraphic_R = { italic_R start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_R start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT , … , italic_R start_POSTSUBSCRIPT italic_D end_POSTSUBSCRIPT }, there is an algorithm that checks if \mathcal{R}caligraphic_R (equivalently ()\mathcal{E}(\mathcal{R})caligraphic_E ( caligraphic_R )) completely covers P𝑃Pitalic_P. The algorithm runs in 𝒪(D(D+n)2)𝒪𝐷superscript𝐷𝑛2\mathcal{O}(D\cdot(D+n)^{2})caligraphic_O ( italic_D ⋅ ( italic_D + italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) time.

Proof 4.2.

Clearly, if \mathcal{R}caligraphic_R does not completely cover the entire interior of P𝑃Pitalic_P, the uncovered interior of P𝑃Pitalic_P will be a collection of one or more orthogonal polygons themselves. Further the edges of these polygons must be either an edge of P𝑃Pitalic_P or an edge of some rec-pack in \mathcal{R}caligraphic_R. Therefore the vertices must be intersections of two such edges (either of P𝑃Pitalic_P or of some rec-pack in \mathcal{R}caligraphic_R). Moreover, the number of such intersections is upper-bounded by (2D+n)2superscript2𝐷𝑛2(2D+n)^{2}( 2 italic_D + italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT. Therefore we check for each such intersection α𝛼\alphaitalic_α, if all four blocks with α𝛼\alphaitalic_α as a corner are covered by some rec-pack in \mathcal{R}caligraphic_R, then we are done.

Thus, the following algorithm answers whether \mathcal{R}caligraphic_R completely covers the orthogonal polygon P𝑃Pitalic_P in 𝒪(D(D+n)2)𝒪𝐷superscript𝐷𝑛2\mathcal{O}(D\cdot(D+n)^{2})caligraphic_O ( italic_D ⋅ ( italic_D + italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) time.

Algorithm 1 Complete Coverage Checker     Input: Orthogonal Polygon P𝑃Pitalic_P, \mathcal{R}caligraphic_R
for all x-coordinates x0subscript𝑥0x_{0}italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT of vertical edges of P𝑃Pitalic_P and \mathcal{R}caligraphic_R do \triangleright 𝒪(D+n)𝒪𝐷𝑛\mathcal{O}(D+n)caligraphic_O ( italic_D + italic_n ) loop
     for all y-coordinates y0subscript𝑦0y_{0}italic_y start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT of horizontal edges of P𝑃Pitalic_P and \mathcal{R}caligraphic_R do \triangleright 𝒪(D+n)𝒪𝐷𝑛\mathcal{O}(D+n)caligraphic_O ( italic_D + italic_n ) loop
         for all four blocks p𝑝pitalic_p with (x0,y0)subscript𝑥0subscript𝑦0(x_{0},y_{0})( italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_y start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) as corner do \triangleright 𝒪(1)𝒪1\mathcal{O}(1)caligraphic_O ( 1 ) loop
              if p𝑝pitalic_p lies outside P𝑃Pitalic_P then
                  continue to next iteration
              end if
              flag \leftarrow FALSE \triangleright To keep track if s𝑠sitalic_s is covered
              for all R𝑅R\in\mathcal{R}italic_R ∈ caligraphic_R do \triangleright 𝒪(D)𝒪𝐷\mathcal{O}(D)caligraphic_O ( italic_D ) loop
                  if p𝑝pitalic_p lies inside R𝑅Ritalic_R then \triangleright 𝒪(1)𝒪1\mathcal{O}(1)caligraphic_O ( 1 ) check
                       flag \leftarrow TRUE
                       break out from the current loop
                  end if
              end for
              if flag = FALSE then \triangleright incomplete covering
                  return INCOMPLETE COVERING
              end if
         end for
     end for
end for
return COMPLETE COVERING

4.2 Detecting Unambiguous Squares

We now discuss an algorithm that takes in a square S𝑆Sitalic_S, a partial solution \mathcal{R}caligraphic_R for OPCS and the input orthogonal polygon P𝑃Pitalic_P and decides if S𝑆Sitalic_S is an unambiguous square given \mathcal{R}caligraphic_R. We crucially use Lemma 3.16 for the correctness of the algorithm.

Lemma 4.3.

Given an orthogonal polygon P𝑃Pitalic_P, a partial solution \mathcal{R}caligraphic_R for OPCS and valid square S𝑆Sitalic_S, there is an algorithm that checks if S𝑆Sitalic_S is an unambiguous square given \mathcal{R}caligraphic_R in 𝒪((n2+||n)3)𝒪superscriptsuperscript𝑛2𝑛3\mathcal{O}((n^{2}+|\mathcal{R}|n)^{3})caligraphic_O ( ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT ) time.

Proof 4.4.

We start by constructing the sets Dxsubscript𝐷𝑥D_{x}italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT and Dysubscript𝐷𝑦D_{y}italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT as in Lemma 3.16. By definition, |Dx|,|Dy|=𝒪((n+||+1)n)=𝒪(n2+||n)subscript𝐷𝑥subscript𝐷𝑦𝒪𝑛1𝑛𝒪superscript𝑛2𝑛|D_{x}|,|D_{y}|=\mathcal{O}((n+|\mathcal{R}|+1)\cdot n)=\mathcal{O}(n^{2}+|% \mathcal{R}|n)| italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT | , | italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT | = caligraphic_O ( ( italic_n + | caligraphic_R | + 1 ) ⋅ italic_n ) = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ). Definition 3.10 implies that S𝑆Sitalic_S is an unambiguous square given \mathcal{R}caligraphic_R if and only if there is a simplicial node p𝑝pitalic_p in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) such that S𝑆Sitalic_S covers p𝑝pitalic_p and all its neighbours in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ). From Lemma 3.16, this is not the case if and only if all maximal squares with a corner in DxDysubscript𝐷𝑥subscript𝐷𝑦D_{x}\cup D_{y}italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT ∪ italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT which cover some block not covered by {S}𝑆\mathcal{R}\cup\{S\}caligraphic_R ∪ { italic_S }, together cover up the entire region inside S𝑆Sitalic_S not covered by \mathcal{R}caligraphic_R. In other words, all blocks p1subscript𝑝1p_{1}italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT in S𝑆Sitalic_S not covered by \mathcal{R}caligraphic_R have an adjacent block p2subscript𝑝2p_{2}italic_p start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) and therefore p1subscript𝑝1p_{1}italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT cannot be a simplicial node in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) with S𝑆Sitalic_S covering all its neighbours in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ). Let 𝒟𝒟\mathcal{D}caligraphic_D be the set of maximal squares with a corner in DxDysubscript𝐷𝑥subscript𝐷𝑦D_{x}\cup D_{y}italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT ∪ italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT that cover some node in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) which is not covered by S𝑆Sitalic_S (i.e. we do not consider those maximal squares which lie completely outside the region covered by {S}𝑆\mathcal{R}\cup\{S\}caligraphic_R ∪ { italic_S }). By construction, |𝒟|4|Dx|+4|Dy|=𝒪(n2+||n)𝒟4subscript𝐷𝑥4subscript𝐷𝑦𝒪superscript𝑛2𝑛|\mathcal{D}|\leq 4|D_{x}|+4|D_{y}|=\mathcal{O}(n^{2}+|\mathcal{R}|n)| caligraphic_D | ≤ 4 | italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT | + 4 | italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT | = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ).

There is some block p𝑝pitalic_p in S𝑆Sitalic_S, which is not covered by any rec-pack in 𝒟𝒟\mathcal{D}\cup\mathcal{R}caligraphic_D ∪ caligraphic_R, if and only if p𝑝pitalic_p is a simplicial node in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P ) with S𝑆Sitalic_S covering p𝑝pitalic_p and all its neighbours, i.e. S𝑆Sitalic_S is an unambiguous square given \mathcal{R}caligraphic_R (Lemma 3.16). However, we cannot check for simpliciality in all blocks in S𝑆Sitalic_S, as this can potentially be exponential. Nevertheless, let us draw the infinite horizontal and vertical lines from all corners of rec-packs of {S}𝒟𝑆𝒟\mathcal{R}\cup\{S\}\cup\mathcal{D}caligraphic_R ∪ { italic_S } ∪ caligraphic_D and from the vertices of P𝑃Pitalic_P. This would form a grid like structure with 𝒪((n2+||n)2)𝒪superscriptsuperscript𝑛2𝑛2\mathcal{O}((n^{2}+|\mathcal{R}|n)^{2})caligraphic_O ( ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) rectangular regions. Clearly, any two blocks in the same rectangular region would be covered by the same subset of rec-packs in {S}𝒟𝑆𝒟\mathcal{R}\cup\{S\}\cup\mathcal{D}caligraphic_R ∪ { italic_S } ∪ caligraphic_D. Therefore it would be sufficient to check for simpliciality in a single block in each rectangular region (we check all the corner blocks of the rectangular regions i.e. blocks having a corner which shares an x coordinate of a vertex in P𝑃Pitalic_P or a corner in {S}𝒟𝑆𝒟\mathcal{R}\cup\{S\}\cup\mathcal{D}caligraphic_R ∪ { italic_S } ∪ caligraphic_D as well as the y coordinate). Given the description above, checking for simpliciality will take 𝒪(n2+||n)𝒪superscript𝑛2𝑛\mathcal{O}(n^{2}+|\mathcal{R}|n)caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) time.

Therefore, given \mathcal{R}caligraphic_R the following algorithm answers whether S𝑆Sitalic_S is an unambiguous square in 𝒪((n2+||n)3)𝒪superscriptsuperscript𝑛2𝑛3\mathcal{O}((n^{2}+|\mathcal{R}|n)^{3})caligraphic_O ( ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT ) time.

Algorithm 2 Is Unambiguous Square     Input: P𝑃Pitalic_P, \mathcal{R}caligraphic_R, S𝑆Sitalic_S
If S𝑆Sitalic_S is not maximal return NOT UNAMBIGUOUS \triangleright 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) time
Construct Dxsubscript𝐷𝑥D_{x}italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT, Dysubscript𝐷𝑦D_{y}italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT as in Lemma 3.16 \triangleright |Dx|,|Dy|=𝒪(n2+||n)subscript𝐷𝑥subscript𝐷𝑦𝒪superscript𝑛2𝑛|D_{x}|,|D_{y}|=\mathcal{O}(n^{2}+|\mathcal{R}|n)| italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT | , | italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT | = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n )
𝒟superscript𝒟absent\mathcal{D}^{\prime}\leftarrowcaligraphic_D start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ← {maximal squares with a corner in DxDysubscript𝐷𝑥subscript𝐷𝑦D_{x}\cup D_{y}italic_D start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT ∪ italic_D start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT} \triangleright 𝒪((n2+||n)n)𝒪superscript𝑛2𝑛𝑛\mathcal{O}((n^{2}+|\mathcal{R}|n)\cdot n)caligraphic_O ( ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) ⋅ italic_n ) time
𝒟𝒟absent\mathcal{D}\leftarrowcaligraphic_D ← {squares in 𝒟superscript𝒟\mathcal{D}^{\prime}caligraphic_D start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT covering a block not covered by {S}𝑆\mathcal{R}\cup\{S\}caligraphic_R ∪ { italic_S }} \triangleright |𝒟|=𝒪(n2+||n)𝒟𝒪superscript𝑛2𝑛|\mathcal{D}|=\mathcal{O}(n^{2}+|\mathcal{R}|n)| caligraphic_D | = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n )
T{(x,y)|x and y are coordinates of corners in P or 𝒟{S}}𝑇conditional-set𝑥𝑦𝑥 and 𝑦 are coordinates of corners in 𝑃 or 𝒟𝑆T\leftarrow\{(x,y)|x\text{ and }y\text{ are coordinates of corners in }P\text{% or }\mathcal{R}\cup\mathcal{D}\cup\{S\}\}italic_T ← { ( italic_x , italic_y ) | italic_x and italic_y are coordinates of corners in italic_P or caligraphic_R ∪ caligraphic_D ∪ { italic_S } }
for (x,y)T𝑥𝑦𝑇(x,y)\in T( italic_x , italic_y ) ∈ italic_T do \triangleright 𝒪(|T|)=𝒪((|𝒟|+||+n)2)=𝒪((n2+||n)2)𝒪𝑇𝒪superscript𝒟𝑛2𝒪superscriptsuperscript𝑛2𝑛2\mathcal{O}(|T|)=\mathcal{O}((|\mathcal{D}|+|\mathcal{R}|+n)^{2})=\mathcal{O}(% (n^{2}+|\mathcal{R}|n)^{2})caligraphic_O ( | italic_T | ) = caligraphic_O ( ( | caligraphic_D | + | caligraphic_R | + italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) = caligraphic_O ( ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) loop
     for blocks p𝑝pitalic_p with corner (x,y)𝑥𝑦(x,y)( italic_x , italic_y ) do \triangleright at most 4444 possibilities
         if pS𝑝𝑆p\in Sitalic_p ∈ italic_S and R𝒟,pRformulae-sequencefor-all𝑅𝒟𝑝𝑅\forall R\in\mathcal{R}\cup\mathcal{D},p\notin R∀ italic_R ∈ caligraphic_R ∪ caligraphic_D , italic_p ∉ italic_R then \triangleright 𝒪(|𝒟|+||)=𝒪(n2+||n)𝒪𝒟𝒪superscript𝑛2𝑛\mathcal{O}(|\mathcal{D}|+|\mathcal{R}|)=\mathcal{O}(n^{2}+|\mathcal{R}|n)caligraphic_O ( | caligraphic_D | + | caligraphic_R | ) = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) check
              return UNAMBIGUOUS \triangleright p𝑝pitalic_p is simplicial in G(P)superscript𝐺𝑃G^{\mathcal{R}}(P)italic_G start_POSTSUPERSCRIPT caligraphic_R end_POSTSUPERSCRIPT ( italic_P )
         end if
     end for
end for
return NOT UNAMBIGUOUS

4.3 Generating Rec-Packs within a Strip

We wish to use Lemma 3.21 to extend an existing partial solution by adding a rec-pack. In order to do this, we need to construct rec-packs R𝑅Ritalic_R within a strip (between e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT, Lemma 3.21) which shares its shorter side (perpendicular to e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT) with the side of a given square S𝑆Sitalic_S (we call this the ‘seed’). We discuss the following algorithm to construct rec-packs R𝑅Ritalic_R for the setting in Lemma 3.21.

Lemma 4.5.

Given a maximal square S𝑆Sitalic_S (referred to as the ‘seed’) of an orthogonal polygon P𝑃Pitalic_P with side length d𝑑ditalic_d, there is an algorithm to test if there are horizontal polygon edges e1,e2subscript𝑒1subscript𝑒2e_{1},e_{2}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT and some natural number η𝜂\eta\in\mathbb{N}italic_η ∈ blackboard_N, such that

  • The top and bottom edges of S𝑆Sitalic_S overlaps with horizontal polygon edges e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT respectively.

  • e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT contains the top right corner of S𝑆Sitalic_S and the distance between the top right corner of S𝑆Sitalic_S and the right endpoint e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT is more than ηd𝜂𝑑\eta ditalic_η italic_d.

  • e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT contains the bottom right corner of S𝑆Sitalic_S and the distance between the bottom right corner of S𝑆Sitalic_S and the right endpoint of e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT is more than ηd𝜂𝑑\eta ditalic_η italic_d.

  • There is a strip between e1,e2subscript𝑒1subscript𝑒2e_{1},e_{2}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT, and the right side of the strip is more than ηd𝜂𝑑\eta ditalic_η italic_d distance away from the right side of S𝑆Sitalic_S.

Moreover, if this exists, the algorithm finds the largest possible η𝜂\etaitalic_η and if η2𝜂2\eta\geq 2italic_η ≥ 2 the algorithm returns the rec-pack R𝑅Ritalic_R of width d𝑑ditalic_d and strength η1𝜂1\eta-1italic_η - 1, such that the vertical sides of R𝑅Ritalic_R are of length d𝑑ditalic_d and the right side of the square S𝑆Sitalic_S coincides with the left side of R𝑅Ritalic_R. The algorithm runs in total 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) time.

Note that this can be done for all four directions. Therefore, henceforth if we need to apply a similar algorithm in a different direction, we shall still refer to this Lemma.

This essentially tests if Lemma 3.21 can be applied to the setting or not; if yes, this also outputs the rec-pack R𝑅Ritalic_R with the second largest strength η1𝜂1\eta-1italic_η - 1 for which the setting applies.

Proof 4.6.

Consider the following algorithm.

Algorithm 3 Generate-Rec-pack-left     Input: P𝑃Pitalic_P, seed S𝑆Sitalic_S
Try finding e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT containing top-left and bottom-right corner of S𝑆Sitalic_S \triangleright 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) check
if e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT or e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT not found then return NOT-APPLICABLE end if
x1subscript𝑥1absentx_{1}\leftarrowitalic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ← x coordinate of right side of S𝑆Sitalic_S
x2min(x coordinate of right end of e1,x coordinate of right end of e2)subscript𝑥2x coordinate of right end of subscript𝑒1x coordinate of right end of subscript𝑒2x_{2}\leftarrow\min(\text{x coordinate of right end of }e_{1},\text{x % coordinate of right end of }e_{2})italic_x start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ← roman_min ( x coordinate of right end of italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , x coordinate of right end of italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT )
x2min(x2, x coordinate x of polygon vertex lying between e1,e2:x>x1x_{2}\leftarrow\min(x_{2},\text{ x coordinate $x^{\prime}$ of polygon vertex % lying between }e_{1},e_{2}:x^{\prime}>x_{1}italic_x start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ← roman_min ( italic_x start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT , x coordinate italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT of polygon vertex lying between italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT : italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT > italic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT)
d𝑑absentd\leftarrowitalic_d ← side length of S𝑆Sitalic_S
if x2x1dsubscript𝑥2subscript𝑥1𝑑x_{2}-x_{1}\leq ditalic_x start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT - italic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ≤ italic_d then return NOT-APPLICABLE end if \triangleright Setting not applicable
ηx2x1d1𝜂subscript𝑥2subscript𝑥1𝑑1\eta\leftarrow\lceil\frac{x_{2}-x_{1}}{d}\rceil-1italic_η ← ⌈ divide start_ARG italic_x start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT - italic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT end_ARG start_ARG italic_d end_ARG ⌉ - 1 \triangleright gets maximum possible strength η𝜂\etaitalic_η
if η=1𝜂1\eta=1italic_η = 1 then return SHORT-STRIP end if
return rec-pack R𝑅Ritalic_R of strength η𝜂\etaitalic_η, width d𝑑ditalic_d sharing left-side with right-side of S𝑆Sitalic_S

This algorithm first checks for the existence of polygonal edges e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT (𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) loop on all polygon-edge) and further checks if e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT have right end points lying farther than ηd𝜂𝑑\eta ditalic_η italic_d distance for at least η=1𝜂1\eta=1italic_η = 1 (the minimum value). If any of these do not happen, no such R𝑅Ritalic_R exists and the algorithm outputs ‘NOT-APPLICABLE’.

Moreover, if it is applicable, it finds the largest value of η𝜂\etaitalic_η such that e1,e2subscript𝑒1subscript𝑒2e_{1},e_{2}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT have both of their right endpoints more than ηd𝜂𝑑\eta ditalic_η italic_d distance away from the right side of S𝑆Sitalic_S. Finally, the algorithm returns the rec-pack R𝑅Ritalic_R of strength η1𝜂1\eta-1italic_η - 1 as needed if η2𝜂2\eta\geq 2italic_η ≥ 2 or returns ‘SHORT-STRIP’ if η=1𝜂1\eta=1italic_η = 1.

The entire algorithm runs in linear time and can be extended to all directions.

{observation}

The rec-packs generated in Algorithm 3 leaves at least distance d𝑑ditalic_d and at most distance 2d2𝑑2d2 italic_d from the right side of the strip contained in e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT and can not intersect with any valid square that covers some region outside the strip containing e1,e2subscript𝑒1subscript𝑒2e_{1},e_{2}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT.

The idea for generating R𝑅Ritalic_R with strength η1𝜂1\eta-1italic_η - 1 (or returning ‘SHORT-STRIP’ if η=1𝜂1\eta=1italic_η = 1) is to ensure that R𝑅Ritalic_R does not intersect with any square that partially lies outside the strip in between e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT. Moreover, if we get ‘SHORT-STRIP’ as an output, we know that there is no efficient rec-pack representation necessary as the number of squares needed to cover any such region with η=1𝜂1\eta=1italic_η = 1 is at most 2222.

While using this as a subroutine for our final algorithm discussed later, we need to check that given a partial solution {S}𝑆\mathcal{R}\cup\{S\}caligraphic_R ∪ { italic_S } with S𝑆Sitalic_S acting as a seed, if the generated rec-pack R𝑅Ritalic_R intersects with any rec-pack in \mathcal{R}caligraphic_R. If there is no intersection, we can say that {R}𝑅\mathcal{R}\cup\{R\}caligraphic_R ∪ { italic_R } is also a partial solution.

4.4 Polynomial Time Algorithm: Building up Partial Solutions

Finally, we are ready to state the polynomial time algorithm for OPCS when the input polygon is in terms of its n𝑛nitalic_n vertices. We use the following framework: Start with an empty partial solution, keep extending the partial solution either by adding unambiguous squares (Lemma 3.12) or by adding rec-packs generated by a seed square (Algorithm 3 and Lemma 3.21). We stop this whenever we have a set of rec-packs which completely covers the polygon (detected using Algorithm 1). This will be guaranteed to be a minimum cover, because throughout the algorithm the set of rec-packs is guaranteed to be a partial solution by Lemma 3.12 and Lemma 3.21.

To find unambiguous squares given a partial solution \mathcal{R}caligraphic_R of OPCS, we generate all possible maximal squares having end points in CxCysubscript𝐶𝑥subscript𝐶𝑦C_{x}\cup C_{y}italic_C start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT ∪ italic_C start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT as defined in Lemma 3.14. We are guaranteed to get an unambiguous square given \mathcal{R}caligraphic_R (due to Lemma 3.14). Next, we test for all such generated squares if it is unambiguous using Algorithm 2.

Formally, the algorithm is as follows.

Algorithm 4 Extend-Partial-Solution     Input: P𝑃Pitalic_P
\mathcal{R}\leftarrow\emptysetcaligraphic_R ← ∅ \triangleright Start with empty partial solution
while \mathcal{R}caligraphic_R does not cover P𝑃Pitalic_P do \triangleright 𝒪(||(||+n)2)𝒪superscript𝑛2\mathcal{O}(|\mathcal{R}|\cdot(|\mathcal{R}|+n)^{2})caligraphic_O ( | caligraphic_R | ⋅ ( | caligraphic_R | + italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) time check with Algorithm 1
     Construct Cx,Cysubscript𝐶𝑥subscript𝐶𝑦C_{x},C_{y}italic_C start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT , italic_C start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT as Lemma 3.14 \triangleright |Cx|,|Cy|=𝒪(n(n+||))subscript𝐶𝑥subscript𝐶𝑦𝒪𝑛𝑛|C_{x}|,|C_{y}|=\mathcal{O}(n\cdot(n+|\mathcal{R}|))| italic_C start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT | , | italic_C start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT | = caligraphic_O ( italic_n ⋅ ( italic_n + | caligraphic_R | ) )
     𝒮{squares with corner in CxCy}superscript𝒮squares with corner in subscript𝐶𝑥subscript𝐶𝑦\mathcal{S}^{\prime}\leftarrow\{\text{squares with corner in }C_{x}\cup C_{y}\}caligraphic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ← { squares with corner in italic_C start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT ∪ italic_C start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT } \triangleright |𝒮|=𝒪(n(n+||))superscript𝒮𝒪𝑛𝑛|\mathcal{S}^{\prime}|=\mathcal{O}(n\cdot(n+|\mathcal{R}|))| caligraphic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | = caligraphic_O ( italic_n ⋅ ( italic_n + | caligraphic_R | ) ), time =𝒪(|𝒮|n)absent𝒪superscript𝒮𝑛=\mathcal{O}(|\mathcal{S}^{\prime}|\cdot n)= caligraphic_O ( | caligraphic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | ⋅ italic_n )
     for S𝒮𝑆superscript𝒮S\in\mathcal{S}^{\prime}italic_S ∈ caligraphic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT do \triangleright |𝒮|=𝒪(n(n+||))superscript𝒮𝒪𝑛𝑛|\mathcal{S}^{\prime}|=\mathcal{O}(n\cdot(n+|\mathcal{R}|))| caligraphic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | = caligraphic_O ( italic_n ⋅ ( italic_n + | caligraphic_R | ) ) loop
         if S𝑆Sitalic_S is unambiguous in P𝑃Pitalic_P given \mathcal{R}caligraphic_R then\triangleright 𝒪((n2+||n)3)𝒪superscriptsuperscript𝑛2𝑛3\mathcal{O}((n^{2}+|\mathcal{R}|n)^{3})caligraphic_O ( ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT ) using Algorithm 2
              {S}𝑆\mathcal{R}\leftarrow\mathcal{R}\cup\{S\}caligraphic_R ← caligraphic_R ∪ { italic_S } \triangleright \mathcal{R}caligraphic_R is still a partial solution by Lemma 3.12
              Rlsubscript𝑅𝑙absentR_{l}\leftarrowitalic_R start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT ← generated rec-pack with seed S𝑆Sitalic_S to the left. \triangleright 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) with Algorithm 3
              Rrsubscript𝑅𝑟absentR_{r}\leftarrowitalic_R start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT ← generated rec-pack with seed S𝑆Sitalic_S to the right. \triangleright Similar to Algorithm 3
              Rtsubscript𝑅𝑡absentR_{t}\leftarrowitalic_R start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT ← generated rec-pack with seed S𝑆Sitalic_S to the top. \triangleright Similar to Algorithm 3
              Rbsubscript𝑅𝑏absentR_{b}\leftarrowitalic_R start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT ← generated rec-pack with seed S𝑆Sitalic_S to the bottom. \triangleright Similar to Algorithm 3
              for R{Rl,Rr,Rt,Rb}𝑅subscript𝑅𝑙subscript𝑅𝑟subscript𝑅𝑡subscript𝑅𝑏R\in\{R_{l},R_{r},R_{t},R_{b}\}italic_R ∈ { italic_R start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT , italic_R start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT , italic_R start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_R start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT } do \triangleright 𝒪(1)𝒪1\mathcal{O}(1)caligraphic_O ( 1 ) loop
                  if R𝑅absentR\notinitalic_R ∉ {NOT-APPLICABLE, SHORT-STRIP} then \triangleright Algorithm 3 output
                       if R𝑅Ritalic_R does not intersects with any rec-pack in \mathcal{R}caligraphic_R then \triangleright 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) check
                           {R}𝑅\mathcal{R}\leftarrow\mathcal{R}\cup\{R\}caligraphic_R ← caligraphic_R ∪ { italic_R } \triangleright \mathcal{R}caligraphic_R remains a partial solution by Lemma 3.21
                       end if
                  end if
              end for
              break out of for loop, continue next while loop iteration
         end if
     end for
end while
s0𝑠0s\leftarrow 0italic_s ← 0
for R𝑅R\in\mathcal{R}italic_R ∈ caligraphic_R do \triangleright 𝒪(||)𝒪\mathcal{O}(|\mathcal{R}|)caligraphic_O ( | caligraphic_R | ) loop
     ss+(strength of R)𝑠𝑠strength of 𝑅s\leftarrow s+(\text{strength of }R)italic_s ← italic_s + ( strength of italic_R ) \triangleright |(R)|=𝑅absent|\mathcal{E}(R)|=| caligraphic_E ( italic_R ) | = strength of R𝑅Ritalic_R.
end for
return s𝑠sitalic_s

First, as the generated rec-packs are only added to \mathcal{R}caligraphic_R if they do not intersect with any rec-pack in \mathcal{R}caligraphic_R, we make the following observation.

{observation}

The only non-trivial rec-packs in \mathcal{R}caligraphic_R are the ones generated by a seed, and no two non-trivial rec-packs in \mathcal{R}caligraphic_R intersect with each other.

From the discussion above, we obtain the following statement.

Lemma 4.7.

Algorithm 1 (Extend-Partial-Solution) terminates in finite time and outputs the minimum number of squares to cover P𝑃Pitalic_P.

Proof 4.8.

Termination. Each iteration of the while loop takes finite time and every other step outside the while loop takes finite time as well. Moreover, the number of while loop iterations is also finite as at each step, as in each step the algorithm is guaranteed to find an unambiguous square (Lemma 3.14) and therefore the size of the partial solution increases at least by one. Further, this unambiguous square added covers at least one currently uncovered block of the polygon, thereby decreasing in the current step the area of the uncovered region of the polygon at least by 1111. Since PPPitalic_P has a finite area, the number of while loop iterations is finite, and hence Algorithm 4 terminates in finite time.

Minimum Covering. By Lemma 3.12 and Lemma 3.21, \mathcal{R}caligraphic_R is always a partial solution, and therefore if \mathcal{R}caligraphic_R covers PPPitalic_P completely, it has to be a minimum cover. This means ()\mathcal{E}(\mathcal{R})caligraphic_E ( caligraphic_R ) is a minimum cover. Therefore, we have,

OPCS(P)=|()|=|R(R)|=R|(R)|=R(strength of R)OPCS𝑃subscript𝑅𝑅subscript𝑅𝑅subscript𝑅strength of 𝑅\text{{OPCS}}(P)=|\mathcal{E}(\mathcal{R})|=|\bigcup\limits_{R\in\mathcal{R}}% \mathcal{E}(R)|=\sum\limits_{R\in\mathcal{R}}|\mathcal{E}(R)|=\sum\limits_{R% \in\mathcal{R}}(\text{strength of }R)OPCS ( italic_P ) = | caligraphic_E ( caligraphic_R ) | = | ⋃ start_POSTSUBSCRIPT italic_R ∈ caligraphic_R end_POSTSUBSCRIPT caligraphic_E ( italic_R ) | = ∑ start_POSTSUBSCRIPT italic_R ∈ caligraphic_R end_POSTSUBSCRIPT | caligraphic_E ( italic_R ) | = ∑ start_POSTSUBSCRIPT italic_R ∈ caligraphic_R end_POSTSUBSCRIPT ( strength of italic_R )

which completes the proof.

Our next step is to bound the time for each iteration of the while loop.

Lemma 4.9.

Each iteration of the while loop of Algorithm 4 runs in 𝒪((n2+||n)4)𝒪superscriptsuperscript𝑛2𝑛4\mathcal{O}((n^{2}+|\mathcal{R}|n)^{4})caligraphic_O ( ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 4 end_POSTSUPERSCRIPT ) time.

Proof 4.10.

We analyse the time taken at each step.

  • Checking the condition of the while loop takes 𝒪(||(||+n)2)𝒪superscript𝑛2\mathcal{O}(|\mathcal{R}|\cdot(|\mathcal{R}|+n)^{2})caligraphic_O ( | caligraphic_R | ⋅ ( | caligraphic_R | + italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) time, which is clearly bounded by 𝒪((n2+||n)4)𝒪superscriptsuperscript𝑛2𝑛4\mathcal{O}((n^{2}+|\mathcal{R}|n)^{4})caligraphic_O ( ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 4 end_POSTSUPERSCRIPT ).

  • Generating 𝒮superscript𝒮\mathcal{S}^{\prime}caligraphic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT, and checking for all possible squares in 𝒮superscript𝒮\mathcal{S}^{\prime}caligraphic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT if they are ambiguous takes time 𝒪((n2+||n)n+(n2+||n)(n2+||n)3)=𝒪((n2+||n)4)𝒪superscript𝑛2𝑛𝑛superscript𝑛2𝑛superscriptsuperscript𝑛2𝑛3𝒪superscriptsuperscript𝑛2𝑛4\mathcal{O}((n^{2}+|\mathcal{R}|n)\cdot n+(n^{2}+|\mathcal{R}|n)\cdot(n^{2}+|% \mathcal{R}|n)^{3})=\mathcal{O}((n^{2}+|\mathcal{R}|n)^{4})caligraphic_O ( ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) ⋅ italic_n + ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) ⋅ ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT ) = caligraphic_O ( ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 4 end_POSTSUPERSCRIPT ) as |S|=𝒪(n2+||n)superscript𝑆𝒪superscript𝑛2𝑛|S^{\prime}|=\mathcal{O}(n^{2}+|\mathcal{R}|n)| italic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n )

  • Generating rec-packs with the seed S𝑆Sitalic_S and the respective checks are only done four times per while loop iteration, and therefore they take up a total overhead of 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ).

Hence, each iteration of the while loop in Algorithm 4 takes 𝒪((n2+||n)4)𝒪superscriptsuperscript𝑛2𝑛4\mathcal{O}((n^{2}+|\mathcal{R}|n)^{4})caligraphic_O ( ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 4 end_POSTSUPERSCRIPT ) time.

We now bound the total time in terms of the size of final set of rec-packs \mathcal{R}caligraphic_R.

Lemma 4.11.

If the final set of rec-packs from Algorithm 4 is \mathcal{R}caligraphic_R, then the running time is 𝒪(||(n2+||n)4))\mathcal{O}(|\mathcal{R}|\cdot(n^{2}+|\mathcal{R}|n)^{4}))caligraphic_O ( | caligraphic_R | ⋅ ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 4 end_POSTSUPERSCRIPT ) ).

Proof 4.12.

By Lemma 4.9, we know that each while loop iteration takes at most 𝒪((n2+||n)4)𝒪superscriptsuperscript𝑛2𝑛4\mathcal{O}((n^{2}+|\mathcal{R}|n)^{4})caligraphic_O ( ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 4 end_POSTSUPERSCRIPT ) time. As the size of \mathcal{R}caligraphic_R increases at least by one at each iteration, the number of while loop iterations must be bounded by |||\mathcal{R}|| caligraphic_R |, the size of the final rec-pack minimum cover. Therefore, the total time for all while loop iterations is 𝒪(||(n2+||n)4))\mathcal{O}(|\mathcal{R}|\cdot(n^{2}+|\mathcal{R}|n)^{4}))caligraphic_O ( | caligraphic_R | ⋅ ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 4 end_POSTSUPERSCRIPT ) ). As there is only a total overhead of 𝒪(||)𝒪\mathcal{O}(|\mathcal{R}|)caligraphic_O ( | caligraphic_R | ) outside the while loop, the total running time of Algorithm 4 becomes 𝒪(||(n2+||n)4))\mathcal{O}(|\mathcal{R}|\cdot(n^{2}+|\mathcal{R}|n)^{4}))caligraphic_O ( | caligraphic_R | ⋅ ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 4 end_POSTSUPERSCRIPT ) ).

Remark 4.13.

If we only extended our partial solutions by unambiguous squares (and not generate rec-packs from a seed), we would finally have a set of trivial rec-packs (squares) 𝒮𝒮\mathcal{S}caligraphic_S which is a minimum cover of P𝑃Pitalic_P with OPCS (P)=|𝒮|𝑃𝒮(P)=|\mathcal{S}|( italic_P ) = | caligraphic_S |. This would give us an output sensitive algorithm of 𝒪(|𝒮|(n2+|𝒮|n)4))\mathcal{O}(|\mathcal{S}|\cdot(n^{2}+|\mathcal{S}|n)^{4}))caligraphic_O ( | caligraphic_S | ⋅ ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_S | italic_n ) start_POSTSUPERSCRIPT 4 end_POSTSUPERSCRIPT ) )

We now proceed to bound the size of the final set \mathcal{R}caligraphic_R of rec-packs in Algorithm 4.

Lemma 4.14.

If \mathcal{R}caligraphic_R be the final set of rec-packs in Algorithm 4, then ||=𝒪(n2)𝒪superscript𝑛2|\mathcal{R}|=\mathcal{O}(n^{2})| caligraphic_R | = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT )

Proof 4.15.

Let gsubscript𝑔\mathcal{R}_{g}\subseteq\mathcal{R}caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ⊆ caligraphic_R be the set of rec-packs generated from a seed, and let usubscript𝑢\mathcal{R}_{u}\subseteq\mathcal{R}caligraphic_R start_POSTSUBSCRIPT italic_u end_POSTSUBSCRIPT ⊆ caligraphic_R be the set of unambiguous squares appearing as trivial rec-packs in R𝑅Ritalic_R. Therefore, =gusubscript𝑔subscript𝑢\mathcal{R}=\mathcal{R}_{g}\cup\mathcal{R}_{u}caligraphic_R = caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ∪ caligraphic_R start_POSTSUBSCRIPT italic_u end_POSTSUBSCRIPT.

Claim 1.

For any set of squares 𝒮𝒮\mathcal{S}caligraphic_S such that (g)𝒮subscript𝑔𝒮\mathcal{E}(\mathcal{R}_{g})\cup\mathcal{S}caligraphic_E ( caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ) ∪ caligraphic_S covers P𝑃Pitalic_P, we must have |𝒮||u|𝒮subscript𝑢|\mathcal{S}|\geq|\mathcal{R}_{u}|| caligraphic_S | ≥ | caligraphic_R start_POSTSUBSCRIPT italic_u end_POSTSUBSCRIPT |.

Proof 4.16.

Since \mathcal{R}caligraphic_R is a minimum cover (Lemma 4.7), ()=(g)usubscript𝑔subscript𝑢\mathcal{E}(\mathcal{R})=\mathcal{E}(\mathcal{R}_{g})\cup\mathcal{R}_{u}caligraphic_E ( caligraphic_R ) = caligraphic_E ( caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ) ∪ caligraphic_R start_POSTSUBSCRIPT italic_u end_POSTSUBSCRIPT is a minimum cardinality set of squares covering P𝑃Pitalic_P. Therefore, for any set of squares 𝒮superscript𝒮\mathcal{S}^{\prime}caligraphic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT that covers P𝑃Pitalic_P, we must have |𝒮||(g)u|superscript𝒮subscript𝑔subscript𝑢|\mathcal{S}^{\prime}|\geq|\mathcal{E}(\mathcal{R}_{g})\cup\mathcal{R}_{u}|| caligraphic_S start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | ≥ | caligraphic_E ( caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ) ∪ caligraphic_R start_POSTSUBSCRIPT italic_u end_POSTSUBSCRIPT |. In particular, for any set of squares 𝒮𝒮\mathcal{S}caligraphic_S such that (g)𝒮subscript𝑔𝒮\mathcal{E}(\mathcal{R}_{g})\cup\mathcal{S}caligraphic_E ( caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ) ∪ caligraphic_S covers P𝑃Pitalic_P, we must have |(g)𝒮||(g)u|subscript𝑔𝒮subscript𝑔subscript𝑢|\mathcal{E}(\mathcal{R}_{g})\cup\mathcal{S}|\geq|\mathcal{E}(\mathcal{R}_{g})% \cup\mathcal{R}_{u}|| caligraphic_E ( caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ) ∪ caligraphic_S | ≥ | caligraphic_E ( caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ) ∪ caligraphic_R start_POSTSUBSCRIPT italic_u end_POSTSUBSCRIPT |. This means that |𝒮||u|𝒮subscript𝑢|\mathcal{S}|\geq|\mathcal{R}_{u}|| caligraphic_S | ≥ | caligraphic_R start_POSTSUBSCRIPT italic_u end_POSTSUBSCRIPT | (as usubscript𝑢\mathcal{R}_{u}caligraphic_R start_POSTSUBSCRIPT italic_u end_POSTSUBSCRIPT and (g)subscript𝑔\mathcal{E}(\mathcal{R}_{g})caligraphic_E ( caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ) are disjoint).

We now construct such a set of squares 𝒮𝒮\mathcal{S}caligraphic_S of size 𝒪(n2)𝒪superscript𝑛2\mathcal{O}(n^{2})caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ). Let us draw a vertical line and a horizontal line through each vertex v𝑣vitalic_v of P𝑃Pitalic_P. Let us call them vertex induced lines of P𝑃Pitalic_P. As P𝑃Pitalic_P has n𝑛nitalic_n vertices, there are at most n𝑛nitalic_n vertex induced vertical lines and n𝑛nitalic_n vertex induced horizontal lines.

These vertex induced lines form a grid like structure resulting in rectangular grid cells formed between two consecutive vertex induced vertical lines and two consecutive vertex induced horizontal lines. Let abcd𝑎𝑏𝑐𝑑abcditalic_a italic_b italic_c italic_d be a such a rectangular grid cell formed by consecutive vertex induced vertical & horizontal lines, that lies in the interior (possibly overlap** with some of the polygon edges of P𝑃Pitalic_P), as shown in Figure 8. Let a𝑎aitalic_a be the top-left corner, b𝑏bitalic_b be the top-right corner, c𝑐citalic_c be the bottom-right corner and d𝑑ditalic_d be the bottom left corner. Without loss of generality, let the rectangle abcd𝑎𝑏𝑐𝑑abcditalic_a italic_b italic_c italic_d have its vertical sides no longer than the horizontal sides (i.e. length is along the x𝑥xitalic_x-axis). We now present a method to cover the entire rectangular region abcd𝑎𝑏𝑐𝑑abcditalic_a italic_b italic_c italic_d (possibly covering some more portion of the interior of the polygon) with at most 5555 more valid squares (if we consider gsubscript𝑔\mathcal{R}_{g}caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT to be already placed).

Refer to caption
Figure 8: Defining the rectangular region abcd𝑎𝑏𝑐𝑑abcditalic_a italic_b italic_c italic_d

Consider the two consecutive vertex induced vertical lines l1,l2subscript𝑙1subscript𝑙2l_{1},l_{2}italic_l start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_l start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT, one passing through a,d𝑎𝑑a,ditalic_a , italic_d and the other passing through b,c𝑏𝑐b,citalic_b , italic_c. There cannot be any vertex v𝑣vitalic_v of P𝑃Pitalic_P lying strictly between these two lines (otherwise, these would not be adjacent vertex induced lines). As abcd𝑎𝑏𝑐𝑑abcditalic_a italic_b italic_c italic_d lies inside P𝑃Pitalic_P, the following must hold (Figure 9(a)):

Refer to caption
(a) The edges e1,e2subscript𝑒1subscript𝑒2e_{1},e_{2}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT
Refer to caption
(b) Covering of abcd𝑎𝑏𝑐𝑑abcditalic_a italic_b italic_c italic_d
Figure 9: 3333 more squares cover abcd𝑎𝑏𝑐𝑑abcditalic_a italic_b italic_c italic_d
  • There must be a horizontal polygon edge e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT of P𝑃Pitalic_P that intersects both l1subscript𝑙1l_{1}italic_l start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and l2subscript𝑙2l_{2}italic_l start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT (possibly at its endpoint), and that either overlaps with the line segment ab𝑎𝑏abitalic_a italic_b or lies above ab𝑎𝑏abitalic_a italic_b.

  • There must be a horizontal polygon edge e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT of P𝑃Pitalic_P that intersects both l1subscript𝑙1l_{1}italic_l start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and l2subscript𝑙2l_{2}italic_l start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT (possibly at its endpoint), and that either overlaps with the line segment cd𝑐𝑑cditalic_c italic_d or lies under cd𝑐𝑑cditalic_c italic_d.

  • The rectangular region enclosed by e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT, l1subscript𝑙1l_{1}italic_l start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, l2subscript𝑙2l_{2}italic_l start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT entirely lies inside the polygon P𝑃Pitalic_P.

Let δ𝛿\deltaitalic_δ denote the vertical distance between e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT. Further, if ei¯¯subscript𝑒𝑖\overline{e_{i}}over¯ start_ARG italic_e start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT end_ARG is the length of an edge eisubscript𝑒𝑖e_{i}italic_e start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT, then e1¯,e2¯ab¯¯subscript𝑒1¯subscript𝑒2¯𝑎𝑏\overline{e_{1}},\overline{e_{2}}\geq\overline{ab}over¯ start_ARG italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT end_ARG , over¯ start_ARG italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT end_ARG ≥ over¯ start_ARG italic_a italic_b end_ARG (e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT intersect both l1subscript𝑙1l_{1}italic_l start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, l2subscript𝑙2l_{2}italic_l start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT). We now discuss the following cases.

Refer to caption
Figure 10: Defining Sl,Sr,SL,SRsubscript𝑆𝑙subscript𝑆𝑟subscript𝑆𝐿subscript𝑆𝑅S_{l},S_{r},S_{L},S_{R}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT , italic_S start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT , italic_S start_POSTSUBSCRIPT italic_L end_POSTSUBSCRIPT , italic_S start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT in the strip Y𝑌Yitalic_Y
  • Case I: 5δab¯5δ¯ab5\delta\geq\overline{ab}5 italic_δ ≥ over¯ start_ARG italic_a italic_b end_ARG. In this case, we can draw at most three δ×δ𝛿𝛿\delta\times\deltaitalic_δ × italic_δ squares which cover the entire rectangular region enclosed by e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT, l1subscript𝑙1l_{1}italic_l start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, l2subscript𝑙2l_{2}italic_l start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT and hence covers abcd𝑎𝑏𝑐𝑑abcditalic_a italic_b italic_c italic_d (Figure 9(b)). Therefore abcd𝑎𝑏𝑐𝑑abcditalic_a italic_b italic_c italic_d can be covered by at most 3333 squares.

  • Case II: 5δ<ab¯5δ¯ab5\delta<\overline{ab}5 italic_δ < over¯ start_ARG italic_a italic_b end_ARG. In this case, there must be a (unique) strip Y𝑌Yitalic_Y that is enclosed within e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, e2subscript𝑒2e_{2}italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT (Section 2). Y𝑌Yitalic_Y must have an aspect ratio of more than 5555. Let S0subscript𝑆0S_{0}\in\mathcal{R}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∈ caligraphic_R be the first δ×δ𝛿𝛿\delta\times\deltaitalic_δ × italic_δ square placed that covers some portion in Y𝑌Yitalic_Y when Algorithm 4 is run on P𝑃Pitalic_P (there would always be a δ×δ𝛿𝛿\delta\times\deltaitalic_δ × italic_δ square placed in Y𝑌Yitalic_Y as no square with smaller dimension can generate a rec-pack as a seed that overlaps with Y𝑌Yitalic_Y, and all maximal squares covering any block which is at a distance of more than δ𝛿\deltaitalic_δ from the left & right boundary of Y𝑌Yitalic_Y, have dimension δ×δ𝛿𝛿\delta\times\deltaitalic_δ × italic_δ). Let Slsubscript𝑆𝑙S_{l}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT be the left most δ×δ𝛿𝛿\delta\times\deltaitalic_δ × italic_δ square lying inside Y𝑌Yitalic_Y and SLsubscript𝑆𝐿S_{L}italic_S start_POSTSUBSCRIPT italic_L end_POSTSUBSCRIPT be the square obtained by reflecting Slsubscript𝑆𝑙S_{l}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT about its right side. Similarly, let Srsubscript𝑆𝑟S_{r}italic_S start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT be the right most δ×δ𝛿𝛿\delta\times\deltaitalic_δ × italic_δ square lying inside Y𝑌Yitalic_Y and SRsubscript𝑆𝑅S_{R}italic_S start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT be the square obtained by reflecting Srsubscript𝑆𝑟S_{r}italic_S start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT about its left side (Figure 10). Since the aspect ratio of Y𝑌Yitalic_Y is more than 5555, Slsubscript𝑆𝑙S_{l}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT,SLsubscript𝑆𝐿S_{L}italic_S start_POSTSUBSCRIPT italic_L end_POSTSUBSCRIPT,SRsubscript𝑆𝑅S_{R}italic_S start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT,Srsubscript𝑆𝑟S_{r}italic_S start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT are pairwise non-overlap** δ×δ𝛿𝛿\delta\times\deltaitalic_δ × italic_δ squares that inside Y. Moreover since Y𝑌Yitalic_Y is a strip with δ𝛿\deltaitalic_δ as the length of the shorter side, there cannot be a valid square that covers some region outside Y𝑌Yitalic_Y as well as some region inside Y𝑌Yitalic_Y which is not covered by Slsubscript𝑆𝑙S_{l}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT,Srsubscript𝑆𝑟S_{r}italic_S start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT. Consider the portion Ylsubscript𝑌𝑙Y_{l}italic_Y start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT of Y𝑌Yitalic_Y lying to the left hand side of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT. Either Ylsubscript𝑌𝑙Y_{l}italic_Y start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT is entirely covered by Slsubscript𝑆𝑙S_{l}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT and SLsubscript𝑆𝐿S_{L}italic_S start_POSTSUBSCRIPT italic_L end_POSTSUBSCRIPT, or the horizontal distance between the left side of S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT and the left side of Ylsubscript𝑌𝑙Y_{l}italic_Y start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT is more than 2δ2𝛿2\delta2 italic_δ. Even if the second case occurs, then Algorithm 1 must generate Rlgsubscript𝑅𝑙subscript𝑔R_{l}\in\mathcal{R}_{g}italic_R start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT ∈ caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT as the rec-pack lying to the left of the seed S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT which intersects with SLsubscript𝑆𝐿S_{L}italic_S start_POSTSUBSCRIPT italic_L end_POSTSUBSCRIPT (as S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT is the first square placed in the strip Y𝑌Yitalic_Y and hence generates a rec-pack Rlsubscript𝑅𝑙R_{l}italic_R start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT with the left side at most 2δ2𝛿2\delta2 italic_δ distance from the left side of Y𝑌Yitalic_Y, and hence Rlsubscript𝑅𝑙R_{l}italic_R start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT cannot intersect with any square or re-pack in the partial solution found before S0subscript𝑆0S_{0}italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT was added, Section 4.3). This means Ylsubscript𝑌𝑙Y_{l}italic_Y start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT is entirely covered by Slsubscript𝑆𝑙S_{l}italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT, SLsubscript𝑆𝐿S_{L}italic_S start_POSTSUBSCRIPT italic_L end_POSTSUBSCRIPT and possibly some rec-pack in gsubscript𝑔\mathcal{R}_{g}caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT. Similarly, the portion Yrsubscript𝑌𝑟Y_{r}italic_Y start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT of Y𝑌Yitalic_Y to the right of S𝑆Sitalic_S is entirely covered by Srsubscript𝑆𝑟S_{r}italic_S start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT, SRsubscript𝑆𝑅S_{R}italic_S start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT and possibly some rec-pack in gsubscript𝑔\mathcal{R}_{g}caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT. Therefore the entire region of Y𝑌Yitalic_Y (and hence abcd𝑎𝑏𝑐𝑑abcditalic_a italic_b italic_c italic_d) is covered by gsubscript𝑔\mathcal{R}_{g}caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT and 5555 more squares, {S0,Sl,SL,SR,Sr}subscript𝑆0subscript𝑆𝑙subscript𝑆𝐿subscript𝑆𝑅subscript𝑆𝑟\{S_{0},S_{l},S_{L},S_{R},S_{r}\}{ italic_S start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_S start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT , italic_S start_POSTSUBSCRIPT italic_L end_POSTSUBSCRIPT , italic_S start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT , italic_S start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT }.

If we repeat the same process for each rectangular region abcd𝑎𝑏𝑐𝑑abcditalic_a italic_b italic_c italic_d formed by consecutive vertex induced lines, then we can cover up the entire polygon P𝑃Pitalic_P using just 5555 more squares for each such rectangular region lying inside P𝑃Pitalic_P (along with the rec-packs in Rgsubscript𝑅𝑔R_{g}italic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT). However, the total number of such rectangular region is 𝒪(n2)𝒪superscript𝑛2\mathcal{O}(n^{2})caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ). Therefore, if 𝒮𝒮\mathcal{S}caligraphic_S is the set of all such squares (at most 5555 of them per rectangular region abcd𝑎𝑏𝑐𝑑abcditalic_a italic_b italic_c italic_d), then |𝒮|=𝒪(n2)𝒮𝒪superscript𝑛2|\mathcal{S}|=\mathcal{O}(n^{2})| caligraphic_S | = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) and (g)Ssubscript𝑔𝑆\mathcal{E}(\mathcal{R}_{g})\cup Scaligraphic_E ( caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ) ∪ italic_S is a set of squares covering the entire polygon P𝑃Pitalic_P. As discussed in 1, we have |u||𝒮|=𝒪(n2)subscript𝑢𝒮𝒪superscript𝑛2|\mathcal{R}_{u}|\leq|\mathcal{S}|=\mathcal{O}(n^{2})| caligraphic_R start_POSTSUBSCRIPT italic_u end_POSTSUBSCRIPT | ≤ | caligraphic_S | = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ).

Moreover, as for each unambiguous square S𝑆Sitalic_S, Algorithm 4 adds at most four rec-packs with seed S𝑆Sitalic_S, the number of rec-packs generated from a seed can be at most 4444 times the number of unambiguous squares. Therefore |g|4|u|=𝒪(n2)subscript𝑔4subscript𝑢𝒪superscript𝑛2|\mathcal{R}_{g}|\leq 4|\mathcal{R}_{u}|=\mathcal{O}(n^{2})| caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT | ≤ 4 | caligraphic_R start_POSTSUBSCRIPT italic_u end_POSTSUBSCRIPT | = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ).

Hence, ||=|g|+|u|=𝒪(n2)subscript𝑔subscript𝑢𝒪superscript𝑛2|\mathcal{R}|=|\mathcal{R}_{g}|+|\mathcal{R}_{u}|=\mathcal{O}(n^{2})| caligraphic_R | = | caligraphic_R start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT | + | caligraphic_R start_POSTSUBSCRIPT italic_u end_POSTSUBSCRIPT | = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ).

This allows us to derive the algorithmic running time purely in terms of n𝑛nitalic_n.

Theorem 4.17.

For an orthogonal polygon P𝑃Pitalic_P with n𝑛nitalic_n vertices, Algorithm 4 outputs OPCS(P)OPCS𝑃\textsc{OPCS}(P)OPCS ( italic_P ) in 𝒪(n14)𝒪superscript𝑛14\mathcal{O}(n^{14})caligraphic_O ( italic_n start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ) time.

Proof 4.18.

The correctness of the algorithm is due to Lemma 4.7. For the analysis of the running time of Algorithm 4, we substitute the bound of ||=𝒪(n2)𝒪superscript𝑛2|\mathcal{R}|=\mathcal{O}(n^{2})| caligraphic_R | = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) obtained in Lemma 4.14 in the time complexity of Lemma 4.11. Therefore,

Running time of Algorithm 4 =𝒪(||(n2+||n)4))\displaystyle=\mathcal{O}(|\mathcal{R}|\cdot(n^{2}+|\mathcal{R}|n)^{4}))= caligraphic_O ( | caligraphic_R | ⋅ ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + | caligraphic_R | italic_n ) start_POSTSUPERSCRIPT 4 end_POSTSUPERSCRIPT ) ) [Lemma 4.11]delimited-[]Lemma 4.11\displaystyle[\text{\lx@cref{creftype~refnum}{lem:time-square-count}}][ ]
=𝒪(n2(n2+n2n)4))\displaystyle=\mathcal{O}(n^{2}\cdot(n^{2}+n^{2}\cdot n)^{4}))= caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ⋅ ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ⋅ italic_n ) start_POSTSUPERSCRIPT 4 end_POSTSUPERSCRIPT ) ) [||=𝒪(n2),Lemma 4.14]delimited-[]𝒪superscript𝑛2Lemma 4.14\displaystyle[|\mathcal{R}|=\mathcal{O}(n^{2}),\text{\lx@cref{creftype~refnum}% {lem:R-bound}}][ | caligraphic_R | = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) , ]
=𝒪(n2(n3)4)=𝒪(n14)absent𝒪superscript𝑛2superscriptsuperscript𝑛34𝒪superscript𝑛14\displaystyle=\mathcal{O}(n^{2}\cdot(n^{3})^{4})=\mathcal{O}(n^{14})= caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ⋅ ( italic_n start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT 4 end_POSTSUPERSCRIPT ) = caligraphic_O ( italic_n start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT )

This completes the proof.

Remark 4.19.

To report the solution instead of just the count, we could return the set \mathcal{R}caligraphic_R of rec-packs in Algorithm 4. Here, rec-packs are used to efficiently encode multiple squares (potentially exponentially many) into constant sized information.

Remark 4.20.

Here we assumed that arithmetic operations take constant time. However, even if each arithmetic operation took polynomial time, the total runtime would still be polynomial as there are only polynomially many arithmetic operations done.

5 Improved Algorithm for Orthogonal Polygons with k𝑘kitalic_k Knobs

In this section, we design an algorithm for p𝑝pitalic_p-OPCS where along with the number n𝑛nitalic_n of vertices of the input orthogonal polygon we also have the parameter k𝑘kitalic_k, which is the number of knobs (Definition 2.4) in P𝑃Pitalic_P. This algorithm works better than Algorithm 4 when are input instances are such that k=o(n13/14)𝑘𝑜superscript𝑛1314k=o(n^{13/14})italic_k = italic_o ( italic_n start_POSTSUPERSCRIPT 13 / 14 end_POSTSUPERSCRIPT ).

First, we define a special structure called separating squares and crucially use it to construct our recursive algorithm. We solve the base cases of the recursive algorithm using Algorithm 4.

5.1 More on Structure of Minimum Covering

We define our crucial structure of a separating maximal corner square (or simply, a separating square) and use the definition to further explore properties of non-knob convex vertices (Definition 2.5).

Definition 5.1 (Separating Maximal Corner Square).

Let P𝑃Pitalic_P be an orthogonal polygon. For a convex vertex v𝑣vitalic_v, MCS(v)𝑀𝐶𝑆𝑣MCS(v)italic_M italic_C italic_S ( italic_v ) is said to be a separating maximal corner square or simply a separating square if the region inside P𝑃Pitalic_P but not inside MCS(v)𝑀𝐶𝑆𝑣MCS(v)italic_M italic_C italic_S ( italic_v ) is not a connected region (Figure 11).

Refer to caption
(a) A separating square
Refer to caption
(b) A maximal square which is not a separating square
Figure 11: Separating Maximal Corner Square

This gives us the following result.

Lemma 5.2.

If visubscript𝑣𝑖v_{i}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT is a non-knob convex vertex (Definition 2.5) of an orthogonal polygon P𝑃Pitalic_P, then MCS(vi)𝑀𝐶𝑆subscript𝑣𝑖MCS(v_{i})italic_M italic_C italic_S ( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) is a separating square which separates vi2subscript𝑣𝑖2v_{i-2}italic_v start_POSTSUBSCRIPT italic_i - 2 end_POSTSUBSCRIPT and vi+2subscript𝑣𝑖2v_{i+2}italic_v start_POSTSUBSCRIPT italic_i + 2 end_POSTSUBSCRIPT.

Proof 5.3.

If visubscript𝑣𝑖v_{i}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT is a non-knob convex vertex, then any curve lying in P𝑃Pitalic_P and having end points at vi+2subscript𝑣𝑖2v_{i+2}italic_v start_POSTSUBSCRIPT italic_i + 2 end_POSTSUBSCRIPT and vi2subscript𝑣𝑖2v_{i-2}italic_v start_POSTSUBSCRIPT italic_i - 2 end_POSTSUBSCRIPT must intersect MCS(vi)𝑀𝐶𝑆subscript𝑣𝑖MCS(v_{i})italic_M italic_C italic_S ( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) and hence MCS(vi)𝑀𝐶𝑆subscript𝑣𝑖MCS(v_{i})italic_M italic_C italic_S ( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) must be a separating square separating vi2subscript𝑣𝑖2v_{i-2}italic_v start_POSTSUBSCRIPT italic_i - 2 end_POSTSUBSCRIPT and vi+2subscript𝑣𝑖2v_{i+2}italic_v start_POSTSUBSCRIPT italic_i + 2 end_POSTSUBSCRIPT.

Remark 5.4.

Given an orthogonal polygon P𝑃Pitalic_P, we can find a non-knob convex vertex in 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) time (if it exists) by a simple check on all vertices (or report no non-knob convex vertex exist).

We now use this to recursively obtain simpler instances from an input instance P𝑃Pitalic_P.

5.2 Recursion with Separating Squares

Recall that a separating square separates an input orthogonal polygon P𝑃Pitalic_P into unconnected uncovered regions. We will construct two polygons from these uncovered polygons which still preserves the information about OPCS(P)OPCS𝑃\textsc{OPCS}(P)OPCS ( italic_P ). First, we need the following terminology.

Definition 5.5.

Given an orthogonal polygon P𝑃Pitalic_P, let S𝑆Sitalic_S be a (maximal) separating square which is a maximal square due to a non-knob convex vertex of P𝑃Pitalic_P. We classify the set of connected components of P𝑃Pitalic_P that are separated by S𝑆Sitalic_S as follows,

  • Qtsubscript𝑄𝑡Q_{t}italic_Q start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT be the connected components separated by S𝑆Sitalic_S that only intersect at more than one point with the top side of S𝑆Sitalic_S (and no other side).

  • Qbsubscript𝑄𝑏Q_{b}italic_Q start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT be the connected components separated by S𝑆Sitalic_S that only intersect at more than one point with the bottom side of S𝑆Sitalic_S (and no other side).

  • Qlsubscript𝑄𝑙Q_{l}italic_Q start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT be the connected components separated by S𝑆Sitalic_S that only intersect at more than one point with the left side of S𝑆Sitalic_S (and no other side).

  • Qrsubscript𝑄𝑟Q_{r}italic_Q start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT be the connected components separated by S𝑆Sitalic_S that only intersect at more than one point with the right side of S𝑆Sitalic_S (and no other side).

  • Qtrsubscript𝑄𝑡𝑟Q_{tr}italic_Q start_POSTSUBSCRIPT italic_t italic_r end_POSTSUBSCRIPT be the connected components separated by S𝑆Sitalic_S that only intersect at more than one point with the top side and right side of S𝑆Sitalic_S and also at the top-right corner of S𝑆Sitalic_S.

  • Qbrsubscript𝑄𝑏𝑟Q_{br}italic_Q start_POSTSUBSCRIPT italic_b italic_r end_POSTSUBSCRIPT be the connected components separated by S𝑆Sitalic_S that only intersect at more than one point with the bottom side and right side of S𝑆Sitalic_S and also at the bottom-right corner of S𝑆Sitalic_S.

  • Qtlsubscript𝑄𝑡𝑙Q_{tl}italic_Q start_POSTSUBSCRIPT italic_t italic_l end_POSTSUBSCRIPT be the connected components separated by S𝑆Sitalic_S that only intersect at more than one point with the top side and left side of S𝑆Sitalic_S and also at the top-left corner of S𝑆Sitalic_S.

  • Qblsubscript𝑄𝑏𝑙Q_{bl}italic_Q start_POSTSUBSCRIPT italic_b italic_l end_POSTSUBSCRIPT be the connected components separated by S𝑆Sitalic_S that only intersect at more than one point with the left side and right side of S𝑆Sitalic_S and also at the bottom-left corner of S𝑆Sitalic_S.

  • Qtrbsubscript𝑄𝑡𝑟𝑏Q_{trb}italic_Q start_POSTSUBSCRIPT italic_t italic_r italic_b end_POSTSUBSCRIPT be the connected components separated by S𝑆Sitalic_S that only intersect at more than one point with the top side, bottom side and right side of S𝑆Sitalic_S and also at the top-right corner and the bottom-right corner of S𝑆Sitalic_S.

  • Qtlbsubscript𝑄𝑡𝑙𝑏Q_{tlb}italic_Q start_POSTSUBSCRIPT italic_t italic_l italic_b end_POSTSUBSCRIPT be the connected components separated by S𝑆Sitalic_S that only intersect at more than one point with the top side, bottom side and left side of S𝑆Sitalic_S and also at the top-left corner and the bottom-left corner of S𝑆Sitalic_S.

  • Qrblsubscript𝑄𝑟𝑏𝑙Q_{rbl}italic_Q start_POSTSUBSCRIPT italic_r italic_b italic_l end_POSTSUBSCRIPT be the connected components separated by S𝑆Sitalic_S that only intersect at more than one point with the right side, bottom side and left side of S𝑆Sitalic_S and also at the bottom-right corner and the bottom-left corner of S𝑆Sitalic_S.

  • Qrtlsubscript𝑄𝑟𝑡𝑙Q_{rtl}italic_Q start_POSTSUBSCRIPT italic_r italic_t italic_l end_POSTSUBSCRIPT be the connected components separated by S𝑆Sitalic_S that only intersect at more than one point with the right side, top side and left side of S𝑆Sitalic_S and also at the top-right corner and the top-left corner of S𝑆Sitalic_S.

Let 𝒬={Qt,Qb,Qr,Ql,Qtr,Qbr,Qtl,Qbl,Qtrb,Qtlb,Qrbl,Qrtl}superscript𝒬subscript𝑄𝑡subscript𝑄𝑏subscript𝑄𝑟subscript𝑄𝑙subscript𝑄𝑡𝑟subscript𝑄𝑏𝑟subscript𝑄𝑡𝑙subscript𝑄𝑏𝑙subscript𝑄𝑡𝑟𝑏subscript𝑄𝑡𝑙𝑏subscript𝑄𝑟𝑏𝑙subscript𝑄𝑟𝑡𝑙\mathcal{Q}^{\prime}=\{Q_{t},Q_{b},Q_{r},Q_{l},Q_{tr},Q_{br},Q_{tl},Q_{bl},Q_{% trb},Q_{tlb},Q_{rbl},Q_{rtl}\}caligraphic_Q start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = { italic_Q start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_t italic_r end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_b italic_r end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_t italic_l end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_b italic_l end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_t italic_r italic_b end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_t italic_l italic_b end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_r italic_b italic_l end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_r italic_t italic_l end_POSTSUBSCRIPT } and let 𝒬={Q𝒬|Q is nonempty}𝒬conditional-set𝑄superscript𝒬𝑄 is nonempty\mathcal{Q}=\{Q\in\mathcal{Q}^{\prime}|Q\text{ is nonempty}\}caligraphic_Q = { italic_Q ∈ caligraphic_Q start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | italic_Q is nonempty }.

Lemma 5.6.

Given an orthogonal polygon P𝑃Pitalic_P, let S𝑆Sitalic_S be a (maximal) separating square which is a maximal square due to a non-knob convex vertex of P𝑃Pitalic_P and 𝒬𝒬\mathcal{Q}caligraphic_Q be as defined in 5.5. Then the following must hold true.

  • Q𝒬for-all𝑄𝒬\forall Q\in\mathcal{Q}∀ italic_Q ∈ caligraphic_Q, SQ𝑆𝑄S\cup Qitalic_S ∪ italic_Q is a connected orthogonal polygon without holes.

  • OPCS(P)=(Q𝒬OPCS(SQ))(|𝒬|1)OPCS𝑃subscript𝑄𝒬OPCS𝑆𝑄𝒬1\text{{OPCS}}(P)=\big{(}\sum\limits_{Q\in\mathcal{Q}}\text{{OPCS}}(S\cup Q)% \big{)}-(|\mathcal{Q}|-1)OPCS ( italic_P ) = ( ∑ start_POSTSUBSCRIPT italic_Q ∈ caligraphic_Q end_POSTSUBSCRIPT OPCS ( italic_S ∪ italic_Q ) ) - ( | caligraphic_Q | - 1 )

Refer to caption
Figure 12: OPCS(P)=(Q𝒬OPCS(SQ))(|𝒬|1)OPCS𝑃subscript𝑄𝒬OPCS𝑆𝑄𝒬1\text{{OPCS}}(P)=\big{(}\sum\limits_{Q\in\mathcal{Q}}\text{{OPCS}}(S\cup Q)% \big{)}-(|\mathcal{Q}|-1)OPCS ( italic_P ) = ( ∑ start_POSTSUBSCRIPT italic_Q ∈ caligraphic_Q end_POSTSUBSCRIPT OPCS ( italic_S ∪ italic_Q ) ) - ( | caligraphic_Q | - 1 ) with 𝒬={Ql,Qrtl,Qr,Qbl,Qb}𝒬subscript𝑄𝑙subscript𝑄𝑟𝑡𝑙subscript𝑄𝑟subscript𝑄𝑏𝑙subscript𝑄𝑏\mathcal{Q}=\{Q_{l},Q_{rtl},Q_{r},Q_{bl},Q_{b}\}caligraphic_Q = { italic_Q start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_r italic_t italic_l end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_b italic_l end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT } in this case
Proof 5.7.

First, we observe that since S𝑆Sitalic_S is a separating square which is a maximal square due to a non-knob convex vertex v𝑣vitalic_v, there cannot be a component that intersects with three vertices of S𝑆Sitalic_S (otherwise S𝑆Sitalic_S would not be maximal and could be grown by fixing a corner at v𝑣vitalic_v).

To see that for all Q𝒬𝑄𝒬Q\in\mathcal{Q}italic_Q ∈ caligraphic_Q, SQ𝑆𝑄S\cup Qitalic_S ∪ italic_Q is connected, it is sufficient to observe that we can find a curve in the strict interior of SQ𝑆𝑄S\cup Qitalic_S ∪ italic_Q from any point t1subscript𝑡1t_{1}italic_t start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT in its interior to any point t2subscript𝑡2t_{2}italic_t start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT in its interior; either lying inside a single connected component of Q𝑄Qitalic_Q (if t1,t2subscript𝑡1subscript𝑡2t_{1},t_{2}italic_t start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_t start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT are in that component), or through S𝑆Sitalic_S (if t1,t2subscript𝑡1subscript𝑡2t_{1},t_{2}italic_t start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_t start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT are in different components of Q𝑄Qitalic_Q). Further, QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S cannot have holes as P𝑃Pitalic_P does not have holes.

Moreover, we observe that there cannot be a valid square of P𝑃Pitalic_P that covers two different points from distinct Q,Q𝒬𝑄superscript𝑄𝒬Q,Q^{\prime}\in\mathcal{Q}italic_Q , italic_Q start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ∈ caligraphic_Q (this would contradict the maximality of S𝑆Sitalic_S). Also, in a minimum covering with S𝑆Sitalic_S as one of the squares, all other valid squares must cover at least one point from the interior of exactly one Q𝒬𝑄𝒬Q\in\mathcal{Q}italic_Q ∈ caligraphic_Q (otherwise this square would be completely inside S𝑆Sitalic_S, hence redundant). Therefore if P𝑃Pitalic_P is covered using a set 𝒮𝒮\mathcal{S}caligraphic_S of C𝐶Citalic_C squares including S𝑆Sitalic_S, we can cover QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S using the squares in 𝒮𝒮\mathcal{S}caligraphic_S that cover some part of Q𝑄Qitalic_Q and the square S𝑆Sitalic_S itself. If we do this for all Q𝒬𝑄𝒬Q\in\mathcal{Q}italic_Q ∈ caligraphic_Q this uses C+(|𝒬|1)𝐶𝒬1C+(|\mathcal{Q}|-1)italic_C + ( | caligraphic_Q | - 1 ) squares as S𝑆Sitalic_S is in this cover of all |𝒬|𝒬|\mathcal{Q}|| caligraphic_Q | instances QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S, but appear only once in 𝒮𝒮\mathcal{S}caligraphic_S (other squares in 𝒮𝒮\mathcal{S}caligraphic_S appear exactly once in a cover of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S for exactly one Q𝒬𝑄𝒬Q\in\mathcal{Q}italic_Q ∈ caligraphic_Q). Since we start with a minimum cover of P𝑃Pitalic_P and find a valid cover of all QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S polygons with exactly (|𝒬|1)𝒬1(|\mathcal{Q}|-1)( | caligraphic_Q | - 1 ) more squares in total, we get,

OPCS(P)(Q𝒬OPCS(SQ))(|𝒬|1)OPCS𝑃subscript𝑄𝒬OPCS𝑆𝑄𝒬1\text{{OPCS}}(P)\geq\big{(}\sum\limits_{Q\in\mathcal{Q}}\text{{OPCS}}(S\cup Q)% \big{)}-(|\mathcal{Q}|-1)OPCS ( italic_P ) ≥ ( ∑ start_POSTSUBSCRIPT italic_Q ∈ caligraphic_Q end_POSTSUBSCRIPT OPCS ( italic_S ∪ italic_Q ) ) - ( | caligraphic_Q | - 1 )

Given any minimum covering of all QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S, all such instances must contain S𝑆Sitalic_S (as S𝑆Sitalic_S is a maximum corner square in both). So we superimpose these coverings and delete all but one S𝑆Sitalic_S to get a covering of P𝑃Pitalic_P. This time we started from a minimal covering of the individual QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S polygons to get a valid covering of P𝑃Pitalic_P. Including this with the rest of the result, we obtain

OPCS(P)=(Q𝒬OPCS(SQ))(|𝒬|1)OPCS𝑃subscript𝑄𝒬OPCS𝑆𝑄𝒬1\text{{OPCS}}(P)=\big{(}\sum\limits_{Q\in\mathcal{Q}}\text{{OPCS}}(S\cup Q)% \big{)}-(|\mathcal{Q}|-1)OPCS ( italic_P ) = ( ∑ start_POSTSUBSCRIPT italic_Q ∈ caligraphic_Q end_POSTSUBSCRIPT OPCS ( italic_S ∪ italic_Q ) ) - ( | caligraphic_Q | - 1 )
Remark 5.8.

|𝒬||𝒬|=12𝒬superscript𝒬12|\mathcal{Q}|\leq|\mathcal{Q}^{\prime}|=12| caligraphic_Q | ≤ | caligraphic_Q start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | = 12 in Lemma 5.6. Moreover, there are combinations (like Qtrsubscript𝑄𝑡𝑟Q_{tr}italic_Q start_POSTSUBSCRIPT italic_t italic_r end_POSTSUBSCRIPT and Qtrbsubscript𝑄𝑡𝑟𝑏Q_{trb}italic_Q start_POSTSUBSCRIPT italic_t italic_r italic_b end_POSTSUBSCRIPT) that cannot both be non-empty in P𝑃Pitalic_P.

We now prove a crucial result that such a recursive step does not increase the number of knobs in each individual instance QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S.

Lemma 5.9.

Let S𝑆Sitalic_S be a (maximal) separating square which is a maximal square due to a non-knob convex vertex of an orthogonal polygon P𝑃Pitalic_P with n𝑛nitalic_n vertices and k𝑘kitalic_k knobs. Let 𝒬𝒬\mathcal{Q}caligraphic_Q be defined as in Definition 5.5. Then, Q𝒬,(QS)for-all𝑄𝒬𝑄𝑆\forall Q\in\mathcal{Q},(Q\cup S)∀ italic_Q ∈ caligraphic_Q , ( italic_Q ∪ italic_S ) is an orthogonal polygon without holes with at most n𝑛nitalic_n vertices and at most k𝑘kitalic_k knobs. Moreover, any vertex in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S which is a corner of S𝑆Sitalic_S is part of a knob in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S along a side of S𝑆Sitalic_S.

Proof 5.10.

Lemma 5.6 already proves that Q𝒬,(QS)for-all𝑄𝒬𝑄𝑆\forall Q\in\mathcal{Q},(Q\cup S)∀ italic_Q ∈ caligraphic_Q , ( italic_Q ∪ italic_S ) is an orthogonal polygon without holes. Further, the number of vertices can only decrease because the only time a new vertex (vertex not in P𝑃Pitalic_P) would be introduced is when S𝑆Sitalic_S already distributes the existing vertices of P𝑃Pitalic_P in each of (QS),Q𝒬𝑄𝑆𝑄𝒬(Q\cup S),Q\in\mathcal{Q}( italic_Q ∪ italic_S ) , italic_Q ∈ caligraphic_Q (causing no total increase in the number of vertices in (QS)𝑄𝑆(Q\cup S)( italic_Q ∪ italic_S ) than in P𝑃Pitalic_P). We now prove that Q𝒬,QPfor-all𝑄𝒬𝑄𝑃\forall Q\in\mathcal{Q},Q\cup P∀ italic_Q ∈ caligraphic_Q , italic_Q ∪ italic_P has at most k𝑘kitalic_k knobs.

Consider QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S for some Q𝒬𝑄𝒬Q\in\mathcal{Q}italic_Q ∈ caligraphic_Q. Without loss of generality assume Q𝑄Qitalic_Q is either Qlsubscript𝑄𝑙Q_{l}italic_Q start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT or Qtlsubscript𝑄𝑡𝑙Q_{tl}italic_Q start_POSTSUBSCRIPT italic_t italic_l end_POSTSUBSCRIPT or Qtlb𝑄𝑡𝑙𝑏Q{tlb}italic_Q italic_t italic_l italic_b (all other cases have symmetric arguments). We now show that for all knobs in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S, there is a distinct knob in P𝑃Pitalic_P (which would show that QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S has at most k𝑘kitalic_k knobs if P𝑃Pitalic_P has at most k𝑘kitalic_k knobs. Clearly any (distinct) knob (u1,u2)𝑢1𝑢2(u1,u2)( italic_u 1 , italic_u 2 ) of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S such that u1𝑢1u1italic_u 1, u2subscript𝑢2u_{2}italic_u start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT are not corners in S𝑆Sitalic_S, (u1,u2)subscript𝑢1subscript𝑢2(u_{1},u_{2})( italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_u start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) must be a (distinct) knob in P𝑃Pitalic_P (knob in Q𝑄Qitalic_Q, in particular). Hence we only need to consider knobs which (u1,u2)subscript𝑢1subscript𝑢2(u_{1},u_{2})( italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_u start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S such that either u1subscript𝑢1u_{1}italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT or u2subscript𝑢2u_{2}italic_u start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT is a vertex of S𝑆Sitalic_S. Without loss of generality, we assume that u1subscript𝑢1u_{1}italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT is a corner in S𝑆Sitalic_S.

  • Case I: Q=QtlbQsubscriptQtlbQ=Q_{tlb}italic_Q = italic_Q start_POSTSUBSCRIPT italic_t italic_l italic_b end_POSTSUBSCRIPT. In this case the top-left and the bottom-left corners of S𝑆Sitalic_S completely lie inside Q𝑄Qitalic_Q and hence are not vertices of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S. Therefore u1subscript𝑢1u_{1}italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT is either the bottom-right corner or the top-right corner of S𝑆Sitalic_S (both are vertices in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S). Without loss of generality, assume u1subscript𝑢1u_{1}italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT to be the top-right corner of S𝑆Sitalic_S. Consider e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT to be the horizontal edge of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S (i.e. the edge overlap** with top edge of S𝑆Sitalic_S) with u1subscript𝑢1u_{1}italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT as a corner. Since Qtlbsubscript𝑄𝑡𝑙𝑏Q_{tlb}italic_Q start_POSTSUBSCRIPT italic_t italic_l italic_b end_POSTSUBSCRIPT intersects with the right corner of S𝑆Sitalic_S, e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT has to shorter than the side length of S𝑆Sitalic_S. As the entire region inside S𝑆Sitalic_S is inside QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S, the other end point of e1subscript𝑒1e_{1}italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT must be a concave vertex. Therefore (u1,u2)e1subscript𝑢1subscript𝑢2subscript𝑒1(u_{1},u_{2})\neq e_{1}( italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_u start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) ≠ italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT. Moreover, as the other end point of the vertical edge of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S from u1subscript𝑢1u_{1}italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT is the bottom-right corner of S𝑆Sitalic_S, u2subscript𝑢2u_{2}italic_u start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT must be the bottom right corner of S𝑆Sitalic_S; (u1,u2)subscript𝑢1subscript𝑢2(u_{1},u_{2})( italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_u start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) must be a left knob (and the only knob) in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S (which proves that all vertices in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S which are corners in S𝑆Sitalic_S are part of knobs in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S, along a side of S𝑆Sitalic_S). Moreover, for this knob (u1,u2)subscript𝑢1subscript𝑢2(u_{1},u_{2})( italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_u start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ), can find a left knob of the region PQ𝑃𝑄P\setminus Qitalic_P ∖ italic_Q (which must be a knob in P𝑃Pitalic_P as PQ𝑃𝑄P\setminus Qitalic_P ∖ italic_Q intersects Q𝑄Qitalic_Q only in top, bottom and right edges). Therefore, in this case, for every knob in SQ𝑆𝑄S\cup Qitalic_S ∪ italic_Q, we can find a distinct knob in P𝑃Pitalic_P.

  • Case II: Q=QtlQsubscriptQtlQ=Q_{tl}italic_Q = italic_Q start_POSTSUBSCRIPT italic_t italic_l end_POSTSUBSCRIPT. We consider four subcases.

    • Case II(a): QQQitalic_Q does not touch the top-right corner or the bottom-left corner of SSSitalic_S. By arguments similar to above, we can show that right side of S𝑆Sitalic_S and the bottom side of S𝑆Sitalic_S are right and bottom knobs of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S (which proves that all vertices in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S which are corners in S𝑆Sitalic_S are part of knobs in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S, along a side of S𝑆Sitalic_S). By a similar argument PQ𝑃𝑄P\setminus Qitalic_P ∖ italic_Q must have a right knob and a bottom knob which are also a right knob and a bottom knob of P𝑃Pitalic_P. Therefore, in this case, for every knob in SQ𝑆𝑄S\cup Qitalic_S ∪ italic_Q, we can find a distinct knob in P𝑃Pitalic_P.

    • Case II(b): QQQitalic_Q touches the bottom-left corner of SSSitalic_S, but not the top-right corner of SSSitalic_S. Similar to before, the right side of S𝑆Sitalic_S is a right knob in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S (which proves that all vertices in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S which are corners in S𝑆Sitalic_S are part of knobs in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S, along a side of S𝑆Sitalic_S) and we can find a right knob in PQ𝑃𝑄P\setminus Qitalic_P ∖ italic_Q which is also a right knob in P𝑃Pitalic_P. However, there can a bottom knob (u1,u2)subscript𝑢1subscript𝑢2(u_{1},u_{2})( italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_u start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S which has its right endpoint u1subscript𝑢1u_{1}italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT as the bottom-right corner of S𝑆Sitalic_S, but u2subscript𝑢2u_{2}italic_u start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT is a convex vertex in Q𝑄Qitalic_Q (and hence in P𝑃Pitalic_P). In this case, either (u1,u2)subscript𝑢1subscript𝑢2(u_{1},u_{2})( italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_u start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) is a bottom knob in P𝑃Pitalic_P (in which case we are done), or there is another vertex u3subscript𝑢3u_{3}italic_u start_POSTSUBSCRIPT 3 end_POSTSUBSCRIPT of P𝑃Pitalic_P such that u1subscript𝑢1u_{1}italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT lies between u2subscript𝑢2u_{2}italic_u start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT and u3subscript𝑢3u_{3}italic_u start_POSTSUBSCRIPT 3 end_POSTSUBSCRIPT; therefore, u3subscript𝑢3u_{3}italic_u start_POSTSUBSCRIPT 3 end_POSTSUBSCRIPT must be vertex in Qrsubscript𝑄𝑟Q_{r}italic_Q start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT or Qtrsubscript𝑄𝑡𝑟Q_{tr}italic_Q start_POSTSUBSCRIPT italic_t italic_r end_POSTSUBSCRIPT. Again, if u3subscript𝑢3u_{3}italic_u start_POSTSUBSCRIPT 3 end_POSTSUBSCRIPT is a a convex vertex in P𝑃Pitalic_P, then (u2,u3)subscript𝑢2subscript𝑢3(u_{2},u_{3})( italic_u start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT , italic_u start_POSTSUBSCRIPT 3 end_POSTSUBSCRIPT ) is a knob in P𝑃Pitalic_P and we are done. Otherwise there will be a bottom knob in the component Q{Qr,Qtr}superscript𝑄subscript𝑄𝑟subscript𝑄𝑡𝑟Q^{\prime}\in\{Q_{r},Q_{tr}\}italic_Q start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ∈ { italic_Q start_POSTSUBSCRIPT italic_r end_POSTSUBSCRIPT , italic_Q start_POSTSUBSCRIPT italic_t italic_r end_POSTSUBSCRIPT } containing u3subscript𝑢3u_{3}italic_u start_POSTSUBSCRIPT 3 end_POSTSUBSCRIPT. Further as Qsuperscript𝑄Q^{\prime}italic_Q start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT can only intersect with PQ𝑃superscript𝑄P\setminus Q^{\prime}italic_P ∖ italic_Q start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT in a right or a top edge, the bottom knob of Qsuperscript𝑄Q^{\prime}italic_Q start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT must be a bottom knob of P𝑃Pitalic_P. This completes the argument for this case that for every knob in SQ𝑆𝑄S\cup Qitalic_S ∪ italic_Q, we can find a distinct knob in P𝑃Pitalic_P.

    • Case II(c): QQQitalic_Q touches the top-right corner of SSSitalic_S, but not the bottom-left corner of SSSitalic_S. Symmetric argument similar to the previous case.

    • Case II(d): QQQitalic_Q touches the bottom-left corner and the top-right corner of SSSitalic_S. This means the non-knob convex vertex v𝑣vitalic_v for much S𝑆Sitalic_S was the maximal square covering v𝑣vitalic_v must be the bottom-right corner of S𝑆Sitalic_S. However, since Q𝑄Qitalic_Q touches the bottom-left corner and the top-right corner of S𝑆Sitalic_S, we can extend S𝑆Sitalic_S by fixing its bottom right corner at v𝑣vitalic_v, contradicting the maximality of S𝑆Sitalic_S. Hence this case can never happen.

  • Case III: Q=QlQsubscriptQlQ=Q_{l}italic_Q = italic_Q start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT. We consider four subcases.

    • Case III(a): QQQitalic_Q does not touch the top-left corner or the bottom-left corner of SSSitalic_S. By arguments similar to Case I, we can show that right side, the bottom side and the top side of S𝑆Sitalic_S are right, bottom and top knobs of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S respectively (which proves that all vertices in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S which are corners in S𝑆Sitalic_S are part of knobs in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S, along a side of S𝑆Sitalic_S). And by similar argument PQ𝑃𝑄P\setminus Qitalic_P ∖ italic_Q must have a right knob, a bottom knob and a top knob which are also a right knob, a bottom knob and a top knob of P𝑃Pitalic_P. Therefore, in this case, for every knob in SQ𝑆𝑄S\cup Qitalic_S ∪ italic_Q, we can find a distinct knob in P𝑃Pitalic_P.

    • Case III(b): QQQitalic_Q touches the top-left corner of SSSitalic_S, but not the bottom-left corner of SSSitalic_S. Again similar to Case II(a), the right side and the bottom side of S𝑆Sitalic_S is a right knob and a bottom knob in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S (which proves that all vertices in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S which are corners in S𝑆Sitalic_S are part of knobs in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S, along a side of S𝑆Sitalic_S); and we can find a right knob and a bottom knob in PQ𝑃𝑄P\setminus Qitalic_P ∖ italic_Q (and also in P𝑃Pitalic_P). Moreover, there can be a top knob of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S which has one vertex in S𝑆Sitalic_S and one vertex in Q𝑄Qitalic_Q. Again, this case is similar to the second case of Case II(b) and we can find a top knob in P𝑃Pitalic_P which is not entirely contained in Q𝑄Qitalic_Q. Therefore, in this case, for every knob in SQ𝑆𝑄S\cup Qitalic_S ∪ italic_Q, we can find a distinct knob in P𝑃Pitalic_P.

    • Case III(c): QQQitalic_Q touches the bottom-left corner of SSSitalic_S, but not the top-left corner of SSSitalic_S. Symmetric argument similar to the previous case.

    • Case III(d): QQQitalic_Q touches both bottom-left corner and the top-left corner of SSSitalic_S. By arguments similar to Case I, we can show that right side of S𝑆Sitalic_S is right knob of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S (which proves that all vertices in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S which are corners in S𝑆Sitalic_S are part of knobs in QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S, along a side of S𝑆Sitalic_S) and there is a right knob in PQ𝑃𝑄P\setminus Qitalic_P ∖ italic_Q which is also a right knob in P𝑃Pitalic_P. Moreover, there can be a top knob of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S which has one vertex in S𝑆Sitalic_S and one vertex in Q𝑄Qitalic_Q; and a bottom knob of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S which has one vertex in S𝑆Sitalic_S and one vertex in Q𝑄Qitalic_Q. Again, this case is similar to the second case of Case II(b) and we can find a top knob (bottom knob) in P𝑃Pitalic_P which is not entirely contained in Q𝑄Qitalic_Q. Therefore, in this case, for every knob in SQ𝑆𝑄S\cup Qitalic_S ∪ italic_Q, we can find a distinct knob in P𝑃Pitalic_P

Therefore in all cases, we can map knobs of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S for any Q𝒬𝑄𝒬Q\in\mathcal{Q}italic_Q ∈ caligraphic_Q to distinct knobs in P𝑃Pitalic_P. Therefore the total number of knobs of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S can be at most k𝑘kitalic_k, if P𝑃Pitalic_P had at most k𝑘kitalic_k knobs.

Using the following framework, we find a non-knob convex vertex v𝑣vitalic_v (if any) in 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) time (Remark 5.4). We construct S:=MCS(v)assign𝑆𝑀𝐶𝑆𝑣S:=MCS(v)italic_S := italic_M italic_C italic_S ( italic_v ), construct 𝒬𝒬\mathcal{Q}caligraphic_Q and use this recursion to recurse into |𝒬|𝒬|\mathcal{Q}|| caligraphic_Q | similar instances where the number of knobs do not increase. We observe that each recursive step can also be done in linear time by a simple traversal of the polygon vertices in order.

Lemma 5.11.

If P𝑃Pitalic_P is an orthogonal polygon with n𝑛nitalic_n vertices and at most k𝑘kitalic_k knobs, we can either report that no non-knob convex vertex exists, or z12𝑧12z\leq 12italic_z ≤ 12 new smaller instances of orthogonal polygons P1,Pzsubscript𝑃1subscript𝑃𝑧P_{1},\ldots P_{z}italic_P start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … italic_P start_POSTSUBSCRIPT italic_z end_POSTSUBSCRIPT which individually have at most k𝑘kitalic_k knobs, in 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) time.

Polygons without non-knob convex vertices.

Lemma 5.11 implies that whenever we have a non-knob convex vertex, we can recurse in linear time. However, we need to analyse what happens if there are no non-knob convex vertices. Our first result is to bound the number of vertices of such polygons.

Lemma 5.12.

There are at most 4k44𝑘44k-44 italic_k - 4 vertices in an orthogonal polygon P𝑃Pitalic_P with at most k𝑘kitalic_k knobs and no non-knob convex vertex.

Proof 5.13.

Let nx,nvsubscript𝑛𝑥subscript𝑛𝑣n_{x},n_{v}italic_n start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT , italic_n start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT be the number of convex vertices and concave vertices in P𝑃Pitalic_P respectively. We must nv=nx4subscript𝑛𝑣subscript𝑛𝑥4n_{v}=n_{x}-4italic_n start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT = italic_n start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT - 4 because P𝑃Pitalic_P is an orthogonal polygon with no holes. Moreover, as all convex vertices are part of knobs and there are at most k𝑘kitalic_k knobs (containing two distinct vertices), we must have nx2ksubscript𝑛𝑥2𝑘n_{x}\leq 2kitalic_n start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT ≤ 2 italic_k. Therefore the total number of vertices is nx+nv=2nx44k4subscript𝑛𝑥subscript𝑛𝑣2subscript𝑛𝑥44𝑘4n_{x}+n_{v}=2n_{x}-4\leq 4k-4italic_n start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT + italic_n start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT = 2 italic_n start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT - 4 ≤ 4 italic_k - 4.

Therefore, for such polygons, we have n=𝒪(k)𝑛𝒪𝑘n=\mathcal{O}(k)italic_n = caligraphic_O ( italic_k ). We can detect if this is the case (i.e. P𝑃Pitalic_P does not have a non-knob convex vertex) in 𝒪(n)=𝒪(k)𝒪𝑛𝒪𝑘\mathcal{O}(n)=\mathcal{O}(k)caligraphic_O ( italic_n ) = caligraphic_O ( italic_k ) time (Lemma 5.11) and apply Algorithm 4 to solve OPCS (P)𝑃(P)( italic_P ) in time 𝒪(n14)=𝒪(k14)𝒪superscript𝑛14𝒪superscript𝑘14\mathcal{O}(n^{14})=\mathcal{O}(k^{14})caligraphic_O ( italic_n start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ) = caligraphic_O ( italic_k start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ) (Theorem 4.17).

Lemma 5.14.

Given an orthogonal polygon P𝑃Pitalic_P with n𝑛nitalic_n vertices and at most k𝑘kitalic_k knobs and with no non-knob convex vertices, we can solve OPCS in 𝒪(k14)𝒪superscript𝑘14\mathcal{O}(k^{14})caligraphic_O ( italic_k start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ) time.

5.3 A Recursive Algorithm

With the previous results in hand, we can construct an exact algorithm, that solves OPCS on an arbitrary orthogonal polygon P𝑃Pitalic_P with n𝑛nitalic_n vertices and at most k𝑘kitalic_k knobs.

The algorithm follows the framework of (i) recurse as in Lemma 5.11 whenever possible and (ii) detect and solve base cases as in Lemma 5.14. We formally state the algorithm as follows.

Algorithm 5 Separating-Square-Recursion     Input: P𝑃Pitalic_P with n𝑛nitalic_n vertices and at most k𝑘kitalic_k knobs
if P𝑃Pitalic_P has no non-knob convex vertex then \triangleright 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) from Lemma 5.11
     C𝐶absentC\leftarrowitalic_C ←OPCS (P)𝑃(P)( italic_P ) \triangleright using Algorithm 4, 𝒪(k14)𝒪superscript𝑘14\mathcal{O}(k^{14})caligraphic_O ( italic_k start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ) time from Lemma 5.14
     return C𝐶Citalic_C
end if
v𝑣absentv\leftarrowitalic_v ← some non-knob convex vertex \triangleright 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) from Lemma 5.11
SMCS(v)𝑆𝑀𝐶𝑆𝑣S\leftarrow MCS(v)italic_S ← italic_M italic_C italic_S ( italic_v ) \triangleright 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) from Lemma 3.2
Construct 𝒬𝒬\mathcal{Q}caligraphic_Q as in Lemma 5.6 \triangleright total 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) time
s0𝑠0s\leftarrow 0italic_s ← 0
for Q𝒬𝑄𝒬Q\in\mathcal{Q}italic_Q ∈ caligraphic_Q do \triangleright recurse, Algorithm 5, |𝒬|12𝒬12|\mathcal{Q}|\leq 12| caligraphic_Q | ≤ 12
     t𝑡absentt\leftarrowitalic_t ← return value when Separating-Square-Recursion is run on QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S
     ss+t𝑠𝑠𝑡s\leftarrow s+titalic_s ← italic_s + italic_t
end for
return (s(|𝒬|1))𝑠𝒬1(s-(|\mathcal{Q}|-1))( italic_s - ( | caligraphic_Q | - 1 ) ) \triangleright application of Lemma 5.6

5.4 Analysis of Separating-Square-Recursion

The correctness of Separating-Square-Recursion (Algorithm 5) is a direct consequence of Lemma 5.6 and the correctness of Algorithm 4, i.e. Theorem 4.17. We now analyse the time complexity of Algorithm 5.

Firstly, all steps of Algorithm 5 take 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) time other than the calls to Algorithm 4 and the recursion step. We now prove some results of this algorithm which helps us bound the number of recursive calls to Algorithm 5.

We observe that if the input polygon is P0subscript𝑃0P_{0}italic_P start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT at some recursive step, the chosen separating square for a non-knobbed convex vertex v𝑣vitalic_v, is S=MCS(v)𝑆𝑀𝐶𝑆𝑣S=MCS(v)italic_S = italic_M italic_C italic_S ( italic_v ) and the recursed polygons are P1,,Pzsubscript𝑃1subscript𝑃𝑧P_{1},\ldots,P_{z}italic_P start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_P start_POSTSUBSCRIPT italic_z end_POSTSUBSCRIPT, then the vertices of each of Pisubscript𝑃𝑖P_{i}italic_P start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT are either vertices in P0subscript𝑃0P_{0}italic_P start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT or corners of S𝑆Sitalic_S. With this in mind we prove the following result.

Lemma 5.15.

Let an orthogonal polygon P𝑃Pitalic_P with n𝑛nitalic_n vertices and at most k𝑘kitalic_k knobs be the original input to the topmost level invocation of Algorithm 5. At some recursive step, let the input be P0subscript𝑃0P_{0}italic_P start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT, and let the algorithm choose v𝑣vitalic_v to be a non-knob convex vertex of P0subscript𝑃0P_{0}italic_P start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT. Then v𝑣vitalic_v must also be a non-knob convex vertex of the original polygon P𝑃Pitalic_P. Moreover, any corner of S𝑆Sitalic_S that is also a vertex of QS𝑄𝑆Q\cup Sitalic_Q ∪ italic_S can not be a non-knob convex vertex.

Proof 5.16.

If v𝑣vitalic_v is a non-knob convex vertex in P0subscript𝑃0P_{0}italic_P start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT, then v𝑣vitalic_v must be a vertex in P𝑃Pitalic_P (and not a vertex introduced by some separating square at some recursive step). This is because all vertices introduced by a separating square at an intermediate recursive step have a knob along the side of the separating square itself (Lemma 5.9).

Next, if v𝑣vitalic_v is a vertex participating in a knob (u,v)𝑢𝑣(u,v)( italic_u , italic_v ) in P𝑃Pitalic_P, then u𝑢uitalic_u is a convex vertex. Due to this, at any intermediate recursion step, there cannot a polygon Psuperscript𝑃P^{\prime}italic_P start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT (P0subscript𝑃0P_{0}italic_P start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT in particular) with v𝑣vitalic_v as a vertex and a concave endpoint to the edge originating from v𝑣vitalic_v and along uv𝑢𝑣uvitalic_u italic_v. Thus, v𝑣vitalic_v must be a non-knob convex vertex in P𝑃Pitalic_P.

We now prove that if v𝑣vitalic_v is chosen as a non-knob convex vertex at some recursive step, then no subsequent recursive steps can again choose v𝑣vitalic_v to construct their separating square.

Lemma 5.17.

Let v𝑣vitalic_v be a non-knob convex vertex of the original input polygon P𝑃Pitalic_P. Then v𝑣vitalic_v is chosen as the non-knob convex vertex in at most one recursive step of Algorithm 5.

Proof 5.18.

If v𝑣vitalic_v is a non-knob convex vertex of the original input polygon P𝑃Pitalic_P, and let it be chosen at some recursive step 𝔯𝔯\mathfrak{r}fraktur_r for the first time. v𝑣vitalic_v cannot be chosen as a non-knob convex vertex by any recursive step 𝔯superscript𝔯\mathfrak{r}^{\prime}fraktur_r start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT which does not lie in the subtree of 𝔯𝔯\mathfrak{r}fraktur_r in the recursion tree (as v𝑣vitalic_v does not even appear as a vertex in those instances). However, once v𝑣vitalic_v is chosen as the non-knob convex vertex, v𝑣vitalic_v becomes a part of a knob (Lemma 5.9) in the subsequent steps (and hence not a non-knob convex vertex). Therefore v𝑣vitalic_v is never chosen a the non-knob convex vertex in the subsequent recursive steps either.

Now, we can bound the number of recursive calls to Algorithm 5.

Lemma 5.19.

The recursion tree of Separating-Square-Recursion (Algorithm 5) has at most n𝑛nitalic_n internal nodes running Separating-Square-Recursion, and at most 12n12𝑛12n12 italic_n leaf nodes which solve the base case by invoking Algorithm 4.

Proof 5.20.

Due to Lemma 5.17, the number of recursive steps where Algorithm 5) recurses (i.e. internal nodes in recursion tree), is bounded by the number n𝑛nitalic_n of vertices in the original input polygon. As any recursive step calls at most 12121212 more recursive steps, the number of steps where Algorithm 5 achieves the base-case condition (no non-knob convex vertex found) and calls Algorithm 4 is bounded by 12n12𝑛12n12 italic_n (i.e. leaf nodes in recursion tree). Therefore we have the above result.

Finally, we complete our algorithm with bounding the running time.

Theorem 5.21.

Separating-Square-Recursion (Algorithm 5) when run on an arbitrary orthogonal polygon P𝑃Pitalic_P with n𝑛nitalic_n vertices and at most k𝑘kitalic_k knobs, outputs the value of OPCS (P)𝑃(P)( italic_P ) in 𝒪(n2+k14n)𝒪superscript𝑛2superscript𝑘14𝑛\mathcal{O}(n^{2}+k^{14}\cdot n)caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + italic_k start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ⋅ italic_n ) time.

Proof 5.22.

Each internal node of the recursion tree for the algorithm takes 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) time. Therefore, following from the bound in Lemma 5.19, the total time taken by the internal nodes of the recursion tree for the algorithm is 𝒪(n2)𝒪superscript𝑛2\mathcal{O}(n^{2})caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ).

Each leaf node of the recursion tree is an execution of Algorithm 4, each taking 𝒪(k14)𝒪superscript𝑘14\mathcal{O}(k^{14})caligraphic_O ( italic_k start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ) time (Lemma 5.14). Now, as there are 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) leaf nodes in the recursion tree (Lemma 5.19), the base conditions together take 𝒪(k14n)𝒪superscript𝑘14𝑛\mathcal{O}(k^{14}\cdot n)caligraphic_O ( italic_k start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ⋅ italic_n ) time.

Hence, Separating-Square-Recursion runs in 𝒪(n2+k14n)𝒪superscript𝑛2superscript𝑘14𝑛\mathcal{O}(n^{2}+k^{14}\cdot n)caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + italic_k start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ⋅ italic_n ) time.

Remark 5.23.

Note that we should only prefer Algorithm 5 when k=o(n13/14)𝑘𝑜superscript𝑛1314k=o(n^{13/14})italic_k = italic_o ( italic_n start_POSTSUPERSCRIPT 13 / 14 end_POSTSUPERSCRIPT ), otherwise Algorithm 4 provides better or same asymptotic run time.

Note that we may use any exact algorithm for OPCS to solve the base case.

Corollary 5.24.

If there is an algorithm solving OPCS in time T(n)𝑇𝑛T(n)italic_T ( italic_n ) for polygons with n𝑛nitalic_n vertices, there is also another algorithm solving p𝑝pitalic_p-OPCS on polygons with n𝑛nitalic_n vertices and at most k𝑘kitalic_k knobs in time 𝒪(n2)+nT(4k4)𝒪superscript𝑛2𝑛𝑇4𝑘4\mathcal{O}(n^{2})+n\cdot T(4k-4)caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) + italic_n ⋅ italic_T ( 4 italic_k - 4 ).

5.5 Discussion on Orthogonally Convex Polygons

We discuss a well-studied special case of orthogonal polygons: orthogonally convex polygons.

Definition 5.25 (Orthogonally Convex Polygon).

An orthogonal polygon P𝑃Pitalic_P is said to be orthogonally convex (Figure 13), if the following hold true.

  • P𝑃Pitalic_P is a simply connected polygon with polygon edges parallel to either the x-axis or the y-axis.

  • The intercept of any line parallel to x-axis or y-axis with P𝑃Pitalic_P produces one continuous (possibly empty) line segment parallel to x-axis or y-axis.

Refer to caption
(a) Orthogonally Convex Polygon
Refer to caption
(b) Not Orthogonally Convex
Figure 13: Orthogonally Convex Polygons

It is easy to construct a simple orthogonal polygon having arbitrarily large number of knobs. However, we show that for orthogonally convex polygons, the number of knobs must be exactly 4444.

Lemma 5.26.

Any orthogonally convex polygon P𝑃Pitalic_P contains exactly 4444 knobs. Moreover, P𝑃Pitalic_P contains exactly one left knob, exactly one right knob, exactly one top knob and exactly one bottom knob.

Proof 5.27.

Existence. Consider the leftmost vertical line that intersects PPPitalic_P to form a non-empty vertical line segment of intersection. This must intersect with a vertical polygon edge of PPPitalic_P (otherwise the vertical line can be moved more to the left). Clearly these endpoints of this vertical polygon edge form a left knob (otherwise the vertical line can again be moved more to the left). Hence a left knob always exists. Symmetric arguments yield that a top knob, a bottom knob and a right knob exists as well.

Refer to caption
Figure 14: For proof of Lemma 5.26

Uniqueness. We will show that there cannot be two left knobs implying that there is exactly one left knob. For the sake of contradiction, consider that there are two left knobs (vi,vi+1)subscriptvisubscriptvi1(v_{i},v_{i+1})( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ) and (vj,vj+1)subscriptvjsubscriptvj1(v_{j},v_{j+1})( italic_v start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_j + 1 end_POSTSUBSCRIPT ) with xi=xi+1xj=xj+1subscriptxisubscriptxi1subscriptxjsubscriptxj1x_{i}=x_{i+1}\geq x_{j}=x_{j+1}italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ≥ italic_x start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT italic_j + 1 end_POSTSUBSCRIPT (refer to Figure 14). Consider the vertical line x=xixsubscriptxix=x_{i}italic_x = italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT. This line intersects PPPitalic_P at the entire edge (vi,vi+1)subscriptvisubscriptvi1(v_{i},v_{i+1})( italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_v start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ) with the intercept the y coordinates being [min(yi,yi+1),max(yi,yi+1)]subscriptyisubscriptyi1subscriptyisubscriptyi1[\min(y_{i},y_{i+1}),\max(y_{i},y_{i+1})][ roman_min ( italic_y start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_y start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ) , roman_max ( italic_y start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_y start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ) ]. Now consider any curve lying inside PPPitalic_P with visubscriptviv_{i}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT and vjsubscriptvjv_{j}italic_v start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT as endpoints. This curve must also intersect the line x=xixsubscriptxix=x_{i}italic_x = italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT (as xjxisubscriptxjsubscriptxix_{j}\leq x_{i}italic_x start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT ≤ italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT) at some y coordinate outside [min(yi,yi+1),max(yi,yi+1)]subscriptyisubscriptyi1subscriptyisubscriptyi1[\min(y_{i},y_{i+1}),\max(y_{i},y_{i+1})][ roman_min ( italic_y start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_y start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ) , roman_max ( italic_y start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_y start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ) ]. This means the intersection of the line x=xixsubscriptxix=x_{i}italic_x = italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT with PPPitalic_P is not a single line segment, which contradicts the assumption that PPPitalic_P is orthogonally convex. Therefore, there can be exactly one left knob. Subsequently, by symmetric arguments this would mean that there is exactly one right knob, exactly one top knob and exactly one bottom knob.

Therefore, if we use Algorithm 5 to solve OPCS on orthogonally convex polygons, we can substitute k=4𝑘4k=4italic_k = 4 in the analysis.

Corollary 5.28.

As orthogonally convex polygons have exactly k=4𝑘4k=4italic_k = 4 knobs, Separating-Square-Recursion (Algorithm 5) takes 𝒪(n2)𝒪superscript𝑛2\mathcal{O}(n^{2})caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) time to solve OPCS on orthogonally convex polygons.

6 Hardness Results for Polygons with Holes

In this Section, we consider the OPCSH problem. We consider the setting as described in [3], i.e. we need to solve OPCSH in orthogonal polygons, where the input consists of all N𝑁Nitalic_N lattice points lying in the polygon or on the boundary. In [3], a proof is given to show that OPCSH is NP-complete if the input size is polynomial in N𝑁Nitalic_N. In this section, we fix an issue with the proof and state other results obtained as a consequence.

6.1 Issue with the existing proof

The proof in [3] for NP-completeness of OPCSH gives a reduction from Planar 3-CNF [8]. The reduction gives a polynomial time algorithm to reduce any Planar 3-CNF instance (say ψ𝜓\psiitalic_ψ) and transforms it to an instance of OPCSH. First the formula is negated to obtain ϕ=¬ψitalic-ϕ𝜓\phi=\neg\psiitalic_ϕ = ¬ italic_ψ, which is a formula in disjunctive normal form (DNF) due to De-Morgan’s law. This means that ψ𝜓\psiitalic_ψ is satisfied if and only if ϕitalic-ϕ\phiitalic_ϕ evaluates to false on some truth assignment of the variables. Now, ϕitalic-ϕ\phiitalic_ϕ is reduced to an instance of OPCSH using three kinds of gadgets: wires, variable gadgets and junction gadgets. A variable gadget is introduced for each variable of ϕitalic-ϕ\phiitalic_ϕ and a junction gadget is introduced for each conjunction in ϕitalic-ϕ\phiitalic_ϕ. Further wire gadgets (or simply wires) are introduced to ‘connect’ junction gadgets to variable gadgets.

The variable gadgets, wires and the junction gadgets shall be placed according to the formula ϕitalic-ϕ\phiitalic_ϕ. For each variable gadget or each wire, it is easy to compute in polynomial time the minimum number of squares needed to cover the gadget. It is possible that some of the squares used for covering a wire may cover a region inside a junction gadget. Each variable gadget permits two kinds of covering (representing the two kinds of truth assignment to a variable in ϕitalic-ϕ\phiitalic_ϕ). Let us denote these coverings by true-covering and false-covering, respectively - both coverings require the same number of squares. Similarly we can extend this observation to see that there are two ways in which a variable gadget and its adjacent wires can be covered optimally - and both coverings use the same number of squares. A combination of how a variable gadget is covered affects which portions of all its corresponding junction gadgets (i.e. gadgets for the and-clauses containing the corresponding variable in ϕitalic-ϕ\phiitalic_ϕ) will be covered. We will keep the construction of variable gadgets and wires unchanged from the construction in [3]. Let V𝑉Vitalic_V be the number of squares required to cover all variable gadgets and W𝑊Witalic_W be the number of squares required to cover all wire gadgets.

In [3], the authors claim that the junction gadgets (or simply, a junction) are such that, the minimum number of squares needed to cover a junction gadget is 12121212 if all three variable gadgets corresponding to the and-clause are covered with a covering which makes the and-clause evaluate to true (i.e. true-covering if the variable appears non-negated in the clause, or false-covering if the variable is negated in the clause); otherwise the minimum number of squares needed is 13131313. Therefore, the junctions act similar to and-gates. Now, if the total number of junctions be j𝑗jitalic_j, then [3] concludes by stating that ψ𝜓\psiitalic_ψ is satisfiable if and only if the reduced instance can be covered with less than (V+W+13j)𝑉𝑊13𝑗(V+W+13j)( italic_V + italic_W + 13 italic_j ) squares; otherwise exactly (V+W+13j)𝑉𝑊13𝑗(V+W+13j)( italic_V + italic_W + 13 italic_j ) squares are required. Hence solving OPCSH would also solve Planar 3-CNF.

However, we take a deeper look into this reduction by performing a case work on the evaluated value of ψ𝜓\psiitalic_ψ for possible truth assignments of variables.

  • Case I, ψ𝜓\psiitalic_ψ is true for all assignments. This implies ϕ=¬ψitalic-ϕ𝜓\phi=\neg\psiitalic_ϕ = ¬ italic_ψ is false for all assignments. Since ϕitalic-ϕ\phiitalic_ϕ is in DNF, all assignments must render all and-clauses as false. Therefore, for all minimum covering of the variable gadgets, coverings all junctions would require 13131313 squares. This means the minimum number of squares needed to cover such an instance is V+W+13j𝑉𝑊13𝑗V+W+13jitalic_V + italic_W + 13 italic_j.

  • Case II, ψ𝜓\psiitalic_ψ is false for all assignments. This implies ϕ=¬ψitalic-ϕ𝜓\phi=\neg\psiitalic_ϕ = ¬ italic_ψ is true for all assignments. Since ϕitalic-ϕ\phiitalic_ϕ is in DNF, all assignments must render at least one and-clauses as true. Therefore, for any arbitrary minimum covering of the variable gadgets, there would be at least one junction that can be covered with 12121212 squares (while others take at most 13131313 squares). This means the minimum number of squares needed to cover such an instance is less than V+W+13j𝑉𝑊13𝑗V+W+13jitalic_V + italic_W + 13 italic_j.

  • Case III, ψ𝜓\psiitalic_ψ is true for some assignments and false for some. This implies ϕ=¬ψitalic-ϕ𝜓\phi=\neg\psiitalic_ϕ = ¬ italic_ψ is also true for some assignments and false for some. Consider any such assignment such that ϕitalic-ϕ\phiitalic_ϕ is true and cover the variable clauses accordingly. Since ϕitalic-ϕ\phiitalic_ϕ is in DNF, this assignments must render at least one and-clauses as true. Therefore, if we cover the variable gadgets corresponding to such an assignment, there would be at least one junction that can be covered with 12121212 squares (while others take at most 13131313 squares). This means the minimum number of squares needed to cover such an instance is less than V+W+13j𝑉𝑊13𝑗V+W+13jitalic_V + italic_W + 13 italic_j.

Therefore, the minimum number of squares to cover the reduced instance is equal to V+W+13j𝑉𝑊13𝑗V+W+13jitalic_V + italic_W + 13 italic_j if and only if ψ𝜓\psiitalic_ψ is true for all assignments (Case I) and less than V+W+13j𝑉𝑊13𝑗V+W+13jitalic_V + italic_W + 13 italic_j otherwise. Therefore, solving OPCSH solves tautology for ψ𝜓\psiitalic_ψ instead of satisfiablity. Moreover, tautology in a CNF formula can be checked in linear time (Since ψ𝜓\psiitalic_ψ is a tautology if and only if for all clauses c𝑐citalic_c in ϕitalic-ϕ\phiitalic_ϕ there is a variable x𝑥xitalic_x such that both x𝑥xitalic_x and ¬x𝑥\neg x¬ italic_x appear in c𝑐citalic_c). Hence this reduction does not prove NP-hardness of OPCSH.

6.2 Fixing the Construction

The issue in the NP-hardness reduction in [3] arose as the clauses require more number of squares when the literals of a clause do not all evaluate to true even if this assignment sets the clause to true.

We construct such a junction that requires 29292929 squares if all three of its literals evaluate to false, whereas the junctions require 28282828 squares when at least one literal evaluates to true. Therefore our modified junction behaves similar to an or-gate.

Recap** the Constructions of Variable Gadgets and Wires.

The construction due to [3] starts by defining even-lines (odd-lines) as horizontal lines with an even (odd) y-coordinate or a vertical line with an even (odd) x-coordinate. The construction of variable gadgets and wires follow the following properties.

  • All maximal squares of variable gadgets and wires are 2×2222\times 22 × 2 in dimension.

  • The wires connecting a variable gadget for a variable x𝑥xitalic_x, to a junction for a clause c𝑐citalic_c, where x𝑥xitalic_x appears non-negated in c𝑐citalic_c — connect to the variable gadget (as well as the junction) horizontally, and along two consecutive odd lines (i.e. an even line passes through the middle of such a connection). Refer to diagrams in  [3].

  • The wires connecting a variable gadget for a variable x𝑥xitalic_x, to a junction for a clause c𝑐citalic_c, where x𝑥xitalic_x appears negated in c𝑐citalic_c — connect to the variable gadget (as well as the junction) horizontally, and along two consecutive even lines (i.e. an odd line passes through the middle of such a connection). Refer to diagrams in  [3].

  • If a variable gadget for a variable x𝑥xitalic_x is covered with a true-covering, then all wires connecting it to a junction for a clause c𝑐citalic_c where x𝑥xitalic_x appears non-negated, will be covered in a way such that half a square protrudes out of destination and hence covers a part of the junction. Otherwise, for a false-covering, the entire junction would remain uncovered, even when the variable gadget and the wire are covered. Refer to diagrams in  [3].

  • If a variable gadget for a variable x𝑥xitalic_x is covered with a false-covering, then all wires connecting it to a junction for a clause c𝑐citalic_c where x𝑥xitalic_x appears negated, will be covered in a way such that half a square protrudes out of destination and hence covers a part of the junction. Otherwise, for a true-covering, the entire junction would remain uncovered, even when the variable gadget and the wire are covered. Refer to diagrams in  [3].

We construct new junction gadgets along with these constructions of wires and variable gadgets in [3].

Modifying the Junction Gadgets.

We construct new junction gadgets as shown in Figure 15. Wires connect to these junction gadgets in the same way as described in [3].

Refer to caption
(a) Junction for clauses of type (xyz)𝑥𝑦𝑧(x\vee y\vee z)( italic_x ∨ italic_y ∨ italic_z )
Refer to caption
(b) Junction for clauses of type (x¬yz)𝑥𝑦𝑧(x\vee\neg y\vee z)( italic_x ∨ ¬ italic_y ∨ italic_z )
Figure 15: Modified junction

The junctions for clauses of type (¬x¬y¬z)𝑥𝑦𝑧(\neg x\vee\neg y\vee\neg z)( ¬ italic_x ∨ ¬ italic_y ∨ ¬ italic_z ) can be constructed by shifting the gadget in Figure 15(a) vertically up by one square. Similarly the junctions for clauses of type (¬xy¬z)𝑥𝑦𝑧(\neg x\vee y\vee\neg z)( ¬ italic_x ∨ italic_y ∨ ¬ italic_z ) can be constructed by shifting the gadget in Figure 15(b) vertically up by one square.

We now investigate minimal coverings of squares for each of these gadgets.

Lemma 6.1.

Each junction gadget requires 28282828 squares to be covered when at least one literal in it evaluates to true. Otherwise the junction gadget requires 29292929 squares to be covered.

Proof 6.2.

The following proof works for both the gadgets in Figure 15(a) and Figure 15(b). Both configurations are such that there are nine 4×4444\times 44 × 4 maximal squares due to convex vertices present due, and eleven 2×2222\times 22 × 2 squares necessary for joining with wire gadgets (Remark 3.5). Other than these 20202020 squares, we analyse other valid squares needed to cover it fully.

In both gadgets, we can find eight blocks (1×1111\times 11 × 1 regions) p1,,p8subscript𝑝1subscript𝑝8p_{1},\ldots,p_{8}italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_p start_POSTSUBSCRIPT 8 end_POSTSUBSCRIPT, as shown in Figure 16, such that these are not covered by any of the 20202020 previously placed squares (irrespective of the true/false values carried through the wires); and for ij𝑖𝑗i\neq jitalic_i ≠ italic_j, pisubscript𝑝𝑖p_{i}italic_p start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT and pjsubscript𝑝𝑗p_{j}italic_p start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT cannot be covered by a single valid square. This means at least 8888 more valid squares are required to cover the entire gadget. This means at least 28282828 squares are required to cover the entire gadget (for any truth values being carried through the wires).

Refer to caption
(a) p1,,p8subscript𝑝1subscript𝑝8p_{1},\ldots,p_{8}italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_p start_POSTSUBSCRIPT 8 end_POSTSUBSCRIPT for Figure 15(a)
Refer to caption
(b) p1,,p8subscript𝑝1subscript𝑝8p_{1},\ldots,p_{8}italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_p start_POSTSUBSCRIPT 8 end_POSTSUBSCRIPT for Figure 15(b)
Figure 16: Positions of p1,,p8subscript𝑝1subscript𝑝8p_{1},\ldots,p_{8}italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_p start_POSTSUBSCRIPT 8 end_POSTSUBSCRIPT
Refer to caption
(a) q1,,q9subscript𝑞1subscript𝑞9q_{1},\ldots,q_{9}italic_q start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_q start_POSTSUBSCRIPT 9 end_POSTSUBSCRIPT for Figure 15(a)
Refer to caption
(b) q1,,q9subscript𝑞1subscript𝑞9q_{1},\ldots,q_{9}italic_q start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_q start_POSTSUBSCRIPT 9 end_POSTSUBSCRIPT for Figure 15(b)
Figure 17: Positions of q1,,q9subscript𝑞1subscript𝑞9q_{1},\ldots,q_{9}italic_q start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_q start_POSTSUBSCRIPT 9 end_POSTSUBSCRIPT

Further, if all wires contain a false value, we can find nine blocks (1×1111\times 11 × 1 regions) q1,,q9subscript𝑞1subscript𝑞9q_{1},\ldots,q_{9}italic_q start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_q start_POSTSUBSCRIPT 9 end_POSTSUBSCRIPT, as shown in Figure 17, such that these are not covered by any of the 20202020 previously placed squares; and for ij𝑖𝑗i\neq jitalic_i ≠ italic_j, qisubscript𝑞𝑖q_{i}italic_q start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT and qjsubscript𝑞𝑗q_{j}italic_q start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT cannot be covered by a single valid square. This means at least 9999 more valid squares are required to cover the entire gadget. Therefore at least 29292929 squares are required to cover the entire gadget when all wires contain a false value.

In Figure 18 and Figure 19, we indeed construct a set of 29292929 valid squares covering the entire gadget when all three wires carry a false value, and a set of 28282828 valid squares covering the entire gadget when at least one of the wires contain a true value. This construction proves that indeed 29292929 squares and 28282828 squares are precisely the minimum number of valid covering squares required to cover the gadgets if all literals are false, and at least one literal is true, respectively. This completes the proof.

Refer to caption
(a) 29292929 squares when literals are (F,F,F)𝐹𝐹𝐹(F,F,F)( italic_F , italic_F , italic_F )
Refer to caption
(b) 28282828 squares when literals are (F,F,T)𝐹𝐹𝑇(F,F,T)( italic_F , italic_F , italic_T ) or (T,F,F)𝑇𝐹𝐹(T,F,F)( italic_T , italic_F , italic_F )
Refer to caption
(c) 28282828 squares when literals are (T,F,T)𝑇𝐹𝑇(T,F,T)( italic_T , italic_F , italic_T )
Refer to caption
(d) 28282828 squares when literals are (F,T,T)𝐹𝑇𝑇(F,T,T)( italic_F , italic_T , italic_T ) or (T,F,F)𝑇𝐹𝐹(T,F,F)( italic_T , italic_F , italic_F )
Refer to caption
(e) 28282828 squares when literals are (F,T,F)𝐹𝑇𝐹(F,T,F)( italic_F , italic_T , italic_F )
Refer to caption
(f) 28282828 squares when literals are (T,T,T)𝑇𝑇𝑇(T,T,T)( italic_T , italic_T , italic_T )
Figure 18: Minimal covering of junctions in Figure 15(a)
Refer to caption
(a) 29292929 squares when literals are (F,F,F)𝐹𝐹𝐹(F,F,F)( italic_F , italic_F , italic_F )
Refer to caption
(b) 28282828 squares when literals are (F,F,T)𝐹𝐹𝑇(F,F,T)( italic_F , italic_F , italic_T ) or (T,F,F)𝑇𝐹𝐹(T,F,F)( italic_T , italic_F , italic_F )
Refer to caption
(c) 28282828 squares when literals are (T,F,T)𝑇𝐹𝑇(T,F,T)( italic_T , italic_F , italic_T )
Refer to caption
(d) 28282828 squares when literals are (F,T,T)𝐹𝑇𝑇(F,T,T)( italic_F , italic_T , italic_T ) or (T,F,F)𝑇𝐹𝐹(T,F,F)( italic_T , italic_F , italic_F )
Refer to caption
(e) 28282828 squares when literals are (F,T,F)𝐹𝑇𝐹(F,T,F)( italic_F , italic_T , italic_F )
Refer to caption
(f) 28282828 squares when literals are (T,T,T)𝑇𝑇𝑇(T,T,T)( italic_T , italic_T , italic_T )
Figure 19: Minimal covering of junctions in Figure 15(b)

Now, we complete the reduction from Planar 3-CNF (refer to [8]).

Completing the Reduction.

We consider an instance (a CNF boolean formula) ψ𝜓\psiitalic_ψ of Planar 3-CNF. We construct variable gadgets (as in [3]) for each variable in ψ𝜓\psiitalic_ψ, and set up junctions ( Figure 15) for each clause in ψ𝜓\psiitalic_ψ (we are working with ψ𝜓\psiitalic_ψ directly, instead of working with ϕ=¬ψitalic-ϕ𝜓\phi=\neg\psiitalic_ϕ = ¬ italic_ψ as done in [3]) and connect them with wires (as in [3]). Let V+W𝑉𝑊V+Witalic_V + italic_W be the squares required to cover all variable gadgets and wires.

Now, we analyse the three cases like before. Let j𝑗jitalic_j be the number of junctions.

  • Case I, ψ𝜓\psiitalic_ψ is true for all assignments (satisfiable). Since ψ𝜓\psiitalic_ψ is in CNF, all assignments must render all or-clauses as true (i.e. at least one literal in each clause is true). Therefore from Lemma 6.1, for all minimum covering of the variable gadgets, coverings all junctions would require a minimum of only 28282828 valid squares. This means the minimum number of squares needed to cover such an instance is equal to V+W+28j𝑉𝑊28𝑗V+W+28jitalic_V + italic_W + 28 italic_j.

  • Case II, ψ𝜓\psiitalic_ψ is false for all assignments (not satisfiable). Since ψ𝜓\psiitalic_ψ is in CNF, all assignments must render at least one or-clause as false (i.e. at all literals in at least one clause is false). Therefore from Lemma 6.1, at least one junction requires a minimum of 29292929 valid squares, where as others require at least 28282828 valid squares for being covered. This means the minimum number of squares needed to cover such an instance is strictly more than V+W+28j𝑉𝑊28𝑗V+W+28jitalic_V + italic_W + 28 italic_j.

  • Case III, ψ𝜓\psiitalic_ψ is true for some assignments and false for some (satisfiable). Consider any such assignment such that ψ𝜓\psiitalic_ψ is true and cover the variable clauses accordingly. Since ψ𝜓\psiitalic_ψ is in CNF, this assignments must render all or-clauses as true (i.e. at least one literal in each clause is true). Therefore from Lemma 6.1, for such a minimum covering of the variable gadgets, coverings all junctions would require 28282828 squares. This means the minimum number of squares needed to cover such an instance is equal to V+W+28j𝑉𝑊28𝑗V+W+28jitalic_V + italic_W + 28 italic_j.

This implies that ψ𝜓\psiitalic_ψ is satisfiable if and only if the reduced instance has a minimum covering with exactly V+W+28j𝑉𝑊28𝑗V+W+28jitalic_V + italic_W + 28 italic_j squares. On the other hand, if ψ𝜓\psiitalic_ψ is not satisfiable, then the minimum number of squares required to cover the reduced instance is strictly more than V+Q+28j𝑉𝑄28𝑗V+Q+28jitalic_V + italic_Q + 28 italic_j. Since Planar 3-CNF is NP-hard, OPCSH must also be NP-hard. Finally, as any certificate can be verified in polynomial time using Algorithm 1, OPCSH is NP-complete.

Theorem 6.3.

The problem of covering orthogonal polygons with holes using minimum number of squares (OPCSH) is NP-complete (when the input is the set of all N𝑁Nitalic_N lattice points inside the orthogonal polygon).

Moreover, as both the answer V+W+28j𝑉𝑊28𝑗V+W+28jitalic_V + italic_W + 28 italic_j and the numerical value of the coordinates of each of the points is linear (polynomial) in the number N𝑁Nitalic_N of points inside the polygon, the problem is strongly NP-complete. Hence we can conclude the following.

Corollary 6.4.

OPCSH is strongly NP-complete. Therefore, there is no FPTAS scheme for OPCSH unless P=NPPNP\mbox{P}=\mbox{NP}P = NP. That is, there is no (1+ε)1𝜀(1+\varepsilon)( 1 + italic_ε )-approximation scheme for arbitrarily small ε𝜀\varepsilonitalic_ε, such that runs in time 𝒪(poly(1ε,N))𝒪𝑝𝑜𝑙𝑦1𝜀𝑁\mathcal{O}(poly(\frac{1}{\varepsilon},N))caligraphic_O ( italic_p italic_o italic_l italic_y ( divide start_ARG 1 end_ARG start_ARG italic_ε end_ARG , italic_N ) ), where N𝑁Nitalic_N is the number of lattice points inside the polygon.

Due to the structure of the reduced instance, we can also infer the following.

Corollary 6.5.

The following problems are NP-complete:

  • The problem of finding a minimum square covering of polygons with holes, where all squares are restricted to have a side-length of at most η𝜂\etaitalic_η is NP-complete whenever η4𝜂4\eta\geq 4italic_η ≥ 4.

  • The problem of finding the minimum square covering of polygons, where the squares can take side lengths from a set ΛΛ\Lambda\subset\mathbb{N}roman_Λ ⊂ blackboard_N is NP-complete, even if |Λ|=2Λ2|\Lambda|=2| roman_Λ | = 2.

Proof 6.6.

The results follow from the observation that the reduced instance from Planar 3-CNF only contains maximal squares of size 2×2222\times 22 × 2 and 4×4444\times 44 × 4, and from Observation 3.

Another immediate corollary of Theorem 6.3 is that fact that OPCSH is NP-hard when the n𝑛nitalic_n vertices of the polygon constitute the input, instead of the N𝑁Nitalic_N lattice points lying inside. This is because the reduced instance had n=Θ(N)𝑛Θ𝑁n=\Theta(N)italic_n = roman_Θ ( italic_N ). It turns out that OPCSH is in fact in the class NP, with n𝑛nitalic_n vertices as input. This gives us the following result.

Corollary 6.7.

OPCSH is NP-complete when the input is the n𝑛nitalic_n vertices.

Proof 6.8.

Theorem 6.3 immediately gives us that OPCSH is NP-hard when the input is the n𝑛nitalic_n vertices.

To prove that OPCSH with n𝑛nitalic_n vertices is in NP, we need to show a polynomial time verifier for a certificate. We consider the set of rec-packs to be a certificate, and we can do the following to check if these indeed form a valid covering:

  • Check if each rec-pack lies inside the polygon. This can be checked in 𝒪(n)𝒪𝑛\mathcal{O}(n)caligraphic_O ( italic_n ) by checking if an arbitrary point in the rec-pack lies in the polygon, followed by ensuring that no polygon-edge intersects a rec-pack edge non-trivially.

  • If all rec-packs lie in the polygon, we can use Algorithm 1 to check if they form a complete covering of the polygon. Algorithm 1 does generalize to polygons with holes as well.

This proves there there is in fact a polynomial time verifier for OPCSH.

7 Conclusion

In this paper, we answer an open problem in [3], of whether OPCS has an exact algorithm running in time polynomial in the number n𝑛nitalic_n of vertices of the input orthogonal polygon without holes. Our exact algorithm for OPCS runs in 𝒪(n14)𝒪superscript𝑛14\mathcal{O}(n^{14})caligraphic_O ( italic_n start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ) time. We further optimize the running time for orthogonal polygons with n𝑛nitalic_n vertices and a small number of knobs k𝑘kitalic_k, by designing a recursive algorithm with running time 𝒪(n2+k14n)𝒪superscript𝑛2superscript𝑘14𝑛\mathcal{O}(n^{2}+k^{14}\cdot n)caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + italic_k start_POSTSUPERSCRIPT 14 end_POSTSUPERSCRIPT ⋅ italic_n ). This gives us an 𝒪(n2)𝒪superscript𝑛2\mathcal{O}(n^{2})caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) algorithm for solving OPCS on orthogonally convex polygons. We also correct some errors in the NP-hardness reduction for OPCSH given in [3]. A natural future direction is to study the problem with respect to covering of orthogonal polygons with other geometric objects like triangles, line segments, orthogonally convex polygons etc. and try to obtain an algorithm whose running time is polynomial in the number of vertices of the input polygon and not on the total number of interior points of the input polygon. Another interesting question directly related to our current work would be to find tight bounds for the number of rec-packs required to produce a minimum covering of an orthogonal polygon; our paper only proves an upper bound of 𝒪(n2)𝒪superscript𝑛2\mathcal{O}(n^{2})caligraphic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) rec-packs required to produce a minimum covering of an entire polygon.

References

  • [1] Michael O. Albertson and Claire J. O’Keefe. Covering regions with squares. SIAM Journal on Algebraic Discrete Methods, 2(3):240–243, 1981. arXiv:https://doi.org/10.1137/0602026, doi:10.1137/0602026.
  • [2] V. S. Anil Kumar and H. Ramesh. Covering rectilinear polygons with axis-parallel rectangles. In Proceedings of the Thirty-First Annual ACM Symposium on Theory of Computing, STOC ’99, page 445–454, New York, NY, USA, 1999. Association for Computing Machinery. doi:10.1145/301250.301369.
  • [3] L. J. Aupperle, H. E. Conn, J. M. Keil, and Joseph O’Rourke. Covering orthogonal polygons with squares. Proc. 26th Allerton Conf. Commun. Control Comput., 1988. URL: https://www.science.smith.edu/~jorourke/Papers/ConnJORsquares.pdf.
  • [4] Reuven Bar-Yehuda. Covering polygons with squares. 2014. URL: https://api.semanticscholar.org/CorpusID:50721774.
  • [5] Jean R. S. Blair and Barry Peyton. An introduction to chordal graphs and clique trees. In Alan George, John R. Gilbert, and Joseph W. H. Liu, editors, Graph Theory and Sparse Matrix Computation, pages 1–29, New York, NY, 1993. Springer New York.
  • [6] J.C. Culberson and R.A. Reckhow. Covering polygons is hard. In [Proceedings 1988] 29th Annual Symposium on Foundations of Computer Science, pages 601–611, 1988. doi:10.1109/SFCS.1988.21976.
  • [7] Fanica Gavril. Algorithms for minimum coloring, maximum clique, minimum covering by cliques, and maximum independent set of a chordal graph. SIAM J. Comput., 1:180–187, 1972. URL: https://api.semanticscholar.org/CorpusID:1111479.
  • [8] David Lichtenstein. Planar formulae and their uses. SIAM Journal on Computing, 11(2):329–343, 1982. doi:10.1137/0211025.
  • [9] Dipen Moitra. Finding a minimal cover for binary images: An optimal parallel algorithm. Algorithmica, 6(5):624–657, 1991. doi:10.1007/BF01759065.
  • [10] J. O’Rourke. Art Gallery Theorems and Algorithms. International series of monographs on computer science. Oxford University Press, 1987. URL: https://books.google.co.in/books?id=aPZQAAAAMAAJ.