Verified Numerical Integration #
This file implements numerical integration with rigorous error bounds. Given an expression and an interval, we compute an interval guaranteed to contain the definite integral.
Main definitions #
integrateInterval- Compute bounds on ∫_a^b f(x) dxintegrateInterval_correct_n1- Correctness theorem for n=1 (FULLY PROVED)
Algorithm #
We use uniform partitioning with interval evaluation:
- Partition [a, b] into n subintervals
- On each subinterval, bound f using interval arithmetic
- Sum the bounds: ∫ ≤ Σ (width * upper_bound)
Verification status #
The integrateInterval_correct_n1 theorem is fully proved for ExprSupported expressions.
This demonstrates the end-to-end verification pipeline.
Auxiliary lemmas for integration bounds #
If lo ≤ f(x) ≤ hi for all x ∈ [a, b], then lo * (b - a) ≤ ∫_a^b f ≤ hi * (b - a). This is the fundamental lemma for bounding integrals.
Uniform partition integration #
Partition an interval into n equal parts
Equations
Instances For
Sum of interval bounds over a partition
Equations
- One or more equations did not get rendered due to their size.
Instances For
Compute interval bounds on ∫_a^b f(x) dx using uniform partitioning
Equations
Instances For
Integration correctness for n = 1 #
For single-interval integration (n=1), we can compute the result directly.
Equations
Instances For
The single-interval integration is contained in the general integration for n=1
The single-interval correctness theorem. This is FULLY PROVED - no sorry, no axioms.
Adding zero on the left preserves interval membership
Correctness for n = 1 (single interval, no partition). This is FULLY PROVED - no sorry, no axioms.
Integration correctness for general n #
The real sequence of partition points for uniform partition. x_i = I.lo + (I.hi - I.lo) * i / n
Instances For
x_0 = I.lo
x_n = I.hi
The partition points are monotone
The i-th subinterval of the uniform partition
Equations
- LeanCert.Engine.partitionInterval I n hn k hk = (LeanCert.Engine.uniformPartition I n hn).get ⟨k, ⋯⟩
Instances For
Partition points match partition interval bounds (real version)
Integrability on a subinterval
Integrability using partition points
The integral decomposes over the partition
Summing interval bounds over partitions #
Each subinterval integral is bounded by integrateInterval1 on that subinterval
IntervalRat.add is associative
Helper: foldl add distributes: foldl (acc.add I) Is = acc.add (foldl I Is)
Adding singleton 0 on the left is identity
Adding singleton 0 on the right is identity
Helper: generalized foldl lemma relating sumIntervalBounds-style fold with add fold
sumIntervalBounds equals foldl over mapped integrateInterval1
Main theorem: the integral lies in integrateInterval for general n
Adaptive integration #
Interval operations for error estimation #
Interval intersection (returns the tighter bound). If intervals don't overlap, returns the first one (conservative).
Equations
Instances For
Intersection is sound: if x ∈ I and x ∈ J, then x ∈ inter I J
Union of intervals (convex hull)
Instances For
Union is sound: if x ∈ I then x ∈ union I J
Union is sound: if x ∈ J then x ∈ union I J
Splitting intervals #
Midpoint definition helper
Midpoint is at least lo
Midpoint is at most hi
Split an interval at its midpoint
Equations
Instances For
The left half of a split covers [lo, mid]
The right half of a split covers [mid, hi]
Splitting preserves coverage: any x in I is in one of the halves
Adaptive integration result and algorithm #
Adaptive integration result
- bound : Core.IntervalRat
Interval containing the integral
- evals : ℕ
Number of function evaluations used
Instances For
Compute integration bound for a single interval using n=2 panels
Equations
Instances For
Compute integration bound for a single interval using n=1 panel (coarse)
Equations
Instances For
Error estimate: width of the refined bound (Conservative: could use intersection, but width of refined is simpler)
Equations
- LeanCert.Engine.errorEstimate refined = refined.width
Instances For
Recursive adaptive integration. At each level, computes refined bound and either:
- Returns if error ≤ tol or maxDepth = 0
- Subdivides and recurses
Equations
- One or more equations did not get rendered due to their size.
- LeanCert.Engine.integrateAdaptiveAux e I tol 0 = { bound := LeanCert.Engine.integrateRefined e I, evals := 2 }
Instances For
Adaptive integration with error tolerance.
Keeps subdividing until the uncertainty is below tol.
Equations
- LeanCert.Engine.integrateAdaptive e I tol _htol maxDepth = LeanCert.Engine.integrateAdaptiveAux e I tol maxDepth
Instances For
Correctness proofs for adaptive integration #
integrateRefined is correct (direct from integrateInterval_correct)
integrateCoarse is correct
Helper: midpoint is between lo and hi (real version)
Midpoint is in the interval
Helper: integral over split interval equals sum of integrals over halves
Integrability on left half
Integrability on right half
Main soundness theorem: adaptive integration returns a bound containing the true integral. This is proved by induction on maxDepth.
Soundness of the main adaptive integration function
Non-uniform (geometric) partitioning #
Build geometric breakpoints from start, growing by ratio each step.
Returns list of breakpoints (not intervals). Stops at stop or after maxN steps.
Equations
- LeanCert.Engine.geometricBreakpoints start stop w₀ ratio maxN = (LeanCert.Engine.geometricBreakpoints.go stop ratio start w₀ maxN []).reverse
Instances For
Build a non-uniform partition: geometric near both edges, uniform in the middle.
Returns List IntervalRat. Intervals with lo ≥ hi are dropped.
Equations
- One or more equations did not get rendered due to their size.