Documentation

LeanCert.Examples.EdgeCases

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.

theorem LeanCert.Examples.EdgeCases.inv_zero_safe :
have result := Engine.evalIntervalCoreWithDiv (Core.Expr.var 0).inv fun (x : ) => I_cross_zero; result.lo -1000000 1000000 result.hi

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.

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.

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.

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

    6. The "Wiggle" Function #

    Test a function with oscillating behavior: x · sin(10x) on [0.1, 1].

    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.

    9. Dyadic Interval Evaluation #

    Test the dyadic (floating-point style) evaluator for performance comparison.

    Equations
    Instances For

      10. Global Optimization Edge Cases #