Formalization of Mathematical Proofs

Lean checks mathematical proofs as typed terms. A small conjunction example shows how the kernel and the library contribute different kinds of assurance.

Source
Anbloq
Language
English
Created
Updated
Chapters
3
Reading time
2 min
In this article3 chapters
  1. Proofs as dependent terms
  2. A proof term for a familiar inference
  3. Working with Mathlib and auditing assumptions

Proofs as dependent terms

In Lean, a proposition is a type in \(\mathtt{Prop}\), and a proof is a term of that type. A function type \(P\to Q\) describes a transformation from proofs of \(P\) to proofs of \(Q\). A dependent function type lets the output type vary with the input. \[f:\prod_{x:A} B(x), \qquad f(a):B(a)\quad\text{for } a:A.\] This supports the direct encoding of universally quantified properties and mathematical structures with laws. An existential statement carries a witness and proof of its property at the level of the proposition, although extracting data from proofs in \(\mathtt{Prop}\) is subject to Lean’s elimination rules.

A proof term for a familiar inference

Given \(h:P\wedge Q\), its left and right fields have types \(P\) and \(Q\), respectively. The conjunction constructor checks these inputs in the reversed order because its expected result has type \(Q\wedge P\).

theorem swap_and (P Q : Prop) (h : P ∧ Q) : Q ∧ P :=
  And.intro h.right h.left

Tactics may build the same term indirectly by turning the original goal into two subgoals. Elaboration resolves notation, implicit arguments and typeclass instances, and the kernel checks the resulting proof term. This is the key connection to proof theory. A successful search tactic must yield a derivation in the underlying system.

Working with Mathlib and auditing assumptions

Mathlib provides definitions and lemmas that need to compose across files. A formalization of the first isomorphism theorem, for example, should use the library’s group homomorphism, subgroup and quotient structures so it can reuse the established interfaces. Reviewers can inspect the statement’s types and hypotheses and ask Lean to report which axioms a theorem uses. A type check verifies the precise formal statement. Matching the statement and its assumptions to the mathematical claim remains a separate part of review, especially when classical choice or additional principles used in foundational theories matter.[1][2]

References

  1. Jeremy Avigad, Leonardo de Moura, Soonho Kong and Sebastian Ullrich, Theorem Proving in Lean 4 ↩
  2. The Mathlib Community, The Lean Mathematical Library ↩