Skip to content
ProofQuest

ProofQuest

Every Move Must Be Proven.

Created on 24th October 2026

•

ProofQuest

ProofQuest

Every Move Must Be Proven.

The problem ProofQuest solves

The Problem It Solves

Theorem provers like Lean 4 are some of the most powerful tools we have for writing bug-free code and mathematically verifying software. But learning them can be brutal.

Most people open a Lean tutorial and immediately get hit with walls of type theory, confusing syntax, and cryptic compiler errors. You spend hours trying to figure out what an "unsolved goal" or "metavariable" means before you can even prove anything simple. As a result, most developers bounce off formal verification before they ever get to see why it's useful.

ProofQuest fixes this by turning formal proofs into visual tile puzzles. Instead of proving abstract math lemmas, you write actual Lean tactics (swap, paint, rotate_row) to turn a starting board into a target board. It gives you an immediate visual handle on what tactics do: each move changes the board, and finish closes the proof once everything matches.


What People Can Use It For

  • Learning Lean 4 without the headache: If you're a developer who has been curious about formal verification, ProofQuest lets you build an intuition for goals, tactic chaining, and macros in minutes instead of days.
  • Teaching discrete math and logic: Computer science professors and TAs can use it in class to explain state machines and inductive steps. Students see the board update live instead of staring at dry whiteboard symbols.
  • Brain teasers for developers: It plays like a logic puzzle (think sliding tiles or Rubik's cube), but the solution you write is actual verified code.

How It Makes Things Easier and Safer

  • You can actually see your proof state: In a standard editor, inspecting intermediate proof states means deciphering terminal text. ProofQuest shows the board after every step, complete with a timeline slider so you can scrub backward and forward to see where things went off track.
  • Real verification under the hood: This isn't a mock or client-side fake. A live Lean 4 compiler runs in the background. When your solution passes, Lean has mathematically checked every move.
  • Clear, human-readable errors: Instead of 20-line compiler dumps, ProofQuest translates errors into plain English—telling you if a tile index is out of bounds, if your syntax is off, or if you still have remaining tiles to fix.
  • Zero installation required: No wrestling with Elan, Lake, or VS Code extensions just to try out Lean. It runs instantly in the browser.

Challenges I ran into

Challenges I Ran Into

1. Sluggish Lean 4 Execution Times (From 3s down to <800ms)

When I first hooked up the Lean compiler to the backend, running a proof took anywhere from 2.5 to 4 seconds per check. Lean 4 is a heavy, industrial-grade theorem prover, not an interpreted scripting language. Cold-starting a new process with lake env lean meant Lean was loading its standard library and environment from scratch on every single check.

How I fixed it:
I pre-built the core game logic (ProofQuest.lean) into compiled .olean binaries ahead of time using Lake. That way, the runtime process only has to compile the few lines of tactics the user wrote, rather than the entire board state machine. I also added server-side startup pre-warming and an in-memory LRU cache for identical proofs. This brought round-trip verification time down to under 800ms.


2. Extracting Step-by-Step Board Snapshots from Lean's Tactic Engine

Lean either accepts a proof or throws an error—it isn’t designed out-of-the-box to send intermediate game state to a browser. I didn't want the UI to just say "Yes" or "No"; I needed the user to see what the board looked like after every single tactic so the step timeline and diff markers could work.

How I fixed it:
I wrote custom Lean 4 tactic macros that hook into Lean’s elaboration stage. Every time a tactic like swap or paint executes, the macro calls logInfoAt to spit out structured JSON state markers (PQ_STATE {"cells": [...]}) into Lean's compiler output. Running Lean with the --json flag let my Node.js backend parse the diagnostics stream, map each state snapshot to the exact player line, and send a clean step-by-step timeline back to the frontend.


3. The sorry Cheat and Sandboxing

In Lean, typing the sorry tactic tells the type checker: "trust me, this theorem is true without a proof." During early testing, anyone could just type sorry or admit on any level, and Lean would report exit code 0 ("Proof Verified!").

How I fixed it:
I built a backend AST & token sanitizer in sanitizer.ts. Before code touches the Lean process, it strips comments and checks for forbidden keywords (sorry, admit, #eval, axiom, and unsafe foreign imports). If Lean's output mentions declaration uses 'sorry', the verifier immediately flags it as a cheat and rejects the submission.


4. Translating Compiler Line Numbers to the User's Editor

The user only types 2 or 3 lines of tactics in the UI, but under the hood, the backend wraps those tactics in imports, type definitions, initial board constants, and theorem headers.

Initially, when a user had an error on their first line, Lean would report:

Error on line 18: tile 9 is out of bounds

This was confusing because the player's editor only had 2 lines of code.

How I fixed it:
I wrote a source-map offset tracker in the template assembler (assembler.ts). It tracks exactly where the user's code is spliced into the full Lean harness. Any diagnostics or warnings coming out of Lean's JSON stream have their line coordinates re-mapped so errors highlight the exact line in the browser's CodeMirror editor.

Tracks Applied (1)

Functional Programming Track

ProofQuest is built entirely around Lean 4, a pure functional programming language and theorem prover. Instead of trea...Read More

FP Launchpad

Discussion

Builders also viewed

See more projects on Devfolio