Documentation

LeanCert.Engine.TaylorModel.Core

Taylor Models - Core Definitions #

This file contains the core Taylor model abstraction, polynomial helpers, and basic operations with their correctness proofs.

Main definitions #

Design notes #

A Taylor model for f on interval I centered at c is: TM(f) = (P, R) where ∀x ∈ I, f(x) ∈ P(x-c) + R

Operations on Taylor models (add, mul, compose) preserve this property.

Polynomial helpers for Taylor models #

noncomputable def LeanCert.Engine.truncPoly (p : Polynomial ) (n : ) :

Truncate a polynomial to terms of degree ≤ n by summing coefficients

Equations
Instances For
    noncomputable def LeanCert.Engine.tailPoly (p : Polynomial ) (n : ) :

    The tail of a polynomial (terms with degree > n)

    Equations
    Instances For
      noncomputable def LeanCert.Engine.boundPolyAbs (p : Polynomial ) (domain : Core.IntervalRat) (c : ) :

      Bound a polynomial over an interval centered at c. Evaluates at shifted argument: P(x - c) for x ∈ domain.

      We bound each term: |aᵢ (x-c)ⁱ| ≤ |aᵢ| * r^i where r = radius of domain from c. Then the total bound is ∑ᵢ |aᵢ| * rⁱ

      Equations
      Instances For

        The bound computed by boundPolyAbs is nonnegative

        noncomputable def LeanCert.Engine.boundTail (p : Polynomial ) (d : ) (domain : Core.IntervalRat) (c : ) :

        Bound the tail of polynomial p (terms with degree > d) when evaluated at (x-c) for x ∈ domain.

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

          Taylor Model structure #

          A Taylor model: polynomial approximation with remainder interval.

          Instances For

            The set of real values this Taylor model can take at point x

            Equations
            Instances For

              Evaluate polynomial part at a point

              Equations
              Instances For

                Interval bound for the polynomial part over the domain.

                Equations
                Instances For

                  Get bounds on the Taylor model over its domain: polynomial bound + remainder

                  Equations
                  Instances For
                    theorem LeanCert.Engine.TaylorModel.valueAtCenter_correct (tm : TaylorModel) (f : ) (hf : xtm.domain, f x tm.evalSet x) (hc : tm.center tm.domain) :

                    Correctness: the true function value at center is in valueAtCenterInterval.

                    Taylor model operations #

                    Constant Taylor model

                    Equations
                    Instances For

                      Identity Taylor model: represents the function x ↦ x

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

                        Add two Taylor models

                        Equations
                        Instances For

                          Negate a Taylor model

                          Equations
                          Instances For

                            Subtract Taylor models

                            Equations
                            Instances For

                              Invert a Taylor model, assuming its bound does not contain 0.

                              Equations
                              Instances For
                                noncomputable def LeanCert.Engine.TaylorModel.mul (tm1 tm2 : TaylorModel) (maxDegree : ) :

                                Multiply Taylor models with truncation and proper remainder handling.

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

                                  Core Correctness Theorems #

                                  Key lemma: polynomial evaluation is bounded by polyBoundInterval.

                                  theorem LeanCert.Engine.taylorModel_correct (tm : TaylorModel) (f : ) (hf : xtm.domain, f x tm.evalSet x) (x : ) :
                                  x tm.domainf x tm.bound

                                  Taylor model bounds are correct: if f(x) ∈ evalSet for all x in domain, then f(x) ∈ bound for all x in domain.

                                  Local evalSet correctness lemmas #

                                  theorem LeanCert.Engine.TaylorModel.const_evalSet_correct (q : ) (domain : Core.IntervalRat) (x : ) :
                                  x domainq (const q domain).evalSet x

                                  Constant TM correctness for evalSet: q ∈ const(q).evalSet x.

                                  Identity TM correctness for evalSet: x ∈ identity.evalSet x.

                                  Negation preserves evalSet membership.

                                  Convenience: any evalPoly x + r with r ∈ remainder lies in evalSet.

                                  theorem LeanCert.Engine.TaylorModel.add_evalSet_of_mem {tm1 tm2 : TaylorModel} {x : } (hcenter : tm1.center = tm2.center) {v1 v2 : } (hv1 : v1 tm1.evalSet x) (hv2 : v2 tm2.evalSet x) :
                                  v1 + v2 (tm1.add tm2).evalSet x

                                  Addition preserves evalSet membership when centers match.

                                  Polynomial helper lemmas for multiplication #

                                  truncPoly + tailPoly = original polynomial

                                  aeval distributes over truncPoly + tailPoly

                                  theorem LeanCert.Engine.tailPoly_eval_bounded (p : Polynomial ) (n : ) (domain : Core.IntervalRat) (c : ) (x : ) (hx : x domain) :
                                  |(Polynomial.aeval (x - c)) (tailPoly p n)| (boundPolyAbs (tailPoly p n) domain c)

                                  Tail polynomial evaluation is bounded by boundPolyAbs of tail.

                                  theorem LeanCert.Engine.poly_eval_bounded (p : Polynomial ) (domain : Core.IntervalRat) (c : ) (x : ) (hx : x domain) :
                                  |(Polynomial.aeval (x - c)) p| (boundPolyAbs p domain c)

                                  Polynomial bound lemma: |P(y)| ≤ boundPolyAbs P domain c for y = x - c, x ∈ domain

                                  theorem LeanCert.Engine.mem_symmetric_interval_of_abs_le {x : } {B : } (hB : 0 B) (h : |x| B) :
                                  x { lo := -B, hi := B, le := }

                                  Value in symmetric interval from absolute bound

                                  Generic Taylor model algebra lemmas #

                                  These lemmas are pure TM algebra that don't depend on Expr or transcendentals.

                                  If x ∈ bound and bound doesn't contain zero, then x ≠ 0.

                                  theorem LeanCert.Engine.TaylorModel.foil_to_trunc_remainder {p1 p2 : Polynomial } {r1 r2 y : } {degree : } (hsplit : (Polynomial.aeval y) (p1 * p2) = (Polynomial.aeval y) (truncPoly (p1 * p2) degree) + (Polynomial.aeval y) (tailPoly (p1 * p2) degree)) :
                                  ((Polynomial.aeval y) p1 + r1) * ((Polynomial.aeval y) p2 + r2) = (Polynomial.aeval y) (truncPoly (p1 * p2) degree) + ((Polynomial.aeval y) (tailPoly (p1 * p2) degree) + (Polynomial.aeval y) p1 * r2 + (Polynomial.aeval y) p2 * r1 + r1 * r2)

                                  FOIL expansion for Taylor model multiplication. (P₁ + r₁)(P₂ + r₂) = trunc(P₁P₂) + [tail(P₁P₂) + P₁r₂ + P₂r₁ + r₁r₂]

                                  theorem LeanCert.Engine.TaylorModel.remainder_four_terms_mem {v_tail v_p1r2 v_p2r1 v_r1r2 : } {I_tail I_p1r2 I_p2r1 I_r1r2 : Core.IntervalRat} (htail : v_tail I_tail) (hp1r2 : v_p1r2 I_p1r2) (hp2r1 : v_p2r1 I_p2r1) (hr1r2 : v_r1r2 I_r1r2) :
                                  v_tail + v_p1r2 + v_p2r1 + v_r1r2 I_tail.add (I_p1r2.add (I_p2r1.add I_r1r2))

                                  Four-term remainder membership: tail + p1r2 + p2r1 + r1r2 ∈ totalRemainder. This extracts the nested interval addition pattern from mul_evalSet_correct.

                                  theorem LeanCert.Engine.TaylorModel.mul_evalSet_correct (f₁ f₂ : ) (tm1 tm2 : TaylorModel) (degree : ) (hcenter : tm1.center = tm2.center) (hdomain : tm1.domain = tm2.domain) (hf1 : xtm1.domain, f₁ x tm1.evalSet x) (hf2 : xtm2.domain, f₂ x tm2.evalSet x) (x : ) :
                                  x tm1.domainf₁ x * f₂ x (tm1.mul tm2 degree).evalSet x

                                  Multiplication preserves evalSet membership.

                                  Given:

                                  • f₁(x) ∈ tm1.evalSet x (i.e., f₁(x) = P₁(y) + r₁ with r₁ ∈ tm1.remainder)
                                  • f₂(x) ∈ tm2.evalSet x (i.e., f₂(x) = P₂(y) + r₂ with r₂ ∈ tm2.remainder)

                                  Then f₁(x) * f₂(x) ∈ (TaylorModel.mul tm1 tm2 degree).evalSet x.

                                  The expansion is: (P₁ + r₁)(P₂ + r₂) = P₁P₂ + P₁r₂ + P₂r₁ + r₁r₂ = trunc(P₁P₂) + [tail(P₁P₂) + P₁r₂ + P₂r₁ + r₁r₂]

                                  theorem LeanCert.Engine.TaylorModel.inv_evalSet_correct (f : ) (tm : TaylorModel) (hnz : ¬tm.bound.containsZero) (hf : xtm.domain, f x tm.evalSet x) (x : ) :
                                  x tm.domain(f x)⁻¹ (tm.inv hnz).evalSet x

                                  Inversion preserves evalSet membership (conservative construction).

                                  Since TaylorModel.inv uses poly = 0 and remainder = invBound, we show that if f(x) ∈ tm.evalSet x for all x in domain, then f(x)⁻¹ ∈ (inv tm hnz).evalSet x.