Proof Puzzle
Every move a proof. Every win checked by Lean.
Created on 24th October 2026
•
Proof Puzzle
Every move a proof. Every win checked by Lean.
The problem Proof Puzzle solves
Proof Puzzle makes formal verification tangible through a visual game. Players rearrange colored blocks by writing short Lean tactics: swap, paint, and rotate. The board follows each line immediately, and illegal moves highlight the affected tiles. A level clears only after the Lean kernel checks that legal moves reach the target.
Seven levels progress from two simple swaps to 3×3 boards and player-defined helpers. A guided helper builder generates visible, editable Lean macros, so beginners can name and reuse patterns without memorizing the syntax. Helpers can compose earlier helpers.
The game connects functional programming concepts to concrete actions: immutable board states, pure transition functions, composition, resource constraints, invariants, and abstraction. It is designed as a first encounter with proof assistants; educational effectiveness has not yet been measured in a user study.
Verification is inspectable: players can download a standalone Lean file and check it independently. The browser provides an instant preview, while Lean checks bounds, adjacency, locked cells, paint, move budgets, orientation, and the final target.
Validation includes seven accepted reference solutions, rejection tests, 20,310 comparisons between the browser simulator and Lean across three configurations, and four UI-state regression tests. All 13 tests pass. Uncached local checks measured 148–257 ms after rule precompilation; these measurements exclude browser and network latency.
Built for the organizer-provided Proof Puzzle challenge in the Functional Programming Track. Current execution is local; the repository contains setup instructions, tests, and a standalone proof. AI coding assistants supported implementation, debugging, and test generation.
Challenges I ran into
The main challenge was making every player line a genuine Lean tactic rather than merely animating a script. We defined pure board transitions and proved a Reaches.move lemma. Each tactic applies that lemma, proves the move legal with decide, and leaves the next state as the remaining goal. A final equality check closes the proof.
An early formulation duplicated state expressions and made proof goals grow rapidly. A named next-state function keeps the terms linear. Precompiling the rules to an .olean and caching repeated results reduced local checks to roughly 0.15–0.26 seconds in the recorded benchmark.
The browser preview also had to agree with Lean. We generated 20,310 one- and two-move sequences across three board configurations and compared outcomes, including illegal moves, exhausted resources, rotations, and locked tiles.
We mapped compiler diagnostics back to player lines, including helper calls. We also fixed a race where editing during verification could leave the check button disabled or allow stale responses to affect a newer proof. Completion badges now depend on the level definition so redesigned levels cannot inherit old wins.
Helper syntax was a usability hurdle, so we added a form that generates editable Lean macros. The editor intentionally accepts a restricted tactic grammar; arbitrary Lean execution and production hosting remain outside this prototype.
Tracks Applied (1)
Functional Programming Track
FP Launchpad
Technologies used
