ProofSnap

Snap a photo of a handwritten proof and see exactly which step breaks: each step is translated into Lean 4 and checked by the proof assistant.

Role
Solo
Stack
TypeScript, Next.js, Lean 4, Mathlib, AI SDK, Vercel Sandbox, Zod, Tailwind CSS
ProofSnap home page: upload a photo of a handwritten proof or type it, with sample proofs to try
Upload a photo or type the proof, then check it

Problem

Students get proofs back marked wrong with little detail on which step failed or why. A language model alone can grade confidently and still be wrong, so a formal proof checker decides each step and the model only translates and explains.

What I built

A vision model transcribes the theorem and splits the proof into numbered steps without fixing anything. The model then writes a Lean 4 + Mathlib file where every student step is its own have claim, so a false or unjustified step fails in Lean.

Lean runs in a Vercel Sandbox microVM booted from a snapshot with Mathlib and its build cache already in place, with all network access denied and a 150-second limit per check.

Lean errors are mapped back to steps. The model gets up to two repair passes for Lean technicalities without changing what any step claims, and #print axioms confirms no sorry or non-standard axiom slipped in.

Lean’s per-step result is the ground truth. The model explains each failing step in plain math, with a counterexample when there is one, and flags it when the formal statement doesn’t match what the student set out to prove.

Results

  • Live on Vercel.
  • A hand-labeled set of 9 proofs (correct ones, plus ones with a known first wrong step) runs through an admin route that checks whether the verdict and the first wrong step match. A daily cron keeps Lean warm.

Questions about ProofSnap? Email me