Module 5: Reading Real Lean·Lesson 15 of 16·5 min read

Lean Accepted It. Is It True? How to Read a Theorem Statement

Here is a problem. Someone shows you a Lean file and says "this theorem is formally verified". Lean accepted it. Does that mean the claim you care about is true? Not necessarily. Lean checks that the proof matches the statement. It does not check that the statement says what the person claims it says.

So the skill that matters most when reading real Lean is reading the statement itself. This lesson walks through every part of a theorem statement, then shows two ways a checked theorem can still mislead you: sorry, and definitions hidden behind friendly names.

The parts of a statement

Take this Mathlib-style theorem:

lean
import Mathlib

theorem my_mul_inv {F : Type*} [Field F] (a : F) (h : a ≠ 0) :
    a * a⁻¹ = 1 :=
  mul_inv_cancel₀ h

#check @my_mul_inv
example : (3 : ℚ) * 3⁻¹ = 1 := my_mul_inv 3 (by norm_num)
#print axioms my_mul_inv

Read it left to right:

  • theorem my_mul_inv is the name. It is only a label. Lean does not check that the name matches the content.
  • Everything between the name and the colon is a list of binders: the inputs the theorem needs.
  • After the colon, a * a⁻¹ = 1 is the conclusion, the thing being promised.
  • After := comes the proof. When reading a statement, you can mostly skip this part. Lean has checked it.

Three kinds of brackets

The binders use three kinds of brackets, and each means something different.

Round brackets (a : F) are explicit arguments. When you use the theorem, you pass them yourself, as in my_mul_inv 3 ....

Curly brackets {F : Type*} are implicit arguments. Lean works them out from the other arguments, so you do not write them. In the example, Lean sees 3 : ℚ and figures out that F is ℚ.

Square brackets [Field F] are instance arguments. They say "this only applies when F is a field", and Lean finds the proof of that automatically from its library of instances. When you see a square bracket, read it as a condition on the type: the theorem holds for every field, not for every type.

Here is the same idea in core Lean, with no Mathlib:

lean
-- implicit and explicit binders
theorem len_append {α : Type} (xs ys : List α) :
    (xs ++ ys).length = xs.length + ys.length := by
  simp

#check len_append [1, 2] [3]
#check @len_append

The first #check passes only the two lists, and Lean fills in α as Nat. The @ in the second one turns all arguments explicit, so Lean prints the full statement with {α : Type} visible.

Hypotheses versus conclusion

In my_mul_inv, the binder (h : a ≠ 0) is not a value. It is a proof that a is not zero. Binders like this are hypotheses: conditions the user of the theorem must supply.

This is where careful reading pays off. A theorem only promises its conclusion when all its hypotheses hold. If a statement has a strong hypothesis that is hard to satisfy, its conclusion may say much less than it seems to. Always ask: under what conditions is this claimed? A theorem with a hypothesis that can never be true proves nothing useful, even though Lean accepts it.

Animation: The parts of my_mul_inv: implicit, instance and explicit arguments, a hypothesis, and the conclusion.

What sorry means

sorry is a placeholder that tells Lean "accept this without proof". It is useful while you are writing, because you can leave holes and fill them later. Lean prints a warning, but the file still compiles. That is the danger: a file can contain a false theorem and still build.

This snippet uses sorry on purpose to show the problem:

lean
theorem my_add_comm (a b : Nat) : a + b = b + a := Nat.add_comm a b

theorem cheat (n : Nat) : n * 0 = 1 := by
  sorry

#print axioms my_add_comm
#print axioms cheat

The statement n * 0 = 1 is false, yet Lean only warns: declaration uses sorry. If you just ran the file and looked for errors, you might miss it.

#print axioms: the honest check

#print axioms tells you what a theorem ultimately rests on. For the snippet above, Lean prints 'my_add_comm' does not depend on any axioms. For the false one it prints 'cheat' depends on axioms: [sorryAx]. The sorryAx entry means a sorry is somewhere in the chain, even if it is buried deep inside a lemma used by a lemma.

Normal Mathlib proofs often depend on three standard axioms: propext, Classical.choice and Quot.sound. Those are expected and accepted.

lean
-- classical axioms show up too
theorem em_example (p : Prop) : p ∨ ¬p := Classical.em p
#print axioms em_example
theorem decide_example : 10 < 20 := by decide
#print axioms decide_example

The first prints those three standard axioms. The second depends on none. What should worry you is sorryAx, or any axiom declared in the project itself with the axiom keyword. An axiom is an assumption Lean takes on trust, so a project can assume anything that way.

Definitions hide behind names

This is the trap that catches even careful readers. A statement uses words like IsPrime or Stable, and you read them in their everyday meaning. But in Lean, each word is a definition that someone wrote. The theorem is only about what that definition actually says.

lean
-- The theorem line looks impressive. The definition is not.
def IsPrime (n : Nat) : Prop := n > 1

theorem four_is_prime : IsPrime 4 := by
  unfold IsPrime
  decide

#print axioms four_is_prime
#print IsPrime

Lean accepts four_is_prime, and #print axioms says it depends on no axioms at all. It is a fully checked proof. It is also not about primes, because this IsPrime only means "greater than 1". #print IsPrime shows the real definition: fun n => n > 1.

The lesson: you must read the definitions a statement uses, not just the theorem line. Use #print on any name you do not recognise, or click through to its source in the docs. Keep going until you reach definitions you trust, such as ones from Mathlib.

A reading checklist

When you meet a claimed result in Lean, check in this order:

  1. Read the conclusion after the colon. Is it the claim you were told?
  2. Read every hypothesis. Are they reasonable, and can they all hold at once?
  3. Look at the square brackets. Which types does this cover?
  4. #print every unfamiliar name in the statement and read its definition.
  5. Run #print axioms. Look for sorryAx or project-specific axioms.

Try this

On live.lean-lang.org, paste the IsPrime snippet. Then change the definition to n > 5 and see which line breaks. Fix the theorem by changing 4 to a number that satisfies the new definition, and run #print axioms again.

The next lesson applies this checklist to a real research claim, statement by statement.

Sources

Try it yourselfMedium

Spot the hypothesis that makes a theorem trivial

`safe_div` claims that dividing then multiplying gives the number back. It has a proof, but one hypothesis makes it say almost nothing. Prove it, then prove `strong_hyp_false` to show that hypothesis can never hold.

theorem safe_div (n d : Nat) (h : d > d) : n / d * d = n := by
  sorry

theorem strong_hyp_false (d : Nat) : ¬ (d > d) := by
  sorry
Open in the Lean web editor

The official Lean editor runs in your browser and checks the file on Lean's server. Replace every sorry until no errors or warnings are left, then mark it solved.

The worked solution unlocks after your first attempt.

Saved in this browser. Pass the quiz while signed in to count it for the certificate.

Check what you learned

Answer all 3 questions. You need at least 2 right to pass.

1. What do square brackets like [Field F] mean in a statement?

2. What does it mean if #print axioms lists sorryAx?

3. Why was four_is_prime misleading even though it has no axioms?