Mathlib.Analysis.Certified­Contour­Interval­Arithmetic

Certified numerical-analysis infrastructure: exact rational intervals, effective certified-real refinement, transcendental enclosures, Lipschitz mesh quadrature, and measurable finite selection.

Complex 108 core · 69 supporting · 11 submodules Certified complex numerical semantics: rational rectangle arithmetic, refining complex names, elementary transcendental enclosures, scheduled circle nodes, and finite contour quadrature.
Basic 18 core · 29 supporting This module provides closed intervals with rational endpoints and exact endpoint algorithms for the elementary arithmetic operations. ★ mul_sound

Exact rational interval arithmetic

This module provides closed intervals with rational endpoints and exact endpoint algorithms for the elementary arithmetic operations. Each operation is proved to enclose the corresponding real-number calculation, and the inclusion order records safe refinement of an enclosure.

structure RatInterval reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic

A rational closed interval consists of a rational lower endpoint and a rational upper endpoint, with the lower endpoint no greater than the upper endpoint.

Definition (Lean source)
The rational lower endpoint of the enclosure.
lo :
The rational upper endpoint of the enclosure.
hi :
The lower endpoint does not exceed the upper endpoint.
lo_le_hi :
lo ≤ hi
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:18
def Contains reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For a rational interval and a real number, the containment relation holds precisely when the real number is no smaller than the interval's lower endpoint and no larger than its upper endpoint, after the rational endpoints are viewed as real numbers.

Definition (Lean source)
x :
Contains I x :
Prop
clause 1
(I.lo : ℝ) ≤ x
clause 2
x ≤ (I.hi : ℝ)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.Contains · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:32 · uses RatInterval
def width reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For a rational interval, its width is the upper rational endpoint minus the lower rational endpoint.

Definition (Lean source)
width I :
I.hi - I.lo
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:36 · uses RatInterval
def maxAbs reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For a rational interval, its maximum endpoint magnitude is the larger of the absolute values of its two rational endpoints.

Definition (Lean source)
maxAbs I :
max |I.lo| |I.hi|
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.maxAbs · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:39 · uses RatInterval
def Subinterval reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For two rational intervals, the subinterval relation holds precisely when the second interval's lower endpoint is no greater than the first interval's lower endpoint and the first interval's upper endpoint is no greater than the second interval's upper endpoint.

Definition (Lean source)
I J :
Subinterval I J :
Prop
clause 1
J.lo ≤ I.lo
clause 2
I.hi ≤ J.hi
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.Subinterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:42 · uses RatInterval
def point reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For a rational number, the point interval at that number is the rational interval whose lower endpoint is that number, upper endpoint is that number, and endpoints are ordered because they are equal.

Definition (Lean source)
q :
point q :
⟨q, q, le_rfl⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.point · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:46 · uses RatInterval
def hull reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For two rational intervals, their rational interval hull has the smaller lower endpoint, the larger upper endpoint, and these endpoints in weakly increasing order.

Definition (Lean source)
I J :
hull I J :
⟨min I.lo J.lo, max I.hi J.hi, by exact (min_le_left _ _).trans (I.lo_le_hi.trans (le_max_left _ _))⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.hull · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:49 · uses RatInterval
def add reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For two rational intervals, their interval sum has lower endpoint equal to the sum of the lower endpoints, upper endpoint equal to the sum of the upper endpoints, and valid endpoint order.

Definition (Lean source)
I J :
add I J :
⟨I.lo + J.lo, I.hi + J.hi, add_le_add I.lo_le_hi J.lo_le_hi⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.add · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:54 · uses RatInterval
def neg reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For a rational interval, its interval negation has lower endpoint equal to the negative of the original upper endpoint, upper endpoint equal to the negative of the original lower endpoint, and valid endpoint order.

Definition (Lean source)
neg I :
⟨-I.hi, -I.lo, neg_le_neg I.lo_le_hi⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.neg · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:58 · uses RatInterval
def sub reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For two rational intervals, their interval difference is the interval sum of the first interval and the interval negation of the second.

Definition (Lean source)
I J :
sub I J :
add I (neg J)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.sub · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:62 · uses RatInterval
def mul reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For two rational intervals, their interval product has lower endpoint equal to the least of the four products of one endpoint from each interval, upper endpoint equal to the greatest of those four products, and valid endpoint order.

Definition (Lean source)
I J :
mul I J :
a :
I.lo * J.lo
b :
I.lo * J.hi
c :
I.hi * J.lo
d :
I.hi * J.hi
⟨min (min a b) (min c d), max (max a b) (max c d), by exact (min_le_left _ _).trans ((min_le_left _ _).trans ((le_max_left _ _).trans (le_max_left _ _)))⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.mul · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:65 · uses RatInterval
def AwayFromZero reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For a rational interval, the property of being separated from zero holds precisely when the interval lies strictly below zero or strictly above zero.

Definition (Lean source)
AwayFromZero I :
Prop
I.hi < 0 ∨ 0 < I.lo
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.AwayFromZero · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:75 · uses RatInterval
def inv reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For a rational interval that is separated from zero, its interval reciprocal has lower endpoint equal to the reciprocal of the original upper endpoint, upper endpoint equal to the reciprocal of the original lower endpoint, and valid endpoint order.

Definition (Lean source)
hI :
I.AwayFromZero
inv I hI :
⟨I.hi⁻¹, I.lo⁻¹, by rcases hI with hI | hI · exact (inv_le_inv_of_neg hI (I.lo_le_hi.trans_lt hI)).2 I.lo_le_hi · exact (inv_le_inv₀ (hI.trans_le I.lo_le_hi) hI).2 I.lo_le_hi⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.inv · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:78 · uses RatInterval , AwayFromZero
def div reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For a numerator rational interval and a denominator rational interval whose denominator interval is separated from zero, their interval quotient is the interval product of the numerator interval and the interval reciprocal of the denominator interval.

Definition (Lean source)
I J :
hJ :
J.AwayFromZero
div I J hJ :
mul I (inv J hJ)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.div · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:85 · uses RatInterval , AwayFromZero
def npow reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For a rational interval, its natural-power interval sequence assigns the point interval at one to exponent zero and the interval product of the preceding power and the original interval to each positive exponent.

Definition (Lean source)
npow I :
ℕ → RatInterval
clause 1
| 0 => point 1
clause 2
| n + 1 => mul (npow I n) I
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.npow · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:88 · uses RatInterval
def tighten reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For two rational intervals, their conditional tightening is their exact intersection when its lower endpoint does not exceed its upper endpoint, and the first interval otherwise.

Definition (Lean source)
I J :
tighten I J :
if h : max I.lo J.lo ≤ min I.hi J.hi then ⟨max I.lo J.lo, min I.hi J.hi, h⟩ else I
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.tighten · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:93 · uses RatInterval
def expand reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For a rational interval, a rational widening amount that is nonnegative, the expanded interval has lower endpoint equal to the original lower endpoint minus the widening amount, upper endpoint equal to the original upper endpoint plus the widening amount, and valid endpoint order.

Definition (Lean source)
e :
he :
0 ≤ e
expand I e he :
⟨I.lo - e, I.hi + e, by linarith [I.lo_le_hi]⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.expand · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:99 · uses RatInterval
theorem mul_sound reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

For rational intervals I and J, if x is a real number contained in I and y is a real number contained in J, then the interval-multiplication enclosure mul I J contains the real product x * y.

