lean-proof-checker / README.md
Angshul's picture
Upload 3 files
d7f867a verified
|
Raw History Blame Contribute Delete
2.89 kB
metadata
title: Lean Proof Checker
emoji: 🧮
colorFrom: indigo
colorTo: blue
sdk: gradio
sdk_version: 6.32.0
python_version: '3.12'
app_file: app.py
pinned: false
license: apache-2.0
short_description: Math proofs from a PDF, checked step by step in Lean 4
preload_from_hub:
  - Qwen/Qwen3-VL-8B-Thinking
  - deepseek-ai/DeepSeek-Prover-V2-7B

Lean Proof Checker

Upload a PDF of theorems with their proofs (or paste one). For each problem:

  1. Read – Qwen3-VL-8B-Thinking (a reasoning model) transcribes the PDF pages into theorem + proof text.
  2. Skeleton – the same model writes a Lean 4 skeleton: the theorem statement plus one have per step of the human proof, each left as sorry. Steps the human skipped are added and marked (gap). Lean compiles the skeleton; errors go back to the model (up to 4 rounds).
  3. Automatic tactics – omega, linarith, nlinarith, positivity, norm_num, simp, ring_nf, field_simp are tried on every step in one Lean run (no GPU).
  4. Prover – each remaining step is turned into a standalone lemma from its Lean goal and given to DeepSeek-Prover-V2-7B, which samples several proofs at once. All candidates are checked in one Lean run; the first that compiles is used.
  5. Final check – Lean compiles the assembled proof. Verified means no sorry, no new axioms, only Lean's standard axioms.
  6. Fallback – if no skeleton compiles, the model writes only the theorem statement (the failed skeleton's statement is tried first), and the prover proves the whole theorem with the human proof as a hint. Such a result says whether the theorem is provable, not whether each human step is right.
  7. Back-translation – the Lean statement is translated back into English so you can check it says what your theorem says.

Everything runs inside this Space: Lean 4 + Mathlib on the CPU, both models on ZeroGPU. No external API, no API keys.

Hardware and limits

  • Create the Space with the Gradio SDK and ZeroGPU hardware (needs a PRO account).
  • On every cold start the Space installs Lean and downloads prebuilt Mathlib (about 5–10 minutes); the page shows the progress. A Space on free hardware sleeps after 48 hours without visits.
  • GPU time is taken from the daily ZeroGPU quota of whoever runs the check. A problem typically uses a few GPU minutes.
  • The models can be swapped with the Space variables VL_MODEL and PROVER_MODEL.

Files

File Purpose
app.py Gradio UI and streaming handlers
core.py Skeleton, goal probing, automatic tactics, prover rounds, final check, PDF parsing
models.py The two models and their @spaces.GPU functions
leanenv.py Background Lean install and the Lean checker
setup_lean.sh Installs elan, creates the Mathlib project, downloads the Mathlib cache