Solving Rubiks Cube Using SAT Solvers

Solving Rubiks Cube Using SAT Solvers
Notice: This research summary and analysis were automatically generated using AI technology. For absolute accuracy, please refer to the [Original Paper Viewer] below or the Original ArXiv Source.

Rubik’s Cube is an easily-understood puzzle, which is originally called the “magic cube”. It is a well-known planning problem, which has been studied for a long time. Yet many simple properties remain unknown. This paper studies whether modern SAT solvers are applicable to this puzzle. To our best knowledge, we are the first to translate Rubik’s Cube to a SAT problem. To reduce the number of variables and clauses needed for the encoding, we replace a naive approach of 6 Boolean variables to represent each color on each facelet with a new approach of 3 or 2 Boolean variables. In order to be able to solve quickly Rubik’s Cube, we replace the direct encoding of 18 turns with the layer encoding of 18-subtype turns based on 6-type turns. To speed up the solving further, we encode some properties of two-phase algorithm as an additional constraint, and restrict some move sequences by adding some constraint clauses. Using only efficient encoding cannot solve this puzzle. For this reason, we improve the existing SAT solvers, and develop a new SAT solver based on PrecoSAT, though it is suited only for Rubik’s Cube. The new SAT solver replaces the lookahead solving strategy with an ALO (\emph{at-least-one}) solving strategy, and decomposes the original problem into sub-problems. Each sub-problem is solved by PrecoSAT. The empirical results demonstrate both our SAT translation and new solving technique are efficient. Without the efficient SAT encoding and the new solving technique, Rubik’s Cube will not be able to be solved still by any SAT solver. Using the improved SAT solver, we can find always a solution of length 20 in a reasonable time. Although our solver is slower than Kociemba’s algorithm using lookup tables, but does not require a huge lookup table.


💡 Research Summary

The paper presents a novel approach to solving the Rubik’s Cube by translating the puzzle into a Boolean satisfiability (SAT) problem and then solving it with a specially engineered SAT solver. The authors first address the naïve encoding that uses six Boolean variables per facelet to represent the six possible colors. Recognizing that only ⌈log₂6⌉≈3 bits are required, they propose a compact representation using either three bits (for general states) or two bits (for the so‑called H‑states that appear in the second phase of Kociemba’s two‑phase algorithm). This reduction cuts the number of variables from 288 (6 × 48) down to 144 or 96, dramatically shrinking the CNF size.

Next, they improve the encoding of moves. Instead of directly encoding the 18 possible quarter‑turns (U, U’, U2, …, B2), they introduce a hierarchical “layer” encoding: six axis variables (u, d, l, r, f, b) indicate which face is turned at a given step, and each axis variable is linked to three sub‑turn variables (e.g., U, U’, U2). Exactly‑One constraints enforce that each step performs exactly one axis turn and exactly one sub‑turn within that axis. By separating the unchanged facelets from the changed ones and reusing the same constraints for all sub‑turns of the same axis, they reduce the clause count by roughly one third.

The authors also incorporate constraints from the two‑phase algorithm. Phase‑1’s goal state is added as an extra CNF clause, while Phase‑2’s H‑states are encoded with the two‑bit scheme, exploiting the fact that top and bottom faces never move to the side faces under the restricted move set A₁₀. To enforce the at‑most‑one (AMO) condition efficiently, they adopt the two‑product AMO encoding, which for n = 20 requires only 56 clauses instead of the standard 190.

To prune symmetric search paths, they add clauses that forbid move sequences that are commutative (e.g., “U D” vs. “D U”), thereby eliminating redundant branches. They also encode a subset of Kociemba’s algorithmic knowledge as additional constraints, allowing the SAT solver to find solutions up to length 13 directly; for longer solutions (up to the optimal God’s number 20) they rely on the specialized solver.

Recognizing that state‑of‑the‑art SAT solvers still struggle with the resulting instances, the authors design a new solver based on PrecoSAT. The traditional look‑ahead heuristic is replaced by an At‑Least‑One (ALO) driven branching strategy that selects decision variables appearing in AMO constraints. The original CNF is then decomposed into several sub‑problems, each solved independently by PrecoSAT. This decomposition is tailored to the Rubik’s Cube structure and is not a generic SAT technique.

Experimental evaluation shows that the combined encoding and solver can consistently find optimal‑length (20‑move) solutions within a reasonable time frame, using only about 10 MB of RAM. While the runtime is slower than Kociemba’s algorithm, which relies on massive precomputed lookup tables, the SAT‑based approach avoids the need for such tables and demonstrates that SAT technology can be applied to a classic combinatorial puzzle.

In summary, the paper contributes (1) a highly compact SAT encoding for Rubik’s Cube states and moves, (2) clever use of two‑phase constraints and symmetry‑breaking clauses, and (3) a customized SAT solver that leverages ALO branching and problem decomposition. The work expands the applicability of SAT solvers to planning problems with large state spaces and shows that, with problem‑specific engineering, SAT can solve instances previously thought out of reach.


Comments & Academic Discussion

Loading comments...

Leave a Comment