In an edge-matching puzzle, we are given several tiles (usually identical in shape), where each tile has a label on each edge, and the goal is to place all the tiles into a given shape such that shared edges between adjacent tiles have compatible labels. In unsigned edge matching, labels are compatible if they are identical ( matches and nothing else); in signed edge matching, labels have signs (e.g., and ), and two labels are compatible if they are negations of each other ( matches and nothing else, and vice versa). Physical edge-matching puzzles date back to the 1890s [Thurston-patent]; perhaps the most famous example is Eternity II which offered a US$2,000,000 prize for a solution before 2011 [eternity2-wiki].
1.1 Previous Work
The complexity of edge-matching puzzles has been studied since 1966 [Berger-1966]. The most relevant work to this paper is from two past JCDCG conferences. In 2007, Demaine and Demaine [demaine2007jigsaw] proved that signed and unsigned edge-matching square-tile puzzles are NP-complete and equivalent to both jigsaw puzzles and polyomino packing puzzles. In 2016, Bosboom et al. [bosboom2017even] proved that signed and unsigned edge-matching square-tile puzzles are NP-complete even when the target shape is a rectangle, and furthermore hard to approximate within some constant factor. Our work on triangle edge-matching puzzles is inspired by an open problem proposed in the latter paper.
|Signed/unsigned||equilateral triangle||1-player||NP/#P-complete, (2-)ASP-hard*|
|Signed/unsigned||right triangle (hypotenuse contact)||1-player||NP/#P-complete, (2-)ASP-hard*|
|Signed/unsigned||right triangle (leg contact)||1-player||P, #P-complete|
|Signed/unsigned||square/triangular with colors||1-player||P|
1.2 Our Results: Edge Matching
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 “” compatibility condition, where edge labels are numbers, horizontally adjacent edges match if the left edge’s number is less than the right edge’s number, and vertically adjacent edges match if the top edge’s number is less than the bottom edge’s number. Figure 1 shows an example. In Section 2, we prove NP-hardness of -compatible edge matching by reduction from another new NP-hard problem, interval-pair cover. The -compatibility condition (where equal numbers also match, or we assume all labels are distinct) turns out to be substantially easier: even rectangular puzzles turn out to be always solvable, and we give a polynomial-time algorithm.
ASP/#P-completeness for edge matching.
In Section 3, we analyze edge matching for the first time from the perspective of the number of solutions to an instance, which is relevant to constructing puzzles with unique solutions. Specifically, we prove ASP-completeness for signed and unsigned edge-matching puzzles when the left boundary edge is colored (to prevent trivial rotation of solutions), and 2-ASP-hardness and #P-completeness even if the boundary is colorless.
Recall the following definitions of FNP, ASP-complete, and #P-complete. FNP is a variant of NP that actually specifies the valid certificates/solutions for an instance (instead of just requiring that they exist); that is, an FNP problem is a relation between instances and polynomial-length certificates/solutions that can be checked in polynomial time. For edge matching problems, the certificate we consider is a valid placement of the given tiles within the given shape. An FNP problem is ASP-complete [Yato-Seta-2003] if every FNP 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 implies that the -ASP version of the FNP problem — given an instance and solutions to it, decide whether there is another solution — is NP-hard [Yato-Seta-2003]. An FNP problem is #P-complete [Valiant-1979-perm] if counting the number of solutions is as hard as counting the number of solutions to any FNP problem, which is implied by a reduction that is -monious, i.e., that multiplies the number of solutions by a computable factor .111This terminology naturally generalizes “parsimonious” (), and was introduced in an MIT class in 2014 [6.892-L10]. Our reductions to edge matching are the first to be parsimonious or, when global rotation is allowed, 2-monious.
Triangular edge matching.
The conclusion of [bosboom2017even] claimed that the paper’s results extended to equilateral-triangle edge matching, but the proposed simulation of squares by triangles is incorrect because it constrains the orientation of the simulated squares. In Section 4.1, we extend our parsimonious proof to obtain NP/#P/ASP-completeness for signed and unsigned edge matching with equilateral triangles, with or without reflection.
For right isosceles triangles, there are two natural “” arrangements. For clarity, we assume the legs of the triangles have length 1. If we still want a height- tiling, then length- hypotenuses are forced to match, so matching is NP/#P/ASP-complete by simulation of squares. But if we ask for a height- tiling, so only legs match, we show in Section 4.2 that, surprisingly, both signed and unsigned edge matching can be solved in polynomial time using an algorithm based on Eulerian paths. Nonetheless, the latter problems are still #P-complete.
Shapeless edge matching.
In Section 5, we prove that square-tile edge-matching puzzles remain NP/#P/ASP-complete when the goal is to connect all tiles in any (unspecified) single connected shape, with either signed or unsigned compatibility. For #P- and ASP-completeness, we need to give some tile a fixed position in the plane (translation and rotation) to make the number of solutions finite. The proof builds a unique spiral frame that effectively forces a edge-matching puzzle with a fixed left boundary color.
2-player edge matching.
In Section 7, we consider natural 2-player variants of edge-matching puzzles, where the leftmost edge of the rectangle has a prespecified color, players alternate placing a tile in the leftmost empty cell that matches the edge color to the left, and the first player unable to move loses (normal play). We prove PSPACE-completeness for four variants of this problem: both signed and unsigned 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).
1.3 Our Results: Not Edge Matching
Along the way to proving our results on edge matching, we derive other results of possible independent interest in graph algorithms/complexity.
In Section 3.1, we prove #P- and ASP-completeness of the Hamiltonian cycle problem in planar 3-regular directed graphs, by modifying the clause gadget of Plesník’s NP-hardness proof [plesnik] and parsimoniously reducing from 1-in-3SAT instead of 3SAT. Previous work showed the analogous undirected problem ASP-complete (and #P-complete) in planar graphs of maximum degree 3 [Seta02thecomplexities]. We also prove #P- and ASP-completeness of the Hamiltonian path problem with specified start and end vertices in planar 3-regular directed graphs.
Alternating-direction Eulerian paths.
In Section 4.2.1, we characterize when a directed graph admits an alternating-direction Eulerian path, that is, a path that alternates between going forward and going backward along directed edges and visits every edge exactly once. Specifically, we show how to reduce this problem to Eulerian path in a modified graph, enabling solution in linear time. Similar results were obtained independently [alternating-euler-independent].
Partizan Geography game.
We introduce eight new partizan variants of Geography where the two players have different available moves, and characterize their complexity. Specifically, in vertex-partizan geography, vertices have two different colors, and each player can only move to vertices of their color; while in edge-partizan geography, edges have two different colors, and each player can only move along edges of their color. We can consider either variant for both Vertex and Edge Geography (where vertices and edges, respectively, cannot be repeated by either player), and in directed or undirected graphs, resulting in eight possible variants. Table 2 summarizes our results from Section 6, which prove every variant either polynomial or PSPACE-complete.
2 Edge Matching with Inequalities
-compatible edge matching is the following problem:
Instance: unit-square tiles, where each tile is defined by four numbers, one for each side. We use to represent a unit-square tile with numbers .
Question: Can the tiles cover an rectangle such that
for every two horizontally adjacent tiles, the left tile’s right number is strictly smaller than the right tile’s left number; and
for every two vertically adjacent tiles, the bottom tile’s top number is strictly smaller than the top tile’s left number?
The related problem -compatible edge matching is defined similarly, except that we do not require strict inequalities among the numbers.
2.1 A Polynomial Time Algorithm for -Compatible Edge Matching
-compatible edge-matching puzzles are always solvable and a solution can be found in time.
Rotate each tile such that and . Then sort the tiles in ascending order by and place them in the board in row-major order. Because , sorting by ensures all tiles are vertically -compatible. Then sort the tiles in each row in ascending order by . Because , sorting by ensures all tiles in the row are horizontally -compatible. Being both vertically and horizontally -compatible, this is a valid tiling. This algorithm is due to the sorting. ∎
-compatible edge-matching puzzles in which all edge labels are distinct are always solvable and a solution can be found in polynomial time.
-compatible edge-matching puzzles in which every tile has at least one pair of parallel sides with unequal labels are always solvable and a solution can be found in polynomial time.
Rotate each tile such that . If there are two pairs of unequal parallel sides, then choose arbitrarily. Now sort all tiles in ascending order by , breaking ties arbitrarily, and place them in the board in row-major order. Let and be the left and right numbers of tile . From sorting, we know that , and from our rotation of the tiles, we know that . Composing the inequalities gives , which is the -compatibility condition, so this is a valid tiling. ∎
2.2 NP-hardness of -Compatible Edge Matching
To show NP-hardness of -compatible edge matching, we start from the known NP-hard problem N3P-3SAT-2P-E1N [ding2011minimum]. In Section 2.3, we reduce N3P-3SAT-2P-E1N to a novel variant literal-matching N3P-3SAT-2P-E1N. In Section 2.4, we reduce literal-matching N3P-3SAT-2P-E1N to a new problem, interval-pair cover, which implies NP-hardness of -compatible edge matching.
2.3 Reduction from N3P-3SAT-2P-E1N to literal-matching N3P-3SAT-2P-E1N
First, we will define the variants of SAT we make use of.
An instance of N3P-3SAT-2P-E1N is an instance of 3SAT, consisting of variables and clauses each with at most three literals, where each literal is of the form (positive) or (negative), satisfying the following constraints:
N3P: Every clause has at least one negative literal (i.e., no clause has three positive literals).
2P: Every variable appears in at most two positive literals .
E1N: Every variable appears in exactly one negative literal .
Ding et al. [ding2011minimum] proved that N3P-3SAT-2P-E1N is NP-complete. In fact, they proved NP-completeness of a slightly more general problem, N3P-3SAT-3-1N, which constrains each variable to appear in at most three literals, at most one of which is negative. But any variable with zero negative occurrences can be eliminated (setting it to true), so by repeated application of this process, we attain the E1N property. Because each variable appears in at most three literals, at most two of them are positive, so we also have the 2P property. Thus we reduce N3P-3SAT-3-1N to N3P-3SAT-2P-E1N.
We define the shared-literal graph of a 3SAT instance to have one vertex for each clause, and connect two clauses by an edge if they share a literal; 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 . We will show that we can in fact reduce the shared-literal graph to maximum degree .
A literal-matching N3P-3SAT-2P-E1N instance is an instance of N3P-3SAT-2P-E1N whose shared-literal graph is a matching.
Literal-matching N3P-3SAT-2P-E1N is NP-complete.
Trivially, literal-matching N3P-3SAT-2P-E1N NP. We reduce N3P-3SAT-2P-E1N to literal-matching N3P-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 in- and out-degrees of . Because the shared-literal graph is maximum degree , every connected component is either a path or a cycle. Direct each path from one end to the other, and direct each cycle cyclically.
Reduction: For each edge in the directed shared-literal graph, corresponding to a shared literal , replace the occurrence of in with a new helper variable . Additionally, create a new helper clause , i.e., .
This reduction conserves occurrences of the original (nonhelper) variables, and each helper variable appears positively once (replacing some 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 if and only if the original formula is satisfiable under . If satisfies an original clause (by being true), the helper clause enforces that is also true. If is false, the helper clause enforces that is also false, and so cannot satisfy the original clause it is a member of. Thus if satisfies the transformed formula, satisfies the original formula. can be false when is true, but as already satisfies ’s helper clause and always appears positively in its original clause, such an assignment cannot satisfy more clauses than if were true. Thus if satisfies the original formula, satisfies the transformed formula.
After replacing the occurrence of in clause , each edge in the original formula’s directed shared-literal graph corresponds to an edge between and the helper clause containing in the transformed formula’s shared-literal graph, so original clauses have degree at most 1. Each helper variable appears only once in each polarity, so helper variables do not give rise to edges in the shared-literal graph. Thus all helper clauses have degree 1. Then the transformed formula’s shared-literal graph has maximum degree 1, and so is a matching. ∎
2.4 Reduction from literal-matching N3P-3SAT-2P-E1N to Interval-Pair Cover
To begin, we define a new problem interval-pair cover; refer to Figure 4.
Interval-pair cover is the following problem:
Instance: A universe and pairs of closed intervals for . Here , , and .
Question: Is there a choice of one interval from each pair such that every is covered by some chosen interval?
Interval-Pair Cover is NP-complete, even when every interval pair satisfies and .
We reduce from literal-matching N3P-3SAT-2P-E1N; refer to Figure 5. We draw the shared-literal graph on the integer line from through , placing the vertices at integer coordinates and using unit-length edges. This is always possible because the shared-literal graph is a matching. Then we create an interval pair for each variable . The pair’s first interval contains only the coordinate of the vertex representing the clause where appears negatively; by the E1N property, there is exactly one. The pair’s second interval contains only the coordinate(s) of the vertex or vertices representing the clause(s) where appears positively; by the 2P property, there are at most two, and they are adjacent on the line because they share an edge in the shared-literal graph. If 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 corresponding to variable , we choose the first interval if is assigned false and the second interval if is assigned true. Each chosen interval covers the coordinate(s) of the clause vertices satisfied by , so if the truth assignment satisfies the formula, the chosen intervals cover all integers in the universe. Given a complete interval cover, we assign true to if the second interval was chosen from its corresponding pair and false if the first interval was chosen. By the same interval-variable correspondence, if the intervals cover all integers in the universe, the constructed truth assignment satisfies the formula. ∎
2.5 Reduction from Interval-Pair Cover to -Compatible Edge Matching
-compatible edge matching is NP-complete.
We reduce from interval-pair cover. For each integer in the interval-pair cover universe , we create two copies of the element tile . For each interval pair , we create an interval-pair tile . The edge matching board is , where is the size of the universe and is the number of interval pairs.
Given a solution to the produced edge-matching instance, we can construct a solution to interval-pair cover by choosing each interval tile’s horizontally-oriented interval (e.g., the interval for a tile oriented as or as ). Suppose for contradiction that an element is uncovered by every chosen interval. Then in every placed tile whose left edge is at least , its right edge is at least , so the left edge of the next tile is at least . In the sequence of left edges of tiles, the left edge of the tile after the first copy of is at least , so every following left edge is at least , leaving no place for the second copy of .
Given a solution to interval-pair cover, we can construct a solution to the produced edge-matching instance. We’ll first describe a solution that uses extra copies of . For each chosen interval , orient the tile as , and attach to its right , …, to get a sequence of tiles with left edge and right edge . Now place, for each , the tile , followed by any of the above sequences of tiles with left edge and right edge . That uses as many copies of as the number of intervals that cover , plus 1, which is at least two. We can remove any and leave a valid solution, so arbitrarily removing copies until there are two copies of each left leaves a solution to the edge-matching instance.
3 Edge Matching ASP/#P-hardness
In this section, we adapt the work of [bosboom2017even] to show that edge-matching puzzles are ASP- and #P-complete. Like [bosboom2017even], we reduce from Hamiltonian path in planar 3-regular directed graphs, which we newly prove ASP- and #P-complete.
3.1 Directed Hamiltonicity ASP/#P-hardness
Seta’s thesis [Seta02thecomplexities] proves ASP-completeness for Hamiltonicity in planar max-degree-3 undirected graphs. Here we prove the analogous result for directed graphs:
Finding Hamiltonian cycles in a planar 3-regular directed graph with max in-degree 2 and max out-degree 2 is ASP-complete, and counting Hamiltonian cycles in those graphs is #P-complete.
We reduce from planar positive 1-in-3SAT, which is known to be ASP-complete and #P-complete [DBLP:journals/siamcomp/HuntMRS98]. Our reduction is patterned after Plesník’s NP-hardness reduction from 3SAT for Hamiltonian cycle in this class of graphs [plesnik]. Plesník’s reduction does not conserve the number of solutions because the clause gadget admits multiple solutions when multiple literals in the clause are satisfied (Figure 8(a)). Reducing from 1-in-3SAT and simplifying Plesník’s clause gadget allows us to conserve the number of solutions, and reducing from positive 1-in-3SAT (no negated literals) allows us to simplify the clause gadget. Plesník’s exclusive-or gadget and exclusive-or crossover gadget do not give rise to additional solutions, so they can be used as-is.
Figure 6 shows a full Hamiltonicity instance produced by our reduction, with variable gadgets on the right (heading down) and clause gadgets on the left (heading up), with variables and clauses connected by exclusive-or lines (the green lines with hollow endpoints) which may cross. (Compare [plesnik, Figure 1], in which Plesník has abbreviated the clause gadgets.)
An exclusive-or line between two edges abbreviates the pattern of additional vertices and edges shown in Figure 8. Traversing either of the two edges covers all of the additional vertices in exactly one way, excluding the other original edge from the cycle. Traversing a path not corresponding to one of the original edges (e.g., from the bottom left to bottom right in Figure 8) prevents the center four vertices from being part of any cycle (either they are uncovered, or they are the last four vertices in the path, so the path is not a cycle). If neither of the two original edges is used, all of the additional vertices are uncovered.
Exclusive-or lines connecting variable gadgets to clause gadgets may cross,222We are reducing from planar positive 1-in-3SAT, but to avoid these crossings, we would need the variable-clause graph to remain planar with a line through all of the variables and all of the clauses, a variant not known hard [ivan-thesis]. necessitating the exclusive-or crossover shown in Figure 8. The crossover works by splitting each crossed-over edge between one pair of original edges into two edges and adding new exclusive-or lines that guarantee the parity of these paired edges is the same throughout the gadget. For example, in Figure 8, if the top edge is 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 in exactly one way for each pair of original edges traversed, and a traversal not corresponding to an original edge leaves some vertices uncovered.
The variable gadget is a pair of vertices connected by a pair of parallel edges.333The 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. The edge on the interior face of the variable-clause cycle is connected by exclusive-or lines to each clause in which the 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 to false. 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-or line such that they have opposite settings, with the second pair connected to clauses where the variable appeared as a negative literal. We reduce from planar positive 1-in-3SAT, so all literals in our clauses are positive, making the second pair unnecessary.
Our clause gadget and its three Hamiltonian paths are shown in Figure 8(b). The three rightmost edges in the clause gadget are connected by exclusive-or lines to the variable gadgets corresponding to the variables appearing in this clause. If a variable is set to true, then the rightmost edge connected to that variable gadget cannot be in the cycle; otherwise, that rightmost edge must be in the cycle. If exactly one of the three variables is true, then the clause gadget can be covered in exactly one way (using one of the paths shown in Figure 8(b)). If a variable is true, the path must go to the left of that hexagon, where it must enter the left loop. If the path leaves the left loop before visiting all vertices in it, it cannot visit the top vertex of the hexagon where it entered the loop, so the left loop must be covered in its entirety. But then the 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 the left loop. The bridges allow multiple literals to be simultaneously true, which is necessary for Plesník’s reduction (from 3SAT).
Figure 6 shows a full instance produced by our reduction. For each satisfying assignment of the variables, there is one corresponding Hamiltonian cycle using the corresponding configuration of the variable gadgets and the unique satisfying path through each clause gadget. Conversely, a satisfying assignment can be uniquely read off from each Hamiltonian cycle based on the configuration of the variable gadgets. ∎
3.2 Reduction from Hamiltonicity to Edge Matching
Finding Hamiltonian paths (with or without given start and end vertices) in planar 3-regular graphs with max in-degree 2 and max out-degree 2 is ASP-complete and counting Hamiltonian paths in those graphs is #P-complete.
We prove this result via a parsimonious reduction from Hamiltonian cycle in planar 3-regular graphs with max in-degree and out-degree 2. Given a 3-regular directed graph, we find an edge that must be in every Hamiltonian cycle (an outgoing edge from a vertex with in-degree 2, or an incoming edge to a vertex with out-degree 2). We split , 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 unique longest (simple) path entering the graph in Figure 9(b) ends at the vertex labeled , because the first three vertices have outdegree 1 and the other successor of the fourth vertex is already in the path. By a similar argument working backwards from the outgoing edge of the graph in Figure 9(a), the unique longest path leaving the graph starts at the vertex labeled . Thus, whether or not and are specified as the start and end vertices in the Hamiltonian path instance, all Hamiltonian paths in the transformed graph start at and end at . Because occurs in every Hamiltonian cycle of the input graph, there is a bijection between Hamiltonian cycles in the input instance and Hamiltonian paths in the output instance, and this bijection can be computed in polynomial time by replacing with the unique paths in the start/end gadgets or vice versa. ∎
The symmetry of edge-matching puzzles is problematic for ASP-hardness. Because rotating any solution by will give another solution, the answer to the ASP problem is always ‘yes’. To avoid this trivial additional solution, we consider the version of edge-matching puzzles where the leftmost boundary edge’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 we show #P-hardness even for edge-matching puzzles without any such restriction.
The reduction in [bosboom2017even] that establishes NP-hardness of edge-matching puzzles is not parsimonious because of garbage collection: the tiles corresponding to edges which are not part of the Hamiltonian path are placed at the end of the row of tiles in an arbitrary order. Our reduction will instead place these unused tiles near the corresponding vertex tiles, so that there is only one tile sequence corresponding to each Hamiltonian path.
edge-matching puzzles with the leftmost boundary edge color specified are ASP-complete and #P-complete.
Clearly this problem is in FNP and its counting problem is in #P. To show hardness, we present a parsimonious reduction from Hamiltonian path in 3-regular directed graphs, adapted from the reduction in [bosboom2017even].
Given a 3-regular directed graph with specified vertices and , we construct a edge-matching puzzle as follows. We assume and have in-degree 1 and out-degree 2. For each edge in , we have a color , and for each vertex we have three colors , , and .
We build three tiles for each vertex. Suppose has one edge coming in and two edges and going out. Then we construct the tiles
For the other case, suppose has two edges and coming in and one edge going out. Then we construct the tiles
These tiles are shown in Figure 11; each tile corresponds to one of the half-edges incident to . We remove the tile(s) corresponding to the half-edge(s) entering and the tile(s) corresponding to half-edge(s) leaving . Finally, we specify that the leftmost boundary edge has color . This reduction can clearly be done in polynomial time.
We show that the number of solutions to this edge-matching puzzle is the same as the number of Hamiltonian paths in from to . Suppose we have such a Hamiltonian path. We can construct a solution to the edge-matching puzzle by placing the three tiles for each vertex consecutively, in the order the vertices appear in the path. These three tiles are placed so that the tiles corresponding to the edges and used to enter and exit are first and last, respectively, so the sequence of colors is . These sequences of three tiles corresponding to vertices connect at the edge colors, and they match because the sequence of vertices is a path. There are fewer tiles corresponding to and ; we simply cut the sequence short at the beginning and end. The leftmost boundary color is then , as required, and the rightmost boundary color is .
We will now show that every solution to the edge-matching puzzle has this form, and thus corresponds to a Hamiltonian path. Suppose we have a solution to the edge-matching puzzle. The leftmost tile must be one of the tiles corresponding to , and must have on the left and on the right. So the next tile is the other tile corresponding to . The only tile corresponding to is , where is the incoming edge. Because and do not appear on any other tiles, this must be the rightmost tile with the side with color on the left.
Let be a vertex other than and . None of the tiles corresponding to can be at either end of the solution, because those spaces are claimed by and . Suppose has in-degree 1 and out-degree 2; the other case is similar. Because is the only tile with the color , it must be adjacent to other tiles on the other two sides. The tile adjacent on the side with color must be another tile corresponding to . Whichever one it is, the opposite side must have color , so the following tile must be the third tile corresponding to , with the color of another edge incident to on the side touching the next tile. In summary, the three tiles corresponding to must be consecutive, and the two colors they expose to other tiles are two edges incident to with different orientations relative to .
Suppose the sequence of three tiles corresponding to and adjacent to the sequence corresponding to . Then the side where these sequences touch must have color , where is an edge between and . Because the colors on either side of the sequence for have different orientation relative to , by induction this orientation is consistent between vertices. That is, if the solution has a several consecutive groups of three tiles corresponding to vertices, the sequence of vertices must form a path in in either direction. The entire solution must be a sequence of groups corresponding to vertices starting with and ending with , such that adjacent vertices share an edge, and which uses each tile 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 used at that vertex. So there are the same number of Hamiltonian paths in from to and solutions to the edge-matching puzzle. Because this reduction is parsimonious, it shows that edge-matching puzzles with the color of the leftmost boundary edge specified is ASP- and #P-complete. ∎
edge-matching puzzles are #P-complete and their 2-ASP problem is NP-hard.
In the proof of Theorem 3.3, each side of each tile can only ever be used in one orientation, so the proof works just as well for signed edge matching. If we do not specify the color of the leftmost boundary edge, the solutions to the constructed edge-matching puzzle are those described in the proof and their rotations, so the reduction is 2-monious. Again this works for both signed and unsigned edge-matching. ∎
4 Triangular Edge Matching
In this section we study edge-matching puzzles with triangular tiles, specifically, equilateral and right isosceles triangles. There is one natural interpretation of “” for equilateral triangles, as shown in Figure 11(a). However, for right isosceles triangles, there are two natural interpretations. If the triangles have legs of length 1, then to pack a box they must have alternating hypotenuse/leg contact, which we will simply refer to as hypotenuse contact, as shown in Figure 11(b). On the other hand, if the triangles have a height of 1, then they must be packed using only leg-to-leg contacts, as shown in Figure 11(c).
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 another context in the conclusion of [bosboom2017even].) Thus NP-completeness, ASP-completeness (with left boundary specified), and #P-completeness of these puzzles follows directly from results on square tiles. Hence we will devote the rest of this section to equilateral triangles (Section 4.1) and right triangles with leg contact (Section 4.2).
4.1 Equilateral-Triangle Edge Matching
In this section we show NP/#P/ASP-completeness of equilateral triangular edge-matching puzzles. We start with an NP-completeness proof, then augment it and analyse it further to prove #/ASP-completeness.
4.1.1 NP-hardness of Equilateral-Triangle Edge Matching
We reduce from Hamiltonian path in undirected 3-regular graphs [Garey-Johnson-1979] to signed triangular edge matching as follows. First, arbitrarily assign a direction to each edge. Then for every vertex with incident edges , construct triangular tiles , , , where in each case the sign of is positive if is incoming to and negative otherwise. This reduction takes polynomial time.
We show that a solution to this tile set exists if and only if the graph has a Hamiltonian path. Suppose on the one hand that there exists a Hamiltonian path . Then there is a solution to this tile set obtained by listing the tiles of each vertex along this path, arranged such that the incoming edge’s color is exposed on the left side and the outgoing edge’s color is exposed on the right. (Here “incoming” and “outgoing” refer to the direction given by the Hamiltonian path, not the arbitrary directions assigned in the reduction.)
On the other hand, suppose that the tile set has a solution. For any solution, either all the tiles corresponding to a given vertex are adjacent to each other, except possibly allowing for one vertex to cyclically “wrap around”, appearing both at the beginning and the end. In either case, listing all of the vertices in the order in which their color appears in the tile set yields a Hamiltonian path of the original graph. (If one of the vertex’s tiles wrapped around, then this process yields a Hamiltonian cycle, which is stronger.)
Thus the Hamiltonian-path instance is satisfied if and only if the signed triangular edge-matching instance is. Thus signed triangular edge-matching puzzles are NP-hard.
Note that it makes no difference whether the tiles are reflectable or not. Furthermore, the same reduction shows that unsigned triangular edge-matching puzzles are NP-hard simply by dropping the signs.
4.1.2 ASP/#P-completeness of Equilateral-Triangle Edge Matching
In this section we prove ASP-completeness of equilateral-triangle edge matching with specified left boundary color. As in the case of squares, our reduction also proves that the problem of counting solutions when no left boundary color is specified is #P-complete. This problem is clearly contained in FNP because every solution can be verified in polynomial time. We will now prove ASP-completeness of Equilateral Triangle edge matching with a specified left boundary color by giving a parsimonious reduction from undirected Hamiltonian cycle in maximum-degree-3 simple graphs, proved ASP-complete in [Seta02thecomplexities]. First, we give a parsimonious reduction from undirected Hamiltonian cycle in this restricted class of graphs to undirected Hamiltonian - path in the same class of graphs; the reduction is very similar to that given in the proof of Theorem 3.2. Let be a maximum-degree-3 undirected graph. We can assume has at least one vertex of degree two [Seta02thecomplexities], so let be such a vertex, and let be one of its two incident edges. Because is incident to a vertex of degree 2 it must be contained in every Hamiltonian cycle. Now construct by removing the edge , adding two new vertices and , and edges and . Because is contained in every Hamiltonian cycle in there is a direct bijection between Hamiltonian cycles in and Hamiltonian - paths in , thus proving ASP-completeness of undirected Hamiltonian - path in maximum-degree-3 graphs.
Now we can modify our reduction for NP-hardness of equilateral triangular edge matching from section 4.1 to give a parsimonious reduction from undirected Hamiltonian - path in maximum-degree-3 graphs to equilateral-triangle edge matching with a specified left boundary color. Just as in the NP-hardness proof, we will only explicitly define the signed case; the unsigned case uses the same reduction, just dropping the signs. As in the original reduction from Hamiltonian path, we start by assigning an arbitrary orientation to each edge. For the degree 3 vertices nothing changes in the reduction. For the degree two vertices, we add an imaginary third edge not incident on any vertex, and then mimic the construction of triangles used for degree 3 vertices. We can assume that the only degree 1 vertices in our original graph are and , because any other degree 1 vertices could not possibly be reached in an - path (and thus in this case we could parsimoniously reduce to triangular edge matching by constructing any unsolvable edge matching instance). So it remains only to create triangles corresponding to and . To do this, create the tiles and . and represent the unique edges incident on and respectively, with signs chosen for these edge colors based on our arbitrary orientation on the original graph, in the same fashion as for all other tiles. Each occurrence of represents a unique color not occurring on any other tile. Finally, we will specify the left boundary color to be .
Because the tile corresponding to vertex possesses the only edge with color it must be placed as the leftmost tile. Because the tile corresponding to has two sides with unique colors, it must then be placed as the rightmost tile. As argued in the above NP-hardness proof, every triplet of tiles corresponding to 3 vertices must occur consecutively (except one which wraps around at the ends, but the and tiles prevent this). The same is true for degree 2 vertices because we use the same construction as we do for degree 3 vertices (with one imaginary edge). So every solution is fully defined by an ordering of the vertex tile triplets between the leftmost tile and the rightmost tile. Thus there is a clear (and efficiently computable) bijection between the ordering of tile triplets between and and Hamiltonian - paths in our graph. To extend this to a bijection between edge matching solutions and Hamiltonian path solutions, it remains only to show that given an ordering of the tile triplets, there is a unique arrangement of the three tiles within each triplet.
Say a tile triplet for vertex occurs between triplets for and . The only edge colors ’s triplet can have in common with the and triplets are the colors representing edges and in the original graph, so the two tiles in ’s triplet containing the and colors must be on the left and right respectively with those edges exposed. This leaves the remaining tile in the triplet no choice but to be oriented between them with its -colored edges facing the other two tiles in the triplet, and its third edge facing the box boundary. Thus, the arrangement of tiles within each triplet is uniquely defined by the ordering of tile triplets along the box, completing the proof that our reduction is parsimonious.
4.2 Right-Triangle Edge Matching
As explained above, we focus only on right triangles which tile a box by leg contact. In this section we show that solving such puzzles is closely related to the problem of finding an Eulerian path in a graph. We use this first to show that these puzzles can be solved in polynomial time, and then to show that counting solutions to these puzzles is #P-complete.
4.2.1 Polynomial-Time Algorithm for Right-Triangle Edge Matching
In this section, we show that right-triangle edge matching with leg contact can be solved in polynomial time, in both the signed and unsigned case.
Unsigned Right Triangles:
Given an instance of unsigned right-triangle edge matching, we start by creating a vertex for every color that occurs on the leg of a tile; hypotenuses never touch, so we can ignore their colors completely. Now, for every triangle , create an edge in our graph directed from to . Now, any solution to this edge matching problem consists of some ordering of the triangles along the box, with each triangle oriented either with its hypotenuse facing up or down. Such a solution is correct if and only if the triangles alternate upwards/downwards orientations, each adjacent pair of triangles matches colors along their shared edge, and the orientation of the first and last triangles match the slope of the box boundary. In the context of the graph we just constructed, this corresponds precisely to a path that uses every edge in the graph exactly once, alternates between going forwards and backwards along edges, and is forced to traverse its first and last edges with specified orientations (forward or backwards). We call this problem of finding an Eulerian path in a directed graph which alternates between going forwards and backwards along edges the alternating-direction Eulerian path problem. We now prove the following lemma:
The alternating-direction Eulerian path problem can be reduced in polynomial time to the Eulerian path problem.
Let be an instance of the alternating-direction Eulerian path problem in the form of a directed graph. Now, construct an undirected graph as follows: for each vertex , construct two vertices and . Now for every directed edge , add the undirected edge to . This construction of a bipartite undirected graph from a directed graph is referred to in the literature as a “split” [intro-to-graphs].
First, say there exists an alternating-direction Eulerian path in ; call this path . So then we can take this sequence of edges constituting and replace each edge with the edge to obtain . Because the function mapping to is a bijection by definition, and is an alternating-direction Eulerian path, must also use every edge exactly once. Because alternates between going forwards and backwards along edges, each time it visits some vertex it either visits it forwards and then backwards, in which case it uses two incoming edges, or backwards and then forwards, in which case it uses two outgoing edges. So in this means it will enter and then leave , or enter and leave ; in either case we see constitutes a path through , and because it uses every edge exactly once, it must be an Eulerian path. The same bijection between edges in and edges in can be used to map any Eulerian path in to an alternating-direction Eulerian path in , completing the proof. ∎
There is one extra constraint in the edge matching puzzle that must be satisfied: the slopes of the left and right box boundary force the orientation of the first and last edge used, so viewing this as a graph problem, this is equivalent to forcing whether the first and last edge are traversed forwards or backwards. In our reduction to the Eulerian path problem, this means forcing whether the first and last vertex are “positive” or “negative” vertices. To solve this constraint, first determine if the graph is even (thus admitting an Eulerian cycle), even except for two odd vertices (admitting an Eulerian path but only with distinct endpoints), or neither. In the third case there is no solution. In the first case, any Eulerian path must start and end at the same vertex, so the puzzle has a solution if and only if the left and right boundaries have matching slopes. In the second case, there exist two unique vertices in the graph such that every Eulerian tour starts and ends at those, so we must simply verify that they match signs with the signs forced by the left and right box boundaries.
Signed Right Triangles:
For signed right triangles we start by ignoring all signs and using the same reduction to alternating-direction Eulerian path, creating a vertex for each color and an edge for every triangle . Now a solution to the edge matching puzzle must still correspond to an alternating-direction Eulerian path in this new graph, but there is an additional constraint that when two triangles are used to transition in and out of a vertex/color , they must do so with opposite signs. This is equivalent to, for every vertex, partitioning its edge set into positive and negative edges, and requiring that the alternating-direction path pass through each vertex by pairing edges which touch that vertex with opposite signs. Applying our previous reduction from alternating-direction Eulerian path to the standard Eulerian path problem this condition is preserved; given a partition of the incident edges of into , when we split into this partition gets inherited by and in the obvious way. So we have now reduced signed right-triangle edge matching to the following problem: given an undirected graph with each vertex’s incident edges labeled as positive or negative, does there exist an Eulerian path in this graph such that each time it passes through a vertex, it enters and then exits through edges with opposite signs relative to that vertex’s edge-partition? This problem was studied in [Kotzig1968] for the more general case of an arbitrary partition of edges (instead of a bipartition). They show that the existence of a solution can be determined by comparing the degree of each vertex to the size of the largest component in its edge partition. Their result immediately implies the problem is in P, and thus signed right-triangle edge matching is also in P.
4.2.2 ASP/#P-Completeness of Right-Triangle Edge Matching
Unsigned Right Triangles:
In [countingEuler] it is proved that counting the number of Eulerian cycles in a graph is #P-complete. This can be easily reduced to the problem of counting the number of Eulerian paths from a specified start vertex to a specified end vertex , a problem we call - Eulerian path, as follows: given a graph , choose an arbitrary vertex and attach two leaves and . Now every - Eulerian path starts at , goes to , then follows a Eulerian cycle through starting and ending at , and finally moves to . So every - Eulerian path is fully defined by an Eulerian cycle thought so this reduction in parsimonious and thus - Eulerian path is #P-complete.
Now we reduce from - Eulerian path to unsigned right-triangle edge matching. Given a graph and with specified start and end vertices and , start by creating a unique color for each vertex. Now create triangles and where are unique unmatchable colors and is the hypotenuse color. Now for each edge , create two tiles where is the hypotenuse color (which does not matter), and is a unique glue only used for these two tiles. If we make the box a parallelogram with its left and right boundaries having positive slope, must be placed on the leftmost side of the box and must be on the rightmost side. Then, because every other tile has to touch another tile on both sides, every edge pair is forced to stick together because of the unique glue, and when they do they create a parallelogram whose exposed sides have colors and , and flipping this parallelogram by gives us the same shape but with the colors in the opposite order. This simulates an undirected edge.
Now we have a direct bijection between solutions. The two pieces on the left and right extremes of the bounding box are forced, and so each solution to the edge matching problem is uniquely defined by the order of the glued-together edge pairs and their orientation (there are two orientations for the tile pair for edge , one with on the left and one with on the left). Given a placement of these edge pairs, we can read off the colors of the leftmost boundary of each edge pair, in order from left to right, to get back an - Eulerian path in our graph, and given an - Eulerian path, we can get back that same solution by ordering the edge pairs in the order they are traversed in the Eulerian path, and flipping each edge pair so that the vertex which is visited first is on the left. So this reduction is parsimonious, meaning unsigned right-triangle edge matching is #P-hard.
Signed Right Triangles:
Again, we start by assigning each vertex in a unique color. Now create triangles and where is a unique unmatchable color and is the hypotenuse color. Next, for each vertex of degree create pairs of tiles, each pair of the form where is a unique glue and is the hypotenuse. Now for every edge create two tiles (where again is unique and is the hypotenuse).
For the same reason as in the unsigned reduction, the and tiles are forced to the edges, at which point all of the vertex and edge pairs must glue together. Because of the way we assigned signs, tile pairs must alternate between edge pairs and vertex pairs, and in particular an edge pair can be next to a vertex pair if and only if the edge is incident to that vertex in .
So this reduction is almost parsimonious; if we count tiles with the same color set as identical copies of the same tile then for the same reason as in the unsigned case we have a direct bijection between solutions. However, if we count identical tiles differently then for each Eulerian path solution, we can permute the order of the vertex pairs of each distinct vertex arbitrarily, and also flip the orientation of each pair by . So this makes the reduction -monious, where is the number of edges in the original graph and is the degree of . We get because (the degree sum lemma). Because can be computed in polynomial time, if we had an oracle that counted the number of solutions to a signed right-triangle edge matching instance than we could find the number of solutions to this problem and then divide this number by , giving us the number of - Eulerian paths in . So this problem is also #P-hard.
5 Shapeless Edge Matching
In this section, we prove NP-hardness of shapeless edge matching in both the signed and unsigned case. We define the problem as follows:
Signed/unsigned shapeless edge matching is the following problem: given a set of unit square tiles where each edge of each tile is given a color (and a sign in the signed case), can the tiles be laid out in any configuration in the plane such that the overall arrangement is edge-connected, and all edge-to-edge contacts between tiles are valid?
The distinguishing feature of this problem, compared to the rectangular edge matching problems for which hardness is already known, is that the target shape is not specified, so there is no constraint on the spatial footprint of a solution. We will show that this variation is also NP-hard, ASP-hard, and #P-hard, by reduction from edge matching with specified left boundary, which was proved NP-hard by [bosboom2017even] and proved ASP/#P-hard in Section 3 of this paper (for both the signed and unsigned cases).
5.1 Reduction from Signed/Unsigned Edge Matching With Specified Left Boundary to Signed/Unsigned Shapeless Edge Matching
An instance of edge matching with specified left boundary comes in the following form: a set of of tiles (signed or unsigned), and a single color denoting the color of the leftmost boundary of the box in which the tiles in must be placed.
For the reduction, we create a set of tiles which, if they are to be placed in a connected arrangement, force themselves into a rectangular framing structure that simulates a box. The frame tile set is listed in Figure 15, intended to be placed as in Figure 16. In the signed case, we generate four new colors that appear positively and negatively and one new unmatchable color that appears only positively. In the unsigned case, each represents an unmatchable color that appears only once.
The resulting instance of shapeless edge matching is the input tiles along with the frame tiles.
This reduction can be completed in polynomial time.
The number of tiles in the frame set is linear in so the total number of tiles constructed is of linear size, and thus this result follows. ∎
5.2 Proof of Correctness
The frame tiles collectively have a valid and forced arrangement.
We show that the frame tiles must be positioned to form the frame shown in Figure 16. Our proof uses signed tiles; by dropping signs from all tiles the same proof holds in the unsigned case.
Consider the outer cap . Because the overall arrangement of tiles must be connected but edges colored are unmatchable, the outer cap’s edge colored must be adjacent to either a top-wall tile or the top-right corner , the only other tiles with edges colored .
However, if the top-right corner were adjacent to the outer cap, it would be impossible to connect them to any of the top-wall tiles, as there would be no further way to expose an edge colored (of either sign). Inductively, all top-wall tiles are forced to be placed in a row adjacent to the outer cap before the top-right corner is placed, being the only remaining tile with an edge colored .
By the same argument, the right-wall tiles and bottom-right corner are the only tiles with edges colored , thus following the top-right corner must be the three right-wall tiles and then the bottom-right corner, and similarly along the bottom wall and left wall, terminating with the left boundary tile as the final frame tile, forming the frame as desired.
By construction, the frame tiles only end up adjacent to tiles directly neighboring it along the frame, and in the signed case the edge colors must alternate to from start to end around the frame, therefore all edge matchings are valid. ∎
The shapeless edge-matching instance has a solution if and only if the corresponding edge-matching instance has a solution.
The forced arrangement of frame tiles only exposes edges colored , the unmatchable color, except for the single exposed edge colored , so the tiles of , from the edge-matching instance, must connect to the frame through that edge. Figure 16 shows that the only available region in which to arrange the tiles of is within a box with its left-most boundary colored . ∎
5.3 Shapeless Edge Matching ASP/#P-hardness
For ASP/#P-hardness, we modify the problem to specify the placement (position and rotation) of one tile, to avoid the infinite number of translations as well as global rotations. If we can guarantee that the frame has a unique construction, then the above reduction will be parsimonious. Because Section 3 proves ASP/#P-hardness of signed/unsigned edge matching with specified left boundary, this parsimonious reduction gives us ASP/#P-hardness for signed/unsigned shapeless edge matching.
The only degree of freedom in the frame construction as specified above is the ordering of the wall tiles along each wall. In order to fix their order, we simply create distinct tiles for each position along the wall, and give them each unique colors only shared with their neighbors in that ordering. In particular, we modify the upper wall to be, constructing unique upper wall tiles and changing the outer cap and upper-right corner accordingly to match. Applying the same modification to the other walls and corners gives us a frame that has one unique construction, and thus the number of solutions to the Shapeless edge-matching instance corresponds exactly to the number of solutions to the original edge-matching puzzle with specified left boundary.
6 Partizan Geography
In this section, we give a complete characterization of partizan geography, one variant of which we will later reduce from to prove the hardness of 2-player edge-matching games. First, we need a result about (impartial) geography that has been widely assumed, but to the best of our knowledge, not explicitly proved in the literature.
Directed edge geography remains PSPACE-hard even when restricted to bipartite planar graphs with maximum degree 3 and maximum in-/out-degree 2.
Problem GP2 in Garey and Johnson [Garey-Johnson-1979] is “Generalized Geography”. Their decision question describes directed edge geography, and they cite Schaefer’s paper giving a PSPACE-hardness proof [DBLP:journals/jcss/Schaefer78], but then cite Lichtenstein and Sipser [lichtenstein1980go] to add the bipartite, planar, and degree restrictions on the graph, apparently overlooking that the latter paper is about vertex geography. This claim and citation pair have been repeated, including in Fraenkel et al.’s paper on undirected edge geography [fraenkel1993undirected], though Bodlaender [DBLP:journals/tcs/Bodlaender93] correctly distinguishes.
Directed vertex geography is PSPACE-hard on bipartite planar graphs with maximum degree 3 and maximum in-/out-degree 2 [lichtenstein1980go]. We reduce from vertex to edge geography by replacing each vertex (with any number of incoming and outgoing edges) with the gadget shown in Figure 17. This gadget is bipartite and planar, and it has the same max in- and out-degree 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 player 2’s turn to play one of the outgoing edges. Once the gadget has been traversed, playing any of the remaining incoming edges loses. Thus this gadget correctly simulates a vertex in the vertex geography instance. ∎
Now we turn to partizan geography. In -partizan -geography, with , players take turns extending a shared path,444Fraenkel and Simonson [DBLP:journals/tcs/FraenkelS93] analyzes path-construction games with two paths, where partizan and impartial refer to which paths each player is allowed to extend. Tron [DBLP:conf/fun/Miltzow12] is another PSPACE-complete two-player two-path game. playing only s of their color while not repeating any already visited. For example, in edge-partizan vertex geography, players can play only edges of their color that lead to a vertex not already visited. We give a complete characterization for -partizan -geography on directed and undirected graphs, as summarized in Table 2.
Vertex-partizan geography is equivalent to geography in bipartite graphs. Specifically:
Vertex-partizan directed vertex geography and vertex-partizan directed edge geography are PSPACE-complete even when restricted to bipartite planar graphs with maximum degree 3 and maximum in-/out-degree 2.
Vertex-partizan undirected vertex geography and vertex partizan undirected edge geography are polynomial.
Given a bipartite geography instance, coloring the vertices according to the bipartition produces a vertex-partizan game with the same winner. Conversely, no monochromatic edges in a vertex-partizan instance can be played because the players alternate moves, so those edges can be deleted without changing the winner. The resulting graph is bipartite, with each partition containing only vertices of a single player’s color. Thus the problems are equivalent.
Directed vertex geography in bipartite planar max-degree-3 max-in-/out-degree-2 graphs is proved PSPACE-complete in [lichtenstein1980go] and Theorem 6.1 extends this to edge geography in the same class of graphs. Undirected vertex geography (in all graphs) and bipartite undirected edge geography are both polynomial [fraenkel1993undirected]. All of these results carry directly to vertex-partizan geography. ∎
Edge-partizan geography (of all kinds) is PSPACE-complete even when restricted to bipartite planar graphs with maximum degree 3 and maximum in-/out-degree 2.
Given an (impartial) bipartite directed vertex (respectively edge) geography instance, we can color the nodes red and blue, so (by bipartiteness) every edge is from red to blue or from blue to red. Color the first type of edge red and the second type of edge blue. Because every path alternates vertex colors, they will also alternate edge colors, so adding the edge-partizan constraint does not prohibit any paths. Thus edge-partizan directed geography is equivalent to bipartite directed geography.
We can reduce edge-partizan directed geography to edge-partizan undirected geography using the directed edge simulation gadget in Figure 18. When the blue player plays the left edge, the red and blue player’s next moves are forced and it’s the red player’s turn at the right vertex. If blue tries to play the simulated edge backwards (starting at the right vertex), red can immediately win using the leaf.
Thus all edge-partizan geography games are PSPACE-complete even when restricted to bipartite planar graphs with maximum degree 3 and maximum in-/out-degree 2, again carrying through the results in [lichtenstein1980go] and Theorem 6.1. ∎
7 2-player Edge Matching
In this section, we prove PSPACE-hardness for 2-player variants of edge matching. We define the game as follows:
The 2-player edge-matching game is the following. Given a board where the leftmost edge has a specified (possibly signed) color, and given square tiles, where each tile consists of four (possibly signed) edge colors specified in clockwise order, two players take turns making the following type of move: choose an unused tile, choose one of the four rotations of the tile, and place the rotated tile in the leftmost unoccupied position of the board. A move is valid only if the tile’s left edge matches the color (and has the opposite sign of) the edge to its left (on 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. Decide whether the first player can force a win.
We consider four variants of the 2-player edge-matching game. The players draw from either a shared pool of tiles or their own pool of tiles, and tiles are either signed or unsigned. We first present a proof similar to the one of Theorem 3.3, although its results are subsumed by the following two theorems.
If players draw from a shared pool of tiles, which can be signed or unsigned, the 2-player edge-matching game is PSPACE-hard.
We reduce from directed vertex geography in graphs with maximum degree 3 and a start vertex , which was proved to be PSPACE-hard in [lichtenstein1980go].
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 tiles are placed for each vertex, so if two players alternate placing tiles, then they alternate placing the first tile for each vertex, which corresponds to taking that vertex in the geography game. In the same proof, the only choices are which tile to place second for each vertex of outdegree 2 (the first tile is fixed, and the unchosen tile must be placed third), a choice which the player who did not place the first tile for that vertex can make and which determines the next visited vertex in the tile-placing game. Correspondingly, in the geography game, when one player chooses a vertex, the player who did not choose that vertex chooses the next visited vertex. Finally, the winner of the tile-placing game is the last player to place a tile. Each vertex has three tiles which are always placed in sequence, so the last player to place a tile is the last player to place the first tile for a vertex, which corresponds to the last player to pick a vertex in the geography game. So the winner of 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 separate pools of tiles if we reduce from directed vertex geography in bipartite graphs with maximum degree 3 and a start vertex , because we know which player places the first tile for each vertex. However, the other player’s choice of a second tile for each vertex means we do not know which player places those tiles.
The 2-player signed edge-matching game is PSPACE-hard, whether players draw from their own pools of tiles or a shared pool.
We first reduce from directed vertex geography in bipartite graphs with maximum degree 3 and a start vertex , which is known to be PSPACE-hard [lichtenstein1980go], to the version with the left edge specified. For our reduction, we create one tile for each vertex except the start vertex. For a vertex having two incoming edges from and , we create the tile having colors clockwise on its edges. For a vertex with only one incoming edge from , we create the tile having colors clockwise on its edges. We set the board size to , and its left boundary edge is colored (where is the start vertex’s color).
This signed 2-player edge-matching instance has the same answer as the original vertex Geography instance.
The left boundary edge’s color simulates the start vertex tile (that we didn’t make) having been previously played, so the first player must play a vertex tile having color , representing an incoming edge from the start vertex. Then the players alternate playing tiles whose left edge represents an incoming edge from the previous vertex.
Each pair of opposing edges on each tile has one positive color and one negative color, and the left boundary edge has positive color, so the right edge of each played tile will also have positive color. Thus rotation is only useful for playing vertices of in-degree 2 from either possible previous vertex, and any partial tiling always corresponds to a simple path in the geography graph.
Each vertex corresponds to at most one tile, so visited vertices cannot be played again, and the start vertex cannot be played because we didn’t make a tile for it. Thus, if a player would lose in the simulated geography instance, they also lose in the edge-matching instance.
Thus, our edge-matching instance faithfully simulates the input geography instance, so 2-player signed edge-matching games with a shared pool and a specified left boundary color are PSPACE-complete. ∎
Note that we reduced from a version of Geography that was bipartite. This means that one player can only play the tiles corresponding to vertices of one color in the graph’s two-coloring, and the other player can only play the tiles corresponding to vertices of the other color. Thus, the proof works we give the players a shared pool of tiles or separate pools corresponding to the tiles they place. As such, 2-player signed edge-matching games with specified left boundary color and shared or separate pools are PSPACE-complete.
Finally, we consider the variant where tiles are unsigned and players draw from separate pools of tiles.
The 2-player unsigned edge-matching game is PSPACE-hard, whether players draw from their own pools of tiles or a shared pool.
We first assume that the tile pool is shared, and reduce from partisan directed vertex geography with max degree 3 on bipartite graphs, as in Section 6.
We make one tile for each vertex.
For a vertex with one in-edge and one out-edge , make .
For a vertex with one in-edge and two out-edges and , make .
For a vertex with two in-edges and and one out-edge , make .
Placing a tile such that its right side is labeled with an edge corresponds to choosing in the partisan directed vertex geography game. At all times, the rightmost tile side corresponds to the most recently traversed edge in geography, and the last player in the edge-matching game is the last player in geography.
If the players have their own pools, because the graph is bipartite, each vertex can only be visited by one player whom we know at the start of the game, so we can fill each player’s pool with the tiles corresponding to all the vertices they could visit.
If the left edge is unspecified and the players have a shared pool, we reduce from partisan directed vertex geography with max degree 3 and no start vertex, as in Section 6; the reduction is the same.
If the left edge is unspecified and the players have their own pools, we reduce from partisan directed vertex geography with max degree 3 and no start vertex on bipartite graphs as in Section 6. Here we do not know which partite class the first player will choose to start with, so we need to reduce twice: we make one edge-matching problem where the first player has the tiles corresponding to one partite class, and another edge-matching problem where the first player has the tiles corresponding to the other; the first player wins the geography game if and only if they win either edge-matching game. ∎
This work was initiated during open problem solving in the MIT class on Algorithmic Lower Bounds: Fun with Hardness Proofs (6.892) in Spring 2019. We thank the other participants of that class for related discussions and providing an inspiring atmosphere.