Documentation

LeanCert.Engine.Affine.Basic

Affine Arithmetic #

This file implements Affine Arithmetic (AA), which tracks linear dependencies between variables to avoid the "dependency problem" in interval arithmetic.

The Dependency Problem #

Standard interval arithmetic treats each occurrence of a variable independently:

Affine arithmetic solves this by representing values as: x̂ = c₀ + Σᵢ cᵢ·εᵢ + [-r, r]

where εᵢ ∈ [-1, 1] are noise symbols tracking input correlations.

Main definitions #

Key Properties #

References #

Helper Lemmas #

The Affine Form Data Structure #

Affine Form: c₀ + Σᵢ (coeffs[i] * εᵢ) + [-r, r]

where εᵢ ∈ [-1, 1] are independent noise symbols.

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

      Helper Functions #

      Linear Operations (Exact) #

      Equations
      Instances For
        Equations
        Instances For
          Equations
          Instances For

            Non-Linear Operations #

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

                Interval Conversion #

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

                    The Key Property: x - x = 0 #

                    The central value of x - x is exactly 0

                    For an input affine form (r = 0), x - x has zero radius

                    Subtraction of the same form gives all-zero coefficients

                    Soundness Infrastructure #

                    The linear functional Σ cᵢ * εᵢ

                    Equations
                    Instances For
                      Equations
                      Instances For

                        Helper lemmas for soundness #

                        Soundness Proofs #

                        Constants are sound: const q represents q

                        theorem LeanCert.Engine.Affine.AffineForm.mem_scale (q : ) {a : AffineForm} {eps : NoiseAssignment} {v : } (hmem : a.mem_affine eps v) :
                        (scale q a).mem_affine eps (q * v)

                        Scalar multiplication is sound

                        theorem LeanCert.Engine.Affine.AffineForm.mem_add {a b : AffineForm} {eps : NoiseAssignment} {va vb : } (ha : a.mem_affine eps va) (hb : b.mem_affine eps vb) :
                        (a.add b).mem_affine eps (va + vb)

                        Addition is sound

                        theorem LeanCert.Engine.Affine.AffineForm.mem_neg {a : AffineForm} {eps : NoiseAssignment} {va : } (ha : a.mem_affine eps va) :
                        a.neg.mem_affine eps (-va)

                        Negation is sound

                        theorem LeanCert.Engine.Affine.AffineForm.mem_sub {a b : AffineForm} {eps : NoiseAssignment} {va vb : } (ha : a.mem_affine eps va) (hb : b.mem_affine eps vb) :
                        (a.sub b).mem_affine eps (va - vb)

                        Subtraction is sound

                        Bounding the linear sum #

                        Multiplication Soundness Infrastructure #

                        theorem LeanCert.Engine.Affine.AffineForm.mem_mul {a b : AffineForm} {eps : NoiseAssignment} {va vb : } (hvalid : validNoise eps) (ha : a.mem_affine eps va) (hb : b.mem_affine eps vb) :
                        (a.mul b).mem_affine eps (va * vb)

                        Multiplication is sound

                        theorem LeanCert.Engine.Affine.AffineForm.mem_sq {a : AffineForm} {eps : NoiseAssignment} {v : } (hvalid : validNoise eps) (hmem : a.mem_affine eps v) :
                        a.sq.mem_affine eps (v * v)

                        Squaring is sound: if v is represented by a, then v*v is represented by sq a

                        theorem LeanCert.Engine.Affine.AffineForm.mem_toInterval {af : AffineForm} {eps : NoiseAssignment} {v : } (hvalid : validNoise eps) (hlen : List.length eps = af.coeffs.length) (hmem : af.mem_affine eps v) :

                        If v is represented by af, then v ∈ toInterval af

                        If v is represented by af, then v ∈ toInterval af (no length assumption).

                        theorem LeanCert.Engine.Affine.AffineForm.mem_affine_of_interval {I : Core.IntervalRat} {eps : NoiseAssignment} {x : } (hx : x I) :
                        { c0 := (I.lo + I.hi) / 2, coeffs := [], r := |(I.hi - I.lo) / 2|, r_nonneg := }.mem_affine eps x

                        If x is inside an interval, the midpoint/radius affine form contains x.