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:
x - xwithx ∈ [-1, 1]gives[-2, 2]instead of[0, 0]
Affine arithmetic solves this by representing values as:
x̂ = c₀ + Σᵢ cᵢ·εᵢ + [-r, r]
where εᵢ ∈ [-1, 1] are noise symbols tracking input correlations.
Main definitions #
AffineForm- Affine representation: central value + linear terms + errorAffineForm.add,sub,neg,scale- Linear operations (exact)AffineForm.mul- Multiplication (introduces error)AffineForm.toInterval- Convert back to interval bounds
Key Properties #
sub_self_c0- x - x has central value 0sub_self_radius_zero- For input forms (r=0), x - x has radius 0
References #
- Stolfi & de Figueiredo, "Self-Validated Numerical Methods and Applications"
Helper Lemmas #
The Affine Form Data Structure #
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- LeanCert.Engine.Affine.AffineForm.const q = { c0 := q, coeffs := [], r := 0, r_nonneg := LeanCert.Engine.Affine.AffineForm.const._proof_1 }
Instances For
Helper Functions #
Equations
- LeanCert.Engine.Affine.AffineForm.sumAbs l = List.foldl (fun (acc c : ℚ) => acc + |c|) 0 l
Instances For
Equations
Instances For
Equations
- LeanCert.Engine.Affine.AffineForm.zipWithPad f [] [] = []
- LeanCert.Engine.Affine.AffineForm.zipWithPad f [] (h :: t) = f 0 h :: LeanCert.Engine.Affine.AffineForm.zipWithPad f [] t
- LeanCert.Engine.Affine.AffineForm.zipWithPad f (h :: t) [] = f h 0 :: LeanCert.Engine.Affine.AffineForm.zipWithPad f t []
- LeanCert.Engine.Affine.AffineForm.zipWithPad f (h1 :: t1) (h2 :: t2) = f h1 h2 :: LeanCert.Engine.Affine.AffineForm.zipWithPad f t1 t2
Instances For
Linear Operations (Exact) #
Equations
Instances For
Equations
Instances For
Instances For
Equations
Instances For
Non-Linear Operations #
Equations
- One or more equations did not get rendered due to their size.
Instances For
Interval Conversion #
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- af.toInterval = { lo := af.c0 - af.deviationBound, hi := af.c0 + af.deviationBound, le := ⋯ }
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 #
Instances For
Equations
- LeanCert.Engine.Affine.AffineForm.validNoise eps = ∀ e ∈ eps, -1 ≤ e ∧ e ≤ 1
Instances For
The linear functional Σ cᵢ * εᵢ
Equations
- LeanCert.Engine.Affine.AffineForm.linearSum coeffs eps = (List.zipWith (fun (c : ℚ) (e : ℝ) => ↑c * e) coeffs eps).sum
Instances For
Equations
- af.evalLinear eps = ↑af.c0 + LeanCert.Engine.Affine.AffineForm.linearSum af.coeffs eps
Instances For
Instances For
Helper lemmas for soundness #
Soundness Proofs #
Constants are sound: const q represents q
Scalar multiplication is sound
Addition is sound
Negation is sound
Subtraction is sound
Bounding the linear sum #
Multiplication Soundness Infrastructure #
Multiplication is sound
Squaring is sound: if v is represented by a, then v*v is represented by sq a
If v is represented by af, then v ∈ toInterval af
If v is represented by af, then v ∈ toInterval af (no length assumption).
If x is inside an interval, the midpoint/radius affine form contains x.