Skip to content
LeanLearn
Level 3~40 minLean 4

Cube Quest 3 · Mechanize: moves as data

A move is itself a cube state, and doing one move after another is a multiplication. Write the move R in Lean and watch your own definition turn the 3D cube.

You will be able to
  • Represent a move as the state it produces from the solved cube.
  • Compose moves with multiplication and predict which pieces a sequence moves.
  • Define R yourself and prove it correct against a sticker specification.

Recommended first: Cube Quest 2 · Formalize: the cube as a Lean structure. You can start anyway. Nothing is locked.

EncounterActivity 1 of 6

Encounter

Here is the key idea of this world: a move is a cube state, namely the state you get by doing that move to a solved cube. R is the five lists you see after one clockwise turn of the right face.

Doing a and then b is written a * b. To compute it, ask for each slot i: "which piece does b put here?" (b.cp[i], call it j), then "which piece did a put in slot j?" (a.cp[j]). Twists add up along the way, mod 3:

(a * b).cp[i] = a.cp[b.cp[i]]
(a * b).co[i] = (a.co[b.cp[i]] + b.co[i]) % 3

The solved cube 1 changes nothing: 1 * c = c * 1 = c. Every move can be undone: R * R' = 1. These are exactly the rules of a group, which is where Cube Quest is heading.