10.7. Certified Bounds and Models
The exponential in the figure returns us to the heat profile that opened the chapter. Here the question is quantitative: how far can a polynomial lie from the function anywhere on the stated interval? Increasing the degree can reduce that error, but the final zero-width band replaces the polynomial by the exponential itself: the same inequality with the exponential as its own model and error zero. The plotted coordinates illustrate the estimate; the certificates supply proofs.
The shared semantic vocabulary is intentionally small:
ApproxOn f g s εmeans\lVert f(x)-g(x)\rVert\leq\varepsilonfor everyx\in s;BoundOn f s cmeansf(x)\leq cthroughouts;EnclosedOn f s lo himeans\mathrm{lo}\leq f(x)\leq\mathrm{hi}throughouts;ResidualBound r s εmeans\lVert r(x)\rVert\leq\varepsilonthroughouts.
These are ordinary propositions in the language of approximation theory. The
certificate records ApproxCert, ResidualCert, BoundCert, and
EnclosureCert store the functions, domain, and numerical data of one of them
together with a sound field proving it; a QuadratureCert does the same for
the error of an interval integral. Checked certificates compose through
ordinary Lean theorems.
10.7.1. One Calculation, End to End
The derivative request
-- Retain the nonzero-domain condition
-- for log in the report.
#cas [derive x] (log x)
Expand...
illustrates the complete exact path. The parser first turns the ordinary
notation into an expression tree. Inspecting the logarithm records a nonzero
condition on its argument. The differentiator constructs the candidate 1/x,
and the analytic differentiation theorem justifies the ordinary statement
that the derivative of \log at x is 1/x, provided x\ne0.
The condition printed by the inspection command is part of the answer. To use the derivative at a particular point, a theorem-facing tactic must prove that condition from the hypotheses. This is the same obligation that appeared in the affine Burgers denominator and in the logarithmic fundamental solution away from its pole. Polynomial examples need no such exclusion, but they pass through the same proof interface.
A CEGA query follows the same architecture but ends in a quantitative certificate. For
-- Exercise the full parser-to-certificate
-- pipeline.
set_option linter.hashCommand false in
#cas [enclose x in [-1 / 10, 1 / 10]] (cos x)
Expand...
the parser again produces an expression tree, and a rational interval evaluator constructs candidate endpoints. A successful computation returns those endpoints together with a proof that every value on the input interval lies between them.
Taylor models use enclosures to bound their remainders while retaining polynomial structure. Derivative bounds also help determine a sufficient subdivision for quadrature.
10.7.2. Certified Approximation and Enclosures
FloatLib supplies the interval arithmetic and elementary-function enclosures.
The rational backend uses FloatLib.Numerics.Interval ℚ; PDEAtlas's
RationalInterval extends it with just the endpoint-order proof hle.
Its endpoints remain exact rationals. FloatLib's generic expression evaluator
accepts CAS expressions through a proved semantic translation, and its
upstream backends choose the endpoint representation and rounding policy.
CEGA connects their containment proofs to real inequalities, so an analytic
theorem can use a different representation without changing its statement.
The four basic certificate shapes.
On a domain s, the records name their data as follows: ApproxCert α E s
has functions lhs and rhs and an error eps; ResidualCert α E s has a
residual and an eps; BoundCert α s has a real function fn and an
upper endpoint; EnclosureCert α s has fn, lo, and hi. Each sound
field proves the corresponding proposition on s. These general records may
contain noncomputable real data, while concrete rational enclosures provide
executable endpoints. For example, an enclosure
-0.01\le r(x)\le0.01 immediately gives a residual certificate with error
0.01; an enclosure of f-g inside [-\varepsilon,\varepsilon] gives an
approximation certificate from f to g.
An approximation certificate stores two functions, an explicit domain and uniform error budget, and a proof of the corresponding norm bound. Exact equality is the zero-error special case. The budget is stored as a real number.
Its theorem-facing field is exactly
\operatorname{ApproxOn}(f,g,s,\varepsilon)
\;:\!\Longleftrightarrow\;
\forall x\in s,\quad \lVert f(x)-g(x)\rVert\leq\varepsilon.
Lean code for Definition10.36●1 definitionAssociated Lean declarationsCAS.Certificate.ApproxCert[complete]
CAS.Certificate.ApproxCert[complete]
- structuredefined in CAS/Certificate/Approximation.leancomplete
structure CAS.Certificate.ApproxCert.{u_1, u_2} (α : Type u_1) (E : Type u_2) [NormedAddCommGroup E] (s : Set α) : Type (max u_1 u_2)
structure CAS.Certificate.ApproxCert.{u_1, u_2} (α : Type u_1) (E : Type u_2) [NormedAddCommGroup E] (s : Set α) : Type (max u_1 u_2)
A checked uniform approximation certificate on a domain.
The fields
lhs,rhs, andepsmake the certificate composable as data, andsoundproves theApproxOnproposition. The budget is necessarily nonnegative on every nonempty domain; equivalently, a negative budget certifies only an empty domain.Fields
lhs : α → E
Left-hand function.
rhs : α → E
Right-hand/reference function.
eps : ℝ
Uniform error budget. It is nonnegative whenever
sis nonempty.sound : CAS.Certificate.ApproxOn self.lhs self.rhs s self.eps
lhsis uniformlyeps-close torhsons.
An approximation or residual certificate has a nonnegative error budget unless its certified domain is empty. Equivalently, a negative budget can never be used to establish a nonvacuous estimate.
For either certificate family,
0\leq c.\mathrm{eps}\quad\lor\quad s=\varnothing.
Lean code for Theorem10.37●2 theoremsAssociated Lean declarations
- theoremdefined in CAS/Certificate/Approximation.leancomplete
theorem CAS.Certificate.ApproxCert.eps_nonneg_or_eq_empty.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (c : CAS.Certificate.ApproxCert α E s) : 0 ≤ c.eps ∨ s = ∅
theorem CAS.Certificate.ApproxCert.eps_nonneg_or_eq_empty.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (c : CAS.Certificate.ApproxCert α E s) : 0 ≤ c.eps ∨ s = ∅
An approximation budget is nonnegative unless its certified domain is empty.
- theoremdefined in CAS/Certificate/Residual.leancomplete
theorem CAS.Certificate.ResidualCert.eps_nonneg_or_eq_empty.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (c : CAS.Certificate.ResidualCert α E s) : 0 ≤ c.eps ∨ s = ∅
theorem CAS.Certificate.ResidualCert.eps_nonneg_or_eq_empty.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (c : CAS.Certificate.ResidualCert α E s) : 0 ≤ c.eps ∨ s = ∅
A residual budget is nonnegative unless its certified domain is empty.
If the domain is nonempty, choose one point in it. Soundness bounds a norm,
which is nonnegative, by the stored budget; hence the budget is nonnegative by
transitivity. If no point exists, the alternative s=\varnothing holds.
CAS.Certificate.ApproxCert.trans[complete]CAS.Certificate.ApproxCert.mapLipschitz[complete]CAS.Certificate.ApproxCert.eqOn_of_eps_eq_zero[complete]
Approximation certificates compose by adding error budgets, pass through Lipschitz maps, and recover exact equality when the final budget is zero.
The three principal rules are
\begin{aligned}
\operatorname{ApproxOn}(f,g,s,\varepsilon_1)
\land\operatorname{ApproxOn}(g,h,s,\varepsilon_2)
&\Longrightarrow
\operatorname{ApproxOn}(f,h,s,\varepsilon_1+\varepsilon_2),\\
\operatorname{ApproxOn}(f,g,s,\varepsilon)
\land L\geq0
\land\left(\forall u,v,\ \lVert\phi(u)-\phi(v)\rVert\leq L\lVert u-v\rVert\right)
&\Longrightarrow
\operatorname{ApproxOn}(\phi\circ f,\phi\circ g,s,L\varepsilon),\\
\operatorname{ApproxOn}(f,g,s,0)
&\Longrightarrow f= g\quad\text{on }s.
\end{aligned}
Lean code for Definition10.38●3 declarationsAssociated Lean declarationsCAS.Certificate.ApproxCert.trans[complete]CAS.Certificate.ApproxCert.mapLipschitz[complete]CAS.Certificate.ApproxCert.eqOn_of_eps_eq_zero[complete]
CAS.Certificate.ApproxCert.trans[complete]CAS.Certificate.ApproxCert.mapLipschitz[complete]CAS.Certificate.ApproxCert.eqOn_of_eps_eq_zero[complete]
- defdefined in CAS/Certificate/Approximation.leancomplete
def CAS.Certificate.ApproxCert.trans.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (a b : CAS.Certificate.ApproxCert α E s) (hmid : a.rhs = b.lhs) : CAS.Certificate.ApproxCert α E s
def CAS.Certificate.ApproxCert.trans.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (a b : CAS.Certificate.ApproxCert α E s) (hmid : a.rhs = b.lhs) : CAS.Certificate.ApproxCert α E s
Compose two approximation certificates whose middle functions agree.
- defdefined in CAS/Certificate/Approximation.leancomplete
def CAS.Certificate.ApproxCert.mapLipschitz.{u_1, u_2, u_3} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} {F : Type u_3} [NormedAddCommGroup F] (c : CAS.Certificate.ApproxCert α E s) (φ : E → F) (L : ℝ) (hL : 0 ≤ L) (hφ : ∀ (x y : E), ‖φ x - φ y‖ ≤ L * ‖x - y‖) : CAS.Certificate.ApproxCert α F s
def CAS.Certificate.ApproxCert.mapLipschitz.{u_1, u_2, u_3} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} {F : Type u_3} [NormedAddCommGroup F] (c : CAS.Certificate.ApproxCert α E s) (φ : E → F) (L : ℝ) (hL : 0 ≤ L) (hφ : ∀ (x y : E), ‖φ x - φ y‖ ≤ L * ‖x - y‖) : CAS.Certificate.ApproxCert α F s
Push an approximation certificate through a Lipschitz map.
If
φhas Lipschitz constantLandf ≈ gwith errorε, thenφ ∘ f ≈ φ ∘ gwith errorL * ε. Nonlinear post-processing of any approximation, whether it came from an exact symbolic route or an interval enclosure, goes through this rule. - theoremdefined in CAS/Certificate/Approximation.leancomplete
theorem CAS.Certificate.ApproxCert.eqOn_of_eps_eq_zero.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (c : CAS.Certificate.ApproxCert α E s) (heps : c.eps = 0) : Set.EqOn c.lhs c.rhs s
theorem CAS.Certificate.ApproxCert.eqOn_of_eps_eq_zero.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (c : CAS.Certificate.ApproxCert α E s) (heps : c.eps = 0) : Set.EqOn c.lhs c.rhs s
A zero-error approximation certificate gives equality on the domain.
A real interval implementation supplies lower and upper endpoints, a membership predicate, and proofs that membership implies the corresponding real inequalities. Exact rational intervals are the registered instance; a verified finite-precision representation with the same two proofs feeds the same enclosure theorems.
Every backend instance must establish
x\in_{\!B} I
\quad\Longrightarrow\quad
\operatorname{lo}(I)\leq x\leq\operatorname{hi}(I).
The representation of I and the implementation of membership are otherwise
abstract. For the rational backend, CEGA's endpoint inequalities are
equivalent to FloatLib's real containment predicate.
Attaching hle preserves that predicate and gives refinement and quadrature
an ordered interval with a nonnegative radius.
Lean code for Definition10.39●1 definitionAssociated Lean declarationsCAS.Continuum.RealIntervalBackend[complete]
CAS.Continuum.RealIntervalBackend[complete]
- classdefined in CAS/Continuum/IntervalBackend.leancomplete
class CAS.Continuum.RealIntervalBackend.{u} (ι : Type u) : Type u
class CAS.Continuum.RealIntervalBackend.{u} (ι : Type u) : Type u
A CEGA-facing real interval backend.
The backend chooses the interval representation. CEGA only asks for lower and upper real endpoints plus sound projections from backend membership to real inequalities, so any representation with these projections fits the same API;
RationalIntervalis the one instance.The interface permits empty enclosures: it does not require
lo I ≤ hi I. Any inhabited enclosure has ordered endpoints bylower_memandupper_mem.Methods
lo : ι → ℝ
Lower real endpoint.
hi : ι → ℝ
Upper real endpoint.
MemReal : ι → ℝ → Prop
Backend membership predicate, interpreted over real values.
lower_mem : ∀ {I : ι} {x : ℝ}, CAS.Continuum.RealIntervalBackend.MemReal I x → CAS.Continuum.RealIntervalBackend.lo I ≤ x
Membership implies the lower endpoint bound.
upper_mem : ∀ {I : ι} {x : ℝ}, CAS.Continuum.RealIntervalBackend.MemReal I x → x ≤ CAS.Continuum.RealIntervalBackend.hi I
Membership implies the upper endpoint bound.
Before interval compilation, an intrinsic syntax check rejects malformed rational literals whose denominator is zero. Division, logarithm, and square root remain ordinary real expressions with pointwise analytic validity conditions; this check handles only malformed syntax, so it cannot be bypassed by evaluating over an empty domain.
The nontrivial recursive clauses are
\begin{aligned}
\operatorname{WF}(\operatorname{rat}(m,d))&\Longleftrightarrow d\neq0,\\
\operatorname{WF}(e_1\mathbin\circ e_2)
&\Longleftrightarrow\operatorname{WF}(e_1)\land\operatorname{WF}(e_2),\\
\operatorname{WF}(\operatorname{op}(e))
&\Longleftrightarrow\operatorname{WF}(e).
\end{aligned}
Here \circ ranges over binary syntax constructors and
\operatorname{op} over unary constructors; branch-domain proofs are
deliberately separate.
Lean code for Definition10.40●1 definitionAssociated Lean declarationsCAS.Verified.Expr.isWellFormed[complete]
CAS.Verified.Expr.isWellFormed[complete]
- defdefined in CAS/Continuum/IntervalEval/WellFormed.leancomplete
def CAS.Verified.Expr.isWellFormed.{u_1} {ι : Type u_1} : CAS.Verified.Expr ι → Bool
def CAS.Verified.Expr.isWellFormed.{u_1} {ι : Type u_1} : CAS.Verified.Expr ι → Bool
Decide intrinsic well-formedness, rejecting rational literals with denominator zero.
Successful evaluation by a sound FloatLib backend encloses every real value
of the expression on the input panel. The semantic translation identifies
that value with the original CAS expression when the coordinate environments
agree, with no condition on the expression. It writes \pi, real powers and
\mathrm e as FloatLib's standard calls, whose enclosures come with their
own containment theorems.
For an environment enclosure
\rho(i)\in_{\!B}\operatorname{env}(i), successful evaluation satisfies
\operatorname{evalInterval}(\operatorname{env},e)
=\operatorname{some}(J)
\quad\Longrightarrow\quad
\operatorname{eval}(e,\rho)\in_{\!B}J.
The admissible numerical domains depend on the backend. FloatLib's default
elementary enclosures require positive logarithm panels, and its real-power
call requires a positive base panel. The translation sends a square-root
argument through \max(0,\cdot), so negative inputs follow Mathlib's
\sqrt x=0 on every backend. CEGA's certified contexts use FloatLib's total
elementary table, which also treats strictly negative logarithm panels through
\log x=\log|x| and the singleton zero through \log0=0.
A nontrivial panel touching zero has no finite logarithm range. Division
needs a denominator interval that excludes zero, or the checked lower bound
below; unsupported or failed operations return none.
A checked denominator entry stores a positive rational lower bound
\delta, its direct theorem \delta\leq|\operatorname{eval}(d,\rho)| on
the chart, and route provenance. A certified context then evaluates the
quotient a/d as a\cdot w for a fresh variable w=d^{-1} with the
interval [-1/\delta,1/\delta], with the same enclosure conclusion.
Lean code for Theorem10.41●5 theoremsAssociated Lean declarations
- theoremdefined in CAS/Expr/FloatLib.leancomplete
theorem CAS.Verified.Expr.eval_toFloatLib.{u_1} {ι : Type u_1} (expr : CAS.Verified.Expr ι) (vars : ι → ℕ) (ρ : ι → ℝ) (values : ℕ → ℝ) (hvars : ∀ (i : ι), values (vars i) = ρ i) : (CAS.Verified.Expr.toFloatLib vars expr).eval values (FloatLib.Numerics.Interval.extensionValues FloatLib.Numerics.Interval.Backend.Standard.functions) = CAS.Verified.Expr.eval ρ expr
theorem CAS.Verified.Expr.eval_toFloatLib.{u_1} {ι : Type u_1} (expr : CAS.Verified.Expr ι) (vars : ι → ℕ) (ρ : ι → ℝ) (values : ℕ → ℝ) (hvars : ∀ (i : ι), values (vars i) = ρ i) : (CAS.Verified.Expr.toFloatLib vars expr).eval values (FloatLib.Numerics.Interval.extensionValues FloatLib.Numerics.Interval.Backend.Standard.functions) = CAS.Verified.Expr.eval ρ expr
The translation keeps the value: FloatLib's value of
expr.toFloatLib vars, with the real functionsBackend.Standard.functionsfor its calls, is SymLean's value ofexpratρ, for every assignmentvaluesthat gives the indexvars ithe valueρ i. There is no other hypothesis.Rewriting the conclusion of FloatLib's
Interval.Expr.containsReal_evalZero?with this equality gives an enclosure of the SymLean expression. - theoremdefined in FloatLib/Numerics/Enclosure/Expression/Real.leancomplete
theorem FloatLib.Numerics.Interval.Expr.containsReal_eval?.{u_1} {α : Type u_1} (e : FloatLib.Numerics.Interval.Expr) {B : FloatLib.Numerics.Interval.Backend α} {functions : ℕ → List ℝ → ℝ} (hB : B.Sound functions) {env : ℕ → Option (FloatLib.Numerics.Interval α)} {values : ℕ → ℝ} (henv : ∀ (i : ℕ) (I : FloatLib.Numerics.Interval α), env i = some I → FloatLib.Numerics.Interval.ContainsReal B.decode I (values i)) {I : FloatLib.Numerics.Interval α} (h : e.eval? B env = some I) : FloatLib.Numerics.Interval.ContainsReal B.decode I (e.eval values functions)
theorem FloatLib.Numerics.Interval.Expr.containsReal_eval?.{u_1} {α : Type u_1} (e : FloatLib.Numerics.Interval.Expr) {B : FloatLib.Numerics.Interval.Backend α} {functions : ℕ → List ℝ → ℝ} (hB : B.Sound functions) {env : ℕ → Option (FloatLib.Numerics.Interval α)} {values : ℕ → ℝ} (henv : ∀ (i : ℕ) (I : FloatLib.Numerics.Interval α), env i = some I → FloatLib.Numerics.Interval.ContainsReal B.decode I (values i)) {I : FloatLib.Numerics.Interval α} (h : e.eval? B env = some I) : FloatLib.Numerics.Interval.ContainsReal B.decode I (e.eval values functions)
A successful expression evaluation encloses the exact real value throughout the input box.
Only variables actually supplied by the interval environment need a membership proof. A missing variable prevents successful evaluation, so it cannot create an unproved assumption.
- theoremdefined in CAS/Expr/FloatLib.leancomplete
theorem CAS.Verified.Expr.containsReal_evalZero?.{u_1, u_2} {ι : Type u_1} {α : Type u_2} {B : FloatLib.Numerics.Interval.Backend α} {functions : ℕ → List ℝ → ℝ} {config : FloatLib.Numerics.Interval.Backend.Config} {vars : ι → ℕ} {ρ : ι → ℝ} {values : ℕ → ℝ} (hB : B.Sound functions) (hvars : ∀ (i : ι), values (vars i) = ρ i) {env : ℕ → Option (FloatLib.Numerics.Interval α)} (henv : ∀ (k : ℕ) (I : FloatLib.Numerics.Interval α), env k = some I → FloatLib.Numerics.Interval.ContainsReal B.decode I (values k)) (expr : CAS.Verified.Expr ι) {I : FloatLib.Numerics.Interval α} (h : (CAS.Verified.Expr.toFloatLib vars expr).evalZero? (B.withExtensions config FloatLib.Numerics.Interval.Backend.Standard.extensions) env = some I) : FloatLib.Numerics.Interval.ContainsReal B.decode I (CAS.Verified.Expr.eval ρ expr)
theorem CAS.Verified.Expr.containsReal_evalZero?.{u_1, u_2} {ι : Type u_1} {α : Type u_2} {B : FloatLib.Numerics.Interval.Backend α} {functions : ℕ → List ℝ → ℝ} {config : FloatLib.Numerics.Interval.Backend.Config} {vars : ι → ℕ} {ρ : ι → ℝ} {values : ℕ → ℝ} (hB : B.Sound functions) (hvars : ∀ (i : ι), values (vars i) = ρ i) {env : ℕ → Option (FloatLib.Numerics.Interval α)} (henv : ∀ (k : ℕ) (I : FloatLib.Numerics.Interval α), env k = some I → FloatLib.Numerics.Interval.ContainsReal B.decode I (values k)) (expr : CAS.Verified.Expr ι) {I : FloatLib.Numerics.Interval α} (h : (CAS.Verified.Expr.toFloatLib vars expr).evalZero? (B.withExtensions config FloatLib.Numerics.Interval.Backend.Standard.extensions) env = some I) : FloatLib.Numerics.Interval.ContainsReal B.decode I (CAS.Verified.Expr.eval ρ expr)
A successful FloatLib evaluation with the zero rule of
expr.toFloatLib vars, by a sound backendBwith FloatLib's standard calls added, contains SymLean's value ofexpratρ. The interval environmentenvmust containvalues kat every indexkthat it fills, andvaluesmust give the indexvars ithe valueρ i. This is FloatLib'sInterval.Expr.containsReal_evalZero?aftereval_toFloatLib. - theoremdefined in CAS/Expr/FloatLib.leancomplete
theorem CAS.Verified.Expr.containsReal_loweredIntervals.{u_1} {ι : Type u_1} {ρ : ι → ℝ} {intervals : ι → FloatLib.Numerics.Interval ℚ} {lookup : CAS.Verified.Expr ι → Option ℚ} {expr : CAS.Verified.Expr ι} (hvars : ∀ i ∈ expr.occurrences, FloatLib.Numerics.Interval.ContainsReal some (intervals i) (ρ i)) (hlookup : ∀ (b : CAS.Verified.Expr ι) (δ : ℚ), lookup b = some δ → 0 < δ ∧ ↑δ ≤ |CAS.Verified.Expr.eval ρ b|) (l : ι ⊕ CAS.Verified.Expr ι × ℚ) : l ∈ (CAS.Verified.Expr.lowerDivisions lookup expr).occurrences → FloatLib.Numerics.Interval.ContainsReal some (CAS.Verified.Expr.loweredIntervals intervals l) (CAS.Verified.Expr.loweredValues ρ l)
theorem CAS.Verified.Expr.containsReal_loweredIntervals.{u_1} {ι : Type u_1} {ρ : ι → ℝ} {intervals : ι → FloatLib.Numerics.Interval ℚ} {lookup : CAS.Verified.Expr ι → Option ℚ} {expr : CAS.Verified.Expr ι} (hvars : ∀ i ∈ expr.occurrences, FloatLib.Numerics.Interval.ContainsReal some (intervals i) (ρ i)) (hlookup : ∀ (b : CAS.Verified.Expr ι) (δ : ℚ), lookup b = some δ → 0 < δ ∧ ↑δ ≤ |CAS.Verified.Expr.eval ρ b|) (l : ι ⊕ CAS.Verified.Expr ι × ℚ) : l ∈ (CAS.Verified.Expr.lowerDivisions lookup expr).occurrences → FloatLib.Numerics.Interval.ContainsReal some (CAS.Verified.Expr.loweredIntervals intervals l) (CAS.Verified.Expr.loweredValues ρ l)
Each variable of
expr.lowerDivisions lookuphas its value atρin its interval: a variable ofexprwhen its interval contains its value, and the fresh variable of a denominatorbwithlookup b = some δwhen0 < δ ≤ |b|atρ. WithcontainsReal_occurrences, the occurrence inputs of the lowered expression then lie in its occurrence box. - theoremdefined in CAS/Continuum/IntervalEval/Context.leancomplete
theorem CAS.Continuum.RationalInterval.CertifiedEvalContext.sound.{u_1, u_2} {α : Type u_1} {ι : Type u_2} {s : Set α} {ρ : α → ι → ℝ} (p : CAS.Continuum.RationalInterval.CertifiedEvalContext s ρ) (x : α) (hx : x ∈ s) (expr : CAS.Verified.Expr ι) (I : CAS.Continuum.RationalInterval) (hEval : p.eval expr = some I) : I.MemReal (CAS.Verified.Expr.eval (ρ x) expr)
theorem CAS.Continuum.RationalInterval.CertifiedEvalContext.sound.{u_1, u_2} {α : Type u_1} {ι : Type u_2} {s : Set α} {ρ : α → ι → ℝ} (p : CAS.Continuum.RationalInterval.CertifiedEvalContext s ρ) (x : α) (hx : x ∈ s) (expr : CAS.Verified.Expr ι) (I : CAS.Continuum.RationalInterval) (hEval : p.eval expr = some I) : I.MemReal (CAS.Verified.Expr.eval (ρ x) expr)
Soundness of the bundled evaluator at a concrete chart point.
FloatLib proves containment by induction on its expression tree: leaves use
the environment and constant contracts, each operation uses the backend's
soundness theorem on the inductive enclosures, and each standard call uses the
containment theorem of its registered enclosure. Compose this result with the
CAS translation's real-denotation equality. The lowered quotient has the value
of the original one because a/d=a\cdot d^{-1} in \mathbb R, and
\delta\leq|d| gives |d^{-1}|\leq1/\delta, so the fresh variable lies in
its interval at every chart point. Failed operations propagate none, so
every successful branch retains its containment proof.
Backend membership yields ordinary real enclosures. If the interval lies
inside [-\varepsilon,\varepsilon], the same bridge yields a certified
residual bound.
Lean code for Theorem10.42●2 theoremsAssociated Lean declarations
- theoremdefined in CAS/Continuum/IntervalBackend.leancomplete
theorem CAS.Continuum.RealIntervalBackend.enclosedOn_of_memReal.{u, u_1} {ι : Type u} [CAS.Continuum.RealIntervalBackend ι] {α : Type u_1} {f : α → ℝ} {s : Set α} {I : ι} (h : ∀ x ∈ s, CAS.Continuum.RealIntervalBackend.MemReal I (f x)) : CAS.Certificate.EnclosedOn f s (CAS.Continuum.RealIntervalBackend.lo I) (CAS.Continuum.RealIntervalBackend.hi I)
theorem CAS.Continuum.RealIntervalBackend.enclosedOn_of_memReal.{u, u_1} {ι : Type u} [CAS.Continuum.RealIntervalBackend ι] {α : Type u_1} {f : α → ℝ} {s : Set α} {I : ι} (h : ∀ x ∈ s, CAS.Continuum.RealIntervalBackend.MemReal I (f x)) : CAS.Certificate.EnclosedOn f s (CAS.Continuum.RealIntervalBackend.lo I) (CAS.Continuum.RealIntervalBackend.hi I)
If
f xlies in the backend intervalIfor everyx ∈ s, thenfis enclosed onsby the real endpoints ofI. - theoremdefined in CAS/Continuum/IntervalBackend.leancomplete
theorem CAS.Continuum.RealIntervalBackend.residualBound_of_memReal_le.{u, u_1} {ι : Type u} [CAS.Continuum.RealIntervalBackend ι] {α : Type u_1} {residual : α → ℝ} {s : Set α} {I : ι} {ε : ℝ} (hlo : -ε ≤ CAS.Continuum.RealIntervalBackend.lo I) (hhi : CAS.Continuum.RealIntervalBackend.hi I ≤ ε) (h : ∀ x ∈ s, CAS.Continuum.RealIntervalBackend.MemReal I (residual x)) : CAS.Certificate.ResidualBound residual s ε
theorem CAS.Continuum.RealIntervalBackend.residualBound_of_memReal_le.{u, u_1} {ι : Type u} [CAS.Continuum.RealIntervalBackend ι] {α : Type u_1} {residual : α → ℝ} {s : Set α} {I : ι} {ε : ℝ} (hlo : -ε ≤ CAS.Continuum.RealIntervalBackend.lo I) (hhi : CAS.Continuum.RealIntervalBackend.hi I ≤ ε) (h : ∀ x ∈ s, CAS.Continuum.RealIntervalBackend.MemReal I (residual x)) : CAS.Certificate.ResidualBound residual s ε
If a backend interval lies inside
[-ε, ε], interval containment gives a CEGA residual bound with errorε.
Apply the backend membership theorem pointwise to obtain the real lower and
upper inequalities. If those endpoints lie in
[-\varepsilon,\varepsilon], transitivity gives
-\varepsilon\leq f(x)\leq\varepsilon, which is equivalent to the required
absolute residual bound.
How FloatLib encloses elementary functions.
An interval for f(I) must contain f(x) for every real x\in I,
including irrational inputs. FloatLib's ContainsReal theorems make exactly
this claim. PDEAtlas's elementary-function adapters call the upstream routines,
express their results in CEGA's ordered interval interface, and connect the
routines' domains to Mathlib's total real functions. The numerical
series, remainder estimates, period reduction, and integer square root live
in FloatLib.
Exponential enclosure. expRangeWith I order calls FloatLib's expBounds
with degree d=\max(\mathrm{order},1). For an endpoint q, FloatLib
chooses a binary scale s so that r=q/2^s has |r|<1. With
n=d+1, its exact rational Taylor sum and error bound are
T_n(r)=\sum_{k=0}^{n-1}\frac{r^k}{k!},\qquad
R_n(r)=\frac{|r|^n(n+1)}{n!\,n}.
The proved estimate puts \exp r in [T_n(r)-R_n(r),T_n(r)+R_n(r)].
Repeated interval squaring then uses
\exp q=(\exp r)^{2^s} to restore the original scale. Monotonicity
combines the lower endpoint enclosure at I.lo with the upper endpoint
enclosure at I.hi, and expBounds clamps the lower bound to zero.
Logarithm enclosure. logRangeWith takes a proof that the input panel is
strictly positive and calls FloatLib's logBounds?. For a positive endpoint
q\geq1, binary reduction writes q=2^k r with 1\leq r<2;
for 0<q<1, FloatLib first encloses \log(q^{-1}) and negates the
result. The transformed series argument
t=(r-1)/(r+1) lies in [0,1/3), while the separate enclosure of
\log2 uses t=1/3. Writing P_d(t)=\sum_{j=1}^{d}t^j/j, the
identity \log r=\log(1+t)-\log(1-t) gives the rational estimate
\left|\log r-\bigl(P_d(t)-P_d(-t)\bigr)\right|
\leq\frac{2|t|^{d+1}}{1-|t|}.
FloatLib restores k\log2 by interval arithmetic. There is no reduction
fuel limit: the binary scale comes from the rational argument. CEGA maps a
requested logTerms value to d=2\max(\mathrm{logTerms},1) for this
geometric remainder bound.
Square root enclosure. For q=n/d\geq0 in lowest terms, CEGA calls
FloatLib's sqrtPointBounds on q d^2=nd and divides the resulting
endpoints by d. With S=2^s, the upstream integer square root
r=\lfloor\sqrt{ndS^2}\rfloor gives
\sqrt q\in\left[\frac{r}{dS},\frac{r+1}{dS}\right].
Trigonometric enclosures. The base calls are FloatLib's sinBounds and
cosBounds, each with degree 32. They enclose the panel midpoint and
inflate that enclosure by the panel radius using
|f(x)-f(m)|\leq|x-m| for f=\sin,\cos. Intersecting with
[-1,1] retains the global range, including when the panel crosses an
extremum. For a midpoint of magnitude above 4, FloatLib reduces by
approximate full periods derived from its certified enclosure of \pi/4.
The error includes both the Taylor remainder and the accumulated period
uncertainty. That uncertainty grows with the number of removed periods, so
a narrow input panel alone does not guarantee a sharp range at large arguments.
CEGA refines these FloatLib bounds with endpoint monotonicity and sign facts
when rational branch tests justify them. For example, on a panel crossing
zero inside [-\pi,\pi], cosine's lower bound comes from the two endpoint
enclosures and its upper bound is 1. Those endpoint enclosures also come
from FloatLib. Subdivision can sharpen a range but need not improve it strictly.
Arctangent enclosure. atanRange calls FloatLib's atanBounds with
parameter 16. Oddness reduces negative inputs to nonnegative ones;
reciprocation reduces inputs above one to [0,1]. On (1/2,1], the
identity
\arctan q=\frac{\pi}{4}+\arctan\frac{q-1}{q+1}
leaves a series argument of magnitude at most 1/2. FloatLib bounds the
arctangent series by a geometric tail and encloses \pi/4 using Machin's
identity \pi/4=4\arctan(1/5)-\arctan(1/239). Monotonicity combines
the endpoint enclosures into a range for the full panel.
Inverse trigonometric and hyperbolic functions. Arcsine and arccosine use
FloatLib's asinBounds? and acosBounds?. CEGA clamps endpoint arguments
to [-1,1], proves agreement with Mathlib's total functions, and uses their
monotonicity to lift point bounds to panels. If an optional point enclosure
fails, a proved global range supplies the fallback. Hyperbolic ranges call
FloatLib's sinhBounds, coshBounds, and tanhBounds with the requested
positive exponential degree; their containment theorems pass through the
same real-membership bridge.
Example: enclosing \exp(\cos x) on [-1/10, 1/10].
A conservative hand calculation shows how enclosures compose; its Taylor order is chosen by hand.
Variable range. The input panel gives
x \in [-1/10, 1/10].Cosine enclosure. At center
0,\cos 0 = 1. The one-Lipschitz inflation gives\cos x \in [1 - 1/10, 1 + 1/10] = [9/10, 11/10]. Intersecting with[-1, 1]gives\cos x \in [9/10, 1].Exponential enclosure. At each endpoint
q\in\{9/10,1\}, useT_8(q)=\sum_{k<8}q^k/k!andR_8(q)=q^8\,9/(8!\,8). The proved Taylor estimate gives\exp(q)\in[T_8(q)-R_8(q),T_8(q)+R_8(q)]. Monotonicity therefore encloses the composition in the exact rational interval[T_8(9/10)-R_8(9/10),T_8(1)+R_8(1)].Result. These rational endpoints and the uniform enclosure proof give the data needed for an
EnclosureCert. The evaluator can instead compose FloatLib's cosine and exponential bounds through the same containment rule.
The evaluator handles composed transcendental expressions without
special-case code for \exp \circ \cos. Each function's enclosure feeds into
the next through the generic interval backend interface. The exact range is
[\exp(\cos(1/10)),\exp(1)]; the conservative cosine step accounts for much
of the excess width.
The interval evaluator's compositional structure.
Expr.toFloatLib translates CAS syntax into
FloatLib.Numerics.Interval.Expr. FloatLib's Expr.eval? traverses this
expression using an upstream backend:
Rational literals are enclosed by the backend's constant operation.
Variables take their intervals from the supplied coordinate environment.
Arithmetic and elementary nodes use FloatLib's operations and containment theorems.
\pi, the real powera^band\mathrm eare FloatLib's standard calls0,1and2(Backend.Standard.extensions). The enclosures of\piand\mathrm efollow the configured precision, and the real power needs a base interval with a positive lower endpoint.Inverse sine and cosine clamp their arguments to
[-1,1], and the square root takes\max(0,\cdot)of its argument, preserving Mathlib's total functions.
The translation proves agreement of real values; numerical evaluation and its soundness theorem live upstream. Ordinary multiplication followed by addition remains two expression nodes. An application requiring fused multiply-add uses FloatLib's explicit FMA node.
CEGA evaluates with Expr.evalZero?, which adds one rule to Expr.eval?: a
product with an exactly zero factor, or a quotient with an exactly zero
numerator, is zero whatever the other operand is. The certified context
RationalInterval.CertifiedEvalContext.eval runs this evaluation on one
FloatLib backend whose elementary settings come from the precision policy.
Division uses either a denominator interval excluding zero or, on a second
attempt, a certified positive lower bound for the actual denominator's
absolute value, through the fresh reciprocal variable w=d^{-1}. FloatLib
computes the ranges of the unary operations from the intervals of their
arguments, so the context needs no facts about them. A failed subevaluation
propagates none. The standard calls for \pi and \mathrm e run at the
precision setting 128.
Direct FloatLib execution.
FloatLib provides Backend.rational for rational endpoints,
Backend.binaryGrid for integer endpoints on a specified binary grid, and
Backend.ofRounding for a supplied outward rounder. The latter computes
rational elementary bounds and rounds them into the chosen endpoint
representation. Decoding failures, rejected domains, and unrepresentable
bounds propagate as none. These are upstream types and operations.
The binaryGrid representation uses scaled integers on a binary grid; it is
not an IEEE format. FloatLib's certified IEEE binary32 operations form a
separate facility, and the concrete CEGA backend used by the command and
tactic is rational. The generic expression translation and rounding interface
can connect another backend once its operations and containment proofs are
supplied.
For quadrature or a Taylor model, the numerical enclosure must refer to the same exact-real rule or polynomial as the analytic certificate. Its radius then bounds replacement by the interval midpoint, including any outward rounding. Adding that radius to the analytic remainder gives the total error. An enclosure alone supplies neither differentiability nor a quadrature remainder; CEGA's analytic theorems retain those hypotheses.
A certified enclosure.
The command asks for a uniform cosine enclosure on a rational panel:
-- Prove one interval enclosure uniformly
-- over the whole input panel.
set_option linter.hashCommand false in
#cas [enclose x in [-1 / 10, 1 / 10]] (cos x)
If the query succeeds with rational endpoints a,b, its mathematical
meaning is
\forall x\in[-1/10,1/10],\qquad a\leq\cos x\leq b.
FloatLib computes interval multiplication as the exact four-corner product.
For rational panels
I=[a,b] and J=[c,d] the product panel has endpoints
\min(ac,ad,bc,bd) and \max(ac,ad,bc,bd), which is sharp for
independent factors in every sign configuration; on x\in[-1,2],
y\in[2,3] it gives [-3,6] where a symmetric magnitude bound gives
[-6,6].
x\in I\ \land\ y\in J
\quad\Longrightarrow\quad
xy\in I\cdot J.
Lean code for Theorem10.43●1 theoremAssociated Lean declarationsCAS.Continuum.RationalInterval.mul_sound[complete]
CAS.Continuum.RationalInterval.mul_sound[complete]
- theoremdefined in CAS/Continuum/Interval/Rational/Arithmetic.leancomplete
theorem CAS.Continuum.RationalInterval.mul_sound {I J : CAS.Continuum.RationalInterval} {x y : ℝ} (hx : I.MemReal x) (hy : J.MemReal y) : (I.mul J).MemReal (x * y)
theorem CAS.Continuum.RationalInterval.mul_sound {I J : CAS.Continuum.RationalInterval} {x y : ℝ} (hx : I.MemReal x) (hy : J.MemReal y) : (I.mul J).MemReal (x * y)
Multiplication contains the product of any two contained real values.
The interval product bound follows from FloatLib's multiplication theorem.
To see why the four corners suffice, fix the sign of y. Multiplication
by y is then monotone or antitone, so
xy lies between ay and by. Each of these is a fixed factor times a
value between c and d, hence lies between the two corner products with
that factor. Both bounds are therefore between the minimum and the maximum of
the four corners.
For every rational panel I and every requested order, expRangeWith
contains \exp x whenever x\in I. The implementation passes
\max(\mathrm{order},1) to FloatLib's expBounds, and the automatic
expRange uses degree 8. Positive, negative, and zero-crossing input
panels all satisfy the same theorem.
Lean code for Theorem10.44●2 theoremsAssociated Lean declarations
- theoremdefined in CAS/Continuum/Interval/Elementary/Exp.leancomplete
theorem CAS.Continuum.RationalInterval.expRange_sound (I : CAS.Continuum.RationalInterval) {x : ℝ} (hx : I.MemReal x) : I.expRange.MemReal (Real.exp x)
theorem CAS.Continuum.RationalInterval.expRange_sound (I : CAS.Continuum.RationalInterval) {x : ℝ} (hx : I.MemReal x) : I.expRange.MemReal (Real.exp x)
expRange IcontainsReal.exp xfor everyx ∈ I. - theoremdefined in CAS/Continuum/Interval/Elementary/Exp.leancomplete
theorem CAS.Continuum.RationalInterval.expRangeWith_sound (I : CAS.Continuum.RationalInterval) (order : ℕ) {x : ℝ} (hx : I.MemReal x) : (I.expRangeWith order).MemReal (Real.exp x)
theorem CAS.Continuum.RationalInterval.expRangeWith_sound (I : CAS.Continuum.RationalInterval) (order : ℕ) {x : ℝ} (hx : I.MemReal x) : (I.expRangeWith order).MemReal (Real.exp x)
expRangeWith I ordercontainsReal.exp xfor everyx ∈ I.
FloatLib's pointwise exponential bound encloses the exponential of the reduced argument;
repeated squaring transports that bound through
\exp q=(\exp(q/2^s))^{2^s}, and monotonicity covers the panel.
Attaching the order proof and translating containment back to MemReal
preserves the resulting inequalities.
For every rational panel I=[\ell,h] with 0<\ell, logRangeWith
contains \log x whenever x\in I. It calls FloatLib's logBounds?
with degree 2\max(\mathrm{terms},1). The positivity proof ensures that
the upstream optional routine succeeds. The default request is 10, hence
FloatLib degree 20.
Lean code for Theorem10.45●3 theoremsAssociated Lean declarations
- theoremdefined in CAS/Continuum/Interval/Elementary/Log.leancomplete
theorem CAS.Continuum.RationalInterval.logRange_sound (I : CAS.Continuum.RationalInterval) (hpos : 0 < I.lo) {x : ℝ} (hx : I.MemReal x) : (I.logRange hpos).MemReal (Real.log x)
theorem CAS.Continuum.RationalInterval.logRange_sound (I : CAS.Continuum.RationalInterval) (hpos : 0 < I.lo) {x : ℝ} (hx : I.MemReal x) : (I.logRange hpos).MemReal (Real.log x)
logRange I hposcontainsReal.log xfor everyx ∈ I. - theoremdefined in CAS/Continuum/Interval/Elementary/Log.leancomplete
theorem CAS.Continuum.RationalInterval.logRangeWith_sound (I : CAS.Continuum.RationalInterval) (terms : ℕ) (hpos : 0 < I.lo) {x : ℝ} (hx : I.MemReal x) : (I.logRangeWith terms hpos).MemReal (Real.log x)
theorem CAS.Continuum.RationalInterval.logRangeWith_sound (I : CAS.Continuum.RationalInterval) (terms : ℕ) (hpos : 0 < I.lo) {x : ℝ} (hx : I.MemReal x) : (I.logRangeWith terms hpos).MemReal (Real.log x)
logRangeWith I terms hposcontainsReal.log xfor everyx ∈ I. - theoremdefined in CAS/Continuum/Interval/Elementary/Log.leancomplete
theorem CAS.Continuum.RationalInterval.logPointIntervalWith_sound (terms : ℕ) (q : ℚ) (hq : 0 < q) : (CAS.Continuum.RationalInterval.logPointIntervalWith terms q hq).MemReal (Real.log ↑q)
theorem CAS.Continuum.RationalInterval.logPointIntervalWith_sound (terms : ℕ) (q : ℚ) (hq : 0 < q) : (CAS.Continuum.RationalInterval.logPointIntervalWith terms q hq).MemReal (Real.log ↑q)
logPointIntervalWith terms q hqcontainsReal.log q.
The positive lower endpoint establishes the domain condition. The two
logarithm series and their geometric tails
bound \log(1+t)-\log(1-t); binary scaling and, for inputs below one,
reciprocation restore the original argument. Monotonicity lifts the point
bounds to the whole positive panel.
For every rational panel and every binary precision s, sqrtRangeInterval
contains Mathlib's total real square root throughout the panel. At a
nonnegative endpoint q=n/d in lowest terms, the point enclosure has width
at most 1/(d2^s) and is exact when its lower endpoint squares to q.
Negative endpoints map to zero. The default precision is 12 binary digits.
Lean code for Theorem10.46●4 theoremsAssociated Lean declarations
- theoremdefined in CAS/Continuum/Interval/Elementary/Sqrt.leancomplete
theorem CAS.Continuum.RationalInterval.sqrtNonnegativePointInterval_sound (q : ℚ) (hq : 0 ≤ q) (steps : ℕ) : (CAS.Continuum.RationalInterval.sqrtNonnegativePointInterval q hq steps).MemReal √↑q
theorem CAS.Continuum.RationalInterval.sqrtNonnegativePointInterval_sound (q : ℚ) (hq : 0 ≤ q) (steps : ℕ) : (CAS.Continuum.RationalInterval.sqrtNonnegativePointInterval q hq steps).MemReal √↑q
sqrtNonnegativePointInterval q hq stepscontainsReal.sqrt q. - theoremdefined in CAS/Continuum/Interval/Elementary/Sqrt.leancomplete
theorem CAS.Continuum.RationalInterval.sqrtNonnegativePointInterval_width_le (q : ℚ) (hq : 0 ≤ q) (steps : ℕ) : (CAS.Continuum.RationalInterval.sqrtNonnegativePointInterval q hq steps).hi - (CAS.Continuum.RationalInterval.sqrtNonnegativePointInterval q hq steps).lo ≤ 1 / (↑q.den * 2 ^ steps)
theorem CAS.Continuum.RationalInterval.sqrtNonnegativePointInterval_width_le (q : ℚ) (hq : 0 ≤ q) (steps : ℕ) : (CAS.Continuum.RationalInterval.sqrtNonnegativePointInterval q hq steps).hi - (CAS.Continuum.RationalInterval.sqrtNonnegativePointInterval q hq steps).lo ≤ 1 / (↑q.den * 2 ^ steps)
The enclosure of
√qhas width at most1 / (q.den * 2 ^ steps). - theoremdefined in CAS/Continuum/Interval/Elementary/Sqrt.leancomplete
theorem CAS.Continuum.RationalInterval.sqrtRangeInterval_sound (I : CAS.Continuum.RationalInterval) (steps : ℕ) {x : ℝ} (hx : I.MemReal x) : (I.sqrtRangeInterval steps).MemReal √x
theorem CAS.Continuum.RationalInterval.sqrtRangeInterval_sound (I : CAS.Continuum.RationalInterval) (steps : ℕ) {x : ℝ} (hx : I.MemReal x) : (I.sqrtRangeInterval steps).MemReal √x
sqrtRangeInterval I stepscontainsReal.sqrt xfor everyx ∈ I. - theoremdefined in CAS/Continuum/Interval/Elementary/Sqrt.leancomplete
theorem CAS.Continuum.RationalInterval.sqrtRange_sound (I : CAS.Continuum.RationalInterval) {x : ℝ} (hx : I.MemReal x) : I.sqrtRange.MemReal √x
theorem CAS.Continuum.RationalInterval.sqrtRange_sound (I : CAS.Continuum.RationalInterval) {x : ℝ} (hx : I.MemReal x) : I.sqrtRange.MemReal √x
sqrtRange IcontainsReal.sqrt xfor everyx ∈ I.
FloatLib proves both containment and the width bound for its integer-root
enclosure. Since d>0, division by d preserves the endpoint order, and
\sqrt{qd^2}=d\sqrt q gives the desired point enclosure. For negative
arguments, Mathlib's square root is zero. Apply monotonicity of this total
function to the two endpoint certificates to enclose the full panel.
For every rational panel, atanRange contains the real arctangent throughout
that panel. It uses FloatLib's atanBounds with parameter 16, and no
sign restriction on the input panel is needed.
Lean code for Theorem10.47●1 theoremAssociated Lean declarations
- theoremdefined in CAS/Continuum/Interval/Elementary/Atan.leancomplete
theorem CAS.Continuum.RationalInterval.atanRange_sound (I : CAS.Continuum.RationalInterval) {x : ℝ} (hx : I.MemReal x) : I.atanRange.MemReal (Real.arctan x)
theorem CAS.Continuum.RationalInterval.atanRange_sound (I : CAS.Continuum.RationalInterval) {x : ℝ} (hx : I.MemReal x) : I.atanRange.MemReal (Real.arctan x)
atanRange IcontainsReal.arctan xfor everyx ∈ I.
FloatLib's pointwise arctangent bound transports the
small-argument series bounds through the arctangent identities, using a
certified Machin enclosure for \pi/4. Monotonicity then combines the lower
bound at the left endpoint with the upper bound at the right endpoint.
For every rational panel, the sine and cosine ranges contain all real
function values on it. The base ranges are FloatLib's degree-32 bounds;
CEGA intersects them with endpoint or sign bounds when the panel satisfies a
proved principal-branch condition.
Lean code for Theorem10.48●4 theoremsAssociated Lean declarations
- theoremdefined in CAS/Continuum/Interval/Elementary/Trig.leancomplete
theorem CAS.Continuum.RationalInterval.sinBase_sound {I : CAS.Continuum.RationalInterval} {x : ℝ} (hx : I.MemReal x) : I.sinBase.MemReal (Real.sin x)
theorem CAS.Continuum.RationalInterval.sinBase_sound {I : CAS.Continuum.RationalInterval} {x : ℝ} (hx : I.MemReal x) : I.sinBase.MemReal (Real.sin x)
sinBase IcontainsReal.sin xfor everyx ∈ I. - theoremdefined in CAS/Continuum/Interval/Elementary/Trig.leancomplete
theorem CAS.Continuum.RationalInterval.cosBase_sound {I : CAS.Continuum.RationalInterval} {x : ℝ} (hx : I.MemReal x) : I.cosBase.MemReal (Real.cos x)
theorem CAS.Continuum.RationalInterval.cosBase_sound {I : CAS.Continuum.RationalInterval} {x : ℝ} (hx : I.MemReal x) : I.cosBase.MemReal (Real.cos x)
cosBase IcontainsReal.cos xfor everyx ∈ I. - theoremdefined in CAS/Continuum/Interval/Elementary/Trig.leancomplete
theorem CAS.Continuum.RationalInterval.sin_sound {I : CAS.Continuum.RationalInterval} {x : ℝ} (hx : I.MemReal x) : I.sin.MemReal (Real.sin x)
theorem CAS.Continuum.RationalInterval.sin_sound {I : CAS.Continuum.RationalInterval} {x : ℝ} (hx : I.MemReal x) : I.sin.MemReal (Real.sin x)
I.sincontainsReal.sin xfor everyx ∈ I. - theoremdefined in CAS/Continuum/Interval/Elementary/Trig.leancomplete
theorem CAS.Continuum.RationalInterval.cos_sound {I : CAS.Continuum.RationalInterval} {x : ℝ} (hx : I.MemReal x) : I.cos.MemReal (Real.cos x)
theorem CAS.Continuum.RationalInterval.cos_sound {I : CAS.Continuum.RationalInterval} {x : ℝ} (hx : I.MemReal x) : I.cos.MemReal (Real.cos x)
I.coscontainsReal.cos xfor everyx ∈ I.
FloatLib's sine and cosine bounds include the error introduced by period
reduction. If m is the
midpoint, r the panel radius, and [a,b] contains f(m), the
one-Lipschitz estimate gives f(x)\in[a-r,b+r] for every panel member.
For each accepted branch test, monotonicity and symmetry justify endpoint
bounds from the same FloatLib point enclosures; a proved sign permits clamping
at zero. Each intersection contains the exact function value, so the final
interval retains the containment theorem.
For a rational box B=I_1\times\cdots\times I_n with midpoint m and a
function differentiable on the box, the mean value theorem in centered form
gives
f(x)=f(m)+\sum_{i=1}^{n}\partial_i f(c)\,(x_i-m_i)
\qquad\text{for some }c\text{ on the segment from }m\text{ to }x,
so that f(B)\subseteq f(m)+\sum_i \partial_i f(B)\,(I_i-m_i); a coordinate
whose panel is a single point contributes nothing. For a symbolic expression,
the checked route first certifies analytic validity throughout the box. It
encloses the midpoint value and the symbolic partial derivatives, then adds
the interval products with I_i-m_i. In one dimension, if J_0 encloses
f(m) and D encloses f' on I, the result is
J_0+D(I-m), with width
\mathrm{width}(J_0)+2\,\mathrm{radius}(I)\max(|\inf D|,|\sup D|).
This can improve the natural extension without a fixed derivative sign;
the midpoint error and derivative magnitude determine the gain.
The companion monotonicity route works coordinatewise on the same boxes: when
a partial derivative \partial_i f keeps one sign on B, every value of
f lies in the hull of the enclosures of f on the two faces
x_i=\min I_i and x_i=\max I_i, and one planner level nests up to n
such face reductions. On [1,2]^2, direct interval substitution in xy-x
gives [1,4]-[1,2]=[-1,3]. As a hand calculation, the factorization
x(y-1) makes the exact range [0,2] visible; likewise,
xyz-xy=xy(z-1) has exact range [0,4] on [1,2]^3.
Previews rank candidate routes by width, endpoint magnitude, and route length,
after any correlated hyperbolic enclosure; the selected route must still
construct its certificate, with fallback on failure.
Lean code for Theorem10.49●2 declarationsAssociated Lean declarations
- theoremdefined in CAS/Continuum/IntervalEval/Registry/CenteredForm.leancomplete
theorem CAS.Continuum.RationalInterval.CertifiedEvalRegistry.exists_eq_add_deriv_mul_sub {f f' : ℝ → ℝ} {a b : ℝ} (hcont : ContinuousOn f (Set.Icc a b)) (hderiv : ∀ x ∈ Set.Icc a b, HasDerivAt f (f' x) x) {m x : ℝ} (hm : m ∈ Set.Icc a b) (hx : x ∈ Set.Icc a b) : ∃ c ∈ Set.Icc a b, f x = f m + f' c * (x - m)
theorem CAS.Continuum.RationalInterval.CertifiedEvalRegistry.exists_eq_add_deriv_mul_sub {f f' : ℝ → ℝ} {a b : ℝ} (hcont : ContinuousOn f (Set.Icc a b)) (hderiv : ∀ x ∈ Set.Icc a b, HasDerivAt f (f' x) x) {m x : ℝ} (hm : m ∈ Set.Icc a b) (hx : x ∈ Set.Icc a b) : ∃ c ∈ Set.Icc a b, f x = f m + f' c * (x - m)
The mean value theorem in centered form: on a closed interval, a differentiable function satisfies
f x = f m + f' c · (x - m)for somecin the interval. - defdefined in CAS/Continuum/IntervalEval/Registry/CenteredForm.leancomplete
def CAS.Continuum.RationalInterval.CertifiedEvalRegistry.centeredFormEnclosureAttempt? {n : ℕ} (precision : CAS.Continuum.RationalInterval.Precision) (box : Fin n → CAS.Continuum.RationalInterval) (expr : CAS.Verified.Expr (Fin n)) : Option (CAS.Continuum.RationalInterval.EnclosureAttempt (ℝ^n) (CAS.Continuum.RationalInterval.boxDomain box) fun x ↦ CAS.Verified.Expr.eval (fun j ↦ x.ofLp j) expr)
def CAS.Continuum.RationalInterval.CertifiedEvalRegistry.centeredFormEnclosureAttempt? {n : ℕ} (precision : CAS.Continuum.RationalInterval.Precision) (box : Fin n → CAS.Continuum.RationalInterval) (expr : CAS.Verified.Expr (Fin n)) : Option (CAS.Continuum.RationalInterval.EnclosureAttempt (ℝ^n) (CAS.Continuum.RationalInterval.boxDomain box) fun x ↦ CAS.Verified.Expr.eval (fun j ↦ x.ofLp j) expr)
Try to certify a box range by the centered form
f(B) ⊆ f(m) + Σᵢ ∂ᵢf(B) · (Bᵢ - mᵢ).Every ingredient is a checked certificate; the route selection inside the derivative planner is untrusted and only decides which certificates are built.
The box is convex, so the segment from the midpoint m to x stays in it;
apply the mean value theorem to t\mapsto f(m+t(x-m)) on [0,1], whose
derivative is the Fréchet derivative of f applied to x-m, that is the sum
of the partial derivatives weighted by the coordinate offsets, to obtain the
intermediate point c. Interval soundness of the midpoint evaluation, of each
partial-derivative enclosure at c, and of the products with I_i-m_i then
places f(x) in the assembled box. For the face reduction, a one-signed
partial derivative makes t\mapsto f(x+t e_i) monotone on the segment across
the box, so f(x) lies between the values at the two faces, hence in the hull
of their enclosures.
A Precision value bundles three requests for FloatLib-backed elementary
ranges and a depth for checked box refinement:
(\mathrm{expOrder},\ \mathrm{sqrtDigits},\ \mathrm{logTerms},\ \mathrm{depth})
\quad\text{with defaults}\quad(8,\ 12,\ 10,\ 2).
expOrder supplies FloatLib's exponential degree after promotion of zero to
one. sqrtDigits sets the binary grid for the denominator-scaled square-root
bounds. logTerms maps to FloatLib degree 2\max(\mathrm{logTerms},1).
The sine, cosine, and arctangent adapters use their own fixed parameters.
The configuration group (prec := n) sets the first three fields to n;
(depth := n) sets the subdivision depth. An omitted policy uses the defaults.
The policy is planner data. Every range theorem holds for all parameter values, so changing the policy preserves soundness while affecting cost and potential sharpness. The final width also depends on input variation, dependence between subexpressions, and period uncertainty, any of which can dominate the error.
Lean code for Definition10.50●3 definitionsAssociated Lean declarations
- structuredefined in CAS/Continuum/IntervalEval/Planning/Precision.leancomplete
structure CAS.Continuum.RationalInterval.Precision : Type
structure CAS.Continuum.RationalInterval.Precision : Type
Numerical precision policy for automatic interval compilation.
The defaults use exponential Taylor order 8, square roots with 12 binary digits, 10 logarithm series terms, and subdivision depth 2.
Fields
expOrder : ℕ
Taylor order for exponential and hyperbolic ranges; zero is promoted to one.
sqrtDigits : ℕ
Binary digits of square-root enclosures.
logTerms : ℕ
Series terms for logarithm ranges, run by FloatLib at degree
2 * max logTerms 1.depth : ℕ
Number of checked bisection levels used by subdivided enclosures.
digits : Option ℕ
Requested decimal digits. When set, box enclosures first try the precision-parametric evaluator
DigitsEval.evalat the working precisionDigitsEval.precisionFor digits. - defdefined in CAS/Continuum/IntervalEval/Planning/Precision.leancomplete
def CAS.Continuum.RationalInterval.Precision.withPrec (policy : CAS.Continuum.RationalInterval.Precision) (prec : ℕ) : CAS.Continuum.RationalInterval.Precision
def CAS.Continuum.RationalInterval.Precision.withPrec (policy : CAS.Continuum.RationalInterval.Precision) (prec : ℕ) : CAS.Continuum.RationalInterval.Precision
The policy that requests the Taylor order
precforexp,precseries terms forlog, andprecbinary digits for square roots, keeping the subdivision depth and thedigitsrequest. - defdefined in CAS/Continuum/IntervalEval/Planning/Precision.leancomplete
def CAS.Continuum.RationalInterval.Precision.withDepth (policy : CAS.Continuum.RationalInterval.Precision) (depth : ℕ) : CAS.Continuum.RationalInterval.Precision
def CAS.Continuum.RationalInterval.Precision.withDepth (policy : CAS.Continuum.RationalInterval.Precision) (depth : ℕ) : CAS.Continuum.RationalInterval.Precision
The policy with a requested subdivision depth.
CAS.Continuum.CEGAInclusion.mem_liftUnary[complete]CAS.Continuum.CEGAInclusion.div_mem[complete]CAS.Continuum.CEGAInclusion.exp_mem[complete]CAS.Continuum.CEGAInclusion.log_mem[complete]CAS.Continuum.CEGAInclusion.sqrt_mem[complete]CAS.Continuum.CEGAInclusion.sin_mem[complete]CAS.Continuum.CEGAInclusion.cos_mem[complete]
Mathlib's dyadic_interval tactic evaluates a real proposition over intervals
with dyadic endpoints and checks the outcome in the kernel. The cega_real
family adds CEGA's ranges to it: quotients, natural powers, \pi, the
exponential, the logarithm, the square root, the trigonometric and inverse
trigonometric functions, and the hyperbolic functions. A bounded dyadic
interval I has rational endpoints, so it passes unchanged to a CEGA range
F, and the rational interval F(I) is rounded outward to the grid
2^{-p}, where p is the tactic's prec parameter. If x\in I, then
f(x) lies in the rounded interval. An unbounded argument, and a reciprocal
or logarithm whose argument interval contains zero, give a range that holds
for every real input: [-1,1] for sine and cosine, [0,\infty) for the
exponential and the square root, and the whole line otherwise. The Taylor
order of the exponential family and the series length of the logarithm are
at least p/2, and the square root keeps at least p+4 binary digits.
The \pi bracket and the trigonometric and inverse-trigonometric series use
fixed parameters; increasing p refines their outward rounding but does not
refine those underlying rational ranges.
Bare cega runs this evaluation with p=32 on a goal without free
variables that its carrier and box routes do not prove, such as a
conjunction, a disjunction, a negation, an interval membership or an
equality of real constants.
Lean code for Theorem10.51●7 theoremsAssociated Lean declarationsCAS.Continuum.CEGAInclusion.mem_liftUnary[complete]CAS.Continuum.CEGAInclusion.div_mem[complete]CAS.Continuum.CEGAInclusion.exp_mem[complete]CAS.Continuum.CEGAInclusion.log_mem[complete]CAS.Continuum.CEGAInclusion.sqrt_mem[complete]CAS.Continuum.CEGAInclusion.sin_mem[complete]CAS.Continuum.CEGAInclusion.cos_mem[complete]
CAS.Continuum.CEGAInclusion.mem_liftUnary[complete]CAS.Continuum.CEGAInclusion.div_mem[complete]CAS.Continuum.CEGAInclusion.exp_mem[complete]CAS.Continuum.CEGAInclusion.log_mem[complete]CAS.Continuum.CEGAInclusion.sqrt_mem[complete]CAS.Continuum.CEGAInclusion.sin_mem[complete]CAS.Continuum.CEGAInclusion.cos_mem[complete]
- theoremdefined in CAS/Continuum/Interval/Inclusion/Basic.leancomplete
theorem CAS.Continuum.CEGAInclusion.mem_liftUnary {g : ℝ → ℝ} {f : FloatLib.Numerics.Interval ℚ → Option (FloatLib.Numerics.Interval ℚ)} (hf : ∀ {J K : FloatLib.Numerics.Interval ℚ} {x : ℝ}, f J = some K → FloatLib.Numerics.Interval.ContainsReal some J x → FloatLib.Numerics.Interval.ContainsReal some K (g x)) {fallback : Inclusion.Interval Dyadic} (hfallback : ∀ (x : ℝ), g x ∈ fallback) {x : ℝ} {I : Inclusion.Interval Dyadic} (hx : x ∈ I) (prec : ℕ) : g x ∈ CAS.Continuum.CEGAInclusion.liftUnary f fallback I prec
theorem CAS.Continuum.CEGAInclusion.mem_liftUnary {g : ℝ → ℝ} {f : FloatLib.Numerics.Interval ℚ → Option (FloatLib.Numerics.Interval ℚ)} (hf : ∀ {J K : FloatLib.Numerics.Interval ℚ} {x : ℝ}, f J = some K → FloatLib.Numerics.Interval.ContainsReal some J x → FloatLib.Numerics.Interval.ContainsReal some K (g x)) {fallback : Inclusion.Interval Dyadic} (hfallback : ∀ (x : ℝ), g x ∈ fallback) {x : ℝ} {I : Inclusion.Interval Dyadic} (hx : x ∈ I) (prec : ℕ) : g x ∈ CAS.Continuum.CEGAInclusion.liftUnary f fallback I prec
If
fenclosesgon rational intervals andfallbackcontains every value ofg, then the lifted range enclosesgon dyadic intervals. - theoremdefined in CAS/Continuum/Interval/Inclusion/Elementary.leancomplete
theorem CAS.Continuum.CEGAInclusion.div_mem {x y : ℝ} {I J : Inclusion.Interval Dyadic} (hx : x ∈ I) (hy : y ∈ J) (prec : ℕ) : x / y ∈ I.mul (CAS.Continuum.CEGAInclusion.liftUnary CAS.Continuum.CEGAInclusion.invRange? (Inclusion.Interval.univ Dyadic) J prec)
theorem CAS.Continuum.CEGAInclusion.div_mem {x y : ℝ} {I J : Inclusion.Interval Dyadic} (hx : x ∈ I) (hy : y ∈ J) (prec : ℕ) : x / y ∈ I.mul (CAS.Continuum.CEGAInclusion.liftUnary CAS.Continuum.CEGAInclusion.invRange? (Inclusion.Interval.univ Dyadic) J prec)
A quotient is the product with the reciprocal range.
- theoremdefined in CAS/Continuum/Interval/Inclusion/Elementary.leancomplete
theorem CAS.Continuum.CEGAInclusion.exp_mem {x : ℝ} {I : Inclusion.Interval Dyadic} (hx : x ∈ I) (prec : ℕ) : Real.exp x ∈ CAS.Continuum.CEGAInclusion.liftElementary FloatLib.Numerics.Interval.UnaryOp.exp (CAS.Continuum.CEGAInclusion.atLeast 0) I prec
theorem CAS.Continuum.CEGAInclusion.exp_mem {x : ℝ} {I : Inclusion.Interval Dyadic} (hx : x ∈ I) (prec : ℕ) : Real.exp x ∈ CAS.Continuum.CEGAInclusion.liftElementary FloatLib.Numerics.Interval.UnaryOp.exp (CAS.Continuum.CEGAInclusion.atLeast 0) I prec
The exponential range of
I, with[0, ∞)as the unbounded-input fallback. - theoremdefined in CAS/Continuum/Interval/Inclusion/Elementary.leancomplete
theorem CAS.Continuum.CEGAInclusion.log_mem {x : ℝ} {I : Inclusion.Interval Dyadic} (hx : x ∈ I) (prec : ℕ) : Real.log x ∈ CAS.Continuum.CEGAInclusion.liftElementary FloatLib.Numerics.Interval.UnaryOp.log (Inclusion.Interval.univ Dyadic) I prec
theorem CAS.Continuum.CEGAInclusion.log_mem {x : ℝ} {I : Inclusion.Interval Dyadic} (hx : x ∈ I) (prec : ℕ) : Real.log x ∈ CAS.Continuum.CEGAInclusion.liftElementary FloatLib.Numerics.Interval.UnaryOp.log (Inclusion.Interval.univ Dyadic) I prec
The total logarithm range of
I, with the whole line as the fallback on an interval that contains zero and another point. - theoremdefined in CAS/Continuum/Interval/Inclusion/Elementary.leancomplete
theorem CAS.Continuum.CEGAInclusion.sqrt_mem {x : ℝ} {I : Inclusion.Interval Dyadic} (hx : x ∈ I) (prec : ℕ) : √x ∈ CAS.Continuum.CEGAInclusion.liftElementary FloatLib.Numerics.Interval.UnaryOp.sqrt (CAS.Continuum.CEGAInclusion.atLeast 0) I prec
theorem CAS.Continuum.CEGAInclusion.sqrt_mem {x : ℝ} {I : Inclusion.Interval Dyadic} (hx : x ∈ I) (prec : ℕ) : √x ∈ CAS.Continuum.CEGAInclusion.liftElementary FloatLib.Numerics.Interval.UnaryOp.sqrt (CAS.Continuum.CEGAInclusion.atLeast 0) I prec
The total square-root range of
I, including Mathlib's zero values below zero. - theoremdefined in CAS/Continuum/Interval/Inclusion/Elementary.leancomplete
theorem CAS.Continuum.CEGAInclusion.sin_mem {x : ℝ} {I : Inclusion.Interval Dyadic} (hx : x ∈ I) (prec : ℕ) : Real.sin x ∈ CAS.Continuum.CEGAInclusion.liftElementary FloatLib.Numerics.Interval.UnaryOp.sin (CAS.Continuum.CEGAInclusion.closed (-1) 1) I prec
theorem CAS.Continuum.CEGAInclusion.sin_mem {x : ℝ} {I : Inclusion.Interval Dyadic} (hx : x ∈ I) (prec : ℕ) : Real.sin x ∈ CAS.Continuum.CEGAInclusion.liftElementary FloatLib.Numerics.Interval.UnaryOp.sin (CAS.Continuum.CEGAInclusion.closed (-1) 1) I prec
The sharp sine range of
I, with the global bound[-1, 1]for unbounded inputs. - theoremdefined in CAS/Continuum/Interval/Inclusion/Elementary.leancomplete
theorem CAS.Continuum.CEGAInclusion.cos_mem {x : ℝ} {I : Inclusion.Interval Dyadic} (hx : x ∈ I) (prec : ℕ) : Real.cos x ∈ CAS.Continuum.CEGAInclusion.liftElementary FloatLib.Numerics.Interval.UnaryOp.cos (CAS.Continuum.CEGAInclusion.closed (-1) 1) I prec
theorem CAS.Continuum.CEGAInclusion.cos_mem {x : ℝ} {I : Inclusion.Interval Dyadic} (hx : x ∈ I) (prec : ℕ) : Real.cos x ∈ CAS.Continuum.CEGAInclusion.liftElementary FloatLib.Numerics.Interval.UnaryOp.cos (CAS.Continuum.CEGAInclusion.closed (-1) 1) I prec
The sharp cosine range of
I, with the global bound[-1, 1]for unbounded inputs.
The rational interval with the endpoints of I contains x, so the CEGA
soundness theorem places f(x) in F(I), and outward rounding only
enlarges F(I). The global ranges follow from -1\le\sin x\le 1,
0<e^x, 0\le\sqrt x, \lvert\arctan x\rvert<\pi/2\le 2 and the
corresponding bounds for \arcsin, \arccos, \cosh and \tanh.
Mathlib's inclusion tactic composes these one-step facts along the
expression tree.
10.7.3. Taylor Models
Taylor models combine a finite polynomial with a uniform remainder theorem on an explicit interval. We keep three errors distinct: analytic truncation, uncertainty in the polynomial coefficients, and any roundoff used to evaluate the polynomial. A final certificate may add them, and each is bounded by its own theorem.
We return to the rational function used in the interval-enclosure figure. Subdivision narrowed the input intervals; a retained polynomial keeps algebraic dependence that a single interval would discard. The remainder panel uses its own vertical scale, making the difference visible even where the function and polynomial nearly coincide. A model needs a uniform bound on that difference throughout the stated interval; agreement at sampled points alone cannot supply it.
Uniform approximation of values does not by itself certify derivatives.
For \varepsilon>0 and k>0, the smooth error
e(x)=\varepsilon\sin(kx) obeys
|e(x)|\leq\varepsilon, while |e'(0)|=\varepsilon k can be as
large as we choose. Consequently, differentiating the polynomial in a model
does not automatically give an equally accurate model of the derivative.
For a PDE residual involving derivatives, we need certificates for those
derivatives or a direct residual certificate, with the analytic regularity
needed to interpret them. The derivative-bound and symbolic-calculus results
supply these alongside the value models.
A concrete polynomial and remainder for the exponential.
FloatLib's small-argument exponential theorem gives a direct example of
analytic truncation. For a rational q with |q|\leq1, choose a degree
d\in\mathbb N and put n=d+1. Its polynomial and radius are
T_n(q)=\sum_{k<n}\frac{q^k}{k!},
\qquad
R_n(q)=\frac{|q|^n\,(n+1)}{n!\,n}.
Both are exact rationals. As a hand specialization, d=2 gives n=3,
T_3(q)=1+q+q^2/2, and R_3(q)=2|q|^3/9\leq2/9. The radius bounds the
truncation error at rational points with |q|\leq1; the general Taylor-model
constructors supply uniform approximation certificates from derivative bounds
at arbitrary real inputs.
A model-approximation certificate records an original function, a reference
function, model-order metadata, an error budget, and the proved uniform error
estimate. Writing its source as f, its model as p, its domain as S,
and its error as \varepsilon, the trusted field is
\forall x\in S,\qquad \lVert f(x)-p(x)\rVert\leq\varepsilon.
The stored order does not occur in this proposition; it is metadata. A supplied model need not be a Taylor polynomial or have a finite-dimensional representation, and such structure requires a separate construction.
Lean code for Definition10.52●1 definitionAssociated Lean declarationsCAS.Certificate.ModelApproxCert[complete]
CAS.Certificate.ModelApproxCert[complete]
- structuredefined in CAS/Certificate/ModelApproximation.leancomplete
structure CAS.Certificate.ModelApproxCert.{u_1, u_2} (α : Type u_1) (E : Type u_2) [NormedAddCommGroup E] (patch : Set α) : Type (max u_1 u_2)
structure CAS.Certificate.ModelApproxCert.{u_1, u_2} (α : Type u_1) (E : Type u_2) [NormedAddCommGroup E] (patch : Set α) : Type (max u_1 u_2)
A checked uniform approximation with model-order metadata.
The field
modelOrderis an unconstrained label recording how the model was constructed; onlytoApproxCertcarries a proof.Fields
toApproxCert : CAS.Certificate.ApproxCert α E patch
Canonical approximation certificate from the source function to the reference function.
modelOrder : ℕ
Model order, a label without proof obligation (for a Taylor model, its order).
For every rational q with |q|\leq1 and every degree d, FloatLib's
expSmall q d encloses \exp q. With n=d+1, the polynomial
T_n(q) has absolute error at most R_n(q), so the real exponential lies
between the exact rational endpoints T_n(q)-R_n(q) and T_n(q)+R_n(q).
Lean code for Theorem10.53●2 theoremsAssociated Lean declarations
- theoremdefined in FloatLib/Numerics/Enclosure/Elementary/Proof.leancomplete
theorem FloatLib.Numerics.Enclosure.abs_exp_sub_expTaylor_le (x : ℚ) (degree : ℕ) (hx : |x| ≤ 1) : |Real.exp ↑x - ↑(FloatLib.Numerics.Enclosure.expTaylor x (degree + 1))| ≤ ↑(FloatLib.Numerics.Enclosure.expRadius x (degree + 1))
theorem FloatLib.Numerics.Enclosure.abs_exp_sub_expTaylor_le (x : ℚ) (degree : ℕ) (hx : |x| ≤ 1) : |Real.exp ↑x - ↑(FloatLib.Numerics.Enclosure.expTaylor x (degree + 1))| ≤ ↑(FloatLib.Numerics.Enclosure.expRadius x (degree + 1))
The executable exponential polynomial satisfies its computed absolute-error bound.
- theoremdefined in FloatLib/Numerics/Enclosure/Elementary/Proof.leancomplete
theorem FloatLib.Numerics.Enclosure.contains_expSmall (x : ℚ) (degree : ℕ) (hx : |x| ≤ 1) : (FloatLib.Numerics.Enclosure.expSmall x degree).Contains (Real.exp ↑x)
theorem FloatLib.Numerics.Enclosure.contains_expSmall (x : ℚ) (degree : ℕ) (hx : |x| ≤ 1) : (FloatLib.Numerics.Enclosure.expSmall x degree).Contains (Real.exp ↑x)
Taylor truncation and its rational remainder bound enclose the small exponential.
FloatLib identifies its rational Taylor sum and error radius with their real
counterparts, then applies Mathlib's Real.exp_bound with d+1 terms.
The hypothesis |q|\leq1 gives the bound
|\exp q-T_n(q)|\leq R_n(q). Its contains_expSmall theorem expresses
that absolute-error estimate as interval containment. CEGA reuses the upstream
kernel through its exponential range adapter.
For an ordinary scalar function on an ordered closed interval, we build
the actual order-n Taylor polynomial from within-derivatives, prove that its
evaluation is Mathlib's Taylor evaluation, and prove that its degree is at
most n. Assuming C^{n+1} regularity on that interval, a bound C on
the norm of the (n+1)-st within-derivative produces an
ApproxCert with uniform error
C(b-a)^{n+1}/n!, the conservative remainder supplied by Mathlib's
mean-remainder theorem.
Lean code for Theorem10.54●3 declarationsAssociated Lean declarations
- theoremdefined in CAS/Continuum/TaylorApproximation.leancomplete
theorem CAS.Continuum.scalarTaylorPolynomialWithin_eval (f : ℝ → ℝ) (n : ℕ) (s : Set ℝ) (a x : ℝ) : Polynomial.eval x (CAS.Continuum.scalarTaylorPolynomialWithin f n s a) = taylorWithinEval f n s a x
theorem CAS.Continuum.scalarTaylorPolynomialWithin_eval (f : ℝ → ℝ) (n : ℕ) (s : Set ℝ) (a x : ℝ) : Polynomial.eval x (CAS.Continuum.scalarTaylorPolynomialWithin f n s a) = taylorWithinEval f n s a x
The scalar polynomial evaluates to Mathlib's Taylor evaluation.
- theoremdefined in CAS/Continuum/TaylorApproximation.leancomplete
theorem CAS.Continuum.scalarTaylorPolynomialWithin_natDegree_le (f : ℝ → ℝ) (n : ℕ) (s : Set ℝ) (a : ℝ) : (CAS.Continuum.scalarTaylorPolynomialWithin f n s a).natDegree ≤ n
theorem CAS.Continuum.scalarTaylorPolynomialWithin_natDegree_le (f : ℝ → ℝ) (n : ℕ) (s : Set ℝ) (a : ℝ) : (CAS.Continuum.scalarTaylorPolynomialWithin f n s a).natDegree ≤ n
The generated Taylor polynomial has degree at most its requested order.
- defdefined in CAS/Continuum/TaylorApproximation.leancomplete
def CAS.Continuum.taylorApproxCert {f : ℝ → ℝ} {n : ℕ} {a b C : ℝ} (hab : a ≤ b) (hf : ContDiffOn ℝ (↑n + 1) f (Set.Icc a b)) (hderiv : ∀ x ∈ Set.Icc a b, ‖iteratedDerivWithin (n + 1) f (Set.Icc a b) x‖ ≤ C) : CAS.Certificate.ApproxCert ℝ ℝ (Set.uIcc a b)
def CAS.Continuum.taylorApproxCert {f : ℝ → ℝ} {n : ℕ} {a b C : ℝ} (hab : a ≤ b) (hf : ContDiffOn ℝ (↑n + 1) f (Set.Icc a b)) (hderiv : ∀ x ∈ Set.Icc a b, ‖iteratedDerivWithin (n + 1) f (Set.Icc a b) x‖ ≤ C) : CAS.Certificate.ApproxCert ℝ ℝ (Set.uIcc a b)
The ordered-interval Taylor certificate restated on the unoriented interval used by quadrature and CEGA APIs.
The finite polynomial is the sum of the within-derivative coefficients through
order n, so its evaluation agrees term by term with Mathlib's Taylor
evaluation and its degree is at most n. Mathlib's mean-remainder theorem,
together with the supplied next-derivative bound, gives the uniform error,
which is the sound field of the approximation certificate.
CAS.Certificate.ApproxCert.add[complete]CAS.Certificate.ApproxCert.sub[complete]CAS.Certificate.ApproxCert.neg[complete]CAS.Certificate.ApproxCert.mulRealOfBoundCerts[complete]
Finite-model approximations compose through the canonical ApproxCert
calculus after projecting a ModelApproxCert to its stored certificate. If
f and g are approximated on S by p and q with errors
\varepsilon and \delta, respectively, then the additive rules prove
\begin{aligned}
f+g&\sim_{\varepsilon+\delta}p+q,&
f-g&\sim_{\varepsilon+\delta}p-q,&
-f&\sim_{\varepsilon}-p.
\end{aligned}
For real-valued functions, checked bounds |f(x)|\leq A and
|q(x)|\leq B give the nonlinear rule
fg\sim_{A\delta+B\varepsilon}pq\qquad\text{on }S.
Here u\sim_\eta v abbreviates
\forall x\in S,\ \lVert u(x)-v(x)\rVert\leq\eta. The rules act on the
underlying ApproxCert; model-order metadata can be reattached afterwards.
Lean code for Definition10.55●4 definitionsAssociated Lean declarationsCAS.Certificate.ApproxCert.add[complete]CAS.Certificate.ApproxCert.sub[complete]CAS.Certificate.ApproxCert.neg[complete]CAS.Certificate.ApproxCert.mulRealOfBoundCerts[complete]
CAS.Certificate.ApproxCert.add[complete]CAS.Certificate.ApproxCert.sub[complete]CAS.Certificate.ApproxCert.neg[complete]CAS.Certificate.ApproxCert.mulRealOfBoundCerts[complete]
- defdefined in CAS/Certificate/Approximation.leancomplete
def CAS.Certificate.ApproxCert.add.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (a b : CAS.Certificate.ApproxCert α E s) : CAS.Certificate.ApproxCert α E s
def CAS.Certificate.ApproxCert.add.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (a b : CAS.Certificate.ApproxCert α E s) : CAS.Certificate.ApproxCert α E s
Add two approximation certificates pointwise.
If
f ≈ gwith errorεandh ≈ kwith errorδ, thenf+h ≈ g+kwith errorε+δ. This is the certificate-level triangle inequality used by residual and numerical error estimators. - defdefined in CAS/Certificate/Approximation.leancomplete
def CAS.Certificate.ApproxCert.sub.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (a b : CAS.Certificate.ApproxCert α E s) : CAS.Certificate.ApproxCert α E s
def CAS.Certificate.ApproxCert.sub.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (a b : CAS.Certificate.ApproxCert α E s) : CAS.Certificate.ApproxCert α E s
Subtract two approximation certificates pointwise.
This is implemented as addition with
neg, so the error budget is again the sum of the two local budgets. - defdefined in CAS/Certificate/Approximation.leancomplete
def CAS.Certificate.ApproxCert.neg.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (c : CAS.Certificate.ApproxCert α E s) : CAS.Certificate.ApproxCert α E s
def CAS.Certificate.ApproxCert.neg.{u_1, u_2} {α : Type u_1} {E : Type u_2} [NormedAddCommGroup E] {s : Set α} (c : CAS.Certificate.ApproxCert α E s) : CAS.Certificate.ApproxCert α E s
Negate both sides of an approximation certificate.
- defdefined in CAS/Certificate/Approximation.leancomplete
def CAS.Certificate.ApproxCert.mulRealOfBoundCerts.{u_3} {α : Type u_3} {s : Set α} (a b : CAS.Certificate.ApproxCert α ℝ s) (boundLhs boundRhs : CAS.Certificate.BoundCert α s) (hLhs : boundLhs.fn = fun x ↦ |a.lhs x|) (hRhs : boundRhs.fn = fun x ↦ |b.rhs x|) : CAS.Certificate.ApproxCert α ℝ s
def CAS.Certificate.ApproxCert.mulRealOfBoundCerts.{u_3} {α : Type u_3} {s : Set α} (a b : CAS.Certificate.ApproxCert α ℝ s) (boundLhs boundRhs : CAS.Certificate.BoundCert α s) (hLhs : boundLhs.fn = fun x ↦ |a.lhs x|) (hRhs : boundRhs.fn = fun x ↦ |b.rhs x|) : CAS.Certificate.ApproxCert α ℝ s
Multiply two real-valued approximation certificates using magnitude-bound certificates.
The same as
mulReal, with the magnitude bounds for|a.lhs|and|b.rhs|supplied asBoundCerts, which is what interval routes return.
Finite Taylor jets.
The jet uses the real coefficients c_0,\ldots,c_n to define the finite
polynomial \sum_{k=0}^{n}c_k(x-a)^k. The certificate accepts a real-valued
coefficient function; it does not require a rational or floating-point encoding.
We prove three separate statements: exact coefficients recover the mathematical
Taylor polynomial, coefficient intervals bound the perturbation of that
polynomial, and a bound on the next derivative controls the analytic remainder.
Only after those statements are available are their two error budgets added.
Reading a TaylorJetCert.
For order n=2 on [a,b] with a\leq b, a TaylorJetCert stores coefficients
c_0,c_1,c_2, coefficient uncertainties
\delta_0,\delta_1,\delta_2, and a bound C for the third within-derivative.
Its model is
q(x)=c_0+c_1(x-a)+c_2(x-a)^2.
The certificate keeps the error calculation visible:
\begin{aligned}
E_{\mathrm{coeff}}
&=\delta_0+\delta_1(b-a)+\delta_2(b-a)^2,\\
E_{\mathrm{rem}}
&=C\frac{(b-a)^3}{2!},\\
E_{\mathrm{jet}}
&=E_{\mathrm{rem}}+E_{\mathrm{coeff}}.
\end{aligned}
The coefficient inequalities prove that the exact Taylor polynomial is within
E_{\mathrm{coeff}} of q. The derivative bound and ContDiffOn
hypothesis prove that the source function is within E_{\mathrm{rem}} of
the exact Taylor polynomial. Adding the two error bounds gives
\forall x\in[a,b],\qquad |f(x)-q(x)|\leq E_{\mathrm{jet}}.
Let
c_k=(k!)^{-1}D^k_{[a,b]}f(a) be the exact within-derivative coefficient.
For every real x, evaluating the finite power-basis jet gives exactly
Mathlib's scalar Taylor polynomial:
\sum_{k=0}^{n}c_k(x-a)^k
=T^{[a,b]}_{n,a}f(x).
Thus the finite coefficient sum and the analytic object used by the remainder theorem have the same real semantics.
Lean code for Theorem10.56●1 theoremAssociated Lean declarationsCAS.Continuum.taylorJetEval_exact[complete]
CAS.Continuum.taylorJetEval_exact[complete]
- theoremdefined in CAS/Continuum/TaylorJet.leancomplete
theorem CAS.Continuum.taylorJetEval_exact (f : ℝ → ℝ) (n : ℕ) (s : Set ℝ) (center x : ℝ) : CAS.Continuum.taylorJetEval n center (CAS.Continuum.taylorCoefficientWithin f s center) x = Polynomial.eval x (CAS.Continuum.scalarTaylorPolynomialWithin f n s center)
theorem CAS.Continuum.taylorJetEval_exact (f : ℝ → ℝ) (n : ℕ) (s : Set ℝ) (center x : ℝ) : CAS.Continuum.taylorJetEval n center (CAS.Continuum.taylorCoefficientWithin f s center) x = Polynomial.eval x (CAS.Continuum.scalarTaylorPolynomialWithin f n s center)
Exact Taylor coefficients recover the scalar Taylor polynomial.
Expand the finite real jet as its coefficient sum and substitute the definition
c_k=D^k_{[a,b]}f(a)/k!. The resulting finite sum is exactly the definition
of Mathlib's scalar Taylor evaluation, so the two functions agree for every x.
The Taylor compiler constructs the derivatives of orders zero through
n+1 under one checked validity certificate. It fails when the panel crosses
an unsupported branch boundary or when rational canonicalization cannot prove
its generated side conditions. Each compiled derivative reuses its canonical
derivative object and adds only the panel orientation and analytic-validity
route. A successful result exposes every derivative through this same checked
interface.
Lean code for Definition10.57●2 definitionsAssociated Lean declarations
- defdefined in CAS/Continuum/CompiledDerivative.leancomplete
def CAS.Continuum.CompiledTaylorJet.derivative {expr : CAS.Verified.Expr (Fin 1)} {order : ℕ} {a b : ℚ} (jet : CAS.Continuum.CompiledTaylorJet expr order a b) (k : Fin (order + 2)) : CAS.Continuum.CompiledDerivative expr (↑k) a b
def CAS.Continuum.CompiledTaylorJet.derivative {expr : CAS.Verified.Expr (Fin 1)} {order : ℕ} {a b : ℚ} (jet : CAS.Continuum.CompiledTaylorJet expr order a b) (k : Fin (order + 2)) : CAS.Continuum.CompiledDerivative expr (↑k) a b
Project one derivative without repeating validity or canonicalization.
- defdefined in CAS/Continuum/CompiledDerivative.leancomplete
def CAS.Continuum.RationalInterval.compileTaylorJet? (expr : CAS.Verified.Expr (Fin 1)) (order : ℕ) (a b : ℚ) (hab : ↑a < ↑b) : Option (CAS.Continuum.CompiledTaylorJet expr order a b)
def CAS.Continuum.RationalInterval.compileTaylorJet? (expr : CAS.Verified.Expr (Fin 1)) (order : ℕ) (a b : ℚ) (hab : ↑a < ↑b) : Option (CAS.Continuum.CompiledTaylorJet expr order a b)
Compile all Taylor coefficient derivatives and the remainder derivative under one maximal validity certificate.
The compiler is fail-closed: any analytic-domain failure or unproved canonicalization side condition rejects the complete jet.
Suppose the stored coefficient c_k is within \delta_k\geq0 of the exact
Taylor coefficient c_k^\ast for 0\leq k\leq n. For the stored jet
q_n(x)=\sum_{k=0}^{n}c_k(x-a)^k, the coefficient bounds imply
\forall x\in[a,b],\qquad
\left|T^{[a,b]}_{n,a}f(x)-q_n(x)\right|
\leq\sum_{k=0}^{n}\delta_k(b-a)^k.
This estimate contains coefficient uncertainty only.
Lean code for Theorem10.58●2 theoremsAssociated Lean declarations
- theoremdefined in CAS/Continuum/TaylorJet.leancomplete
theorem CAS.Continuum.approxOn_taylorJetEval_of_coefficient_bounds {f : ℝ → ℝ} {n : ℕ} {a b : ℝ} {coefficients errors : ℕ → ℝ} (hcoeff : ∀ k ∈ Finset.range (n + 1), ‖CAS.Continuum.taylorCoefficientWithin f (Set.Icc a b) a k - coefficients k‖ ≤ errors k) : CAS.Certificate.ApproxOn (fun x ↦ Polynomial.eval x (CAS.Continuum.scalarTaylorPolynomialWithin f n (Set.Icc a b) a)) (CAS.Continuum.taylorJetEval n a coefficients) (Set.Icc a b) (CAS.Continuum.taylorCoefficientError n (b - a) errors)
theorem CAS.Continuum.approxOn_taylorJetEval_of_coefficient_bounds {f : ℝ → ℝ} {n : ℕ} {a b : ℝ} {coefficients errors : ℕ → ℝ} (hcoeff : ∀ k ∈ Finset.range (n + 1), ‖CAS.Continuum.taylorCoefficientWithin f (Set.Icc a b) a k - coefficients k‖ ≤ errors k) : CAS.Certificate.ApproxOn (fun x ↦ Polynomial.eval x (CAS.Continuum.scalarTaylorPolynomialWithin f n (Set.Icc a b) a)) (CAS.Continuum.taylorJetEval n a coefficients) (Set.Icc a b) (CAS.Continuum.taylorCoefficientError n (b - a) errors)
Per-coefficient bounds imply a uniform approximation of the exact Taylor polynomial by the stored jet.
- theoremdefined in CAS/Continuum/TaylorJet.leancomplete
theorem CAS.Continuum.TaylorJetCert.coefficients_approx {f : ℝ → ℝ} {n : ℕ} {a b : ℝ} (jet : CAS.Continuum.TaylorJetCert f n a b) : CAS.Certificate.ApproxOn (fun x ↦ Polynomial.eval x (CAS.Continuum.scalarTaylorPolynomialWithin f n (Set.Icc a b) a)) jet.model (Set.Icc a b) jet.coefficientError
theorem CAS.Continuum.TaylorJetCert.coefficients_approx {f : ℝ → ℝ} {n : ℕ} {a b : ℝ} (jet : CAS.Continuum.TaylorJetCert f n a b) : CAS.Certificate.ApproxOn (fun x ↦ Polynomial.eval x (CAS.Continuum.scalarTaylorPolynomialWithin f n (Set.Icc a b) a)) jet.model (Set.Icc a b) jet.coefficientError
The exact Taylor polynomial is close to the stored finite jet.
Subtract the two finite power series term by term and apply the triangle
inequality. Each coefficient difference is at most \delta_k, while
|x-a|^k\leq(b-a)^k on the ordered interval. Summing these bounds gives the
displayed perturbation estimate.
A uniform bound on the (n+1)-st within derivative, together with the
certificate's C^{n+1} regularity on the ordered interval, gives the analytic
remainder between the source function and its exact Taylor polynomial. This
term contains no coefficient uncertainty and no runtime roundoff.
Lean code for Theorem10.59●1 theoremAssociated Lean declarations
- theoremdefined in CAS/Continuum/TaylorJet.leancomplete
theorem CAS.Continuum.TaylorJetCert.remainder_approx {f : ℝ → ℝ} {n : ℕ} {a b : ℝ} (jet : CAS.Continuum.TaylorJetCert f n a b) : CAS.Certificate.ApproxOn f (fun x ↦ Polynomial.eval x (CAS.Continuum.scalarTaylorPolynomialWithin f n (Set.Icc a b) a)) (Set.Icc a b) jet.remainderError
theorem CAS.Continuum.TaylorJetCert.remainder_approx {f : ℝ → ℝ} {n : ℕ} {a b : ℝ} (jet : CAS.Continuum.TaylorJetCert f n a b) : CAS.Certificate.ApproxOn f (fun x ↦ Polynomial.eval x (CAS.Continuum.scalarTaylorPolynomialWithin f n (Set.Icc a b) a)) (Set.Icc a b) jet.remainderError
Mathlib's exact Taylor polynomial approximates the source function.
Apply the within-interval Taylor remainder theorem at the left endpoint.
The supplied uniform bound on the next derivative controls the remainder
factor, and |x-a|\leq b-a makes the estimate uniform over the panel.
The combined certificate converts derivative enclosures into coefficient
centers c_k, coefficient radii \delta_k, and a bound C on the
(n+1)-st within derivative. For
q_n(x)=\sum_{k=0}^{n}c_k(x-a)^k, its soundness theorem is
\forall x\in[a,b],\qquad
|f(x)-q_n(x)|
\leq
C\frac{(b-a)^{n+1}}{n!}
+\sum_{k=0}^{n}\delta_k(b-a)^k.
The same proposition is exported as an ordinary ModelApproxCert. Runtime
roundoff in evaluating q_n is a separate error.
Lean code for Theorem10.60●3 declarationsAssociated Lean declarations
- theoremdefined in CAS/Continuum/TaylorJet.leancomplete
theorem CAS.Continuum.TaylorJetCert.sound {f : ℝ → ℝ} {n : ℕ} {a b : ℝ} (jet : CAS.Continuum.TaylorJetCert f n a b) : CAS.Certificate.ApproxOn f jet.model (Set.Icc a b) jet.error
theorem CAS.Continuum.TaylorJetCert.sound {f : ℝ → ℝ} {n : ℕ} {a b : ℝ} (jet : CAS.Continuum.TaylorJetCert f n a b) : CAS.Certificate.ApproxOn f jet.model (Set.Icc a b) jet.error
The source function is uniformly approximated by the explicit jet.
- defdefined in CAS/Continuum/TaylorJet.leancomplete
def CAS.Continuum.TaylorJetCert.ofDerivativeEnclosures.{u_1} {I : Type u_1} [CAS.Continuum.RealIntervalBackend I] {f : ℝ → ℝ} {n : ℕ} {a b : ℝ} (ordered : a ≤ b) (smooth : ContDiffOn ℝ (↑n + 1) f (Set.Icc a b)) (coefficientRanges : ℕ → I) (coefficientRanges_sound : ∀ k ∈ Finset.range (n + 1), CAS.Continuum.RealIntervalBackend.MemReal (coefficientRanges k) (iteratedDerivWithin k f (Set.Icc a b) a)) (derivativeRange : I) (derivativeRange_sound : ∀ x ∈ Set.Icc a b, CAS.Continuum.RealIntervalBackend.MemReal derivativeRange (iteratedDerivWithin (n + 1) f (Set.Icc a b) x)) : CAS.Continuum.TaylorJetCert f n a b
def CAS.Continuum.TaylorJetCert.ofDerivativeEnclosures.{u_1} {I : Type u_1} [CAS.Continuum.RealIntervalBackend I] {f : ℝ → ℝ} {n : ℕ} {a b : ℝ} (ordered : a ≤ b) (smooth : ContDiffOn ℝ (↑n + 1) f (Set.Icc a b)) (coefficientRanges : ℕ → I) (coefficientRanges_sound : ∀ k ∈ Finset.range (n + 1), CAS.Continuum.RealIntervalBackend.MemReal (coefficientRanges k) (iteratedDerivWithin k f (Set.Icc a b) a)) (derivativeRange : I) (derivativeRange_sound : ∀ x ∈ Set.Icc a b, CAS.Continuum.RealIntervalBackend.MemReal derivativeRange (iteratedDerivWithin (n + 1) f (Set.Icc a b) x)) : CAS.Continuum.TaylorJetCert f n a b
Construct a Taylor jet from checked derivative enclosures.
For orders
0, ..., n, the stored coefficient is the interval midpoint divided byk!, and its uncertainty is the interval radius divided byk!. The final interval encloses the(n+1)-st derivative on the whole panel and therefore supplies the analytic remainder constant. - defdefined in CAS/Continuum/TaylorJet.leancomplete
def CAS.Continuum.TaylorJetCert.toModelApproxCert {f : ℝ → ℝ} {n : ℕ} {a b : ℝ} (jet : CAS.Continuum.TaylorJetCert f n a b) : CAS.Certificate.ModelApproxCert ℝ ℝ (Set.Icc a b)
def CAS.Continuum.TaylorJetCert.toModelApproxCert {f : ℝ → ℝ} {n : ℕ} {a b : ℝ} (jet : CAS.Continuum.TaylorJetCert f n a b) : CAS.Certificate.ModelApproxCert ℝ ℝ (Set.Icc a b)
Forget Taylor-specific data and expose the ordinary approximation certificate.
Insert the exact Taylor polynomial between f and the stored jet q_n.
The Taylor remainder theorem bounds the first difference, and the coefficient
perturbation theorem bounds the second. The triangle inequality adds these two
independent budgets, producing the certificate's soundness field.
Informal sizing calculation for \sin(x) on [0, \pi].
Suppose we request a piecewise model approximating \sin x to tolerance
\eta = 10^{-4} on [0, \pi]. The adaptive algorithm proceeds:
Initial attempt. At the root interval
[0, \pi]with ordern = 4, the remainder bound usesC = \max_{x \in [0,\pi]} |D^5\sin(x)| = 1. The remainder isC(\pi-0)^5/4! \approx 12.7, which exceeds\eta.First bisection. Split at
\pi/2. On each half-panel of width\pi/2 \approx 1.57, the remainder is1 \cdot (1.57)^5/24 \approx 0.39, still exceeding\eta.Further bisection. After 4 levels (panels of width
\pi/16 \approx 0.196), the remainder is(0.196)^5/24 \approx 1.2 \times 10^{-5} < \eta. The analytic remainder fits the budget; leaf acceptance still needs the coefficient and validity certificates.
This calculation suggests 16 quartic panels. A RationalModelTree
certificate has rational endpoints, whereas \pi is irrational. A checked
implementation must first choose a rational outer interval and provide the
derivative and coefficient certificates required by each leaf. The intended
global guarantee would then have the form
\forall x \in [0, \pi], \qquad |\sin x - P_\tau(x)| \leq 10^{-4},
where P_\tau selects the appropriate leaf polynomial based on which
subinterval contains x.
The distinction from pure interval arithmetic.
Classical interval arithmetic (Moore, 1966; Neumaier, 1990) replaces each real
number by an interval [\underline{x}, \overline{x}] and propagates bounds
through every arithmetic operation. Repeated occurrences are treated
independently, which can overestimate the range. For example, evaluating
x - x with x \in [0,1] yields [-1, 1] instead of \{0\}. This is
the interval dependency problem; repeated enclosure of transformed sets also
gives rise to the related wrapping effect.
Taylor models (Berz and Makino, 1998) mitigate this loss of correlation by
retaining polynomial structure. Instead of an interval, each quantity is
represented as a polynomial plus a remainder interval. Subtraction of
correlated expressions can cancel matching polynomial parts exactly, leaving
the remainder enclosure to account for the unresolved error. This is useful
for PDE verification, where expressions such as
\nabla u \cdot \nabla u - |\nabla u|^2 should simplify before interval
evaluation.
PDEAtlas's Taylor certificates are approximation and composition theorems, assembled into piecewise models, rather than a Taylor-model arithmetic with the wrapping-control strategies of that literature.
The rational interval operations, such as expRange, logRange on strictly
positive panels, RationalInterval.sin, and RationalInterval.cos, enclose
the range of a function on a whole panel. A Taylor model instead retains a
polynomial approximation over the panel; the symbolic Taylor constructors use
interval analysis only to establish analytic-domain conditions and to bound
the remainder derivative, while coefficient enclosures can separately supply
the jet's coefficient-error budget.
Order selection and error decomposition.
The Taylor-jet certificate makes the three error sources explicit:
\underbrace{C \frac{(b-a)^{n+1}}{n!}}_{\text{truncation}}
+ \underbrace{\sum_{k=0}^n \delta_k (b-a)^k}_{\text{coefficient uncertainty}}
+ \underbrace{r_{\text{eval}}}_{\text{runtime roundoff}}.
The first term depends on the smoothness of the function and the panel width.
The second term vanishes when exact symbolic coefficients are used (all
\delta_k = 0). The third term is added separately by the numerical backend
and is separate from the analytic approximation theorem.
The CEGA option expOrder (default defaultExpTaylorOrder = 8, so a reduced
Taylor sum with n=9 terms) is a different order: it is the degree of the
elementary exponential enclosure used by the interval evaluator, while a
Taylor jet has its own polynomial order and these three error budgets.
Piecewise models.
RationalModelTree joins local approximation certificates along exact rational
split points; the leaf models need not be polynomials. If P_\tau is the
piecewise model selected by a tree \tau and E_\tau is the maximum of
its leaf errors after replacing each by \max(0,E_\ell), structural induction
proves
\forall x\in[a,b],\qquad
|f(x)-P_\tau(x)|\leq E_\tau.
For an adaptive result with E_\tau\leq\eta, the exported theorem replaces
E_\tau by the requested tolerance \eta.
Lean code for Theorem10.61●2 theoremsAssociated Lean declarations
- theoremdefined in CAS/Continuum/TaylorModel.leancomplete
theorem CAS.Continuum.RationalModelTree.sound {f : ℝ → ℝ} {a b : ℚ} (tree : CAS.Continuum.RationalModelTree f a b) : CAS.Certificate.ApproxOn f tree.model (Set.Icc ↑a ↑b) tree.error
theorem CAS.Continuum.RationalModelTree.sound {f : ℝ → ℝ} {a b : ℚ} (tree : CAS.Continuum.RationalModelTree f a b) : CAS.Certificate.ApproxOn f tree.model (Set.Icc ↑a ↑b) tree.error
The piecewise reference function approximates
fon its interval withintree.error. - theoremdefined in CAS/Continuum/TaylorModel.leancomplete
theorem CAS.Continuum.RationalModelTree.sound_of_adaptive {f : ℝ → ℝ} {a b tolerance : ℚ} (result : CAS.Continuum.AdaptiveResult (CAS.Continuum.RationalModelTree.adaptiveSystem f).error ↑tolerance) : CAS.Certificate.ApproxOn f (CAS.Continuum.RationalModelTree.model result.result) (Set.Icc ↑a ↑b) ↑tolerance
theorem CAS.Continuum.RationalModelTree.sound_of_adaptive {f : ℝ → ℝ} {a b tolerance : ℚ} (result : CAS.Continuum.AdaptiveResult (CAS.Continuum.RationalModelTree.adaptiveSystem f).error ↑tolerance) : CAS.Certificate.ApproxOn f (CAS.Continuum.RationalModelTree.model result.result) (Set.Icc ↑a ↑b) ↑tolerance
A successful adaptive result gives an ordinary uniform approximation theorem.
Induct on the model tree. A leaf uses its local model certificate. At a split,
membership in the root interval places the point in one child panel; apply the
corresponding inductive estimate and weaken its leaf error to the maximum of
the two child errors. The adaptive conclusion follows by transitivity with
E_\tau\leq\eta.
A payload tree may retain derivative enclosures, centers, or backend data at
each leaf while erasing to the underlying model tree. For
x\in[a,b], let \ell_x be the selected leaf and p_{\ell_x} its
certified local model. Selection satisfies the exact identity
P_\tau(x)=p_{\ell_x}(x),
while erasure supplies
|f(x)-P_\tau(x)|\leq E_\tau. Payloads leave the approximation semantics
unchanged.
Lean code for Theorem10.62●2 theoremsAssociated Lean declarations
- theoremdefined in CAS/Continuum/ModelTreePayload.leancomplete
theorem CAS.Continuum.RationalModelTree.WithPayload.sound {f : ℝ → ℝ} {Payload : ℚ → ℚ → Type} {a b : ℚ} (tree : CAS.Continuum.RationalModelTree.WithPayload f Payload a b) : CAS.Certificate.ApproxOn f tree.model (Set.Icc ↑a ↑b) tree.error
theorem CAS.Continuum.RationalModelTree.WithPayload.sound {f : ℝ → ℝ} {Payload : ℚ → ℚ → Type} {a b : ℚ} (tree : CAS.Continuum.RationalModelTree.WithPayload f Payload a b) : CAS.Certificate.ApproxOn f tree.model (Set.Icc ↑a ↑b) tree.error
Payload trees inherit the ordinary uniform approximation theorem.
- theoremdefined in CAS/Continuum/ModelTreePayload.leancomplete
theorem CAS.Continuum.RationalModelTree.WithPayload.model_eq_selectedLeaf {f : ℝ → ℝ} {Payload : ℚ → ℚ → Type} {a b : ℚ} (tree : CAS.Continuum.RationalModelTree.WithPayload f Payload a b) (x : ℝ) (hx : x ∈ Set.Icc ↑a ↑b) : tree.model x = (tree.selectLeaf x hx).cert.toApproxCert.rhs x
theorem CAS.Continuum.RationalModelTree.WithPayload.model_eq_selectedLeaf {f : ℝ → ℝ} {Payload : ℚ → ℚ → Type} {a b : ℚ} (tree : CAS.Continuum.RationalModelTree.WithPayload f Payload a b) (x : ℝ) (hx : x ∈ Set.Icc ↑a ↑b) : tree.model x = (tree.selectLeaf x hx).cert.toApproxCert.rhs x
Selection returns the local model used by the erased piecewise tree.
Follow the same endpoint comparison used by the piecewise model evaluator to select a leaf. Structural induction shows that erasing payloads does not change this branch choice or the selected local model. The payload tree therefore evaluates to the certified leaf model, while the erased tree supplies its approximation bound.
Let R(c,d) be a declared relation between a leaf certificate and its
payload. If every leaf satisfies R, then point selection proves
\forall x\in[a,b],\qquad
R\!\left(c_{\ell_x},d_{\ell_x}\right).
Validated adaptive search preserves this local relation together with the
global guarantee
\forall x\in[a,b],\ |f(x)-P_\tau(x)|\leq\eta for the requested tolerance
\eta.
Lean code for Theorem10.63●2 theoremsAssociated Lean declarations
- theoremdefined in CAS/Continuum/ModelTreePayload.leancomplete
theorem CAS.Continuum.RationalModelTree.Validated.selectLeaf_relation {f : ℝ → ℝ} {Payload : ℚ → ℚ → Type} {Relation : {a b : ℚ} → CAS.Certificate.ModelApproxCert ℝ ℝ (Set.Icc ↑a ↑b) → Payload a b → Prop} {a b : ℚ} (result : CAS.Continuum.RationalModelTree.Validated f Payload (fun {a b} ↦ Relation) a b) (x : ℝ) (hx : x ∈ Set.Icc ↑a ↑b) : Relation (result.selectLeaf x hx).cert (result.selectLeaf x hx).payload
theorem CAS.Continuum.RationalModelTree.Validated.selectLeaf_relation {f : ℝ → ℝ} {Payload : ℚ → ℚ → Type} {Relation : {a b : ℚ} → CAS.Certificate.ModelApproxCert ℝ ℝ (Set.Icc ↑a ↑b) → Payload a b → Prop} {a b : ℚ} (result : CAS.Continuum.RationalModelTree.Validated f Payload (fun {a b} ↦ Relation) a b) (x : ℝ) (hx : x ∈ Set.Icc ↑a ↑b) : Relation (result.selectLeaf x hx).cert (result.selectLeaf x hx).payload
The selected pair satisfies the validated leaf relation.
- theoremdefined in CAS/Continuum/ModelTreePayload.leancomplete
theorem CAS.Continuum.RationalModelTree.Validated.sound_of_adaptive {f : ℝ → ℝ} {Payload : ℚ → ℚ → Type} {Relation : {a b : ℚ} → CAS.Certificate.ModelApproxCert ℝ ℝ (Set.Icc ↑a ↑b) → Payload a b → Prop} {a b tolerance : ℚ} (result : CAS.Continuum.AdaptiveResult (fun result ↦ result.error) ↑tolerance) : CAS.Certificate.ApproxOn f result.result.model (Set.Icc ↑a ↑b) ↑tolerance
theorem CAS.Continuum.RationalModelTree.Validated.sound_of_adaptive {f : ℝ → ℝ} {Payload : ℚ → ℚ → Type} {Relation : {a b : ℚ} → CAS.Certificate.ModelApproxCert ℝ ℝ (Set.Icc ↑a ↑b) → Payload a b → Prop} {a b tolerance : ℚ} (result : CAS.Continuum.AdaptiveResult (fun result ↦ result.error) ↑tolerance) : CAS.Certificate.ApproxOn f result.result.model (Set.Icc ↑a ↑b) ↑tolerance
The model of a successful adaptive search over validated payload trees approximates
fon[a, b]within the tolerance.
Induct along the branch selected by the point. At a leaf, the stored validation
field proves R(c,d). At a split m, use the left child when x\leq m
and the right child otherwise; root membership gives membership in that chosen
child, so its induction hypothesis applies. A queried split point uses the
left branch. The global approximation estimate is inherited from the erased
model tree.
The leaf construction combines the checked symbolic derivative pipeline with
a noncomputable Taylor polynomial. Given rational a<b, regularity through order
n+1, and a proved nonnegative rational bound
\lVert D^{n+1}_{[a,b]}f(x)\rVert\leq C, a successful leaf construction
returns the exact Taylor model T^{[a,b]}_{n,a}f with
\forall x\in[a,b],\qquad
\left|f(x)-T^{[a,b]}_{n,a}f(x)\right|
\leq C\frac{(b-a)^{n+1}}{n!}.
The compiler records analytic branch conditions explicitly and verifies
rational cancellation and denominator conditions. Unsupported derivatives or
failed interval obligations return none, so this theorem is exposed only
after all required evidence has been constructed.
Lean code for Definition10.64●5 declarationsAssociated Lean declarations
- defdefined in CAS/Continuum/TaylorModel.leancomplete
def CAS.Continuum.taylorLeafCandidate {f : ℝ → ℝ} {n : ℕ} {a b C : ℚ} (hab : ↑a < ↑b) (hC : 0 ≤ C) (hf : ContDiffOn ℝ (↑n + 1) f (Set.Icc ↑a ↑b)) (hderiv : ∀ x ∈ Set.Icc ↑a ↑b, ‖iteratedDerivWithin (n + 1) f (Set.Icc ↑a ↑b) x‖ ≤ ↑C) : CAS.Continuum.RationalBudgetCandidate (CAS.Continuum.RationalModelTree.adaptiveSystem f).error
def CAS.Continuum.taylorLeafCandidate {f : ℝ → ℝ} {n : ℕ} {a b C : ℚ} (hab : ↑a < ↑b) (hC : 0 ≤ C) (hf : ContDiffOn ℝ (↑n + 1) f (Set.Icc ↑a ↑b)) (hderiv : ∀ x ∈ Set.Icc ↑a ↑b, ‖iteratedDerivWithin (n + 1) f (Set.Icc ↑a ↑b) x‖ ≤ ↑C) : CAS.Continuum.RationalBudgetCandidate (CAS.Continuum.RationalModelTree.adaptiveSystem f).error
Build one order-
nTaylor-model leaf.The model coefficients are Mathlib's actual within-derivatives at the left endpoint.
Cis an exact-rational upper bound for the(n+1)-st derivative, so the stopping budget is executable even though the polynomial coefficients and semantic theorem live overℝ. - defdefined in CAS/Continuum/CompiledDerivative.leancomplete
def CAS.Continuum.RationalInterval.compileDerivative? (expr : CAS.Verified.Expr (Fin 1)) (order : ℕ) (a b : ℚ) (hab : ↑a < ↑b) : Option (CAS.Continuum.CompiledDerivative expr order a b)
def CAS.Continuum.RationalInterval.compileDerivative? (expr : CAS.Verified.Expr (Fin 1)) (order : ℕ) (a b : ℚ) (hab : ↑a < ↑b) : Option (CAS.Continuum.CompiledDerivative expr order a b)
Compile one derivative for all verified interval backends.
The function fails closed. It returns
nonewhen the panel crosses an analytic singularity, touches a strictlog/sqrtbranch boundary, or cannot prove a nonzero condition introduced by rational canonicalization. - theoremdefined in CAS/Continuum/CompiledDerivative.leancomplete
theorem CAS.Continuum.CompiledDerivative.contDiffOn {expr : CAS.Verified.Expr (Fin 1)} {order : ℕ} {a b : ℚ} (compiled : CAS.Continuum.CompiledDerivative expr order a b) : ContDiffOn ℝ (↑order) expr.univariateEval (Set.Icc ↑a ↑b)
theorem CAS.Continuum.CompiledDerivative.contDiffOn {expr : CAS.Verified.Expr (Fin 1)} {order : ℕ} {a b : ℚ} (compiled : CAS.Continuum.CompiledDerivative expr order a b) : ContDiffOn ℝ (↑order) expr.univariateEval (Set.Icc ↑a ↑b)
The source function is
C^orderon the compiled panel. - theoremdefined in CAS/Continuum/CompiledDerivative.leancomplete
theorem CAS.Continuum.CanonicalDerivative.sound {expr : CAS.Verified.Expr (Fin 1)} {order : ℕ} {a b : ℚ} (self : CAS.Continuum.CanonicalDerivative expr order a b) (x : ℝ) : x ∈ Set.Icc ↑a ↑b → CAS.Verified.Expr.eval !₂[x].ofLp (expr.symbolicDerivative order) = CAS.Verified.Expr.eval !₂[x].ofLp self.expression
theorem CAS.Continuum.CanonicalDerivative.sound {expr : CAS.Verified.Expr (Fin 1)} {order : ℕ} {a b : ℚ} (self : CAS.Continuum.CanonicalDerivative expr order a b) (x : ℝ) : x ∈ Set.Icc ↑a ↑b → CAS.Verified.Expr.eval !₂[x].ofLp (expr.symbolicDerivative order) = CAS.Verified.Expr.eval !₂[x].ofLp self.expression
The canonical expression equals the requested symbolic derivative on the panel.
- theoremdefined in CAS/Continuum/IntervalEval/Attempt.leancomplete
theorem CAS.Continuum.RationalInterval.EnclosureAttempt.memReal.{u_1} {α : Type u_1} {s : Set α} {fn : α → ℝ} (a : CAS.Continuum.RationalInterval.EnclosureAttempt α s fn) {x : α} (hx : x ∈ s) : a.interval.MemReal (fn x)
theorem CAS.Continuum.RationalInterval.EnclosureAttempt.memReal.{u_1} {α : Type u_1} {s : Set α} {fn : α → ℝ} (a : CAS.Continuum.RationalInterval.EnclosureAttempt α s fn) {x : α} (hx : x ∈ s) : a.interval.MemReal (fn x)
The displayed rational interval contains the indexed function on the attempt domain.
For each splittable coordinate x_i, the planner encloses the symbolic
partial derivative and assigns the exact rational score
(b_i-a_i)\max\{|L_i|,|U_i|\},
\qquad
\operatorname{eval}(\operatorname{diff}_i e,X)\subseteq[L_i,U_i].
This is an enclosure of the formal derivative expression. Its identification with an analytic partial derivative requires the separate validity hypotheses. The largest positive score selects the coordinate; if no score is positive, the widest coordinate with an unenclosed derivative is chosen. The ranking is a heuristic, and soundness comes from the checked interval enclosures used by the adaptive search.
Lean code for Definition10.65●2 definitionsAssociated Lean declarations
- defdefined in CAS/Continuum/IntervalEval/Registry/Refinement.leancomplete
def CAS.Continuum.RationalInterval.CertifiedEvalRegistry.variableSensitivities.{u_1, u_2} {α : Type u_1} {ι : Type u_2} [DecidableEq ι] {s : Set α} {ρ : α → ι → ℝ} (r : CAS.Continuum.RationalInterval.CertifiedEvalRegistry s ρ) (coordinates : List ι) (expr : CAS.Verified.Expr ι) : List (CAS.Continuum.RationalInterval.CertifiedEvalRegistry.VariableSubdivisionChoice ι)
def CAS.Continuum.RationalInterval.CertifiedEvalRegistry.variableSensitivities.{u_1, u_2} {α : Type u_1} {ι : Type u_2} [DecidableEq ι] {s : Set α} {ρ : α → ι → ℝ} (r : CAS.Continuum.RationalInterval.CertifiedEvalRegistry s ρ) (coordinates : List ι) (expr : CAS.Verified.Expr ι) : List (CAS.Continuum.RationalInterval.CertifiedEvalRegistry.VariableSubdivisionChoice ι)
First-order sensitivity scores for the splittable variables among
coordinates, in the order of that list.The caller supplies the coordinate enumeration (
List.finRange nforFin n) instead of this function sortingFinset.univ: CEGA queries are evaluated by the kernel, andFinset.sortreduces throughList.mergeSort, whose body Lean core does not expose to module files. - defdefined in CAS/Continuum/IntervalEval/Registry/Planner.leancomplete
def CAS.Continuum.RationalInterval.CertifiedEvalRegistry.selectVariableSubdivisionChoice?.{u_1, u_2} {α : Type u_1} {ι : Type u_2} [DecidableEq ι] {s : Set α} {ρ : α → ι → ℝ} (r : CAS.Continuum.RationalInterval.CertifiedEvalRegistry s ρ) (coordinates : List ι) (expr : CAS.Verified.Expr ι) : Option (CAS.Continuum.RationalInterval.CertifiedEvalRegistry.VariableSubdivisionChoice ι)
def CAS.Continuum.RationalInterval.CertifiedEvalRegistry.selectVariableSubdivisionChoice?.{u_1, u_2} {α : Type u_1} {ι : Type u_2} [DecidableEq ι] {s : Set α} {ρ : α → ι → ℝ} (r : CAS.Continuum.RationalInterval.CertifiedEvalRegistry s ρ) (coordinates : List ι) (expr : CAS.Verified.Expr ι) : Option (CAS.Continuum.RationalInterval.CertifiedEvalRegistry.VariableSubdivisionChoice ι)
Choose a coordinate for interval subdivision among
coordinates.Positive first-order influence scores are preferred. If interval evaluation cannot enclose any relevant partial derivative, the widest unsupported coordinate is selected. Coordinates whose checked derivative range is exactly zero are not subdivided merely because they are syntactically present. The caller enumerates the coordinates (see
variableSensitivities).
ExprAdaptiveTaylor.panelOfRange is the analytic handoff from a proved
derivative enclosure to a real Taylor model with an exact-rational error
bound. Both it and the adaptive constructor adaptiveToTolerance? are
noncomputable. The latter constructs a leaf of the requested order on each
panel from the exact-rational enclosure of its remainder derivative. It retries
rejected leaves on half-panels until the model tree meets the requested
tolerance \eta or the finite search budget is exhausted. If the optional
search returns a result with piecewise model P, Lean proves
\forall x\in[a,b],\qquad
\left|\operatorname{eval}(e,x)-P(x)\right|\leq\eta.
Failure returns none, and success carries an ordinary ApproxOn
theorem.
Lean code for Theorem10.66●2 declarationsAssociated Lean declarations
- theoremdefined in CAS/Continuum/ExprAdaptiveTaylor.leancomplete
theorem CAS.Continuum.ExprAdaptiveTaylor.adaptiveToTolerance?_sound {expr : CAS.Verified.Expr (Fin 1)} {a b tolerance : ℚ} (result : CAS.Continuum.AdaptiveResult (CAS.Continuum.RationalModelTree.adaptiveSystem expr.univariateEval).error ↑tolerance) : CAS.Certificate.ApproxOn expr.univariateEval (CAS.Continuum.RationalModelTree.model result.result) (Set.Icc ↑a ↑b) ↑tolerance
theorem CAS.Continuum.ExprAdaptiveTaylor.adaptiveToTolerance?_sound {expr : CAS.Verified.Expr (Fin 1)} {a b tolerance : ℚ} (result : CAS.Continuum.AdaptiveResult (CAS.Continuum.RationalModelTree.adaptiveSystem expr.univariateEval).error ↑tolerance) : CAS.Certificate.ApproxOn expr.univariateEval (CAS.Continuum.RationalModelTree.model result.result) (Set.Icc ↑a ↑b) ↑tolerance
The model of every adaptive Taylor result approximates
expr.univariateEvalwithintoleranceon[a, b]. AnAdaptiveResultcarries the proof that the error of its tree is at mosttolerance, so this covers every result thatadaptiveToTolerance?returns. - defdefined in CAS/Continuum/ExprAdaptiveTaylor.leancomplete
def CAS.Continuum.ExprAdaptiveTaylor.panelOfRange.{u} {I : Type u} [CAS.Continuum.RealIntervalBackend I] (expr : CAS.Verified.Expr (Fin 1)) (order : ℕ) (a b derivativeBound : ℚ) (hab : ↑a < ↑b) (hvalid : expr.ValidIteratesOn (order + 2) (Set.Icc ↑a ↑b)) (derivativeRange : I) (hrange : ∀ x ∈ Set.Icc ↑a ↑b, CAS.Continuum.RealIntervalBackend.MemReal derivativeRange (CAS.Verified.Expr.eval !₂[x].ofLp (expr.symbolicDerivative (order + 1)))) (hbound : max |CAS.Continuum.RealIntervalBackend.lo derivativeRange| |CAS.Continuum.RealIntervalBackend.hi derivativeRange| ≤ ↑derivativeBound) : CAS.Continuum.RationalBudgetCandidate (CAS.Continuum.RationalModelTree.adaptiveSystem expr.univariateEval).error
def CAS.Continuum.ExprAdaptiveTaylor.panelOfRange.{u} {I : Type u} [CAS.Continuum.RealIntervalBackend I] (expr : CAS.Verified.Expr (Fin 1)) (order : ℕ) (a b derivativeBound : ℚ) (hab : ↑a < ↑b) (hvalid : expr.ValidIteratesOn (order + 2) (Set.Icc ↑a ↑b)) (derivativeRange : I) (hrange : ∀ x ∈ Set.Icc ↑a ↑b, CAS.Continuum.RealIntervalBackend.MemReal derivativeRange (CAS.Verified.Expr.eval !₂[x].ofLp (expr.symbolicDerivative (order + 1)))) (hbound : max |CAS.Continuum.RealIntervalBackend.lo derivativeRange| |CAS.Continuum.RealIntervalBackend.hi derivativeRange| ≤ ↑derivativeBound) : CAS.Continuum.RationalBudgetCandidate (CAS.Continuum.RationalModelTree.adaptiveSystem expr.univariateEval).error
Build one symbolic Taylor leaf from a proved derivative enclosure.
derivativeRangemay come from any implementation ofRealIntervalBackend. Adaptive stopping reads only the exact rationalderivativeBound.
Every accepted leaf is produced from a derivative enclosure and the Taylor
remainder theorem, hence carries a local model certificate. Recursive
subdivision assembles these leaves with the model-tree soundness theorem.
The successful search result also stores that the maximum leaf error is at
most \eta; composing the two facts proves the root-domain approximation.
10.7.4. Derivative Bounds and Adaptive Search
High-order quadrature and Taylor remainders require uniform bounds on the
analytic derivative. Checked symbolic derivatives are identified with
Mathlib's iteratedDerivWithin and then enclosed panel by panel on a declared
real domain.
Adaptive search consumes only these proved local bounds. It may accept a panel, subdivide it, compare two certified trees, or exhaust its depth budget. The search strategy is computational; the returned tree is useful because its root error theorem is independent of that strategy.
From x^4 to an analytic bound.
Let the symbolic expression be e(x)=x^4. Repeated checked differentiation
and normalization produce the constant fourth derivative 24. The
variable-independent route can evaluate that expression once, obtaining the
degenerate enclosure [24,24], and reuse it on every requested panel.
The route then crosses two proof boundaries:
the differentiation theorem identifies the checked symbolic expression with Mathlib's
iteratedDerivWithin 4;the interval theorem turns membership in
[24,24]into an absolute-value upper bound.
The resulting IteratedDerivativeBounderOn proves, for every nondegenerate
panel [a,b] in its declared domain and every x\in[a,b],
\left\|\operatorname{iteratedDerivWithin}
4\,(\lambda x,x^4)\,[a,b]\,x\right\|\leq24.
For the polynomial, smoothness is proved analytically, and a quadrature
theorem receives that ContDiffOn proof separately from the numerical bound.
A rational example with a side condition.
For f(x)=1/(1+x) on [0,1], the fourth derivative simplifies to
24/(1+x)^5. The checked rational route also records the condition
1+x\neq0. Interval positivity proves that condition uniformly because
1\leq1+x\leq2 on the domain.
A range provider can then enclose the simplified derivative. Even a
conservative enclosure such as [-24,24] is sufficient: converting it to a
bound certificate yields the useful conclusion
\left\|f^{(4)}(x)\right\|\leq24
\qquad (0\leq x\leq1).
An IteratedDerivativeBounderOn n f s produces a BoundCert for
\lVert f^{(n)}\rVert on every requested nondegenerate compact interval
contained in s. The specialized interface stores only the scalar panel bound
and its direct proof for Mathlib's iteratedDerivWithin; its generic
BoundCert is a derived projection. Constructors accept a panelwise Lean
estimate, CEGA derivative enclosures, or any sound RealIntervalBackend.
Smoothness is a separate analytic hypothesis; an enclosure of a formal
derivative says nothing about differentiability of the original function.
Lean code for Definition10.67●1 definitionAssociated Lean declarations
- structuredefined in CAS/Continuum/DerivativeBounds.leancomplete
structure CAS.Continuum.IteratedDerivativeBounderOn (n : ℕ) (f : ℝ → ℝ) (s : Set ℝ) : Type
structure CAS.Continuum.IteratedDerivativeBounderOn (n : ℕ) (f : ℝ → ℝ) (s : Set ℝ) : Type
A producer of certified local norm bounds for the
n-th ordinary derivative.The interval is required to be nondegenerate. This keeps local enclosures useful for refinement and ensures that every reported upper bound is nonnegative.
Fields
bound : {a b : ℝ} → a < b → Set.Icc a b ⊆ s → ℝ
Certified upper bound on an ordered interval.
sound : ∀ {a b : ℝ} (hab : a < b) (hsub : Set.Icc a b ⊆ s), CAS.Certificate.BoundOn (fun x ↦ ‖iteratedDerivWithin n f (Set.Icc a b) x‖) (Set.Icc a b) (self.bound hab hsub)
The reported value bounds the intended within-derivative norm.
On a set with UniqueDiffOn ℝ s, assume validity of the intermediate symbolic
derivatives at levels k<n. The order-n checked derivative then denotes
Mathlib's iteratedDerivWithin. This includes every nondegenerate closed
interval contained in the validity domain. The linked regularity theorem
uses the sufficient stronger assumption of validity through level n
inclusive to prove ContDiffOn ℝ n: it establishes continuity of the final
derivative by proving that derivative differentiable.
If e^{[n]} is the expression obtained by n checked symbolic
derivatives, then on every admissible panel [a,b] and every x\in[a,b],
\operatorname{iteratedDerivWithin}
n\,(\lambda y,\operatorname{eval}(e,y))\,[a,b]\,x
=\operatorname{eval}\!\left(e^{[n]},x\right).
Lean code for Theorem10.68●2 theoremsAssociated Lean declarations
- theoremdefined in CAS/Continuum/SymbolicDerivativeBounds.leancomplete
theorem CAS.Verified.Expr.iteratedDerivWithin_univariateEval_eq_symbolicDerivative (expr : CAS.Verified.Expr (Fin 1)) (n : ℕ) {s : Set ℝ} (hs : UniqueDiffOn ℝ s) (hvalid : expr.ValidIteratesOn n s) {x : ℝ} (hx : x ∈ s) : iteratedDerivWithin n expr.univariateEval s x = CAS.Verified.Expr.eval !₂[x].ofLp (expr.symbolicDerivative n)
theorem CAS.Verified.Expr.iteratedDerivWithin_univariateEval_eq_symbolicDerivative (expr : CAS.Verified.Expr (Fin 1)) (n : ℕ) {s : Set ℝ} (hs : UniqueDiffOn ℝ s) (hvalid : expr.ValidIteratesOn n s) {x : ℝ} (hx : x ∈ s) : iteratedDerivWithin n expr.univariateEval s x = CAS.Verified.Expr.eval !₂[x].ofLp (expr.symbolicDerivative n)
On a set
swith unique derivatives on whichexpr.ValidIteratesOn n sholds, Mathlib'siteratedDerivWithin nof the evaluated expression is, at every point ofs, the value ofexpr.symbolicDerivative n. - theoremdefined in CAS/Calculus/IteratedDifferentiation.leancomplete
theorem CAS.Verified.Expr.contDiffOn_univariateEval (expr : CAS.Verified.Expr (Fin 1)) (n : ℕ) {s : Set ℝ} (hs : UniqueDiffOn ℝ s) (hvalid : expr.ValidIteratesOn (n + 1) s) : ContDiffOn ℝ (↑n) expr.univariateEval s
theorem CAS.Verified.Expr.contDiffOn_univariateEval (expr : CAS.Verified.Expr (Fin 1)) (n : ℕ) {s : Set ℝ} (hs : UniqueDiffOn ℝ s) (hvalid : expr.ValidIteratesOn (n + 1) s) : ContDiffOn ℝ (↑n) expr.univariateEval s
Validity of the first
n + 1symbolic derivatives implies that the denoted one-variable function isCⁿon a set with unique derivatives.The additional validity level is used to prove differentiability, hence continuity, of the
n-th symbolic derivative; computing a formal derivative alone would not give smoothness.
Induct on the derivative order. The base case is evaluation itself. At the successor step, apply the one-step symbolic derivative bridge to the current derived expression and use the induction hypothesis to identify the analytic within-derivative already constructed. The validity assumptions propagate to every intermediate expression.
The rational route proposes a polynomial-gcd cancellation, checks its semantic equality through the exact normalizer, and turns generated denominator conditions into interval obligations. Exact rational hulls cover arbitrary real panels, and checked zero exclusion or an absolute lower bound discharges the nonzero conditions on the whole declared domain.
Writing the checked route as \operatorname{route}(d)=(r,S), its semantic
boundary is the conditional identity
\operatorname{SideHolds}(\rho,S)
\quad\Longrightarrow\quad
\operatorname{eval}(d,\rho)=\operatorname{eval}(r,\rho).
The interval phase proves the premise uniformly on the panel.
Lean code for Theorem10.69●3 theoremsAssociated Lean declarations
- theoremdefined in CAS/ClosedForm/RationalCanonical.leancomplete
theorem CAS.Verified.Expr.RationalCanonical.route_sound (expr : CAS.Verified.Expr (Fin 1)) (ρ : Fin 1 → ℝ) (hside : CAS.Verified.Expr.Alg.SideHolds ρ (CAS.Verified.Expr.RationalCanonical.route expr).nonzero) : CAS.Verified.Expr.eval ρ (CAS.Verified.Expr.RationalCanonical.route expr).rhs = CAS.Verified.Expr.eval ρ expr
theorem CAS.Verified.Expr.RationalCanonical.route_sound (expr : CAS.Verified.Expr (Fin 1)) (ρ : Fin 1 → ℝ) (hside : CAS.Verified.Expr.Alg.SideHolds ρ (CAS.Verified.Expr.RationalCanonical.route expr).nonzero) : CAS.Verified.Expr.eval ρ (CAS.Verified.Expr.RationalCanonical.route expr).rhs = CAS.Verified.Expr.eval ρ expr
Semantic soundness of the total route under its generated obligations.
- theoremdefined in CAS/Continuum/IntervalEval/Context.leancomplete
theorem CAS.Continuum.RationalInterval.CertifiedEvalContext.sideHolds_of_certifiesSideConditions.{u_1, u_2} {α : Type u_1} {ι : Type u_2} {s : Set α} {ρ : α → ι → ℝ} (p : CAS.Continuum.RationalInterval.CertifiedEvalContext s ρ) (side : List (CAS.Verified.Expr ι)) (hcheck : p.certifiesSideConditions side = true) (x : α) (hx : x ∈ s) : CAS.Verified.Expr.Alg.SideHolds (ρ x) side
theorem CAS.Continuum.RationalInterval.CertifiedEvalContext.sideHolds_of_certifiesSideConditions.{u_1, u_2} {α : Type u_1} {ι : Type u_2} {s : Set α} {ρ : α → ι → ℝ} (p : CAS.Continuum.RationalInterval.CertifiedEvalContext s ρ) (side : List (CAS.Verified.Expr ι)) (hcheck : p.certifiesSideConditions side = true) (x : α) (hx : x ∈ s) : CAS.Verified.Expr.Alg.SideHolds (ρ x) side
A successful combined check discharges every exact-normalization side condition throughout the context domain.
- theoremdefined in CAS/Continuum/Interval/Rational/Basic.leancomplete
theorem CAS.Continuum.RationalInterval.memReal_rationalHull {d : ℕ} (hd : 0 < d) {a b x : ℝ} (hab : a ≤ b) (hx : x ∈ Set.Icc a b) : (CAS.Continuum.RationalInterval.rationalHull d hd a b hab).MemReal x
theorem CAS.Continuum.RationalInterval.memReal_rationalHull {d : ℕ} (hd : 0 < d) {a b x : ℝ} (hab : a ≤ b) (hx : x ∈ Set.Icc a b) : (CAS.Continuum.RationalInterval.rationalHull d hd a b hab).MemReal x
Every point of
[a, b]lies inrationalHull d hd a b hab.
Polynomial gcd cancellation proposes the reduced rational expression, but the exact normalizer proves the cross-multiplied identity. Checked interval facts then show that every cancelled denominator is nonzero throughout the panel. Substituting those side facts into the conditional normalization theorem gives the pointwise equality used by the derivative bounder.
A verified panel evaluator, checked variable boxes, and a proof of successful evaluation define a total range provider for one symbolic expression. The provider stores the returned backend interval together with its direct enclosure theorem.
For every a<b with [a,b]\subseteq s, its total contract is
\forall x\in[a,b],\qquad
\operatorname{eval}(e,x)\in\operatorname{result}(a,b).
Lean code for Definition10.70●1 definitionAssociated Lean declarations
- defdefined in CAS/Continuum/IntervalEval/Range.leancomplete
def CAS.Continuum.ExprRangeProviderOn.ofPanelEvaluator.{u, v} {I : Type u} [CAS.Continuum.RealIntervalBackend I] {ι : Type v} {expr : CAS.Verified.Expr ι} {ρ : ℝ → ι → ℝ} {s : Set ℝ} (evaluator : CAS.Continuum.VerifiedExprIntervalEvaluator I) (env : {a b : ℝ} → a < b → Set.Icc a b ⊆ s → ι → I) (henv : ∀ {a b : ℝ} (hab : a < b) (hsub : Set.Icc a b ⊆ s), ∀ x ∈ Set.Icc a b, ∀ (i : ι), CAS.Continuum.RealIntervalBackend.MemReal (env hab hsub i) (ρ x i)) (hsuccess : ∀ {a b : ℝ} (hab : a < b) (hsub : Set.Icc a b ⊆ s), (evaluator.eval (env hab hsub) expr).isSome = true) : CAS.Continuum.ExprRangeProviderOn expr ρ s
def CAS.Continuum.ExprRangeProviderOn.ofPanelEvaluator.{u, v} {I : Type u} [CAS.Continuum.RealIntervalBackend I] {ι : Type v} {expr : CAS.Verified.Expr ι} {ρ : ℝ → ι → ℝ} {s : Set ℝ} (evaluator : CAS.Continuum.VerifiedExprIntervalEvaluator I) (env : {a b : ℝ} → a < b → Set.Icc a b ⊆ s → ι → I) (henv : ∀ {a b : ℝ} (hab : a < b) (hsub : Set.Icc a b ⊆ s), ∀ x ∈ Set.Icc a b, ∀ (i : ι), CAS.Continuum.RealIntervalBackend.MemReal (env hab hsub i) (ρ x i)) (hsuccess : ∀ {a b : ℝ} (hab : a < b) (hsub : Set.Icc a b ⊆ s), (evaluator.eval (env hab hsub) expr).isSome = true) : CAS.Continuum.ExprRangeProviderOn expr ρ s
Evaluate an expression afresh on every requested panel.
The caller supplies only a panel-dependent variable box and proves that the backend succeeds on those boxes. The result field is extracted from the successful evaluator run, so no separate interval value or duplicated evaluation equation is required.
The direct constructor encloses the structurally normalized symbolic derivative. A second constructor accepts an explicitly proved rewrite before range evaluation. In both cases the resulting certificate bounds Mathlib's analytic iterated derivative.
For every accepted panel, the produced bound B(a,b) satisfies
\forall x\in[a,b],\qquad
\left\|\operatorname{iteratedDerivWithin}
n\,f\,[a,b]\,x\right\|\leq B(a,b).
Lean code for Definition10.71●2 definitionsAssociated Lean declarations
- defdefined in CAS/Continuum/SymbolicDerivativeBounds.leancomplete
def CAS.Continuum.IteratedDerivativeBounderOn.ofExpr.{u} {I : Type u} [CAS.Continuum.RealIntervalBackend I] (expr : CAS.Verified.Expr (Fin 1)) (n : ℕ) (s : Set ℝ) (hvalid : expr.ValidIteratesOn n s) (provider : CAS.Continuum.ExprRangeProviderOn (expr.symbolicDerivative n) (fun x ↦ !₂[x].ofLp) s) : CAS.Continuum.IteratedDerivativeBounderOn n expr.univariateEval s
def CAS.Continuum.IteratedDerivativeBounderOn.ofExpr.{u} {I : Type u} [CAS.Continuum.RealIntervalBackend I] (expr : CAS.Verified.Expr (Fin 1)) (n : ℕ) (s : Set ℝ) (hvalid : expr.ValidIteratesOn n s) (provider : CAS.Continuum.ExprRangeProviderOn (expr.symbolicDerivative n) (fun x ↦ !₂[x].ofLp) s) : CAS.Continuum.IteratedDerivativeBounderOn n expr.univariateEval s
Compile the structural normalized derivative and a backend range provider into local
iteratedDerivWithinbounds. - defdefined in CAS/Continuum/SymbolicDerivativeBounds.leancomplete
def CAS.Continuum.IteratedDerivativeBounderOn.ofExprWithRewrite.{u} {I : Type u} [CAS.Continuum.RealIntervalBackend I] (expr derivative : CAS.Verified.Expr (Fin 1)) (n : ℕ) (s : Set ℝ) (hvalid : expr.ValidIteratesOn n s) (hrewrite : ∀ x ∈ s, CAS.Verified.Expr.eval !₂[x].ofLp derivative = CAS.Verified.Expr.eval !₂[x].ofLp (expr.symbolicDerivative n)) (provider : CAS.Continuum.ExprRangeProviderOn derivative (fun x ↦ !₂[x].ofLp) s) : CAS.Continuum.IteratedDerivativeBounderOn n expr.univariateEval s
def CAS.Continuum.IteratedDerivativeBounderOn.ofExprWithRewrite.{u} {I : Type u} [CAS.Continuum.RealIntervalBackend I] (expr derivative : CAS.Verified.Expr (Fin 1)) (n : ℕ) (s : Set ℝ) (hvalid : expr.ValidIteratesOn n s) (hrewrite : ∀ x ∈ s, CAS.Verified.Expr.eval !₂[x].ofLp derivative = CAS.Verified.Expr.eval !₂[x].ofLp (expr.symbolicDerivative n)) (provider : CAS.Continuum.ExprRangeProviderOn derivative (fun x ↦ !₂[x].ofLp) s) : CAS.Continuum.IteratedDerivativeBounderOn n expr.univariateEval s
Compile a proved rewrite of a symbolic derivative into local
iteratedDerivWithinbounds.The rewrite may be a stronger normal form than the structural expression produced directly by differentiation. Its semantic equality is an explicit hypothesis, so rational cancellation and other rewrites that depend on side conditions must be proved before the evaluator sees them.
Side-aware constructors consume a checked equality route together with proofs of every emitted nonzero condition. The rational specialization may cancel polynomial factors, but its simplified derivative enters the bounder only through that conditional semantic equality.
The constructor composes
\left(\forall x\in[a,b],\operatorname{SideHolds}(x,S)\right)
\land
\left(\forall x\in[a,b],|\operatorname{eval}(r,x)|\leq B\right)
\quad\Longrightarrow\quad
\forall x\in[a,b],\|f^{(n)}(x)\|\leq B.
Lean code for Definition10.72●2 definitionsAssociated Lean declarations
- defdefined in CAS/Continuum/SymbolicDerivativeBounds.leancomplete
def CAS.Continuum.IteratedDerivativeBounderOn.ofExprWithSideRoute.{u} {I : Type u} [CAS.Continuum.RealIntervalBackend I] (expr : CAS.Verified.Expr (Fin 1)) (route : CAS.Verified.Expr.SideClaimRoute (Fin 1)) (n : ℕ) (s : Set ℝ) (hvalid : expr.ValidIteratesOn n s) (hsource : route.lhs = expr.symbolicDerivative n) (hside : ∀ x ∈ s, CAS.Verified.Expr.Alg.SideHolds !₂[x].ofLp route.nonzero) (provider : CAS.Continuum.ExprRangeProviderOn route.rhs (fun x ↦ !₂[x].ofLp) s) : CAS.Continuum.IteratedDerivativeBounderOn n expr.univariateEval s
def CAS.Continuum.IteratedDerivativeBounderOn.ofExprWithSideRoute.{u} {I : Type u} [CAS.Continuum.RealIntervalBackend I] (expr : CAS.Verified.Expr (Fin 1)) (route : CAS.Verified.Expr.SideClaimRoute (Fin 1)) (n : ℕ) (s : Set ℝ) (hvalid : expr.ValidIteratesOn n s) (hsource : route.lhs = expr.symbolicDerivative n) (hside : ∀ x ∈ s, CAS.Verified.Expr.Alg.SideHolds !₂[x].ofLp route.nonzero) (provider : CAS.Continuum.ExprRangeProviderOn route.rhs (fun x ↦ !₂[x].ofLp) s) : CAS.Continuum.IteratedDerivativeBounderOn n expr.univariateEval s
Compile any checked side-aware simplification route into local derivative bounds.
The route identifies its source expression, carries the semantic proof of its target, and exposes only the emitted side conditions to the caller.
- defdefined in CAS/Continuum/SymbolicDerivativeBounds.leancomplete
def CAS.Continuum.IteratedDerivativeBounderOn.ofRationalExpr.{u} {I : Type u} [CAS.Continuum.RealIntervalBackend I] (expr : CAS.Verified.Expr (Fin 1)) (n : ℕ) (s : Set ℝ) (hvalid : expr.ValidIteratesOn n s) (hside : ∀ x ∈ s, CAS.Verified.Expr.Alg.SideHolds !₂[x].ofLp (CAS.Verified.Expr.RationalCanonical.route (expr.symbolicDerivative n)).nonzero) (provider : CAS.Continuum.ExprRangeProviderOn (CAS.Verified.Expr.RationalCanonical.route (expr.symbolicDerivative n)).rhs (fun x ↦ !₂[x].ofLp) s) : CAS.Continuum.IteratedDerivativeBounderOn n expr.univariateEval s
def CAS.Continuum.IteratedDerivativeBounderOn.ofRationalExpr.{u} {I : Type u} [CAS.Continuum.RealIntervalBackend I] (expr : CAS.Verified.Expr (Fin 1)) (n : ℕ) (s : Set ℝ) (hvalid : expr.ValidIteratesOn n s) (hside : ∀ x ∈ s, CAS.Verified.Expr.Alg.SideHolds !₂[x].ofLp (CAS.Verified.Expr.RationalCanonical.route (expr.symbolicDerivative n)).nonzero) (provider : CAS.Continuum.ExprRangeProviderOn (CAS.Verified.Expr.RationalCanonical.route (expr.symbolicDerivative n)).rhs (fun x ↦ !₂[x].ofLp) s) : CAS.Continuum.IteratedDerivativeBounderOn n expr.univariateEval s
Differentiate, canonically reduce the univariate rational expression, and compile a range provider for the canonical derivative expression into derivative bounds.
Unsupported expressions conservatively use the identity route. Successful gcd cancellation is accepted only after the rational equality checker proves the equality under the generated nonzero conditions.
When the compiled derivative contains no occurrence of the interval variable, one verified evaluation at an enclosure of zero supplies the same bound on every real panel. This avoids asking a finite interval backend to represent arbitrary real endpoints for a constant expression.
Variable independence gives
x\notin\operatorname{vars}(d)
\quad\Longrightarrow\quad
\operatorname{eval}(d,\rho[x\mapsto t])
=\operatorname{eval}(d,\rho[x\mapsto0])
for every t; a single enclosure of the right-hand side is therefore valid
on every requested panel.
Lean code for Definition10.73●1 definitionAssociated Lean declarations
- defdefined in CAS/Continuum/SymbolicDerivativeBounds.leancomplete
def CAS.Continuum.IteratedDerivativeBounderOn.ofIndependentExpr.{u} {I : Type u} [CAS.Continuum.RealIntervalBackend I] (evaluator : CAS.Continuum.VerifiedExprIntervalEvaluator I) (expr : CAS.Verified.Expr (Fin 1)) (n : ℕ) (s : Set ℝ) (hvalid : expr.ValidIteratesOn n s) (hindependent : CAS.Verified.Expr.containsVar 0 (expr.symbolicDerivative n) = false) (input result : I) (hzero : CAS.Continuum.RealIntervalBackend.MemReal input 0) (hevaluated : evaluator.eval (fun x ↦ input) (expr.symbolicDerivative n) = some result) : CAS.Continuum.IteratedDerivativeBounderOn n expr.univariateEval s
def CAS.Continuum.IteratedDerivativeBounderOn.ofIndependentExpr.{u} {I : Type u} [CAS.Continuum.RealIntervalBackend I] (evaluator : CAS.Continuum.VerifiedExprIntervalEvaluator I) (expr : CAS.Verified.Expr (Fin 1)) (n : ℕ) (s : Set ℝ) (hvalid : expr.ValidIteratesOn n s) (hindependent : CAS.Verified.Expr.containsVar 0 (expr.symbolicDerivative n) = false) (input result : I) (hzero : CAS.Continuum.RealIntervalBackend.MemReal input 0) (hevaluated : evaluator.eval (fun x ↦ input) (expr.symbolicDerivative n) = some result) : CAS.Continuum.IteratedDerivativeBounderOn n expr.univariateEval s
Compile a derivative that normalizes to an expression independent of the sole variable.
Only one backend input interval, enclosing zero, is required: the derivative is evaluated once and the same range serves every panel, so the backend never has to enclose the panel endpoints.
A successful adaptive result contains a quadrature tree together with a proof that the sum of its leaf errors is at most the root tolerance. Projecting this result gives the ordinary interval-integral estimate for the tree's accumulated value.
For R:\mathrm{WithErrorAtMost}(f,a,b,\tau), the public theorem is
\left\|\int_a^b f(x)\,dx
-R.\mathrm{tree}.\mathrm{value}\right\|\leq\tau.
Lean code for Theorem10.74●1 theoremAssociated Lean declarations
- theoremdefined in CAS/Continuum/Quadrature/Subdivision.leancomplete
theorem CAS.Continuum.QuadratureTree.WithErrorAtMost.sound.{u_1} {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : ℝ → E} {a b tolerance : ℝ} (result : CAS.Continuum.QuadratureTree.WithErrorAtMost f a b tolerance) : ‖(∫ (x : ℝ) in a..b, f x) - result.tree.toCert.value‖ ≤ tolerance
theorem CAS.Continuum.QuadratureTree.WithErrorAtMost.sound.{u_1} {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : ℝ → E} {a b tolerance : ℝ} (result : CAS.Continuum.QuadratureTree.WithErrorAtMost f a b tolerance) : ‖(∫ (x : ℝ) in a..b, f x) - result.tree.toCert.value‖ ≤ tolerance
An accepted tree directly certifies the requested integral error.
The quadrature tree's soundness theorem bounds the root error by the sum of its
leaf budgets. The dependent result type stores a proof that this accumulated
budget is at most \tau; transitivity gives the displayed estimate.
The generic depth-bounded search takes a proved local panel builder and
interval integrability on every nondegenerate panel in the domain. It accepts
a panel when its certificate meets the local tolerance, even at depth zero.
Otherwise it bisects and gives each child half the budget if depth remains;
with no depth left, it returns none. This generic definition compares real
error bounds; the rational-budget interface supplies exact rational stopping
comparisons.
Every successful search satisfies
\operatorname{search}(d,a,b,\tau)=\operatorname{some}(R)
\quad\Longrightarrow\quad
\left\|\int_a^b f-R.\mathrm{tree}.\mathrm{value}\right\|\leq\tau.
Lean code for Definition10.75●1 definitionAssociated Lean declarationsCAS.Continuum.AdaptiveQuadrature.search[complete]
CAS.Continuum.AdaptiveQuadrature.search[complete]
- defdefined in CAS/Continuum/Quadrature/Adaptive.leancomplete
def CAS.Continuum.AdaptiveQuadrature.search {f : ℝ → ℝ} {s : Set ℝ} (build : CAS.Continuum.AdaptiveQuadrature.PanelBuilderOn f s) (integrable : ∀ {a b : ℝ}, a < b → Set.Icc a b ⊆ s → IntervalIntegrable f MeasureTheory.volume a b) (depth : ℕ) (a b : ℝ) (hab : a < b) : Set.Icc a b ⊆ s → (tolerance : ℝ) → Option (CAS.Continuum.QuadratureTree.WithErrorAtMost f a b tolerance)
def CAS.Continuum.AdaptiveQuadrature.search {f : ℝ → ℝ} {s : Set ℝ} (build : CAS.Continuum.AdaptiveQuadrature.PanelBuilderOn f s) (integrable : ∀ {a b : ℝ}, a < b → Set.Icc a b ⊆ s → IntervalIntegrable f MeasureTheory.volume a b) (depth : ℕ) (a b : ℝ) (hab : a < b) : Set.Icc a b ⊆ s → (tolerance : ℝ) → Option (CAS.Continuum.QuadratureTree.WithErrorAtMost f a b tolerance)
Depth-bounded adaptive search for a total local quadrature method.
This is the
some-valued specialization ofsearchPartial; total and partial builders therefore share one bisection and tolerance-allocation semantics.
CAS.Continuum.PanelRule.search[complete]CAS.Continuum.simpsonRule.fourthOrder[complete]
Adaptive Simpson search instantiates the generic engine with sharp local Simpson certificates built from panelwise fourth-derivative bounds.
Every successful result therefore proves
\operatorname{simpsonRule.fourthOrder.search}(\ldots)=\operatorname{some}(R)
\quad\Longrightarrow\quad
\left|\int_a^b f-R.\mathrm{tree}.\mathrm{value}\right|\leq\tau,
with each accepted leaf justified by the fourth-order Simpson bound.
Lean code for Definition10.76●2 definitionsAssociated Lean declarationsCAS.Continuum.PanelRule.search[complete]CAS.Continuum.simpsonRule.fourthOrder[complete]
CAS.Continuum.PanelRule.search[complete]CAS.Continuum.simpsonRule.fourthOrder[complete]
- defdefined in CAS/Continuum/Quadrature/PanelRule.leancomplete
def CAS.Continuum.PanelRule.search {m : ℕ} (R : CAS.Continuum.PanelRule m) {f : ℝ → ℝ} {s : Set ℝ} (hf : ContDiffOn ℝ (↑m) f s) (bounder : CAS.Continuum.IteratedDerivativeBounderOn m f s) (depth : ℕ) (a b : ℝ) (hab : a < b) : Set.Icc a b ⊆ s → (tolerance : ℝ) → Option (CAS.Continuum.QuadratureTree.WithErrorAtMost f a b tolerance)
def CAS.Continuum.PanelRule.search {m : ℕ} (R : CAS.Continuum.PanelRule m) {f : ℝ → ℝ} {s : Set ℝ} (hf : ContDiffOn ℝ (↑m) f s) (bounder : CAS.Continuum.IteratedDerivativeBounderOn m f s) (depth : ℕ) (a b : ℝ) (hab : a < b) : Set.Icc a b ⊆ s → (tolerance : ℝ) → Option (CAS.Continuum.QuadratureTree.WithErrorAtMost f a b tolerance)
Depth-bounded adaptive search with the rule's panels as leaves.
At depth zero the current panel must already meet the tolerance. At positive depth, a rejected panel is bisected and each child is checked against half the parent tolerance. Exhausting the depth budget returns
none. - defdefined in CAS/Continuum/Quadrature/CompositeSimpson.leancomplete
def CAS.Continuum.simpsonRule.fourthOrder : CAS.Continuum.PanelRule 4
def CAS.Continuum.simpsonRule.fourthOrder : CAS.Continuum.PanelRule 4
Simpson's rule as a panel rule of order
4, with its sharp one-panel constant2880.
CAS.Continuum.PanelRule.search[complete]CAS.Continuum.gaussLegendreTwoRule.fourthOrder[complete]
Adaptive two-point Gauss–Legendre search uses the same subdivision policy with the corresponding sharp Peano-kernel certificate at each accepted leaf.
Its successful-result contract is likewise
\operatorname{gaussLegendreTwoRule.fourthOrder.search}(\ldots)
=\operatorname{some}(R)
\quad\Longrightarrow\quad
\left|\int_a^b f-R.\mathrm{tree}.\mathrm{value}\right|\leq\tau.
Lean code for Definition10.77●2 definitionsAssociated Lean declarationsCAS.Continuum.PanelRule.search[complete]CAS.Continuum.gaussLegendreTwoRule.fourthOrder[complete]
CAS.Continuum.PanelRule.search[complete]CAS.Continuum.gaussLegendreTwoRule.fourthOrder[complete]
- defdefined in CAS/Continuum/Quadrature/PanelRule.leancomplete
def CAS.Continuum.PanelRule.search {m : ℕ} (R : CAS.Continuum.PanelRule m) {f : ℝ → ℝ} {s : Set ℝ} (hf : ContDiffOn ℝ (↑m) f s) (bounder : CAS.Continuum.IteratedDerivativeBounderOn m f s) (depth : ℕ) (a b : ℝ) (hab : a < b) : Set.Icc a b ⊆ s → (tolerance : ℝ) → Option (CAS.Continuum.QuadratureTree.WithErrorAtMost f a b tolerance)
def CAS.Continuum.PanelRule.search {m : ℕ} (R : CAS.Continuum.PanelRule m) {f : ℝ → ℝ} {s : Set ℝ} (hf : ContDiffOn ℝ (↑m) f s) (bounder : CAS.Continuum.IteratedDerivativeBounderOn m f s) (depth : ℕ) (a b : ℝ) (hab : a < b) : Set.Icc a b ⊆ s → (tolerance : ℝ) → Option (CAS.Continuum.QuadratureTree.WithErrorAtMost f a b tolerance)
Depth-bounded adaptive search with the rule's panels as leaves.
At depth zero the current panel must already meet the tolerance. At positive depth, a rejected panel is bisected and each child is checked against half the parent tolerance. Exhausting the depth budget returns
none. - defdefined in CAS/Continuum/Quadrature/CompositeGaussLegendre.leancomplete
def CAS.Continuum.gaussLegendreTwoRule.fourthOrder : CAS.Continuum.PanelRule 4
def CAS.Continuum.gaussLegendreTwoRule.fourthOrder : CAS.Continuum.PanelRule 4
The two-point Gauss-Legendre rule as a panel rule of order
4, with its sharp one-panel constant4320.
Why subdivision can improve a certificate.
For f(x)=x^5 on [0,1], the fourth derivative is 120x. The root panel
may therefore receive the bound 120, while its left half receives the
sharper bound 60.
If the root certificate exceeds its assigned tolerance, adaptive search
bisects the interval and asks the same derivative-bound object for each child.
The sharp Simpson budget on a panel of width h is
C h^5/2880, where C bounds the fourth derivative. Thus the unsplit
budget is 120/2880=1/24, while the two half-panel budgets are
\frac{60(1/2)^5}{2880}=\frac1{1536},
\qquad
\frac{120(1/2)^5}{2880}=\frac1{768}.
Their sum is 1/512. Most of the gain comes from the fifth power of the
panel width; the smaller derivative bound on the left improves it further.
In this construction, both children meet tolerance 1/384, and
adding the child certificates gives an estimate with analytic error
1/512. The arithmetic that chooses to split plays no part in the proof,
which uses only the two local error bounds, interval
integrability, and additivity of the interval integral.
A rational-budget candidate contains a client result, an exact rational upper bound for its semantic error, and a proof relating the two. When decidable rational comparison accepts the candidate, its real error is at most the requested rational tolerance.
Precisely,
\operatorname{accepted}(c,\tau)=\mathrm{true}
\quad\Longrightarrow\quad
\operatorname{error}(c.\mathrm{cert})\leq(\tau:\mathbb R).
Lean code for Theorem10.78●1 theoremAssociated Lean declarations
- theoremdefined in CAS/Continuum/RationalAdaptiveSearch.leancomplete
theorem CAS.Continuum.RationalBudgetCandidate.error_le_of_accepted.{u_1} {Result : Type u_1} {error : Result → ℝ} (candidate : CAS.Continuum.RationalBudgetCandidate error) (tolerance : ℚ) (haccepted : candidate.accepted tolerance = true) : error candidate.cert ≤ ↑tolerance
theorem CAS.Continuum.RationalBudgetCandidate.error_le_of_accepted.{u_1} {Result : Type u_1} {error : Result → ℝ} (candidate : CAS.Continuum.RationalBudgetCandidate error) (tolerance : ℚ) (haccepted : candidate.accepted tolerance = true) : error candidate.cert ≤ ↑tolerance
An accepted candidate meets the requested real tolerance.
The candidate's proof bounds its semantic real error by the cast of its exact
rational budget. Boolean acceptance is precisely the decidable rational
comparison of that budget with \tau. Casting this comparison to the reals
and composing the inequalities proves the result.
The generic rational adaptive kernel keeps endpoints, midpoints, and local tolerances exact. A rejected or unavailable parent candidate is bisected at its rational midpoint; accepted children are combined only through the client's proved error-subadditivity theorem.
The dependent result type records the invariant
\operatorname{searchPartial}(\ldots,\tau)=\operatorname{some}(R)
\quad\Longrightarrow\quad
\operatorname{error}(R.\mathrm{result})\leq(\tau:\mathbb R).
Lean code for Definition10.79●1 definitionAssociated Lean declarations
- defdefined in CAS/Continuum/RationalAdaptiveSearch.leancomplete
def CAS.Continuum.RationalAdaptiveSystem.searchPartial (system : CAS.Continuum.RationalAdaptiveSystem) {s : Set ℝ} (build : system.PartialBuilderOn s) (depth : ℕ) (a b : ℚ) : ↑a < ↑b → Set.Icc ↑a ↑b ⊆ s → (tolerance : ℚ) → Option (CAS.Continuum.AdaptiveResult system.error ↑tolerance)
def CAS.Continuum.RationalAdaptiveSystem.searchPartial (system : CAS.Continuum.RationalAdaptiveSystem) {s : Set ℝ} (build : system.PartialBuilderOn s) (depth : ℕ) (a b : ℚ) : ↑a < ↑b → Set.Icc ↑a ↑b ⊆ s → (tolerance : ℚ) → Option (CAS.Continuum.AdaptiveResult system.error ↑tolerance)
Depth-bounded generic adaptive search.
The domain arguments ensure every recursively generated panel remains inside the ambient analytic domain. They are proof-only; all executable decisions use exact rational arithmetic.
The quadrature specialization stores accepted local QuadratureCerts in the
same backend-independent tree used by real-valued adaptive search. Local
interval-integrability evidence justifies composing adjacent panel integrals.
Both an over-budget root and a missing root candidate may therefore be
recovered by proved child certificates, while a failed finite search returns
none.
On success it returns exactly the root theorem
\left|\int_a^b f(x)\,dx
-R.\mathrm{tree}.\mathrm{value}\right|\leq(\tau:\mathbb R),
where a, b, and \tau are the input rationals cast to reals.
Lean code for Definition10.80●1 definitionAssociated Lean declarations
- defdefined in CAS/Continuum/Quadrature/RationalAdaptive.leancomplete
def CAS.Continuum.RationalAdaptiveQuadrature.searchPartial {f : ℝ → ℝ} {s : Set ℝ} (build : (CAS.Continuum.RationalAdaptiveQuadrature.system f).PartialBuilderOn s) (depth : ℕ) (a b : ℚ) (hab : ↑a < ↑b) (hsub : Set.Icc ↑a ↑b ⊆ s) (tolerance : ℚ) : Option (CAS.Continuum.QuadratureTree.WithErrorAtMost f ↑a ↑b ↑tolerance)
def CAS.Continuum.RationalAdaptiveQuadrature.searchPartial {f : ℝ → ℝ} {s : Set ℝ} (build : (CAS.Continuum.RationalAdaptiveQuadrature.system f).PartialBuilderOn s) (depth : ℕ) (a b : ℚ) (hab : ↑a < ↑b) (hsub : Set.Icc ↑a ↑b ⊆ s) (tolerance : ℚ) : Option (CAS.Continuum.QuadratureTree.WithErrorAtMost f ↑a ↑b ↑tolerance)
Depth-bounded, fail-closed quadrature search, implemented by the shared exact rational search
RationalAdaptiveSystem.searchPartial. The builder keeps rational endpoints while its domain hypotheses and resulting quadrature tree use their real casts.
Competing subdivision trees for the same interval can be compared by their proved error budgets. The selector returns a tree with the minimum budget. More generally, a dependent leaf-refinement rule may propose a replacement tree at every accepted leaf; retaining the better local alternative is proved never to increase the accumulated root error. Candidate generation is untrusted.
For two root trees T_1,T_2,
\left\|\int_a^b f
-\operatorname{select}(T_1,T_2).\mathrm{value}\right\|
\leq\min\!\left(E(T_1),E(T_2)\right),
and leafwise improvement satisfies E(\operatorname{improve}(T))\leq E(T).
Lean code for Theorem10.81●2 theoremsAssociated Lean declarations
- theoremdefined in CAS/Continuum/Quadrature/Adaptive.leancomplete
theorem CAS.Continuum.QuadratureTree.selectLowerError_sound.{u_1} {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : ℝ → E} {a b : ℝ} (first second : CAS.Continuum.QuadratureTree f a b) : ‖(∫ (x : ℝ) in a..b, f x) - (first.selectLowerError second).toCert.value‖ ≤ min first.toCert.error second.toCert.error
theorem CAS.Continuum.QuadratureTree.selectLowerError_sound.{u_1} {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : ℝ → E} {a b : ℝ} (first second : CAS.Continuum.QuadratureTree f a b) : ‖(∫ (x : ℝ) in a..b, f x) - (first.selectLowerError second).toCert.value‖ ≤ min first.toCert.error second.toCert.error
The selected tree retains an ordinary root quadrature-error theorem.
- theoremdefined in CAS/Continuum/Quadrature/Adaptive.leancomplete
theorem CAS.Continuum.QuadratureTree.improveLeaves_error_le.{u_1} {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : ℝ → E} {a b : ℝ} (refiner : CAS.Continuum.QuadratureTree.LeafRefiner f) (tree : CAS.Continuum.QuadratureTree f a b) : (CAS.Continuum.QuadratureTree.improveLeaves (fun {a b} ↦ refiner) tree).toCert.error ≤ tree.toCert.error
theorem CAS.Continuum.QuadratureTree.improveLeaves_error_le.{u_1} {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : ℝ → E} {a b : ℝ} (refiner : CAS.Continuum.QuadratureTree.LeafRefiner f) (tree : CAS.Continuum.QuadratureTree f a b) : (CAS.Continuum.QuadratureTree.improveLeaves (fun {a b} ↦ refiner) tree).toCert.error ≤ tree.toCert.error
A leaf-refinement pass cannot increase the accumulated root error budget.
For two complete trees, choose the one whose stored error budget is smaller; its existing soundness theorem supplies the integral estimate. For leafwise refinement, use structural induction on the original tree. At each leaf retain the original certificate or a proved-better replacement, and at each branch add the two inductive error inequalities.
A candidate family associates mesh, rule, or arithmetic-schedule keys with
ordinary quadrature certificates and an executable Boolean acceptance test.
The policy proves that every accepted result meets the requested tolerance.
Finite search returns the first accepted key together with that theorem, or
none if every candidate fails.
If finite search returns an accepted key k, its projection proves
\left\|\int_a^b f(x)\,dx
-\operatorname{candidate}(k).\mathrm{value}\right\|\leq\tau.
Lean code for Theorem10.82●1 theoremAssociated Lean declarations
- theoremdefined in CAS/Continuum/Quadrature/Search.leancomplete
theorem CAS.Continuum.QuadratureCandidateFamily.AcceptedCandidate.sound.{u_1, u_2} {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : ℝ → E} {a b tolerance : ℝ} {κ : Type u_2} {family : CAS.Continuum.QuadratureCandidateFamily κ f a b tolerance} (accepted : family.AcceptedCandidate) : ‖(∫ (x : ℝ) in a..b, f x) - accepted.cert.value‖ ≤ tolerance
theorem CAS.Continuum.QuadratureCandidateFamily.AcceptedCandidate.sound.{u_1, u_2} {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : ℝ → E} {a b tolerance : ℝ} {κ : Type u_2} {family : CAS.Continuum.QuadratureCandidateFamily κ f a b tolerance} (accepted : family.AcceptedCandidate) : ‖(∫ (x : ℝ) in a..b, f x) - accepted.cert.value‖ ≤ tolerance
The accepted candidate satisfies the requested integral error bound.
Finite search returns a key only together with evidence that the family's acceptance predicate holds for that key. The policy theorem converts this evidence into the requested tolerance bound, and the candidate's stored quadrature soundness identifies the quantity being bounded. A failed search has no conclusion to prove.
Exact-rational candidate families obtain their Boolean test from rational
comparison and transport the result to a real error theorem. A FloatLib
enclosure of the exact rule value gives another such candidate: its certified
endpoint radius bounds replacement by the midpoint, and that radius is added
to the analytic error. For rounded endpoints, the radius must use their exact
decoded values. The derivative enclosure must still bound the analytic
derivative on the whole panel: order four supplies the Simpson remainder,
and order n+1 supplies the degree-n Taylor remainder.
The common derivative object is used by the Simpson and two-point Gauss–Legendre constructors for one panel, fixed composites, planned tolerances, and adaptive subdivision. The total tolerance planner reserves part of the budget for analytic error and accepts a replacement value only when its proved numerical error fits the remainder.

