Documentation

LeanCert.Engine.TaylorModel.Expr

Taylor Model Composition and Expression Integration #

This file provides composition operations for Taylor models and integration with the Expr AST. It builds on the core Taylor model infrastructure and function-specific Taylor approximations to enable automatic Taylor model construction for expression trees.

Main definitions #

Main results #

Interval-based composition operations #

Given a TM for an argument, these operations return TMs that bound transcendental functions of that argument. They use function-level Taylor models for tight bounds.

noncomputable def LeanCert.Engine.TaylorModel.sin (tm : TaylorModel) (degree : ) :

Interval-based sin composition. Given a TM for the argument, returns a TM that bounds sin of the argument. Uses function-level Taylor model for tight bounds.

Equations
Instances For
    noncomputable def LeanCert.Engine.TaylorModel.cos (tm : TaylorModel) (degree : ) :

    Interval-based cos composition. Given a TM for the argument, returns a TM that bounds cos of the argument. Uses function-level Taylor model for tight bounds.

    Equations
    Instances For
      noncomputable def LeanCert.Engine.TaylorModel.exp (tm : TaylorModel) (degree : ) :

      Interval-based exp composition. Given a TM for the argument, returns a TM that bounds exp of the argument. Uses function-level Taylor model for tight bounds.

      Equations
      Instances For
        noncomputable def LeanCert.Engine.TaylorModel.sinh (tm : TaylorModel) (degree : ) :

        Interval-based sinh composition. Given a TM for the argument, returns a TM that bounds sinh of the argument. Uses function-level Taylor model for tight bounds.

        Equations
        Instances For
          noncomputable def LeanCert.Engine.TaylorModel.cosh (tm : TaylorModel) (degree : ) :

          Interval-based cosh composition. Given a TM for the argument, returns a TM that bounds cosh of the argument. Uses function-level Taylor model for tight bounds.

          Equations
          Instances For
            noncomputable def LeanCert.Engine.TaylorModel.tanh (tm : TaylorModel) (degree : ) :

            Interval-based tanh composition. Given a TM for the argument, returns a TM that bounds tanh of the argument. Uses tanh = sinh / cosh with the fact that cosh ≥ 1 > 0.

            Equations
            Instances For
              noncomputable def LeanCert.Engine.TaylorModel.atan (tm : TaylorModel) (degree : ) :

              Interval-based atan composition. Given a TM for the argument, returns a TM that bounds atan of the argument. Uses function-level Taylor model. Valid for |arg| ≤ 1.

              Equations
              Instances For
                noncomputable def LeanCert.Engine.TaylorModel.atanh (tm : TaylorModel) (degree : ) :

                Interval-based atanh composition. Given a TM for the argument, returns a TM that bounds atanh of the argument. Uses function-level Taylor model. Valid for |arg| < 1.

                Equations
                Instances For
                  noncomputable def LeanCert.Engine.TaylorModel.asinh (tm : TaylorModel) (degree : ) :

                  Interval-based asinh composition. Given a TM for the argument, returns a TM that bounds asinh of the argument. Uses function-level Taylor model.

                  Equations
                  Instances For
                    noncomputable def LeanCert.Engine.TaylorModel.sinc (tm : TaylorModel) (degree : ) :

                    Interval-based sinc composition. Given a TM for the argument, returns a TM that bounds sinc of the argument. sinc(z) = sin(z)/z for z ≠ 0, sinc(0) = 1.

                    Equations
                    Instances For
                      noncomputable def LeanCert.Engine.TaylorModel.erf (tm : TaylorModel) (degree : ) :

                      Interval-based erf composition. Given a TM for the argument, returns a TM that bounds erf of the argument. erf(z) = (2/√π) ∫₀ᶻ e^{-t²} dt.

                      Equations
                      Instances For

                        Interval-based log composition. Given a TM for the argument, returns a TM that bounds log of the argument. Only valid when the argument interval is strictly positive. Returns none if the argument could be ≤ 0.

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

                          Interval-based sqrt composition. Given a TM for the argument, returns a TM that bounds sqrt of the argument. Uses sqrtIntervalTight for the interval bound.

                          Equations
                          Instances For

                            Interval-based atan composition. Given a TM for the argument, returns a TM that bounds atan of the argument. Uses atanInterval for the interval bound (a conservative [-2, 2]).

                            Equations
                            Instances For

                              Interval-based erf composition. Given a TM for the argument, returns a TM that bounds erf of the argument. Uses erfInterval for the interval bound ([-1, 1]).

                              Equations
                              Instances For

                                Check if an interval is safe for atanh: max(|lo|, |hi|) ≤ 99/100. This ensures we're away from the singularities at ±1.

                                Equations
                                Instances For

                                  If an interval is atanh-safe, any value in the interval has |z| < 1.

                                  Interval-based atanh composition with domain check. Given a TM for the argument, returns a TM that bounds atanh of the argument. Returns none if the argument bound could be too close to ±1.

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

                                    Building Taylor models from Expr #

                                    noncomputable def LeanCert.Engine.TaylorModel.fromExpr (e : Core.Expr) (domain : Core.IntervalRat) (degree : ) :

                                    Convert an expression to a Taylor model (total builder used for examples).

                                    Equations
                                    Instances For

                                      Safe (partial) builder: convert an expression to a Taylor model, returning none if an inversion would require dividing by an interval that contains 0.

                                      Equations
                                      Instances For
                                        theorem LeanCert.Engine.fromExpr?_center (e : Core.Expr) (domain : Core.IntervalRat) (degree : ) (tm : TaylorModel) (h : TaylorModel.fromExpr? e domain degree = some tm) :
                                        tm.center = domain.midpoint

                                        Centers produced by fromExpr? are always domain.midpoint.

                                        theorem LeanCert.Engine.TaylorModel.add_evalSet_correct (e1 e2 : Core.Expr) (domain : Core.IntervalRat) (tm1 tm2 : TaylorModel) (hcenter : tm1.center = tm2.center) (hf1 : xdomain, Core.Expr.eval (fun (x_1 : ) => x) e1 tm1.evalSet x) (hf2 : xdomain, Core.Expr.eval (fun (x_1 : ) => x) e2 tm2.evalSet x) (x : ) :
                                        x domainCore.Expr.eval (fun (x_1 : ) => x) (e1.add e2) (tm1.add tm2).evalSet x

                                        Composition lemma (addition): if sub-evaluations are in their evalSets, the sum is in the evalSet of the added TM (centers must match).

                                        theorem LeanCert.Engine.TaylorModel.neg_evalSet_correct (e : Core.Expr) (domain : Core.IntervalRat) (tm : TaylorModel) (hf : xdomain, Core.Expr.eval (fun (x_1 : ) => x) e tm.evalSet x) (x : ) :
                                        x domainCore.Expr.eval (fun (x_1 : ) => x) e.neg tm.neg.evalSet x

                                        If e evaluates into tm.evalSet x on the domain, then -e evaluates into (neg tm).evalSet x on the domain.

                                        Correctness of transcendental operations #

                                        theorem LeanCert.Engine.TaylorModel.sin_evalSet_correct (f : ) (tm : TaylorModel) (degree : ) (hf : xtm.domain, f x tm.evalSet x) (x : ) :
                                        x tm.domainReal.sin (f x) (tm.sin degree).evalSet x

                                        sin preserves evalSet membership.

                                        theorem LeanCert.Engine.TaylorModel.cos_evalSet_correct (f : ) (tm : TaylorModel) (degree : ) (hf : xtm.domain, f x tm.evalSet x) (x : ) :
                                        x tm.domainReal.cos (f x) (tm.cos degree).evalSet x

                                        cos preserves evalSet membership.

                                        theorem LeanCert.Engine.TaylorModel.exp_evalSet_correct (f : ) (tm : TaylorModel) (degree : ) (hf : xtm.domain, f x tm.evalSet x) (x : ) :
                                        x tm.domainReal.exp (f x) (tm.exp degree).evalSet x

                                        exp preserves evalSet membership.

                                        theorem LeanCert.Engine.TaylorModel.sinh_evalSet_correct (f : ) (tm : TaylorModel) (degree : ) (hf : xtm.domain, f x tm.evalSet x) (x : ) :
                                        x tm.domainReal.sinh (f x) (tm.sinh degree).evalSet x

                                        sinh preserves evalSet membership.

                                        theorem LeanCert.Engine.TaylorModel.cosh_evalSet_correct (f : ) (tm : TaylorModel) (degree : ) (hf : xtm.domain, f x tm.evalSet x) (x : ) :
                                        x tm.domainReal.cosh (f x) (tm.cosh degree).evalSet x

                                        cosh preserves evalSet membership.

                                        theorem LeanCert.Engine.TaylorModel.asinh_evalSet_correct (f : ) (tm : TaylorModel) (degree : ) (hf : xtm.domain, f x tm.evalSet x) (x : ) :
                                        x tm.domainReal.arsinh (f x) (tm.asinh degree).evalSet x

                                        asinh preserves evalSet membership.

                                        theorem LeanCert.Engine.TaylorModel.sinc_evalSet_correct (f : ) (tm : TaylorModel) (degree : ) (hf : xtm.domain, f x tm.evalSet x) (x : ) :
                                        x tm.domainReal.sinc (f x) (tm.sinc degree).evalSet x

                                        sinc preserves evalSet membership.

                                        theorem LeanCert.Engine.TaylorModel.tanh_evalSet_correct (f : ) (tm : TaylorModel) (degree : ) (hf : xtm.domain, f x tm.evalSet x) (x : ) :
                                        x tm.domainReal.tanh (f x) (tm.tanh degree).evalSet x

                                        tanh preserves evalSet membership.

                                        theorem LeanCert.Engine.TaylorModel.atanh_evalSet_correct' (f : ) (tm result : TaylorModel) (degree : ) (hf : xtm.domain, f x tm.evalSet x) (hatanh : tm.atanh? degree = some result) (x : ) :
                                        x tm.domainCore.Real.atanh (f x) result.evalSet x

                                        atanh preserves evalSet membership when atanh? succeeds.

                                        Main fromExpr correctness #

                                        theorem LeanCert.Engine.fromExpr?_domain (e : Core.Expr) (domain : Core.IntervalRat) (degree : ) (tm : TaylorModel) (h : TaylorModel.fromExpr? e domain degree = some tm) :
                                        tm.domain = domain

                                        Helper: fromExpr? produces TaylorModels with matching domain.

                                        theorem LeanCert.Engine.fromExpr_evalSet_correct (e : Core.Expr) (domain : Core.IntervalRat) (degree : ) (tm : TaylorModel) (h : TaylorModel.fromExpr? e domain degree = some tm) (x : ) :
                                        x domainCore.Expr.eval (fun (x_1 : ) => x) e tm.evalSet x

                                        Core evalSet correctness: if fromExpr? succeeds, evaluation is in evalSet.

                                        theorem LeanCert.Engine.fromExpr_correct (e : Core.Expr) (domain : Core.IntervalRat) (degree : ) (tm : TaylorModel) (h : TaylorModel.fromExpr? e domain degree = some tm) (x : ) :
                                        x domainCore.Expr.eval (fun (x_1 : ) => x) e tm.bound

                                        fromExpr? produces correct Taylor models when it succeeds.

                                        Refined exp interval using Taylor models #

                                        Refined interval bound for exp using Taylor models. For small intervals (width ≤ 1), uses degree-5 Taylor model which gives tight bounds. For larger intervals, falls back to the monotonicity-based coarse bound.

                                        Equations
                                        Instances For

                                          FTIA for refined exp: if x ∈ I, then exp(x) ∈ expIntervalRefined I