Formal verification

Proof lab

A proof assistant checks every step of an argument. Lean 4 is one of the most active systems, and it is increasingly used for research mathematics. The examples below open in the official Lean playground with the code already loaded.

Read this first
What Lean checks

A proof against a formal statement, step by step, using the rules of the system.

What it does not check

Whether the formal statement matches the problem you had in mind. That translation needs human review.

What sorry means

A proof with sorry is incomplete. Lean accepts it with a warning because drafts need placeholders.

OpenProblems does not run Lean. The buttons open the official playground, where code is checked on Lean servers. Do not paste anything private.

4 small exercises

Try the checker

Runs on live.lean-lang.org
Start here

Ask Lean what already exists

Lean 4

Lean ships with a large mathematical library. The #check command prints the type of a definition or theorem, which is how most proofs begin.

import Mathlib

#check Nat.Prime
#check Nat.add_comm
#check Real.sqrt
#check Function.Injective

Try this: Replace one name with a definition you want to use. If Lean finds it, its type appears in the messages panel.

First proof

Close a goal with automation

Lean 4

Addition of natural numbers is commutative. Lean can close this goal with omega, a decision procedure for linear arithmetic.

import Mathlib

example (a b : Nat) : a + b = b + a := by
  omega

Try this: Change the statement to a + b + 1 = b + a + 1 and run it again. Then remove omega and see what Lean reports.

Rewriting

Use a hypothesis

Lean 4

If a equals b, then a + 1 equals b + 1. The rw tactic replaces one side of a hypothesis throughout the goal.

import Mathlib

example (a b : Nat) (h : a = b) : a + 1 = b + 1 := by
  rw [h]

Try this: Change the goal to a + 1 = b + 2. Lean will reject the proof, which shows that the checker is doing real work.

Calculation

Let ring do the algebra

Lean 4

The ring tactic proves identities that follow from the rules of addition and multiplication. Here it shows that doubling n is the same as adding n to itself.

import Mathlib

example (n : Nat) : 2 * n = n + n := by
  ring

Try this: Try 3 * n = n + n + n. Then try an identity that is false and read the error message.

What it takes

Formalising an open problem

A formal proof is not a substitute for checking the problem statement. A solved problem needs three separate things.

  1. 01
    State the problem formally.

    Every symbol and quantifier must be defined, including the domain and the meaning of equality.

  2. 02
    Prove it.

    The kernel checks each step against the rules of the system. A proof that uses sorry does not count.

  3. 03
    Check the translation.

    A proof of a different statement is not a solution. The formal statement must be reviewed against the original problem.

For claimed proofs

A machine check is evidence, not acceptance

A Lean proof can show that a formal statement follows from the definitions. It cannot show that the statement captures the intended problem, that the definitions are the standard ones, or that the proof has been reviewed by the relevant experts. This catalogue treats claims separately from accepted results for that reason.

In this catalogue

External formalisations

3 entries

Some entries link to machine-checked formalisations of a result or its underlying definitions. A formalisation is listed separately from the editorial status of the problem.

Four Color Theorem
Mathematics · Graph theory
Coq formalisation ↗
Kepler Conjecture
Mathematics · Discrete geometry
HOL Light formalisation ↗
The Halting Problem
Computer Science · Computability theory
Lean formalisation ↗
Go further

Lean resources

Lean language and install guide ↗
The official project site, with documentation and setup instructions.
Mathlib ↗
The community mathematics library used by most research formalisations.
Lean playground ↗
The official browser editor. Code is checked on Lean servers, not on this site.
Public discussion
All public threads ↗

Comments are public and need a GitHub account. A comment does not change the editorial status of this entry. For a claimed proof, link the manuscript, its date and the step you believe is new.

Start a public thread ↗How claims are handled ->

If the thread does not load, open it on GitHub ↗