17. What a checked proof guarantees
Lean’s elaborator converts notation, implicit arguments, type-class instances, and tactic scripts into core expressions. The kernel checks those expressions against their types. The resulting proof term must satisfy the kernel’s checks regardless of how the tactic constructed it.
That guarantee has boundaries. The statement may omit an assumption from the real application. A definition may model a physical quantity in the wrong units.
Runtime code, foreign functions, parsing, operating systems, and external services add assumptions beyond a pure theorem.
Audit assumptions
The kernel checks that the proof term establishes the theorem under its stated assumptions.
theorem identityProof (P : Prop) : P → P := fun h => h
#print axioms identityProof
example (P : Prop) : P ∨ ¬ P := by
classical
exact Classical.em P
#print axioms reports the axioms on which a declaration depends transitively. An ordinary constructive identity proof needs no axioms, while classical proofs may depend on standard logical principles.
A proof using sorry depends on sorryAx, which stands for an unfinished argument.
Review logical assumptions and runtime mechanisms separately. Lean restricts unsafe declarations to uses outside trusted proofs.
noncomputable definitions can use classical existence without producing executable algorithms. Lean can run partial definitions, but treats them as opaque in proofs.
A new axiom adds an assumed constant without proving it. Use it only for a deliberate assumption in the theory.
Computation in proofs
decide can establish decidable propositions by reduction. Other mechanisms may rely on compiled computation and introduce additional trust assumptions. For an accelerated decision tactic, check its documented trust assumptions and inspect the resulting theorem’s axiom dependencies.
The account project’s theorems quantify over all mathematical inputs to the total pure function. The CLI tests exercise selected executions through parsing and output.
Equality beyond rewriting
Function extensionality, funext, proves functions equal by proving equal outputs at every input. Structure extensionality reduces equality to fields when an appropriate theorem or tactic is available. Quotients identify values through an equivalence relation, allowing mathematics to use objects determined up to that relation.
These principles explain some common dependencies printed by axiom inspection. Check what each dependency means and whether it fits the foundations you intend to use.
example (f : Nat → Nat) : (fun x => f x) = f := by
funext x
rfl
Exercises
- Inspect the axioms of a small theorem you proved by induction.
- Explain the difference between a theorem with a missing proof and one using classical logic.
- List which parts of the final CLI are covered by the conservation theorem and which are covered only by integration tests.
A useful verification claim identifies the statement, the model, the checked artefact, and the assumptions connecting it to the surrounding system.