Lean check

From flonat/flonat-research · View interactive version

Lean check is an AI agent skill from the GitHub repository flonat/flonat-research. Formalize a self-authored lemma or theorem in Lean 4/mathlib and require a clean `lake build` without `sorry`. Use when the mathematical claim can be stated faithfully and machine-checked. For numerical falsification or symbolic algebra, use $numerical-check or $symbolic-check.

How to use this skill

Skill file

Lean Check: Machine-Prove a Self-Authored Lemma

Formalize a lemma/theorem in Lean 4 + mathlib and let the kernel check it. A lake build that succeeds with no sorry and no extra axioms is a machine-verified proof — the strongest guarantee available.

When to Use

When NOT to Use

| Situation | Use instead |

|---|---|

| Stress-test / hunt a counterexample to a distributional claim | numerical-check (R1) |

| Verify an algebra / derivative / limit / closed-form step | symbolic-check (R2) |

| A statement too rich to faithfully formalize in reasonable time (heavy measure theory, bespoke objects) | domain-reviewer — do NOT force a lossy Lean statement |

Position in the verification spectrum

R3 — formal machine proof. The top rung: lake build (clean, sorry-free) = a kernel-checked theorem. Cost is high (formalization effort + statement fidelity), so reserve it for the claims that matter most; use R1/R2 to triage first.

Toolchain (pre-seeded — do not re-download)

Procedure

1. State the lemma FAITHFULLY (the hard part — get this right or the check is worthless)

2. Write the module into the mathlib project scratch (NEVER the Overleaf paper)

Write to ~/lean-verify/mathlib_verify/MathlibVerify/<Name>.lean:

import Mathlib
theorem <name> (<hyps>) : <conclusion> := by
  <tactic proof>

3. Prove with mathlib tactics; iterate

4. Build and read the verdict

cd ~/lean-verify/mathlib_verify && lake build MathlibVerify.<Name>

5. Emit the verification report + keep the .lean

Verdict semantics (important)

| Outcome | Verdict |

|---|---|

| Faithful statement, clean build, no sorry, standard axioms only | VERIFIED |

| Proved the negation | FALSIFIED |

| Faithful statement, proof didn't close after real effort | INCONCLUSIVE (unproven) |

| Can't faithfully formalize the claim | INCONCLUSIVE (not formalizable) |

| Toolchain / build-system failure | ERROR |

Anti-Patterns

Output — Verification Report (shared `*-check` shape)

Write to reviews/<scope>/verify-lean/<YYYY-MM-DD-HHMM>.md, and copy the .lean module beside it (or note its path):

claim:    <informal statement> ⟶ <Lean statement (verbatim)>
fidelity: <one line: why the Lean statement faithfully encodes the claim>
method:   R3 Lean 4 (v4.31.0) + mathlib; lake build; sorry-free; axioms = <#print axioms output>
verdict:  VERIFIED | FALSIFIED | INCONCLUSIVE (unproven|not formalizable) | ERROR
reproduce: cd ~/lean-verify/mathlib_verify && lake build MathlibVerify.<Name>   (module attached)

Verification (did this skill work?)

Worked example (toolchain smoke)

theorem lc_smoke (a b : ℝ) (h : a ≤ b) : a - 1 < b + 1 := by linarith → lake build exit 0, no sorry, standard axioms → VERIFIED. (A faithful Lean formalization of the median-collapse theorem itself — Φ, medians of distributions, the large-council limit — is a genuine formalization project; lean-check is for the tractable load-bearing lemmas, with R1/R2 covering the rest.)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.