No Easy Puzzles: A Hardness Result for Jigsaw Puzzles

Michael Brand
FUN with Algorithms, July 1-3, 2014
Canonic shape
Non-canonic shape
Non-planar shape
(partially assembled)
Apictorial
Canonic puzzle = pictoral puzzle + canonic shape
n=12
d=4
n=20
d=4
n=27
d=6
n = size of the puzzle ( = # of tiles)
d = degree of the puzzle ( = max # connecting to a tile)

"Tile matching" - Does the outline of the tab
on tile A match the outline of the pocket on
tile B?
◦ Can be ignored by assuming a tile-matching Oracle.

"Parsimonious Testing" - Which two tiles
should I try to match up next?
◦ Can be ignored by assuming Oracle pre-calculation.

"Bijection Reconstruction" - Where does tile A
go in the finished puzzle?

"Bijection Reconstruction" - Instance of
(sub-)graph isomorphism.
◦ Polynomial without spurious matches (bounded d).
◦ Else: NPC even on canonicals (E.+M. Demaine).

"Tile matching" - Lots and lots of literature

"Parsimonious Testing"
◦ Best results use quite complex edge
representations.
◦ Complex matching algorithms can be slow,
increasing the importance of Parsimonious Testing
(e.g. to find optimal trade-offs).
◦ Nothing. We address this gap in the literature.

We introduce a model where Parsimonious
Testing can be studied in isolation.
◦ We present it as a communication problem.
I
(infinitely powerful
computer, but with no
knowledge of edge
shapes)

O
(Oracle with perfect
edge-matching
abilities; can be
queried)
How many queries to O does I need, in order
to solve the puzzle?

Jigsaw puzzle = <T, P, Ep, Q>
◦ T=tiles; P=positions; |T|=|P|=n
◦ <P,Ep>=shape, undirected graph of degree d
◦ Q=set of queries (that can be asked of O)

Two types of queries
◦ Match queries: does tile x fit to tile y?
◦ Positional queries: does tile x fit in position p?
◦ (We assume no spurious matches.)



Pictorial puzzle: Q = all possible queries
Apictorial puzzle: Q = all match queries
Solution: bijection, π, from T to P.

Solution algorithm = decision tree
Queries
from Q
Partitioning
stops when
remaining
solution is
unique
q1?
q2?
q3?
q4?
𝜋1


𝜋2
𝜋3
q5?
𝜋4
𝜋5
Solvable puzzle = has a solution algorithm
Communication complexity = depth of
minimum-depth solution tree
𝜋6


The communication complexity of any set of
solvable jigsaw puzzles with bounded degree is
𝜃(𝑛2 ), where 𝑛 is the puzzle size.
Note that O(𝑛2) is a trivial upper bound (ask all
queries), so proof is really for Ω(𝑛2 ).
◦ Loosely: no easy puzzles.
◦ Our puzzle def simplifies some aspects that cannot
affect this basic result. (e.g., orientation and spurious
matches can only make puzzles more complex.)

Without bounded degree, can be as low as
𝜃(𝑛 log 𝑛).


Any bipartite graph, 𝐿, 𝑅, 𝐸 , with 𝐿 = 𝑅 = 𝑛,
where the degree of each vertex is at least
𝑛/2 has a perfect matching.
Proof: from Hall's theorem
◦ Any set S of size more than n/2 in L or R must have
n neighbours.
◦ □


Any set of bounded-degree graphs, 𝑉, 𝐸 ,
has a code of distance 3 of size Ω( 𝑉 ).
Proof: greedy algorithm
◦ guarantees size
𝑉
𝑉
= 2
=Ω 𝑉
1 + 𝑑 + 𝑑(𝑑 − 1) 𝑑 + 1
per assumption that degree is bounded.
◦ □




Positional puzzle: Q = the set of all positional
queries.
The communication complexity of positional
puzzles is 𝜃(𝑛2 ), where 𝑛 is the puzzle size.
Note: by definition -- solvable
Proof:
◦ We find a long path in the tree.
◦ Can be thought of as an algorithm for an
"adversarial Oracle" trying to delay determination of
the correct matching bijection.
Initialisation
1: 𝑀𝑎𝑡𝑐ℎ𝑒𝑠 ← ∅.
2: 𝑈 = 𝐿, 𝑅, 𝐸 ← 𝑇, 𝑃, 𝑇 × 𝑃 .
The bijection portion already determined.
Bipartite graph managing
unmatched tiles and positions.
Queries not yet asked.
Function DOES X FIT POSITION P(x, p)
𝑁𝑈 𝑥 = x's neighbours in U.
3: 𝑀 ← a perfect matching in U
4: 𝐸 ← 𝐸 ∖ 𝑥, 𝑝
5: while ∃ 𝑙, 𝑟 ∈ 𝑀 such that not (𝑁𝑈 𝑙 > 𝑅/2 and 𝑁𝑈 𝑟 > 𝐿/2 ) do
6:
𝑀𝑎𝑡𝑐ℎ𝑒𝑠 ← 𝑀𝑎𝑡𝑐ℎ𝑒𝑠 ∪ (𝑙, 𝑟).
7:
Restrict U and M to (𝐿 ∖ 𝑙 ) × 𝑅 ∖ 𝑟 .
8: end while
9: return 𝑥, 𝑝 ∈ 𝑀𝑎𝑡𝑐ℎ𝑒𝑠.
end function
Initialisation
1: 𝑀𝑎𝑡𝑐ℎ𝑒𝑠 ← ∅.
2: 𝑈 = 𝐿, 𝑅, 𝐸 ← 𝑇, 𝑃, 𝑇 × 𝑃 .
Exists by Lemma 1.
Function DOES X FIT POSITION P(x, p)
3: 𝑀 ← a perfect matching in U
4: 𝐸 ← 𝐸 ∖ 𝑥, 𝑝
5: while ∃ 𝑙, 𝑟 ∈ 𝑀 such that not (𝑁𝑈 𝑙 > 𝑅/2 and 𝑁𝑈 𝑟 > 𝐿/2 ) do
6:
𝑀𝑎𝑡𝑐ℎ𝑒𝑠 ← 𝑀𝑎𝑡𝑐ℎ𝑒𝑠 ∪ (𝑙, 𝑟).
7:
Restrict U and M to (𝐿 ∖ 𝑙 ) × 𝑅 ∖ 𝑟 .
8: end while
9: return 𝑥, 𝑝 ∈ 𝑀𝑎𝑡𝑐ℎ𝑒𝑠.
Satisfied at latest when 𝐿 = 𝑅 = ∅.
end function
Initialisation
1: 𝑀𝑎𝑡𝑐ℎ𝑒𝑠 ← ∅.
2: 𝑈 = 𝐿, 𝑅, 𝐸 ← 𝑇, 𝑃, 𝑇 × 𝑃 .
By Lemma 1, while this invariant
is maintained and L, R are not
empty, U has more than one
perfect matching, so puzzle is
not yet solved.
Function DOES X FIT POSITION P(x, p)
3: 𝑀 ← a perfect matching in U
4: 𝐸 ← 𝐸 ∖ 𝑥, 𝑝
5: while ∃ 𝑙, 𝑟 ∈ 𝑀 such that not (𝑁𝑈 𝑙 > 𝑅/2 and 𝑁𝑈 𝑟 > 𝐿/2 ) do
6:
𝑀𝑎𝑡𝑐ℎ𝑒𝑠 ← 𝑀𝑎𝑡𝑐ℎ𝑒𝑠 ∪ (𝑙, 𝑟).
7:
Restrict U and M to (𝐿 ∖ 𝑙 ) × 𝑅 ∖ 𝑟 .
8: end while
9: return 𝑥, 𝑝 ∈ 𝑀𝑎𝑡𝑐ℎ𝑒𝑠.
end function


Removing even one element from L and R
requires at least 𝑅/2 = 𝐿/2 queries.
To empty all elements (and solve the puzzle),
one needs at least
𝑛
𝑛−1
1
+
+ ⋯+
= 𝜃 𝑛2
2
2
2

queries.
□


The main claim is different to Lemma 3 in
that here both positional and match queries
are allowed.
We will use the Oracle strategy from Lemma 3
to answer positional queries, but will
◦ change the initialisation; and
◦ provide a new function to answer match queries.
Exists by Lemma 2.
1:
2:
3:
4:
5:
C ← code of distance 3 and size Ω 𝑛 over 𝑃, 𝐸𝑝 .
S ← an arbitrary bijection from T to P.
𝑇𝑐 ← 𝑥 ∈ 𝑇 | 𝑠(𝑥) ∈ 𝐶 .
𝑀𝑎𝑡𝑐ℎ𝑒𝑠 ← 𝑥, 𝑆 𝑥 | 𝑥 ∈ 𝑇 ∖ 𝑇𝑐 .
𝑈 = 𝐿, 𝑅, 𝐸 ← 𝑇𝑐 , 𝐶, 𝑇𝑐 × 𝐶 .
The entire puzzle is
predetermined (so,
essentially, solved), except
for the positions in C.
By construction, 𝐿 =
𝑅 = 𝐶 = Ω(𝑛), so
solving the puzzle still
requires Ω(𝑛2 ) positional
queries.


Simulate each match query by at-most one
positional query.
Examples:
◦ y matches z because this is
part of the "solved" portion.
◦ No two "unsolved" tiles
match. (code distance >1.)
◦ x doesn't match w.
◦ x matches y iff x fits into
position p. (Choice of p
at most unique given y because code distance>2.)




To solve, one still needs to empty U.
Match queries do not manipulate U directly;
only by invoking at most one positional
query.
Therefore, if any solution algorithm
combining match and positional queries of
depth 𝑜(𝑛2 ) can empty U, then there is also
such a solution algorithm using positional
queries only -- contradicting Lemma 3.
□

Conclusions
◦ No (bounded degree) puzzle shapes are essentially
much easier than any others.
◦ No strategy is essentially much better than any
other. (You don't have to start with the border!)

Open problems
◦ All of the above is true in the worst case, against an
adversarial Oracle.
◦ What about the expected complexity? (Simulating
the more realistic situation where tiles are shuffled
randomly, rather than adversarially.)

questions?