LeanCert Showcase #
Demonstrations of verified numerical computation in Lean 4.
What This Library Does #
LeanCert proves facts about real-valued functions using interval arithmetic. The key idea: compute with rational intervals, get proofs about reals.
Highlights #
- Transcendental bounds: exp, sin, cos with Taylor model error bounds
- Root existence: Prove √2 exists via sign change
- Root absence: Prove functions stay away from zero
- Composition: Combine operations freely
The Golden Theorem Pattern #
Each verified result follows this pattern:
- Build an
Expr(expression AST) or use raw Lean syntax - Run interval evaluation → get rational bounds
- Use
native_decideto check the bound - Golden theorem lifts to a proof about reals
Intervals #
Equations
- LeanCert.Examples.Showcase.I01 = { lo := 0, hi := 1, le := LeanCert.Examples.Showcase.I01._proof_1 }
Instances For
Equations
- LeanCert.Examples.Showcase.I_sym = { lo := -1, hi := 1, le := LeanCert.Examples.Showcase.I_sym._proof_1 }
Instances For
Section 1: Basic Polynomial Bounds #
Simple examples showing interval_bound on polynomials.
Section 2: Transcendental Functions #
exp, sin, cos with verified Taylor series bounds.
Section 3: Combined Expressions #
Mixing polynomials with transcendentals.
x² - 2 < 0 on [0, 1] (since √2 > 1)
Section 4: Root Absence #
Prove functions have no roots by showing they stay strictly positive/negative.
x² + 1 ≠ 0 on [0, 1] (always positive)
exp(x) ≠ 0 on [0, 1] (always positive)
x + 2 ≠ 0 on [0, 1] (always positive)
x² - 2 ≠ 0 on [0, 1] (√2 ≈ 1.41 is outside [0,1])
Section 5: Root Existence #
Prove roots exist via sign change (Intermediate Value Theorem).
Equations
- LeanCert.Examples.Showcase.I12 = { lo := 1, hi := 2, le := LeanCert.Examples.Showcase.I12._proof_1 }
Instances For
√2 exists: there is an x ∈ [1, 2] with x² = 2
π/2 exists: there is an x ∈ [1, 2] with cos(x) = 0
ln(2) exists: there is an x ∈ [0, 1] with exp(x) = 2
Why This Matters #
- Verified: Every bound is machine-checked by Lean's kernel
- Computational: Bounds computed at compile time via
native_decide - Composable: Build complex proofs from simple pieces
- Automated: Tactics handle boilerplate
The library automates numerical verification where symbolic methods are tedious.