Formal statement
I J :
x y :
hx :
I.Contains x
hy :
J.Contains y
(mul I J).Contains (x * y)
Proof (Lean source)
theorem mul_sound {I J : RatInterval} {x y : ℝ} (hx : I.Contains x) (hy : J.Contains y) : (mul I J).Contains (x * y) := by rcases hx with ⟨hxl, hxu⟩ rcases hy with ⟨hyl, hyu⟩ simp only [mul, Contains, Rat.cast_min, Rat.cast_max, Rat.cast_mul] constructor · by_cases hx0 : 0 ≤ x · by_cases hy0 : 0 ≤ y · by_cases hIl : 0 ≤ (I.lo : ℝ) · refine (min_le_of_left_le (min_le_of_left_le ?_)) calc (I.lo : ℝ) * J.lo ≤ I.lo * y := mul_le_mul_of_nonneg_left hyl hIl _ ≤ x * y := mul_le_mul_of_nonneg_right hxl hy0 · refine (min_le_of_left_le (min_le_of_right_le ?_)) calc (I.lo : ℝ) * J.hi ≤ I.lo * y := mul_le_mul_of_nonpos_left hyu (le_of_not_ge hIl) _ ≤ x * y := mul_le_mul_of_nonneg_right hxl hy0 · have hy0' : y ≤ 0 := le_of_not_ge hy0 refine (min_le_of_right_le (min_le_of_left_le ?_)) calc (I.hi : ℝ) * J.lo ≤ I.hi * y := mul_le_mul_of_nonneg_left hyl (hx0.trans hxu) _ ≤ x * y := mul_le_mul_of_nonpos_right hxu hy0' · have hx0' : x ≤ 0 := le_of_not_ge hx0 by_cases hy0 : 0 ≤ y · refine (min_le_of_left_le (min_le_of_right_le ?_)) calc (I.lo : ℝ) * J.hi ≤ x * J.hi := mul_le_mul_of_nonneg_right hxl (hy0.trans hyu) _ ≤ x * y := mul_le_mul_of_nonpos_left hyu hx0' · have hy0' : y ≤ 0 := le_of_not_ge hy0 by_cases hIh : (I.hi : ℝ) ≤ 0 · refine (min_le_of_right_le (min_le_of_right_le ?_)) calc (I.hi : ℝ) * J.hi ≤ I.hi * y := mul_le_mul_of_nonpos_left hyu hIh _ ≤ x * y := mul_le_mul_of_nonpos_right hxu hy0' · refine (min_le_of_right_le (min_le_of_left_le ?_)) calc (I.hi : ℝ) * J.lo ≤ I.hi * y := mul_le_mul_of_nonneg_left hyl (le_of_not_ge hIh) _ ≤ x * y := mul_le_mul_of_nonpos_right hxu hy0' · by_cases hx0 : 0 ≤ x · by_cases hy0 : 0 ≤ y · refine (le_max_of_le_right (le_max_of_le_right ?_)) calc x * y ≤ (I.hi : ℝ) * y := mul_le_mul_of_nonneg_right hxu hy0 _ ≤ I.hi * J.hi := mul_le_mul_of_nonneg_left hyu (hx0.trans hxu) · have hy0' : y ≤ 0 := le_of_not_ge hy0 by_cases hIl : 0 ≤ (I.lo : ℝ) · refine (le_max_of_le_left (le_max_of_le_right ?_)) calc x * y ≤ (I.lo : ℝ) * y := mul_le_mul_of_nonpos_right hxl hy0' _ ≤ I.lo * J.hi := mul_le_mul_of_nonneg_left hyu hIl · refine (le_max_of_le_left (le_max_of_le_left ?_)) calc x * y ≤ (I.lo : ℝ) * y := mul_le_mul_of_nonpos_right hxl hy0' _ ≤ I.lo * J.lo := mul_le_mul_of_nonpos_left hyl (le_of_not_ge hIl) · have hx0' : x ≤ 0 := le_of_not_ge hx0 by_cases hy0 : 0 ≤ y · by_cases hJl : 0 ≤ (J.lo : ℝ) · refine (le_max_of_le_right (le_max_of_le_left ?_)) calc x * y ≤ x * (J.lo : ℝ) := mul_le_mul_of_nonpos_left hyl hx0' _ ≤ I.hi * J.lo := mul_le_mul_of_nonneg_right hxu hJl · refine (le_max_of_le_left (le_max_of_le_left ?_)) calc x * y ≤ x * (J.lo : ℝ) := mul_le_mul_of_nonpos_left hyl hx0' _ ≤ I.lo * J.lo := mul_le_mul_of_nonpos_right hxl (le_of_not_ge hJl) · have hy0' : y ≤ 0 := le_of_not_ge hy0 refine (le_max_of_le_left (le_max_of_le_left ?_)) calc x * y ≤ (I.lo : ℝ) * y := mul_le_mul_of_nonpos_right hxl hy0' _ ≤ I.lo * J.lo := mul_le_mul_of_nonpos_left hyl (hxl.trans hx0')
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.mul_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:161 · uses RatInterval , Contains , mul
29 supporting declarations (lemmas, instances)
  • ext theorem
    ∀ {x y : RatInterval}, x.lo = y.lo → x.hi = y.hi → x = y
    Proof (Lean source)
    @[ext]
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.ext · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:21
  • ext_iff theorem
    ∀ {x y : RatInterval}, x = y ↔ x.lo = y.lo ∧ x.hi = y.hi
    Proof (Lean source)
    @[ext]
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.ext_iff · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:21
  • width_nonneg theorem — Every rational interval has nonnegative width.
    0 ≤ I.width
    Proof (Lean source)
    theorem width_nonneg (I : RatInterval) : 0 ≤ I.width := by exact sub_nonneg.mpr I.lo_le_hi
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.width_nonneg · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:103
  • contains_point_iff theorem — Containment in a point interval is equality with that rational point.
    q :
    x :
    (point q).Contains x ↔ x = (q : ℝ)
    Proof (Lean source)
    @[simp] theorem contains_point_iff (q : ℚ) (x : ℝ) : (point q).Contains x ↔ x = (q : ℝ) := by constructor · rintro ⟨hlo, hhi⟩ exact le_antisymm hhi hlo · rintro rfl exact ⟨le_rfl, le_rfl⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.contains_point_iff · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:107
  • subinterval_refl theorem — Subinterval is reflexive.
    I.Subinterval I
    Proof (Lean source)
    theorem subinterval_refl (I : RatInterval) : I.Subinterval I := by exact ⟨le_rfl, le_rfl⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.subinterval_refl · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:116
  • subinterval_trans theorem — Subinterval is transitive.
    I J K :
    I.Subinterval J
    J.Subinterval K
    I.Subinterval K
    Proof (Lean source)
    theorem subinterval_trans {I J K : RatInterval} : I.Subinterval J → J.Subinterval K → I.Subinterval K := by rintro ⟨hlo₁, hhi₁⟩ ⟨hlo₂, hhi₂⟩ exact ⟨hlo₂.trans hlo₁, hhi₁.trans hhi₂⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.subinterval_trans · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:120
  • mono theorem — A real point contained in a subinterval is contained in the enclosing interval.
    I J :
    x :
    hIJ :
    I.Subinterval J
    hx :
    I.Contains x
    J.Contains x
    Proof (Lean source)
    theorem Contains.mono {I J : RatInterval} {x : ℝ} (hIJ : I.Subinterval J) (hx : I.Contains x) : J.Contains x := by have hlo : (J.lo : ℝ) ≤ I.lo := by exact_mod_cast hIJ.1 have hhi : (I.hi : ℝ) ≤ J.hi := by exact_mod_cast hIJ.2 exact ⟨hlo.trans hx.1, hx.2.trans hhi⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.Contains.mono · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:126
  • width_mono theorem — Inclusion of rational intervals cannot increase their width.
    I J :
    hIJ :
    I.Subinterval J
    I.width ≤ J.width
    Proof (Lean source)
    theorem width_mono {I J : RatInterval} (hIJ : I.Subinterval J) : I.width ≤ J.width := by unfold width linarith [hIJ.1, hIJ.2]
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.width_mono · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:133
  • point_sound theorem — The point interval soundly encloses its rational value viewed as a real.
    q :
    (point q).Contains (q : ℝ)
    Proof (Lean source)
    theorem point_sound (q : ℚ) : (point q).Contains (q : ℝ) := by simp
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.point_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:138
  • add_sound theorem — Rational interval addition encloses the sum of any enclosed real operands.
    I J :
    x y :
    hx :
    I.Contains x
    hy :
    J.Contains y
    (add I J).Contains (x + y)
    Proof (Lean source)
    theorem add_sound {I J : RatInterval} {x y : ℝ} (hx : I.Contains x) (hy : J.Contains y) : (add I J).Contains (x + y) := by constructor <;> simp only [add, Contains, Rat.cast_add] · exact add_le_add hx.1 hy.1 · exact add_le_add hx.2 hy.2
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.add_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:142
  • neg_sound theorem — Rational interval negation encloses the negation of every enclosed real operand.
    x :
    hx :
    I.Contains x
    I.neg.Contains (-x)
    Proof (Lean source)
    theorem neg_sound {I : RatInterval} {x : ℝ} (hx : I.Contains x) : I.neg.Contains (-x) := by constructor <;> simp only [neg, Contains, Rat.cast_neg] · exact neg_le_neg hx.2 · exact neg_le_neg hx.1
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.neg_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:149
  • sub_sound theorem — Rational interval subtraction encloses the difference of any enclosed real operands.
    I J :
    x y :
    hx :
    I.Contains x
    hy :
    J.Contains y
    (sub I J).Contains (x - y)
    Proof (Lean source)
    theorem sub_sound {I J : RatInterval} {x y : ℝ} (hx : I.Contains x) (hy : J.Contains y) : (sub I J).Contains (x - y) := by simpa [sub_eq_add_neg, sub] using add_sound hx (neg_sound hy)
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.sub_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:156
  • ne_zero_of_contains theorem — A real number contained in an interval separated from zero is nonzero.
    x :
    hI :
    I.AwayFromZero
    hx :
    I.Contains x
    x ≠ 0
    Proof (Lean source)
    theorem ne_zero_of_contains {I : RatInterval} {x : ℝ} (hI : I.AwayFromZero) (hx : I.Contains x) : x ≠ 0 := by rcases hI with hI | hI · have hI' : (I.hi : ℝ) < 0 := by exact_mod_cast hI exact ne_of_lt (hx.2.trans_lt hI') · have hI' : (0 : ℝ) < I.lo := by exact_mod_cast hI exact ne_of_gt (hI'.trans_le hx.1)
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.ne_zero_of_contains · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:239
  • inv_sound theorem — Rational interval reciprocal encloses the reciprocal of every enclosed real operand.
    x :
    hI :
    I.AwayFromZero
    hx :
    I.Contains x
    (inv I hI).Contains x⁻¹
    Proof (Lean source)
    theorem inv_sound {I : RatInterval} {x : ℝ} (hI : I.AwayFromZero) (hx : I.Contains x) : (inv I hI).Contains x⁻¹ := by rcases hI with hneg | hpos · have hhineg : (I.hi : ℝ) < 0 := by exact_mod_cast hneg have hloneg : (I.lo : ℝ) < 0 := by exact_mod_cast I.lo_le_hi.trans_lt hneg have hxneg : x < 0 := hx.2.trans_lt hhineg simp only [inv, Contains, Rat.cast_inv] exact ⟨(inv_le_inv_of_neg hhineg hxneg).2 hx.2, (inv_le_inv_of_neg hxneg hloneg).2 hx.1⟩ · have hlopos : (0 : ℝ) < I.lo := by exact_mod_cast hpos have hhipos : (0 : ℝ) < I.hi := by exact_mod_cast hpos.trans_le I.lo_le_hi have hxpos : 0 < x := hlopos.trans_le hx.1 simp only [inv, Contains, Rat.cast_inv] exact ⟨(inv_le_inv₀ hhipos hxpos).2 hx.2, (inv_le_inv₀ hxpos hlopos).2 hx.1⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.inv_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:248
  • div_sound theorem — Rational interval division encloses every quotient whose denominator interval avoids zero.
    I J :
    x y :
    hJ :
    J.AwayFromZero
    hx :
    I.Contains x
    hy :
    J.Contains y
    (div I J hJ).Contains (x / y)
    Proof (Lean source)
    theorem div_sound {I J : RatInterval} {x y : ℝ} (hJ : J.AwayFromZero) (hx : I.Contains x) (hy : J.Contains y) : (div I J hJ).Contains (x / y) := by simpa [div, div_eq_mul_inv] using mul_sound hx (inv_sound hJ hy)
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.div_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:265
  • npow_sound theorem — Repeated interval multiplication encloses every natural power of an enclosed real number.
    x :
    hx :
    I.Contains x
    n :
    (I.npow n).Contains (x ^ n)
    Proof (Lean source)
    theorem npow_sound {I : RatInterval} {x : ℝ} (hx : I.Contains x) (n : ℕ) : (I.npow n).Contains (x ^ n) := by induction n with | zero => simpa [npow] using point_sound 1 | succ n ih => simpa [npow, pow_succ] using mul_sound ih hx
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.npow_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:270
  • tighten_sound theorem — Tightening two intervals that share an enclosed real point returns their intersection and continues to enclose that point.
    I J :
    x :
    hI :
    I.Contains x
    hJ :
    J.Contains x
    (tighten I J).Contains x
    Proof (Lean source)
    theorem tighten_sound {I J : RatInterval} {x : ℝ} (hI : I.Contains x) (hJ : J.Contains x) : (tighten I J).Contains x := by have hlohi : max I.lo J.lo ≤ min I.hi J.hi := by apply max_le · apply le_min I.lo_le_hi exact_mod_cast hI.1.trans hJ.2 · apply le_min · exact_mod_cast hJ.1.trans hI.2 · exact J.lo_le_hi simp only [tighten, hlohi, dif_pos, Contains, Rat.cast_max, Rat.cast_min] exact ⟨max_le hI.1 hJ.1, le_min hI.2 hJ.2⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.tighten_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:277
  • tighten_subinterval_left theorem — Tightening by another sound interval produces a subinterval of the first interval.
    I J :
    x :
    hI :
    I.Contains x
    hJ :
    J.Contains x
    (tighten I J).Subinterval I
    Proof (Lean source)
    theorem tighten_subinterval_left {I J : RatInterval} {x : ℝ} (hI : I.Contains x) (hJ : J.Contains x) : (tighten I J).Subinterval I := by have hlohi : max I.lo J.lo ≤ min I.hi J.hi := by apply max_le · apply le_min I.lo_le_hi exact_mod_cast hI.1.trans hJ.2 · apply le_min · exact_mod_cast hJ.1.trans hI.2 · exact J.lo_le_hi simp only [tighten, hlohi, dif_pos, Subinterval] exact ⟨le_max_left _ _, min_le_left _ _⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.tighten_subinterval_left · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:292
  • add_mono theorem — Addition is inclusion-isotone in both interval arguments.
    I I' J J' :
    hI :
    I.Subinterval I'
    hJ :
    J.Subinterval J'
    (add I J).Subinterval (add I' J')
    Proof (Lean source)
    theorem add_mono {I I' J J' : RatInterval} (hI : I.Subinterval I') (hJ : J.Subinterval J') : (add I J).Subinterval (add I' J') := by exact ⟨add_le_add hI.1 hJ.1, add_le_add hI.2 hJ.2⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.add_mono · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:306
  • neg_mono theorem — Negation preserves interval inclusion.
    I J :
    hIJ :
    I.Subinterval J
    I.neg.Subinterval J.neg
    Proof (Lean source)
    theorem neg_mono {I J : RatInterval} (hIJ : I.Subinterval J) : I.neg.Subinterval J.neg := by exact ⟨neg_le_neg hIJ.2, neg_le_neg hIJ.1⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.neg_mono · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:312
  • sub_mono theorem — Subtraction is inclusion-isotone in both interval arguments.
    I I' J J' :
    hI :
    I.Subinterval I'
    hJ :
    J.Subinterval J'
    (sub I J).Subinterval (sub I' J')
    Proof (Lean source)
    theorem sub_mono {I I' J J' : RatInterval} (hI : I.Subinterval I') (hJ : J.Subinterval J') : (sub I J).Subinterval (sub I' J') := by exact add_mono hI (neg_mono hJ)
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.sub_mono · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:317
  • mul_mono theorem — Multiplication is inclusion-isotone in both interval arguments.
    I I' J J' :
    hI :
    I.Subinterval I'
    hJ :
    J.Subinterval J'
    (mul I J).Subinterval (mul I' J')
    Proof (Lean source)
    theorem mul_mono {I I' J J' : RatInterval} (hI : I.Subinterval I') (hJ : J.Subinterval J') : (mul I J).Subinterval (mul I' J') := by have Ilo : I.Contains (I.lo : ℝ) := ⟨le_rfl, by exact_mod_cast I.lo_le_hi⟩ have Ihi : I.Contains (I.hi : ℝ) := ⟨by exact_mod_cast I.lo_le_hi, le_rfl⟩ have Jlo : J.Contains (J.lo : ℝ) := ⟨le_rfl, by exact_mod_cast J.lo_le_hi⟩ have Jhi : J.Contains (J.hi : ℝ) := ⟨by exact_mod_cast J.lo_le_hi, le_rfl⟩ have p₁ : (mul I' J').Contains ((I.lo : ℝ) * (J.lo : ℝ)) := mul_sound (Contains.mono hI Ilo) (Contains.mono hJ Jlo) have p₂ : (mul I' J').Contains ((I.lo : ℝ) * (J.hi : ℝ)) := mul_sound (Contains.mono hI Ilo) (Contains.mono hJ Jhi) have p₃ : (mul I' J').Contains ((I.hi : ℝ) * (J.lo : ℝ)) := mul_sound (Contains.mono hI Ihi) (Contains.mono hJ Jlo) have p₄ : (mul I' J').Contains ((I.hi : ℝ) * (J.hi : ℝ)) := mul_sound (Contains.mono hI Ihi) (Contains.mono hJ Jhi) simp only [Subinterval, mul] constructor · apply le_min · apply le_min · exact_mod_cast p₁.1 · exact_mod_cast p₂.1 · apply le_min · exact_mod_cast p₃.1 · exact_mod_cast p₄.1 · apply max_le · apply max_le · exact_mod_cast p₁.2 · exact_mod_cast p₂.2 · apply max_le · exact_mod_cast p₃.2 · exact_mod_cast p₄.2
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.mul_mono · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:323
  • npow_mono theorem — Natural interval powers preserve interval inclusion.
    I J :
    hIJ :
    I.Subinterval J
    n :
    (I.npow n).Subinterval (J.npow n)
    Proof (Lean source)
    theorem npow_mono {I J : RatInterval} (hIJ : I.Subinterval J) (n : ℕ) : (I.npow n).Subinterval (J.npow n) := by induction n with | zero => exact subinterval_refl _ | succ n ih => exact mul_mono ih hIJ
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.npow_mono · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:360
  • inv_mono theorem — Reciprocal preserves inclusion when both intervals are certified away from zero.
    I J :
    hIJ :
    I.Subinterval J
    hI :
    I.AwayFromZero
    hJ :
    J.AwayFromZero
    (inv I hI).Subinterval (inv J hJ)
    Proof (Lean source)
    theorem inv_mono {I J : RatInterval} (hIJ : I.Subinterval J) (hI : I.AwayFromZero) (hJ : J.AwayFromZero) : (inv I hI).Subinterval (inv J hJ) := by simp only [Subinterval, inv] constructor · rcases hJ with hJneg | hJpos · exact (inv_le_inv_of_neg hJneg (hIJ.2.trans_lt hJneg)).2 hIJ.2 · exact (inv_le_inv₀ (hJpos.trans_le J.lo_le_hi) ((hJpos.trans_le hIJ.1).trans_le I.lo_le_hi)).2 hIJ.2 · rcases hJ with hJneg | hJpos · exact (inv_le_inv_of_neg (I.lo_le_hi.trans_lt (hIJ.2.trans_lt hJneg)) (J.lo_le_hi.trans_lt hJneg)).2 hIJ.1 · exact (inv_le_inv₀ (hJpos.trans_le hIJ.1) hJpos).2 hIJ.1
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.inv_mono · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:367
  • div_mono theorem — Division is inclusion-isotone when both denominator intervals avoid zero.
    I I' J J' :
    hI :
    I.Subinterval I'
    hJ :
    J.Subinterval J'
    hJ0 :
    J.AwayFromZero
    hJ0' :
    J'.AwayFromZero
    (div I J hJ0).Subinterval (div I' J' hJ0')
    Proof (Lean source)
    theorem div_mono {I I' J J' : RatInterval} (hI : I.Subinterval I') (hJ : J.Subinterval J') (hJ0 : J.AwayFromZero) (hJ0' : J'.AwayFromZero) : (div I J hJ0).Subinterval (div I' J' hJ0') := by exact mul_mono hI (inv_mono hJ hJ0 hJ0')
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.div_mono · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:383
  • width_add theorem — Addition makes widths add exactly.
    I J :
    (add I J).width = I.width + J.width
    Proof (Lean source)
    theorem width_add (I J : RatInterval) : (add I J).width = I.width + J.width := by simp [width, add] ring
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.width_add · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:390
  • width_neg theorem — Negation preserves interval width exactly.
    I.neg.width = I.width
    Proof (Lean source)
    theorem width_neg (I : RatInterval) : I.neg.width = I.width := by simp [width, neg] ring
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.width_neg · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:395
  • width_sub theorem — Subtraction makes widths add exactly.
    I J :
    (sub I J).width = I.width + J.width
    Proof (Lean source)
    theorem width_sub (I J : RatInterval) : (sub I J).width = I.width + J.width := by simp [sub, width_add, width_neg]
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.width_sub · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:400
  • width_expand theorem — Widening an interval by a nonnegative amount on each side increases its width by twice that amount.
    e :
    he :
    0 ≤ e
    (expand I e he).width = I.width + 2 * e
    Proof (Lean source)
    theorem width_expand (I : RatInterval) (e : ℚ) (he : 0 ≤ e) : (expand I e he).width = I.width + 2 * e := by simp [expand, width] ring
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.width_expand · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Basic.lean:404
Certified­Real 8 core · 5 supporting This module represents a real quantity by nested rational enclosures together with a precision rule (an arbitrary function; computability is not encoded). ★ refine_width

Certified real names and effective refinement

This module represents a real quantity by nested rational enclosures together with a precision rule (an arbitrary function; computability is not encoded). It turns any positive rational error target into a concrete interval that still contains the quantity and is no wider than that target.

abbrev PosRat reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic

A positive rational number is a rational number that is strictly greater than zero.

Definition (Lean source)
PosRat :
Type
{q : ℚ // 0 < q}
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.PosRat · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/CertifiedReal.lean:15
structure CertifiedReal reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic

A certified real name represents a real number by a sequence of rational interval enclosures indexed by precision that is nested — each successive enclosure a subinterval of the one before — and always contains the represented value, together with a rule (an arbitrary function, not required to be computable) selecting, for any requested positive rational error, a precision level whose enclosure is no wider than that error.

Definition (Lean source)
The real number denoted by the certified name.
value :
The rational enclosure returned at each natural precision.
approx :
ℕ → RatInterval
Increasing precision produces a subinterval of the preceding enclosure.
nested :
∀ n, (approx (n + 1)).Subinterval (approx n)
Every rational approximation encloses the denoted real value.
contains :
∀ n, (approx n).Contains value
The precision selected for a requested positive rational width (an arbitrary function, not required to be computable).
modulus :
PosRat → ℕ
The interval at the selected precision has at most the requested width.
width_modulus :
∀ ε : PosRat, (approx (modulus ε)).width ≤ ε.1
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/CertifiedReal.lean:18
def refine reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal

For a certified real number and a requested positive rational tolerance, its refinement is the rational interval returned at the precision selected by that certificate's modulus for the requested tolerance.

Definition (Lean source)
refine x ε :
x.approx (x.modulus ε)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal.refine · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/CertifiedReal.lean:48 · uses CertifiedReal , PosRat , RatInterval
theorem refine_width reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal

For a certified real number x and a requested positive rational tolerance ε, refining x to the precision selected by ε's modulus yields an enclosure whose width is at most ε.

Formal statement
(x.refine ε).width ≤ ε.1
Proof (Lean source)
theorem refine_width (x : CertifiedReal) (ε : PosRat) : (x.refine ε).width ≤ ε.1 := by exact x.width_modulus ε
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal.refine_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/CertifiedReal.lean:59 · uses CertifiedReal , refine , PosRat , width
def ofRat reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal

For a rational number, its certified real name denotes that rational number and uses its degenerate one-point rational interval at every precision.

Definition (Lean source)
q :
ofRat q :
clause 1
value := q
clause 2
approx := fun _ => RatInterval.point q
clause 3
nested := by intro n exact RatInterval.subinterval_refl _
clause 4
contains := by intro n exact RatInterval.point_sound q
clause 5
modulus := fun _ => 0
clause 6
width_modulus := by intro ε simpa [RatInterval.width, RatInterval.point] using ε.2.le
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal.ofRat · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/CertifiedReal.lean:72 · uses CertifiedReal
def neg reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal

For a certified real number, its certified negation denotes the negative of the real number named by the certificate, negates every rational interval enclosure, and retains the same precision-selection rule.

Definition (Lean source)
neg x :
clause 1
value := -x.value
clause 2
approx := fun n => (x.approx n).neg
clause 3
nested := by intro n exact RatInterval.neg_mono (x.nested n)
clause 4
contains := by intro n exact RatInterval.neg_sound (x.contains n)
clause 5
modulus := x.modulus
clause 6
width_modulus := by intro ε simpa [RatInterval.width_neg] using x.width_modulus ε
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal.neg · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/CertifiedReal.lean:89 · uses CertifiedReal
def add reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal

For two certified real numbers, their certified sum denotes the sum of their named real numbers, adds their rational interval enclosures at each common precision, and selects a precision sufficient to make each input enclosure no wider than half the requested tolerance.

Definition (Lean source)
add x y :
clause 1
value := x.value + y.value
clause 2
approx := fun n => RatInterval.add (x.approx n) (y.approx n)
clause 3
nested := by intro n exact RatInterval.add_mono (x.nested n) (y.nested n)
clause 4
contains := by intro n exact RatInterval.add_sound (x.contains n) (y.contains n)
clause 5
modulus := fun ε
=> max (x.modulus ⟨ε.1 / 2, div_pos ε.2 (by decide)⟩) (y.modulus ⟨ε.1 / 2, div_pos ε.2 (by decide)⟩)
clause 6
width_modulus := by intro ε let δ : PosRat := ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩ have hx : (x.approx (max (x.modulus δ) (y.modulus δ))).width
≤ δ.1 := (RatInterval.width_mono (x.approx_mono (le_max_left _ _))).trans (x.width_modulus δ) have hy : (y.approx (max (x.modulus δ) (y.modulus δ))).width ≤ δ.1 := (RatInterval.width_mono (y.approx_mono (le_max_right _ _))).trans (y.width_modulus δ) rw [RatInterval.width_add] dsimp [δ] at hx hy ⊢ linarith
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal.add · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/CertifiedReal.lean:106 · uses CertifiedReal
def sub reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal

For two certified real numbers, their certified difference is their certified sum after negating the second certificate; it therefore denotes the first named real number minus the second.

Definition (Lean source)
sub x y :
add x (neg y)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal.sub · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/CertifiedReal.lean:135 · uses CertifiedReal
5 supporting declarations (lemmas, instances)
  • approx_mono theorem — Nestedness extends from successive precisions to every pair of ordered precisions.
    m n :
    hmn :
    m ≤ n
    (x.approx n).Subinterval (x.approx m)
    Proof (Lean source)
    theorem approx_mono (x : CertifiedReal) {m n : ℕ} (hmn : m ≤ n) : (x.approx n).Subinterval (x.approx m) := by induction n, hmn using Nat.le_induction with | base => exact RatInterval.subinterval_refl _ | succ n hmn ih => exact RatInterval.subinterval_trans (x.nested n) ih
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal.approx_mono · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/CertifiedReal.lean:40
  • refine_contains theorem — Refinement always encloses the real value named by the certificate.
    (x.refine ε).Contains x.value
    Proof (Lean source)
    theorem refine_contains (x : CertifiedReal) (ε : PosRat) : (x.refine ε).Contains x.value := by exact x.contains (x.modulus ε)
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal.refine_contains · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/CertifiedReal.lean:54
  • exists_refinement theorem — Every positive rational tolerance admits an explicitly returned enclosing interval of at most that width.
    ε :
    :
    0 < ε
    ∃ n : ℕ,
    conclusion 1
    (x.approx n).Contains x.value
    conclusion 2
    (x.approx n).width ≤ ε
    Proof (Lean source)
    theorem exists_refinement (x : CertifiedReal) (ε : ℚ) (hε : 0 < ε) : ∃ n : ℕ, (x.approx n).Contains x.value ∧ (x.approx n).width ≤ ε := by exact ⟨x.modulus ⟨ε, hε⟩, x.contains _, x.width_modulus ⟨ε, hε⟩⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal.exists_refinement · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/CertifiedReal.lean:66
  • sub_value theorem — Certified subtraction denotes the difference of the two named real values.
    (sub x y).value = x.value - y.value
    Proof (Lean source)
    @[simp] theorem sub_value (x y : CertifiedReal) : (sub x y).value = x.value - y.value := by rfl
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal.sub_value · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/CertifiedReal.lean:140
  • value_eq_of_common_approximations theorem — Two certified names whose every approximation is shared denote the same real value.
    hxy :
    ∀ n, x.approx n = y.approx n
    x.value = y.value
    Proof (Lean source)
    theorem value_eq_of_common_approximations (x y : CertifiedReal) (hxy : ∀ n, x.approx n = y.approx n) : x.value = y.value := by apply le_antisymm · by_contra h have hlt : y.value < x.value := lt_of_not_ge h obtain ⟨ε, hεpos, hεlt⟩ : ∃ ε : ℚ, 0 < ε ∧ (ε : ℝ) < x.value - y.value := by exact exists_pos_rat_lt (sub_pos.mpr hlt) let n := x.modulus ⟨ε, hεpos⟩ have hx := x.contains n have hy : (x.approx n).Contains y.value := by simpa [hxy n] using y.contains n have hw : ((x.approx n).width : ℝ) ≤ ε := by exact_mod_cast x.width_modulus ⟨ε, hεpos⟩ have hspan : x.value - y.value ≤ ((x.approx n).width : ℝ) := by simp only [RatInterval.width, Rat.cast_sub] linarith [hx.2, hy.1] exact (not_lt_of_ge (hspan.trans hw)) hεlt · by_contra h have hlt : x.value < y.value := lt_of_not_ge h obtain ⟨ε, hεpos, hεlt⟩ : ∃ ε : ℚ, 0 < ε ∧ (ε : ℝ) < y.value - x.value := by exact exists_pos_rat_lt (sub_pos.mpr hlt) let n := x.modulus ⟨ε, hεpos⟩ have hx := x.contains n have hy : (x.approx n).Contains y.value := by simpa [hxy n] using y.contains n have hw : ((x.approx n).width : ℝ) ≤ ε := by exact_mod_cast x.width_modulus ⟨ε, hεpos⟩ have hspan : y.value - x.value ≤ ((x.approx n).width : ℝ) := by simp only [RatInterval.width, Rat.cast_sub] linarith [hy.2, hx.1] exact (not_lt_of_ge (hspan.trans hw)) hεlt
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedReal.value_eq_of_common_approximations · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/CertifiedReal.lean:145
Mesh 19 core · 10 supporting This module provides rational rectangles for complex values and finite uniform mesh enclosures for the infimum and supremum of a real function. ★ infEnclosure_sound

Certified finite mesh extrema

This module provides rational rectangles for complex values and finite uniform mesh enclosures for the infimum and supremum of a real function. A supplied Lipschitz bound turns rational node enclosures into global enclosures with an explicit mesh-error allowance.

structure ComplexRatInterval reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic

A rational rectangle in the complex plane consists of a rational interval enclosing the real coordinate and a rational interval enclosing the imaginary coordinate.

Definition (Lean source)
The rational interval enclosing the real coordinate.
The rational interval enclosing the imaginary coordinate.
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:19
def Contains reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

Given a rational rectangle and a complex number, rectangle membership means that both the real and imaginary coordinates of the number lie in their respective rational intervals.

Definition (Lean source)
z :
Contains I z :
Prop
clause 1
I.re.Contains z.re
clause 2
I.im.Contains z.im
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.Contains · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:30 · uses ComplexRatInterval
def Subinterval reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

Given two rational rectangles in the complex plane, the refinement relation holds exactly when each coordinate interval of the first is contained in the corresponding coordinate interval of the second.

Definition (Lean source)
Subinterval I J :
Prop
clause 1
I.re.Subinterval J.re
clause 2
I.im.Subinterval J.im
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.Subinterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:34 · uses ComplexRatInterval
def add reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

For two rational rectangles in the complex plane, their sum rectangle is obtained by adding their real-coordinate intervals and their imaginary-coordinate intervals separately.

Definition (Lean source)
add I J :
⟨I.re.add J.re, I.im.add J.im⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.add · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:38 · uses ComplexRatInterval
def smulRat reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

For a rational scalar and a rational rectangle in the complex plane, the scalar-multiple rectangle is obtained by multiplying each coordinate interval by that scalar.

Definition (Lean source)
q :
smulRat q I :
⟨(RatInterval.point q).mul I.re, (RatInterval.point q).mul I.im⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.smulRat · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:42 · uses ComplexRatInterval
def expand reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

For a rational rectangle in the complex plane, a rational error allowance, and the condition that this allowance is nonnegative, the expanded rectangle widens each coordinate interval by that allowance.

Definition (Lean source)
e :
he :
0 ≤ e
expand I e he :
⟨I.re.expand e he, I.im.expand e he⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.expand · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:46 · uses ComplexRatInterval
def zero reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

The zero rectangle is the rational rectangle whose real and imaginary coordinate intervals are both the singleton interval containing zero.

Definition (Lean source)
⟨RatInterval.point 0, RatInterval.point 0⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.zero · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:50 · uses ComplexRatInterval
def meshPoint reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

For a mesh size and a node index, the mesh point is the real number k/nk/n. It is a mesh point for positive mesh size; for n=0n=0 every point is zero by the division convention.

Definition (Lean source)
n k :
meshPoint n k :
(k : ℝ) / n
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.meshPoint · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:77
def circleMap reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

For a complex center, a real radius, and a real parameter, the circle point is c+rexp(2πui)c+r\exp(2\pi u i).

Definition (Lean source)
c :
r :
u :
circleMap c r u :
c + r * exp ((2 * pi * u) * I)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.circleMap · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:80
def circleTangent reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

For a real radius and a real parameter, the circle tangent is 2πirexp(2πui)2\pi i r\exp(2\pi u i).

Definition (Lean source)
r :
u :
circleTangent r u :
((2 * pi) * I) * r * exp ((2 * pi * u) * I)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.circleTangent · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:84
def circleIntegrand reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

For a complex-valued function, a complex center, a real radius, and a real parameter, the parameterized contour integrand is the value of the function at the corresponding circle point multiplied by the circle tangent there.

Definition (Lean source)
f :
ℂ → ℂ
c :
r :
u :
circleIntegrand f c r u :
f (circleMap c r u) * circleTangent r u
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.circleIntegrand · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:88
def circleContourIntegral reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

For a complex-valued function, a complex center, and a real radius, the circle contour integral is the integral from 00 to 11 of the parameterized contour integrand. No integrability is required: for an integrand that is not interval integrable the integral is zero by convention, so this is the contour integral only when the parameterized integrand is integrable.

Definition (Lean source)
f :
ℂ → ℂ
c :
r :
circleContourIntegral f c r :
∫ u in (0 : ℝ)..1, circleIntegrand f c r u
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.circleContourIntegral · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:92
def minLoUpTo reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

Given a sequence of rational intervals, the minimum lower endpoint up to a terminal node index is computed recursively: at index zero it is the lower endpoint of the initial interval, and at each successor index it is the smaller of the preceding result and the new lower endpoint.

Definition (Lean source)
nodes :
ℕ → RatInterval
minLoUpTo nodes :
ℕ → ℚ
clause 1
| 0 => (nodes 0).lo
clause 2
| n + 1 => min (minLoUpTo nodes n) (nodes (n + 1)).lo
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.minLoUpTo · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:96 · uses RatInterval
def minHiUpTo reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

Given a sequence of rational intervals, the minimum upper endpoint up to a terminal node index is computed recursively: at index zero it is the upper endpoint of the initial interval, and at each successor index it is the smaller of the preceding result and the new upper endpoint.

Definition (Lean source)
nodes :
ℕ → RatInterval
minHiUpTo nodes :
ℕ → ℚ
clause 1
| 0 => (nodes 0).hi
clause 2
| n + 1 => min (minHiUpTo nodes n) (nodes (n + 1)).hi
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.minHiUpTo · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:103 · uses RatInterval
def maxLoUpTo reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

Given a sequence of rational intervals, the maximum lower endpoint up to a terminal node index is computed recursively: at index zero it is the lower endpoint of the initial interval, and at each successor index it is the larger of the preceding result and the new lower endpoint.

Definition (Lean source)
nodes :
ℕ → RatInterval
maxLoUpTo nodes :
ℕ → ℚ
clause 1
| 0 => (nodes 0).lo
clause 2
| n + 1 => max (maxLoUpTo nodes n) (nodes (n + 1)).lo
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.maxLoUpTo · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:110 · uses RatInterval
def maxHiUpTo reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

Given a sequence of rational intervals, the maximum upper endpoint up to a terminal node index is computed recursively: at index zero it is the upper endpoint of the initial interval, and at each successor index it is the larger of the preceding result and the new upper endpoint.

Definition (Lean source)
nodes :
ℕ → RatInterval
maxHiUpTo nodes :
ℕ → ℚ
clause 1
| 0 => (nodes 0).hi
clause 2
| n + 1 => max (maxHiUpTo nodes n) (nodes (n + 1)).hi
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.maxHiUpTo · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:117 · uses RatInterval
def infEnclosure reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

Given a sequence of rational node intervals, a rational Lipschitz constant, the condition that the constant is nonnegative, a mesh size, and the condition that the mesh size is positive, the infimum enclosure has lower endpoint equal to the minimum node lower endpoint minus L/nL/n and upper endpoint equal to the minimum node upper endpoint.

Definition (Lean source)
nodes :
ℕ → RatInterval
L :
hL :
0 ≤ L
n :
hn :
0 < n
infEnclosure nodes L hL n hn :
⟨minLoUpTo nodes n - L / n, minHiUpTo nodes n, by have hdiv : 0
≤ L / (n : ℚ) := div_nonneg hL (by positivity) linarith [minEndpoints_le nodes n]⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.infEnclosure · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:274 · uses RatInterval
def supEnclosure reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

Given a sequence of rational node intervals, a rational Lipschitz constant, the condition that the constant is nonnegative, a mesh size, and the condition that the mesh size is positive, the supremum enclosure has lower endpoint equal to the maximum node lower endpoint and upper endpoint equal to the maximum node upper endpoint plus L/nL/n.

Definition (Lean source)
nodes :
ℕ → RatInterval
L :
hL :
0 ≤ L
n :
hn :
0 < n
supEnclosure nodes L hL n hn :
⟨maxLoUpTo nodes n, maxHiUpTo nodes n + L / n, by have hdiv : 0
≤ L / (n : ℚ) := div_nonneg hL (by positivity) linarith [maxEndpoints_le nodes n]⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.supEnclosure · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:281 · uses RatInterval
theorem infEnclosure_sound reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

Certified infimum enclosure on the unit mesh. Fix a nonnegative Lipschitz constant and a positive number of mesh nodes, and suppose the real function is Lipschitz on [0, 1] with that constant and each rational node interval contains the function's value at the corresponding mesh point. Then the infimum enclosure built from those node intervals contains the true infimum of the function over [0, 1].

Formal statement
f :
ℝ → ℝ
nodes :
ℕ → RatInterval
L :
hL :
0 ≤ L
n :
hn :
0 < n
hLip :
∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, |f s - f t| ≤ (L : ℝ) * |s - t|
hnodes :
∀ k ≤ n, (nodes k).Contains (f (meshPoint n k))
(infEnclosure nodes L hL n hn).Contains (sInf (f '' Icc (0 : ℝ) 1))
Proof (Lean source)
theorem infEnclosure_sound {f : ℝ → ℝ} {nodes : ℕ → RatInterval} {L : ℚ} (hL : 0 ≤ L) {n : ℕ} (hn : 0 < n) (hLip : ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, |f s - f t| ≤ (L : ℝ) * |s - t|) (hnodes : ∀ k ≤ n, (nodes k).Contains (f (meshPoint n k))) : (infEnclosure nodes L hL n hn).Contains (sInf (f '' Icc (0 : ℝ) 1)) := by have hL' : (0 : ℝ) ≤ L := by exact_mod_cast hL have hcont : ContinuousOn f (Icc (0 : ℝ) 1) := continuousOn_of_lipschitz_bound hL' (by simpa [Real.norm_eq_abs] using hLip) have hbdd : BddBelow (f '' Icc (0 : ℝ) 1) := isCompact_Icc.bddBelow_image hcont have hne : (f '' Icc (0 : ℝ) 1).Nonempty := ⟨f 0, ⟨0, ⟨le_rfl, zero_le_one⟩, rfl⟩⟩ constructor · simp only [infEnclosure, RatInterval.Contains, Rat.cast_sub, Rat.cast_div, Rat.cast_natCast] apply le_csInf hne rintro y ⟨x, hx, rfl⟩ obtain ⟨k, hk, hdist⟩ := exists_near_meshPoint hn hx have hm := hnodes k hk have hmesh := meshPoint_mem hn hk have hlip := hLip x hx (meshPoint n k) hmesh have hLo : ((minLoUpTo nodes n : ℚ) : ℝ) ≤ (nodes k).lo := by exact_mod_cast minLoUpTo_le nodes hk have : f (meshPoint n k) - (L : ℝ) / n ≤ f x := by have hdist' : |x - meshPoint n k| ≤ (n : ℝ)⁻¹ := by simpa [one_div] using hdist have habs : |f x - f (meshPoint n k)| ≤ (L : ℝ) / n := by simpa [div_eq_mul_inv] using hlip.trans (mul_le_mul_of_nonneg_left hdist' hL') linarith [neg_le_of_abs_le habs] linarith [hm.1] · simp only [infEnclosure, RatInterval.Contains] obtain ⟨k, hk, heq⟩ := exists_minHiUpTo nodes n have hs : sInf (f '' Icc (0 : ℝ) 1) ≤ f (meshPoint n k) := csInf_le hbdd ⟨meshPoint n k, meshPoint_mem hn hk, rfl⟩ have hhi := (hnodes k hk).2 rw [heq] exact hs.trans hhi
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.infEnclosure_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:288 · uses infEnclosure , meshPoint , RatInterval , Contains
10 supporting declarations (lemmas, instances)
  • ext theorem
    ∀ {x y : ComplexRatInterval}, x.re = y.re → x.im = y.im → x = y
    Proof (Lean source)
    @[ext]
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.ext · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:21
  • ext_iff theorem
    ∀ {x y : ComplexRatInterval}, x = y ↔ x.re = y.re ∧ x.im = y.im
    Proof (Lean source)
    @[ext]
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.ext_iff · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:21
  • add_sound theorem — Complex rectangle addition encloses sums of enclosed complex numbers.
    z w :
    hz :
    I.Contains z
    hw :
    J.Contains w
    (I.add J).Contains (z + w)
    Proof (Lean source)
    theorem add_sound {I J : ComplexRatInterval} {z w : ℂ} (hz : I.Contains z) (hw : J.Contains w) : (I.add J).Contains (z + w) := by exact ⟨RatInterval.add_sound hz.1 hw.1, RatInterval.add_sound hz.2 hw.2⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.add_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:53
  • smulRat_sound theorem — Rational scalar multiplication encloses the corresponding complex scalar multiple.
    z :
    q :
    hz :
    I.Contains z
    (smulRat q I).Contains ((q : ℂ) * z)
    Proof (Lean source)
    theorem smulRat_sound {I : ComplexRatInterval} {z : ℂ} (q : ℚ) (hz : I.Contains z) : (smulRat q I).Contains ((q : ℂ) * z) := by constructor · simpa [smulRat] using RatInterval.mul_sound (RatInterval.point_sound q) hz.1 · simpa [smulRat] using RatInterval.mul_sound (RatInterval.point_sound q) hz.2
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.smulRat_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:58
  • expand_contains theorem — Coordinatewise widening preserves containment.
    z :
    e :
    he :
    0 ≤ e
    hz :
    I.Contains z
    (I.expand e he).Contains z
    Proof (Lean source)
    theorem expand_contains {I : ComplexRatInterval} {z : ℂ} {e : ℚ} (he : 0 ≤ e) (hz : I.Contains z) : (I.expand e he).Contains z := by have he' : (0 : ℝ) ≤ e := by exact_mod_cast he constructor <;> constructor <;> simp only [expand, RatInterval.expand, RatInterval.Contains, Rat.cast_sub, Rat.cast_add] <;> linarith [hz.1.1, hz.1.2, hz.2.1, hz.2.2]
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.expand_contains · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:65
  • meshPoint_mem theorem — A node of a nonempty uniform mesh lies in the unit parameter interval.
    n k :
    hn :
    0 < n
    hk :
    k ≤ n
    meshPoint n k ∈ Icc (0 : ℝ) 1
    Proof (Lean source)
    theorem meshPoint_mem {n k : ℕ} (hn : 0 < n) (hk : k ≤ n) : meshPoint n k ∈ Icc (0 : ℝ) 1 := by constructor · exact div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) · rw [meshPoint, div_le_one (by exact_mod_cast hn)] exact_mod_cast hk
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.meshPoint_mem · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:225
  • continuousOn_of_lipschitz_bound theorem — A function satisfying a finite Lipschitz bound on the unit interval is continuous there.
    E :
    Type*
    ℝ → E
    C :
    hC :
    0 ≤ C
    h :
    ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, ‖g s - g t‖ ≤ C * |s - t|
    ContinuousOn g (Icc (0 : ℝ) 1)
    Proof (Lean source)
    theorem continuousOn_of_lipschitz_bound {E : Type*} [NormedAddCommGroup E] {g : ℝ → E} {C : ℝ} (hC : 0 ≤ C) (h : ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, ‖g s - g t‖ ≤ C * |s - t|) : ContinuousOn g (Icc (0 : ℝ) 1) := by intro x hx rw [Metric.continuousWithinAt_iff] intro ε hε refine ⟨ε / (C + 1), div_pos hε (by linarith), ?_⟩ intro y hy hyx change ‖y - x‖ < ε / (C + 1) at hyx rw [dist_eq_norm] rw [Real.norm_eq_abs] at hyx by_cases hC0 : C = 0 · have hzle : ‖g y - g x‖ ≤ 0 := by simpa [hC0] using h y hy x hx exact (le_antisymm hzle (norm_nonneg _)).trans_lt hε calc ‖g y - g x‖ ≤ C * |y - x| := h y hy x hx _ < C * (ε / (C + 1)) := by exact mul_lt_mul_of_pos_left hyx (lt_of_le_of_ne hC (Ne.symm hC0)) _ < ε := by rw [mul_div_assoc'] exact (div_lt_iff₀ (by linarith : 0 < C + 1)).2 (by nlinarith)
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.continuousOn_of_lipschitz_bound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:250
  • supEnclosure_sound theorem — Rational node enclosures and a Lipschitz bound enclose the supremum of a real function on the unit mesh interval.
    f :
    ℝ → ℝ
    nodes :
    ℕ → RatInterval
    L :
    hL :
    0 ≤ L
    n :
    hn :
    0 < n
    hLip :
    ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, |f s - f t| ≤ (L : ℝ) * |s - t|
    hnodes :
    ∀ k ≤ n, (nodes k).Contains (f (meshPoint n k))
    (supEnclosure nodes L hL n hn).Contains (sSup (f '' Icc (0 : ℝ) 1))
    Proof (Lean source)
    theorem supEnclosure_sound {f : ℝ → ℝ} {nodes : ℕ → RatInterval} {L : ℚ} (hL : 0 ≤ L) {n : ℕ} (hn : 0 < n) (hLip : ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, |f s - f t| ≤ (L : ℝ) * |s - t|) (hnodes : ∀ k ≤ n, (nodes k).Contains (f (meshPoint n k))) : (supEnclosure nodes L hL n hn).Contains (sSup (f '' Icc (0 : ℝ) 1)) := by have hL' : (0 : ℝ) ≤ L := by exact_mod_cast hL have hcont : ContinuousOn f (Icc (0 : ℝ) 1) := continuousOn_of_lipschitz_bound hL' (by simpa [Real.norm_eq_abs] using hLip) have hbdd : BddAbove (f '' Icc (0 : ℝ) 1) := isCompact_Icc.bddAbove_image hcont have hne : (f '' Icc (0 : ℝ) 1).Nonempty := ⟨f 0, ⟨0, ⟨le_rfl, zero_le_one⟩, rfl⟩⟩ constructor · simp only [supEnclosure, RatInterval.Contains] obtain ⟨k, hk, heq⟩ := exists_maxLoUpTo nodes n have hs : f (meshPoint n k) ≤ sSup (f '' Icc (0 : ℝ) 1) := le_csSup hbdd ⟨meshPoint n k, meshPoint_mem hn hk, rfl⟩ have hlo := (hnodes k hk).1 rw [heq] exact hlo.trans hs · simp only [supEnclosure, RatInterval.Contains, Rat.cast_add, Rat.cast_div, Rat.cast_natCast] apply csSup_le hne rintro y ⟨x, hx, rfl⟩ obtain ⟨k, hk, hdist⟩ := exists_near_meshPoint hn hx have hm := hnodes k hk have hmesh := meshPoint_mem hn hk have hlip := hLip x hx (meshPoint n k) hmesh have hHi : ((nodes k).hi : ℝ) ≤ maxHiUpTo nodes n := by exact_mod_cast hi_le_maxHiUpTo nodes hk have hdist' : |x - meshPoint n k| ≤ (n : ℝ)⁻¹ := by simpa [one_div] using hdist have habs : |f x - f (meshPoint n k)| ≤ (L : ℝ) / n := by simpa [div_eq_mul_inv] using hlip.trans (mul_le_mul_of_nonneg_left hdist' hL') linarith [hm.2, le_abs_self (f x - f (meshPoint n k))]
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.supEnclosure_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:333
  • width_infEnclosure theorem — The infimum enclosure width is at most one mesh error plus the uniform node-enclosure width.
    nodes :
    ℕ → RatInterval
    w L :
    hw :
    0 ≤ w
    hL :
    0 ≤ L
    n :
    hn :
    0 < n
    hnodes :
    ∀ k ≤ n, (nodes k).width ≤ w
    (infEnclosure nodes L hL n hn).width ≤ w + L / n
    Proof (Lean source)
    theorem width_infEnclosure {nodes : ℕ → RatInterval} {w L : ℚ} (hw : 0 ≤ w) (hL : 0 ≤ L) {n : ℕ} (hn : 0 < n) (hnodes : ∀ k ≤ n, (nodes k).width ≤ w) : (infEnclosure nodes L hL n hn).width ≤ w + L / n := by obtain ⟨k, hk, heq⟩ := exists_minLoUpTo nodes n have hhi := minHiUpTo_le nodes hk have hwk := hnodes k hk simp only [infEnclosure, RatInterval.width] rw [heq] unfold RatInterval.width at hwk linarith
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.width_infEnclosure · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:370
  • width_supEnclosure theorem — The supremum enclosure width is at most one mesh error plus the uniform node-enclosure width.
    nodes :
    ℕ → RatInterval
    w L :
    hw :
    0 ≤ w
    hL :
    0 ≤ L
    n :
    hn :
    0 < n
    hnodes :
    ∀ k ≤ n, (nodes k).width ≤ w
    (supEnclosure nodes L hL n hn).width ≤ w + L / n
    Proof (Lean source)
    theorem width_supEnclosure {nodes : ℕ → RatInterval} {w L : ℚ} (hw : 0 ≤ w) (hL : 0 ≤ L) {n : ℕ} (hn : 0 < n) (hnodes : ∀ k ≤ n, (nodes k).width ≤ w) : (supEnclosure nodes L hL n hn).width ≤ w + L / n := by obtain ⟨k, hk, heq⟩ := exists_maxHiUpTo nodes n have hlo := lo_le_maxLoUpTo nodes hk have hwk := hnodes k hk simp only [supEnclosure, RatInterval.width] rw [heq] unfold RatInterval.width at hwk linarith
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.width_supEnclosure · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Mesh.lean:383
Exponential 10 core · 6 supporting This module computes nested rational intervals for the exponential of a rational input. ★ expScalar_width

Certified rational exponential enclosures

This module computes nested rational intervals for the exponential of a rational input. Range reduction, Taylor bounds, and an explicit precision rule yield a certified real name whose returned interval meets every positive rational error target.

def expScale reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational exponential argument, the exponential scaling factor is the larger of one and the absolute value of the argument's numerator.

Definition (Lean source)
q :
expScale q :
max 1 q.num.natAbs
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expScale · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:21
def expReduced reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational exponential argument, the reduced exponential argument is the argument divided by its exponential scaling factor.

Definition (Lean source)
q :
expReduced q :
q / (expScale q : ℚ)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expReduced · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:24
def expPartial reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational number and a nonnegative polynomial degree, the exponential Taylor partial sum is the sum of the terms qk/k!q^k/k! for every integer kk from zero through nn.

Definition (Lean source)
q :
n :
expPartial q n :
∑ k ∈ range (n + 1), q ^ k / (k.factorial : ℚ)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expPartial · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:27
def expRemainder reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational number and a nonnegative polynomial degree, the exponential remainder radius is qn+1(n+2)/((n+1)!(n+1))|q|^{n+1}(n+2)/((n+1)!(n+1)).

Definition (Lean source)
q :
n :
expRemainder q n :
|q| ^ (n + 1) * ((n + 2 : ℕ) : ℚ) / (((n + 1).factorial : ℚ) * (n + 1 : ℕ))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expRemainder · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:31
def expReducedRaw reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational number and a nonnegative polynomial degree, the reduced exponential enclosure has lower endpoint equal to the Taylor partial sum minus the remainder radius, upper endpoint equal to the Taylor partial sum plus the remainder radius, and valid endpoint order.

Definition (Lean source)
q :
n :
expReducedRaw q n :
⟨expPartial q n - expRemainder q n, expPartial q n + expRemainder q n, by have hr : 0
expRemainder q n := by simp only [expRemainder] positivity linarith⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expReducedRaw · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:36 · uses RatInterval
def expRaw reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational exponential argument and a nonnegative polynomial degree, the raw exponential enclosure is the natural-power interval obtained by raising the reduced exponential enclosure to the exponential scaling factor.

Definition (Lean source)
q :
n :
expRaw q n :
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expRaw · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:45 · uses RatInterval
def expScalar reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational exponential argument, the scalar exponential enclosure sequence assigns the raw exponential enclosure at degree zero to index zero and the conditional tightening of the preceding enclosure with the next raw enclosure to each positive index.

Definition (Lean source)
q :
expScalar q :
ℕ → RatInterval
clause 1
| 0 => expRaw q 0
clause 2
| n + 1 => RatInterval.tighten (expScalar q n) (expRaw q (n + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expScalar · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:49 · uses RatInterval
def expPrecision reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational exponential argument and a strictly positive rational target width, the exponential precision index is the product of one plus the target-width denominator and two copies of one plus the exponential scaling factor.

Definition (Lean source)
q :
ε :
expPrecision q ε :
(ε.1.den + 1) * (expScale q + 1) * (expScale q + 1)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expPrecision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:54 · uses PosRat
theorem expScalar_width reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational input q and a requested positive rational tolerance ε, evaluating the certified scalar exponential at the precision level selected for that tolerance yields an enclosure whose width is no larger than ε.

Formal statement
q :
ε :
(expScalar q (expPrecision q ε)).width ≤ ε.1
Proof (Lean source)
theorem expScalar_width (q : ℚ) (ε : PosRat) : (expScalar q (expPrecision q ε)).width ≤ ε.1 := by let D : ℕ := ε.1.den let s : ℕ := expScale q let N : ℕ := expPrecision q ε let z : ℚ := expReduced q let R : ℚ := expRemainder z N let I : RatInterval := expReducedRaw z N have hD : 0 < D := by simpa [D] using ε.1.den_pos have hs : 0 < s := by dsimp [s, expScale] omega have hN : 1 ≤ N := by dsimp [N, expPrecision, D, s] exact Nat.mul_pos (Nat.mul_pos (Nat.succ_pos _) (Nat.succ_pos _)) (Nat.succ_pos _) have hz : |z| ≤ 1 := by simpa [z] using abs_expReduced_le_one q have hz0 : 0 ≤ |z| := abs_nonneg z have hzpow (k : ℕ) : |z| ^ k ≤ 1 := pow_le_one₀ hz0 hz have hpartial : |expPartial z N| ≤ 3 := by calc |expPartial z N| ≤ ∑ k ∈ range (N + 1), |z ^ k / (k.factorial : ℚ)| := by simpa [expPartial] using Finset.abs_sum_le_sum_abs (s := range (N + 1)) (f := fun k => z ^ k / (k.factorial : ℚ)) _ ≤ ∑ k ∈ range (N + 1), (1 / k.factorial : ℚ) := by gcongr with k hk rw [abs_div, abs_pow, abs_of_nonneg (by positivity : (0 : ℚ) ≤ k.factorial)] exact div_le_div_of_nonneg_right (hzpow k) (by positivity) _ = 1 + ∑ k ∈ range (N + 1) with 1 ≤ k, (1 / k.factorial : ℚ) := by rw [← Finset.sum_filter_add_sum_filter_not (s := range (N + 1)) (p := fun k => 1 ≤ k) (f := fun k => (1 / k.factorial : ℚ))] simp [add_comm] _ ≤ 3 := by linarith [Complex.sum_div_factorial_le (α := ℚ) 1 (N + 1) (by omega)] have hfac1 : (1 : ℕ) ≤ N.factorial := by exact Nat.factorial_pos N have hrem : R ≤ 1 := by have hnum : |z| ^ (N + 1) * ((N + 2 : ℕ) : ℚ) ≤ ((N + 1).factorial : ℚ) * (N + 1 : ℕ) := by have hfac1Q : (1 : ℚ) ≤ N.factorial := by exact_mod_cast hfac1 have hNQ : (1 : ℚ) ≤ N := by exact_mod_cast hN have hsq : ((N + 2 : ℕ) : ℚ) ≤ (N + 1 : ℚ) * (N + 1 : ℚ) := by push_cast nlinarith calc |z| ^ (N + 1) * ((N + 2 : ℕ) : ℚ) ≤ ((N + 2 : ℕ) : ℚ) := by nlinarith [hzpow (N + 1)] _ ≤ (N + 1 : ℚ) * (N + 1 : ℚ) := hsq _ ≤ ((N + 1).factorial : ℚ) * (N + 1 : ℕ) := by rw [Nat.factorial_succ] push_cast have haux : 0 ≤ ((N.factorial : ℚ) - 1) * (N + 1 : ℚ) ^ 2 := mul_nonneg (sub_nonneg.mpr hfac1Q) (sq_nonneg _) nlinarith dsimp [R, expRemainder] exact (div_le_one (by positivity)).2 hnum have hR0 : 0 ≤ R := by dsimp [R, expRemainder] positivity have hIwidth : I.width = 2 * R := by simp [I, expReducedRaw, RatInterval.width, R] ring have hImax : I.maxAbs ≤ 4 := by dsimp [I, expReducedRaw, RatInterval.maxAbs] apply max_le · calc |expPartial z N - R| ≤ |expPartial z N| + |R| := abs_sub _ _ _ = |expPartial z N| + R := by rw [abs_of_nonneg hR0] _ ≤ 4 := by linarith · calc |expPartial z N + R| ≤ |expPartial z N| + |R| := abs_add_le _ _ _ = |expPartial z N| + R := by rw [abs_of_nonneg hR0] _ ≤ 4 := by linarith have hNlarge : D + 3 * s ≤ N := by have hsum : D + 1 + (s + 1) * (s + 1) ≤ N := by dsimp [N, expPrecision] change D + 1 + (s + 1) * (s + 1) ≤ (D + 1) * (s + 1) * (s + 1) rw [mul_assoc] apply add_le_mul · omega · nlinarith have hsquare : 3 * s ≤ 1 + (s + 1) * (s + 1) := by nlinarith omega have hpowbound : D * s * 4 ^ s ≤ 2 ^ N := by calc D * s * 4 ^ s ≤ 2 ^ D * 2 ^ s * 4 ^ s := by exact Nat.mul_le_mul (Nat.mul_le_mul (nat_le_two_pow D) (nat_le_two_pow s)) le_rfl _ = 2 ^ (D + 3 * s) := by rw [show 4 = 2 ^ 2 by norm_num, ← pow_mul, ← pow_add, ← pow_add] congr 1 omega _ ≤ 2 ^ N := Nat.pow_le_pow_right (by omega) hNlarge have hfactorial : D * s * 4 ^ s ≤ (N + 1).factorial := by exact hpowbound.trans (by simpa [Nat.add_comm] using (@Nat.factorial_mul_pow_le_factorial 1 N)) have hfactorialQ : (D : ℚ) * s * 4 ^ s ≤ ((N + 1).factorial : ℚ) := by exact_mod_cast hfactorial have hRfac : R * ((N + 1).factorial : ℚ) ≤ 2 := by have heq : R * ((N + 1).factorial : ℚ) = |z| ^ (N + 1) * ((N + 2 : ℕ) : ℚ) / (N + 1 : ℕ) := by dsimp [R, expRemainder] field_simp rw [heq] norm_num [Nat.cast_add] apply (div_le_iff₀ (by positivity : (0 : ℚ) < N + 1)).2 nlinarith [hzpow (N + 1)] have hscaled : (D : ℚ) * s * 4 ^ s * R ≤ 2 := by calc (D : ℚ) * s * 4 ^ s * R ≤ ((N + 1).factorial : ℚ) * R := by exact mul_le_mul_of_nonneg_right hfactorialQ hR0 _ = R * ((N + 1).factorial : ℚ) := by ring _ ≤ 2 := hRfac have hraw : (expRaw q N).width ≤ 1 / (D : ℚ) := by have hp := interval_npow_width_le I s have hI0 : 0 ≤ I.maxAbs := (abs_nonneg I.lo).trans (le_max_left _ _) have hpow4 : I.maxAbs ^ (s - 1) ≤ (4 : ℚ) ^ (s - 1) := pow_le_pow_left₀ hI0 hImax _ have hbound : (s : ℚ) * I.maxAbs ^ (s - 1) * I.width ≤ (s : ℚ) * 4 ^ (s - 1) * (2 * R) := by rw [hIwidth] gcongr have hDq : (0 : ℚ) < D := by exact_mod_cast hD have hsform : (4 : ℚ) ^ s = 4 * 4 ^ (s - 1) := by calc (4 : ℚ) ^ s = 4 ^ (s - 1 + 1) := by congr 1 <;> omega _ = 4 ^ (s - 1) * 4 := pow_succ _ _ _ = 4 * 4 ^ (s - 1) := mul_comm _ _ have hfinal : (s : ℚ) * 4 ^ (s - 1) * (2 * R) ≤ 1 / D := by apply (le_div_iff₀ hDq).2 rw [hsform] at hscaled nlinarith simpa [expRaw, I, s] using hp.trans (hbound.trans hfinal) calc (expScalar q (expPrecision q ε)).width ≤ (expRaw q N).width := by apply RatInterval.width_mono simpa [N] using expScalar_subinterval_raw q N _ ≤ 1 / (D : ℚ) := hraw _ ≤ ε.1 := by simpa [D] using inv_den_le_of_pos ε.1 ε.2
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expScalar_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:332 · uses PosRat , width , expPrecision , expScalar
def expName reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational number, the certified-real representation of its exponential has value equal to the real exponential of that rational number, approximating intervals given by the scalar exponential enclosure sequence, nested approximations, containment of the exact value, the exponential precision index as its modulus, and the corresponding target-width guarantee.

Definition (Lean source)
q :
expName q :
clause 1
value := exp (q : ℝ)
clause 2
approx := expScalar q
clause 3
nested := expScalar_nested q
clause 4
contains := expScalar_sound q
clause 5
modulus := expPrecision q
clause 6
width_modulus := expScalar_width q
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expName · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:478 · uses CertifiedReal
6 supporting declarations (lemmas, instances)
  • abs_expReduced_le_one theorem — Range reduction puts the exponential Taylor argument in the closed unit interval.
    q :
    |expReduced q| ≤ 1
    Proof (Lean source)
    theorem abs_expReduced_le_one (q : ℚ) : |expReduced q| ≤ 1 := by have hsN : 0 < expScale q := lt_of_lt_of_le Nat.zero_lt_one (le_max_left _ _) have hs : (0 : ℚ) < expScale q := by exact_mod_cast hsN have hnum : |q| ≤ (q.num.natAbs : ℚ) := by have hd : (0 : ℚ) < q.den := by exact_mod_cast q.den_pos calc |q| = |(q.num : ℚ) / (q.den : ℚ)| := by rw [Rat.num_div_den] _ = (q.num.natAbs : ℚ) / q.den := by rw [abs_div, abs_of_pos hd] norm_num _ ≤ (q.num.natAbs : ℚ) := by apply (div_le_iff₀ hd).2 have hd1 : (1 : ℚ) ≤ q.den := by exact_mod_cast q.den_pos nlinarith rw [expReduced, abs_div, abs_of_pos hs] apply (div_le_iff₀ hs).2 have hscale : (q.num.natAbs : ℚ) ≤ expScale q := by exact_mod_cast (le_max_right 1 q.num.natAbs) simpa only [one_mul] using hnum.trans hscale
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.abs_expReduced_le_one · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:58
  • expRaw_sound theorem — The raw rational exponential interval encloses the real exponential of the rational input.
    q :
    n :
    (expRaw q n).Contains (exp (q : ℝ))
    Proof (Lean source)
    theorem expRaw_sound (q : ℚ) (n : ℕ) : (expRaw q n).Contains (exp (q : ℝ)) := by let z := expReduced q have hzR : |(z : ℝ)| ≤ 1 := by exact_mod_cast abs_expReduced_le_one q have hb := Real.exp_bound hzR (n := n + 1) (Nat.succ_pos n) have hp : ((expPartial z n : ℚ) : ℝ) = ∑ k ∈ range (n + 1), (z : ℝ) ^ k / (k.factorial : ℝ) := by simp [expPartial] have hr : ((expRemainder z n : ℚ) : ℝ) = |(z : ℝ)| ^ (n + 1) * ((n + 2 : ℕ) : ℝ) / (((n + 1).factorial : ℝ) * (n + 1 : ℕ)) := by simp [expRemainder] rw [← hp] at hb have hb' : |exp (z : ℝ) - (expPartial z n : ℝ)| ≤ (expRemainder z n : ℝ) := by rw [hr] convert hb using 1 <;> norm_num [Nat.cast_succ] <;> ring have hred : (expReducedRaw z n).Contains (exp (z : ℝ)) := by rw [abs_le] at hb' simp only [expReducedRaw, RatInterval.Contains, Rat.cast_sub, Rat.cast_add] constructor <;> linarith [hb'.1, hb'.2] have hpow := RatInterval.npow_sound hred (expScale q) have hs : (expScale q : ℝ) ≠ 0 := by exact_mod_cast (ne_of_gt (lt_of_lt_of_le Nat.zero_lt_one (le_max_left 1 q.num.natAbs))) have hq : (q : ℝ) = (expScale q : ℝ) * (z : ℝ) := by dsimp [z, expReduced] push_cast field_simp [hs] simpa [expRaw, ← Real.exp_nat_mul, hq] using hpow
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expRaw_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:80
  • expScalar_sound theorem — Every tightened scalar exponential interval encloses the real exponential.
    q :
    n :
    (expScalar q n).Contains (exp (q : ℝ))
    Proof (Lean source)
    theorem expScalar_sound (q : ℚ) (n : ℕ) : (expScalar q n).Contains (exp (q : ℝ)) := by induction n with | zero => exact expRaw_sound q 0 | succ n ih => exact RatInterval.tighten_sound ih (expRaw_sound q (n + 1))
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expScalar_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:113
  • expScalar_nested theorem — Scalar exponential enclosures are nested as precision increases.
    q :
    n :
    (expScalar q (n + 1)).Subinterval (expScalar q n)
    Proof (Lean source)
    theorem expScalar_nested (q : ℚ) (n : ℕ) : (expScalar q (n + 1)).Subinterval (expScalar q n) := by exact RatInterval.tighten_subinterval_left (expScalar_sound q n) (expRaw_sound q (n + 1))
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expScalar_nested · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:121
  • tighten_subinterval_right theorem — Tightening two enclosures of the same real value is contained in either input enclosure.
    I J :
    x :
    hI :
    I.Contains x
    hJ :
    J.Contains x
    (RatInterval.tighten I J).Subinterval J
    Proof (Lean source)
    theorem tighten_subinterval_right {I J : RatInterval} {x : ℝ} (hI : I.Contains x) (hJ : J.Contains x) : (RatInterval.tighten I J).Subinterval J := by have hlohi : max I.lo J.lo ≤ min I.hi J.hi := by apply max_le · apply le_min I.lo_le_hi exact_mod_cast hI.1.trans hJ.2 · apply le_min · exact_mod_cast hJ.1.trans hI.2 · exact J.lo_le_hi simp only [RatInterval.tighten, hlohi, dif_pos, RatInterval.Subinterval] exact ⟨le_max_right _ _, min_le_right _ _⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.tighten_subinterval_right · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:127
  • inv_den_le_of_pos theorem — The reciprocal of a positive rational's denominator is no larger than the rational itself.
    u :
    hu :
    0 < u
    1 / (u.den : ℚ) ≤ u
    Proof (Lean source)
    theorem inv_den_le_of_pos (u : ℚ) (hu : 0 < u) : 1 / (u.den : ℚ) ≤ u := by have hnum0 : 0 ≤ u.num := Rat.num_nonneg.mpr hu.le have hnumne : u.num ≠ 0 := by intro h have hu0 : u = 0 := by rw [← Rat.num_div_den u, h] simp linarith have hnum1 : (1 : ℚ) ≤ u.num := by exact_mod_cast (lt_of_le_of_ne hnum0 (Ne.symm hnumne)) calc 1 / (u.den : ℚ) ≤ (u.num : ℚ) / u.den := div_le_div_of_nonneg_right hnum1 (by positivity) _ = u := Rat.num_div_den u
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.inv_den_le_of_pos · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Exponential.lean:315
Quadrature 4 core · 3 supporting This module turns complex rational node rectangles on a uniform mesh into a sound enclosure of an interval integral. ★ integralEnclosure_sound

Certified trapezoidal contour quadrature

This module turns complex rational node rectangles on a uniform mesh into a sound enclosure of an interval integral. The deterministic trapezoidal rule is widened by an explicit Lipschitz error, and the result specializes to a circle contour through its standard parameterization.

def trapezoidSum reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

Given a sequence of complex rational rectangles, the unscaled trapezoidal rectangle sum at a nonnegative index is computed recursively: at zero it is the zero rectangle, and at each successor it adds the two rectangles at the new cell's endpoints to the preceding sum.

Definition (Lean source)
nodes :
trapezoidSum nodes :
clause 1
| 0 => ComplexRatInterval.zero
clause 2
| n + 1
=> ComplexRatInterval.add (trapezoidSum nodes n) (ComplexRatInterval.add (nodes n) (nodes (n + 1)))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.trapezoidSum · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Quadrature.lean:18 · uses ComplexRatInterval
def trapezoidEnclosure reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

For a sequence of complex rational rectangles and a mesh size, the trapezoidal enclosure is the unscaled trapezoidal rectangle sum multiplied by 1/(2n)1/(2n). It is meaningful for positive mesh size, as required by the integral enclosure built from it; at mesh size zero the scale factor is zero by the division convention.

Definition (Lean source)
nodes :
n :
trapezoidEnclosure nodes n :
ComplexRatInterval.smulRat (1 / (2 * n : ℚ)) (trapezoidSum nodes n)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.trapezoidEnclosure · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Quadrature.lean:24 · uses ComplexRatInterval
def integralEnclosure reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

Given a sequence of complex rational node rectangles, a rational Lipschitz constant, the condition that this constant is nonnegative, a mesh size, and the condition that the mesh size is positive, the integral enclosure widens the trapezoidal enclosure by L/(2n)L/(2n) in both coordinates.

Definition (Lean source)
nodes :
L :
hL :
0 ≤ L
n :
hn :
0 < n
integralEnclosure nodes L hL n hn :
(trapezoidEnclosure nodes n).expand (L / (2 * n)) (by positivity)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.integralEnclosure · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Quadrature.lean:28 · uses ComplexRatInterval
theorem integralEnclosure_sound reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh

Certified trapezoidal enclosure of an integral. Fix a nonnegative Lipschitz constant and a positive node count, and suppose the complex-valued integrand is Lipschitz on [0, 1] with that constant and each complex rational rectangle contains the integrand's value at the corresponding mesh point. Then the trapezoidal enclosure built from those rectangles contains the true integral of the integrand over [0, 1].

Formal statement
g :
ℝ → ℂ
nodes :
L :
hL :
0 ≤ L
n :
hn :
0 < n
hLip :
∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, ‖g s - g t‖ ≤ (L : ℝ) * |s - t|
hnodes :
∀ k ≤ n, (nodes k).Contains (g (meshPoint n k))
(integralEnclosure nodes L hL n hn).Contains (∫ u in (0 : ℝ)..1, g u)
Proof (Lean source)
theorem integralEnclosure_sound {g : ℝ → ℂ} {nodes : ℕ → ComplexRatInterval} {L : ℚ} (hL : 0 ≤ L) {n : ℕ} (hn : 0 < n) (hLip : ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, ‖g s - g t‖ ≤ (L : ℝ) * |s - t|) (hnodes : ∀ k ≤ n, (nodes k).Contains (g (meshPoint n k))) : (integralEnclosure nodes L hL n hn).Contains (∫ u in (0 : ℝ)..1, g u) := by let T : ℂ := (1 / (2 * n : ℝ)) * ∑ k ∈ range n, (g (meshPoint n k) + g (meshPoint n (k + 1))) have hsum := trapezoidSum_sound (N := n) n hnodes have hT : (trapezoidEnclosure nodes n).Contains T := by unfold trapezoidEnclosure T convert ComplexRatInterval.smulRat_sound (1 / (2 * n : ℚ)) hsum using 1 <;> norm_num [Nat.cast_mul] have herr : ‖(∫ u in (0 : ℝ)..1, g u) - T‖ ≤ (L : ℝ) / (2 * n) := by exact norm_integral_sub_trapezoid_le hL hn hLip unfold integralEnclosure apply expand_contains_of_norm_sub (he := by positivity) hT simpa [Rat.cast_div, Rat.cast_natCast] using herr
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.integralEnclosure_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Quadrature.lean:236 · uses integralEnclosure , meshPoint , ComplexRatInterval , Contains
3 supporting declarations (lemmas, instances)
  • norm_integral_sub_trapezoid_le theorem — A Lipschitz complex function on the unit parameter interval differs from its deterministic trapezoidal rule by at most half a Lipschitz mesh unit.
    g :
    ℝ → ℂ
    L :
    hL :
    0 ≤ L
    n :
    hn :
    0 < n
    hLip :
    ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, ‖g s - g t‖ ≤ (L : ℝ) * |s - t|
    ‖(∫ u in (0 : ℝ)..1, g u) - ((1 / (2 * n : ℝ)) * ∑ k ∈ range n, (g (meshPoint n k) + g (meshPoint n (k + 1))))‖
    ≤ (L : ℝ) / (2 * n)
    Proof (Lean source)
    theorem norm_integral_sub_trapezoid_le {g : ℝ → ℂ} {L : ℚ} (hL : 0 ≤ L) {n : ℕ} (hn : 0 < n) (hLip : ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, ‖g s - g t‖ ≤ (L : ℝ) * |s - t|) : ‖(∫ u in (0 : ℝ)..1, g u) - ((1 / (2 * n : ℝ)) * ∑ k ∈ range n, (g (meshPoint n k) + g (meshPoint n (k + 1))))‖ ≤ (L : ℝ) / (2 * n) := by have hL' : (0 : ℝ) ≤ L := by exact_mod_cast hL have hn' : (0 : ℝ) < n := by exact_mod_cast hn have hcont : ContinuousOn g (Icc (0 : ℝ) 1) := continuousOn_of_lipschitz_bound hL' hLip have hcell : ∀ k < n, ‖(∫ u in meshPoint n k..meshPoint n (k + 1), g u) - (1 / (2 * n : ℝ)) * (g (meshPoint n k) + g (meshPoint n (k + 1)))‖ ≤ (L : ℝ) / (2 * n * n) := by intro k hk let a := meshPoint n k let b := meshPoint n (k + 1) have hka : k ≤ n := (le_of_lt hk) have hkb : k + 1 ≤ n := hk have hab : a ≤ b := meshPoint_mono hn k.le_succ have ha : a ∈ Icc (0 : ℝ) 1 := meshPoint_mem hn hka have hb : b ∈ Icc (0 : ℝ) 1 := meshPoint_mem hn hkb have hgi : IntervalIntegrable g volume a b := (hcont.mono (by rw [uIcc_of_le hab] intro x hx exact ⟨ha.1.trans hx.1, hx.2.trans hb.2⟩)).intervalIntegrable have hp : ∀ u ∈ uIcc a b, ‖g u - ((1 / 2 : ℝ) : ℂ) * (g a + g b)‖ ≤ (L : ℝ) / (2 * n) := by intro u hu rw [uIcc_of_le hab] at hu have huI : u ∈ Icc (0 : ℝ) 1 := ⟨ha.1.trans hu.1, hu.2.trans hb.2⟩ have hla := hLip u huI a ha have hlb := hLip u huI b hb have hdist : |u - a| + |u - b| = b - a := by rw [abs_of_nonneg (sub_nonneg.mpr hu.1), abs_of_nonpos (sub_nonpos.mpr hu.2)] ring have halg : g u - ((1 / 2 : ℝ) : ℂ) * (g a + g b) = ((1 / 2 : ℝ) : ℂ) * (g u - g a) + ((1 / 2 : ℝ) : ℂ) * (g u - g b) := by norm_num ring rw [halg] calc ‖((1 / 2 : ℝ) : ℂ) * (g u - g a) + ((1 / 2 : ℝ) : ℂ) * (g u - g b)‖ ≤ ‖((1 / 2 : ℝ) : ℂ) * (g u - g a)‖ + ‖((1 / 2 : ℝ) : ℂ) * (g u - g b)‖ := norm_add_le _ _ _ = (1 / 2 : ℝ) * ‖g u - g a‖ + (1 / 2 : ℝ) * ‖g u - g b‖ := by simp [norm_mul] _ ≤ (1 / 2 : ℝ) * ((L : ℝ) * |u - a|) + (1 / 2 : ℝ) * ((L : ℝ) * |u - b|) := by gcongr _ = (L : ℝ) / 2 * (b - a) := by rw [← hdist]; ring _ = (L : ℝ) / (2 * n) := by rw [show b - a = 1 / (n : ℝ) by exact meshPoint_succ_sub hn] ring have hbound : ‖∫ u in a..b, (g u - ((1 / 2 : ℝ) : ℂ) * (g a + g b))‖ ≤ ((L : ℝ) / (2 * n)) * |b - a| := intervalIntegral.norm_integral_le_of_norm_le_const (by intro u hu apply hp u rw [uIcc_of_le hab] rw [show Ι a b = Ioc a b from uIoc_of_le hab] at hu exact ⟨le_of_lt hu.1, hu.2⟩) have hrewrite : (∫ u in a..b, g u) - (1 / (2 * n : ℝ)) * (g a + g b) = ∫ u in a..b, (g u - ((1 / 2 : ℝ) : ℂ) * (g a + g b)) := by have hscale : (1 / (2 * n : ℝ)) * (g a + g b) = (1 / (n : ℝ)) • (((1 / 2 : ℝ) : ℂ) * (g a + g b)) := by rw [Complex.real_smul] push_cast field_simp rw [intervalIntegral.integral_sub hgi intervalIntegrable_const, intervalIntegral.integral_const] rw [show b - a = 1 / (n : ℝ) by exact meshPoint_succ_sub hn] rw [hscale] rw [hrewrite] calc ‖∫ u in a..b, (g u - ((1 / 2 : ℝ) : ℂ) * (g a + g b))‖ ≤ ((L : ℝ) / (2 * n)) * |b - a| := hbound _ = (L : ℝ) / (2 * n * n) := by rw [show b - a = 1 / (n : ℝ) by exact meshPoint_succ_sub hn, abs_of_nonneg (by positivity)] ring rw [sum_cell_integrals hn hcont, Finset.mul_sum, ← Finset.sum_sub_distrib] calc _ ≤ ∑ k ∈ range n, ‖(∫ u in meshPoint n k..meshPoint n (k + 1), g u) - (1 / (2 * n : ℝ)) * (g (meshPoint n k) + g (meshPoint n (k + 1)))‖ := by convert norm_sum_le _ _ using 1 <;> norm_num [Nat.cast_mul] _ ≤ ∑ _k ∈ range n, (L : ℝ) / (2 * n * n) := by gcongr with k hk exact hcell k (Finset.mem_range.mp hk) _ = (L : ℝ) / (2 * n) := by simp only [Finset.sum_const, Finset.card_range, nsmul_eq_mul] field_simp
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.norm_integral_sub_trapezoid_le · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Quadrature.lean:75
  • integralEnclosure_width theorem — Each coordinate width of the certified integral is bounded by the uniform node width plus one mesh-scale Lipschitz allowance.
    nodes :
    w L :
    hw :
    0 ≤ w
    hL :
    0 ≤ L
    n :
    hn :
    0 < n
    hnodes :
    ∀ k ≤ n, (nodes k).re.width ≤ w ∧ (nodes k).im.width ≤ w
    conclusion 1
    (integralEnclosure nodes L hL n hn).re.width ≤ w + L / n
    conclusion 2
    (integralEnclosure nodes L hL n hn).im.width ≤ w + L / n
    Proof (Lean source)
    theorem integralEnclosure_width {nodes : ℕ → ComplexRatInterval} {w L : ℚ} (hw : 0 ≤ w) (hL : 0 ≤ L) {n : ℕ} (hn : 0 < n) (hnodes : ∀ k ≤ n, (nodes k).re.width ≤ w ∧ (nodes k).im.width ≤ w) : (integralEnclosure nodes L hL n hn).re.width ≤ w + L / n ∧ (integralEnclosure nodes L hL n hn).im.width ≤ w + L / n := by have hs := width_trapezoidSum hw hnodes have hq : (0 : ℚ) ≤ 1 / (2 * n : ℚ) := by positivity have hscale := width_smulRat_of_nonneg (trapezoidSum nodes n) hq have htre : (trapezoidEnclosure nodes n).re.width ≤ w := by rw [trapezoidEnclosure, hscale.1] calc (1 / (2 * n : ℚ)) * (trapezoidSum nodes n).re.width ≤ (1 / (2 * n : ℚ)) * (2 * n * w) := mul_le_mul_of_nonneg_left hs.1 hq _ = w := by field_simp have htim : (trapezoidEnclosure nodes n).im.width ≤ w := by rw [trapezoidEnclosure, hscale.2] calc (1 / (2 * n : ℚ)) * (trapezoidSum nodes n).im.width ≤ (1 / (2 * n : ℚ)) * (2 * n * w) := mul_le_mul_of_nonneg_left hs.2 hq _ = w := by field_simp have herr : L / (2 * n : ℚ) + L / (2 * n : ℚ) = L / n := by field_simp ring unfold RatInterval.width at htre htim constructor <;> simp only [integralEnclosure, ComplexRatInterval.expand, RatInterval.expand, RatInterval.width] <;> linarith [herr]
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.integralEnclosure_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Quadrature.lean:261
  • circleContourIntegral_enclosed theorem — Applying the complex mesh theorem to the parameterized circle integrand encloses the contour integral.
    f :
    ℂ → ℂ
    c :
    r :
    nodes :
    L :
    hL :
    0 ≤ L
    n :
    hn :
    0 < n
    hLip :
    ∀ s ∈ Icc (0 : ℝ) 1,
    ∀ t ∈ Icc (0 : ℝ) 1,
    ‖circleIntegrand f c r s - circleIntegrand f c r t‖ ≤ (L : ℝ) * |s - t|
    hnodes :
    ∀ k ≤ n, (nodes k).Contains (circleIntegrand f c r (meshPoint n k))
    (integralEnclosure nodes L hL n hn).Contains (circleContourIntegral f c r)
    Proof (Lean source)
    theorem circleContourIntegral_enclosed {f : ℂ → ℂ} {c : ℂ} {r : ℝ} {nodes : ℕ → ComplexRatInterval} {L : ℚ} (hL : 0 ≤ L) {n : ℕ} (hn : 0 < n) (hLip : ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, ‖circleIntegrand f c r s - circleIntegrand f c r t‖ ≤ (L : ℝ) * |s - t|) (hnodes : ∀ k ≤ n, (nodes k).Contains (circleIntegrand f c r (meshPoint n k))) : (integralEnclosure nodes L hL n hn).Contains (circleContourIntegral f c r) := by exact integralEnclosure_sound hL hn hLip hnodes
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CircleMesh.circleContourIntegral_enclosed · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Quadrature.lean:293
API 2 core · 0 supporting This module collects exact rational interval arithmetic, certified-real refinement, transcendental interval extensions, finite mesh enclosures, and total measurable finite searches into one paper-independent interface.

Packaged certified contour interval arithmetic

This module collects exact rational interval arithmetic, certified-real refinement, transcendental interval extensions, finite mesh enclosures, and total measurable finite searches into one paper-independent interface.

structure CertifiedIntervalArithmetic reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic

This interface packages sound rational interval arithmetic and total certified-real refinement behind a paper-independent interface.

Definition (Lean source)
The packaged outward addition operation.
Packaged addition encloses sums of enclosed real operands.
add_sound :
∀ {I J : RatInterval} {x y : ℝ}
if
I.Contains x
and
J.Contains y
then
(add I J).Contains (x + y)
The packaged outward subtraction operation.
Packaged subtraction encloses differences of enclosed real operands.
sub_sound :
∀ {I J : RatInterval} {x y : ℝ}
if
I.Contains x
and
J.Contains y
then
(sub I J).Contains (x - y)
The packaged outward multiplication operation.
Packaged multiplication encloses products of enclosed real operands.
mul_sound :
∀ {I J : RatInterval} {x y : ℝ}
if
I.Contains x
and
J.Contains y
then
(mul I J).Contains (x * y)
The packaged outward division operation requires a denominator interval separated from zero.
div :
(I J : RatInterval) → J.AwayFromZero → RatInterval
Packaged division encloses quotients of enclosed operands away from zero.
div_sound :
∀ {I J : RatInterval} {x y : ℝ} (hJ : J.AwayFromZero)
if
I.Contains x
and
J.Contains y
then
(div I J hJ).Contains (x / y)
The packaged outward exponential extension at a requested natural precision.
exp :
Packaged exponential evaluation encloses exponentials of enclosed reals.
exp_sound :
∀ {I : RatInterval} {x : ℝ}
if
I.Contains x
then
∀ n, (exp I n).Contains (exp x)
The packaged outward logarithm extension requires a strictly positive interval.
log :
(I : RatInterval) → 0 < I.lo → ℕ → RatInterval
Packaged logarithm evaluation encloses logarithms on a certified positive interval.
log_sound :
∀ {I : RatInterval} {x : ℝ} (hI : 0 < I.lo)
if
I.Contains x
then
∀ n, (log I hI n).Contains (log x)
The packaged real-power extension requires a strictly positive base interval.
rpow :
(base exponent : RatInterval) → 0 < base.lo → ℕ → RatInterval
Packaged real-power evaluation encloses real powers on the positive-base domain.
rpow_sound :
∀ {base exponent : RatInterval} {x y : ℝ} (hbase : 0 < base.lo)
if
base.Contains x
and
exponent.Contains y
then
∀ n, (rpow base exponent hbase n).Contains (x ^ y)
The packaged total refinement operation for certified real names.
refine :
Packaged refinement preserves enclosure of the named real value.
refine_contains :
∀ (x : CertifiedReal) (ε : PosRat), (refine x ε).Contains x.value
Packaged refinement returns no more than the requested rational width.
refine_width :
∀ (x : CertifiedReal) (ε : PosRat), (refine x ε).width ≤ ε.1
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.CertifiedIntervalArithmetic · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/API.lean:14
def certifiedIntervalArithmetic reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic

The concrete certified interval-arithmetic package provides outwardly sound rational interval operations for addition, subtraction, multiplication, division away from zero, exponentiation, logarithms and real powers on their positive domains, together with certified-real refinement of any requested positive rational precision.

Definition (Lean source)
certifiedIntervalArithmetic :
clause 1
add := RatInterval.add
clause 2
add_sound := RatInterval.add_sound
clause 3
sub := RatInterval.sub
clause 4
sub_sound := RatInterval.sub_sound
clause 5
mul := RatInterval.mul
clause 6
mul_sound := RatInterval.mul_sound
clause 7
div := RatInterval.div
clause 8
div_sound := RatInterval.div_sound
clause 9
exp := Transcendental.expInterval
clause 10
exp_sound := by intro I x hx n exact Transcendental.expInterval_sound hx n
clause 11
log := Transcendental.logInterval
clause 12
log_sound := by intro I x hI hx n exact Transcendental.logInterval_sound hI hx n
clause 13
rpow := Transcendental.rpowInterval
clause 14
rpow_sound := by intro base exponent x y hbase hx hy n exact Transcendental.rpowInterval_sound hbase hx hy n
clause 15
refine := CertifiedReal.refine
clause 16
refine_contains := CertifiedReal.refine_contains
clause 17
refine_width := CertifiedReal.refine_width
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.certifiedIntervalArithmetic · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/API.lean:63 · uses CertifiedIntervalArithmetic
Finite­Search 4 core · 13 supporting This module provides the finite control flow used by certified numerical procedures. ★ measurable_leastScoreIndex

Total finite searches, deterministic ties, and measurability

This module provides the finite control flow used by certified numerical procedures. It returns a least successful candidate with an explicit fallback, breaks equal real scores by index, and proves that the resulting finite outputs are Borel measurable.

def leastTrue reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.FiniteSearch

For a nonnegative integer and a Boolean-valued family indexed by the n+1n+1 indices from zero through $n, the least-successful-index rule returns the smallest index whose Boolean value is true when such an index exists, and index zero when none exists.

Definition (Lean source)
n :
accept :
Fin (n + 1) → Bool
leastTrue accept :
Fin (n + 1)
if h : (Finset.univ.filter fun i => accept i).Nonempty then (Finset.univ.filter fun i => accept i).min' h else 0
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.FiniteSearch.leastTrue · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/FiniteSearch.lean:45
def finiteRefine reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.FiniteSearch

For a nonnegative integer, a family of n+1n+1 rational candidate intervals, and a strictly positive rational width tolerance, the finite-refinement interval is the candidate at the least index whose width is at most the tolerance, or the zeroth candidate when no candidate meets that condition.

Definition (Lean source)
n :
candidates :
Fin (n + 1) → RatInterval
ε :
finiteRefine candidates ε :
candidates (leastTrue fun i => decide ((candidates i).width ≤ ε.1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.FiniteSearch.finiteRefine · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/FiniteSearch.lean:86 · uses PosRat , RatInterval
def leastScoreIndex reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.FiniteSearch

For a nonnegative integer and a real-valued score for each of the n+1n+1 indices from zero through $n, the least-score index is obtained by forming the finite set of pairs consisting of each score and its index, ordered first by score and then by index, certifying that this finite set is nonempty, and returning the index in its least pair.

Definition (Lean source)
n :
score :
Fin (n + 1) → ℝ
leastScoreIndex score :
Fin (n + 1)
by classical let keys : Finset (ℝ ×ₗ Fin (n + 1)) := Finset.univ.image (fun i => toLex (score i, i)) have hkeys : keys.Nonempty := by refine ⟨toLex (score 0, 0), ?_⟩ exact Finset.mem_image.mpr ⟨0, Finset.mem_univ _, rfl⟩ exact (ofLex (keys.min' hkeys)).2
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.FiniteSearch.leastScoreIndex · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/FiniteSearch.lean:112
theorem measurable_leastScoreIndex reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.FiniteSearch

For a sample-size index n, the function that selects, from a vector of n+1 real scores, the smallest index attaining the least score is measurable with respect to the Borel σ-algebra on the score vector space and the discrete σ-algebra on the finite index set.

Formal statement
n :
Measurable (leastScoreIndex : (Fin (n + 1) → ℝ) → Fin (n + 1))
Proof (Lean source)
@[fun_prop] theorem measurable_leastScoreIndex {n : ℕ} : Measurable (leastScoreIndex : (Fin (n + 1) → ℝ) → Fin (n + 1)) := by apply measurable_to_countable' intro i have hmeas : MeasurableSet {score : Fin (n + 1) → ℝ | ∀ j, score i < score j ∨ (score i = score j ∧ i ≤ j)} := by rw [show {score : Fin (n + 1) → ℝ | ∀ j, score i < score j ∨ (score i = score j ∧ i ≤ j)} = ⋂ j, {score | score i < score j ∨ (score i = score j ∧ i ≤ j)} by ext score simp] apply MeasurableSet.iInter intro j apply MeasurableSet.union · exact measurableSet_lt (measurable_pi_apply i) (measurable_pi_apply j) · apply MeasurableSet.inter · exact measurableSet_eq_fun (measurable_pi_apply i) (measurable_pi_apply j) · exact MeasurableSet.const _ rw [show (leastScoreIndex : (Fin (n + 1) → ℝ) → Fin (n + 1)) ⁻¹' {i} = {score | ∀ j, score i < score j ∨ (score i = score j ∧ i ≤ j)} by ext score simp only [Set.mem_preimage, Set.mem_singleton_iff, Set.mem_setOf_eq] constructor · intro hselected j have hmin := leastScoreIndex_minimal score j rw [hselected] at hmin rcases lt_or_eq_of_le hmin with hlt | heq · exact inl hlt · exact inr ⟨heq, by have htie := leastScoreIndex_tie score (i := j) (by rw [hselected] exact heq.symm) rwa [hselected] at htie⟩ · intro hall let k := leastScoreIndex score have hik : i ≤ k := by rcases hall k with hlt | heq · exact elim ((not_lt_of_ge (leastScoreIndex_minimal score i)) hlt) · exact heq.2 have hki : k ≤ i := by apply leastScoreIndex_tie score rcases hall k with hlt | heq · exact elim ((not_lt_of_ge (leastScoreIndex_minimal score i)) hlt) · exact heq.1 exact le_antisymm hki hik] exact hmeas
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.FiniteSearch.measurable_leastScoreIndex · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/FiniteSearch.lean:174 · uses leastScoreIndex
13 supporting declarations (lemmas, instances)
Logarithm 8 core · 4 supporting This module computes nested rational intervals for the logarithm of a positive rational input. ★ logScalar_width

Certified rational logarithm enclosures

This module computes nested rational intervals for the logarithm of a positive rational input. The atanh series and an explicit geometric remainder bound produce a certified real name with a computable precision for every positive rational error target.

def logCoordinate reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational number, the logarithm coordinate is (q1)/(q+1)(q-1)/(q+1). It is the atanh coordinate of the logarithm for positive qq, the regime used by the logarithm enclosures; at q=1q=-1 the denominator vanishes and the value is zero by the division convention.

Definition (Lean source)
q :
logCoordinate q :
(q - 1) / (q + 1)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.logCoordinate · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Logarithm.lean:19
def logPartial reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational number and a nonnegative polynomial degree, the logarithm Taylor partial sum is twice the sum, for every integer kk from zero through nn, of the (2k+1)(2k+1)st power of the logarithm coordinate divided by 2k+12k+1. It approximates the logarithm of qq only for positive qq; no positivity is imposed by the definition itself.

Definition (Lean source)
q :
n :
logPartial q n :
2 * ∑ k ∈ range (n + 1), (logCoordinate q) ^ (2 * k + 1) / ((2 * k + 1 : ℕ) : ℚ)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.logPartial · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Logarithm.lean:22
def logRemainder reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational number and a nonnegative polynomial degree, the logarithm remainder bound is 2z2n+3/((2n+3)(1z2))2|z|^{2n+3}/((2n+3)(1-|z|^2)), where z=(q1)/(q+1)z=(q-1)/(q+1). It bounds the series tail only for positive qq, where z<1|z|<1; at q=0q=0 (where z=1|z|=1) and at q=1q=-1 the formula divides by zero and gives zero by the division convention.

Definition (Lean source)
q :
n :
logRemainder q n :
2 * |logCoordinate q| ^ (2 * n + 3) / (((2 * n + 3 : ℕ) : ℚ) * (1 - |logCoordinate q| ^ 2))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.logRemainder · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Logarithm.lean:27
def logRaw reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational number that is strictly positive and a nonnegative polynomial degree, the raw logarithm enclosure has lower endpoint equal to the logarithm partial sum minus its remainder bound, upper endpoint equal to the logarithm partial sum plus its remainder bound, and valid endpoint order.

Definition (Lean source)
q :
hq :
0 < q
n :
logRaw q hq n :
⟨logPartial q n
+ logRemainder q n, by have hz := abs_logCoordinate_lt_one_aux q hq have hsquare : |logCoordinate q| ^ 2 < 1 := by nlinarith [mul_self_lt_mul_self (abs_nonneg (logCoordinate q)) hz] have hd : 0 < 1
- |logCoordinate q| ^ 2 := sub_pos.mpr hsquare have hr : 0
logRemainder q n := by simp only [logRemainder] positivity linarith⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.logRaw · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Logarithm.lean:105 · uses RatInterval
def logScalar reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a strictly positive rational number, the scalar logarithm enclosure sequence assigns the raw logarithm enclosure at degree zero to index zero and the conditional tightening of the preceding enclosure with the next raw enclosure to each positive index.

Definition (Lean source)
q :
hq :
0 < q
logScalar q hq :
ℕ → RatInterval
clause 1
| 0 => logRaw q hq 0
clause 2
| n + 1 => RatInterval.tighten (logScalar q hq n) (logRaw q hq (n + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.logScalar · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Logarithm.lean:118 · uses RatInterval
def logPrecision reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational number and a strictly positive rational target width, the logarithm precision index is the product of one plus the target-width denominator and two copies of one plus the sum of the absolute numerator and denominator of the rational number.

Definition (Lean source)
q :
ε :
logPrecision q ε :
(ε.1.den + 1) * (q.num.natAbs + q.den + 1) * (q.num.natAbs + q.den + 1)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.logPrecision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Logarithm.lean:123 · uses PosRat
theorem logScalar_width reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

Precision-driven logarithm enclosure width. For a positive rational number and a requested positive rational tolerance, evaluating the scalar logarithm enclosure at the precision level determined from those two inputs produces an interval no wider than the requested tolerance.

Formal statement
q :
hq :
0 < q
ε :
(logScalar q hq (logPrecision q ε)).width ≤ ε.1
Proof (Lean source)
theorem logScalar_width (q : ℚ) (hq : 0 < q) (ε : PosRat) : (logScalar q hq (logPrecision q ε)).width ≤ ε.1 := by let D : ℚ := ε.1.den let S : ℚ := q.num.natAbs + q.den + 1 let N : ℕ := logPrecision q ε let r : ℚ := |logCoordinate q| have hD : 1 ≤ D := by dsimp [D] exact_mod_cast ε.1.den_pos have hS : 2 ≤ S := by dsimp [S] have ha : (0 : ℚ) ≤ q.num.natAbs := by positivity have hb : (1 : ℚ) ≤ q.den := by exact_mod_cast q.den_pos linarith have hr0 : 0 ≤ r := by positivity have hr1 : r < 1 := by simpa [r] using abs_logCoordinate_lt_one q hq have hrpow : r ^ (2 * N + 3) ≤ 1 := by exact pow_le_one₀ hr0 hr1.le have hgap : 1 / S ≤ 1 - r ^ 2 := by simpa [S, r] using logCoordinate_gap_lower q hq have hSpos : 0 < S := lt_of_lt_of_le (by norm_num) hS have hSgap : 1 ≤ S * (1 - r ^ 2) := by simpa [mul_comm] using (div_le_iff₀ hSpos).mp hgap have hN : (N : ℚ) = (D + 1) * S * S := by dsimp [N, D, S, logPrecision] push_cast ring have hden : 4 * D ≤ ((2 * N + 3 : ℕ) : ℚ) * (1 - r ^ 2) := by have hgap0 : 0 ≤ 1 - r ^ 2 := by nlinarith [sq_nonneg r] have hlarge := mul_le_mul_of_nonneg_left hSgap (show 0 ≤ 2 * (D + 1) * S by positivity) have hstep : 2 * (D + 1) * S ≤ (2 * (D + 1) * S * S) * (1 - r ^ 2) := by nlinarith push_cast rw [hN] nlinarith [mul_nonneg (show (0 : ℚ) ≤ 3 by norm_num) hgap0] have hdenpos : 0 < ((2 * N + 3 : ℕ) : ℚ) * (1 - r ^ 2) := by have : 0 < 1 - r ^ 2 := by nlinarith [sq_nonneg r] positivity have hraw : (logRaw q hq N).width ≤ ε.1 := by have hnum : 4 * r ^ (2 * N + 3) ≤ 4 := by nlinarith have hfrac : 4 * r ^ (2 * N + 3) / (((2 * N + 3 : ℕ) : ℚ) * (1 - r ^ 2)) ≤ 1 / D := by apply (div_le_div_iff₀ hdenpos (show 0 < D by linarith)).2 simpa only [one_mul] using (mul_le_mul_of_nonneg_right hnum (show 0 ≤ D by linarith)).trans hden calc (logRaw q hq N).width = 4 * r ^ (2 * N + 3) / (((2 * N + 3 : ℕ) : ℚ) * (1 - r ^ 2)) := by simp [RatInterval.width, logRaw, logRemainder, r] ring _ ≤ 1 / D := hfrac _ ≤ ε.1 := by simpa [D] using inv_den_le_of_pos ε.1 ε.2 exact (RatInterval.width_mono (logScalar_subinterval_raw q hq N)).trans hraw
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.logScalar_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Logarithm.lean:228 · uses PosRat , width , logPrecision , logScalar
def logName reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational number that is strictly positive, the certified-real representation of its logarithm has value equal to the real logarithm of that rational number, approximating intervals given by the scalar logarithm enclosure sequence, nested approximations, containment of the exact value, the logarithm precision index as its modulus, and the corresponding target-width guarantee.

Definition (Lean source)
q :
hq :
0 < q
logName q hq :
clause 1
value := log (q : ℝ)
clause 2
approx := logScalar q hq
clause 3
nested := logScalar_nested q hq
clause 4
contains := logScalar_sound q hq
clause 5
modulus := logPrecision q
clause 6
width_modulus := logScalar_width q hq
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.logName · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Logarithm.lean:289 · uses CertifiedReal
4 supporting declarations (lemmas, instances)
  • abs_logCoordinate_lt_one theorem — A positive rational logarithm argument has atanh coordinate of absolute value strictly below one.
    q :
    hq :
    0 < q
    Proof (Lean source)
    theorem abs_logCoordinate_lt_one (q : ℚ) (hq : 0 < q) : |logCoordinate q| < 1 := by exact abs_logCoordinate_lt_one_aux q hq
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.abs_logCoordinate_lt_one · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Logarithm.lean:127
  • logRaw_sound theorem — The raw rational logarithm interval encloses the real logarithm of its positive rational input.
    q :
    hq :
    0 < q
    n :
    (logRaw q hq n).Contains (log (q : ℝ))
    Proof (Lean source)
    theorem logRaw_sound (q : ℚ) (hq : 0 < q) (n : ℕ) : (logRaw q hq n).Contains (log (q : ℝ)) := by let z := logCoordinate q have hz : |(z : ℝ)| < 1 := by exact_mod_cast abs_logCoordinate_lt_one q hq have hb := log_series_remainder_bound (z : ℝ) hz n have hratio : (1 + (z : ℝ)) / (1 - (z : ℝ)) = (q : ℝ) := by have hd : (q : ℝ) + 1 ≠ 0 := by positivity dsimp [z, logCoordinate] push_cast field_simp [hd] ring have hplus : (1 + (z : ℝ)) ≠ 0 := by have := (abs_lt.mp hz).1 linarith have hminus : (1 - (z : ℝ)) ≠ 0 := by have := (abs_lt.mp hz).2 linarith have hlog : log (q : ℝ) = log (1 + (z : ℝ)) - log (1 - (z : ℝ)) := by rw [← Real.log_div hplus hminus, hratio] have hp : ((logPartial q n : ℚ) : ℝ) = 2 * ∑ k ∈ range (n + 1), (z : ℝ) ^ (2 * k + 1) / (2 * k + 1 : ℕ) := by simp [logPartial, z] have hr : ((logRemainder q n : ℚ) : ℝ) = 2 * |(z : ℝ)| ^ (2 * n + 3) / ((2 * n + 3 : ℕ) * (1 - |(z : ℝ)| ^ 2)) := by simp [logRemainder, z] rw [← hlog, ← hp, ← hr] at hb rw [abs_le] at hb simp only [logRaw, RatInterval.Contains, Rat.cast_sub, Rat.cast_add] constructor <;> linarith [hb.1, hb.2]
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.logRaw_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Logarithm.lean:170
  • logScalar_sound theorem — Every tightened scalar logarithm interval encloses the real logarithm.
    q :
    hq :
    0 < q
    n :
    (logScalar q hq n).Contains (log (q : ℝ))
    Proof (Lean source)
    theorem logScalar_sound (q : ℚ) (hq : 0 < q) (n : ℕ) : (logScalar q hq n).Contains (log (q : ℝ)) := by induction n with | zero => exact logRaw_sound q hq 0 | succ n ih => exact RatInterval.tighten_sound ih (logRaw_sound q hq (n + 1))
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.logScalar_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Logarithm.lean:206
  • logScalar_nested theorem — Scalar logarithm enclosures are nested as precision increases.
    q :
    hq :
    0 < q
    n :
    (logScalar q hq (n + 1)).Subinterval (logScalar q hq n)
    Proof (Lean source)
    theorem logScalar_nested (q : ℚ) (hq : 0 < q) (n : ℕ) : (logScalar q hq (n + 1)).Subinterval (logScalar q hq n) := by exact RatInterval.tighten_subinterval_left (logScalar_sound q hq n) (logRaw_sound q hq (n + 1))
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.logScalar_nested · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Logarithm.lean:214
Operations 5 core · 5 supporting This module lifts the certified scalar exponential and logarithm constructions to rational input intervals. ★ rpowInterval_sound

Transcendental interval extensions

This module lifts the certified scalar exponential and logarithm constructions to rational input intervals. It supplies sound and nested interval extensions for exponential, positive-domain logarithm, and positive-base real powers.

def expInterval reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational interval and a precision index, the exponential interval evaluation has lower endpoint equal to the lower endpoint of the scalar exponential enclosure at the input interval's lower endpoint, upper endpoint equal to the upper endpoint of the scalar exponential enclosure at the input interval's upper endpoint, and valid endpoint order.

Definition (Lean source)
n :
expInterval I n :
⟨expIntervalLo I n, expIntervalHi I n, expInterval_wellFormed I n⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.expInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Operations.lean:31 · uses RatInterval
def logInterval reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a rational interval whose lower endpoint is strictly positive and a precision index, the logarithm interval evaluation has lower endpoint equal to the lower endpoint of the scalar logarithm enclosure at the original lower endpoint, upper endpoint equal to the upper endpoint of the scalar logarithm enclosure at the original upper endpoint, and valid endpoint order.

Definition (Lean source)
hI :
0 < I.lo
n :
logInterval I hI n :
⟨(logScalar I.lo hI n).lo, (logScalar I.hi (hI.trans_le I.lo_le_hi) n).hi, logInterval_wellFormed I hI n⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.logInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Operations.lean:48 · uses RatInterval
def rpowRaw reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a base rational interval and an exponent rational interval whose base interval has a strictly positive lower endpoint, and a precision index, the raw real-power interval is the exponential interval of the product of the exponent interval and the logarithm interval of the base.

Definition (Lean source)
base exponent :
hbase :
0 < base.lo
n :
rpowRaw base exponent hbase n :
expInterval (RatInterval.mul exponent (logInterval base hbase n)) n
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.rpowRaw · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Operations.lean:54 · uses RatInterval
def rpowInterval reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

For a base rational interval and an exponent rational interval whose base interval has a strictly positive lower endpoint, the real-power interval sequence assigns the raw real-power interval at precision zero to index zero and the conditional tightening of the preceding interval with the next raw real-power interval to each positive index.

Definition (Lean source)
base exponent :
hbase :
0 < base.lo
rpowInterval base exponent hbase :
ℕ → RatInterval
clause 1
| 0 => rpowRaw base exponent hbase 0
clause 2
| n + 1
=> RatInterval.tighten (rpowInterval base exponent hbase n) (rpowRaw base exponent hbase (n + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.rpowInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Operations.lean:58 · uses RatInterval
theorem rpowInterval_sound reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental

Certified real-power interval evaluation. For a base rational interval whose lower endpoint is strictly positive that encloses a real base value, and an exponent rational interval enclosing a real exponent value, the real-power interval evaluation of the base and exponent, at any precision level, contains the true value of the base raised to that exponent.

Formal statement
base exponent :
x y :
hbase :
0 < base.lo
hx :
base.Contains x
hy :
exponent.Contains y
n :
(rpowInterval base exponent hbase n).Contains (x ^ y)
Proof (Lean source)
theorem rpowInterval_sound {base exponent : RatInterval} {x y : ℝ} (hbase : 0 < base.lo) (hx : base.Contains x) (hy : exponent.Contains y) (n : ℕ) : (rpowInterval base exponent hbase n).Contains (x ^ y) := by induction n with | zero => exact rpowRaw_sound hbase hx hy 0 | succ n ih => exact RatInterval.tighten_sound ih (rpowRaw_sound hbase hx hy (n + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.rpowInterval_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Operations.lean:100 · uses RatInterval , Contains , rpowInterval
5 supporting declarations (lemmas, instances)