Trace what a proof rests on with #print axioms
An unproved lemma deep in the graph makes everything above it unproved; Lean says so, and refuses a false claim.
Trust flows along the dependency graph: a result is only as well established as everything beneath it. This core-Lean file has one unproved lemma, one careful proof built on it, one independent result, one use of classical logic and one false claim, and asks Lean what each rests on.
Run it
Save this as proof_rests_on.lean and run lean proof_rests_on.lean with Lean 4.35.0 (core Lean only, no Mathlib), or paste it into the Lean 4 web editor at live.lean-lang.org
.
-- What a proof rests on: trust flows along the dependency graph (core Lean 4).
theorem stepA (n : Nat) : n + 0 = n := sorry -- unproved
theorem stepB (n : Nat) : (n + 0) + 0 = n := (stepA (n + 0)).trans (stepA n)
theorem stepC (n : Nat) : 0 * n = 0 := Nat.zero_mul n
#print axioms stepA -- sorryAx
#print axioms stepB -- sorryAx: careful proof, unproved foundation
#print axioms stepC -- nothing: independent of stepA
-- Classical reasoning is an axiom too, and it shows up.
theorem em_used (p : Prop) : p ∨ ¬ p := Classical.em p
#print axioms em_used
-- The kernel must be seen to say no: a false statement is rejected.
theorem wrong : 2 ^ 5 + 1 = 34 := by decideExpected outcome
proof_rests_on.lean:3:8: warning: declaration uses `sorry`
'stepA' depends on axioms: [sorryAx]
'stepB' depends on axioms: [sorryAx]
'stepC' does not depend on any axioms
'em_used' depends on axioms: [propext, Classical.choice, Quot.sound]
proof_rests_on.lean:16:37: error: Tactic `decide` proved that the proposition
2 ^ 5 + 1 = 34
is falsestepB has a correct proof of its own, but it uses stepA, which is sorry:
so it rests on sorryAx, and is not proved. stepC does not touch either and
depends on nothing. em_used shows that classical reasoning appears as axioms
too. The last line is the kernel seen to say no: decide evaluates both sides
and reports the proposition false. The same reading, at scale, is Part I,
chapter 5.
Mechanism and limitations
Documented: Chapter 16 of the book sets out the mathematics; this program is a self-contained demonstration of it, not one of the laboratory’s recorded investigations.
Observed: the output above, produced by running the program exactly as shown.
Not shown:
#print axiomsreports what a declaration depends on; it does not judge whether those axioms are acceptable for the claim.- The warnings and the final error are the expected output: the file is meant to fail on its last line.
Related worked example: Chapter 6 .
Challenge this result
Copy this into the AI assistant of your choice, or work through it yourself. Check any finding against the recorded evidence.
Examine the dependency graph of the file. For each declaration, predict
`#print axioms` before running it, then check. Explain why `stepB` is not
proved although its own proof is correct. Then add a declaration that uses
`stepC` and `em_used` but not `stepA`, and say what it rests on.
Chapter: https://programmer.ie/books/math/16-chapter/
Example: https://programmer.ie/examples/math/16-chapter/
Program: https://github.com/ernanhughes/math/blob/main/notebooks/math/programs/16-proof-rests-on.lean
Distinguish what the record shows from what you infer. If you cannot open a link, ask me for the material; do not invent it.Canonical source and the program .
Understand this example
Copy this prompt into your AI tool. No code runs here.
Apply this example
Copy this prompt into your AI tool. No code runs here.