Documentation

LeanCert.Engine.Affine.Nonlinear

Affine Arithmetic: Non-Linear Operations #

This file extends Affine Arithmetic with division and square root.

Key Insight #

For non-linear functions f(x), we use the Chebyshev linearization:

  1. Find the best linear approximation L(x) = α·x + β over the interval
  2. Compute the maximum approximation error δ = max|f(x) - L(x)|
  3. Result: α·â + β + [-δ, δ] where â is the affine input

This is sound because for any x ∈ [lo, hi]: f(x) ∈ L(x) + [-δ, δ] = α·x + β + [-δ, δ]

Main definitions #

Inversion (1/x) #

Conservative inversion for affine forms.

For positive intervals [lo, hi]:

  • Linear approx: L(x) = -1/(lo·hi)·x + (lo+hi)/(lo·hi)
  • Max error at endpoints and midpoint

We use a simpler approach: convert to interval, invert, convert back. This loses correlation but is always sound.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Chebyshev linearization for 1/x on [lo, hi] with 0 < lo.

    The optimal linear approximation minimizes max error. For 1/x, the Chebyshev approximation is: L(x) = -1/(lo·hi)·x + (lo+hi)/(lo·hi) with error bounded by (√hi - √lo)² / (2·lo·hi)

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Square Root #

      Square root using Chebyshev linearization.

      For √x on [lo, hi] with 0 ≤ lo:

      • Optimal linear: L(x) = x/(√lo + √hi) + √(lo·hi)/(√lo + √hi)
      • Error: (√hi - √lo)² / 4

      Simplified approach: use interval sqrt, convert back.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Chebyshev linearization for √x on [lo, hi].

        Optimal approximation: L(x) = x/(2·√m) + √m/2 where m = (lo + hi)/2 is the midpoint. Error ≤ (√hi - √lo)²/4

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Division #

          Division: a / b = a · (1/b)

          Equations
          Instances For

            Division with Chebyshev linearization for the inverse

            Equations
            Instances For

              Power Operations #

              @[irreducible]

              Natural number power

              Equations
              Instances For

                Soundness (Placeholder) #

                theorem LeanCert.Engine.Affine.AffineForm.mem_inv {a : AffineForm} {eps : NoiseAssignment} {v : } (hvalid : validNoise eps) (hlen : List.length eps = a.coeffs.length) (hmem : a.mem_affine eps v) (_hv_pos : 0 < v) (hI_pos : 0 < a.toInterval.lo) :
                a.inv.mem_affine eps (1 / v)

                Inversion is sound when interval is positive

                theorem LeanCert.Engine.Affine.AffineForm.mem_sqrt {a : AffineForm} {eps : NoiseAssignment} {v : } (hvalid : validNoise eps) (hlen : List.length eps = a.coeffs.length) (hmem : a.mem_affine eps v) (hv_nonneg : 0 v) :

                Square root is sound for non-negative inputs

                theorem LeanCert.Engine.Affine.AffineForm.mem_sqrt' {a : AffineForm} {eps : NoiseAssignment} {v : } (hvalid : validNoise eps) (hmem : a.mem_affine eps v) :

                Square root is sound without a nonnegativity hypothesis.