Edge Case Stress Tests #
This file tests boundary conditions, singularities, and "tricky" mathematical scenarios to ensure the library behaves safely (soundly) even when exact answers are impossible.
1. The "Division by Zero" Singularity #
The interval evaluator evalIntervalCoreWithDiv has a fallback for intervals containing 0.
It should return a massive safe interval rather than crashing or proving False.
Equations
- LeanCert.Examples.EdgeCases.I_cross_zero = { lo := -1, hi := 1, le := LeanCert.Examples.EdgeCases.I_cross_zero._proof_1 }
Instances For
2. The "Square Root of Negative" Edge Case #
Mathlib defines Real.sqrt x = 0 for x < 0. LeanCert's interval arithmetic
must respect this convention to remain sound with respect to the standard library.
Equations
- LeanCert.Examples.EdgeCases.I_negative = { lo := -5, hi := -1, le := LeanCert.Examples.EdgeCases.I_negative._proof_1 }
Instances For
Equations
Instances For
Equations
Instances For
Equations
- LeanCert.Examples.EdgeCases.I_mixed = { lo := -1, hi := 4, le := LeanCert.Examples.EdgeCases.I_mixed._proof_1 }
Instances For
3. Root Finding: Tangential Roots (Multiplicity > 1) #
Bisection relies on sign change (IVT). It works for crossings (x³) but fails for touching roots (x²). This test confirms the library handles "no sign change" correctly.
NOTE: Interval arithmetic overestimates: [-1, 1] * [-1, 1] = [-1, 1], not [0, 1]. So x² on [-1, 1] gives interval [-1, 1], which includes negative values. This is sound (conservative) but not tight.
Equations
Instances For
Equations
Instances For
Equations
- LeanCert.Examples.EdgeCases.I_positive = { lo := 0, hi := 1, le := LeanCert.Examples.EdgeCases.I_positive._proof_1 }
Instances For
Equations
Instances For
Equations
Instances For
4. The "Sinc" Singularity at 0 #
sin(x)/x has a removable singularity at 0.
Expr.div (sin x) x will give wide bounds at 0, but Expr.sinc x is safe.
NOTE: sinc is not in ExprSupportedCore, so we test using ExprSupportedWithInv or direct evaluation.
Equations
Instances For
Equations
Instances For
5. Precision Stress Test (Deep Polynomial) #
Deep composition of polynomials causes rational denominators to explode in size. We test if the evaluator can handle depths that might choke naive implementations.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- LeanCert.Examples.EdgeCases.I_half_one = { lo := 1 / 2, hi := 1, le := LeanCert.Examples.EdgeCases.I_half_one._proof_1 }
Instances For
6. The "Wiggle" Function #
Test a function with oscillating behavior: x · sin(10x) on [0.1, 1].
Equations
Instances For
Equations
Instances For
Equations
- LeanCert.Examples.EdgeCases.I_wiggle = { lo := 1 / 10, hi := 1, le := LeanCert.Examples.EdgeCases.I_wiggle._proof_1 }
Instances For
7. Type Safety of IntervalRat #
The IntervalRat structure requires lo ≤ hi as a field, so invalid intervals
cannot be constructed. This is proven by the type system itself.
8. Zero-Dimensional Evaluation #
Evaluating a constant expression (0 variables) on an empty domain.
Instances For
Equations
Instances For
Equations
- LeanCert.Examples.EdgeCases.I_any = { lo := 0, hi := 1, le := LeanCert.Examples.EdgeCases.I_positive._proof_1 }
Instances For
9. Dyadic Interval Evaluation #
Test the dyadic (floating-point style) evaluator for performance comparison.
Equations
- LeanCert.Examples.EdgeCases.I_unit_dyadic = { lo := { mantissa := 0, exponent := 0 }, hi := { mantissa := 1, exponent := 0 }, le := LeanCert.Examples.EdgeCases.I_unit_dyadic._proof_1 }