Integration Certificates #
This module provides certificate-driven verification for definite integrals using interval arithmetic with both computable (Core) and noncomputable (Checked) evaluation.
Main definitions #
Computable Integration (Core) #
uniformPartitionCore- Computable uniform partitionintegrateInterval1Core- Single-interval integrationintegrateIntervalCore- Multi-partition integrationcheckIntegralBoundsCore- Boolean checker for integral boundsverify_integral_bound- Golden theorem for integration bounds
Integration with Inverse Support (Checked) #
integrateInterval1Checked- Single-interval integration with inv/log supportintegratePartitionChecked- Partitioned integration with inv/log supportcollectBoundsChecked- Collect bounds over partition
Adaptive Integration #
AdaptiveResultChecked- Result structure for adaptive integrationintegrateAdaptiveChecked- Adaptive integration with error tolerancecheckIntegralAdaptiveLowerBound- Boolean checker for adaptive lower boundscheckIntegralAdaptiveUpperBound- Boolean checker for adaptive upper bounds
Exponential Search #
searchPartitionLower- Find minimum partitions for lower boundsearchPartitionUpper- Find minimum partitions for upper boundsearchPartitionLowerCandidate/searchPartitionUpperCandidate- retained untrusted search results with partition counts and enclosurescheckIntegralPartitionLowerBound/checkIntegralPartitionUpperBound- fixed-candidate certificate checkers
Computable Integration Infrastructure #
For the checked integral engine, we need:
- A computable integration function using
LeanCert.Internal.Rational.evalTotalCore1 - A theorem that
ExprSupportedCoreimpliesIntervalIntegrable - A verification theorem linking the computation to the real integral
Computable uniform partition using LeanCert.Internal.Rational.evalTotalCore1
Equations
Instances For
Sum of interval bounds over a partition using computable LeanCert.Internal.Rational.evalTotalCore1
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable interval bounds on ∫_a^b f(x) dx using uniform partitioning
Equations
Instances For
For single-interval integration (n=1), computable version
Equations
Instances For
IntervalIntegrable from ExprSupportedCore #
All ExprSupportedCore expressions are continuous, hence integrable on compact intervals.
All ExprSupportedCore expressions are interval integrable on any compact interval.
This follows because ExprSupportedCore expressions are continuous (see exprSupportedCore_continuousOn), and continuous functions on compact intervals are integrable.
Note: Requires domain validity for expressions with log.
Correctness of Computable Integration #
Single-interval integration correctness for ExprSupportedCore.
This is proved directly using the same structure as integrateInterval1_correct but with the computable LeanCert.Internal.Rational.evalTotalCore1 instead of noncomputable LeanCert.Internal.Rational.evalUnchecked1.
The hdom hypothesis ensures evaluation domain validity (e.g., log arguments have positive interval bounds).
The hcontdom hypothesis ensures continuity domain validity (e.g., log arguments are positive on the set).
Check if the integral bound contains a given rational value. Returns true if domain is valid and the computed integral bound contains the target value.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Golden Theorem for Integration Bounds
If checkIntegralBoundsCore e I target cfg = true, then the integral is bounded by the
computed interval.
Note: The target parameter and h_cert hypothesis are used for the native_decide workflow
where we verify at compile time that target is in the computed interval. The actual proof
of interval membership uses integrateInterval1Core_correct directly.
This theorem allows proving statements like "∫_a^b f(x) dx ∈ [lo, hi]".
Note: Requires continuity domain validity for expressions with log.
Extract the computed integral bound as an interval
Equations
Instances For
The integral lies within the computed bound (computable version)
Note: Requires continuity domain validity for expressions with log.
Single-interval integration for arbitrary expressions #
Computable single-interval integration using evalInterval?1.
Returns none if interval evaluation fails (e.g., log domain invalid).
Equations
- LeanCert.Validity.Integration.integrateInterval1Checked e I = match LeanCert.Engine.evalInterval?1 e I with | some J => some ((LeanCert.Core.IntervalRat.singleton I.width).mul J) | none => none
Instances For
Single-interval integration correctness for arbitrary expressions. Requires that evalInterval?1 succeeds on the interval.
Check if the computed integration bound contains a target value. Returns false if interval evaluation fails.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Golden Theorem for Integration Bounds (Checked)
If checkIntegralBoundsChecked e I target = true, then the integral lies in the
computed bound. The target parameter is for the native_decide workflow.
Partitioned integration for arbitrary expressions #
Collect per-subinterval bounds using evalInterval?1.
Returns none if any subinterval fails.
Equations
Instances For
Sum bounds over a uniform partition using evalInterval?1.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Adaptive Integration for arbitrary expressions #
Adaptive integration concentrates partitions where the error is high (near singularities), dramatically reducing the number of function evaluations compared to uniform partitioning.
The algorithm:
- Compute a refined bound (n=2) on the current interval
- If error (width of bound) is below tolerance, return
- Otherwise, split at midpoint and recurse with half tolerance
- Sum the bounds from sub-intervals
This naturally concentrates partitions near singularities where the function varies rapidly.
Result of adaptive integration with inverse support
- bound : Core.IntervalRat
Interval containing the integral
- partitions : ℕ
Number of subintervals used
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Error estimate for adaptive integration: width of the refined bound
Equations
Instances For
Compute a refined bound (n=2) on a single interval using Checked support.
Returns none if evaluation fails (domain issues).
Equations
Instances For
Recursive adaptive integration with inverse support. 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.
Instances For
Adaptive integration with inverse support and error tolerance.
Keeps subdividing until the uncertainty is below tol.
Equations
- LeanCert.Validity.Integration.integrateAdaptiveChecked e I tol maxDepth = LeanCert.Validity.Integration.integrateAdaptiveAuxChecked e I tol maxDepth
Instances For
Correctness proofs for adaptive integration with inverse support #
integrateRefinedChecked is correct (direct from integratePartitionChecked_correct)
Integrability on left half after midpoint split
Integrability on right half after midpoint split
Integral over split interval equals sum of integrals over halves
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 with inverse support
Adaptive integral bound checkers for native_decide #
Boolean checker for adaptive integral lower bounds. More efficient than uniform partitioning for functions with singularities.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Boolean checker for adaptive integral upper bounds. More efficient than uniform partitioning for functions with singularities.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Bridge theorem: if checkIntegralAdaptiveLowerBound returns true, the integral is ≥ c.
Bridge theorem: if checkIntegralAdaptiveUpperBound returns true, the integral is ≤ c.
Exponential Search for Optimal Partition Count #
Instead of using a fixed large N or deep adaptive recursion, we can search for the minimum partition count that achieves the desired bound. This is often much faster because many integrals only need N=100-500 instead of N=3000.
Algorithm:
- Start with N=startN (e.g., 32)
- Double N until the bound is achieved (exponential search)
- Return the first N that works
This finds the optimal N in O(log(N)) integration attempts.
Retained result of the untrusted exponential partition search. The selected partition count is certified separately by a fixed-candidate checker, so the search itself never needs to be executed by the verifier.
- success (partitions : ℕ) (enclosure : Core.IntervalRat) (attempts : ℕ) : IntegralPartitionSearchResult
- exhausted (lastPartitions : Option ℕ) (lastEnclosure : Option Core.IntervalRat) (attempts : ℕ) : IntegralPartitionSearchResult
- domainObstruction (partitions attempts : ℕ) : IntegralPartitionSearchResult
- invalidStart : IntegralPartitionSearchResult
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Structured exponential search for a lower integral bound. This function
is candidate generation only; soundness comes from
checkIntegralPartitionLowerBound below.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Structured exponential search for an upper integral bound.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- LeanCert.Validity.Integration.searchPartitionLowerCandidate e I startN maxN c = LeanCert.Validity.Integration.searchPartitionLowerCandidateAux e I startN maxN c 20 0
Instances For
Equations
- LeanCert.Validity.Integration.searchPartitionUpperCandidate e I startN maxN c = LeanCert.Validity.Integration.searchPartitionUpperCandidateAux e I startN maxN c 20 0
Instances For
Fixed-candidate checker for an integral lower bound.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Fixed-candidate checker for an integral upper bound.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Golden theorem for a retained lower-bound partition candidate.
Golden theorem for a retained upper-bound partition candidate.
Exponential search with explicit fuel for termination.
Returns the computed bound if found within fuel doublings, or none otherwise.
Equations
- One or more equations did not get rendered due to their size.
- LeanCert.Validity.Integration.searchPartitionLowerAux e I n maxN c 0 = none
Instances For
Exponential search for minimum partition count that achieves a lower bound.
Equations
- LeanCert.Validity.Integration.searchPartitionLower e I startN maxN c = LeanCert.Validity.Integration.searchPartitionLowerAux e I startN maxN c 20
Instances For
Exponential search with explicit fuel for upper bounds.
Equations
- One or more equations did not get rendered due to their size.
- LeanCert.Validity.Integration.searchPartitionUpperAux e I n maxN c 0 = none
Instances For
Exponential search for minimum partition count that achieves an upper bound.
Equations
- LeanCert.Validity.Integration.searchPartitionUpper e I startN maxN c = LeanCert.Validity.Integration.searchPartitionUpperAux e I startN maxN c 20
Instances For
Check lower bound using exponential search to find optimal N. Much faster than fixed large N when fewer partitions suffice. startN: initial partition count (e.g., 32) maxN: maximum partitions to try (e.g., 8192)
Equations
- LeanCert.Validity.Integration.checkIntegralSearchLowerBound e I startN maxN c = (LeanCert.Validity.Integration.searchPartitionLower e I startN maxN c).isSome
Instances For
Check upper bound using exponential search to find optimal N.
Equations
- LeanCert.Validity.Integration.checkIntegralSearchUpperBound e I startN maxN c = (LeanCert.Validity.Integration.searchPartitionUpper e I startN maxN c).isSome
Instances For
Helper: if searchPartitionLowerAux succeeds, the result satisfies the bound.
Helper: if searchPartitionUpperAux succeeds, the result satisfies the bound.
Helper: searchPartitionLowerAux returns a valid integration bound.
Helper: searchPartitionUpperAux returns a valid integration bound.
Bridge theorem: if exponential search succeeds, the integral satisfies the lower bound.
Bridge theorem: if exponential search succeeds, the integral satisfies the upper bound.