Edge Matching with Inequalities, Triangles, Unknown Shape, and Two Players
Jeffrey Bosboom, Charlotte Chen, Lily Chung, Spencer Compton, Michael Coulombe, Erik D. Demaine, Martin L. Demaine, Ivan Tadeu Ferreira Antunes Filho, Dylan Hendrickson, Adam Hesterberg, Calvin Hsu, William Hu, Oliver Korten, Zhezheng Luo, Lillian Zhang
EEdge Matching with Inequalities, Triangles,Unknown Shape, and Two Players
Jeffrey Bosboom ∗ Charlotte Chen ∗ Lily Chung ∗ Spencer Compton ∗ Michael Coulombe ∗ Erik D. Demaine ∗ Martin L. Demaine ∗ Ivan Tadeu Ferreira Antunes Filho ∗ Dylan Hendrickson ∗ Adam Hesterberg ∗ Calvin Hsu ∗ William Hu ∗ Oliver Korten † Zhezheng Luo ∗ Lillian Zhang ∗ Abstract
We analyze the computational complexity of several new variants of edge-matching puzzles. Firstwe analyze inequality (instead of equality) constraints between adjacent tiles, proving the problem NP-complete for strict inequalities but polynomial-time solvable for nonstrict inequalities. Second we analyzethree types of triangular edge matching, of which one is polynomial-time solvable and the other two areNP-complete; all three are × n edge matching, all four of whichare PSPACE-complete. Most of our NP-hardness reductions are parsimonious, newly proving × n edge matching. Along the way, we prove In an edge-matching puzzle , we are given several tiles (usually identical in shape), where each tile has alabel on each edge, and the goal is to place all the tiles (usually via translation and rotation) into a givenshape such that shared edges between adjacent tiles have compatible labels. In unsigned edge matching,labels are compatible if they are identical ( a matches a and nothing else); in signed edge matching, labelshave signs (e.g., + a and − a ), and two labels are compatible if they are negations of each other (+ a matches − a and nothing else, and vice versa). Physical edge-matching puzzles date back to the 1890s [Thu92];perhaps the most famous example is Eternity II which offered a US$2,000,000 prize for a solution before2011 [Wik19].
The complexity of edge-matching puzzles has been studied since 1966 [Ber66]. The most relevant workto this paper is from two past JCDCG conferences. In 2007, Demaine and Demaine [DD07] proved thatsigned and unsigned edge-matching square-tile puzzles are NP-complete and equivalent to both jigsaw puzzlesand polyomino packing puzzles. In 2016, Bosboom et al. [BDD +
17] proved that signed and unsigned edge-matching square-tile puzzles are NP-complete even when the target shape is a 1 × n rectangle, and furthermorehard to approximate within some constant factor. Our work on 1 × n triangle edge-matching puzzles isinspired by an open problem proposed in the latter paper. ∗ MIT Computer Science and Artificial Intelligence Laboratory, 32 Vassar St., Cambridge, MA 02139, USA,[email protected], { czchen,ikdc,scompton,mcoulomb,edemaine,mdemaine,ivanaf,dylanhen,achester,ineq,whu2704,ezzluo,lillianz } @mit.edu, charlotte z [email protected] † Department of Computer Science, Tufts University, Medford, MA, USA, [email protected] a r X i v : . [ c s . CC ] J un ompatibility Board Tiles Players Complexity < × n square 1-player NP-complete ≤ m × n square 1-player PSigned/unsigned 1 × n square 1-player NP/ × n equilateral triangle 1-player NP/ × n right triangle (hypotenuse contact) 1-player NP/ √ × n right triangle (leg contact) 1-player ∈ P, O (1) × n square/triangular with O (1) colors 1-player ∈ PSigned/unsigned shapeless square 1-player NP/ × n square impartial 2-player PSPACE-completeSigned/unsigned 1 × n square partizan 2-player PSPACE-complete Table 1: Our results on edge-matching puzzles. *Our proof gives ASP-completeness for 1 × n edge matchingonly when at least one boundary edge is colored; otherwise, each solution can be rotated 180 degrees to formanother valid solution, so we get 2-ASP-hardness (NP-hard to find a third solution given two).Figure 1: A solved 2 × < -compatible edge-matching puzzle. This solution is valid because 1 <
52 and22 <
78 in the top row, 3 < <
21 in the bottom row, and 12 <
54, 12 <
14, and 1 <
45 in thecolumns.
Table 1 summarizes our results in edge matching, described in more detail below.
Inequality edge matching.
Our most involved result is an NP-hardness proof for a new “ < ” compatibilitycondition, where edge labels are numbers, horizontally adjacent edges match if the left edge’s number is lessthan the right edge’s number, and vertically adjacent edges match if the top edge’s number is less than thebottom edge’s number. Figure 1 shows an example. In Section 2, we prove NP-hardness of < -compatible 1 × n edge matching by reduction from another new NP-hard problem, Interval-Pair Cover. The ≤ -compatibilitycondition (where equal numbers also match, or we assume all labels are distinct) turns out to be substantiallyeasier: even rectangular puzzles turn out to be always solvable, and we give a polynomial-time algorithm. ASP/ × n edge matching. In Section 3, we analyze edge matching for thefirst time from the perspective of the number of solutions to an instance, which is relevant to constructingpuzzles with unique solutions. Specifically, we prove ASP-completeness for signed and unsigned 1 × n edge-matching puzzles when the left boundary edge is colored (to prevent trivial 180 ◦ rotation of solutions), and2-ASP-hardness and FNP is a variant of NPthat actually specifies the valid certificates/solutions for an instance (instead of just requiring that theyexist); that is, an FNP problem is a relation between instances and polynomial-length certificates/solutionsthat can be checked in polynomial time. For edge matching problems, the certificate we consider is a validplacement of the given tiles within the given shape. An FNP problem Π is
ASP-complete [YS03] if everyFNP problem has a polynomial-time parsimonious reduction (preserving the number of solutions) to Πalong with a polynomial-time bijection between solutions of the two problems. ASP-completeness impliesthat the k -ASP version of the FNP problem — given an instance and k solutions to it, decide whetherthere is another solution — is NP-hard [YS03]. An FNP problem is [Val79] if counting the2umber of solutions is as hard as counting the number of solutions to any FNP problem, which is implied bya reduction that is c -monious , i.e., that multiplies the number of solutions by a computable factor c ≥ Our reductions to 1 × n edge matching are the first to be parsimonious or, when global 180 ◦ rotation isallowed, 2-monious. Triangular edge matching.
The conclusion of [BDD +
17] claimed that the paper’s results extended toequilateral-triangle edge matching, but the proposed simulation of squares by triangles is incorrect becauseit constrains the orientation of the simulated squares. In Section 4.1, we extend our 1 × n parsimonious proofto obtain NP/ × n ” arrangements. For clarity, we assume the legsof the triangles have length 1. If we still want a height-1 tiling, then length- √ √ tiling,so only legs match, we show in Section 4.2 that, surprisingly, both signed and unsigned edge matching canbe solved in polynomial time using an algorithm based on Eulerian paths. Nonetheless, the latter problemsare still Shapeless edge matching.
In Section 5, we prove that square-tile edge-matching puzzles remain NP/ × n edge-matching puzzle with a fixed left boundary color. In Section 6, we consider natural 2-player variants of 1 × n edge-matchingpuzzles, where the left boundary edge of the rectangle has a prespecified color, players alternate placing atile in the leftmost empty cell that matches the edge color to the left, and the first player unable to moveloses ( normal play ). We prove PSPACE-completeness for four variants of this problem: both signed andunsigned square-tile edge matching, and both when players can play any remaining tile from a shared pool( impartial ) and when players play from separate pools of tiles ( partizan ). Along the way to proving our results on edge matching, we derive other results of possible independentinterest in graph algorithms/complexity.
Hamiltonicity parsimony.
In Section 3.1, we prove directed graphs, by modifying the clause gadget of Plesn´ık’s NP -hardness proof[Ple79] and parsimoniously reducing from 1-in-3SAT instead of 3SAT. Previous work showed the analogous undirected problem ASP-complete (and Antidirected Eulerian paths.
In Section 4.2.1, we characterize when a directed graph admits an an-tidirected Eulerian path [Ber78, Fle90, ˇZit96], that is, a path that alternates between going forward andgoing backward along directed edges and visits every edge (in either direction) exactly once. (Such directedgraphs are called aneulerian [Ber78, Fle90, ˇZit96].) Specifically, we show how to reduce this problem tofinding an Eulerian path in a modified graph, enabling solution in linear time. Although antidirected Eulerianpaths were introduced over 50 years ago [Ber78], their existence does not seem to have been characterizedbefore our work and a recent independent discovery [AGW19]. This terminology naturally generalizes “parsimonious” ( c = 1), and was introduced in an MIT class in 2014 [Dem19]. Throughout this paper, we follow the half-standard terminology that paths and cycles are allowed to repeat verticesand/or edges (though we will rarely allow repeated edges). In a different half-standard terminology, these notions are called“walks/trails” and “circuits”. If a path or cycle makes no such repetitions, it is called simple . raph Partizan Geography Complexity undirected vertex vertex polynomialundirected vertex edge polynomialundirected edge vertex PSPACE-completeundirected edge edge PSPACE-completedirected vertex vertex PSPACE-completedirected vertex edge PSPACE-completedirected edge vertex PSPACE-completedirected edge edge PSPACE-completeTable 2: Partizan geography results Forbidden-transition Eulerian paths.
In Section 4.2.2, we give linear-time algorithms to find Eulerianpaths or antidirected Eulerian paths when certain monochromatic edge-to-edge transitions are forbidden,extending past work by Kotzig [Kot68] to be algorithmic (and to the antidirected case). Specifically, eachvertex can define a partition of its incident edges into groups, and the problem forbids the Eulerian pathfrom passing through the vertex via two edges from the same group.
Partizan Geography game.
We introduce eight new partizan variants of Geography where the twoplayers have different available moves, and characterize their complexity. Specifically, in vertex-partizangeography, vertices have two different colors, and each player can only move to vertices of their color; whilein edge-partizan geography, edges have two different colors, and each player can only move along edgesof their color. We can consider either variant for both Vertex and Edge Geography (where vertices andedges, respectively, cannot be repeated by either player), and in directed or undirected graphs, resulting ineight possible variants. Table 2 summarizes our results from Section 6.1, which prove every variant eitherpolynomial or PSPACE-complete.
In this section, we analyze the complexity of the following problems:
Definition 2.1. m × n < -compatible edge matching is the following problem: Instance: mn unit-square tiles, where each tile is defined by four numbers, one for each side. We use a b (cid:3) d c to represent a unit-square tile with numbers a, b, c, d . Question:
Can the mn tiles cover an m × n rectangle such that • for every two horizontally adjacent tiles, the left tile’s right number is strictly smaller than the righttile’s left number; and • for every two vertically adjacent tiles, the top tile’s bottom number is strictly smaller than the bottomtile’s top number?The related problem ≤ -compatible edge matching is defined similarly, except that we do not requirestrict inequalities among the numbers. ≤ -Compatible Edge Matching Theorem 2.1. m × n ≤ -compatible edge-matching puzzles are always solvable and a solution can be foundin O ( mn log( mn )) time.Proof. Rotate each tile AB (cid:3) DC such that A ≥ C and B ≥ D . Then sort the tiles in ascending order by D andplace them in the board in row-major order. Because B ≥ D , sorting by D ensures all tiles are vertically ≤ -compatible. Then sort the tiles in each row in ascending order by C . Because A ≥ C , sorting by C ensures4ll tiles in the row are horizontally ≤ -compatible. Being both vertically and horizontally ≤ -compatible, thisis a compatible tiling. This algorithm runs in O ( mn log( mn )) time from the sorting.The following special cases of the m × n < -compatible edge-matching puzzles are tractable: Corollary 2.2. m × n < -compatible edge-matching puzzles in which all edge labels are distinct are alwayssolvable and a solution can be found in polynomial time. Theorem 2.3. × n < -compatible edge-matching puzzles in which every tile has at least one pair of parallelsides with unequal labels are always solvable and a solution can be found in polynomial time.Proof. Rotate each tile AB (cid:3) DC such that A > C . If there are two pairs of unequal parallel sides, then choosearbitrarily. Now sort all tiles in ascending order by A , breaking ties arbitrarily, and place them in the boardin row-major order. Let A i and C i be the left and right numbers of tile i . From sorting, we know that A i ≤ A i +1 , and from our rotation of the tiles, we know that C i < A i . Composing the inequalities gives C i < A i +1 , which is the < -compatibility condition, so this is a compatible tiling. × n < -Compatible Edge Matching To show NP-hardness of < -compatible edge matching, we start from the known NP-hard problem N3P-3SAT-2P-E1N [DFZ11] defined in Section 2.2.1. In Section 2.2.2, we reduce N3P-3SAT-2P-E1N to a novelvariant literal-matching N3P-3SAT-2P-E1N. In Section 2.2.3, we reduce literal-matching N3P-3SAT-2P-E1Nto a new problem, Interval-Pair Cover, which implies NP-hardness of 1 × n < -compatible edge matching. Our starting point is the following variant of SAT (named to follow notation from [Fil19]):
Definition 2.2.
An instance of
N3P-3SAT-2P-E1N is an instance of 3SAT, consisting of n variables x , x , . . . , x n and m clauses each with at most three literals, where each literal is of the form x i (positive)or ¬ x i (negative), satisfying the following constraints:1. N3P : Every clause has at least one negative literal (i.e., no clause has three positive literals).2. : Every variable x i appears in at most two positive literals x i .3. E1N : Every variable x i appears in exactly one negative literal ¬ x i .Ding et al. [DFZ11] proved that N3P-3SAT-2P-E1N is NP-complete. In fact, they proved NP-completenessof a slightly more general problem, N3P-3SAT-3-1N, which constrains each variable to appear in at mostthree literals, at most one of which is negative. But any variable with zero negative occurrences can be elim-inated (setting it to true), so by repeated application of this process, we attain the E1N property. Becauseeach variable appears in at most three literals, at most two of them are positive, so we also have the 2Pproperty. Thus we reduce N3P-3SAT-3-1N to N3P-3SAT-2P-E1N. Define the shared-literal graph of a 3SAT instance to have one vertex for each clause, and connect twoclauses by an edge for each literal they share; see Figure 2. For a N3P-3SAT-2P-E1N instance, the shared-literal graph has two additional properties. By the E1N constraint, every edge corresponds to a shared positive literal. By the 2P property, the shared-literal graph has maximum degree 2. We will show that wecan in fact reduce the shared-literal graph to maximum degree 1.
Definition 2.3. A literal-matching N3P-3SAT-2P-E1N instance is an instance of N3P-3SAT-2P-E1Nwhose shared-literal graph is a matching. Theorem 2.4.
Literal-matching N3P-3SAT-2P-E1N is NP-complete. ∨ 𝑥𝑥 ∨ ¬ 𝑥𝑥 ∧ ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑥𝑥 ∧ 𝑥𝑥 ∨ 𝑥𝑥 ∨ ¬ 𝑥𝑥 𝑥𝑥 ¬ 𝑥𝑥 𝑥𝑥 𝑥𝑥 𝑥𝑥 (a) 3SAT formula ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑥𝑥 ∧ ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑥𝑥 ∧ 𝑥𝑥 ∨ ¬ 𝑥𝑥 ∨ 𝑥𝑥 𝑥𝑥 𝑥𝑥 𝑥𝑥 (b) N3P-3SAT-2P-1N formula Figure 2: Shared-literal graph: two examples. 𝑥𝑥 𝑥𝑥 𝑥𝑥 ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑥𝑥 ∧ ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑥𝑥 ∧ 𝑥𝑥 ∨ ¬ 𝑥𝑥 ∨ 𝑥𝑥 (a) Oriented N3P-3SAT-2P-E1N instance from Fig-ure 2b 𝑥𝑥 𝑥𝑥 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑦𝑦 ∧ ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑦𝑦 ∧ 𝑦𝑦 ∨ ¬ 𝑥𝑥 ∨ 𝑥𝑥 (b) Reduced literal-matching N3P-3SAT-2P-E1N in-stance Figure 3: Reduction from N3P-3SAT-2P-E1N to literal-matching N3P-3SAT-2P-E1N of Theorem 2.4.
Proof.
Trivially, literal-matching N3P-3SAT-2P-E1N ∈ NP. We reduce N3P-3SAT-2P-E1N to literal-matchingN3P-3SAT-2P-E1N to show literal-matching N3P-3SAT-2P-E1N is NP-hard. Refer to Figure 3.First we orient the shared-literal graph to have maximum indegree and maximum outdegree 1. Becausethe shared-literal graph is maximum degree 2, every connected component is either a path or a cycle. Directeach path from one end to the other, and direct each cycle cyclically.Reduction: For each edge ( c, d ) in the directed shared-literal graph, corresponding to a shared literal x i ,replace the occurrence of x i in d with a new helper variable h i . Additionally, create a new helper clause ¬ h i ∨ x i , i.e., h i ⇒ x i .This reduction conserves occurrences of the original (nonhelper) variables, and each helper variableappears positively once (replacing some x i in an original clause) and negatively once (in the helper clause),so the transformed formula is still N3P-3SAT-2P-E1N.The transformed formula is satisfiable under an augmented truth assignment σ X,H = σ X ∪ σ H if and onlyif the original formula is satisfiable under σ X . If h i satisfies an original clause (by being true), the helperclause enforces that x i is also true. If x i is false, the helper clause enforces that h i is also false, and so cannotsatisfy the original clause it is a member of. Thus if σ X,H satisfies the transformed formula, σ X satisfies theoriginal formula. Variable h i can be false when x i is true, but as x i already satisfies h i ’s helper clause and h i always appears positively in its original clause, such an assignment cannot satisfy more clauses than if h i were true. Thus if σ X satisfies the original formula, σ X,H = σ X ∪ { h i = σ X ( x i ) } satisfies the transformedformula.After replacing the occurrence of x i in clause d , each edge ( c, d ) in the original formula’s directed shared-literal graph corresponds to an edge between c and the helper clause containing x i in the transformedformula’s shared-literal graph, so original clauses have degree at most 1. Each helper variable appears onlyonce in each polarity, so helper variables do not give rise to edges in the shared-literal graph. Thus all helperclauses have degree 1. Then the transformed formula’s shared-literal graph has maximum degree 1, and sois a matching. To begin, we define a new problem Interval-Pair Cover; refer to Figure 4.
Definition 2.4.
Interval-pair cover is the following problem:
Instance:
A universe U = { , , . . . , n } and m pairs of closed intervals ([ a i , b i ] , [ c i , d i ]) for i = 1 , , . . . , m . Here a i , b i , c i , d i ∈ U , a i ≤ b i , and c i ≤ d i .6 (a) Input (b) Solution Figure 4: Interval-Pair Cover: sample input and solution. The two intervals in the same pair are colored thesame and share the same y coordinate. 𝑥𝑥 𝑥𝑥 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑦𝑦 ∧ ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑦𝑦 ∧ 𝑦𝑦 ∨ ¬ 𝑥𝑥 ∨ 𝑥𝑥 (a) Literal-matching N3P-3SAT-2P-E1N instance 𝑥𝑥 𝑥𝑥 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑦𝑦 ∧ ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑦𝑦 ∧ 𝑦𝑦 ∨ ¬ 𝑥𝑥 ∨ 𝑥𝑥 (b) Short drawing ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑦𝑦 ∧ ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑦𝑦 ∧ 𝑦𝑦 ∨ ¬ 𝑥𝑥 ∨ 𝑥𝑥 𝑥𝑥 𝑥𝑥 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ¬ 𝑥𝑥 𝑥𝑥 ¬ 𝑥𝑥 𝑥𝑥 𝑥𝑥 ¬ 𝑥𝑥 𝑦𝑦 ¬ 𝑦𝑦 𝑦𝑦 ¬ 𝑦𝑦 𝑦𝑦 ¬ 𝑦𝑦 (c) Interval-pair cover instance ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑦𝑦 ∧ ¬ 𝑥𝑥 ∨ 𝑥𝑥 ∨ 𝑦𝑦 ∧ 𝑦𝑦 ∨ ¬ 𝑥𝑥 ∨ 𝑥𝑥 𝑥𝑥 𝑥𝑥 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 ∧ ¬ 𝑦𝑦 ∨ 𝑥𝑥 𝑥𝑥 ¬ 𝑥𝑥 𝑥𝑥 𝑥𝑥 𝑦𝑦 ¬ 𝑦𝑦 𝑦𝑦 ¬ 𝑦𝑦 𝑦𝑦 ¬ 𝑦𝑦 ¬ 𝑥𝑥 ¬ 𝑥𝑥 (d) Solution Figure 5: Reduction from literal-matching N3P-3SAT-2P-E1N to Interval-Pair Cover of Theorem 2.5.
Question:
Is there a choice of one interval from each pair such that every i ∈ U is covered by somechosen interval? Theorem 2.5.
Interval-Pair Cover is NP-complete, even when every interval pair ([ a j , b j ] , [ c j , d j ]) satisfies a j = b j and d j − c j ∈ { , } .Proof. We reduce from literal-matching N3P-3SAT-2P-E1N; refer to Figure 5. We draw the shared-literalgraph on the integer line from 1 through n , placing the vertices at integer coordinates and using unit-lengthedges. This is always possible because the shared-literal graph is a matching. Then we create an interval pairfor each variable x i . The pair’s first interval contains only the coordinate of the vertex representing the clausewhere x i appears negatively; by the E1N property, there is exactly one. The pair’s second interval containsonly the coordinate(s) of the vertex or vertices representing the clause(s) where x i appears positively; bythe 2P property, there are at most two, and they are adjacent on the line because they share an edge in theshared-literal graph. If x i does not appear positively, we set the second interval equal to the first interval.The produced Interval-Pair Cover instance has a solution if and only if the input literal-matching N3P-3SAT-2P-E1N instance is satisfiable. Given a satisfying truth assignment, from the interval pair correspond-ing to variable x i , we choose the first interval if x i is assigned false and the second interval if x i is assignedtrue. Each chosen interval covers the coordinate(s) of the clause vertices satisfied by x i , so if the truthassignment satisfies the formula, the chosen intervals cover all integers in the universe. Given a completeinterval cover, we assign true to x i if the second interval was chosen from its corresponding pair and false ifthe first interval was chosen. By the same interval-variable correspondence, if the intervals cover all integersin the universe, the constructed truth assignment satisfies the formula. × n < -Compatible Edge MatchingTheorem 2.6. × n < -compatible edge matching is NP-complete. roof. We reduce from Interval-Pair Cover. For each integer i in the Interval-Pair Cover universe { , , . . . , n } ,we create two copies of the element tile i i (cid:3) i i . For each interval pair ([ a j , b j ] , [ c j , d j ]), we create an interval-pairtile a j − c j − (cid:3) d j +1 b j +1 . The edge-matching board is 1 × (2 n + m ), where n is the size of the universe and m is thenumber of interval pairs.Given a solution to the produced edge-matching instance, we can construct a solution to Interval-PairCover by choosing each interval tile’s horizontally-oriented interval (e.g., the interval [ a j , b j ] for a tile orientedas a j − c j − (cid:3) d j +1 b j +1 or as b j +1 d j +1 (cid:3) c j − a j − ). Suppose for contradiction that an element i is uncovered by every choseninterval. Then in every placed tile whose left edge is at least i + 1, its right edge is at least i , so the left edgeof the next tile is at least i + 1. In the sequence of left edges of tiles, the left edge of the tile after the firstcopy of i i (cid:3) i i is at least i + 1, so every following left edge is at least i + 1, leaving no place for the second copyof i i (cid:3) i i .Given a solution to Interval-Pair Cover, we can construct a solution to the produced edge-matchinginstance. We will first describe a solution that uses extra copies of i i (cid:3) i i . For each chosen interval [ a j , b j ],orient the tile as b j +1 d j +1 (cid:3) c j − a j − , and attach to its right a j a j (cid:3) a j a j , . . . , b j b j (cid:3) b j b j to get a sequence of tiles with leftedge b j + 1 and right edge b j . Now place, for each i ∈ { , , . . . , n } , the tile i i (cid:3) i i , followed by any of the abovesequences of tiles with left edge i + 1 and right edge i . That uses as many copies of i i (cid:3) i i as the number ofintervals that cover i , plus 1, which is at least two. We can remove any i i (cid:3) i i and leave a valid solution, soarbitrarily removing copies until there are two copies of each i i (cid:3) i i left leaves a solution to the edge-matchinginstance. × n Edge Matching ASP/
In this section, we adapt the work of [BDD +
17] to show that 1 × n edge-matching puzzles are ASP- and + Seta’s thesis [Set02] proves ASP-completeness for Hamiltonicity in planar maximum-degree-3 undirected graphs. Here we prove the analogous result for directed graphs:
Theorem 3.1.
Finding Hamiltonian cycles in a planar 3-regular directed graph with maximum indegree 2and maximum outdegree 2 is ASP-complete, and counting Hamiltonian cycles in those graphs is
These problems are clearly in FNP and Our reduction is patterned after Plesn´ık’s NP-hardness reduction from 3SAT for Hamiltoniancycle in this class of graphs [Ple79]. Plesn´ık’s reduction does not conserve the number of solutions becausethe clause gadget admits multiple solutions when multiple literals in the clause are satisfied (Figure 9a). Re-ducing from 1-in-3SAT and simplifying Plesn´ık’s clause gadget allows us to conserve the number of solutions,and reducing from positive Our proof does not actually use the planarity of the 1-in-3SAT instance. To avoid the exclusive-or crossover gadget, wewould need the variable-clause graph to remain planar with a line through all of the variables and all of the clauses, a variantnot known hard [Fil19].
Exclusive-or line.
An exclusive-or line between two edges abbreviates the pattern of additional verticesand edges shown in Figure 7. Traversing either of the two edges covers all of the additional vertices in exactlyone way, excluding the other original edge from the cycle. Traversing a path not corresponding to one of theoriginal edges (e.g., from the bottom left to bottom right in Figure 7) prevents the center four vertices frombeing part of any cycle (either they are uncovered, or they are the last four vertices in the path, so the pathis not a cycle). If neither of the two original edges is used, all of the additional vertices are uncovered.
Exclusive-or crossover.
Exclusive-or lines connecting variable gadgets to clause gadgets may cross, ne-cessitating the exclusive-or crossover shown in Figure 8. The crossover works by splitting each crossed-overedge between one pair of original edges into two edges and adding new exclusive-or lines that guarantee theparity of these paired edges is the same throughout the gadget. For example, in Figure 8, if the top edgeis in the cycle, then the top edge of each pair is also in the cycle and the bottom edge is not in the cycle,regardless of which of the left or right edges are in the cycle. As before, the expansion can be traversed inexactly one way for each pair of original edges traversed, and a traversal not corresponding to an originaledge leaves some vertices uncovered.
Variable gadget.
The variable gadget is a pair of vertices connected by a pair of parallel edges. Theedge on the interior face of the variable-clause cycle is connected by exclusive-or lines to each clause in whichthe variable appears; including this edge in the Hamiltonian cycle represents setting the variable to true.The other edge of the variable gadget is not connected to anything and represents setting the variable tofalse. The variable gadgets are connected in sequence.Plesn´ık’s variable gadget used two pairs of parallel edges, connected on the exterior by an exclusive-orline such that they have opposite settings, with the second pair connected to clauses where the variableappeared as a negative literal. We reduce from planar positive
Clause gadget.
Our clause gadget and its three Hamiltonian paths are shown in Figure 9b. The threerightmost edges in the clause gadget are connected by exclusive-or lines to the variable gadgets correspondingto the variables appearing in this clause. If a variable is set to true, then the rightmost edge connected tothat variable gadget cannot be in the cycle; otherwise, that rightmost edge must be in the cycle. If exactlyone of the three variables is true, then the clause gadget can be covered in exactly one way (using one of thepaths shown in Figure 9b). If a variable is true, the path must go to the left of that hexagon, where it mustenter the left loop. If the path leaves the left loop before visiting all vertices in it, it cannot visit the topvertex of the hexagon where it entered the loop, so the left loop must be covered in its entirety. But thenthe path cannot go left in any other hexagon, so the other variable must be false. If all variables are false,the left loop is uncovered. Thus this gadget simulates a 1-in-3SAT clause.Our clause gadget differs from Plesn´ık’s by the deletion of the “bridges” between the hexagons and theleft loop. The bridges allow multiple literals to be simultaneously true, which is necessary for Plesn´ık’sreduction (from 3SAT).
Conclusion.
Figure 6 shows a full instance produced by our reduction. For each satisfying assignmentof the variables, there is one corresponding Hamiltonian cycle using the corresponding configuration ofthe variable gadgets and the unique satisfying path through each clause gadget. Conversely, a satisfying The graph is a simple graph, not a multigraph: If we remove any variables not used in any clauses, then for each variable,one of these edges will be replaced by an exclusive-or gadget, leaving no parallel edges.
Theorem 3.2.
Finding Hamiltonian paths, with or without given start vertex s and/or end vertex t , inplanar 3-regular directed graphs with maximum indegree 2 and maximum outdegree 2 is ASP-complete, andcounting Hamiltonian paths in those graphs is s has outdegree 1 and the given vertex t has indegree 1.Proof. We prove this result via a parsimonious reduction from Hamiltonian cycle in planar 3-regular graphswith maximum indegree and outdegree 2. Given a 3-regular directed graph, we find an edge uv that must bein every Hamiltonian cycle (an outgoing edge from a vertex with indegree 2, or an incoming edge to a vertexwith outdegree 2). We split uv , introducing two degree-1 vertices but otherwise leaving the graph 3-regular.To restore 3-regularity we replace the degree-1 vertices with the graphs shown in Figure 10. The uniquelongest (simple) path entering the graph in Figure 10b ends at the vertex labeled t , because the first threevertices have outdegree 1 and the other successor of the fourth vertex is already in the path. By a similarargument working backwards from the outgoing edge of the graph in Figure 10a, the unique longest pathleaving the graph starts at the vertex labeled s . Thus, whether or not s and t are specified as the start andend vertices in the Hamiltonian path instance, all Hamiltonian paths in the transformed graph start at s and end at t . Vertex s has outdegree 1 and t has indegree 1, as claimed in the theorem statement. Because uv occurs in every Hamiltonian cycle of the input graph, there is a bijection between Hamiltonian cyclesin the input instance and Hamiltonian paths in the output instance, and this bijection can be computed inpolynomial time by replacing uv with the unique paths in the start/end gadgets or vice versa. × n Edge Matching
The symmetry of 1 × n edge-matching puzzles is problematic for ASP-hardness. Because rotating anysolution by 180 ◦ will give another solution, the answer to the ASP problem is always ‘yes’. To avoid thistrivial additional solution, we consider the version of 1 × n edge-matching puzzles where the left boundaryedge’s color is specified. This breaks the rotational symmetry, and we will show that this problem is ASP-complete through a parsimonious reduction. Without this restriction, our reduction is 2-monious, so weshow × n edge-matching puzzles without any such restriction.11 a) The three Hamiltonian paths through Plesn´ık’s clause gadget [Ple79, Fig. 2] when all three literals are true. (Theright edge of each hexagon is covered via the exclusive-or line from the variable gadget.)(b) The three Hamiltonian paths through our modified clause gadget. The right edges of two of the three hexagonsare always used, so this is a 1-in-3SAT clause. Figure 9: Comparison of Plesn´ık’s clause gadget and our modified clause gadget.The reduction in [BDD +
17] that establishes NP-hardness of 1 × n edge-matching puzzles is not parsimo-nious because of garbage collection: the tiles corresponding to edges which are not part of the Hamiltonianpath are placed at the end of the row of tiles in an arbitrary order. Our reduction will instead place theseunused tiles near the corresponding vertex tiles, so that there is only one tile sequence corresponding to eachHamiltonian path. Theorem 3.3. × n signed and unsigned edge-matching puzzles with the left boundary edge color specifiedare ASP-complete and Clearly this problem is in FNP and its counting problem is in + G with specified vertices s and t , we construct a 1 × n signed edge-matching puzzle as follows. (For the unsigned case, we will simply remove all signs.) For each edge e in G ,12 a) 3-regular start vertex gadget (b) 3-regular end vertex gadget Figure 10: Gadgets that replace degree-1 start or end vertices to restore 3-regularity to the overall graphwhile maintaining a unique Hamiltonian path. Vertices s and t are the new start and end vertices.we have a color e , and for each vertex v we have three colors v I , v O , and v X . For each vertex v , we buildthree tiles; refer to Figure 11. In one case, v has one edge e coming in and two edges e and e going out.Then we construct the tiles + e − v X (cid:3) − v X − v I , + v O − v O (cid:3) + v I − e , and + v O − v O (cid:3) + v I − e . In the other case, v has two edges e and e coming in and one edge e going out. Then we construct thetiles + e + v I (cid:3) − v O − v I , + e + v I (cid:3) − v O − v I and + v O − v X (cid:3) − v X − e . Each of these tiles corresponds to one of the half-edges incident to v . (Overall, each edge is represented bytwo half-edge tiles.) We use that s has outdegree 1 and t has indegree 1, as provided by Theorem 3.2. Weremove the tiles corresponding to the half-edges entering s and the tiles corresponding to half-edges leaving t , so s and t each have only one corresponding tile. Finally, we specify that the left boundary edge hascolor − s O .We claim that the number of solutions to this edge-matching puzzle is the same as the number ofHamiltonian paths in G from s to t .First suppose that we have such a Hamiltonian path s = v , v , . . . , v | V | = t . We can construct asolution to the edge-matching puzzle by placing the three tiles for each vertex v i consecutively, in the order i = 1 , , . . . , | V | the vertices appear in the path. As in the bottom of Figure 11, we place the three tilesfor each vertex v i so that the tiles corresponding to the edges e i = ( v i − , v i ) and e i +1 = ( v i , v i +1 ) that thepath uses to enter and exit v are first and last, respectively, so the sequence of colors is e i , v i,I , v i,O , e i +1 .The exposed colors are + e i on the left and − e i +1 on the right, so the these placed triples of tiles match upat their ends (because the sequence of vertices is a path). There is only one tile for each of s and t , whichwe place at the beginning and end. The left boundary color is then + s O , as required, and the rightmostboundary color is + t I .Next we show that every solution to the edge-matching puzzle has this form, and thus corresponds toa Hamiltonian path. Suppose we have a solution to the edge-matching puzzle. Because the left boundarycolor is − s O , the tile corresponding to s must be placed on the left oriented with + s O on the left and theoutgoing edge color on the right. The only tile corresponding to t is + e − t X (cid:3) − t X − t I , where e is the incoming edge.Because colors t X and t I do not appear on any other tiles, this tile must be placed rightmost with color + e on the left. 13 a) A vertex with indegree 1 andoutdegree 2. (b) A vertex with indegree 2 andoutdegree 1. Figure 11: The tiles in the reduction showing ASP- and × n edge-matching puzzles. Atthe bottom we show one possible edge-matching solution corresponding to one (blue) path through v .Consider a vertex v other than s and t . None of the tiles corresponding to v can be at either end of thesolution, because those spaces are claimed by s and t . Suppose v has indegree 1 and outdegree 2; the othercase is similar. Because + e − v X (cid:3) − v X − v I is the only tile with the color v X , it must be adjacent to other tiles on theother two sides. The tile adjacent on the side with color − v I must be one of the two other tiles correspondingto v . Whichever tile it is, its orientation is fixed by matching color v I , so the opposite side must have color − v O , so the following tile must be the third tile corresponding to v , with the color of another edge incidentto v on the side touching the next tile. In summary, the three tiles corresponding to v must be consecutive,and the two colors they expose to other tiles are two edges incident to v with different orientations relativeto v , with the local configuration of the three tiles determined by those exposed colors.Suppose the sequence of tiles corresponding to vertex u are adjacent to the sequence corresponding tovertex v . Then the side where these sequences touch must have color e , where e is either ( u, v ) outgoing from u and incoming to v or ( v, u ) outgoing from v and incoming to u . The other left and right edges of thesetiles must also have edge colors corresponding to edges incident to u and v . By induction, if the solution hasseveral consecutive sequences of tiles corresponding to vertices, the sequence of vertices must form a path in G in either direction. The entire solution must therefore be a concatenation of sequences corresponding tovertices starting with s and ending with t , such that adjacent vertices share an edge from left to right, andusing each tile exactly once. Hence it must correspond to a Hamiltonian path.For each Hamiltonian path, there is exactly one corresponding solution to the edge-matching puzzle,because there is only one way to connect the tiles corresponding to a vertex for each pair of edges usedat that vertex. So there are the same number of Hamiltonian paths in G from s to t and solutions to theedge-matching puzzle. Because this reduction is parsimonious, it shows that 1 × n signed edge-matchingpuzzles with the color of the left boundary edge specified is ASP- and Corollary 3.4. × n signed and unsigned edge-matching puzzles are Without a specified left boundary color, we cannot guarantee that the tile corresponding to the startvertex s is on the left and the tile corresponding to the end vertex t is on the right; instead we only have thatthey are at the ends. Thus each solution to the edge-matching puzzle can be rotated 180 ◦ to form another14olution, so the reduction is 2-monious. In this section, we study 1 × n edge-matching puzzles with triangular tiles, specifically, equilateral and rightisosceles triangles. There is one natural interpretation of “1 × n ” for equilateral triangles, as shown inFigure 12a. However, for right isosceles triangles, there are two natural interpretations. If the triangles havelegs of length 1, then to pack a 1 × n box they must have alternating hypotenuse/leg contact, which we willsimply refer to as hypotenuse contact, as shown in Figure 12b. On the other hand, if the triangles have aheight of 1, then they must be packed using only leg-to-leg contacts, as shown in Figure 12c. (a) Equilateral triangles(b) Right triangles, hypotenuse contact (c) Right triangles, leg contact Figure 12: Three types of triangular tiles.Hypotenuse-contact right triangles can directly and parsimoniously simulate square tiles: for each square,create two triangles whose hypotenuses have a matching, unique color. (This idea is mentioned in anothercontext in the conclusion of [BDD + In this section, we prove NP/ × n equilateral triangular edge-matching puzzles. Westart with an NP-completeness proof, then augment it and analyze it further to prove Theorem 4.1. × n signed and unsigned equilateral-triangle edge-matching puzzles are NP-complete. Thesame results hold if we allow tile reflection.Proof. Clearly these problems are in NP. To show NP-hardness, we reduce from Hamiltonian path in 3-regular undirected graphs [GJ79] (in contrast to Section 3 which considered directed graphs). We describesigned tiles resulting from our reduction to signed edge matching; for the unsigned puzzle, we will just dropthe signs. Similar to the proof of Theorem 3.3, we will create exactly two tiles per edge; refer to Figure 13.To assign complementary signs to the edge colors, arbitrarily orient each edge e (but paths need not followthis orientation). For every vertex v with incident edges e , e , e , construct the triangular tiles + v (cid:52) ± e − v , + v (cid:52) ± e − v , and + v (cid:52) ± e − v , where the sign of each e i color is positive if e i was arbitrarily oriented to be incoming to v and negativeotherwise. We claim that these tiles have a signed or unsigned edge-matching solution if and only if thegraph has a Hamiltonian path.First suppose that there is a Hamiltonian path v , v , . . . , v n . We can construct an edge-matching solutionby, for each vertex v i , arranging the three corresponding tiles so that { v i − , v i } is on the left boundary edge15igure 13: NP-hardness of 1 × n equilateral-triangle edge matching, showing one possible (blue) path through v and the corresponding edge-matching solutions (depending on parity up to this point).and { v i , v i +1 } is on the right boundary edge, as in Figure 13 (right, top or bottom according to parity of i as required by the tiling). The figure illustrates that the vertex colors match with opposite signs, and thattiles do not need to be reflected. By the arbitrary orientation of the edges, every edge color will match withits negated color.Now suppose that there is an edge-matching solution, even without the color signs. Without the colorsigns, the tiles are reflectionally symmetric, so the following argument works also when we allow tile reflection.Each vertex color v appears in exactly three tiles, so the three vertex tiles can match only with each other, orsome of them can appear as the extreme left or extreme right tile. If any of the three tiles for v are extreme,then none of the tiles can be placed in the middle of an edge-matching solution (lacking the three tilesrequired to form an 180 ◦ angle), so in this case, all three tiles for v appear at the left and right extremes ofthe solution, effectively “wrapping around” the 1 × n board. For every other vertex, the three correspondingtiles must appear together. Listing all of the vertices in the order in which their color appears in the solutionyields a Hamiltonian path of the original graph. (If one vertex’s tiles wrap around, then this process yieldsa Hamiltonian cycle, which is stronger.)The proof above suggests an alternate approach to proving Theorem 3.3 about squares: unify the v I , v O , v x colors into a single color, and reduce from undirected Hamiltonian path. However, for unsigned colors, thischange would make the reduction not parsimonious, because it enables the middle tile to rotate by 180 ◦ inthe two arrangements on the bottom of Figure 11. But equilateral triangles lack this ambiguity, and we areable to obtain parsimony by a more careful handling of the start and end.First we need a slightly different form of undirected Hamiltonicity: Lemma 4.2.
Finding Hamiltonian paths, with or without specified start vertex s and/or end vertex t ,in maximum-degree-3 planar undirected graphs is ASP-complete, and counting Hamiltonian paths in thosegraphs is s, t have degree 1.Proof. We present a parsimonious reduction from Hamiltonian cycle in maximum-degree-3 planar undirectedgraphs (the same graphs) having at least one vertex of degree 2, proved ASP-complete by Seta [Set02]. Ourreduction is similar to the first step in the proof of Theorem 3.2.Let G be a maximum-degree-3 undirected graph with a degree-2 vertex v . Let { u, v } be one of v ’s incidentedges, which must be in every Hamiltonian cycle. Construct G (cid:48) by adding two new vertices s and t , andreplacing the edge { u, v } with edges { s, u } and { t, v } . Because s and t have degree 1, they are in everyHamiltonian path of G (cid:48) . Because edge { u, v } is contained in every Hamiltonian cycle in G (cid:48) , there is a directbijection between Hamiltonian cycles in G and Hamiltonian ( s - t ) paths in G (cid:48) . Theorem 4.3. × n signed and unsigned equilateral-triangle edge-matching puzzles with the left boundaryedge color specified are ASP-complete and Clearly this problem is in FNP and its counting problem is in s - t paths in maximum-degree-3 undirected graphs where s and t <
3. For each degree-2 vertex v , we attach a half-edge { v } (with no other endpoint), and then apply the degree-3 construction from Figure 13. We can assume thatthe only degree-1 vertices are s and t , because any other degree-1 vertices could not possibly be reached by an s - t path (and thus in this case we could parsimoniously reduce by constructing any unsolvable edge-matchinginstance). For the degree-1 vertices s and t , we create corresponding tiles s ∠∠ U ± e and ± e ∠∠ U U , where e and e represent the unique edges incident to s and t respectively, with signs chosen for these edgecolors based on our arbitrary orientation of the original graph, in the same fashion as for all other tiles. (Asbefore, for the unsigned problem, we just drop the signs.) Each occurrence of U represents a unique colornot occurring in any other tile. Finally, we specify the left boundary color to be s , which is another uniquecolor.Because the tile corresponding to vertex s is the only one with color s , it must be placed as the leftmosttile. Because the tile corresponding to t has two sides with unique colors, it must be placed as the rightmosttile. As argued in Theorem 4.1, every triplet of tiles corresponding to a degree-3 (or degree-2) vertex mustoccur consecutively, because the s and t tiles prevent “wrapping around”. Therefore every edge-matchingsolution induces an ordering of the vertex tile triplets between the leftmost s tile and the rightmost t tile. Toguarantee a bijection between edge-matching solutions and Hamiltonian s - t paths solutions, it only remainsto show that, given an ordering of the tile triplets, there is a unique arrangement of the three tiles withineach triplet.Suppose the tile triplet for vertex v occurs between the triplets for vertices u and w . The only edge colorsthat v ’s triplet have in common with u ’s and w ’s triplets are the colors representing edges { u, v } and { v, w } in the original graph, so the two tiles in v ’s triplet containing the { u, v } and { v, w } colors must be on theleft and right respectively, with those edges exposed. The remaining tile in the triplet has no choice butto be oriented between them with its v -colored edges facing the two other tiles in the triplet, and its thirdedge facing the 1 × n boundary. Thus the arrangement of tiles within each triplet is uniquely defined by theordering of tile triplets along the box, completing the proof that our reduction is parsimonious. Corollary 4.4. × n signed and unsigned equilateral-triangle edge-matching puzzles are As in Corollary 3.4.
In this section, we show that edge matching with right isosceles triangles that tile a 1 × n box by leg contact(as in Figure 12c) is closely related to finding an Eulerian path in a graph, or more precisely, two variantscalled antidirected and forbidden-transition Eulerian paths analyzed in Sections 4.2.1 and 4.2.2 respectively.We use this connection to show that these puzzles can be solved in polynomial time (Section 4.2.3), andthen to show that counting solutions to these puzzles is Consider a directed graph G . Recall that a (directed) Eulerian path is a directed path in G (respectingthe edge directions in G ) that visits every edge in G exactly once. It is well-known that a connected graphhas such a path if and only if it has zero or two vertices of odd degree [BM76, Corollary 4.1], and in thiscase, the path can be constructed in linear time [Fle91].Here we analyze the variant where the edge directions of G must alternate. Precisely, an antidirectedpath [Gr¨u71, Ber78, BJBJK17] is a sequence of edges where every pair of consecutive edges share an endpoint(an undirected path) and furthermore those edges either both point toward or both point away from thatshared endpoint. In other words, an antidirected path alternates between following an edge of G in the“forwards” direction and following an edge of G in the “backwards” direction, with an arbitrary startingparity. An antidirected Eulerian path [Ber78, Fle90, ˇZit96] of G is an antidirected path of G that visits17igure 14: Reduction from antidirected Eulerian path to Eulerian path.every edge (either forwards or backwards) exactly once. Examples of past results on this topic include thata directed graph without degree-2 vertices has an odd number of Eulerian paths if and only if it is 4-regularand has an antidirected Eulerian path [Ber78], while not every connected 4-regular undirected graph withan odd cycle has an orientation admitting an antidirected Eulerian path [ˇZit96].In the [antidirected] Eulerian path problem , we are given a directed graph G , and want to knowwhether G has an [antidirected] Eulerian path, and if so, to find one. We relate these two problems: Theorem 4.5.
The antidirected Eulerian path problem can be reduced in linear time to the Eulerian pathproblem.Proof.
Let G be a directed graph input for the antidirected Eulerian path problem. Construct an undirectedbipartite graph G (cid:48) (called the “split” of G by West [Wes01, Definition 1.4.20]) as follows; refer to Figure 14.For each vertex v ∈ G , construct two vertices v + and v − in G (cid:48) . For every directed edge e = ( u, v ) ∈ G , addthe undirected edge e (cid:48) = { u + , v − } to G (cid:48) . Because every edge in G (cid:48) connects a plus vertex to a minus vertex, G (cid:48) is bipartite.We claim that paths in G (cid:48) correspond to antidirected paths in G . For any path p (cid:48) = ( v ± , v ∓ , v ± , v ∓ , . . . )in G (cid:48) (where signs alternate by bipartiteness), consider mapping each edge of the form { v + i , v − i +1 } in p (cid:48) to thecorresponding edge ( v i , v i +1 ) of G , and mapping each edge of the form { v − i , v + i +1 } in p (cid:48) to the (backwardstraversal of) the corresponding edge ( v i +1 , v i ) of G . Then we obtain an antidirected path in G . Because themapping between edges of G and G (cid:48) is a bijection, so is this transformation. By the same bijectivity, if p (cid:48) isEulerian, then so is p . Therefore Eulerian paths in G (cid:48) correspond to antidirected Eulerian paths in G .A similar result was obtained independently in [AGW19].For our application to edge matching, we will need to solve a slightly stronger version of the problem: Corollary 4.6.
The antidirected Eulerian path problem can be solved in linear time. The same result holdsif the path is further restricted to start and/or end with specified direction (forwards or backwards).Proof.
The first sentence follows from the reduction of Theorem 4.5 combined with linear-time algorithmsfor finding Eulerian paths [Fle91].Now suppose we are given the starting and ending directions s, t ∈ { forwards , backwards } for an an-tidirected Eulerian path. Applying the previous algorithm, we can detect whether G has any antidirectedEulerian path, i.e., whether G (cid:48) from the proof of Theorem 4.5 has any Eulerian path. If the answer is“no”, then we are done. Otherwise, by the characterization of Eulerian paths [BM76, Corollary 4.1], either(1) every vertex of G (cid:48) has even degree, or (2) exactly two vertices of G (cid:48) have odd degree.In the first case, every Eulerian path p (cid:48) of G (cid:48) is also a cycle, so when we translate to an antidirectedEulerian path/cycle p of G , the starting orientation is the same as the ending orientation if and only if G has an odd number e of edges. Thus we can answer the restricted antidirected Eulerian path problem bychecking whether ( s = t ) ↔ ( e odd). If s = t and e is odd, then we find an antidirected Eulerian cycle andchoose the starting parity for a path to match s = t . If s (cid:54) = t and e is even, then we find any antidirectedEulerian cycle and any starting point, and reverse the path if s and t mismatch. Otherwise, no satisfyingantidirected Eulerian path exists. 18n the second case, every Eulerian path p (cid:48) of G (cid:48) has its endpoints at the two odd-degree vertices o , o of G (cid:48) , so every antidirected Eulerian path p in G has its extreme edge orientations determined by whether o and o are plus or minus vertices (and which is chosen to be the start versus end of the path). If o and o are both plus vertices, then s = forwards and t = backwards is the only possibility. If o and o are bothminus vertices, then s = backwards and t = forwards is the only possibility. If o and o are plus and minusvertices, then s = t is the only constraint: if s = t = forwards, then we start at the plus vertex; and if s = t = backwards, then we start at the minus vertex. Otherwise, no satisfying antidirected Eulerian pathexists.Therefore we can solve the restricted form of the antidirected Eulerian path problem. In the forbidden-transition Eulerian path problem [Kot68], we are given an undirected graph G =( V, E ) and, for every vertex v ∈ V , a partition of the edges E v incident to v into groups P v, , P v, , . . . , P v,k v .The goal is to find an Eulerian path v , v , . . . , v | E | of G such that, for every vertex visit v i where 0 < i < | E | ,the incident edges ( v i − , v i ) and ( v i , v i +1 ) belong to different groups among P v i , , P v i , , . . . , P v i ,k vi . In otherwords, we forbid the subpath ( v i − , v i , v i +1 ) when ( v i − , v i ) and ( v i , v i +1 ) belong to a common group P v i ,j . In a forbidden-transition Eulerian cycle , we similarly restrict the subpath ( v | E |− , v | E | = v , v ).Kotzig [Kot68] showed (in a slightly more general scenario) that the natural necessary conditions for thisproblem are in fact sufficient. We repeat Kotzig’s mathematical argument here in order to verify that it alsoyields an efficient algorithm. Theorem 4.7 ([Kot68]) . An undirected graph G and partition system P has a forbidden-transition Eulerianpath if and only if G has an Eulerian path and every group P v,i has | P v,i | ≤ (cid:100) degree( v ) / (cid:101) . If furthermore G has an Eulerian cycle, then ( G, P ) has a forbidden-transition Eulerian cycle. When such a path/cycle exists,it can be found in linear time.Proof. By the characterization of Eulerian paths [BM76, Corollary 4.1], G must have exactly zero or twovertices of odd degree. We can reduce to the case of zero odd-degree vertices as follows. If G has twoodd-degree vertices, then add an edge between them, which increases their degrees to even but does notchange (cid:100) degree( v i ) / (cid:101) . Now apply the zero-odd-degree-vertices case of the present theorem (proved below)to obtain an Eulerian cycle with the desired property. Removing the added edge results in an Eulerian pathwith the desired property. Therefore we can assume every vertex has even degree, so we can ignore theceilings.Next we prove that the conditions are necessary. Clearly G having an Eulerian path is necessary for itto have a forbidden-transition Eulerian path. If any | P v,i | > degree( v ) /
2, then we claim that (
G, P ) cannothave a forbidden-transition Eulerian path. Any Eulerian path in G is a cycle, and thus its traversal orderpairs up the edges E v incident to v into degree( v ) / P v,i , which is a forbidden transition.Now suppose G has an Eulerian path and every group P v,i satisfies | P v,i | ≤ degree( v ) /
2. For each vertex v , order its incident edges E v = { e , e , . . . , e degree( v ) } so that all edges from group P v,i appear consecutivelyin the ordering, for all 1 ≤ i ≤ k v . Now pair each edge e j with e j +degree( v ) / , for 1 ≤ j ≤ degree( v ) / | P v,i | ≤ degree( v ) /
2, this pairing has no forbidden pairs. The perfect pairing at each vertexpartitions the graph’s edges into edge-disjoint cycles.To merge these cycles into one Eulerian cycle, take any two cycles
C, C (cid:48) that share a vertex v (whichexist because G has an Eulerian path so its edges are connected). Suppose one cycle pairs edges ( e , e )at v , while the other cycle pairs edges ( e (cid:48) , e (cid:48) ) at v . Suppose e , e , e (cid:48) , e (cid:48) are in groups i , i , i (cid:48) , i (cid:48) . If wechange the local pairing to ( e , e (cid:48) ) and ( e (cid:48) , e ), then we merge the cycles, and avoid forbidden pairs provided i (cid:54) = i (cid:48) and i (cid:48) (cid:54) = i . If we change the local pairing to ( e , e (cid:48) ) and ( e (cid:48) , e ) (and reverse one of the cycles),then we again merge the cycles, this time avoiding forbidden pairs provided i (cid:54) = i (cid:48) and i (cid:48) (cid:54) = i . Because It is tempting to think that antidirected Eulerian path in a directed graph is a special case of forbidden-transition Eulerianpath in an undirected graph, using two groups at each vertex to represent the outgoing vs. incoming edges. However, theantidirected constraint requires repeating the incoming/outgoing nature at each vertex, while the forbidden-transition constraint prevents repeating the incoming/outgoing nature at each vertex. i (cid:54) = i and i (cid:48) (cid:54) = i (cid:48) . Thus we can have at most two equalities among thefour possible comparisons between { i , i } and { i (cid:48) , i (cid:48) } . Therefore one of the two merging strategies works.We can implement this algorithm in linear time by constructing the pairing locally as linked pointers,representing each cycle as a doubly linked list on its edges, where each edge stores its two neighboring edgesin the cycle in no particular order. Number the cycles 1 , , . . . , k , and iterate over the cycles to mark eachvertex with each of the cycles it belongs to, along with one edge pairing from that cycle. Label cycle 1 as“merged” and the rest as “unmerged”. Perform a depth-first search in G from any vertex that is in cycle 1.At each vertex v visited, iterate through the cycles that v belongs to (via v ’s marks); if any cycle i has notyet been merged, then merge it into cycle 1 by adjusting O (1) pointers among v ’s marked edge pairings forcycles 1 and i , labeling cycle i as “merged”. By induction, every vertex visited by the depth-first searchwill have already been merged into cycle 1. The running time beyond the linear cost of depth-first searchis proportional to the number of marks, which (by the Handshaking Lemma) is twice the number of edges.This algorithm is essentially the efficient implementation of Hierholzer’s Algorithm for Eulerian tours from[Fle91].Next we combine this result with the results of Section 4.2.1 about antidirected Eulerian paths. For a directed graph G and a partition system P , define a forbidden-transition antidirected Eulerian path in ( G, P ) to be an antidirected Eulerian path e , e , . . . , e | E | of G such that no two edges e i and e i +1 belongto a common group P v,j where v is the shared vertex of e i and e i +1 . Corollary 4.8.
The forbidden-transition antidirected Eulerian path problem can be solved in linear time.The same result holds if the path is further restricted to start and/or end with specified direction (forwardsor backwards).Proof.
Apply the reduction of Theorem 4.5 to obtain an undirected graph G (cid:48) with the property that Eulerianpaths in G (cid:48) correspond to antidirected Eulerian paths in G . For each vertex v ± of G (cid:48) and each 1 ≤ i ≤ k v ,define P (cid:48) v ± ,i to be the set of edges of G (cid:48) incident to v ± that correspond to edges of G in P v,i . Then applyTheorem 4.7 to decide whether ( G (cid:48) , P (cid:48) ) has a forbidden-transition Eulerian path, which is equivalent towhether ( G, P ) has a forbidden-transition antidirected Eulerian path. To handle the start/end directionconstraints, we can apply the same post-analysis as in Corollary 4.6.
Now we use the algorithms we have built for antidirected and forbidden-transition Eulerian paths to solveleg-contact right-isosceles-triangle edge matching. The unsigned case reduces to antidirected Eulerian paths,while the signed case reduces to forbidden-transition antidirected Eulerian paths.
Theorem 4.9. × n signed and unsigned leg-contact right-isosceles-triangle edge-matching puzzles can besolved in linear time.Proof. First note that tile hypotenuses can never touch in a 1 × n box by leg contact, so we can ignore thoseedges’ colors completely. We treat the signed and unsigned cases separately: Unsigned case:
Our algorithm reduces unsigned edge matching to the antidirected Eulerian pathproblem in a directed graph, as solved in Section 4.2.1. Given an instance of unsigned 1 × n leg-contactisosceles-right-triangle edge matching, we construct a directed graph G as follows. Create a vertex for eachunique color that occurs on the legs of the tiles. For every triangle u ∠∠ H v , create a directed edge ( u, v ).Any edge-matching solution consists of some ordering of the triangles that they pack into the 1 × n box,with triangles alternating between being oriented with its hypotenuse on the top or bottom (see Figure 12c),and consecutive triangles matching on their shared edges. We claim that such an edge-matching solutioncorresponds, by replacing each tile with its corresponding edge in G , to an antidirected Eulerian path in G .First, the path must be antidirected: following an edge ( u, v ) in the forwards direction corresponds to placing u ∠∠ H v with its hypotenuse on the bottom (so colors u and v on the left and right, respectively), while followingedge ( u, v ) in the reverse direction ( v, u ) corresponds to placing the tile rotated 180 ◦ with its hypotenuse onthe top (so colors v and u on the left and right, respectively). Second, the path must be Eulerian, becausean edge-matching solution must use every tile exactly once.20he last constraint to handle is the left and right boundary conditions. If the left edge of the box has anacute angle at the bottom [top], then the first tile must be placed with its hypotenuse on the bottom [top],so the first edge of the antidirected Eulerian path must be forwards [backwards]. Similarly, if the right edgeof the box has an acute angle at the bottom [top], then the last tile must be placed with its hypotenuse onthe bottom [top], so the first edge of the antidirected Eulerian path must be forwards [backwards]. Theseconstraints are exactly what Corollary 4.6 handles in polynomial time. By deciding whether G has anappropriate antidirected Eulerian path, we decide whether the edge-matching puzzle has a solution, and anactual solution can be converted by the tile–edge correspondence. Signed case:
Our algorithm reduces signed edge matching to the forbidden-transition antidirectedEulerian path problem in a directed graph, as solved in Section 4.2.2. Given an instance of signed 1 × n leg-contact isosceles-right-triangle edge matching, we construct the same directed graph G as the unsigned case.To capture the color sign constraint on adjacent tiles, we define forbidden transitions for the antidirectedEulerian path in G . Specifically, for each vertex corresponding to an unsigned color c , define four groups:1. P c, consists of all edges incoming to c corresponding to tiles of the form ∠∠ + c ;2. P c, consists of all edges incoming to c corresponding to tiles of the form ∠∠ − c ;3. P c, consists of all edges outgoing from c corresponding to tiles of the form + c ∠∠ ; and4. P c, consists of all edges outgoing from c corresponding to tiles of the form − c ∠∠ .We claim that edge-matching solutions correspond to forbidden-transition antidirected Eulerian paths in( G, P ). Any antidirected path, when visiting a vertex c not as a path endpoint, will use either two incomingedges (groups 1 and 2) or two outgoing edges (groups 3 and 4). The forbidden transitions thus exactlyprevent matching together two instances of c of the same sign. Therefore Corollary 4.8, with the samestart/end conditions as the unsigned case, solves the problem. Even though leg-contact right-isosceles-triangle edge-matching puzzles are not hard to solve, counting theirsolutions remains hard.
Theorem 4.10. × n signed and unsigned leg-contact right-isosceles-triangle edge-matching puzzles are We reduce from counting the number of Eulerian cycles in an undirected graph, proved G , we first add two vertices s, t and attach them to an arbitraryvertex v of G , forming an undirected graph G (cid:48) . The number of Eulerian cycles in G is exactly twice thenumber of Eulerian paths in G (cid:48) (whose endpoints are necessarily s and t — which endpoint is the start ofthe path incurs the factor of 2). Thus we can reduce from counting the number of Eulerian paths in a graph G (cid:48) with two degree-1 vertices s, t . Unsigned case:
For the endpoint vertices s, t , construct two corresponding triangles U ∠∠ H s and U ∠∠ H t , where s and t are colors representing those vertices, H is an arbitrary hypotenuse color, and U and U areglobally unique colors. Because U and U appear only in these tiles, the tiles must be placed leftmost andrightmost in the puzzle (where the rightmost tile is rotated 180 ◦ ).For each edge e = { u, v } in G (cid:48) , construct two corresponding triangles e ∠∠ H u and e ∠∠ H v , where u, v are colors representing these vertices and e is a color representing this edge. Because color e appears only in these two tiles, these tiles must be placed together (with one of them rotated 180 ◦ ), resulting21n a parallelogram with left color u and right color v or, rotating 180 ◦ , the same shape with left color v andright color u . Thus these two tiles (or the resulting parallelogram) simulates the edge { u, v } that can beused in either direction.It follows that edge-matching solutions correspond bijectively to Eulerian paths in G (cid:48) . Signed case:
For the endpoint vertices s, t , construct two corresponding triangles U ∠∠ H + s and U ∠∠ H + t , where s and t are colors representing those vertices, H is an arbitrary hypotenuse color, and U and U areglobally unique colors, forcing these tiles to be placed leftmost and rightmost in the puzzle.For each vertex v / ∈ { s, t } in G (cid:48) , which has even degree k , construct k/ − v X ∠∠ H + v and + v X ∠∠ H + v , where v, v X are two colors corresponding to vertex v . Because v X appears only in these two triangles, theymust be placed together (with one of them rotated 180 ◦ ) to match up the v X -color edges, resulting in aparallelogram with end colors + v and + v .For each edge e = { u, v } in G (cid:48) , construct two corresponding triangles − e ∠∠ H − u and + e ∠∠ H − v , where u, v are colors representing these vertices and e is a color representing this edge. (This constructiondepends slightly on how we distinguish the endpoints of e as u and v , but the choice can be made arbitrarilyfor each edge without affecting the rest of the construction.) Because color e appears only in these two tiles,these tiles must be placed together (with one of them rotated 180 ◦ ), resulting in a parallelogram with leftcolor − u and right color − v or, rotating 180 ◦ , the same shape with left color − v and right color − u .By the signs of the colors, any edge-matching solution must alternate between edge parallelograms andvertex parallelograms, starting and ending with edge parallelograms, surrounded by the s and t triangles. Itfollows that edge-matching solutions correspond to Eulerian paths in G (cid:48) .This reduction is not parsimonious. Each vertex parallelogram (with the same external colors of + v ) canbe formed in two ways, blowing up the number of solutions by a factor of 2. If G (cid:48) has m edges, then thereare m − (cid:80) v / ∈{ s,t } degree( v ) / m − . Furthermore, ifwe do not treat copies of the vertex tiles as identical, then the k/ k vertex tile can bepermuted arbitrarily, blowing up the number of solutions by a factor of ( k/ . The total blowup is thus c = 2 m − (cid:81) v (degree( v ) / , an easy-to-compute constant, making the reduction c -monious. In this section, we analyze the complexity of the following problems:
Definition 5.1.
Signed/unsigned shapeless edge matching is the following problem: given a set of n unit square tiles where each edge of each tile is given a color (and a sign in the signed case), can the tilesbe laid out in any configuration in the plane such that the overall arrangement is connected via edges, andall edge-to-edge contacts between tiles are compatible? In the rooted variant, the problem specifies a singletile to be fixed at the origin in a specified orientation.The distinguishing feature of this problem, compared to the rectangular edge-matching problems forwhich hardness is already known, is that the target shape is not specified, so there is no constraint onthe spatial footprint of a solution. We will show that shapeless edge matching is NP-complete and rootedshapeless edge matching is ASP-complete and × n edge matching withspecified left boundary color, which was proved NP-complete by [BDD +
17] and proved ASP/ n = 5. Grey squares show regions which cannotbe occupied by further tiles because they are adjacent to U -colored edges. Theorem 5.1.
Signed and unsigned shapeless edge-matching puzzles are NP-complete.Proof.
A shapeless edge-matching solution can clearly be checked in polynomial time, so shapeless edgematching is in NP.To prove NP-hardness, we reduce from 1 × n edge matching with specified left boundary color. Supposewe are given an instance consisting of a set T of n tiles (signed or unsigned) and a single color L denoting thecolor of the left boundary edge of the 1 × n target box. We will produce a shapeless edge-matching instanceconsisting of tile set T ∪ T (cid:48) , where | T (cid:48) | = O ( | T | ) = O ( n ).We design tile set T (cid:48) to force these tiles into a rectangular frame structure that simulates a 1 × n box. Figure 15 lists the tiles, and Figure 16 shows their intended placement. We use four new colors { T W, RW, BW, LW } that appear positively and negatively (or in the unsigned case, without signs); eachinstance of U represents a globally unique (and hence unmatchable) color.Next we show that the frame tiles in T (cid:48) must be positioned to form the frame shown in Figure 16. Ourproof mentions signed tiles, but does not depend on these signs, so works equally well in the unsigned case bydropping signs from all tiles. Consider the outer cap U U (cid:3) U − T W . Because the overall arrangement of tiles mustbe connected but edges colored U are unmatchable, the outer cap’s edge colored T W must be adjacent toeither a top-wall tile + T W U (cid:3) U − T W or the top-right corner + T W U (cid:3) − RW U , the only other tiles with edges colored23 W . If the top-right corner were adjacent to the outer cap, it would be impossible to connect any of the n +1top-wall tiles, as there would be no further way to expose an edge colored T W (of either sign). By induction,all top-wall tiles are forced to be placed in a row adjacent to the outer cap before the top-right corner isplaced, being the only remaining tile with an edge colored
T W . By the same argument, the right-wall tiles U + RW (cid:3) − RW U and bottom-right corner − BW + RW (cid:3) U U are the only tiles with edges colored RW , thus following thetop-right corner must be the three right-wall tiles and then the bottom-right corner, and similarly along thebottom wall and left wall, terminating with the left boundary tile U U (cid:3) + LW L as the final frame tile, formingthe frame as desired.Finally, we show that the shapeless edge-matching puzzle T ∪ T (cid:48) has a solution if and only if the corre-sponding 1 × n edge-matching instance T has a solution. The forced arrangement of frame tiles only exposesedges colored with an unmatchable U color, except for the single exposed edge colored L . Thus the inputtiles of T must connect to the frame through that single edge. Figure 16 shows that the only available regionin which to arrange the tiles of T is within a 1 × n box with its leftmost boundary colored L . Corollary 5.2.
Signed and unsigned rooted shapeless edge-matching puzzles are ASP-complete and
For ASP/ × n signed/unsigned edgematching with specified left boundary color is ASP/ n + 1 unique upper-wall tiles and a suitably modified outer cap and upper-right corner asfollows: U U (cid:3) U − T W + T W U (cid:3) U − T W · · · + T W i U (cid:3) U − T W i +1 · · · + T W n +1 U (cid:3) U − T W n +2 + T W n +2 U (cid:3) − RW U . Applying the same modification to the other walls and corners gives us a frame that has a unique construction,and thus the number of solutions to the shapeless edge-matching instance corresponds exactly to the numberof solutions to the original 1 × n edge-matching puzzle with specified left boundary. × n Edge Matching
In this section, we prove PSPACE-hardness for 2-player variants of 1 × n edge matching. In Section 6.1, weintroduce and analyze a new variant of geography called partizan geography. Then in Section 6.2, we reducefrom geography and our new variant to 2-player 1 × n edge matching. Geography (also called generalized geography) is a game played on a directed or undirected graph with adesignated start vertex. In vertex geography [LS80, FSU93], players take turns moving from the currentvertex to a neighboring vertex that has not been visited, with the player who cannot move losing. In edgegeography [Sch78, FSU93], revisiting vertices is allowed, but each edge can be used only once. In all fourvariants, directed/undirected vertex/edge geography, the decision question is whether the first player has awinning strategy. Undirected vertex geography can be solved in polynomial time [FSU93], while all threeother versions are PSPACE-complete [LS80, Sch78, FSU93].24
Figure 17: Gadget simulating vertex geography in edge geographyWe introduce partizan versions of geography, where the available moves depend on which player is movingnext. In
X Y -partizan Z geography , with X ∈ { directed , undirected } and Y, Z ∈ { vertex , edge } , playerstake turns in an X graph extending a shared path, playing only Y s of their color while not repeating any Z already visited. For example, in edge-partizan vertex geography, players can play only edges of their colorthat lead to a vertex not already visited. We give a complete characterization for X Y -partizan Z geographyfor all combinations of X, Y, Z , as summarized in Table 2.First we need a result about (impartial) geography that has been widely assumed, but to the best of ourknowledge, not explicitly proved in the literature:
Theorem 6.1.
Directed edge geography remains PSPACE-hard even when restricted to bipartite planargraphs with maximum degree 3 and maximum in/outdegree 2.
Problem GP2 in Garey and Johnson [GJ79] is called simply “Generalized Geography”, but its decisionquestion describes directed edge geography, and they cite Schaefer’s paper [Sch78] which gives a PSPACE-hardness proof. But Garey and Johnson also cite Lichtenstein and Sipser [LS80] to add the bipartite,planar, and degree restrictions on the graph, apparently overlooking that the latter paper is about vertexgeography. This claim and citation pair have been repeated, including in Fraenkel et al.’s paper on undirectedgeography [FSU93], though Bodlaender [Bod93] correctly distinguishes.
Proof.
Directed vertex geography is PSPACE-hard on bipartite planar graphs with maximum degree 3 andmaximum in/outdegree 2 [LS80]. We reduce from vertex to edge geography by replacing each vertex (withany number of incoming and outgoing edges) with the gadget shown in Figure 17. This gadget is bipartiteand planar, and it has the same maximum indegree and outdegree as the vertex it replaces.If player 1 plays any of the incoming edges to this gadget, the next two moves are forced; then it is player2’s turn to play one of the outgoing edges. Once the gadget has been traversed, playing any of the remainingincoming edges loses (because the central edge has already been played). Thus this gadget correctly simulatesa vertex in the vertex geography instance.
Theorem 6.2.
Vertex-partizan geography is equivalent to geography in bipartite graphs. Specifically: • Directed vertex-partizan vertex geography and directed vertex-partizan edge geography are PSPACE-complete even when restricted to bipartite planar graphs with maximum degree 3 and maximum in/outdegree2. • Undirected vertex-partizan vertex geography and undirected vertex-partizan edge geography can be solvedin polynomial time. Fraenkel and Simonson [FS93] analyze “path-construction games” with two paths, with partizan and impartial variantsthat specify which paths each player is allowed to extend. Tron [Mil12] is another PSPACE-complete two-player two-path game.By contrast, partizan geography is about two players building a single path (like geography). Figure 18: A gadget simulating a directed edge with undirected edges. (Exchange colors to simulate a rededge.)
Proof.
Given a bipartite geography instance, coloring the vertices according to the bipartition producesa vertex-partizan game with the same winner. Conversely, no monochromatic edges in a vertex-partizaninstance can be played because the players alternate moves, so those edges can be deleted without changingthe winner. The resulting graph is bipartite, with each partition containing only vertices of a single player’scolor. Thus the problems are equivalent.Directed vertex geography in bipartite planar maximum-degree-3 maximum-in/outdegree-2 graphs isproved PSPACE-complete in [LS80] and Theorem 6.1 extends this to directed edge geography in the sameclass of graphs. Undirected vertex geography (in all graphs) and bipartite undirected edge geography areboth polynomial [FSU93]. All of these results carry over directly to vertex-partizan geography.
Theorem 6.3.
Edge-partizan geography (of all kinds) is PSPACE-complete even when restricted to bipartiteplanar graphs with maximum degree 3 and maximum in/outdegree 2.Proof.
Given an (impartial) bipartite directed vertex/edge geography instance, we can color the vertices redand blue, so (by bipartiteness) every edge is from red to blue or from blue to red. Color the first type ofedge red and the second type of edge blue. Because every path alternates vertex colors, every path alsoalternates edge colors, so adding the edge-partizan constraint does not prohibit any paths. Thus bipartitedirected geography reduces to directed edge-partizan geography.We can reduce directed edge-partizan geography to undirected edge-partizan geography using the directed-edge-simulation gadget in Figure 18. When the blue player plays the left edge, the red and blue player’snext moves are forced; then it is the red player’s turn at the right vertex. If blue tries to play the simulatededge backwards (starting at the right vertex), then red can immediately win using the leaf.Thus all edge-partizan geography games are PSPACE-complete even when restricted to bipartite planargraphs with maximum degree 3 and maximum in/outdegree 2, again carrying through the results in [LS80]and Theorem 6.1. × n Edge Matching
In this section, we analyze the complexity all four variants of the following 2-player edge-matching game:
Definition 6.1.
In the , two players play on a 1 × n board where the left boundary edge has a specified (possibly signed) color. Also given are n square tiles,where each tile T i = a i b i (cid:3) d i c i consists of four (possibly signed) edge colors. In two variants, the players drawfrom a shared pool (any player can choose any tile) or from their own pools (each player can choose a tileonly from their own pool). The players take turns making the following type of move: choose an unused tilefrom the available pool, choose one of the four rotations of the tile, and place the rotated tile in the leftmostunoccupied position of the board. A move is valid only if the tile’s left edge is compatible with the edge toits left (on the right of the previously played tile or the edge of the board). If a player has no valid move,then that player loses and the other player wins. The decision problem is to determine whether the firstplayer can force a win.First we present a proof similar to the proof of Theorem 3.3, although its results are subsumed by thefollowing theorem. Theorem 6.4.
If players draw from a shared pool of tiles, which can be signed or unsigned, the 2-playeredge-matching game is PSPACE-complete. roof. We reduce from directed vertex geography in graphs with maximum degree 3, which was provedPSPACE-hard in [LS80]. Our reduction is the same as the reduction used in the proof of 1-player ASP-completeness in Theorem 3.3, whose tiles are shown in Figure 11. In the proof of Theorem 3.3, three tilesare placed for each vertex, so if two players alternate placing tiles, then they alternate placing the first tilefor each vertex, which corresponds to taking that vertex in the geography game. In the same proof, the onlychoices are which tile to place second for each vertex of outdegree 2 (the first tile is fixed, and the unchosentile must be placed third), a choice which the player who did not place the first tile for that vertex can makeand which determines the next visited vertex in the tile-placing game. Correspondingly, in the geographygame, when one player chooses a vertex, the player who did not choose that vertex chooses the next visitedvertex. Finally, the winner of the tile-placing game is the last player to place a tile. Each vertex has threetiles which are always placed in sequence, so the last player to place a tile is the last player to place the firsttile for a vertex, which corresponds to the last player to pick a vertex in the geography game. So the winnerof the geography game is the winner of the tile-placing game, as desired.The same proof almost works in the case where the players draw from their own pools of tiles if we reducefrom directed vertex-partizan vertex geography, because then we know which player places the first tile foreach vertex. However, the other player needs to be able to choose the second tile for each vertex, and thenthe original player needs to be able to choose the remaining third tile, meaning we do not know which poolsshould have those two tiles. In fact, there is an even simpler proof that avoids this problem:
Theorem 6.5.
The 2-player signed and unsigned edge-matching games are PSPACE-complete, whetherplayers draw from their own pools of tiles or from a shared pool.Proof.
We reduce from a version of edge geography. For signed edge matching, we reduce from directed edgegeography. For unsigned edge matching, we reduce from undirected edge geography. For players drawingfrom their own tile pools, we reduce from edge-partizan edge geography. For players drawing from a sharedpool, we reduce from impartial (nonpartizan) edge geography. All four of these versions of edge geographyare PSPACE-complete by [Sch78, FSU93] and Theorem 6.3.In all cases, the reduction creates a single tile for each edge in the graph. For a directed edge ( u, v ), wemake a signed tile − uU (cid:3) U + v . For an undirected edge { u, v } , we make an unsigned tile uU (cid:3) U v . Each U denotesa globally unique color, so these tiles can be rotated only by 180 ◦ . In the own-pool case, we put the tilein the pool of the player that can play the corresponding edge in edge-partizan geography. We set the leftboundary edge color to + s in the signed case and s in the unsigned case, where s is the given start vertex.We define the board size n to be the number of tiles (the number of edges in the input graph) so that thereis no additional limit on the number of moves.We claim that the resulting 2-player edge matching game faithfully simulates the edge geography game.By the left edge color, the first tile must have an edge colored s , and in the signed case, the edge mustbe colored − s ; equivalently, the first edge played in geography must be incident to s , and in the directedcase, it must be an edge outgoing from s . In a general move, the rightmost tile’s right edge (exposed)color v represents the vertex v most recently visited by the path, and the current player must choose a tilerepresenting an edge incident to or outgoing from that vertex, revealing the other endpoint of that edge.Because each tile can be played only once, each edge can be played only once (edge geography). The lastplayer to play a tile/edge wins. Acknowledgments
This work was initiated during open problem solving in the MIT class on Algorithmic Lower Bounds: Funwith Hardness Proofs (6.892) in Spring 2019. We thank the other participants of that class for relateddiscussions and providing an inspiring atmosphere.
References [AGW19] David Ariyibi, Jonathan Gabor, and Aaron Williams. Personal communication, 2019.27BDD +
17] Jeffrey Bosboom, Erik D. Demaine, Martin L. Demaine, Adam Hesterberg, Pasin Manurangsi,and Anak Yodpinyanee. Even 1 × n edge-matching and jigsaw puzzles are really hard. Journalof Information Processing , 25:682–694, 2017.[Ber66] Robert Berger. The undecidability of the domino problem.
Memoirs of the American Mathe-matical Society , 66, 1966.[Ber78] Kenneth A. Berman. Aneulerian digraphs and the determination of those Eulerian digraphshaving an odd number of directed Eulerian paths.
Discrete Mathematics , 22(1):75–80, 1978.[BJBJK17] J˚argen Bang-Jensen, St´ephane Bessy, Bill Jackson, and Matthias Kriesell. Antistrong digraphs.
Journal of Combinatorial Theory, Series B , 122:68–90, 2017.[BM76] J. A. Bondy and U. S. R. Murty.
Graph Theory with Applications . North-Holland, 1976.[Bod93] Hans L. Bodlaender. Complexity of path-forming games.
Theor. Comput. Sci. , 110(1):215–245,1993.[BW05] Graham R. Brightwell and Peter Winkler. Counting Eulerian circuits is
Pro-ceedings of the 7th Workshop on Algorithm Engineering and Experiments and the 2nd Workshopon Analytic Algorithmics and Combinatorics , pages 259–262, Vancouver, Canada, 2005.[DD07] Erik D. Demaine and Martin L. Demaine. Jigsaw puzzles, edge matching, and polyomino packing:Connections and complexity.
Graphs and Combinatorics , 23(1):195–208, 2007.[Dem19] Erik D. Demaine. Lecture 10:
MIT class 6.892: Algorithmic Lower Bounds:Fun with Hardness Proofs . 2019. http://courses.csail.mit.edu/6.892/spring19/lectures/L10.html.Originally Lecture 15 of MIT class 6.890 in 2014.[DFZ11] Liang Ding, Bin Fu, and Binhai Zhu. Minimum interval cover and its application to genome se-quencing. In Weifan Wang, Xuding Zhu, and Ding-Zhu Du, editors,
Proceedings of the 5th Inter-national Conference on Combinatorial Optimization and Applications , pages 287–298, Zhangji-ajie, China, 2011.[Fil19] Ivan Tadeu Ferreira Antunes Filho. Characterizing boolean satisfiability variants. M.eng. thesis,Massachusetts Institute of Technology, 2019.[Fle90] Herbert Fleischner. Chapter VI: Various types of Eulerian trails. In
Eulerian Graphs and RelatedTopics: Part 1, Volume 1 , volume 45 of
Annals of Discrete Mathematics . North-Holland, 1990.[Fle91] Herbert Fleischner. Chapter X: Algorithms for Eulerian trails and cycle decompositions, mazesearch algorithms. In
Eulerian Graphs and Related Topics: Part 1, Volume 2 , volume 50 of
Annals of Discrete Mathematics . North-Holland, 1991.[FS93] Aviezri S. Fraenkel and Shai Simonson. Geography.
Theoretical Computer Science , 110(1):197–214, 1993.[FSU93] Aviezri S Fraenkel, Edward R Scheinerman, and Daniel Ullman. Undirected edge geography.
Theoretical Computer Science , 112(2):371–381, 1993.[GJ79] Michael R. Garey and David S. Johnson.
Computers and Intractability: A Guide to the Theoryof NP-Completeness . W. H. Freeman & Co., 1979.[Gr¨u71] Branko Gr¨unbaum. Antidirected hamiltonian paths in tournaments.
Journal of CombinatorialTheory, Series B , 11(3):249–257, 1971.[IMRS98] Harry B. Hunt III, Madhav V. Marathe, Venkatesh Radhakrishnan, and Richard Edwin Stearns.The complexity of planar counting problems.
SIAM Journal on Computing , 27(4):1142–1167,1998. 28Kot68] Anton Kotzig. Moves without forbidden transitions in a graph.
Matematick´y ˇcasopis , 18(1):76–80, 1968.[LS80] David Lichtenstein and Michael Sipser. Go is polynomial-space hard.
Journal of the ACM ,27(2):393–401, 1980.[Mil12] Tillmann Miltzow. Tron, a combinatorial game on abstract graphs. In Evangelos Kranakis,Danny Krizanc, and Flaminia L. Luccio, editors,
Proceedings of the 6th International Conferenceon Fun with Algorithms , volume 7288 of
Lecture Notes in Computer Science , pages 293–304.Springer, June 2012.[Ple79] J´an Plesn´ık. The NP-completeness of the Hamiltonian cycle problem in planar diagraphs withdegree bound two.
Information Processing Letters , 8(4):199–201, April 1979.[Sch78] Thomas J. Schaefer. On the complexity of some two-person perfect-information games.
Journalof Computer and System Sciences , 16(2):185–225, 1978.[Set02] Takahiro Seta. The complexities of puzzles, Cross Sum, and their Another Solution Problems(ASP). Senior thesis, University of Tokyo, 2002.[Thu92] E. L. Thurston. Puzzle. US Patent 487,798, December 13, 1892. https://patents.google.com/patent/US487798.[Val79] L. G. Valiant. The complexity of computing the permanent.
Theoretical Computer Science ,8(2):189–201, 1979.[Wes01] Douglas B. West.
Introduction to Graph Theory . Pearson Education, 2nd edition, 2001.[Wik19] Wikipedia. Eternity II. https://en.wikipedia.org/wiki/Eternity II puzzle, 2019.[YS03] Takayuki Yato and Takahiro Seta. Complexity and completeness of finding another solution andits application to puzzles.