Mathlib.Analysis.Interval­Arithmetic.Contour

Certified interval evaluation of complex contour integrals, with rectangle and circle schedules and rigorous transcendental-function bounds.

Transcendental 20 core · 12 supporting This module defines executable Machin/Taylor enclosures for π, sine and cosine; real interval exponential evaluation lives in Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.IntervalExp. ★ piInterval_width

Rational real transcendental enclosures

This module defines executable Machin/Taylor enclosures for π, sine and cosine; real interval exponential evaluation lives in Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.IntervalExp. Raw rational bounds are recursively intersected, so adjacent-fuel nesting follows from finite intersection rather than from an order asserted between unrelated tolerance parameters. Complex exponential composition and its magnitude-sensitive name semantics live in Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexExp.

def atanPartial reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational argument and a natural-number fuel level, the arctangent Taylor partial sum is the alternating rational series through degree 2f+12f+1.

Definition (Lean source)
q :
ℚ
fuel :
ℕ
atanPartial q fuel :
ℚ
∑ k ∈ range (fuel + 1), (-1 : ℚ) ^ k * q ^ (2 * k + 1) / (2 * k + 1 : ℕ)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.atanPartial · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:36
def atanError reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational argument and a natural-number fuel level, the arctangent remainder scale is ∣q∣2f+3/(2f+3)|q|^{2f+3}/(2f+3).

Definition (Lean source)
q :
ℚ
fuel :
ℕ
atanError q fuel :
ℚ
|q| ^ (2 * fuel + 3) / (2 * fuel + 3 : ℕ)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.atanError · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:41
def atanRaw reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational argument and a natural-number fuel level, the raw arctangent interval has endpoints equal to the Taylor partial sum minus and plus the remainder scale, respectively.

Definition (Lean source)
q :
ℚ
fuel :
ℕ
atanRaw q fuel :
⟨atanPartial q fuel - atanError q fuel, atanPartial q fuel + atanError q fuel, by have : 0
≤ atanError q fuel := by simp only [atanError] positivity linarith⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.atanRaw · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:47 · uses RatInterval
def piRaw reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a natural-number fuel level, the raw π interval is four times the difference between four times the arctangent interval at 1/51/5 and the arctangent interval at 1/2391/239.

Definition (Lean source)
fuel :
ℕ
piRaw fuel :
(RatInterval.point 4).mul ((RatInterval.point 4).mul (atanRaw (1 / 5) fuel) |>.sub (atanRaw (1 / 239) fuel))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.piRaw · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:56 · uses RatInterval
def piInterval reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

For a natural-number fuel level, the π interval at that level is the raw π interval at level zero, and at every successor level is the intersection of the preceding π interval and the new raw π interval.

Definition (Lean source)
piInterval :
ℕ → RatInterval
clause 1
| 0 => piRaw 0
clause 2
| fuel + 1 => (piInterval fuel).tighten (piRaw (fuel + 1))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.piInterval · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:64 · uses RatInterval
def piPrecision reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a positive rational target width, the π precision is eight times one plus the denominator of that target.

Definition (Lean source)
ε :
piPrecision ε :
ℕ
8 * (ε.1.den + 1)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.piPrecision · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:69 · uses PosRat
theorem piInterval_width reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

For a requested positive rational tolerance ε, evaluating the certified π-enclosure at the precision level selected for that tolerance yields an enclosure whose width is no larger than ε.

Formal statement
ε :
(piInterval (piPrecision ε)).width ≤ ε.1
Proof (Lean source)
theorem piInterval_width (ε : PosRat) : (piInterval (piPrecision ε)).width ≤ ε.1 := by let N := piPrecision ε have hw := RatInterval.width_mono (piInterval_subinterval_raw N) rw [piRaw_width_eq] at hw have hp5 : |(1 / 5 : ℚ)| ^ (2 * N + 3) ≤ 1 / 125 := by norm_num only [abs_of_nonneg (by norm_num : (0 : ℚ) ≤ 1 / 5)] norm_num [show 2 * N + 3 = 3 + 2 * N by omega, pow_add] exact pow_le_one₀ (by norm_num) (by norm_num) have hp239 : |(1 / 239 : ℚ)| ^ (2 * N + 3) ≤ 1 / 125 := by calc _ ≤ |(1 / 5 : ℚ)| ^ (2 * N + 3) := by gcongr <;> norm_num _ ≤ _ := hp5 have he5 : atanError (1 / 5) N ≤ (1 / 125) / (2 * N + 3 : ℕ) := by rw [atanError] exact div_le_div_of_nonneg_right hp5 (by positivity) have he239 : atanError (1 / 239) N ≤ (1 / 125) / (2 * N + 3 : ℕ) := by rw [atanError] exact div_le_div_of_nonneg_right hp239 (by positivity) have hden : (16 : ℚ) * ε.1.den ≤ (2 * N + 3 : ℕ) := by dsimp [N, piPrecision] push_cast nlinarith have hεden : (1 : ℚ) ≤ ε.1 * ε.1.den := by have hn : 0 < ε.1.num := (Rat.num_pos).2 ε.2 have hr := Rat.num_div_den ε.1 have hd : (0 : ℚ) < ε.1.den := by exact_mod_cast ε.1.den_pos have heq : (ε.1.num : ℚ) = ε.1 * ε.1.den := (div_eq_iff hd.ne').mp hr rw [← heq] exact_mod_cast hn have hcoarse : 40 * ((1 / 125 : ℚ) / (2 * N + 3 : ℕ)) ≤ ε.1 := by rw [show 40 * ((1 / 125 : ℚ) / (2 * N + 3 : ℕ)) = (40 * (1 / 125 : ℚ)) / (2 * N + 3 : ℕ) by ring] apply (div_le_iff₀ (by positivity : (0 : ℚ) < (2 * N + 3 : ℕ))).2 have hprod : 16 ≤ ε.1 * (2 * N + 3 : ℕ) := by nlinarith [mul_le_mul_of_nonneg_left hden ε.2.le] norm_num [Nat.cast_add, Nat.cast_mul] at hprod ⊢ exact (by norm_num : (8 / 25 : ℚ) ≤ 16).trans hprod exact hw.trans (by nlinarith [he5, he239, hcoarse])
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.piInterval_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:169 · uses piInterval , piPrecision , PosRat , width
def piName reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

The certified real name for π has exact value π, uses the recursively refined π intervals as approximations, and uses the specified π precision to achieve each requested positive rational width.

Definition (Lean source)
piName :
clause 1
value := pi
clause 2
approx := piInterval
clause 3
clause 4
contains := piInterval_sound
clause 5
clause 6
width_modulus := piInterval_width
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.piName · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:212 · uses CertifiedReal
def sinPartial reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational argument and a natural-number fuel level, the sine Taylor partial sum is the alternating rational sine series through degree 2f+12f+1.

Definition (Lean source)
q :
ℚ
fuel :
ℕ
sinPartial q fuel :
ℚ
∑ k ∈ range (fuel + 1), (-1 : ℚ) ^ k * q ^ (2 * k + 1) / ((2 * k + 1).factorial : ℚ)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.sinPartial · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:221
def sinError reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational argument and a natural-number fuel level, the sine remainder scale is ∣q∣2f+3/(2f+3)!|q|^{2f+3}/(2f+3)!.

Definition (Lean source)
q :
ℚ
fuel :
ℕ
sinError q fuel :
ℚ
|q| ^ (2 * fuel + 3) / ((2 * fuel + 3).factorial : ℚ)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.sinError · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:226
def cosPartial reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational argument and a natural-number fuel level, the cosine Taylor partial sum is the alternating rational cosine series through degree 2f2f.

Definition (Lean source)
q :
ℚ
fuel :
ℕ
cosPartial q fuel :
ℚ
∑ k ∈ range (fuel + 1), (-1 : ℚ) ^ k * q ^ (2 * k) / ((2 * k).factorial : ℚ)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.cosPartial · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:230
def cosError reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational argument and a natural-number fuel level, the cosine remainder scale is ∣q∣2f+2/(2f+2)!|q|^{2f+2}/(2f+2)!.

Definition (Lean source)
q :
ℚ
fuel :
ℕ
cosError q fuel :
ℚ
|q| ^ (2 * fuel + 2) / ((2 * fuel + 2).factorial : ℚ)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.cosError · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:235
def sinRaw reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational argument and a natural-number fuel level, the raw sine interval has endpoints equal to the sine Taylor partial sum minus and plus the sine remainder scale, respectively.

Definition (Lean source)
q :
ℚ
fuel :
ℕ
sinRaw q fuel :
⟨sinPartial q fuel - sinError q fuel, sinPartial q fuel + sinError q fuel, by have : 0
≤ sinError q fuel := by simp only [sinError] positivity linarith⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.sinRaw · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:239 · uses RatInterval
def cosRaw reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational argument and a natural-number fuel level, the raw cosine interval has endpoints equal to the cosine Taylor partial sum minus and plus the cosine remainder scale, respectively.

Definition (Lean source)
q :
ℚ
fuel :
ℕ
cosRaw q fuel :
⟨cosPartial q fuel - cosError q fuel, cosPartial q fuel + cosError q fuel, by have : 0
≤ cosError q fuel := by simp only [cosError] positivity linarith⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.cosRaw · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:248 · uses RatInterval
def intervalMid reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational interval, its rational midpoint is the arithmetic mean of its lower and upper endpoints.

Definition (Lean source)
intervalMid I :
ℚ
(I.lo + I.hi) / 2
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.intervalMid · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:257 · uses RatInterval
def intervalRadius reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational interval, its rational radius is half its width.

Definition (Lean source)
intervalRadius I :
ℚ
I.width / 2
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.intervalRadius · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:262 · uses RatInterval
def sinIntervalRaw reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational input interval and a natural-number fuel level, the raw sine image interval expands the midpoint sine interval by the input interval's radius.

Definition (Lean source)
fuel :
ℕ
sinIntervalRaw I fuel :
(sinRaw (intervalMid I) fuel).expand (intervalRadius I) (by exact div_nonneg (RatInterval.width_nonneg I) (by norm_num))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.sinIntervalRaw · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:267 · uses RatInterval
def cosIntervalRaw reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational input interval and a natural-number fuel level, the raw cosine image interval expands the midpoint cosine interval by the input interval's radius.

Definition (Lean source)
fuel :
ℕ
cosIntervalRaw I fuel :
(cosRaw (intervalMid I) fuel).expand (intervalRadius I) (by exact div_nonneg (RatInterval.width_nonneg I) (by norm_num))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.cosIntervalRaw · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:274 · uses RatInterval
def sinInterval reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

For a rational input interval and a natural-number fuel level, the sine image interval at that level is the raw sine image interval at level zero, and at every successor level is the intersection of the preceding sine image interval and the new raw sine image interval.

Definition (Lean source)
sinInterval I :
ℕ → RatInterval
clause 1
| 0 => sinIntervalRaw I 0
clause 2
| fuel + 1 => (sinInterval I fuel).tighten (sinIntervalRaw I (fuel + 1))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.sinInterval · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:281 · uses RatInterval
def cosInterval reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

For a rational input interval and a natural-number fuel level, the cosine image interval at that level is the raw cosine image interval at level zero, and at every successor level is the intersection of the preceding cosine image interval and the new raw cosine image interval.

Definition (Lean source)
cosInterval I :
ℕ → RatInterval
clause 1
| 0 => cosIntervalRaw I 0
clause 2
| fuel + 1 => (cosInterval I fuel).tighten (cosIntervalRaw I (fuel + 1))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.cosInterval · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:286 · uses RatInterval
12 supporting declarations (lemmas, instances)
  • piRaw_sound theorem — Every raw Machin rectangle contains the mathematical constant π.
    fuel :
    ℕ
    (piRaw fuel).Contains pi
    Proof (Lean source)
    theorem piRaw_sound (fuel : ℕ) : (piRaw fuel).Contains pi := by have hfour := RatInterval.point_sound 4 have h5 := atanRaw_sound_of_nonneg_lt_one (1 / 5) (by norm_num) (by norm_num) fuel have h239 := atanRaw_sound_of_nonneg_lt_one (1 / 239) (by norm_num) (by norm_num) fuel have h := RatInterval.mul_sound hfour (RatInterval.sub_sound (RatInterval.mul_sound hfour h5) h239) have hm := Real.four_mul_arctan_inv_5_sub_arctan_inv_239 have heq : (4 : ℝ) * ((4 : ℝ) * Real.arctan (1 / 5 : ℝ) - Real.arctan (1 / 239 : ℝ)) = pi := by norm_num [div_eq_mul_inv] nlinarith [hm] rw [← heq] simpa [piRaw] using h
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.piRaw_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:118
  • piInterval_sound theorem — Every recursively intersected π rectangle contains π.
    fuel :
    ℕ
    (piInterval fuel).Contains pi
    Proof (Lean source)
    theorem piInterval_sound (fuel : ℕ) : (piInterval fuel).Contains pi := by induction fuel with | zero => exact piRaw_sound 0 | succ fuel ih => exact RatInterval.tighten_sound ih (piRaw_sound (fuel + 1))
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.piInterval_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:133
  • piInterval_nested theorem — Adjacent π fuel values are nested by construction through finite intersection.
    fuel :
    ℕ
    (piInterval (fuel + 1)).Subinterval (piInterval fuel)
    Proof (Lean source)
    theorem piInterval_nested (fuel : ℕ) : (piInterval (fuel + 1)).Subinterval (piInterval fuel) := by exact RatInterval.tighten_subinterval_left (piInterval_sound fuel) (piRaw_sound (fuel + 1))
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.piInterval_nested · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:140
  • sinRaw_sound theorem — Raw rational sine bounds contain the exact sine at every rational center.
    q :
    ℚ
    fuel :
    ℕ
    (sinRaw q fuel).Contains (sin q)
    Proof (Lean source)
    theorem sinRaw_sound (q : ℚ) (fuel : ℕ) : (sinRaw q fuel).Contains (sin q) := by have hb := sin_taylor_error_bound (q : ℝ) fuel have hp : ((sinPartial q fuel : ℚ) : ℝ) = ∑ k ∈ range (fuel + 1), (-1 : ℝ) ^ k * (q : ℝ) ^ (2 * k + 1) / ((2 * k + 1).factorial : ℝ) := by simp [sinPartial] have he : ((sinError q fuel : ℚ) : ℝ) = |(q : ℝ)| ^ (2 * fuel + 3) / ((2 * fuel + 3).factorial : ℝ) := by simp [sinError] rw [← hp, ← he, abs_le] at hb exact ⟨by simpa [sinRaw] using hb.1, by simpa [sinRaw, add_comm] using hb.2⟩
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.sinRaw_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:462
  • cosRaw_sound theorem — Raw rational cosine bounds contain the exact cosine at every rational center.
    q :
    ℚ
    fuel :
    ℕ
    (cosRaw q fuel).Contains (cos q)
    Proof (Lean source)
    theorem cosRaw_sound (q : ℚ) (fuel : ℕ) : (cosRaw q fuel).Contains (cos q) := by have hb := cos_taylor_error_bound (q : ℝ) fuel have hp : ((cosPartial q fuel : ℚ) : ℝ) = ∑ k ∈ range (fuel + 1), (-1 : ℝ) ^ k * (q : ℝ) ^ (2 * k) / ((2 * k).factorial : ℝ) := by simp [cosPartial] have he : ((cosError q fuel : ℚ) : ℝ) = |(q : ℝ)| ^ (2 * fuel + 2) / ((2 * fuel + 2).factorial : ℝ) := by simp [cosError] rw [← hp, ← he, abs_le] at hb exact ⟨by simpa [cosRaw] using hb.1, by simpa [cosRaw, add_comm] using hb.2⟩
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.cosRaw_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:476
  • abs_sub_intervalMid_le_radius theorem — Every real point enclosed by a rational interval is at most half its width away from the interval's rational midpoint.
    x :
    ℝ
    hx :
    I.Contains x
    |x - (intervalMid I : ℝ)| ≤ (intervalRadius I : ℝ)
    Proof (Lean source)
    theorem abs_sub_intervalMid_le_radius {I : RatInterval} {x : ℝ} (hx : I.Contains x) : |x - (intervalMid I : ℝ)| ≤ (intervalRadius I : ℝ) := by have hlo : (I.lo : ℝ) ≤ x := hx.1 have hhi : x ≤ (I.hi : ℝ) := hx.2 rw [abs_le] simp only [intervalMid, intervalRadius, RatInterval.width, Rat.cast_div, Rat.cast_add, Rat.cast_sub, Rat.cast_ofNat] constructor <;> linarith
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.abs_sub_intervalMid_le_radius · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:490
  • sinInterval_sound theorem — Sine interval evaluation encloses sine throughout the input interval.
    x :
    ℝ
    hx :
    I.Contains x
    fuel :
    ℕ
    (sinInterval I fuel).Contains (sin x)
    Proof (Lean source)
    theorem sinInterval_sound {I : RatInterval} {x : ℝ} (hx : I.Contains x) (fuel : ℕ) : (sinInterval I fuel).Contains (sin x) := by induction fuel with | zero => exact sinIntervalRaw_sound hx 0 | succ fuel ih => exact RatInterval.tighten_sound ih (sinIntervalRaw_sound hx (fuel + 1))
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.sinInterval_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:523
  • cosInterval_sound theorem — Cosine interval evaluation encloses cosine throughout the input interval.
    x :
    ℝ
    hx :
    I.Contains x
    fuel :
    ℕ
    (cosInterval I fuel).Contains (cos x)
    Proof (Lean source)
    theorem cosInterval_sound {I : RatInterval} {x : ℝ} (hx : I.Contains x) (fuel : ℕ) : (cosInterval I fuel).Contains (cos x) := by induction fuel with | zero => exact cosIntervalRaw_sound hx 0 | succ fuel ih => exact RatInterval.tighten_sound ih (cosIntervalRaw_sound hx (fuel + 1))
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.cosInterval_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:530
  • sinInterval_nested theorem — Adjacent sine outputs are nested by recursive finite intersection.
    fuel :
    ℕ
    (sinInterval I (fuel + 1)).Subinterval (sinInterval I fuel)
    Proof (Lean source)
    theorem sinInterval_nested (I : RatInterval) (fuel : ℕ) : (sinInterval I (fuel + 1)).Subinterval (sinInterval I fuel) := by have hmid : I.Contains (intervalMid I : ℝ) := by constructor <;> exact_mod_cast (by dsimp [intervalMid] linarith [I.lo_le_hi]) exact RatInterval.tighten_subinterval_left (sinInterval_sound hmid fuel) (sinIntervalRaw_sound hmid (fuel + 1))
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.sinInterval_nested · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:537
  • cosInterval_nested theorem — Adjacent cosine outputs are nested by recursive finite intersection.
    fuel :
    ℕ
    (cosInterval I (fuel + 1)).Subinterval (cosInterval I fuel)
    Proof (Lean source)
    theorem cosInterval_nested (I : RatInterval) (fuel : ℕ) : (cosInterval I (fuel + 1)).Subinterval (cosInterval I fuel) := by have hmid : I.Contains (intervalMid I : ℝ) := by constructor <;> exact_mod_cast (by dsimp [intervalMid] linarith [I.lo_le_hi]) exact RatInterval.tighten_subinterval_left (cosInterval_sound hmid fuel) (cosIntervalRaw_sound hmid (fuel + 1))
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.cosInterval_nested · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:547
  • sinInterval_width theorem — Sine output width is the shrinking input diameter plus its explicit Taylor error.
    fuel :
    ℕ
    (sinInterval I fuel).width ≤ I.width + 2 * sinError (intervalMid I) fuel
    Proof (Lean source)
    theorem sinInterval_width (I : RatInterval) (fuel : ℕ) : (sinInterval I fuel).width ≤ I.width + 2 * sinError (intervalMid I) fuel := by have hraw : (sinIntervalRaw I fuel).width = I.width + 2 * sinError (intervalMid I) fuel := by rw [sinIntervalRaw] simp [RatInterval.expand, sinRaw, intervalRadius, RatInterval.width] ring cases fuel with | zero => exact hraw.le | succ fuel => have hmid : I.Contains (intervalMid I : ℝ) := by constructor <;> exact_mod_cast (by dsimp [intervalMid] linarith [I.lo_le_hi]) exact (RatInterval.width_mono (Transcendental.tighten_subinterval_right (sinInterval_sound hmid fuel) (sinIntervalRaw_sound hmid (fuel + 1)))).trans_eq hraw
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.sinInterval_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:557
  • cosInterval_width theorem — Cosine output width is the shrinking input diameter plus its explicit Taylor error.
    fuel :
    ℕ
    (cosInterval I fuel).width ≤ I.width + 2 * cosError (intervalMid I) fuel
    Proof (Lean source)
    theorem cosInterval_width (I : RatInterval) (fuel : ℕ) : (cosInterval I fuel).width ≤ I.width + 2 * cosError (intervalMid I) fuel := by have hraw : (cosIntervalRaw I fuel).width = I.width + 2 * cosError (intervalMid I) fuel := by rw [cosIntervalRaw] simp [RatInterval.expand, cosRaw, intervalRadius, RatInterval.width] ring cases fuel with | zero => exact hraw.le | succ fuel => have hmid : I.Contains (intervalMid I : ℝ) := by constructor <;> exact_mod_cast (by dsimp [intervalMid] linarith [I.lo_le_hi]) exact (RatInterval.width_mono (Transcendental.tighten_subinterval_right (cosInterval_sound hmid fuel) (cosIntervalRaw_sound hmid (fuel + 1)))).trans_eq hraw
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.cosInterval_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Transcendental.lean:576
Basic 5 core · 11 supporting This module extends rational intervals with sign-aware squaring, Newton square-root enclosures, convergence and width bounds, and endpoint-magnitude estimates. ★ sqrt_iterates_sound

Rational square and square-root interval bounds

This module extends rational intervals with sign-aware squaring, Newton square-root enclosures, convergence and width bounds, and endpoint-magnitude estimates. Complex rectangle operations and certified complex names live in Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Rectangles and Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Names, respectively.

def sq reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval

For a rational interval, its squared interval is the interval from the square of its upper endpoint to the square of its lower endpoint when it lies strictly below zero, the interval from the square of its lower endpoint to the square of its upper endpoint when it lies strictly above zero, and the interval from zero to the larger squared endpoint when it contains zero.

Definition (Lean source)
sq I :
if hneg : I.hi < 0 then ⟨I.hi ^ 2, I.lo ^ 2, by nlinarith [I.lo_le_hi]⟩ else if hpos : 0 < I.lo then ⟨I.lo ^ 2, I.hi ^ 2, by nlinarith [I.lo_le_hi]⟩ else ⟨0, max (I.lo ^ 2) (I.hi ^ 2), by positivity⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.sq · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:19 · uses RatInterval
def sqrtUpper reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval

For a rational number, the Newton upper-iterate sequence assigns the absolute value of the number plus one at iteration zero and one half of the sum of the preceding iterate and the number divided by that iterate at each later iteration.

Definition (Lean source)
q :
ℚ
sqrtUpper q :
ℕ → ℚ
clause 1
| 0 => |q| + 1
clause 2
| n + 1 => let u := sqrtUpper q n (u + q / u) / 2
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.sqrtUpper · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:79
def sqrtLower reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval

For a rational number and an iteration count, the Newton lower square-root bound is the number divided by its Newton upper iterate at that count.

Definition (Lean source)
q :
ℚ
n :
ℕ
sqrtLower q n :
ℚ
q / sqrtUpper q n
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.sqrtLower · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:86
theorem sqrt_iterates_sound reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval

For a nonnegative rational number q and any fuel count n, the Newton-iterate rational lower bound sqrtLower q n and upper bound sqrtUpper q n both enclose the real square root of q: sqrtLower q n ≤ √q ≤ sqrtUpper q n.

Formal statement
q :
ℚ
hq :
0 ≤ q
n :
ℕ
conclusion 1
(sqrtLower q n : ℝ) ≤ sqrt q
conclusion 2
sqrt q ≤ (sqrtUpper q n : ℝ)
Proof (Lean source)
theorem sqrt_iterates_sound (q : ℚ) (hq : 0 ≤ q) (n : ℕ) : (sqrtLower q n : ℝ) ≤ sqrt q ∧ sqrt q ≤ (sqrtUpper q n : ℝ) := by obtain ⟨hu, hsq⟩ := sqrtUpper_invariants q hq n have hqu : 0 ≤ q / sqrtUpper q n := div_nonneg hq hu.le have hmul : (q / sqrtUpper q n) * sqrtUpper q n = q := div_mul_cancel₀ q hu.ne' have hl_sq : (q / sqrtUpper q n) ^ 2 ≤ q := by nlinarith [sq_nonneg (sqrtUpper q n - q / sqrtUpper q n)] constructor · apply (Real.le_sqrt (by exact_mod_cast hqu) (by exact_mod_cast hq)).2 exact_mod_cast hl_sq · apply Real.sqrt_le_left (by exact_mod_cast hu.le) |>.2 exact_mod_cast hsq
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.sqrt_iterates_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:106 · uses sqrtLower , sqrtUpper
def sqrtInterval reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval

For a rational interval whose lower endpoint is nonnegative and a Newton iteration count, the square-root interval has lower endpoint equal to the Newton lower bound of the original lower endpoint, upper endpoint equal to the Newton upper bound of the original upper endpoint, and valid endpoint order.

Definition (Lean source)
hI :
0 ≤ I.lo
fuel :
ℕ
sqrtInterval I hI fuel :
⟨sqrtLower I.lo fuel, sqrtUpper I.hi fuel, by have hhi : 0
≤ I.hi := hI.trans I.lo_le_hi have hlo_sound := sqrt_iterates_sound I.lo hI fuel have hhi_sound := sqrt_iterates_sound I.hi hhi fuel have hsqrt : sqrt (I.lo : ℝ) ≤ sqrt (I.hi : ℝ) := Real.sqrt_le_sqrt (by exact_mod_cast I.lo_le_hi) exact_mod_cast hlo_sound.1.trans (hsqrt.trans hhi_sound.2)⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.sqrtInterval · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:183 · uses RatInterval
11 supporting declarations (lemmas, instances)
  • sq_sound theorem — The sign-aware rational square enclosure contains the square of every real number contained in the input interval.
    x :
    ℝ
    hx :
    I.Contains x
    (sq I).Contains (x ^ 2)
    Proof (Lean source)
    theorem sq_sound {I : RatInterval} {x : ℝ} (hx : I.Contains x) : (sq I).Contains (x ^ 2) := by rcases hx with ⟨hxlo, hxhi⟩ unfold sq split_ifs with hneg hpos · have hneg' : (I.hi : ℝ) < 0 := by exact_mod_cast hneg constructor <;> simp only [Rat.cast_pow] · nlinarith [hxhi] · nlinarith [hxlo, hxhi] · have hpos' : (0 : ℝ) < I.lo := by exact_mod_cast hpos have hhi' : (0 : ℝ) < I.hi := hpos'.trans_le (by exact_mod_cast I.lo_le_hi) constructor <;> simp only [Rat.cast_pow] · nlinarith [hxlo] · nlinarith [hxhi] · constructor · simpa using sq_nonneg x · simp only [Rat.cast_max, Rat.cast_pow] by_cases hx0 : x ≤ 0 · exact le_max_of_le_left (by nlinarith [hxlo]) · exact le_max_of_le_right (by nlinarith [hxhi])
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.sq_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:28
  • sq_mono theorem — Squaring is inclusion-isotone for rational intervals.
    I J :
    hIJ :
    I.Subinterval J
    (sq I).Subinterval (sq J)
    Proof (Lean source)
    theorem sq_mono {I J : RatInterval} (hIJ : I.Subinterval J) : (sq I).Subinterval (sq J) := by have Ilo : J.Contains (I.lo : ℝ) := by constructor · exact_mod_cast hIJ.1 · exact_mod_cast I.lo_le_hi.trans hIJ.2 have Ihi : J.Contains (I.hi : ℝ) := by constructor · exact_mod_cast hIJ.1.trans I.lo_le_hi · exact_mod_cast hIJ.2 have hlo := sq_sound Ilo have hhi := sq_sound Ihi rw [sq] split_ifs with Ihneg Ihpos · exact ⟨by exact_mod_cast hhi.1, by exact_mod_cast hlo.2⟩ · exact ⟨by exact_mod_cast hlo.1, by exact_mod_cast hhi.2⟩ · have hIlo : I.lo ≤ 0 := le_of_not_gt Ihpos have hIhi : 0 ≤ I.hi := le_of_not_gt Ihneg have hzero : J.Contains (0 : ℝ) := by constructor · exact_mod_cast hIJ.1.trans hIlo · exact_mod_cast hIhi.trans hIJ.2 have hz := sq_sound hzero constructor · exact_mod_cast hz.1 · exact max_le (by exact_mod_cast hlo.2) (by exact_mod_cast hhi.2)
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.sq_mono · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:51
  • sqrt_gap_rate theorem — The Newton upper-minus-lower gap is bounded by an explicit reciprocal fuel rate.
    q :
    ℚ
    hq :
    0 ≤ q
    n :
    ℕ
    sqrtUpper q n - sqrtLower q n ≤ (q + 1) / (n + 1)
    Proof (Lean source)
    theorem sqrt_gap_rate (q : ℚ) (hq : 0 ≤ q) (n : ℕ) : sqrtUpper q n - sqrtLower q n ≤ (q + 1) / (n + 1) := by induction n with | zero => rw [sqrtUpper, abs_of_nonneg hq] have hl : 0 ≤ sqrtLower q 0 := div_nonneg hq (sqrtUpper_invariants q hq 0).1.le norm_num linarith | succ n ih => have hstep : sqrtUpper q (n + 1) - sqrtLower q (n + 1) ≤ (sqrtUpper q n - sqrtLower q n) / 2 := by rw [sqrtUpper] rw [show q / sqrtUpper q n = sqrtLower q n by rfl] have hm := sqrtLower_mono_step q hq n linarith have hA : 0 ≤ q + 1 := by linarith calc sqrtUpper q (n + 1) - sqrtLower q (n + 1) ≤ (sqrtUpper q n - sqrtLower q n) / 2 := hstep _ ≤ ((q + 1) / (n + 1)) / 2 := div_le_div_of_nonneg_right ih (by norm_num) _ ≤ (q + 1) / (n + 1 + 1) := by rw [div_div] apply div_le_div_of_nonneg_left hA (by positivity) have hn0 : (0 : ℚ) ≤ n := by positivity push_cast nlinarith _ = (q + 1) / ((n + 1 : ℕ) + 1) := by norm_num [Nat.cast_add]
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.sqrt_gap_rate · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:141
  • sqrt_iterates_converge theorem — The gap between the Newton lower and upper square-root bounds is eventually below every positive rational tolerance.
    q :
    ℚ
    hq :
    0 ≤ q
    ε :
    ∃ n, sqrtUpper q n - sqrtLower q n ≤ ε.1
    Proof (Lean source)
    theorem sqrt_iterates_converge (q : ℚ) (hq : 0 ≤ q) (ε : PosRat) : ∃ n, sqrtUpper q n - sqrtLower q n ≤ ε.1 := by obtain ⟨n, hn⟩ := exists_nat_gt ((q + 1) / ε.1) refine ⟨n, (sqrt_gap_rate q hq n).trans ?_⟩ apply (div_le_iff₀ (by positivity : (0 : ℚ) < n + 1)).2 have hn' : q + 1 < ε.1 * n := by simpa [mul_comm] using (div_lt_iff₀ ε.2).mp hn push_cast nlinarith [ε.2]
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.sqrt_iterates_converge · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:171
  • sqrtInterval_sound theorem — The executable square-root interval encloses the square root of every nonnegative real contained in its input.
    hI :
    0 ≤ I.lo
    x :
    ℝ
    hx :
    I.Contains x
    fuel :
    ℕ
    (sqrtInterval I hI fuel).Contains (sqrt x)
    Proof (Lean source)
    theorem sqrtInterval_sound {I : RatInterval} (hI : 0 ≤ I.lo) {x : ℝ} (hx : I.Contains x) (fuel : ℕ) : (sqrtInterval I hI fuel).Contains (sqrt x) := by have hhi : 0 ≤ I.hi := hI.trans I.lo_le_hi have hlo_sound := sqrt_iterates_sound I.lo hI fuel have hhi_sound := sqrt_iterates_sound I.hi hhi fuel constructor · exact hlo_sound.1.trans (Real.sqrt_le_sqrt hx.1) · exact (Real.sqrt_le_sqrt hx.2).trans hhi_sound.2
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.sqrtInterval_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:193
  • sqrtInterval_width theorem — Square-root interval width is exactly the endpoint Newton gap, exposing both input-diameter and iteration-error contributions.
    hI :
    0 ≤ I.lo
    fuel :
    ℕ
    (sqrtInterval I hI fuel).width = sqrtUpper I.hi fuel - sqrtLower I.lo fuel
    Proof (Lean source)
    theorem sqrtInterval_width (I : RatInterval) (hI : 0 ≤ I.lo) (fuel : ℕ) : (sqrtInterval I hI fuel).width = sqrtUpper I.hi fuel - sqrtLower I.lo fuel := by rfl
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.sqrtInterval_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:205
  • maxAbs_le_of_contains_width theorem — Containment of one real value together with interval width controls both endpoint magnitudes.
    x :
    ℝ
    C w :
    ℚ
    hx :
    I.Contains x
    habs :
    |x| ≤ C
    hw :
    I.width ≤ w
    I.maxAbs ≤ C + w
    Proof (Lean source)
    theorem maxAbs_le_of_contains_width {I : RatInterval} {x : ℝ} {C w : ℚ} (hx : I.Contains x) (habs : |x| ≤ C) (hw : I.width ≤ w) : I.maxAbs ≤ C + w := by rw [abs_le] at habs rcases hx with ⟨hxlo, hxhi⟩ rcases habs with ⟨habslo, habshi⟩ have hw' : (I.hi : ℝ) - I.lo ≤ w := by exact_mod_cast hw apply max_le · rw [abs_le] constructor · exact_mod_cast (show (-(C + w) : ℝ) ≤ (I.lo : ℚ) by push_cast linarith) · exact_mod_cast (show (((I.lo : ℚ) : ℝ) ≤ (C + w : ℚ)) by push_cast linarith) · rw [abs_le] constructor · exact_mod_cast (show (-(C + w) : ℝ) ≤ (I.hi : ℚ) by push_cast linarith) · exact_mod_cast (show (((I.hi : ℚ) : ℝ) ≤ (C + w : ℚ)) by push_cast linarith)
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.maxAbs_le_of_contains_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:212
  • maxAbs_neg theorem — Negation preserves the maximum endpoint magnitude.
    I.neg.maxAbs = I.maxAbs
    Proof (Lean source)
    theorem maxAbs_neg (I : RatInterval) : I.neg.maxAbs = I.maxAbs := by simp [RatInterval.neg, RatInterval.maxAbs, max_comm]
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.maxAbs_neg · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:239
  • maxAbs_add theorem — Addition increases endpoint magnitude by at most the sum of operand bounds.
    I J :
    (I.add J).maxAbs ≤ I.maxAbs + J.maxAbs
    Proof (Lean source)
    theorem maxAbs_add (I J : RatInterval) : (I.add J).maxAbs ≤ I.maxAbs + J.maxAbs := by apply max_le · simpa [RatInterval.add, RatInterval.maxAbs] using (abs_add_le I.lo J.lo).trans (add_le_add (le_max_left _ _) (le_max_left _ _)) · simpa [RatInterval.add, RatInterval.maxAbs] using (abs_add_le I.hi J.hi).trans (add_le_add (le_max_right _ _) (le_max_right _ _))
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.maxAbs_add · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:243
  • maxAbs_sub theorem — Subtraction increases endpoint magnitude by at most the sum of operand bounds.
    I J :
    (I.sub J).maxAbs ≤ I.maxAbs + J.maxAbs
    Proof (Lean source)
    theorem maxAbs_sub (I J : RatInterval) : (I.sub J).maxAbs ≤ I.maxAbs + J.maxAbs := by simpa [RatInterval.sub, maxAbs_neg] using maxAbs_add I J.neg
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.maxAbs_sub · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:254
  • maxAbs_mul theorem — Interval multiplication has the product of operand endpoint magnitudes as an executable magnitude bound.
    I J :
    (I.mul J).maxAbs ≤ I.maxAbs * J.maxAbs
    Proof (Lean source)
    theorem maxAbs_mul (I J : RatInterval) : (I.mul J).maxAbs ≤ I.maxAbs * J.maxAbs := by have hI0 : 0 ≤ I.maxAbs := (abs_nonneg I.lo).trans (le_max_left _ _) have hp (x y : ℚ) (hx : |x| ≤ I.maxAbs) (hy : |y| ≤ J.maxAbs) : |x * y| ≤ I.maxAbs * J.maxAbs := by rw [abs_mul] exact mul_le_mul hx hy (abs_nonneg y) hI0 have ha := hp I.lo J.lo (le_max_left _ _) (le_max_left _ _) have hb := hp I.lo J.hi (le_max_left _ _) (le_max_right _ _) have hc := hp I.hi J.lo (le_max_right _ _) (le_max_left _ _) have hd := hp I.hi J.hi (le_max_right _ _) (le_max_right _ _) simp only [RatInterval.maxAbs, RatInterval.mul] apply max_le · calc |min (min (I.lo * J.lo) (I.lo * J.hi)) (min (I.hi * J.lo) (I.hi * J.hi))| ≤ max |min (I.lo * J.lo) (I.lo * J.hi)| |min (I.hi * J.lo) (I.hi * J.hi)| := abs_min_le_max_abs_abs _ ≤ max (max |I.lo * J.lo| |I.lo * J.hi|) (max |I.hi * J.lo| |I.hi * J.hi|) := max_le_max abs_min_le_max_abs_abs abs_min_le_max_abs_abs _ ≤ I.maxAbs * J.maxAbs := max_le (max_le ha hb) (max_le hc hd) · calc |max (max (I.lo * J.lo) (I.lo * J.hi)) (max (I.hi * J.lo) (I.hi * J.hi))| ≤ max |max (I.lo * J.lo) (I.lo * J.hi)| |max (I.hi * J.lo) (I.hi * J.hi)| := abs_max_le_max_abs_abs _ ≤ max (max |I.lo * J.lo| |I.lo * J.hi|) (max |I.hi * J.lo| |I.hi * J.hi|) := max_le_max abs_max_le_max_abs_abs abs_max_le_max_abs_abs _ ≤ I.maxAbs * J.maxAbs := max_le (max_le ha hb) (max_le hc hd)
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.RatInterval.maxAbs_mul · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Basic.lean:259
Rectangles 12 core · 20 supporting This module equips rational complex rectangles with sound arithmetic, guarded division, modulus bounds, and explicit width propagation. ★ div_sound

Rational complex rectangle operations

This module equips rational complex rectangles with sound arithmetic, guarded division, modulus bounds, and explicit width propagation.

def width reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval

Given a rational complex rectangle, its width is the larger of the widths of its real and imaginary coordinate intervals.

Definition (Lean source)
width I :
ℚ
max I.re.width I.im.width
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:15 · uses ComplexRatInterval
def maxAbs reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval

Given a rational complex rectangle, its maximum coordinate endpoint magnitude is the larger of the maximum absolute endpoint magnitudes of its real and imaginary coordinate intervals.

Definition (Lean source)
maxAbs I :
ℚ
max I.re.maxAbs I.im.maxAbs
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.maxAbs · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:18 · uses ComplexRatInterval
def point reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval

Given a rational real coordinate and a rational imaginary coordinate, the complex point rectangle is the zero-width rectangle containing x+iyx+iy.

Definition (Lean source)
x y :
ℚ
point x y :
⟨RatInterval.point x, RatInterval.point y⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.point · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:21 · uses ComplexRatInterval
def neg reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval

Given a rational complex rectangle, its negative rectangle negates both coordinate intervals.

Definition (Lean source)
⟨I.re.neg, I.im.neg⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.neg · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:25 · uses ComplexRatInterval
def sub reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval

Given a first rational complex rectangle and a second rational complex rectangle, their difference rectangle adds the first rectangle to the coordinatewise negative of the second.

Definition (Lean source)
sub I J :
I.add (neg J)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.sub · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:28 · uses ComplexRatInterval
def mul reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval

Given two rational complex rectangles, their product rectangle is obtained from the Cartesian complex-product formula using outward rational interval operations on the coordinate intervals.

Definition (Lean source)
mul I J :
⟨(I.re.mul J.re).sub (I.im.mul J.im), (I.re.mul J.im).add (I.im.mul J.re)⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.mul · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:31 · uses ComplexRatInterval
def conj reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval

Given a rational complex rectangle, its conjugate rectangle retains its real coordinate interval and negates its imaginary coordinate interval.

Definition (Lean source)
⟨I.re, I.im.neg⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.conj · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:36 · uses ComplexRatInterval
def normSq reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval

Given a rational complex rectangle, its squared-modulus interval is the sum of the sign-aware squares of its real and imaginary coordinate intervals.

Definition (Lean source)
normSq I :
(RatInterval.sq I.re).add (RatInterval.sq I.im)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.normSq · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:39 · uses ComplexRatInterval , RatInterval
def div reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval

Given a numerator rectangle, a denominator rectangle, and evidence that the denominator's squared-modulus interval excludes zero, the guarded quotient rectangle is the product of the numerator rectangle and the denominator's conjugate, with both resulting coordinate intervals divided by the denominator's squared-modulus interval.

Definition (Lean source)
div I J hJ :
numerator :
mul I (conj J)
⟨numerator.re.div (normSq J) hJ, numerator.im.div (normSq J) hJ⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.div · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:43 · uses ComplexRatInterval , normSq , AwayFromZero
def tighten reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval

Given two rational complex rectangles, their coordinatewise tightening is formed by tightening the real coordinate intervals and tightening the imaginary coordinate intervals.

Definition (Lean source)
tighten I J :
⟨I.re.tighten J.re, I.im.tighten J.im⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.tighten · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:48 · uses ComplexRatInterval
theorem div_sound reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval

Guarded division of complex rational rectangles. For two complex rational rectangles enclosing complex values z and w respectively, provided the denominator rectangle's squared-modulus interval is bounded away from zero, the rectangle obtained by dividing the first rectangle by the second under that guard contains the quotient z / w .

Formal statement
z w :
ℂ
hJ :
hz :
I.Contains z
hw :
J.Contains w
(div I J hJ).Contains (z / w)
Proof (Lean source)
theorem div_sound {I J : ComplexRatInterval} {z w : ℂ} (hJ : (normSq J).AwayFromZero) (hz : I.Contains z) (hw : J.Contains w) : (div I J hJ).Contains (z / w) := by have hconj : (conj J).Contains (starRingEnd ℂ w) := by exact ⟨by simpa [conj] using hw.1, by simpa [conj] using RatInterval.neg_sound hw.2⟩ have hnum : (mul I (conj J)).Contains (z * starRingEnd ℂ w) := mul_sound hz hconj have hden := normSq_sound hw rw [Complex.sq_norm] at hden constructor · simpa [div, Complex.div_re, Complex.normSq_apply, div_eq_mul_inv, mul_add, add_mul, mul_comm, mul_left_comm, mul_assoc] using RatInterval.div_sound hJ hnum.1 hden · simpa [div, Complex.div_im, Complex.normSq_apply, div_eq_mul_inv, mul_add, sub_eq_add_neg, add_mul, mul_comm, mul_left_comm, mul_assoc] using RatInterval.div_sound hJ hnum.2 hden
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.div_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:104 · uses ComplexRatInterval , Contains , div , normSq , AwayFromZero
def normInterval reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval

Given a complex rational rectangle and a natural-number square-root fuel level, applying the rational square-root bounds at that fuel level to the rectangle's squared-modulus interval produces an executable enclosure of the complex norm.

Definition (Lean source)
fuel :
ℕ
normInterval I fuel :
RatInterval.sqrtInterval (normSq I) (normSq_lo_nonneg I) fuel
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.normInterval · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:483 · uses ComplexRatInterval , RatInterval
20 supporting declarations (lemmas, instances)
  • point_sound theorem — The rational point rectangle contains the corresponding complex number.
    x y :
    ℚ
    (point x y).Contains ((x : ℝ) + (y : ℝ) * I)
    Proof (Lean source)
    theorem point_sound (x y : ℚ) : (point x y).Contains ((x : ℝ) + (y : ℝ) * I) := by constructor · simpa [point] using RatInterval.point_sound x · simpa [point] using RatInterval.point_sound y
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.point_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:52
  • maxAbs_le_of_contains_width theorem — Semantic coordinate bounds and rectangle width give an executable maximum endpoint-magnitude bound.
    z :
    ℂ
    C w :
    ℚ
    hz :
    I.Contains z
    hzabs :
    max |z.re| |z.im| ≤ (C : ℝ)
    hw :
    width I ≤ w
    maxAbs I ≤ C + w
    Proof (Lean source)
    theorem maxAbs_le_of_contains_width {I : ComplexRatInterval} {z : ℂ} {C w : ℚ} (hz : I.Contains z) (hzabs : max |z.re| |z.im| ≤ (C : ℝ)) (hw : width I ≤ w) : maxAbs I ≤ C + w := by apply max_le · exact RatInterval.maxAbs_le_of_contains_width hz.1 ((le_max_left _ _).trans hzabs) ((le_max_left I.re.width I.im.width).trans hw) · exact RatInterval.maxAbs_le_of_contains_width hz.2 ((le_max_right _ _).trans hzabs) ((le_max_right I.re.width I.im.width).trans hw)
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.maxAbs_le_of_contains_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:59
  • neg_sound theorem — Complex rectangle negation encloses negated complex values.
    z :
    ℂ
    hz :
    I.Contains z
    (neg I).Contains (-z)
    Proof (Lean source)
    theorem neg_sound {I : ComplexRatInterval} {z : ℂ} (hz : I.Contains z) : (neg I).Contains (-z) := by exact ⟨by simpa [neg] using RatInterval.neg_sound hz.1, by simpa [neg] using RatInterval.neg_sound hz.2⟩
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.neg_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:73
  • sub_sound theorem — Complex rectangle subtraction encloses differences of enclosed values.
    z w :
    ℂ
    hz :
    I.Contains z
    hw :
    J.Contains w
    (sub I J).Contains (z - w)
    Proof (Lean source)
    theorem sub_sound {I J : ComplexRatInterval} {z w : ℂ} (hz : I.Contains z) (hw : J.Contains w) : (sub I J).Contains (z - w) := by simpa [sub, sub_eq_add_neg] using add_sound hz (neg_sound hw)
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.sub_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:79
  • mul_sound theorem — Complex rectangle multiplication encloses products of enclosed values.
    z w :
    ℂ
    hz :
    I.Contains z
    hw :
    J.Contains w
    (mul I J).Contains (z * w)
    Proof (Lean source)
    theorem mul_sound {I J : ComplexRatInterval} {z w : ℂ} (hz : I.Contains z) (hw : J.Contains w) : (mul I J).Contains (z * w) := by constructor · simpa [mul, Complex.mul_re] using RatInterval.sub_sound (RatInterval.mul_sound hz.1 hw.1) (RatInterval.mul_sound hz.2 hw.2) · simpa [mul, Complex.mul_im] using RatInterval.add_sound (RatInterval.mul_sound hz.1 hw.2) (RatInterval.mul_sound hz.2 hw.1)
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.mul_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:86
  • normSq_sound theorem — The squared-modulus interval contains the squared complex norm.
    z :
    ℂ
    hz :
    I.Contains z
    (normSq I).Contains (‖z‖ ^ 2)
    Proof (Lean source)
    theorem normSq_sound {I : ComplexRatInterval} {z : ℂ} (hz : I.Contains z) : (normSq I).Contains (‖z‖ ^ 2) := by rw [Complex.sq_norm] simpa [normSq, Complex.normSq_apply, pow_two] using RatInterval.add_sound (RatInterval.sq_sound hz.1) (RatInterval.sq_sound hz.2)
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.normSq_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:97
  • width_conj theorem — Conjugation preserves rectangle width.
    width (conj I) = width I
    Proof (Lean source)
    theorem width_conj (I : ComplexRatInterval) : width (conj I) = width I := by simp [width, conj, RatInterval.width_neg]
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.width_conj · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:127
  • maxAbs_conj theorem — Conjugation preserves the maximum coordinate endpoint magnitude.
    maxAbs (conj I) = maxAbs I
    Proof (Lean source)
    theorem maxAbs_conj (I : ComplexRatInterval) : maxAbs (conj I) = maxAbs I := by simp [maxAbs, conj, RatInterval.maxAbs_neg]
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.maxAbs_conj · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:131
  • tighten_sound_left theorem — Tightening two rectangles containing a common value preserves that value and produces a subrectangle of the first argument.
    z :
    ℂ
    hI :
    I.Contains z
    hJ :
    J.Contains z
    conclusion 1
    (tighten I J).Contains z
    conclusion 2
    (tighten I J).Subinterval I
    Proof (Lean source)
    theorem tighten_sound_left {I J : ComplexRatInterval} {z : ℂ} (hI : I.Contains z) (hJ : J.Contains z) : (tighten I J).Contains z ∧ (tighten I J).Subinterval I := by exact ⟨⟨RatInterval.tighten_sound hI.1 hJ.1, RatInterval.tighten_sound hI.2 hJ.2⟩, ⟨RatInterval.tighten_subinterval_left hI.1 hJ.1, RatInterval.tighten_subinterval_left hI.2 hJ.2⟩⟩
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.tighten_sound_left · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:135
  • width_add theorem — Complex rectangle addition has exactly the maximum of the two summed coordinate widths.
    width (I.add J) = max (I.re.width + J.re.width) (I.im.width + J.im.width)
    Proof (Lean source)
    theorem width_add (I J : ComplexRatInterval) : width (I.add J) = max (I.re.width + J.re.width) (I.im.width + J.im.width) := by simp [width, add, RatInterval.width_add]
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.width_add · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:145
  • mul_maxAbs theorem — Complex rectangle multiplication has twice the product of operand coordinate magnitude bounds as an executable magnitude bound.
    maxAbs (mul I J) ≤ 2 * maxAbs I * maxAbs J
    Proof (Lean source)
    theorem mul_maxAbs (I J : ComplexRatInterval) : maxAbs (mul I J) ≤ 2 * maxAbs I * maxAbs J := by have hIre : I.re.maxAbs ≤ maxAbs I := le_max_left _ _ have hIim : I.im.maxAbs ≤ maxAbs I := le_max_right _ _ have hJre : J.re.maxAbs ≤ maxAbs J := le_max_left _ _ have hJim : J.im.maxAbs ≤ maxAbs J := le_max_right _ _ have hI0 : 0 ≤ maxAbs I := (abs_nonneg I.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hJ0 : 0 ≤ maxAbs J := (abs_nonneg J.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hrr := RatInterval.maxAbs_mul I.re J.re have hii := RatInterval.maxAbs_mul I.im J.im have hri := RatInterval.maxAbs_mul I.re J.im have hir := RatInterval.maxAbs_mul I.im J.re have hrr' : (I.re.mul J.re).maxAbs ≤ maxAbs I * maxAbs J := hrr.trans (mul_le_mul hIre hJre ((abs_nonneg J.re.lo).trans (le_max_left _ _)) hI0) have hii' : (I.im.mul J.im).maxAbs ≤ maxAbs I * maxAbs J := hii.trans (mul_le_mul hIim hJim ((abs_nonneg J.im.lo).trans (le_max_left _ _)) hI0) have hri' : (I.re.mul J.im).maxAbs ≤ maxAbs I * maxAbs J := hri.trans (mul_le_mul hIre hJim ((abs_nonneg J.im.lo).trans (le_max_left _ _)) hI0) have hir' : (I.im.mul J.re).maxAbs ≤ maxAbs I * maxAbs J := hir.trans (mul_le_mul hIim hJre ((abs_nonneg J.re.lo).trans (le_max_left _ _)) hI0) apply max_le · exact (RatInterval.maxAbs_sub _ _).trans (by linarith) · exact (RatInterval.maxAbs_add _ _).trans (by linarith)
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.mul_maxAbs · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:152
  • rat_sq_width_le theorem — Squaring an interval has width at most twice its maximum endpoint magnitude times its width.
    (RatInterval.sq K).width ≤ 2 * K.maxAbs * K.width
    Proof (Lean source)
    theorem rat_sq_width_le (K : RatInterval) : (RatInterval.sq K).width ≤ 2 * K.maxAbs * K.width := by exact (RatInterval.width_mono (rat_sq_subinterval_mul K)).trans (by simpa [two_mul, add_mul] using interval_mul_width_le K K)
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.rat_sq_width_le · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:285
  • rat_sq_hi_le theorem — The upper endpoint of a squared interval is bounded by the square of its maximum endpoint magnitude.
    (RatInterval.sq K).hi ≤ K.maxAbs ^ 2
    Proof (Lean source)
    theorem rat_sq_hi_le (K : RatInterval) : (RatInterval.sq K).hi ≤ K.maxAbs ^ 2 := by have hlo : |K.lo| ≤ K.maxAbs := le_max_left _ _ have hhi : |K.hi| ≤ K.maxAbs := le_max_right _ _ have hM : 0 ≤ K.maxAbs := (abs_nonneg K.lo).trans hlo have hlo' : K.lo ^ 2 ≤ K.maxAbs ^ 2 := (sq_le_sq).2 (by simpa [abs_of_nonneg hM] using hlo) have hhi' : K.hi ^ 2 ≤ K.maxAbs ^ 2 := (sq_le_sq).2 (by simpa [abs_of_nonneg hM] using hhi) rw [RatInterval.sq] split_ifs · exact hlo' · exact hhi' · exact max_le hlo' hhi'
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.rat_sq_hi_le · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:291
  • rat_maxAbs_mono theorem — Refining an interval cannot increase its maximum endpoint magnitude.
    K L :
    hKL :
    K.Subinterval L
    K.maxAbs ≤ L.maxAbs
    Proof (Lean source)
    theorem rat_maxAbs_mono {K L : RatInterval} (hKL : K.Subinterval L) : K.maxAbs ≤ L.maxAbs := by apply max_le · exact abs_le_max_abs_abs hKL.1 (K.lo_le_hi.trans hKL.2) · exact abs_le_max_abs_abs (hKL.1.trans K.lo_le_hi) hKL.2
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.rat_maxAbs_mono · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:306
  • mul_width theorem — Each coordinate width after complex multiplication is bounded explicitly by the operand widths and endpoint magnitudes.
    width (mul I J) ≤ 2 * (maxAbs I * width J + maxAbs J * width I)
    Proof (Lean source)
    theorem mul_width (I J : ComplexRatInterval) : width (mul I J) ≤ 2 * (maxAbs I * width J + maxAbs J * width I) := by have hIreA : I.re.maxAbs ≤ maxAbs I := le_max_left _ _ have hIimA : I.im.maxAbs ≤ maxAbs I := le_max_right _ _ have hJreA : J.re.maxAbs ≤ maxAbs J := le_max_left _ _ have hJimA : J.im.maxAbs ≤ maxAbs J := le_max_right _ _ have hIrew : I.re.width ≤ width I := le_max_left _ _ have hIimw : I.im.width ≤ width I := le_max_right _ _ have hJrew : J.re.width ≤ width J := le_max_left _ _ have hJimw : J.im.width ≤ width J := le_max_right _ _ have hIA0 : 0 ≤ maxAbs I := (abs_nonneg I.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hJA0 : 0 ≤ maxAbs J := (abs_nonneg J.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hrr := interval_mul_width_le I.re J.re have hii := interval_mul_width_le I.im J.im have hri := interval_mul_width_le I.re J.im have hir := interval_mul_width_le I.im J.re have hrr' : (I.re.mul J.re).width ≤ maxAbs I * width J + maxAbs J * width I := by nlinarith [mul_le_mul hIreA hJrew (RatInterval.width_nonneg J.re) hIA0, mul_le_mul hJreA hIrew (RatInterval.width_nonneg I.re) hJA0] have hii' : (I.im.mul J.im).width ≤ maxAbs I * width J + maxAbs J * width I := by nlinarith [mul_le_mul hIimA hJimw (RatInterval.width_nonneg J.im) hIA0, mul_le_mul hJimA hIimw (RatInterval.width_nonneg I.im) hJA0] have hri' : (I.re.mul J.im).width ≤ maxAbs I * width J + maxAbs J * width I := by nlinarith [mul_le_mul hIreA hJimw (RatInterval.width_nonneg J.im) hIA0, mul_le_mul hJimA hIrew (RatInterval.width_nonneg I.re) hJA0] have hir' : (I.im.mul J.re).width ≤ maxAbs I * width J + maxAbs J * width I := by nlinarith [mul_le_mul hIimA hJrew (RatInterval.width_nonneg J.re) hIA0, mul_le_mul hJreA hIimw (RatInterval.width_nonneg I.im) hJA0] change max ((I.re.mul J.re).sub (I.im.mul J.im)).width ((I.re.mul J.im).add (I.im.mul J.re)).width ≤ 2 * (maxAbs I * width J + maxAbs J * width I) rw [RatInterval.width_sub, RatInterval.width_add] exact max_le (by linarith) (by linarith)
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.mul_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:313
  • normSq_width theorem — The squared-modulus interval width is controlled by rectangle magnitude and rectangle width.
    (normSq I).width ≤ 4 * maxAbs I * width I
    Proof (Lean source)
    theorem normSq_width (I : ComplexRatInterval) : (normSq I).width ≤ 4 * maxAbs I * width I := by have hre := rat_sq_width_le I.re have him := rat_sq_width_le I.im have hA0 : 0 ≤ maxAbs I := (abs_nonneg I.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hreprod : I.re.maxAbs * I.re.width ≤ maxAbs I * width I := mul_le_mul (le_max_left _ _) (le_max_left _ _) (RatInterval.width_nonneg I.re) hA0 have himprod : I.im.maxAbs * I.im.width ≤ maxAbs I * width I := mul_le_mul (le_max_right _ _) (le_max_right _ _) (RatInterval.width_nonneg I.im) hA0 rw [normSq, RatInterval.width_add] nlinarith
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.normSq_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:364
  • div_maxAbs theorem — If the squared-modulus denominator has positive lower bound δ, guarded division has maximum coordinate magnitude at most the numerator magnitude divided by δ.
    hJ :
    δ :
    ℚ
    hδ :
    0 < δ
    hsep :
    δ ≤ (normSq J).lo
    maxAbs (div I J hJ) ≤ maxAbs (mul I (conj J)) / δ
    Proof (Lean source)
    theorem div_maxAbs {I J : ComplexRatInterval} (hJ : (normSq J).AwayFromZero) {δ : ℚ} (hδ : 0 < δ) (hsep : δ ≤ (normSq J).lo) : maxAbs (div I J hJ) ≤ maxAbs (mul I (conj J)) / δ := by let N := mul I (conj J) let D := normSq J have hlo : 0 < D.lo := hδ.trans_le hsep have hhi : 0 < D.hi := hlo.trans_le D.lo_le_hi have hinvA : (D.inv hJ).maxAbs ≤ 1 / δ := by have hinvord : D.hi⁻¹ ≤ D.lo⁻¹ := (inv_le_inv₀ hhi hlo).2 D.lo_le_hi simp only [RatInterval.inv, RatInterval.maxAbs, abs_of_pos (inv_pos.mpr hhi), abs_of_pos (inv_pos.mpr hlo)] rw [max_eq_right hinvord] simpa [one_div] using (inv_le_inv₀ hlo hδ).2 hsep have hN0 : 0 ≤ maxAbs N := (abs_nonneg N.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hinv0 : 0 ≤ (D.inv hJ).maxAbs := (abs_nonneg (D.inv hJ).lo).trans (le_max_left _ _) have hre := RatInterval.maxAbs_mul N.re (D.inv hJ) have him := RatInterval.maxAbs_mul N.im (D.inv hJ) have hre' : (N.re.mul (D.inv hJ)).maxAbs ≤ maxAbs N / δ := by calc _ ≤ N.re.maxAbs * (D.inv hJ).maxAbs := hre _ ≤ maxAbs N * (1 / δ) := mul_le_mul (le_max_left _ _) hinvA hinv0 hN0 _ = maxAbs N / δ := by ring have him' : (N.im.mul (D.inv hJ)).maxAbs ≤ maxAbs N / δ := by calc _ ≤ N.im.maxAbs * (D.inv hJ).maxAbs := him _ ≤ maxAbs N * (1 / δ) := mul_le_mul (le_max_right _ _) hinvA hinv0 hN0 _ = maxAbs N / δ := by ring change max (N.re.div D hJ).maxAbs (N.im.div D hJ).maxAbs ≤ maxAbs N / δ change max (N.re.mul (D.inv hJ)).maxAbs (N.im.mul (D.inv hJ)).maxAbs ≤ maxAbs N / δ exact max_le hre' him'
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.div_maxAbs · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:381
  • div_width theorem — If the squared-modulus denominator has certified lower bound δ, guarded division propagates widths with the usual inverse-square factor.
    hJ :
    δ :
    ℚ
    hδ :
    0 < δ
    hsep :
    δ ≤ (normSq J).lo
    width (div I J hJ)
    ≤ maxAbs (mul I (conj J)) * (normSq J).width / (δ ^ 2) + width (mul I (conj J)) / δ
    Proof (Lean source)
    theorem div_width {I J : ComplexRatInterval} (hJ : (normSq J).AwayFromZero) {δ : ℚ} (hδ : 0 < δ) (hsep : δ ≤ (normSq J).lo) : width (div I J hJ) ≤ maxAbs (mul I (conj J)) * (normSq J).width / (δ ^ 2) + width (mul I (conj J)) / δ := by let N := mul I (conj J) let D := normSq J have hlo : 0 < D.lo := hδ.trans_le hsep have hhi : 0 < D.hi := hlo.trans_le D.lo_le_hi have hprod : δ ^ 2 ≤ D.lo * D.hi := by have := mul_le_mul hsep (hsep.trans D.lo_le_hi) hδ.le hlo.le simpa [pow_two] using this have hinvw : (D.inv hJ).width ≤ D.width / δ ^ 2 := by have heq : (D.inv hJ).width = D.width / (D.lo * D.hi) := by simp only [RatInterval.inv, RatInterval.width] field_simp rw [heq] exact div_le_div_of_nonneg_left (RatInterval.width_nonneg D) (sq_pos_of_pos hδ) hprod have hinvA : (D.inv hJ).maxAbs ≤ 1 / δ := by have hinvord : D.hi⁻¹ ≤ D.lo⁻¹ := (inv_le_inv₀ hhi hlo).2 D.lo_le_hi simp only [RatInterval.inv, RatInterval.maxAbs, abs_of_pos (inv_pos.mpr hhi), abs_of_pos (inv_pos.mpr hlo)] rw [max_eq_right hinvord] simpa [one_div] using (inv_le_inv₀ hlo hδ).2 hsep have hNA : 0 ≤ maxAbs N := (abs_nonneg N.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hNW : 0 ≤ width N := (RatInterval.width_nonneg N.re).trans (le_max_left _ _) have hInvA0 : 0 ≤ (D.inv hJ).maxAbs := (abs_nonneg (D.inv hJ).lo).trans (le_max_left _ _) have hInvW0 : 0 ≤ (D.inv hJ).width := RatInterval.width_nonneg _ have hre := interval_mul_width_le N.re (D.inv hJ) have him := interval_mul_width_le N.im (D.inv hJ) have hreA : N.re.maxAbs ≤ maxAbs N := le_max_left _ _ have himA : N.im.maxAbs ≤ maxAbs N := le_max_right _ _ have hrew : N.re.width ≤ width N := le_max_left _ _ have himw : N.im.width ≤ width N := le_max_right _ _ have hre' : (N.re.mul (D.inv hJ)).width ≤ maxAbs N * (D.width / δ ^ 2) + (1 / δ) * width N := by nlinarith [mul_le_mul hreA hinvw hInvW0 hNA, mul_le_mul hinvA hrew (RatInterval.width_nonneg N.re) (by positivity : (0 : ℚ) ≤ 1 / δ)] have him' : (N.im.mul (D.inv hJ)).width ≤ maxAbs N * (D.width / δ ^ 2) + (1 / δ) * width N := by nlinarith [mul_le_mul himA hinvw hInvW0 hNA, mul_le_mul hinvA himw (RatInterval.width_nonneg N.im) (by positivity : (0 : ℚ) ≤ 1 / δ)] change max (N.re.div D hJ).width (N.im.div D hJ).width ≤ maxAbs N * D.width / δ ^ 2 + width N / δ change max (N.re.mul (D.inv hJ)).width (N.im.mul (D.inv hJ)).width ≤ _ apply max_le · exact hre'.trans_eq (by ring) · exact him'.trans_eq (by ring)
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.div_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:420
  • normSq_lo_nonneg theorem — For a rational complex rectangle, the lower endpoint of its squared-modulus interval is nonnegative.
    0 ≤ (normSq I).lo
    Proof (Lean source)
    theorem normSq_lo_nonneg (I : ComplexRatInterval) : 0 ≤ (normSq I).lo := by have hsquare (K : RatInterval) : 0 ≤ (RatInterval.sq K).lo := by unfold RatInterval.sq split_ifs <;> positivity simp only [normSq, RatInterval.add] exact add_nonneg (hsquare I.re) (hsquare I.im)
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.normSq_lo_nonneg · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:474
  • normInterval_sound theorem — The executable modulus interval contains the norm of every enclosed complex value.
    z :
    ℂ
    hz :
    I.Contains z
    fuel :
    ℕ
    (normInterval I fuel).Contains ‖z‖
    Proof (Lean source)
    theorem normInterval_sound {I : ComplexRatInterval} {z : ℂ} (hz : I.Contains z) (fuel : ℕ) : (normInterval I fuel).Contains ‖z‖ := by have hs := RatInterval.sqrtInterval_sound (normSq_lo_nonneg I) (normSq_sound hz) fuel simpa [normInterval, Real.sqrt_sq (norm_nonneg z)] using hs
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ComplexRatInterval.normInterval_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Rectangles.lean:489
Interval­Exp 3 core · 2 supporting This module evaluates the real exponential on rational intervals using midpoint enclosures and a magnitude-dependent Lipschitz allowance. ★ expInterval_width

Certified exponential interval evaluation

This module evaluates the real exponential on rational intervals using midpoint enclosures and a magnitude-dependent Lipschitz allowance.

def expIntervalRaw reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational input interval and a natural-number fuel level, the raw exponential image interval is the input midpoint, the scalar exponential interval at that midpoint, the upper endpoint of the scalar exponential interval at the input's maximum absolute endpoint magnitude, and the midpoint exponential interval expanded by that upper bound times the input radius.

Definition (Lean source)
fuel :
ℕ
expIntervalRaw I fuel :
center :
ecenter :
Transcendental.expScalar center fuel
upper :
(Transcendental.expScalar I.maxAbs fuel).hi
ecenter.expand (upper * intervalRadius I) (by have hs := Transcendental.expScalar_sound I.maxAbs fuel have hu : 0 ≤ upper := by dsimp only [upper] exact_mod_cast (Real.exp_pos (I.maxAbs : ℝ)).le.trans hs.2 exact mul_nonneg hu (div_nonneg (RatInterval.width_nonneg I) (by norm_num)))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.expIntervalRaw · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/IntervalExp.lean:18 · uses RatInterval
def expInterval reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

For a rational input interval and a natural-number fuel level, the exponential image interval at that level is the raw exponential image interval at level zero, and at every successor level is the intersection of the preceding exponential image interval and the new raw exponential image interval.

Definition (Lean source)
expInterval I :
ℕ → RatInterval
clause 1
| 0 => expIntervalRaw I 0
clause 2
| fuel + 1 => (expInterval I fuel).tighten (expIntervalRaw I (fuel + 1))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.expInterval · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/IntervalExp.lean:36 · uses RatInterval
theorem expInterval_width reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

For a rational interval I and a Taylor fuel/iteration count, the width of the certified interval exponential is bounded by the scalar Taylor truncation error at the interval's midpoint plus twice the interval's radius amplified by a certified bound on the exponential's magnitude over the interval.

Formal statement
fuel :
ℕ
(expInterval I fuel).width
≤ (Transcendental.expScalar (intervalMid I) fuel).width
+ 2 * (Transcendental.expScalar I.maxAbs fuel).hi * intervalRadius I
Proof (Lean source)
theorem expInterval_width (I : RatInterval) (fuel : ℕ) : (expInterval I fuel).width ≤ (Transcendental.expScalar (intervalMid I) fuel).width + 2 * (Transcendental.expScalar I.maxAbs fuel).hi * intervalRadius I := by have hraw : (expIntervalRaw I fuel).width = (Transcendental.expScalar (intervalMid I) fuel).width + 2 * (Transcendental.expScalar I.maxAbs fuel).hi * intervalRadius I := by rw [expIntervalRaw, RatInterval.width_expand] ring cases fuel with | zero => exact hraw.le | succ fuel => have hmid : I.Contains (intervalMid I : ℝ) := by constructor <;> exact_mod_cast (by dsimp [intervalMid] linarith [I.lo_le_hi]) exact (RatInterval.width_mono (Transcendental.tighten_subinterval_right (expInterval_sound hmid fuel) (expIntervalRaw_sound hmid (fuel + 1)))).trans_eq hraw
2 supporting declarations (lemmas, instances)
  • expInterval_sound theorem — The magnitude-dependent exponential interval contains the exponential of every enclosed real input.
    x :
    ℝ
    hx :
    I.Contains x
    fuel :
    ℕ
    (expInterval I fuel).Contains (exp x)
    Proof (Lean source)
    theorem expInterval_sound {I : RatInterval} {x : ℝ} (hx : I.Contains x) (fuel : ℕ) : (expInterval I fuel).Contains (exp x) := by induction fuel with | zero => exact expIntervalRaw_sound hx 0 | succ fuel ih => exact RatInterval.tighten_sound ih (expIntervalRaw_sound hx (fuel + 1))
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.expInterval_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/IntervalExp.lean:91
  • expInterval_nested theorem — Adjacent midpoint exponential outputs are nested by finite intersection.
    fuel :
    ℕ
    (expInterval I (fuel + 1)).Subinterval (expInterval I fuel)
    Proof (Lean source)
    theorem expInterval_nested (I : RatInterval) (fuel : ℕ) : (expInterval I (fuel + 1)).Subinterval (expInterval I fuel) := by have hmid : I.Contains (intervalMid I : ℝ) := by constructor <;> exact_mod_cast (by dsimp [intervalMid] linarith [I.lo_le_hi]) exact RatInterval.tighten_subinterval_left (expInterval_sound hmid fuel) (expIntervalRaw_sound hmid (fuel + 1))
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.expInterval_nested · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/IntervalExp.lean:99
Names 8 core · 2 supporting This module represents complex values by nested rational rectangles equipped with supplied refinement rules and derives certified modulus names from them. ★ norm_width_at_precision

Certified complex names

This module represents complex values by nested rational rectangles equipped with supplied refinement rules and derives certified modulus names from them.

structure CertifiedComplex reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

A certified complex name represents a complex number by a sequence of rational rectangle enclosures indexed by fuel that is nested — each successive enclosure a subrectangle of the one before — and always contains the represented value, together with a supplied rule selecting, for any requested positive rational error, a fuel level whose enclosure meets that coordinate-width tolerance.

Definition (Lean source)
The unique complex value denoted by the nested name.
value :
ℂ
The rational rectangle returned at each fuel.
approx :
Adjacent fuel values refine by coordinatewise finite intersection.
nested :
∀ n, (approx (n + 1)).Subinterval (approx n)
Every fuel-indexed rectangle contains the denoted value.
contains :
∀ n, (approx n).Contains value
The fuel selected by the supplied rule for a requested positive rational width.
modulus :
PosRat → ℕ
The selected rectangle meets the requested coordinate-width tolerance.
width_modulus :
∀ ε, ComplexRatInterval.width (approx (modulus ε)) ≤ ε.1
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Names.lean:17
def refine reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex

For a certified complex name and a requested positive rational tolerance, the refined rational rectangle is the rectangle selected by that name's tolerance-to-fuel rule.

Definition (Lean source)
refine z ε :
z.approx (z.modulus ε)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex.refine · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Names.lean:52 · uses ComplexRatInterval , CertifiedComplex , PosRat
def ofRatPair reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex

For a rational real coordinate and a rational imaginary coordinate, the certified complex name of their complex point has that point as its exact value and the corresponding singleton rectangle at every fuel level.

Definition (Lean source)
x y :
ℚ
ofRatPair x y :
clause 1
value := (x : ℝ) + (y : ℝ) * I
clause 2
approx := fun _ => ComplexRatInterval.point x y
clause 3
nested := by intro n exact ⟨RatInterval.subinterval_refl _, RatInterval.subinterval_refl _⟩
clause 4
contains := by intro n; exact ComplexRatInterval.point_sound x y
clause 5
modulus := fun _ => 0
clause 6
width_modulus := by intro ε simpa [ComplexRatInterval.width, ComplexRatInterval.point, RatInterval.width, RatInterval.point] using ε.2.le
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex.ofRatPair · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Names.lean:60 · uses CertifiedComplex
def add reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex

For two certified complex names, their certified sum denotes the sum of their exact complex values and uses the coordinatewise sum of their equal-fuel rectangles.

Definition (Lean source)
add z w :
clause 1
value := z.value + w.value
clause 2
approx := fun n => (z.approx n).add (w.approx n)
clause 3
nested := by intro n exact ⟨RatInterval.add_mono (z.nested n).1 (w.nested n).1, RatInterval.add_mono (z.nested n).2 (w.nested n).2⟩
clause 4
contains := by intro n; exact ComplexRatInterval.add_sound (z.contains n) (w.contains n)
clause 5
modulus := fun ε
=> max (z.modulus ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩) (w.modulus ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩)
clause 6
width_modulus := by intro ε let δ : PosRat := ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩ let k := max (z.modulus δ) (w.modulus δ) have hz : ComplexRatInterval.width (z.approx k)
≤ δ.1 := (rectangle_width_mono (approx_mono z (le_max_left _ _))).trans (z.width_modulus δ) have hw : ComplexRatInterval.width (w.approx k) ≤ δ.1 := (rectangle_width_mono (approx_mono w (le_max_right _ _))).trans (w.width_modulus δ) have hzre : (z.approx k).re.width ≤ δ.1 := (le_max_left _ _).trans hz have hzim : (z.approx k).im.width ≤ δ.1 := (le_max_right _ _).trans hz have hwre : (w.approx k).re.width ≤ δ.1 := (le_max_left _ _).trans hw have hwim : (w.approx k).im.width ≤ δ.1 := (le_max_right _ _).trans hw rw [ComplexRatInterval.width_add] dsimp [k, δ] at hzre hzim hwre hwim ⊢ exact max_le (by linarith) (by linarith)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex.add · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Names.lean:74 · uses CertifiedComplex
def normApprox reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex

For a certified complex name, the modulus approximation at each nonnegative fuel level is computed recursively: at zero it is the initial rectangle's modulus enclosure, and at each successor it is the intersection of the preceding approximation with the new modulus enclosure.

Definition (Lean source)
normApprox z :
ℕ → RatInterval
clause 1
| 0 => ComplexRatInterval.normInterval (z.approx 0) 0
clause 2
| fuel + 1
=> (normApprox z fuel).tighten (ComplexRatInterval.normInterval (z.approx (fuel + 1)) (fuel + 1))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex.normApprox · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Names.lean:106 · uses CertifiedComplex , RatInterval
def normPrecision reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex

For a certified complex name and a requested positive rational tolerance, the modulus precision is the maximum of a fuel level that refines the input rectangle to a tolerance determined by its initial magnitude bound and an explicit Newton-iteration fuel bound.

Definition (Lean source)
normPrecision z ε :
ℕ
M :
ComplexRatInterval.maxAbs (z.approx 0)
δ :
⟨ε.1 ^ 2 / (16 * (M + 1)), by have hM : 0
≤ M := by exact le_max_of_le_left ((abs_nonneg _).trans (le_max_left _ _)) exact div_pos (sq_pos_of_pos ε.2) (by nlinarith)⟩ (: PosRat)
max (z.modulus δ) (64 * (ε.1.den + 1) * (M.num.natAbs + 2) ^ 2)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex.normPrecision · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Names.lean:112 · uses CertifiedComplex , PosRat
theorem norm_width_at_precision reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex

For a certified complex input and a requested positive rational tolerance ε, evaluating the certified-modulus approximation at the precision level selected for that tolerance yields an output enclosure whose width is no larger than ε.

Formal statement
(normApprox z (normPrecision z ε)).width ≤ ε.1
Proof (Lean source)
theorem norm_width_at_precision (z : CertifiedComplex) (ε : PosRat) : (normApprox z (normPrecision z ε)).width ≤ ε.1 := by let M := ComplexRatInterval.maxAbs (z.approx 0) have hM : 0 ≤ M := by exact le_max_of_le_left ((abs_nonneg _).trans (le_max_left _ _)) let δ : PosRat := ⟨ε.1 ^ 2 / (16 * (M + 1)), by exact div_pos (sq_pos_of_pos ε.2) (by nlinarith)⟩ let N := 64 * (ε.1.den + 1) * (M.num.natAbs + 2) ^ 2 let k := max (z.modulus δ) N change (normApprox z k).width ≤ ε.1 have hkmod : z.modulus δ ≤ k := le_max_left _ _ have hkN : N ≤ k := le_max_right _ _ let K := z.approx k let K0 := z.approx 0 let D := ComplexRatInterval.normSq K have hKK0 : K.Subinterval K0 := approx_mono z (zero_le k) have hKw : ComplexRatInterval.width K ≤ δ.1 := (rectangle_width_mono (approx_mono z hkmod)).trans (z.width_modulus δ) have hreA : K.re.maxAbs ≤ M := (ComplexRatInterval.rat_maxAbs_mono hKK0.1).trans (le_max_left _ _) have himA : K.im.maxAbs ≤ M := (ComplexRatInterval.rat_maxAbs_mono hKK0.2).trans (le_max_right _ _) have hrew : K.re.width ≤ δ.1 := (le_max_left _ _).trans hKw have himw : K.im.width ≤ δ.1 := (le_max_right _ _).trans hKw have hDw : D.width ≤ 4 * M * δ.1 := by rw [show D.width = (RatInterval.sq K.re).width + (RatInterval.sq K.im).width by simp [D, ComplexRatInterval.normSq, RatInterval.width_add]] have hre := ComplexRatInterval.rat_sq_width_le K.re have him := ComplexRatInterval.rat_sq_width_le K.im have hre0 : 0 ≤ K.re.maxAbs := (abs_nonneg K.re.lo).trans (le_max_left _ _) have him0 : 0 ≤ K.im.maxAbs := (abs_nonneg K.im.lo).trans (le_max_left _ _) have hδ0 : 0 ≤ δ.1 := δ.2.le nlinarith [mul_le_mul hreA hrew (RatInterval.width_nonneg K.re) hM, mul_le_mul himA himw (RatInterval.width_nonneg K.im) hM] have hDwε : D.width ≤ ε.1 ^ 2 / 4 := by refine hDw.trans ?_ dsimp [δ] have hMp : 0 < M + 1 := by linarith rw [show 4 * M * (ε.1 ^ 2 / (16 * (M + 1))) = (M * ε.1 ^ 2) / (4 * (M + 1)) by field_simp [ne_of_gt hMp] ring] apply (div_le_iff₀ (by positivity : (0 : ℚ) < 4 * (M + 1))).2 nlinarith [sq_nonneg ε.1] have hDhi : D.hi ≤ 2 * M ^ 2 := by change (RatInterval.sq K.re).hi + (RatInterval.sq K.im).hi ≤ 2 * M ^ 2 have hrehi := ComplexRatInterval.rat_sq_hi_le K.re have himhi := ComplexRatInterval.rat_sq_hi_le K.im have hre0 : 0 ≤ K.re.maxAbs := (abs_nonneg K.re.lo).trans (le_max_left _ _) have him0 : 0 ≤ K.im.maxAbs := (abs_nonneg K.im.lo).trans (le_max_left _ _) nlinarith [mul_self_le_mul_self hre0 hreA, mul_self_le_mul_self him0 himA] have hMle : M ≤ (M.num.natAbs : ℕ) := by have hnum0 : 0 ≤ M.num := Rat.num_nonneg.mpr hM calc M = (M.num : ℚ) / (M.den : ℕ) := (Rat.num_div_den M).symm _ ≤ (M.num : ℚ) := div_le_self (by exact_mod_cast hnum0) (by exact_mod_cast Rat.den_pos M) _ = (M.num.natAbs : ℕ) := by have hi : (M.num.natAbs : ℤ) = M.num := Int.natAbs_of_nonneg hnum0 exact (congrArg (fun x : ℤ => (x : ℚ)) hi).symm have hεden : (1 : ℚ) ≤ ε.1 * (ε.1.den : ℕ) := by have hnumpos : 0 < ε.1.num := (Rat.num_pos).2 ε.2 have hrepr := Rat.num_div_den ε.1 have hdenpos : (0 : ℚ) < ε.1.den := by exact_mod_cast Rat.den_pos ε.1 have heq : (ε.1.num : ℚ) = ε.1 * (ε.1.den : ℕ) := (div_eq_iff hdenpos.ne').mp hrepr rw [← heq] exact_mod_cast hnumpos have hrate : (D.hi + 1) / (k + 1) ≤ ε.1 / 4 := by have hp0 : (0 : ℚ) ≤ (M.num.natAbs + 2 : ℕ) := by positivity have hDcoarse : 4 * (D.hi + 1) ≤ 8 * (M.num.natAbs + 2 : ℕ) ^ 2 := by have hp : (M : ℚ) ≤ (M.num.natAbs : ℕ) := hMle have hMsq := mul_self_le_mul_self hM hp have hMsq' : M ^ 2 ≤ (M.num.natAbs : ℚ) ^ 2 := by simpa [pow_two] using hMsq calc 4 * (D.hi + 1) ≤ 4 * (2 * M ^ 2 + 1) := by nlinarith [hDhi] _ ≤ 8 * (M.num.natAbs + 2 : ℕ) ^ 2 := by push_cast nlinarith [hMsq', sq_nonneg (M.num.natAbs : ℚ)] have hkcast : (N : ℚ) ≤ k + 1 := by exact_mod_cast hkN.trans (le_add_right k 1) have hεfac : 1 ≤ ε.1 * (ε.1.den + 1 : ℕ) := by exact hεden.trans (mul_le_mul_of_nonneg_left (by norm_num) ε.2.le) have hNform : (N : ℚ) = 64 * (ε.1.den + 1 : ℕ) * (M.num.natAbs + 2 : ℕ) ^ 2 := by simp [N] have hbig : 8 * (M.num.natAbs + 2 : ℕ) ^ 2 ≤ ε.1 * (k + 1) := by have hP : (0 : ℚ) ≤ (M.num.natAbs + 2 : ℕ) ^ 2 := by positivity have h64 : 64 * (M.num.natAbs + 2 : ℕ) ^ 2 ≤ ε.1 * (N : ℚ) := by rw [hNform] nlinarith [mul_le_mul_of_nonneg_right hεfac hP] nlinarith [mul_le_mul_of_nonneg_left hkcast ε.2.le] apply (div_le_iff₀ (by positivity : (0 : ℚ) < k + 1)).2 nlinarith have hsqrtspan : (sqrt (D.hi : ℝ) - sqrt (D.lo : ℝ)) ≤ (ε.1 : ℝ) / 2 := by have hlo0 : (0 : ℝ) ≤ D.lo := by exact_mod_cast ComplexRatInterval.normSq_lo_nonneg K have hDcast : (D.lo : ℝ) ≤ D.hi := by exact_mod_cast D.lo_le_hi have hhi0 : (0 : ℝ) ≤ D.hi := hlo0.trans hDcast have hslo := Real.sq_sqrt hlo0 have hshi := Real.sq_sqrt hhi0 have hsord := Real.sqrt_le_sqrt hDcast have hw : ((D.hi : ℝ) - D.lo) ≤ (ε.1 : ℝ) ^ 2 / 4 := by exact_mod_cast hDwε have hεr : (0 : ℝ) < ε.1 := by exact_mod_cast ε.2 have hspan0 : 0 ≤ sqrt (D.hi : ℝ) - sqrt (D.lo : ℝ) := sub_nonneg.mpr hsord apply (sq_le_sq₀ hspan0 (by positivity : (0 : ℝ) ≤ (ε.1 : ℝ) / 2)).mp calc (sqrt (D.hi : ℝ) - sqrt (D.lo : ℝ)) ^ 2 ≤ (D.hi : ℝ) - D.lo := by nlinarith [mul_nonneg (Real.sqrt_nonneg (D.lo : ℝ)) (Real.sqrt_nonneg (D.hi : ℝ))] _ ≤ (ε.1 : ℝ) ^ 2 / 4 := hw _ = ((ε.1 : ℝ) / 2) ^ 2 := by ring have hcurrent : (ComplexRatInterval.normInterval K k).width ≤ ε.1 := by rw [ComplexRatInterval.normInterval, RatInterval.sqrtInterval_width] have hblo := RatInterval.sqrt_iterates_sound D.lo (ComplexRatInterval.normSq_lo_nonneg K) k have hbhi := RatInterval.sqrt_iterates_sound D.hi ((ComplexRatInterval.normSq_lo_nonneg K).trans D.lo_le_hi) k have hrlo := RatInterval.sqrt_gap_rate D.lo (ComplexRatInterval.normSq_lo_nonneg K) k have hrhi := RatInterval.sqrt_gap_rate D.hi ((ComplexRatInterval.normSq_lo_nonneg K).trans D.lo_le_hi) k have hrate_lo : (D.lo + 1) / (k + 1) ≤ ε.1 / 4 := (div_le_div_of_nonneg_right (by linarith [D.lo_le_hi]) (by positivity)).trans hrate exact_mod_cast (show (RatInterval.sqrtUpper D.hi k : ℝ) - RatInterval.sqrtLower D.lo k ≤ (ε.1 : ℝ) by have hrlo' : ((RatInterval.sqrtUpper D.lo k - RatInterval.sqrtLower D.lo k : ℚ) : ℝ) ≤ ε.1 / 4 := by exact_mod_cast hrlo.trans hrate_lo have hrhi' : ((RatInterval.sqrtUpper D.hi k - RatInterval.sqrtLower D.hi k : ℚ) : ℝ) ≤ ε.1 / 4 := by exact_mod_cast hrhi.trans hrate norm_num at hrlo' hrhi' have huhi : (RatInterval.sqrtUpper D.hi k : ℝ) - sqrt D.hi ≤ ε.1 / 4 := by linarith [hrhi', hbhi.1] have hllo : sqrt D.lo - (RatInterval.sqrtLower D.lo k : ℝ) ≤ ε.1 / 4 := by linarith [hrlo', hblo.2] linarith [huhi, hllo, hsqrtspan]) exact (RatInterval.width_mono (normApprox_subinterval_current z k)).trans hcurrent
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex.norm_width_at_precision · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Names.lean:167 · uses CertifiedComplex , normApprox , normPrecision , PosRat , width
def norm reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex

For a certified complex name, its certified modulus name denotes the absolute value of its exact complex value and uses the recursive modulus enclosures with the stated precision rule.

Definition (Lean source)
norm z :
clause 1
value := ‖z.value‖
clause 2
approx := normApprox z
clause 3
nested := fun fuel => (normApprox_spec z fuel).2
clause 4
contains := by intro fuel; exact (normApprox_spec z fuel).1
clause 5
clause 6
width_modulus := norm_width_at_precision z
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex.norm · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Names.lean:310 · uses CertifiedReal , CertifiedComplex
2 supporting declarations (lemmas, instances)
  • refine_spec theorem — Refinement by the supplied rule preserves containment and meets its requested width.
    conclusion 1
    (z.refine ε).Contains z.value
    conclusion 2
    ComplexRatInterval.width (z.refine ε) ≤ ε.1
    Proof (Lean source)
    theorem refine_spec (z : CertifiedComplex) (ε : PosRat) : (z.refine ε).Contains z.value ∧ ComplexRatInterval.width (z.refine ε) ≤ ε.1 := by exact ⟨z.contains _, z.width_modulus ε⟩
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex.refine_spec · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Names.lean:55
  • normApprox_spec theorem — Recursive modulus approximations contain the norm and are adjacent-fuel nested.
    fuel :
    ℕ
    conclusion 1
    (normApprox z fuel).Contains ‖z.value‖
    conclusion 2
    (normApprox z (fuel + 1)).Subinterval (normApprox z fuel)
    Proof (Lean source)
    theorem normApprox_spec (z : CertifiedComplex) (fuel : ℕ) : (normApprox z fuel).Contains ‖z.value‖ ∧ (normApprox z (fuel + 1)).Subinterval (normApprox z fuel) := by induction fuel with | zero => have h0 := ComplexRatInterval.normInterval_sound (z.contains 0) 0 have h1 := ComplexRatInterval.normInterval_sound (z.contains 1) 1 exact ⟨h0, RatInterval.tighten_subinterval_left h0 h1⟩ | succ fuel ih => have hnew := ComplexRatInterval.normInterval_sound (z.contains (fuel + 1)) (fuel + 1) have hcur : (normApprox z (fuel + 1)).Contains ‖z.value‖ := by rw [normApprox] exact RatInterval.tighten_sound ih.1 hnew have hnext := ComplexRatInterval.normInterval_sound (z.contains (fuel + 2)) (fuel + 2) constructor · exact hcur · rw [show fuel + 1 + 1 = fuel + 2 by omega, normApprox] exact RatInterval.tighten_subinterval_left hcur hnext
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplex.normApprox_spec · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Names.lean:122
Complex­Exp 13 core · 5 supporting This module composes the rational real exponential, sine, and cosine extensions into complex exponential rectangles. ★ complexExp_width_at_precision

Certified complex exponential semantics

This module composes the rational real exponential, sine, and cosine extensions into complex exponential rectangles. For a certified complex input, each name stage first requests a magnitude-sensitive input width, computes Taylor fuel from the rational rectangle actually returned, and recursively intersects the result with all preceding stages. This avoids both false fixed-input convergence claims and false nesting claims between unrelated midpoint extensions.

def complexExpRaw reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a rational complex input rectangle and a natural-number fuel level, the raw complex-exponential rectangle multiplies the real-exponential interval of the real coordinate by the cosine and sine intervals of the imaginary coordinate to form its real and imaginary coordinates.

Definition (Lean source)
fuel :
ℕ
complexExpRaw I fuel :
⟨(expInterval I.re fuel).mul (cosInterval I.im fuel), (expInterval I.re fuel).mul (sinInterval I.im fuel)⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExpRaw · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:24 · uses ComplexRatInterval
def complexExp reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

For a rational complex input rectangle and a natural-number fuel level, the complex-exponential rectangle at that level is the raw complex-exponential rectangle at level zero, and at every successor level is the intersection of the preceding rectangle and the new raw complex-exponential rectangle.

Definition (Lean source)
complexExp I :
clause 1
| 0 => complexExpRaw I 0
clause 2
| fuel + 1 => ComplexRatInterval.tighten (complexExp I fuel) (complexExpRaw I (fuel + 1))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExp · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:29 · uses ComplexRatInterval
def complexExpMagnitude reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a certified complex number, its complex-exponential magnitude scale is two plus the absolute upper endpoint of the level-zero scalar-exponential interval evaluated at the maximum absolute real-coordinate endpoint of its level-zero enclosure.

Definition (Lean source)
complexExpMagnitude z :
ℚ
|(Transcendental.expScalar (z.approx 0).re.maxAbs 0).hi| + 2
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExpMagnitude · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:123 · uses CertifiedComplex
def complexExpStageTolerance reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a natural-number stage index, the complex-exponential stage tolerance is the positive rational number 1/(n+1)1/(n+1).

Definition (Lean source)
n :
ℕ
complexExpStageTolerance n :
⟨1 / (n + 1 : ℚ), by positivity⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExpStageTolerance · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:128 · uses PosRat
def complexExpInnerTolerance reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a certified complex number and a natural-number stage index, the inner complex-exponential tolerance is the stage tolerance divided by sixteen times the complex-exponential magnitude scale.

Definition (Lean source)
n :
ℕ
complexExpInnerTolerance z n :
⟨(complexExpStageTolerance n).1 / (16 * complexExpMagnitude z), by apply div_pos (complexExpStageTolerance n).2 dsimp [complexExpMagnitude] positivity⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExpInnerTolerance · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:132 · uses CertifiedComplex , PosRat
def complexExpInputTolerance reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a certified complex number and a natural-number stage index, the complex-exponential input tolerance is the inner tolerance divided by four times the complex-exponential magnitude scale.

Definition (Lean source)
n :
ℕ
complexExpInputTolerance z n :
⟨(complexExpInnerTolerance z n).1 / (4 * complexExpMagnitude z), by apply div_pos (complexExpInnerTolerance z n).2 dsimp [complexExpMagnitude] positivity⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExpInputTolerance · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:139 · uses CertifiedComplex , PosRat
def complexExpStageInput reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a certified complex number and a natural-number stage index, the complex-exponential stage input rectangle is the input's approximation at the precision required by that stage's input tolerance.

Definition (Lean source)
n :
ℕ
complexExpStageInput z n :
z.approx (z.modulus (complexExpInputTolerance z n))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExpStageInput · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:146 · uses ComplexRatInterval , CertifiedComplex
def complexExpStageFuel reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a certified complex number and a natural-number stage index, the complex-exponential stage fuel is the stage input rectangle, the inner tolerance divided by eight, the resulting trigonometric Taylor-fuel bound, and the larger of that bound and the two scalar-exponential precision bounds.

Definition (Lean source)
n :
ℕ
complexExpStageFuel z n :
ℕ
α :
⟨(complexExpInnerTolerance z n).1 / 8, div_pos (complexExpInnerTolerance z n).2 (by norm_num)⟩ (: PosRat)
trigFuel :
32 * (α.1.den + 1) * ((intervalMid I.im).num.natAbs + 2) ^ 2
max trigFuel (max (Transcendental.expPrecision (intervalMid I.re) α) (Transcendental.expPrecision I.re.maxAbs α))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExpStageFuel · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:150 · uses CertifiedComplex
def complexExpStage reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a certified complex number and a natural-number stage index, the complex-exponential stage rectangle evaluates the complex exponential on that stage's input rectangle using that stage's fuel.

Definition (Lean source)
n :
ℕ
complexExpStage z n :
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExpStage · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:165 · uses ComplexRatInterval , CertifiedComplex
def complexExpNameApprox reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

For a certified complex number and a natural-number stage index, the complex-exponential name approximation at that level is the stage-zero rectangle, and at every successor level is the intersection of the preceding name approximation and the new stage rectangle.

Definition (Lean source)
complexExpNameApprox z :
clause 1
| 0 => complexExpStage z 0
clause 2
| n + 1
=> ComplexRatInterval.tighten (complexExpNameApprox z n) (complexExpStage z (n + 1))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExpNameApprox · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:169 · uses ComplexRatInterval , CertifiedComplex
def complexExpPrecision reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a certified complex number and a positive rational target width, the complex-exponential precision is the denominator of that target.

Definition (Lean source)
complexExpPrecision _z ε :
ℕ
ε.1.den
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExpPrecision · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:543 · uses CertifiedComplex , PosRat
theorem complexExp_width_at_precision reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

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

Formal statement
ComplexRatInterval.width (complexExpNameApprox z (complexExpPrecision z ε)) ≤ ε.1
Proof (Lean source)
theorem complexExp_width_at_precision (z : CertifiedComplex) (ε : PosRat) : ComplexRatInterval.width (complexExpNameApprox z (complexExpPrecision z ε)) ≤ ε.1 := by -- The recursive name approximation is a subrectangle of its current stage. -- Apply `complexExpStage_width`, unfold the denominator-selected precision, -- and finish with `inv_den_le_of_pos` (using denominator + 1 ≤ denominator -- only in the correct reciprocal direction). let N := complexExpPrecision z ε have hsub := complexExpNameApprox_subinterval_stage z N have hmono : ComplexRatInterval.width (complexExpNameApprox z N) ≤ ComplexRatInterval.width (complexExpStage z N) := max_le_max (RatInterval.width_mono hsub.1) (RatInterval.width_mono hsub.2) have hstage := complexExpStage_width z N have hrecip : (complexExpStageTolerance N).1 ≤ 1 / (ε.1.den : ℚ) := by dsimp [complexExpStageTolerance, N, complexExpPrecision] exact div_le_div_of_nonneg_left (by norm_num) (by positivity) (by exact_mod_cast le_succ ε.1.den) exact hmono.trans (hstage.trans (hrecip.trans (Transcendental.inv_den_le_of_pos ε.1 ε.2)))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExp_width_at_precision · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:546 · uses CertifiedComplex , width , complexExpNameApprox , complexExpPrecision , PosRat
def complexExpName reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a certified complex number, the certified complex-exponential name has exact value the complex exponential of the input value, uses the recursively refined complex-exponential rectangles as approximations, and uses the stated precision rule for requested positive rational widths.

Definition (Lean source)
complexExpName z :
clause 1
value := exp z.value
clause 2
clause 3
nested := fun n => (complexExpNameApprox_spec z n).2
clause 4
contains := by intro n; exact (complexExpNameApprox_spec z n).1
clause 6
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExpName · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:571 · uses CertifiedComplex
5 supporting declarations (lemmas, instances)
  • complexExp_sound theorem — Compositional complex exponential evaluation encloses the exact complex exponential.
    z :
    ℂ
    hz :
    I.Contains z
    fuel :
    ℕ
    (complexExp I fuel).Contains (exp z)
    Proof (Lean source)
    theorem complexExp_sound {I : ComplexRatInterval} {z : ℂ} (hz : I.Contains z) (fuel : ℕ) : (complexExp I fuel).Contains (exp z) := by induction fuel with | zero => exact complexExpRaw_sound hz 0 | succ fuel ih => exact (ComplexRatInterval.tighten_sound_left ih (complexExpRaw_sound hz (fuel + 1))).1
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExp_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:44
  • complexExp_nested theorem — Adjacent complex exponential outputs for one fixed input rectangle are nested by coordinatewise finite intersection.
    fuel :
    ℕ
    (complexExp I (fuel + 1)).Subinterval (complexExp I fuel)
    Proof (Lean source)
    theorem complexExp_nested (I : ComplexRatInterval) (fuel : ℕ) : (complexExp I (fuel + 1)).Subinterval (complexExp I fuel) := by have hz : I.Contains ((intervalMid I.re : ℝ) + (intervalMid I.im : ℝ) * I) := by constructor · simpa using (show I.re.Contains (intervalMid I.re : ℝ) from by constructor <;> exact_mod_cast (by dsimp [intervalMid] linarith [I.re.lo_le_hi])) · simpa using (show I.im.Contains (intervalMid I.im : ℝ) from by constructor <;> exact_mod_cast (by dsimp [intervalMid] linarith [I.im.lo_le_hi])) exact (ComplexRatInterval.tighten_sound_left (complexExp_sound hz fuel) (complexExpRaw_sound hz (fuel + 1))).2
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExp_nested · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:53
  • complexExp_width theorem — Complex exponential width is bounded explicitly by the widths and endpoint magnitudes of its certified exponential and trigonometric factors.
    fuel :
    ℕ
    ComplexRatInterval.width (complexExp I fuel)
    ≤ 2 * (max (expInterval I.re fuel).maxAbs 0 * max (cosInterval I.im fuel).width (sinInterval I.im fuel).width + max (cosInterval I.im fuel).maxAbs (sinInterval I.im fuel).maxAbs * max (expInterval I.re fuel).width 0)
    Proof (Lean source)
    theorem complexExp_width (I : ComplexRatInterval) (fuel : ℕ) : ComplexRatInterval.width (complexExp I fuel) ≤ 2 * (max (expInterval I.re fuel).maxAbs 0 * max (cosInterval I.im fuel).width (sinInterval I.im fuel).width + max (cosInterval I.im fuel).maxAbs (sinInterval I.im fuel).maxAbs * max (expInterval I.re fuel).width 0) := by -- View `complexExpRaw` as multiplication of `⟨E, 0⟩` by `⟨cos, sin⟩`. -- First show the recursively tightened result is a subrectangle of the raw -- result at this fuel, then apply `ComplexRatInterval.mul_width` and simplify -- the point-zero coordinate widths and magnitudes. let E := expInterval I.re fuel let T : ComplexRatInterval := ⟨cosInterval I.im fuel, sinInterval I.im fuel⟩ let A : ComplexRatInterval := ⟨E, RatInterval.point 0⟩ have hsub : (complexExp I fuel).Subinterval (complexExpRaw I fuel) := by cases fuel with | zero => exact ⟨RatInterval.subinterval_refl _, RatInterval.subinterval_refl _⟩ | succ fuel => rw [complexExp] have hmid : I.Contains ((intervalMid I.re : ℝ) + (intervalMid I.im : ℝ) * I) := by constructor · simpa using (show I.re.Contains (intervalMid I.re : ℝ) from by constructor <;> exact_mod_cast (by dsimp [intervalMid] linarith [I.re.lo_le_hi])) · simpa using (show I.im.Contains (intervalMid I.im : ℝ) from by constructor <;> exact_mod_cast (by dsimp [intervalMid] linarith [I.im.lo_le_hi])) have hprev := complexExp_sound hmid fuel have hraw := complexExpRaw_sound hmid (fuel + 1) exact ⟨ Transcendental.tighten_subinterval_right hprev.1 hraw.1, Transcendental.tighten_subinterval_right hprev.2 hraw.2⟩ have hwidth : ComplexRatInterval.width (complexExp I fuel) ≤ ComplexRatInterval.width (complexExpRaw I fuel) := max_le_max (RatInterval.width_mono hsub.1) (RatInterval.width_mono hsub.2) have hraw_eq : complexExpRaw I fuel = ComplexRatInterval.mul A T := by ext <;> simp [complexExpRaw, A, T, E, ComplexRatInterval.mul, RatInterval.point, RatInterval.mul, RatInterval.sub, RatInterval.add, RatInterval.neg] rw [hraw_eq] at hwidth refine hwidth.trans ((ComplexRatInterval.mul_width A T).trans_eq ?_) dsimp [A, T, E, ComplexRatInterval.maxAbs, ComplexRatInterval.width] simp only [RatInterval.point, RatInterval.maxAbs, RatInterval.width, abs_zero, max_self, sub_self]
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExp_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:71
  • complexExpNameApprox_spec theorem — Recursive complex-exponential name approximations remain sound and adjacent stages are nested by their defining finite intersection.
    n :
    ℕ
    conclusion 1
    (complexExpNameApprox z n).Contains (exp z.value)
    conclusion 2
    (complexExpNameApprox z (n + 1)).Subinterval (complexExpNameApprox z n)
    Proof (Lean source)
    theorem complexExpNameApprox_spec (z : CertifiedComplex) (n : ℕ) : (complexExpNameApprox z n).Contains (exp z.value) ∧ (complexExpNameApprox z (n + 1)).Subinterval (complexExpNameApprox z n) := by induction n with | zero => have h0 := complexExpStage_sound z 0 have h1 := complexExpStage_sound z 1 exact ⟨h0, (ComplexRatInterval.tighten_sound_left h0 h1).2⟩ | succ n ih => have hnew := complexExpStage_sound z (n + 1) have hcur : (complexExpNameApprox z (n + 1)).Contains (exp z.value) := by rw [complexExpNameApprox] exact (ComplexRatInterval.tighten_sound_left ih.1 hnew).1 have hnext := complexExpStage_sound z (n + 2) constructor · exact hcur · rw [show n + 1 + 1 = n + 2 by omega, complexExpNameApprox] exact (ComplexRatInterval.tighten_sound_left hcur hnext).2
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExpNameApprox_spec · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:179
  • complexExpStage_width theorem — Every scheduled stage has width at most its reciprocal stage tolerance; the proof combines input refinement, scalar Taylor convergence, magnitude amplification, and explicit rectangle-product propagation.
    n :
    ℕ
    ComplexRatInterval.width (complexExpStage z n) ≤ (complexExpStageTolerance n).1
    Proof (Lean source)
    theorem complexExpStage_width (z : CertifiedComplex) (n : ℕ) : ComplexRatInterval.width (complexExpStage z n) ≤ (complexExpStageTolerance n).1 := by -- Let η be the stage tolerance, B the initial exponential magnitude scale, -- τ = η/(16B), α = τ/8, and K the scheduled input. Nestedness of `z` -- gives `K ⊆ z.approx 0`, while `z.width_modulus` gives `width K ≤ τ/(4B)`. -- Use `power_div_factorial_le` for the sine/cosine errors and -- `expScalar_width` plus scalar nestedness for both exponential calls. -- Bound each factor's `maxAbs` from one contained exact value plus its width, -- feed those estimates to `complexExp_width`, and finish the deliberately -- loose constants by `nlinarith`/`field_simp` using η ≤ 1 and B ≥ 2. let η : ℚ := (complexExpStageTolerance n).1 let B : ℚ := complexExpMagnitude z let τ : ℚ := (complexExpInnerTolerance z n).1 let α : PosRat := ⟨τ / 8, by change 0 < (complexExpInnerTolerance z n).1 / 8 exact div_pos (complexExpInnerTolerance z n).2 (by norm_num)⟩ let K : ComplexRatInterval := complexExpStageInput z n let N : ℕ := complexExpStageFuel z n let d : ℕ := α.1.den + 1 let A : ℕ := (intervalMid K.im).num.natAbs + 2 let S0 := Transcendental.expScalar (z.approx 0).re.maxAbs 0 let E := expInterval K.re N let C := cosInterval K.im N let S := sinInterval K.im N have hηpos : 0 < η := by dsimp [η, complexExpStageTolerance] positivity have hηone : η ≤ 1 := by dsimp [η, complexExpStageTolerance] apply (div_le_iff₀ (by positivity : (0 : ℚ) < (n : ℚ) + 1)).2 norm_num have hB : 2 ≤ B := by dsimp [B, complexExpMagnitude, S0] linarith [abs_nonneg ((Transcendental.expScalar (z.approx 0).re.maxAbs 0).hi)] have hBpos : 0 < B := lt_of_lt_of_le (by norm_num) hB have hτeq : τ = η / (16 * B) := by rfl have hαeq : α.1 = τ / 8 := by rfl have hτpos : 0 < τ := by rw [hτeq]; positivity have hτone : τ ≤ 1 := by rw [hτeq] apply (div_le_iff₀ (by positivity : (0 : ℚ) < 16 * B)).2 nlinarith [hηone] have hαpos : 0 < α.1 := α.2 have hαone : α.1 ≤ 1 := by rw [hαeq]; nlinarith [hτone] have hK0 : K.Subinterval (z.approx 0) := by dsimp [K, complexExpStageInput] exact complexApprox_subinterval_of_le z (zero_le _) have hKw : ComplexRatInterval.width K ≤ τ / (4 * B) := by have hm := z.width_modulus (complexExpInputTolerance z n) simpa [K, complexExpStageInput, complexExpInputTolerance, τ] using hm have hKrew : K.re.width ≤ τ / (4 * B) := (le_max_left _ _).trans hKw have hKimw : K.im.width ≤ τ / (4 * B) := (le_max_right _ _).trans hKw have hNtrig : 32 * d * A ^ 2 ≤ N := by dsimp [N, complexExpStageFuel, d, A, α, K] exact le_max_left _ _ have hNexpMid : Transcendental.expPrecision (intervalMid K.re) α ≤ N := by dsimp [N, complexExpStageFuel, K, α] exact (le_max_left _ _).trans (le_max_right _ _) have hNexpAbs : Transcendental.expPrecision K.re.maxAbs α ≤ N := by dsimp [N, complexExpStageFuel, K, α] exact (le_max_right _ _).trans (le_max_right _ _) have hAone : 1 ≤ A := by dsimp [A]; omega have hdone : 1 ≤ d := by dsimp [d]; omega have hmidA : |intervalMid K.im| ≤ (A : ℚ) := by have hdq : (0 : ℚ) < (intervalMid K.im).den := by exact_mod_cast (intervalMid K.im).den_pos have hnum : |intervalMid K.im| ≤ ((intervalMid K.im).num.natAbs : ℚ) := by calc |intervalMid K.im| = |((intervalMid K.im).num : ℚ) / ((intervalMid K.im).den : ℚ)| := by rw [Rat.num_div_den] _ = ((intervalMid K.im).num.natAbs : ℚ) / (intervalMid K.im).den := by rw [abs_div, abs_of_pos hdq] norm_num _ ≤ ((intervalMid K.im).num.natAbs : ℕ) := by apply (div_le_iff₀ hdq).2 have hd1 : (1 : ℚ) ≤ (intervalMid K.im).den := by exact_mod_cast (intervalMid K.im).den_pos nlinarith calc |intervalMid K.im| ≤ ((intervalMid K.im).num.natAbs : ℕ) := hnum _ ≤ A := by exact_mod_cast le_add_right (intervalMid K.im).num.natAbs 2 have hsinErr : sinError (intervalMid K.im) N ≤ α.1 / 4 := by have hp := power_div_factorial_le (intervalMid K.im) A d N 3 hmidA hAone hdone (by omega) hNtrig have hinv : 1 / (d : ℚ) ≤ α.1 := by exact (div_le_div_of_nonneg_left (by norm_num) (by positivity) (by dsimp [d]; exact_mod_cast le_succ α.1.den)).trans (Transcendental.inv_den_le_of_pos α.1 α.2) calc _ ≤ 1 / ((4 * d : ℕ) : ℚ) := by simpa [sinError] using hp _ = (1 / (d : ℚ)) / 4 := by push_cast; field_simp _ ≤ α.1 / 4 := div_le_div_of_nonneg_right hinv (by norm_num) have hcosErr : cosError (intervalMid K.im) N ≤ α.1 / 4 := by have hp := power_div_factorial_le (intervalMid K.im) A d N 2 hmidA hAone hdone (by omega) hNtrig have hinv : 1 / (d : ℚ) ≤ α.1 := by exact (div_le_div_of_nonneg_left (by norm_num) (by positivity) (by dsimp [d]; exact_mod_cast le_succ α.1.den)).trans (Transcendental.inv_den_le_of_pos α.1 α.2) calc _ ≤ 1 / ((4 * d : ℕ) : ℚ) := by simpa [cosError] using hp _ = (1 / (d : ℚ)) / 4 := by push_cast; field_simp _ ≤ α.1 / 4 := div_le_div_of_nonneg_right hinv (by norm_num) have hCw : C.width ≤ τ := by have h := cosInterval_width K.im N dsimp [C] rw [hαeq] at hcosErr have hdiv : τ / (4 * B) ≤ τ / 8 := by apply div_le_div_of_nonneg_left hτpos.le (by norm_num) nlinarith nlinarith have hSw : S.width ≤ τ := by have h := sinInterval_width K.im N dsimp [S] rw [hαeq] at hsinErr have hdiv : τ / (4 * B) ≤ τ / 8 := by apply div_le_div_of_nonneg_left hτpos.le (by norm_num) nlinarith nlinarith have hscalarMid : (Transcendental.expScalar (intervalMid K.re) N).width ≤ α.1 := by exact (RatInterval.width_mono (expScalar_subinterval_of_le (intervalMid K.re) hNexpMid)).trans (Transcendental.expScalar_width (intervalMid K.re) α) have hscalarAbs : (Transcendental.expScalar K.re.maxAbs N).width ≤ α.1 := by exact (RatInterval.width_mono (expScalar_subinterval_of_le K.re.maxAbs hNexpAbs)).trans (Transcendental.expScalar_width K.re.maxAbs α) have hKabs : K.re.maxAbs ≤ (z.approx 0).re.maxAbs := ratMaxAbs_mono hK0.1 have hmidK : K.re.Contains (intervalMid K.re : ℝ) := by constructor <;> exact_mod_cast (by dsimp [intervalMid] linarith [K.re.lo_le_hi]) have hmidM : (intervalMid K.re : ℝ) ≤ (z.approx 0).re.maxAbs := by exact_mod_cast (le_trans (le_abs_self _) ((abs_le_max_abs_abs (by exact_mod_cast hmidK.1) (by exact_mod_cast hmidK.2)).trans hKabs)) have hvalM : z.value.re ≤ ((z.approx 0).re.maxAbs : ℚ) := by have hz0 := (z.contains 0).1 exact (le_abs_self _).trans (by exact_mod_cast abs_le_max_abs_abs hz0.1 hz0.2) have hS0 := Transcendental.expScalar_sound (z.approx 0).re.maxAbs 0 have hS0hi0 : 0 ≤ S0.hi := by dsimp [S0] exact_mod_cast (Real.exp_pos ((z.approx 0).re.maxAbs : ℝ)).le.trans hS0.2 have hUpper : (Transcendental.expScalar K.re.maxAbs N).hi ≤ B := by change (Transcendental.expScalar K.re.maxAbs N).hi ≤ |S0.hi| + 2 have hUs := Transcendental.expScalar_sound K.re.maxAbs N have hexp : exp (K.re.maxAbs : ℝ) ≤ exp ((z.approx 0).re.maxAbs : ℝ) := Real.exp_le_exp.mpr (by exact_mod_cast hKabs) have hUhi : ((Transcendental.expScalar K.re.maxAbs N).hi : ℝ) ≤ exp (K.re.maxAbs : ℝ) + α.1 := by have hw : (((Transcendental.expScalar K.re.maxAbs N).hi : ℝ) - (Transcendental.expScalar K.re.maxAbs N).lo) ≤ α.1 := by exact_mod_cast hscalarAbs nlinarith [hUs.1] have hUS0 : ((Transcendental.expScalar K.re.maxAbs N).hi : ℝ) ≤ (S0.hi : ℝ) + α.1 := by nlinarith [hS0.2] have hUS0q : (Transcendental.expScalar K.re.maxAbs N).hi ≤ S0.hi + α.1 := by exact_mod_cast hUS0 exact hUS0q.trans (by rw [abs_of_nonneg hS0hi0] nlinarith [hαone]) have hEw : E.width ≤ τ := by have h := expInterval_width K.re N dsimp [E] rw [show intervalRadius K.re = K.re.width / 2 by rfl] at h rw [hαeq] at hscalarMid have hprod : (Transcendental.expScalar K.re.maxAbs N).hi * K.re.width ≤ τ / 4 := by have hu0 : 0 ≤ (Transcendental.expScalar K.re.maxAbs N).hi := by exact_mod_cast (Real.exp_pos (K.re.maxAbs : ℝ)).le.trans (Transcendental.expScalar_sound K.re.maxAbs N).2 have := mul_le_mul hUpper hKrew (RatInterval.width_nonneg K.re) hBpos.le calc _ ≤ B * (τ / (4 * B)) := this _ = τ / 4 := by field_simp nlinarith have hEcontains : E.Contains (exp z.value.re) := by exact expInterval_sound (z.contains _).1 N have hEabs : E.maxAbs ≤ B := by have hexp : exp z.value.re ≤ (S0.hi : ℝ) := (Real.exp_le_exp.mpr hvalM).trans hS0.2 have h := ratMaxAbs_le_of_contains hEcontains (by rw [Real.abs_exp]; exact hexp.trans (by exact_mod_cast le_abs_self S0.hi)) hEw hτpos.le change E.maxAbs ≤ |S0.hi| + 2 exact h.trans (by nlinarith [hτone]) have hCcontains : C.Contains (cos z.value.im) := cosInterval_sound (z.contains _).2 N have hScontains : S.Contains (sin z.value.im) := sinInterval_sound (z.contains _).2 N have hCabs : C.maxAbs ≤ 2 := by exact (ratMaxAbs_le_of_contains (C := (1 : ℚ)) (w := τ) hCcontains (by simpa using Real.abs_cos_le_one z.value.im) hCw hτpos.le).trans (by nlinarith [hτone]) have hSabs : S.maxAbs ≤ 2 := by exact (ratMaxAbs_le_of_contains (C := (1 : ℚ)) (w := τ) hScontains (by simpa using Real.abs_sin_le_one z.value.im) hSw hτpos.le).trans (by nlinarith [hτone]) have hout := complexExp_width K N change ComplexRatInterval.width (complexExp K N) ≤ η have hEA0 : 0 ≤ E.maxAbs := (abs_nonneg E.lo).trans (le_max_left _ _) have hCA0 : 0 ≤ C.maxAbs := (abs_nonneg C.lo).trans (le_max_left _ _) have hSA0 : 0 ≤ S.maxAbs := (abs_nonneg S.lo).trans (le_max_left _ _) have hEw0 := RatInterval.width_nonneg E have hCw0 := RatInterval.width_nonneg C have hSw0 := RatInterval.width_nonneg S have hout' : ComplexRatInterval.width (complexExp K N) ≤ -- … truncated; follow the source link for the rest …
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.complexExpStage_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ComplexExp.lean:274
Circle­Schedule 11 core · 5 supporting This module defines the single schedule record consumed by evaluation, schedule manifests, and specifications. ★ circleNode_sound

Shared schedules and certified circle nodes

This module defines the single schedule record consumed by evaluation, schedule manifests, and specifications. It also evaluates every rational circle node, including the terminal endpoint used by deterministic trapezoidal quadrature, from the same scheduled π and complex-exponential fuel.

structure Schedule reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

A contour schedule packages a requested rational error tolerance, supplied operation-count metadata, an input precision, a mesh size that is nonempty, a fuel budget for transcendental evaluation, and a nonnegative Lipschitz constant, together with three nonnegative error budgets — for node evaluation, for the uniform mesh, and for final quadrature widening — such that the three budgets together fit within the tolerance and the mesh budget absorbs the Lipschitz discretization error.

Definition (Lean source)
The requested final rational tolerance.
tolerance :
Supplied primitive-operation-count metadata for one node program.
operationCount :
ℕ
Input-name precision used by every node evaluation.
inputPrecision :
ℕ
Number of uniform trapezoidal mesh cells.
mesh :
ℕ
The scheduled mesh is nonempty.
mesh_pos :
0 < mesh
Common Taylor/intersection fuel used at all nodes.
fuel :
ℕ
Rational Lipschitz constant used to bound quadrature discretization error.
lipschitzConstant :
ℚ
The Lipschitz constant is nonnegative.
lipschitzConstant_nonneg :
0 ≤ lipschitzConstant
Budget allocated to node evaluation error.
nodeBudget :
ℚ
Budget allocated to uniform-mesh error.
meshBudget :
ℚ
Budget allocated to the final quadrature widening.
quadratureBudget :
ℚ
Node error budget is nonnegative.
nodeBudget_nonneg :
0 ≤ nodeBudget
Mesh error budget is nonnegative.
meshBudget_nonneg :
0 ≤ meshBudget
Quadrature error budget is nonnegative.
quadratureBudget_nonneg :
0 ≤ quadratureBudget
The three split budgets fit within the requested tolerance.
budget_sum_le :
nodeBudget + meshBudget + quadratureBudget ≤ tolerance.1
The selected mesh absorbs the Lipschitz discretization error.
mesh_error_le :
lipschitzConstant / mesh ≤ meshBudget
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Schedule · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:19
def canonical reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Schedule

Given a positive rational tolerance, natural-number operation-count metadata, a rational Lipschitz constant, and evidence that this constant is nonnegative, the canonical contour schedule allocates one third of the tolerance to each error budget and selects its input precision, mesh size, and fuel from the stated rational data.

Definition (Lean source)
tolerance :
operationCount :
ℕ
lipschitzConstant :
ℚ
hlipschitz :
0 ≤ lipschitzConstant
canonical tolerance operationCount lipschitzConstant hlipschitz :
Schedule
clause 1
tolerance := tolerance
clause 2
operationCount := operationCount
clause 3
inputPrecision := 64 * (operationCount + 1) * (tolerance.1.den + 1) * (lipschitzConstant.num.natAbs + 2) ^ 2
clause 4
mesh := 3 * (lipschitzConstant.num.natAbs + 1) * tolerance.1.den
clause 5
mesh_pos := by positivity
clause 6
fuel := 64 * (operationCount + 1) * (tolerance.1.den + 1) * (lipschitzConstant.num.natAbs + 2) ^ 2
clause 7
lipschitzConstant := lipschitzConstant
clause 8
lipschitzConstant_nonneg := hlipschitz
clause 9
nodeBudget := tolerance.1 / 3
clause 10
meshBudget := tolerance.1 / 3
clause 11
quadratureBudget := tolerance.1 / 3
clause 12
nodeBudget_nonneg := by exact (div_nonneg tolerance.2.le (by norm_num))
clause 13
meshBudget_nonneg := by exact (div_nonneg tolerance.2.le (by norm_num))
clause 14
quadratureBudget_nonneg := by exact (div_nonneg tolerance.2.le (by norm_num))
clause 15
budget_sum_le := by linarith
clause 16
mesh_error_le := by have hMle : lipschitzConstant
≤ (lipschitzConstant.num.natAbs : ℕ) := by have hnum0 : 0 ≤ lipschitzConstant.num := Rat.num_nonneg.mpr hlipschitz calc lipschitzConstant = (lipschitzConstant.num : ℚ) / (lipschitzConstant.den : ℕ) := (Rat.num_div_den lipschitzConstant).symm _ ≤ (lipschitzConstant.num : ℚ) := div_le_self (by exact_mod_cast hnum0) (by exact_mod_cast Rat.den_pos lipschitzConstant) _ = (lipschitzConstant.num.natAbs : ℕ) := by have hi : (lipschitzConstant.num.natAbs : ℤ) = lipschitzConstant.num := Int.natAbs_of_nonneg hnum0 exact (congrArg (fun x : ℤ => (x : ℚ)) hi).symm have hεden : (1 : ℚ) ≤ tolerance.1 * (tolerance.1.den : ℕ) := by have hnumpos : 0 < tolerance.1.num := (Rat.num_pos).2 tolerance.2 have hrepr := Rat.num_div_den tolerance.1 have hdenpos : (0 : ℚ) < tolerance.1.den := by exact_mod_cast Rat.den_pos tolerance.1 have heq : (tolerance.1.num : ℚ) = tolerance.1 * (tolerance.1.den : ℕ) := (div_eq_iff hdenpos.ne').mp hrepr rw [← heq] exact_mod_cast hnumpos have hA : (0 : ℚ) ≤ lipschitzConstant.num.natAbs
+ 1 := by positivity have hcoarse : lipschitzConstant
≤ tolerance.1 * (((lipschitzConstant.num.natAbs : ℚ) + 1) * tolerance.1.den) := by calc lipschitzConstant ≤ (lipschitzConstant.num.natAbs : ℕ) := hMle _ ≤ (lipschitzConstant.num.natAbs + 1 : ℕ) := by exact_mod_cast le_succ _ _ ≤ tolerance.1 * (((lipschitzConstant.num.natAbs : ℚ) + 1) * tolerance.1.den) := by have h := mul_le_mul_of_nonneg_left hεden hA push_cast at h ⊢ nlinarith norm_num only [Nat.cast_mul, Nat.cast_add, Nat.cast_one] calc lipschitzConstant / (3 * (lipschitzConstant.num.natAbs + 1) * tolerance.1.den) ≤ (tolerance.1 * ((lipschitzConstant.num.natAbs + 1) * tolerance.1.den)) / (3 * (lipschitzConstant.num.natAbs + 1) * tolerance.1.den) := div_le_div_of_nonneg_right hcoarse (by positivity) _ = tolerance.1 / 3 := by field_simp
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Schedule.canonical · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:63 · uses Schedule , PosRat
structure ScheduleManifestEntry reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

A schedule-manifest entry records a shared schedule, an endpoint index, and an operation ordinal.

Definition (Lean source)
The exact shared schedule stored in this entry.
schedule :
Schedule
The endpoint index recorded by the entry.
node :
ℕ
An ordinal bounded by the node program's supplied operation-count metadata.
operation :
ℕ
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ScheduleManifestEntry · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:139
def circleNodeManifestEntry reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

Given a contour schedule, a mesh-endpoint index, and an operation ordinal, the circle-node schedule-manifest entry records exactly those three quantities.

Definition (Lean source)
schedule :
Schedule
node operation :
ℕ
circleNodeManifestEntry schedule node operation :
⟨schedule, node, operation⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.circleNodeManifestEntry · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:149 · uses Schedule , ScheduleManifestEntry
def circleAngle reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

Given a contour schedule and a natural-number endpoint index, the rational rectangle enclosing the corresponding pure-imaginary circle angle has real coordinate zero and imaginary coordinate 2πk/m2πk/m, where mm is the schedule's mesh size.

Definition (Lean source)
schedule :
Schedule
k :
ℕ
circleAngle schedule k :
⟨RatInterval.point 0, (RatInterval.point (2 * k / schedule.mesh : ℚ)).mul (Transcendental.piInterval schedule.inputPrecision)⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.circleAngle · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:156 · uses ComplexRatInterval , Schedule
def circleNode reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

Given a rational radius, a contour schedule, and a natural-number endpoint index, the scheduled circle-node rectangle is the rational-interval evaluation of rexp⁡(2πik/m)r\exp(2πik/m) using that schedule's angle enclosure and fuel.

Definition (Lean source)
radius :
ℚ
schedule :
Schedule
k :
ℕ
circleNode radius schedule k :
(Transcendental.complexExp (circleAngle schedule k) schedule.fuel).smulRat radius
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.circleNode · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:162 · uses ComplexRatInterval , Schedule
def circleInnerTolerance reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

Given a rational radius and a positive rational target width, the internal circle tolerance is the smaller of target/(256(∣r∣+1))\mathrm{target}/(256(|r|+1)) and 1/10241/1024.

Definition (Lean source)
radius :
ℚ
target :
circleInnerTolerance radius target :
⟨min (target.1 / (256 * (|radius| + 1))) (1 / 1024), by apply lt_min · exact div_pos target.2 (mul_pos (by norm_num) (by linarith [abs_nonneg radius])) · norm_num⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.circleInnerTolerance · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:166 · uses PosRat
def circleInputPrecision reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

Given a rational radius and a positive rational target width, the circle input precision is the π-approximation precision selected for their internal circle tolerance.

Definition (Lean source)
radius :
ℚ
target :
circleInputPrecision radius target :
ℕ
Transcendental.piPrecision (circleInnerTolerance radius target)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.circleInputPrecision · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:176 · uses PosRat
def circleExpFuel reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

Given a rational radius, a natural-number mesh size, and a positive rational target width, the circle exponential fuel is the larger of the zero-input exponential precision and an explicit trigonometric Taylor-fuel bound computed from the internal circle tolerance.

Definition (Lean source)
radius :
ℚ
_mesh :
ℕ
target :
circleExpFuel radius _mesh target :
ℕ
max (Transcendental.expPrecision 0 (circleInnerTolerance radius target)) (32 * ((circleInnerTolerance radius target).1.den + 1) * 12 ^ 2)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.circleExpFuel · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:180 · uses PosRat
def exactCircleNode reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

Given a rational radius, a contour schedule, and a natural-number endpoint index, the exact circle node is the complex number rexp⁡(2πik/m)r\exp(2πik/m), where mm is the schedule's mesh size.

Definition (Lean source)
radius :
ℚ
schedule :
Schedule
k :
ℕ
exactCircleNode radius schedule k :
ℂ
(radius : ℂ) * exp (((2 : ℝ) * pi * ((k : ℝ) / schedule.mesh)) * I)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.exactCircleNode · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:405 · uses Schedule
theorem circleNode_sound reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

For a rational radius, a quadrature schedule, and any index k, the computed rational circle-node rectangle at index k contains the exact complex circle point radius · exp(2πi · k / mesh).

Formal statement
radius :
ℚ
schedule :
Schedule
k :
ℕ
(circleNode radius schedule k).Contains (exactCircleNode radius schedule k)
Proof (Lean source)
theorem circleNode_sound (radius : ℚ) (schedule : Schedule) {k : ℕ} : (circleNode radius schedule k).Contains (exactCircleNode radius schedule k) := by exact ComplexRatInterval.smulRat_sound radius (Transcendental.complexExp_sound (circleAngle_sound schedule) schedule.fuel)
5 supporting declarations (lemmas, instances)
  • circleNode_width_at_selected_precision theorem — The explicit circle input precision and exponential fuel make every actually evaluated endpoint rectangle no wider than the requested target.
    radius :
    ℚ
    hradius :
    0 ≤ radius
    schedule :
    Schedule
    target :
    hprecision :
    schedule.inputPrecision = circleInputPrecision radius target
    hfuel :
    circleExpFuel radius schedule.mesh target ≤ schedule.fuel
    k :
    ℕ
    hk :
    k ≤ schedule.mesh
    ComplexRatInterval.width (circleNode radius schedule k) ≤ target.1
    Proof (Lean source)
    theorem circleNode_width_at_selected_precision (radius : ℚ) (hradius : 0 ≤ radius) (schedule : Schedule) (target : PosRat) (hprecision : schedule.inputPrecision = circleInputPrecision radius target) (hfuel : circleExpFuel radius schedule.mesh target ≤ schedule.fuel) {k : ℕ} (hk : k ≤ schedule.mesh) : ComplexRatInterval.width (circleNode radius schedule k) ≤ target.1 := by let τ := circleInnerTolerance radius target let c : ℚ := 2 * k / schedule.mesh let P := Transcendental.piInterval schedule.inputPrecision let K := (circleAngle schedule k).im let E := Transcendental.expInterval (circleAngle schedule k).re schedule.fuel let C := Transcendental.cosInterval K schedule.fuel let S := Transcendental.sinInterval K schedule.fuel have hτ0 : 0 < τ.1 := τ.2 have hτone : τ.1 ≤ 1 / 1024 := by exact min_le_right _ _ have hτtarget : τ.1 ≤ target.1 / (256 * (|radius| + 1)) := by exact min_le_left _ _ have hc0 : 0 ≤ c := by dsimp [c] positivity have hcle : c ≤ 2 := by apply (div_le_iff₀ (show (0 : ℚ) < schedule.mesh by exact_mod_cast schedule.mesh_pos)).2 push_cast exact_mod_cast (Nat.mul_le_mul_left 2 hk) have hPw : P.width ≤ τ.1 := by dsimp [P] rw [hprecision] exact Transcendental.piInterval_width τ have hKw : K.width ≤ 2 * τ.1 := by change ((RatInterval.point c).mul P).width ≤ 2 * τ.1 rw [point_mul_width c hc0 P] calc c * P.width ≤ 2 * P.width := mul_le_mul_of_nonneg_right hcle (RatInterval.width_nonneg P) _ ≤ 2 * τ.1 := mul_le_mul_of_nonneg_left hPw (by norm_num) have hP0 : P.Subinterval (Transcendental.piInterval 0) := by exact CertifiedReal.approx_mono Transcendental.piName (zero_le _) have hP0w : (Transcendental.piInterval 0).width ≤ 1 := by norm_num [Transcendental.piInterval, Transcendental.piRaw, Transcendental.atanRaw, Transcendental.atanPartial, Transcendental.atanError, RatInterval.mul, RatInterval.sub, RatInterval.add, RatInterval.neg, RatInterval.point, RatInterval.width] have hPwide : P.width ≤ 1 := (RatInterval.width_mono hP0).trans hP0w have hPabs : P.maxAbs ≤ 5 := by have h := interval_maxAbs_le_of_contains_width (C := 4) (w := 1) (Transcendental.piInterval_sound schedule.inputPrecision) (by simpa [abs_of_pos Real.pi_pos] using Real.pi_le_four) hPwide convert h using 1 <;> norm_num [P] have hKabs : K.maxAbs ≤ 10 := by change ((RatInterval.point c).mul P).maxAbs ≤ 10 rw [point_mul_maxAbs c hc0 P] nlinarith have hmidK : K.Contains (Transcendental.intervalMid K : ℝ) := by constructor <;> exact_mod_cast (by dsimp [Transcendental.intervalMid] linarith [K.lo_le_hi]) have hmidA : |Transcendental.intervalMid K| ≤ (12 : ℚ) := by exact (abs_le_max_abs_abs (by exact_mod_cast hmidK.1) (by exact_mod_cast hmidK.2)).trans (hKabs.trans (by norm_num)) have hfuelExp : Transcendental.expPrecision 0 τ ≤ schedule.fuel := by exact (le_max_left _ _).trans (by simpa [circleExpFuel, τ] using hfuel) have hfuelTrig : 32 * (τ.1.den + 1) * 12 ^ 2 ≤ schedule.fuel := by exact (le_max_right _ _).trans (by simpa [circleExpFuel, τ] using hfuel) have hEw : E.width ≤ τ.1 := by have hraw := Transcendental.expInterval_width (RatInterval.point 0) schedule.fuel have hscalar : (Transcendental.expScalar 0 schedule.fuel).width ≤ τ.1 := by exact (RatInterval.width_mono (CertifiedReal.approx_mono (Transcendental.expName 0) hfuelExp)).trans (Transcendental.expScalar_width 0 τ) change (Transcendental.expInterval (RatInterval.point 0) schedule.fuel).width ≤ τ.1 exact hraw.trans (by simpa [RatInterval.point, Transcendental.intervalMid, Transcendental.intervalRadius, RatInterval.width] using hscalar) have hsinErr : Transcendental.sinError (Transcendental.intervalMid K) schedule.fuel ≤ τ.1 / 4 := by have herr := Transcendental.power_div_factorial_le (Transcendental.intervalMid K) 12 (τ.1.den + 1) schedule.fuel 3 hmidA (by norm_num) (by omega) (by omega) hfuelTrig have hinv : 1 / ((τ.1.den + 1 : ℕ) : ℚ) ≤ τ.1 := by exact (div_le_div_of_nonneg_left (by norm_num) (by positivity) (by exact_mod_cast le_succ τ.1.den)).trans (Transcendental.inv_den_le_of_pos τ.1 τ.2) calc _ ≤ 1 / ((4 * (τ.1.den + 1) : ℕ) : ℚ) := by simpa [Transcendental.sinError] using herr _ = (1 / ((τ.1.den + 1 : ℕ) : ℚ)) / 4 := by push_cast; field_simp _ ≤ τ.1 / 4 := div_le_div_of_nonneg_right hinv (by norm_num) have hcosErr : Transcendental.cosError (Transcendental.intervalMid K) schedule.fuel ≤ τ.1 / 4 := by have herr := Transcendental.power_div_factorial_le (Transcendental.intervalMid K) 12 (τ.1.den + 1) schedule.fuel 2 hmidA (by norm_num) (by omega) (by omega) hfuelTrig have hinv : 1 / ((τ.1.den + 1 : ℕ) : ℚ) ≤ τ.1 := by exact (div_le_div_of_nonneg_left (by norm_num) (by positivity) (by exact_mod_cast le_succ τ.1.den)).trans (Transcendental.inv_den_le_of_pos τ.1 τ.2) calc _ ≤ 1 / ((4 * (τ.1.den + 1) : ℕ) : ℚ) := by simpa [Transcendental.cosError] using herr _ = (1 / ((τ.1.den + 1 : ℕ) : ℚ)) / 4 := by push_cast; field_simp _ ≤ τ.1 / 4 := div_le_div_of_nonneg_right hinv (by norm_num) have hCw : C.width ≤ 5 * τ.1 / 2 := (Transcendental.cosInterval_width K schedule.fuel).trans (by nlinarith) have hSw : S.width ≤ 5 * τ.1 / 2 := (Transcendental.sinInterval_width K schedule.fuel).trans (by nlinarith) have hEcontains : E.Contains (1 : ℝ) := by change (Transcendental.expInterval (RatInterval.point 0) schedule.fuel).Contains 1 simpa using Transcendental.expInterval_sound (RatInterval.point_sound (0 : ℚ)) schedule.fuel have hEabs : E.maxAbs ≤ 2 := by exact (interval_maxAbs_le_of_contains_width (C := 1) (w := τ.1) hEcontains (by norm_num) hEw).trans (by nlinarith) have hCcontains : C.Contains (cos (Transcendental.intervalMid K : ℝ)) := Transcendental.cosInterval_sound hmidK schedule.fuel have hScontains : S.Contains (sin (Transcendental.intervalMid K : ℝ)) := Transcendental.sinInterval_sound hmidK schedule.fuel have hCabs : C.maxAbs ≤ 2 := by exact (interval_maxAbs_le_of_contains_width (C := 1) (w := 5 * τ.1 / 2) hCcontains (by simpa only [Rat.cast_one] using Real.abs_cos_le_one (Transcendental.intervalMid K : ℝ)) hCw).trans (by nlinarith) have hSabs : S.maxAbs ≤ 2 := by exact (interval_maxAbs_le_of_contains_width (C := 1) (w := 5 * τ.1 / 2) hScontains (by simpa only [Rat.cast_one] using Real.abs_sin_le_one (Transcendental.intervalMid K : ℝ)) hSw).trans (by nlinarith) have hout := Transcendental.complexExp_width (circleAngle schedule k) schedule.fuel have hout' : ComplexRatInterval.width (Transcendental.complexExp (circleAngle schedule k) schedule.fuel) ≤ 2 * (max E.maxAbs 0 * max C.width S.width + max C.maxAbs S.maxAbs * max E.width 0) := by simpa only [E, C, S, K] using hout have hcomplex : ComplexRatInterval.width (Transcendental.complexExp (circleAngle schedule k) schedule.fuel) ≤ 14 * τ.1 := by change _ ≤ 14 * τ.1 have hTW : max C.width S.width ≤ 5 * τ.1 / 2 := max_le hCw hSw have hTA : max C.maxAbs S.maxAbs ≤ 2 := max_le hCabs hSabs have hEA : max E.maxAbs 0 ≤ 2 := max_le hEabs (by norm_num) have hEW : max E.width 0 ≤ τ.1 := max_le hEw hτ0.le have hTW0 : 0 ≤ max C.width S.width := (RatInterval.width_nonneg C).trans (le_max_left _ _) have hEW0 : 0 ≤ max E.width 0 := le_max_right _ _ have hprod1 := mul_le_mul hEA hTW hTW0 (by norm_num : (0 : ℚ) ≤ 2) have hprod2 := mul_le_mul hTA hEW hEW0 (by norm_num : (0 : ℚ) ≤ 2) exact hout'.trans (by nlinarith) rw [circleNode, complex_smul_width radius hradius] rw [abs_of_nonneg hradius] at hτtarget have hden : 0 < 256 * (radius + 1) := by positivity have hprod : 256 * (radius + 1) * τ.1 ≤ target.1 := by simpa [mul_comm, mul_left_comm] using (le_div_iff₀ hden).mp hτtarget calc radius * ComplexRatInterval.width (Transcendental.complexExp (circleAngle schedule k) schedule.fuel) ≤ radius * (14 * τ.1) := mul_le_mul_of_nonneg_left hcomplex hradius _ ≤ target.1 := by nlinarith
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.circleNode_width_at_selected_precision · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:238
  • circleAngle_sound theorem — The angle rectangle contains the exact pure-imaginary angle at every endpoint index.
    schedule :
    Schedule
    k :
    ℕ
    (circleAngle schedule k).Contains (((2 : ℝ) * pi * ((k : ℝ) / schedule.mesh)) * I)
    Proof (Lean source)
    theorem circleAngle_sound (schedule : Schedule) {k : ℕ} : (circleAngle schedule k).Contains (((2 : ℝ) * pi * ((k : ℝ) / schedule.mesh)) * I) := by constructor · simpa [circleAngle] using RatInterval.point_sound (0 : ℚ) · have h := RatInterval.mul_sound (RatInterval.point_sound (2 * k / schedule.mesh : ℚ)) (Transcendental.piInterval_sound schedule.inputPrecision) have heq : (((2 * k / schedule.mesh : ℚ) : ℝ) * pi) = ((((2 : ℝ) * pi * ((k : ℝ) / schedule.mesh)) * I).im) := by push_cast simp ring rw [← heq] exact h
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.circleAngle_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:410
  • circleNode_endpoint theorem — The terminal endpoint k = mesh, which is explicitly used by the trapezoidal program, is certified and denotes the same point as endpoint zero.
    radius :
    ℚ
    schedule :
    Schedule
    conclusion 1
    (circleNode radius schedule schedule.mesh).Contains (radius : ℂ)
    conclusion 2
    exactCircleNode radius schedule schedule.mesh = (radius : ℂ)
    Proof (Lean source)
    theorem circleNode_endpoint (radius : ℚ) (schedule : Schedule) : (circleNode radius schedule schedule.mesh).Contains (radius : ℂ) ∧ exactCircleNode radius schedule schedule.mesh = (radius : ℂ) := by have hratio : ((schedule.mesh : ℝ) : ℂ) / schedule.mesh = 1 := by apply div_self exact_mod_cast schedule.mesh_pos.ne' have hexact : exactCircleNode radius schedule schedule.mesh = (radius : ℂ) := by rw [exactCircleNode, hratio] simp [Complex.exp_two_pi_mul_I] constructor · rw [← hexact] exact circleNode_sound radius schedule · exact hexact
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.circleNode_endpoint · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:436
  • circleNode_width theorem — Circle-node width propagation exposes radius scaling and the scheduled complex-exponential approximation width.
    radius :
    ℚ
    hradius :
    0 ≤ radius
    schedule :
    Schedule
    k :
    ℕ
    ComplexRatInterval.width (circleNode radius schedule k)
    ≤ radius * ComplexRatInterval.width (Transcendental.complexExp (circleAngle schedule k) schedule.fuel)
    Proof (Lean source)
    theorem circleNode_width (radius : ℚ) (hradius : 0 ≤ radius) (schedule : Schedule) (k : ℕ) : ComplexRatInterval.width (circleNode radius schedule k) ≤ radius * ComplexRatInterval.width (Transcendental.complexExp (circleAngle schedule k) schedule.fuel) := by let I := Transcendental.complexExp (circleAngle schedule k) schedule.fuel have hre : ((RatInterval.point radius).mul I.re).width = radius * I.re.width := by have h := mul_le_mul_of_nonneg_left I.re.lo_le_hi hradius simp [RatInterval.mul, RatInterval.point, RatInterval.width, min_eq_left h, max_eq_right h] ring have him : ((RatInterval.point radius).mul I.im).width = radius * I.im.width := by have h := mul_le_mul_of_nonneg_left I.im.lo_le_hi hradius simp [RatInterval.mul, RatInterval.point, RatInterval.width, min_eq_left h, max_eq_right h] ring change max ((RatInterval.point radius).mul I.re).width ((RatInterval.point radius).mul I.im).width ≤ radius * max I.re.width I.im.width rw [hre, him, ← mul_max_of_nonneg I.re.width I.im.width hradius]
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.circleNode_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:452
  • circleNode_schedule_correspondence theorem — For a rational radius, a schedule, and node and operation ordinals, the manifest's stored schedule data and circle-node construction agree definitionally with the supplied schedule.
    radius :
    ℚ
    schedule :
    Schedule
    k operation :
    ℕ
    conclusion 1
    (circleNodeManifestEntry schedule k operation).schedule.operationCount
    = schedule.operationCount
    conclusion 2
    (circleNodeManifestEntry schedule k operation).schedule.inputPrecision
    = schedule.inputPrecision
    conclusion 3
    (circleNodeManifestEntry schedule k operation).schedule.fuel = schedule.fuel
    conclusion 4
    (circleNodeManifestEntry schedule k operation).schedule.mesh = schedule.mesh
    conclusion 5
    circleNode radius (circleNodeManifestEntry schedule k operation).schedule k
    = circleNode radius schedule k
    Proof (Lean source)
    theorem circleNode_schedule_correspondence (radius : ℚ) (schedule : Schedule) (k operation : ℕ) : (circleNodeManifestEntry schedule k operation).schedule.operationCount = schedule.operationCount ∧ (circleNodeManifestEntry schedule k operation).schedule.inputPrecision = schedule.inputPrecision ∧ (circleNodeManifestEntry schedule k operation).schedule.fuel = schedule.fuel ∧ (circleNodeManifestEntry schedule k operation).schedule.mesh = schedule.mesh ∧ circleNode radius (circleNodeManifestEntry schedule k operation).schedule k = circleNode radius schedule k := by exact ⟨rfl, rfl, rfl, rfl, rfl⟩
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.circleNode_schedule_correspondence · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/CircleSchedule.lean:475
Contour­Program 20 core · 0 supporting This module packages supplied interval extensions of numerator and denominator maps into contour programs, together with uniform value bounds, node boxes and node-error propagation bounds, denominator-separation certific ★ nodeManifest_spec

Certified finite contour programs

This module packages supplied interval extensions of numerator and denominator maps into contour programs, together with uniform value bounds, node boxes and node-error propagation bounds, denominator-separation certificates, scheduled programs, and rectangles for the normalized circle integrand at every mesh endpoint. Feeding those rectangles to deterministic trapezoidal quadrature, and the final containment-and-width certificate certified_contour_evaluation, are in Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourEvaluation.

structure ContourProgram reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

A finite rational contour program consists of a certified interval extension of the numerator function and of the denominator function, together with a rational circle radius that is strictly positive.

Definition (Lean source)
Certified numerator interval extension.
numerator :
Certified denominator interval extension.
denominator :
Rational radius of the centered circle.
radius :
ℚ
The contour radius is strictly positive.
radius_pos :
0 < radius
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:26
def operationCount reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

For a contour program, the recorded operation-count metadata for one contour node is the sum of the supplied counts for its numerator and denominator maps plus two for guarded division and multiplication by the circle point.

Definition (Lean source)
program :
operationCount program :
ℕ
program.numerator.operationCount + program.denominator.operationCount + 2
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram.operationCount · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:39 · uses ContourProgram
def constantUnit reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

Given a rational real numerator coordinate, a rational imaginary numerator coordinate, a rational circle radius, and the condition that the radius is strictly positive, the constant-over-unit contour program has the indicated constant numerator, unit denominator, and radius.

Definition (Lean source)
numeratorRe numeratorIm radius :
ℚ
hradius :
0 < radius
constantUnit numeratorRe numeratorIm radius hradius :
clause 1
numerator := CertifiedComplexMap.constant numeratorRe numeratorIm
clause 2
denominator := CertifiedComplexMap.constant 1 0
clause 3
radius := radius
clause 4
radius_pos := hradius
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram.constantUnit · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:45 · uses ContourProgram
def nodeBox reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

For a contour program, a schedule, and a nonnegative node index, the node rectangle is the scheduled rational rectangle for the circle point at that index.

Definition (Lean source)
program :
schedule :
Schedule
k :
ℕ
nodeBox program schedule k :
circleNode program.radius schedule k
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram.nodeBox · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:53 · uses ComplexRatInterval , ContourProgram , Schedule
structure ContourValueBounds reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

Uniform semantic magnitude data for one contour program: a nonnegative bound that covers every real and imaginary coordinate of the exact numerator function everywhere on the circle, and a nonnegative bound that covers the denominator function likewise.

Definition (Lean source)
program :
Uniform coordinate magnitude bound for the exact numerator.
numerator :
ℚ
Uniform coordinate magnitude bound for the exact denominator.
denominator :
ℚ
The numerator magnitude bound is nonnegative.
numerator_nonneg :
0 ≤ numerator
The denominator magnitude bound is nonnegative.
denominator_nonneg :
0 ≤ denominator
Numerator coordinates satisfy the bound at every circle parameter.
numerator_bound :
∀ u ∈ Icc (0 : ℝ) 1,
max |(program.numerator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I))).re| |(program.numerator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I))).im|
≤ (numerator : ℝ)
Denominator coordinates satisfy the bound at every circle parameter.
denominator_bound :
∀ u ∈ Icc (0 : ℝ) 1,
max |(program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I))).re| |(program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I))).im|
≤ (denominator : ℝ)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourValueBounds · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:58 · uses ContourProgram
def mapWidthBounds reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

For a contour program and a rational common error target, the pair of map-width bounds consists of the target plus the target multiplied by the numerator map's width amplification, and the analogous quantity for the denominator map. These are width bounds for a nonnegative target, which is how the evaluation uses them (with a positive rational target); a negative target gives negative numbers.

Definition (Lean source)
program :
target :
ℚ
mapWidthBounds program target :
ℚ × ℚ
(target + program.numerator.amplification * target, target + program.denominator.amplification * target)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram.mapWidthBounds · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:87 · uses ContourProgram
def nodePropagationBound reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

For a contour program, uniform bounds on its numerator and denominator values, a rational separation bound, and a rational common error target, the node-error propagation bound is obtained by forming the two map-width bounds, adding the numerator bound to its width bound, adding the denominator bound to its width bound, forming a bound for the division numerator, forming its width bound, forming the denominator squared-modulus width bound, forming the quotient width bound, forming the quotient magnitude bound, and combining quotient and circle-point errors. The quotient terms divide by the separation, so this is a valid propagation bound only for positive separation, as assumed by the soundness results; at separation zero those terms are zero by the division convention.

Definition (Lean source)
program :
bounds :
separation target :
ℚ
nodePropagationBound program bounds separation target :
ℚ
widths :
program.mapWidthBounds target
numeratorMax :
bounds.numerator + widths.1
denominatorMax :
bounds.denominator + widths.2
divisionNumeratorMax :
2 * numeratorMax * denominatorMax
divisionNumeratorWidth :
2 * (numeratorMax * widths.2 + denominatorMax * widths.1)
denominatorNormWidth :
4 * denominatorMax * widths.2
quotientWidth :
divisionNumeratorMax * denominatorNormWidth / separation ^ 2
+ divisionNumeratorWidth / separation
quotientMax :
divisionNumeratorMax / separation
2 * (quotientMax * target + (program.radius + target) * quotientWidth)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram.nodePropagationBound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:92 · uses ContourProgram , ContourValueBounds
def nodeScale reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

For a contour program, uniform bounds on its numerator and denominator values, and a positive rational separation bound, the node-error scale is one plus the absolute value of the node-error propagation bound evaluated at target one.

Definition (Lean source)
program :
bounds :
separation :
nodeScale program bounds separation :
ℚ
|program.nodePropagationBound bounds separation.1 1| + 1
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram.nodeScale · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:108 · uses ContourProgram , ContourValueBounds , PosRat
def canonicalNodeTarget reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

For a contour program, uniform bounds on its numerator and denominator values, a positive rational separation bound, and a positive rational tolerance, the canonical node target is the smaller of one and the tolerance divided by three times the node-error scale.

Definition (Lean source)
program :
bounds :
separation tolerance :
canonicalNodeTarget program bounds separation tolerance :
⟨min 1 (tolerance.1 / (3 * program.nodeScale bounds separation)), by apply lt_min (by norm_num) apply div_pos tolerance.2 dsimp [ContourProgram.nodeScale] linarith [abs_nonneg (program.nodePropagationBound bounds separation.1 1)]⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram.canonicalNodeTarget · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:113 · uses ContourProgram , ContourValueBounds , PosRat
def constantUnitBounds reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

Given a rational real numerator coordinate, a rational imaginary numerator coordinate, a rational circle radius, and the condition that the radius is strictly positive, the value bounds for the constant-over-unit contour program bound its numerator coordinates by the larger absolute numerator coordinate and its denominator coordinates by one.

Definition (Lean source)
numeratorRe numeratorIm radius :
ℚ
hradius :
0 < radius
constantUnitBounds numeratorRe numeratorIm radius hradius :
ContourValueBounds (ContourProgram.constantUnit numeratorRe numeratorIm radius hradius)
by refine { numerator := max |numeratorRe| |numeratorIm| denominator := 1 numerator_nonneg := (abs_nonneg numeratorRe).trans (le_max_left _ _) denominator_nonneg := by norm_num numerator_bound := ?_ denominator_bound := ?_ } · intro u hu simp only [ContourProgram.constantUnit, CertifiedComplexMap.constant] norm_num · intro u hu simp only [ContourProgram.constantUnit, CertifiedComplexMap.constant] norm_num
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram.constantUnitBounds · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:312 · uses constantUnit , ContourValueBounds
structure DenominatorCertificate reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

A denominator certificate for a contour program under a fixed schedule provides a common squared-modulus separation bound that is strictly positive, together with the guarantees that every mesh endpoint's denominator interval evaluation is bounded away from zero and that the same separation bound lies below every such endpoint's lower squared-modulus bound.

Definition (Lean source)
program :
schedule :
Schedule
Common positive squared-modulus separation.
separation :
ℚ
The common separation is strictly positive.
separation_pos :
0 < separation
Every endpoint denominator rectangle is away from zero.
away :
∀ k
if
k ≤ schedule.mesh
then
(ComplexRatInterval.normSq (program.denominator.eval (program.nodeBox schedule k) schedule.fuel)).AwayFromZero
The same rational separation lies below every squared-modulus lower endpoint.
lower :
∀ k
if
k ≤ schedule.mesh
then
separation
≤ (ComplexRatInterval.normSq (program.denominator.eval (program.nodeBox schedule k) schedule.fuel)).lo
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.DenominatorCertificate · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:331 · uses ContourProgram , Schedule
structure CertifiedProgramSchedule reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

A certified program schedule packages an exact schedule for evaluating a given contour program to a stated separation bound, together with the guarantees that its recorded operation count matches the program's recorded count, a common positive error target selected canonically from the tolerance, value bounds, and separation, an input precision equal to the uniform circle precision for that target, and that its fuel dominates the circle-exponential fuel requirement, the numerator's algorithmic-error modulus, and the denominator's algorithmic-error modulus, while the compositional arithmetic propagation bound fits within the schedule's node budget.

Definition (Lean source)
program :
bounds :
separation :
The exact schedule consumed by evaluation, manifests, and specifications.
schedule :
Schedule
The schedule operation count equals the program's recorded count.
operationCount_eq :
schedule.operationCount = program.operationCount
The common positive target for circle and map approximation errors.
target :
The target is definitionally selected from tolerance and propagation scale.
target_eq :
target = program.canonicalNodeTarget bounds separation schedule.tolerance
Input precision is the explicit uniform circle precision for this target.
inputPrecision_eq :
schedule.inputPrecision = circleInputPrecision program.radius target
Scheduled fuel dominates the circle exponential fuel requirement.
circleFuel_le :
circleExpFuel program.radius schedule.mesh target ≤ schedule.fuel
Scheduled fuel dominates the numerator algorithmic-error modulus.
numeratorFuel_le :
program.numerator.errorModulus target ≤ schedule.fuel
Scheduled fuel dominates the denominator algorithmic-error modulus.
denominatorFuel_le :
program.denominator.errorModulus target ≤ schedule.fuel
The compositional arithmetic bound fits in the schedule's node budget.
propagation_le :
program.nodePropagationBound bounds separation.1 target.1 ≤ schedule.nodeBudget
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedProgramSchedule · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:350 · uses ContourProgram , ContourValueBounds , PosRat
def nodeManifest reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

For a contour program, its value bounds, a positive separation target, a certified schedule, and a nonnegative node index, the node manifest lists one schedule entry for each ordinal below the program's recorded operation count.

Definition (Lean source)
separation :
scheduled :
CertifiedProgramSchedule program bounds separation
k :
ℕ
nodeManifest program scheduled k :
List.ofFn fun operation : Fin program.operationCount
=> circleNodeManifestEntry scheduled.schedule k operation
theorem nodeManifest_spec reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

For a contour program, its value bounds, a target error separation, a certified schedule for that program, and a stage index k, the node manifest has one entry per recorded operation ordinal and every entry stores the schedule with its matching count.

Formal statement
separation :
scheduled :
CertifiedProgramSchedule program bounds separation
k :
ℕ
conclusion 1
(program.nodeManifest scheduled k).length = program.operationCount
conclusion 2
event ∈ program.nodeManifest scheduled k :
event.schedule = scheduled.schedule
event.schedule.operationCount = program.operationCount
Proof (Lean source)
theorem ContourProgram.nodeManifest_spec (program : ContourProgram) {bounds : ContourValueBounds program} {separation : PosRat} (scheduled : CertifiedProgramSchedule program bounds separation) (k : ℕ) : (program.nodeManifest scheduled k).length = program.operationCount ∧ ∀ event ∈ program.nodeManifest scheduled k, event.schedule = scheduled.schedule ∧ event.schedule.operationCount = program.operationCount := by constructor · simp [ContourProgram.nodeManifest] · intro event hevent simp only [ContourProgram.nodeManifest, List.mem_ofFn] at hevent obtain ⟨operation, rfl⟩ := hevent exact ⟨rfl, scheduled.operationCount_eq⟩
def canonicalScheduled reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

Given a contour program, uniform bounds on its numerator and denominator values, a positive rational separation bound, a positive rational tolerance, a rational Lipschitz constant, and the condition that this constant is nonnegative, the canonical certified schedule derives its recorded operation count, input precision, fuel, mesh, and error budgets from these quantities.

Definition (Lean source)
program :
bounds :
separation tolerance :
lipschitzConstant :
ℚ
hlipschitz :
0 ≤ lipschitzConstant
canonicalScheduled program bounds separation tolerance lipschitzConstant hlipschitz :
CertifiedProgramSchedule program bounds separation
by let base := Schedule.canonical tolerance program.operationCount lipschitzConstant hlipschitz let target := program.canonicalNodeTarget bounds separation tolerance let inputPrecision := circleInputPrecision program.radius target let fuel := max (circleExpFuel program.radius base.mesh target) (max (program.numerator.errorModulus target) (program.denominator.errorModulus target)) let schedule : Schedule := { base with inputPrecision := inputPrecision, fuel := fuel } exact { schedule := schedule operationCount_eq := by rfl target := target target_eq := by rfl inputPrecision_eq := by rfl circleFuel_le := by dsimp [schedule, fuel] exact le_max_left _ _ numeratorFuel_le := by dsimp [schedule, fuel] exact (le_max_left _ _).trans (le_max_right _ _) denominatorFuel_le := by dsimp [schedule, fuel] exact (le_max_right _ _).trans (le_max_right _ _) propagation_le := by have htarget_nonneg : 0 ≤ target.1 := target.2.le have htarget_le_one : target.1 ≤ 1 := by dsimp [target, ContourProgram.canonicalNodeTarget] exact min_le_left _ _ have htarget_le : target.1 ≤ tolerance.1 / (3 * program.nodeScale bounds separation) := by dsimp [target, ContourProgram.canonicalNodeTarget] exact min_le_right _ _ have hscale : 0 < program.nodeScale bounds separation := by dsimp [ContourProgram.nodeScale] linarith [abs_nonneg (program.nodePropagationBound bounds separation.1 1)] calc program.nodePropagationBound bounds separation.1 target.1 ≤ program.nodeScale bounds separation * target.1 := program.nodePropagationBound_le_scale_mul bounds separation htarget_nonneg htarget_le_one _ ≤ program.nodeScale bounds separation * (tolerance.1 / (3 * program.nodeScale bounds separation)) := mul_le_mul_of_nonneg_left htarget_le hscale.le _ = tolerance.1 / 3 := by field_simp _ = schedule.nodeBudget := by rfl }
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram.canonicalScheduled · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:411 · uses CertifiedProgramSchedule , ContourProgram , ContourValueBounds , PosRat
def constantUnitCertificate reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

Given a rational real numerator coordinate, a rational imaginary numerator coordinate, a rational circle radius, the condition that the radius is strictly positive, and a schedule, the constant-over-unit denominator certificate certifies separation one and a squared-modulus lower bound of one at every scheduled endpoint.

Definition (Lean source)
numeratorRe numeratorIm radius :
ℚ
hradius :
0 < radius
schedule :
Schedule
constantUnitCertificate numeratorRe numeratorIm radius hradius schedule :
DenominatorCertificate (ContourProgram.constantUnit numeratorRe numeratorIm radius hradius) schedule
clause 1
separation := 1
clause 2
separation_pos := by norm_num
clause 3
away := by intro k hk right norm_num [ContourProgram.constantUnit, CertifiedComplexMap.constant, ComplexRatInterval.normSq, RatInterval.sq, RatInterval.add, ComplexRatInterval.point, RatInterval.point]
clause 4
lower := by intro k hk norm_num [ContourProgram.constantUnit, CertifiedComplexMap.constant, ComplexRatInterval.normSq, RatInterval.sq, RatInterval.add, ComplexRatInterval.point, RatInterval.point]
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram.constantUnitCertificate · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:468 · uses constantUnit , DenominatorCertificate , Schedule
def integrandNodeFin reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

For a contour program, a schedule, a certificate that its denominator is separated from zero at the scheduled endpoints, and an endpoint index among the mesh plus one endpoints, the finite-index integrand node rectangle is the guarded quotient of the evaluated numerator and denominator rectangles multiplied by the node rectangle.

Definition (Lean source)
program :
schedule :
Schedule
certificate :
DenominatorCertificate program schedule
k :
Fin (schedule.mesh + 1)
integrandNodeFin program schedule certificate k :
node :
program.nodeBox schedule k
numerator :
program.numerator.eval node schedule.fuel
denominator :
program.denominator.eval node schedule.fuel
ComplexRatInterval.mul (ComplexRatInterval.div numerator denominator (certificate.away k (le_of_lt_succ k.isLt))) node
def integrandNodes reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

For a contour program, a schedule, a certificate that its denominator is separated from zero at the scheduled endpoints, and a nonnegative index, the total integrand-node rectangle is the guarded evaluated quotient times the node rectangle when the index is at most the mesh size, and otherwise is the terminal finite-index node rectangle.

Definition (Lean source)
program :
schedule :
Schedule
certificate :
DenominatorCertificate program schedule
k :
ℕ
integrandNodes program schedule certificate k :
if hk : k
≤ schedule.mesh then let node := program.nodeBox schedule k let numerator := program.numerator.eval node schedule.fuel let denominator := program.denominator.eval node schedule.fuel ComplexRatInterval.mul (ComplexRatInterval.div numerator denominator (certificate.away k hk)) node else program.integrandNodeFin schedule certificate ⟨schedule.mesh, lt_succ_self _⟩
def normalizedIntegrand reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

The normalized exact integrand for a contour program at a real circle parameter is the exact numerator-to-denominator quotient at the corresponding circle point, multiplied by that point; the evaluation schedule is accepted to align this function with scheduled enclosures but does not affect its value.

Definition (Lean source)
program :
schedule :
Schedule
u :
ℝ
normalizedIntegrand program schedule u :
ℂ
z :
(program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I) (: ℂ)
(program.numerator.value z / program.denominator.value z) * z
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram.normalizedIntegrand · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:511 · uses ContourProgram , Schedule
def normalizedContourIntegral reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

For a contour program, the normalized contour integral is its circle contour integral for the exact numerator-to-denominator quotient, divided by 2πi2\pi i. It is the contour integral of the quotient when the denominator does not vanish on the circle (as guaranteed by the separation hypotheses of the evaluation theorems); otherwise the quotient and the integral are Lean's totalized values, which can be zero.

Definition (Lean source)
program :
normalizedContourIntegral program :
ℂ
CircleMesh.circleContourIntegral (fun z => program.numerator.value z / program.denominator.value z) 0 program.radius / (((2 : ℝ) * Real.pi : ℂ) * I)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram.normalizedContourIntegral · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourProgram.lean:521 · uses ContourProgram
Contour­Evaluation 3 core · 8 supporting This module proves that scheduled rational contour quadrature encloses the normalized circle integral and attains its requested real-coordinate width. ★ certified_contour_evaluation

Certified finite contour evaluation

This module proves that scheduled rational contour quadrature encloses the normalized circle integral and attains its requested real-coordinate width.

def evaluate reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.ContourProgram

For a contour program, a schedule, and a certificate that its denominator is separated from zero at the scheduled endpoints, the evaluated contour rectangle is the deterministic integral enclosure of its integrand-node rectangles, widened symmetrically by half the schedule's quadrature budget.

Definition (Lean source)
program :
schedule :
Schedule
certificate :
DenominatorCertificate program schedule
evaluate program schedule certificate :
(CircleMesh.integralEnclosure (program.integrandNodes schedule certificate) schedule.lipschitzConstant schedule.lipschitzConstant_nonneg schedule.mesh schedule.mesh_pos).expand (schedule.quadratureBudget / 2) (div_nonneg schedule.quadratureBudget_nonneg (by norm_num))
theorem certified_contour_evaluation reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

Certified finite-precision evaluation of a contour integral. Fix a contour-integral program, value bounds for it, a target separation, a certified mesh schedule built to meet that target, and a certificate that the denominator stays bounded away from zero, whose guaranteed separation covers the target one; assume also that the program's denominator never vanishes anywhere on the parametrized circle and the normalized integrand is Lipschitz in the circle parameter with the schedule's constant. Then the rational rectangle obtained by evaluating the program both contains the true normalized contour integral and has real-part width at most the schedule's requested tolerance.

Formal statement
program :
bounds :
separation :
scheduled :
CertifiedProgramSchedule program bounds separation
certificate :
DenominatorCertificate program scheduled.schedule
hseparation :
separation.1 ≤ certificate.separation
hden :
∀ u ∈ Icc (0 : ℝ) 1,
program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I))
≠ 0
hLip :
∀ s ∈ Icc (0 : ℝ) 1,
∀ t ∈ Icc (0 : ℝ) 1,
‖program.normalizedIntegrand scheduled.schedule s - program.normalizedIntegrand scheduled.schedule t‖
≤ (scheduled.schedule.lipschitzConstant : ℝ) * |s - t|
conclusion 1
(program.evaluate scheduled.schedule certificate).Contains program.normalizedContourIntegral
conclusion 2
(program.evaluate scheduled.schedule certificate).re.width
≤ scheduled.schedule.tolerance.1
Proof (Lean source)
theorem certified_contour_evaluation (program : ContourProgram) (bounds : ContourValueBounds program) (separation : PosRat) (scheduled : CertifiedProgramSchedule program bounds separation) (certificate : DenominatorCertificate program scheduled.schedule) (hseparation : separation.1 ≤ certificate.separation) (hden : ∀ u ∈ Icc (0 : ℝ) 1, program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I)) ≠ 0) (hLip : ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, ‖program.normalizedIntegrand scheduled.schedule s - program.normalizedIntegrand scheduled.schedule t‖ ≤ (scheduled.schedule.lipschitzConstant : ℝ) * |s - t|) : (program.evaluate scheduled.schedule certificate).Contains program.normalizedContourIntegral ∧ (program.evaluate scheduled.schedule certificate).re.width ≤ scheduled.schedule.tolerance.1 := by constructor · exact evaluate_contains program scheduled.schedule certificate hden hLip · exact (le_max_left _ _).trans (evaluate_width program bounds separation scheduled certificate hseparation)
def inverseMaxTolerance reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

For a nonnegative integer, the reciprocal-maximum tolerance is the positive rational number 1/max⁡(n,1)1/\max(n,1).

Definition (Lean source)
n :
ℕ
inverseMaxTolerance n :
⟨1 / (max n 1 : ℚ), by positivity⟩
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.inverseMaxTolerance · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourEvaluation.lean:433 · uses PosRat
8 supporting declarations (lemmas, instances)
  • normalizedContourIntegral_eq theorem — The canceled unit-parameter integral equals the normalized exact circle contour integral whenever the denominator is nonzero along the circle.
    program :
    schedule :
    Schedule
    hden :
    ∀ u ∈ Icc (0 : ℝ) 1,
    program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I))
    ≠ 0
    program.normalizedContourIntegral
    = ∫ u in (0 : ℝ)..1, program.normalizedIntegrand schedule u
    Proof (Lean source)
    theorem normalizedContourIntegral_eq (program : ContourProgram) (schedule : Schedule) (hden : ∀ u ∈ Icc (0 : ℝ) 1, program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * Real.pi * u) * I)) ≠ 0) : program.normalizedContourIntegral = ∫ u in (0 : ℝ)..1, program.normalizedIntegrand schedule u := by rw [ContourProgram.normalizedContourIntegral, CircleMesh.circleContourIntegral] calc (∫ u in (0 : ℝ)..1, CircleMesh.circleIntegrand (fun z => program.numerator.value z / program.denominator.value z) 0 program.radius u) / (((2 : ℝ) * Real.pi : ℂ) * I) = ∫ u in (0 : ℝ)..1, CircleMesh.circleIntegrand (fun z => program.numerator.value z / program.denominator.value z) 0 program.radius u / (((2 : ℝ) * Real.pi : ℂ) * I) := (intervalIntegral.integral_div _ _).symm _ = ∫ u in (0 : ℝ)..1, program.normalizedIntegrand schedule u := by apply intervalIntegral.integral_congr intro u hu simp only [CircleMesh.circleIntegrand, CircleMesh.circleMap, circleMap_zero, CircleMesh.circleTangent, ContourProgram.normalizedIntegrand] have htwoPi : (((2 : ℝ) * Real.pi : ℂ) * I) ≠ 0 := by exact mul_ne_zero (mul_ne_zero (by norm_num) (Complex.ofReal_ne_zero.mpr Real.pi_ne_zero)) Complex.I_ne_zero have huIcc : u ∈ Icc (0 : ℝ) 1 := by simpa [uIcc_of_le (by norm_num : (0 : ℝ) ≤ 1)] using hu have hdenu := hden u huIcc field_simp [htwoPi, hdenu] norm_num ring_nf
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.normalizedContourIntegral_eq · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourEvaluation.lean:19
  • integrandNodes_sound theorem — Every certified finite endpoint rectangle contains the exact normalized integrand.
    program :
    schedule :
    Schedule
    certificate :
    DenominatorCertificate program schedule
    k :
    ℕ
    hk :
    k ≤ schedule.mesh
    (program.integrandNodes schedule certificate k).Contains (program.normalizedIntegrand schedule (CircleMesh.meshPoint schedule.mesh k))
    Proof (Lean source)
    theorem integrandNodes_sound (program : ContourProgram) (schedule : Schedule) (certificate : DenominatorCertificate program schedule) {k : ℕ} (hk : k ≤ schedule.mesh) : (program.integrandNodes schedule certificate k).Contains (program.normalizedIntegrand schedule (CircleMesh.meshPoint schedule.mesh k)) := by have hnode : (program.nodeBox schedule k).Contains (exactCircleNode program.radius schedule k) := by exact circleNode_sound program.radius schedule have hnum := program.numerator.sound hnode schedule.fuel have hden := program.denominator.sound hnode schedule.fuel have hquot := ComplexRatInterval.div_sound (certificate.away k hk) hnum hden have hmul := ComplexRatInterval.mul_sound hquot hnode simpa [ContourProgram.integrandNodes, hk, ContourProgram.nodeBox, ContourProgram.normalizedIntegrand, exactCircleNode, CircleMesh.meshPoint] using hmul
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.integrandNodes_sound · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourEvaluation.lean:56
  • integrandNodes_width_le_propagation theorem — The scheduled node-width bound follows compositionally from circle input precision, both map error moduli, their amplification fields, rational magnitude bounds, guarded-division separation, and primitive width lemmas.
    program :
    bounds :
    separation :
    scheduled :
    CertifiedProgramSchedule program bounds separation
    certificate :
    DenominatorCertificate program scheduled.schedule
    hseparation :
    separation.1 ≤ certificate.separation
    k :
    ℕ
    hk :
    k ≤ scheduled.schedule.mesh
    ComplexRatInterval.width (program.integrandNodes scheduled.schedule certificate k)
    ≤ program.nodePropagationBound bounds separation.1 scheduled.target.1
    Proof (Lean source)
    theorem integrandNodes_width_le_propagation (program : ContourProgram) (bounds : ContourValueBounds program) (separation : PosRat) (scheduled : CertifiedProgramSchedule program bounds separation) (certificate : DenominatorCertificate program scheduled.schedule) (hseparation : separation.1 ≤ certificate.separation) {k : ℕ} (hk : k ≤ scheduled.schedule.mesh) : ComplexRatInterval.width (program.integrandNodes scheduled.schedule certificate k) ≤ program.nodePropagationBound bounds separation.1 scheduled.target.1 := by let schedule := scheduled.schedule let node := program.nodeBox schedule k let numerator := program.numerator.eval node schedule.fuel let denominator := program.denominator.eval node schedule.fuel let numeratorWidth := scheduled.target.1 + program.numerator.amplification * scheduled.target.1 let denominatorWidth := scheduled.target.1 + program.denominator.amplification * scheduled.target.1 let numeratorMax := bounds.numerator + numeratorWidth let denominatorMax := bounds.denominator + denominatorWidth let divisionMax := 2 * numeratorMax * denominatorMax let divisionWidth := 2 * (numeratorMax * denominatorWidth + denominatorMax * numeratorWidth) let normWidth := 4 * denominatorMax * denominatorWidth let quotientWidth := divisionMax * normWidth / separation.1 ^ 2 + divisionWidth / separation.1 have hnodeWidth : ComplexRatInterval.width node ≤ scheduled.target.1 := by exact circleNode_width_at_selected_precision program.radius program.radius_pos.le schedule scheduled.target scheduled.inputPrecision_eq scheduled.circleFuel_le hk have hnodeContains : node.Contains (exactCircleNode program.radius schedule k) := by exact circleNode_sound program.radius schedule have hnumContains : numerator.Contains (program.numerator.value (exactCircleNode program.radius schedule k)) := by exact program.numerator.sound hnodeContains schedule.fuel have hdenContains : denominator.Contains (program.denominator.value (exactCircleNode program.radius schedule k)) := by exact program.denominator.sound hnodeContains schedule.fuel have hnumAlgorithm : program.numerator.algorithmError schedule.fuel ≤ scheduled.target.1 := by exact CertifiedComplexMap.algorithmError_le_of_modulus scheduled.numeratorFuel_le have hdenAlgorithm : program.denominator.algorithmError schedule.fuel ≤ scheduled.target.1 := by exact CertifiedComplexMap.algorithmError_le_of_modulus scheduled.denominatorFuel_le have hnumWidth : ComplexRatInterval.width numerator ≤ numeratorWidth := by calc ComplexRatInterval.width numerator ≤ program.numerator.algorithmError schedule.fuel + program.numerator.amplification * ComplexRatInterval.width node := program.numerator.width_le node schedule.fuel _ ≤ scheduled.target.1 + program.numerator.amplification * scheduled.target.1 := by exact add_le_add hnumAlgorithm (mul_le_mul_of_nonneg_left hnodeWidth program.numerator.amplification_nonneg) _ = numeratorWidth := rfl have hdenWidth : ComplexRatInterval.width denominator ≤ denominatorWidth := by calc ComplexRatInterval.width denominator ≤ program.denominator.algorithmError schedule.fuel + program.denominator.amplification * ComplexRatInterval.width node := program.denominator.width_le node schedule.fuel _ ≤ scheduled.target.1 + program.denominator.amplification * scheduled.target.1 := by exact add_le_add hdenAlgorithm (mul_le_mul_of_nonneg_left hnodeWidth program.denominator.amplification_nonneg) _ = denominatorWidth := rfl have hmesh : CircleMesh.meshPoint schedule.mesh k ∈ Icc (0 : ℝ) 1 := CircleMesh.meshPoint_mem schedule.mesh_pos hk have hnumValueBound : max |(program.numerator.value (exactCircleNode program.radius schedule k)).re| |(program.numerator.value (exactCircleNode program.radius schedule k)).im| ≤ (bounds.numerator : ℝ) := by simpa [exactCircleNode, CircleMesh.meshPoint] using bounds.numerator_bound (CircleMesh.meshPoint schedule.mesh k) hmesh have hdenValueBound : max |(program.denominator.value (exactCircleNode program.radius schedule k)).re| |(program.denominator.value (exactCircleNode program.radius schedule k)).im| ≤ (bounds.denominator : ℝ) := by simpa [exactCircleNode, CircleMesh.meshPoint] using bounds.denominator_bound (CircleMesh.meshPoint schedule.mesh k) hmesh have hnumMax : ComplexRatInterval.maxAbs numerator ≤ numeratorMax := by exact (ComplexRatInterval.maxAbs_le_of_contains_width hnumContains hnumValueBound hnumWidth) have hdenMax : ComplexRatInterval.maxAbs denominator ≤ denominatorMax := by exact (ComplexRatInterval.maxAbs_le_of_contains_width hdenContains hdenValueBound hdenWidth) have htarget0 : 0 ≤ scheduled.target.1 := scheduled.target.2.le have hnWidth0 : 0 ≤ numeratorWidth := by dsimp [numeratorWidth] nlinarith [mul_nonneg program.numerator.amplification_nonneg htarget0] have hdWidth0 : 0 ≤ denominatorWidth := by dsimp [denominatorWidth] nlinarith [mul_nonneg program.denominator.amplification_nonneg htarget0] have hnMax0 : 0 ≤ numeratorMax := by dsimp [numeratorMax] linarith [bounds.numerator_nonneg] have hdMax0 : 0 ≤ denominatorMax := by dsimp [denominatorMax] linarith [bounds.denominator_nonneg] have hdivisionMax0 : 0 ≤ divisionMax := by dsimp [divisionMax] positivity have hdivisionWidth0 : 0 ≤ divisionWidth := by dsimp [divisionWidth] positivity have hnormWidth0 : 0 ≤ normWidth := by dsimp [normWidth] positivity have hnumDenMax : ComplexRatInterval.maxAbs (ComplexRatInterval.mul numerator (ComplexRatInterval.conj denominator)) ≤ divisionMax := by calc ComplexRatInterval.maxAbs (ComplexRatInterval.mul numerator (ComplexRatInterval.conj denominator)) ≤ 2 * ComplexRatInterval.maxAbs numerator * ComplexRatInterval.maxAbs (ComplexRatInterval.conj denominator) := ComplexRatInterval.mul_maxAbs numerator (ComplexRatInterval.conj denominator) _ = 2 * ComplexRatInterval.maxAbs numerator * ComplexRatInterval.maxAbs denominator := by rw [ComplexRatInterval.maxAbs_conj] _ ≤ 2 * numeratorMax * denominatorMax := by nlinarith [mul_le_mul hnumMax hdenMax ((abs_nonneg denominator.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _))) hnMax0] _ = divisionMax := rfl have hnumDenWidth : ComplexRatInterval.width (ComplexRatInterval.mul numerator (ComplexRatInterval.conj denominator)) ≤ divisionWidth := by calc ComplexRatInterval.width (ComplexRatInterval.mul numerator (ComplexRatInterval.conj denominator)) ≤ 2 * (ComplexRatInterval.maxAbs numerator * ComplexRatInterval.width (ComplexRatInterval.conj denominator) + ComplexRatInterval.maxAbs (ComplexRatInterval.conj denominator) * ComplexRatInterval.width numerator) := ComplexRatInterval.mul_width numerator (ComplexRatInterval.conj denominator) _ = 2 * (ComplexRatInterval.maxAbs numerator * ComplexRatInterval.width denominator + ComplexRatInterval.maxAbs denominator * ComplexRatInterval.width numerator) := by rw [ComplexRatInterval.width_conj, ComplexRatInterval.maxAbs_conj] _ ≤ 2 * (numeratorMax * denominatorWidth + denominatorMax * numeratorWidth) := by have hnumA0 : 0 ≤ ComplexRatInterval.maxAbs numerator := (abs_nonneg numerator.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hdenA0 : 0 ≤ ComplexRatInterval.maxAbs denominator := (abs_nonneg denominator.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) nlinarith [mul_le_mul hnumMax hdenWidth (show 0 ≤ ComplexRatInterval.width denominator from (RatInterval.width_nonneg denominator.re).trans (le_max_left _ _)) hnMax0, mul_le_mul hdenMax hnumWidth (show 0 ≤ ComplexRatInterval.width numerator from (RatInterval.width_nonneg numerator.re).trans (le_max_left _ _)) hdMax0] _ = divisionWidth := rfl have hnormWidth : (ComplexRatInterval.normSq denominator).width ≤ normWidth := by calc (ComplexRatInterval.normSq denominator).width ≤ 4 * ComplexRatInterval.maxAbs denominator * ComplexRatInterval.width denominator := ComplexRatInterval.normSq_width denominator _ ≤ 4 * denominatorMax * denominatorWidth := by nlinarith [mul_le_mul hdenMax hdenWidth (show 0 ≤ ComplexRatInterval.width denominator from (RatInterval.width_nonneg denominator.re).trans (le_max_left _ _)) hdMax0] _ = normWidth := rfl have hsep : separation.1 ≤ (ComplexRatInterval.normSq denominator).lo := hseparation.trans (certificate.lower k hk) have hquotientWidth : ComplexRatInterval.width (ComplexRatInterval.div numerator denominator (certificate.away k hk)) ≤ quotientWidth := by calc _ ≤ ComplexRatInterval.maxAbs (ComplexRatInterval.mul numerator (ComplexRatInterval.conj denominator)) * (ComplexRatInterval.normSq denominator).width / separation.1 ^ 2 + ComplexRatInterval.width (ComplexRatInterval.mul numerator (ComplexRatInterval.conj denominator)) / separation.1 := ComplexRatInterval.div_width (certificate.away k hk) separation.2 hsep _ ≤ divisionMax * normWidth / separation.1 ^ 2 + divisionWidth / separation.1 := by have hproduct := mul_le_mul hnumDenMax hnormWidth (RatInterval.width_nonneg (ComplexRatInterval.normSq denominator)) hdivisionMax0 exact add_le_add (div_le_div_of_nonneg_right hproduct (sq_nonneg separation.1)) (div_le_div_of_nonneg_right hnumDenWidth separation.2.le) _ = quotientWidth := rfl have hquotientMax : ComplexRatInterval.maxAbs (ComplexRatInterval.div numerator denominator (certificate.away k hk)) ≤ divisionMax / separation.1 := by exact (ComplexRatInterval.div_maxAbs (certificate.away k hk) separation.2 hsep).trans (div_le_div_of_nonneg_right hnumDenMax separation.2.le) have hexactNorm : ‖exactCircleNode program.radius schedule k‖ = program.radius := by have hradius0 : (0 : ℝ) ≤ program.radius := by exact_mod_cast program.radius_pos.le simp [exactCircleNode, Complex.norm_exp, abs_of_nonneg hradius0] have hnodeValueBound : max |(exactCircleNode program.radius schedule k).re| |(exactCircleNode program.radius schedule k).im| ≤ (program.radius : ℝ) := by exact max_le ((Complex.abs_re_le_norm _).trans_eq hexactNorm) ((Complex.abs_im_le_norm _).trans_eq hexactNorm) have hnodeMax : ComplexRatInterval.maxAbs node ≤ program.radius + scheduled.target.1 := by exact ComplexRatInterval.maxAbs_le_of_contains_width hnodeContains hnodeValueBound hnodeWidth have hquotientWidth0 : 0 ≤ quotientWidth := by dsimp [quotientWidth] exact add_nonneg (div_nonneg (mul_nonneg hdivisionMax0 hnormWidth0) (sq_nonneg separation.1)) (div_nonneg hdivisionWidth0 separation.2.le) rw [ContourProgram.integrandNodes, dif_pos hk] change ComplexRatInterval.width (ComplexRatInterval.mul (ComplexRatInterval.div numerator denominator (certificate.away k hk)) node) ≤ _ calc ComplexRatInterval.width (ComplexRatInterval.mul (ComplexRatInterval.div numerator denominator (certificate.away k hk)) node) ≤ 2 * (ComplexRatInterval.maxAbs (ComplexRatInterval.div numerator denominator (certificate.away k hk)) * ComplexRatInterval.width node + ComplexRatInterval.maxAbs node * ComplexRatInterval.width (ComplexRatInterval.div numerator denominator (certificate.away k hk))) := ComplexRatInterval.mul_width _ _ _ ≤ 2 * ((divisionMax / separation.1) * scheduled.target.1 + (program.radius + scheduled.target.1) * quotientWidth) := by have hquotientA0 : 0 ≤ ComplexRatInterval.maxAbs (ComplexRatInterval.div numerator denominator (certificate.away k hk)) := (abs_nonneg (ComplexRatInterval.div numerator denominator (certificate.away k hk)).re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hnodeA0 : 0 ≤ ComplexRatInterval.maxAbs node := (abs_nonneg node.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) nlinarith [mul_le_mul hquotientMax hnodeWidth (show 0 ≤ ComplexRatInterval.width node from (RatInterval.width_nonneg node.re).trans (le_max_left _ _)) (div_nonneg hdivisionMax0 separation.2.le), -- … truncated; follow the source link for the rest …
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.integrandNodes_width_le_propagation · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourEvaluation.lean:72
  • denominator_ne_zero_at_nodes theorem — Denominator separation at all certified nodes implies nonvanishing of the exact denominator at all mesh endpoints.
    program :
    schedule :
    Schedule
    certificate :
    DenominatorCertificate program schedule
    k :
    ℕ
    hk :
    k ≤ schedule.mesh
    program.denominator.value (exactCircleNode program.radius schedule k) ≠ 0
    Proof (Lean source)
    theorem denominator_ne_zero_at_nodes (program : ContourProgram) (schedule : Schedule) (certificate : DenominatorCertificate program schedule) {k : ℕ} (hk : k ≤ schedule.mesh) : program.denominator.value (exactCircleNode program.radius schedule k) ≠ 0 := by have hnode : (program.nodeBox schedule k).Contains (exactCircleNode program.radius schedule k) := by exact circleNode_sound program.radius schedule have hden := program.denominator.sound hnode schedule.fuel have hnorm := ComplexRatInterval.normSq_sound hden have hnorm_ne : ‖program.denominator.value (exactCircleNode program.radius schedule k)‖ ^ 2 ≠ 0 := RatInterval.ne_zero_of_contains (certificate.away k hk) hnorm intro hz apply hnorm_ne simp [hz]
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.denominator_ne_zero_at_nodes · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourEvaluation.lean:343
  • evaluate_contains theorem — Under a Lipschitz bound and denominator nonvanishing on the full circle, the returned rational rectangle contains the normalized exact contour integral.
    program :
    schedule :
    Schedule
    certificate :
    DenominatorCertificate program schedule
    hden :
    ∀ u ∈ Icc (0 : ℝ) 1,
    program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I))
    ≠ 0
    hLip :
    ∀ s ∈ Icc (0 : ℝ) 1,
    ∀ t ∈ Icc (0 : ℝ) 1,
    ‖program.normalizedIntegrand schedule s - program.normalizedIntegrand schedule t‖
    ≤ (schedule.lipschitzConstant : ℝ) * |s - t|
    (program.evaluate schedule certificate).Contains program.normalizedContourIntegral
    Proof (Lean source)
    theorem evaluate_contains (program : ContourProgram) (schedule : Schedule) (certificate : DenominatorCertificate program schedule) (hden : ∀ u ∈ Icc (0 : ℝ) 1, program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I)) ≠ 0) (hLip : ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, ‖program.normalizedIntegrand schedule s - program.normalizedIntegrand schedule t‖ ≤ (schedule.lipschitzConstant : ℝ) * |s - t|) : (program.evaluate schedule certificate).Contains program.normalizedContourIntegral := by rw [normalizedContourIntegral_eq program schedule hden] apply ComplexRatInterval.expand_contains exact CircleMesh.integralEnclosure_sound schedule.lipschitzConstant_nonneg schedule.mesh_pos hLip (fun k hk => integrandNodes_sound program schedule certificate hk)
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.evaluate_contains · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourEvaluation.lean:361
  • evaluate_width theorem — Uniform scheduled node widths propagate through mesh and final widening, so both result coordinates fit within the three split budgets.
    program :
    bounds :
    separation :
    scheduled :
    CertifiedProgramSchedule program bounds separation
    certificate :
    DenominatorCertificate program scheduled.schedule
    hseparation :
    separation.1 ≤ certificate.separation
    ComplexRatInterval.width (program.evaluate scheduled.schedule certificate)
    ≤ scheduled.schedule.tolerance.1
    Proof (Lean source)
    theorem evaluate_width (program : ContourProgram) (bounds : ContourValueBounds program) (separation : PosRat) (scheduled : CertifiedProgramSchedule program bounds separation) (certificate : DenominatorCertificate program scheduled.schedule) (hseparation : separation.1 ≤ certificate.separation) : ComplexRatInterval.width (program.evaluate scheduled.schedule certificate) ≤ scheduled.schedule.tolerance.1 := by let schedule := scheduled.schedule have hcoordinate : ∀ k ≤ schedule.mesh, (program.integrandNodes schedule certificate k).re.width ≤ schedule.nodeBudget ∧ (program.integrandNodes schedule certificate k).im.width ≤ schedule.nodeBudget := by intro k hk have h := (integrandNodes_width_le_propagation program bounds separation scheduled certificate hseparation hk).trans scheduled.propagation_le exact ⟨(le_max_left _ _).trans h, (le_max_right _ _).trans h⟩ have hbase := CircleMesh.integralEnclosure_width schedule.lipschitzConstant_nonneg schedule.mesh_pos hcoordinate rw [ContourProgram.evaluate, ComplexRatInterval.width, ComplexRatInterval.expand, RatInterval.width_expand, RatInterval.width_expand] apply max_le · linarith [hbase.1, schedule.mesh_error_le, schedule.budget_sum_le] · linarith [hbase.2, schedule.mesh_error_le, schedule.budget_sum_le]
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.evaluate_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourEvaluation.lean:377
  • certified_contour_evaluation_inverseMax theorem — The evaluated contour rectangle has real-coordinate width at most the reciprocal of the larger of an integer and one for a contour program with uniform value bounds and a positive separation target, when its certified schedule uses that reciprocal tolerance. Here the integer determines the reciprocal rate, a denominator certificate is available and covers the target separation, the exact denominator never vanishes on the circle, and the normalized integrand obeys the scheduled Lipschitz bound.
    n :
    ℕ
    program :
    bounds :
    separation :
    scheduled :
    CertifiedProgramSchedule program bounds separation
    hschedule :
    scheduled.schedule.tolerance = inverseMaxTolerance n
    certificate :
    DenominatorCertificate program scheduled.schedule
    hseparation :
    separation.1 ≤ certificate.separation
    hden :
    ∀ u ∈ Icc (0 : ℝ) 1,
    program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I))
    ≠ 0
    hLip :
    ∀ s ∈ Icc (0 : ℝ) 1,
    ∀ t ∈ Icc (0 : ℝ) 1,
    ‖program.normalizedIntegrand scheduled.schedule s - program.normalizedIntegrand scheduled.schedule t‖
    ≤ (scheduled.schedule.lipschitzConstant : ℝ) * |s - t|
    (program.evaluate scheduled.schedule certificate).re.width ≤ 1 / (max n 1 : ℚ)
    Proof (Lean source)
    theorem certified_contour_evaluation_inverseMax (n : ℕ) (program : ContourProgram) (bounds : ContourValueBounds program) (separation : PosRat) (scheduled : CertifiedProgramSchedule program bounds separation) (hschedule : scheduled.schedule.tolerance = inverseMaxTolerance n) (certificate : DenominatorCertificate program scheduled.schedule) (hseparation : separation.1 ≤ certificate.separation) (hden : ∀ u ∈ Icc (0 : ℝ) 1, program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I)) ≠ 0) (hLip : ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, ‖program.normalizedIntegrand scheduled.schedule s - program.normalizedIntegrand scheduled.schedule t‖ ≤ (scheduled.schedule.lipschitzConstant : ℝ) * |s - t|) : (program.evaluate scheduled.schedule certificate).re.width ≤ 1 / (max n 1 : ℚ) := by have h := (certified_contour_evaluation program bounds separation scheduled certificate hseparation hden hLip).2 rw [hschedule] at h exact h
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.certified_contour_evaluation_inverseMax · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourEvaluation.lean:437
  • midpoint_error_le_half_width theorem — Containment in a rational real interval bounds its midpoint error by half the interval width.
    x :
    ℝ
    hx :
    I.Contains x
    |(((I.lo + I.hi) / 2 : ℚ) : ℝ) - x| ≤ (I.width : ℝ) / 2
    Proof (Lean source)
    theorem midpoint_error_le_half_width {I : RatInterval} {x : ℝ} (hx : I.Contains x) : |(((I.lo + I.hi) / 2 : ℚ) : ℝ) - x| ≤ (I.width : ℝ) / 2 := by simp only [RatInterval.Contains] at hx simp only [RatInterval.width] rw [abs_le] push_cast constructor <;> linarith [hx.1, hx.2]
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.midpoint_error_le_half_width · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/ContourEvaluation.lean:465
Program 7 core · 0 supporting This module defines certified complex interval maps with supplied evaluation, error-modulus, and operation-count data, plus composition combinators. ★ algorithmError_le_of_modulus

Certified finite complex programs

This module defines certified complex interval maps with supplied evaluation, error-modulus, and operation-count data, plus composition combinators. The same data are consumed by contour schedules and by the width proof; no caller-supplied node-width conclusion is part of this API.

structure CertifiedComplexMap reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour

A certified complex map packages an exact complex function with a supplied interval-evaluation function over rational input rectangles and a fuel level and supplied operation-count metadata, proved sound — every returned result contains the exact value at every enclosed input. Increasing fuel refines the enclosure to a subrectangle of the previous one, and refining the input rectangle cannot enlarge the output enclosure. The map carries a nonnegative width-amplification bound, together with algorithmic-error bounds that do not increase with fuel, such that the evaluated width never exceeds the algorithmic error plus the amplified input width, and a supplied fuel-selection rule meeting any requested positive algorithmic-error target.

Definition (Lean source)
The exact function described by the interval program.
value :
ℂ → ℂ
Supplied interval evaluation at a rational input rectangle and fuel.
Supplied primitive-operation-count metadata for one evaluation.
operationCount :
ℕ
Every returned result encloses the function at every enclosed input.
sound :
∀ {I z}
if
I.Contains z
then
∀ fuel, (eval I fuel).Contains (value z)
Increasing fuel produces an adjacent subrectangle for a fixed input.
fuel_nested :
∀ I fuel, (eval I (fuel + 1)).Subinterval (eval I fuel)
Refining the input rectangle cannot enlarge the interval extension.
input_mono :
∀ {I J}
if
I.Subinterval J
then
∀ fuel, (eval I fuel).Subinterval (eval J fuel)
A nonnegative rational Lipschitz amplification bound for input width.
amplification :
ℚ
The input-width amplification is nonnegative.
amplification_nonneg :
0 ≤ amplification
Remaining rational algorithmic width at each fuel.
algorithmError :
ℕ → ℚ
Algorithmic error is nonnegative at every fuel.
algorithmError_nonneg :
∀ fuel, 0 ≤ algorithmError fuel
Algorithmic error does not increase when fuel increases.
algorithmError_antitone :
Antitone algorithmError
Width is bounded by algorithmic error plus amplified input diameter.
width_le :
∀ I fuel,
ComplexRatInterval.width (eval I fuel)
≤ algorithmError fuel + amplification * ComplexRatInterval.width I
Supplied fuel selection meeting each positive algorithmic-error target.
errorModulus :
PosRat → ℕ
The algorithmic error meets the requested target at its selected fuel.
error_at_modulus :
∀ ε, algorithmError (errorModulus ε) ≤ ε.1
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplexMap · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Program.lean:19
def identity reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplexMap

The identity certified complex map denotes every complex input itself, returns the input rectangle at every fuel level, has no primitive operations or algorithmic error, and has unit input-width amplification.

Definition (Lean source)
identity :
clause 1
value := id
clause 2
eval := fun I _ => I
clause 3
clause 4
sound := by intro I z hz fuel; exact hz
clause 5
fuel_nested := by intro I fuel exact ⟨RatInterval.subinterval_refl _, RatInterval.subinterval_refl _⟩
clause 6
input_mono := by intro I J hIJ fuel; exact hIJ
clause 7
amplification := 1
clause 8
amplification_nonneg := by norm_num
clause 9
algorithmError := fun _ => 0
clause 10
algorithmError_nonneg := by intro fuel; norm_num
clause 11
algorithmError_antitone := by intro a b hab; rfl
clause 12
width_le := by intro I fuel; simp
clause 13
errorModulus := fun _ => 0
clause 14
error_at_modulus := by intro ε; exact ε.2.le
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplexMap.identity · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Program.lean:66 · uses CertifiedComplexMap
def constant reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplexMap

For a rational real coordinate and a rational imaginary coordinate, the constant certified complex map denotes the corresponding complex constant and returns its singleton rational rectangle for every input rectangle and fuel level.

Definition (Lean source)
x y :
ℚ
constant x y :
clause 1
value := fun _ => (x : ℝ) + (y : ℝ) * I
clause 2
eval := fun _ _ => ComplexRatInterval.point x y
clause 3
clause 4
sound := by intro I z hz fuel; exact ComplexRatInterval.point_sound x y
clause 5
fuel_nested := by intro I fuel exact ⟨RatInterval.subinterval_refl _, RatInterval.subinterval_refl _⟩
clause 6
input_mono := by intro I J hIJ fuel exact ⟨RatInterval.subinterval_refl _, RatInterval.subinterval_refl _⟩
clause 7
amplification := 0
clause 8
amplification_nonneg := by norm_num
clause 9
algorithmError := fun _ => 0
clause 10
algorithmError_nonneg := by intro fuel; norm_num
clause 11
algorithmError_antitone := by intro a b hab; rfl
clause 12
width_le := by intro I fuel simp [ComplexRatInterval.width, ComplexRatInterval.point, RatInterval.width, RatInterval.point]
clause 13
errorModulus := fun _ => 0
clause 14
error_at_modulus := by intro ε; exact ε.2.le
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplexMap.constant · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Program.lean:85 · uses CertifiedComplexMap
def add reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplexMap

For two certified complex maps, their certified pointwise sum denotes the sum of their exact values, evaluates by adding their output rectangles at a common fuel level, and adds their operation counts, width amplifications, and algorithmic errors.

Definition (Lean source)
by let δ : PosRat → PosRat := fun ε
=> ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩ exact { value := fun z => f.value z + g.value z eval := fun I fuel => (f.eval I fuel).add (g.eval I fuel) operationCount := f.operationCount + g.operationCount + 1 sound := by intro I z hz fuel exact ComplexRatInterval.add_sound (f.sound hz fuel) (g.sound hz fuel) fuel_nested := by intro I fuel exact ⟨RatInterval.add_mono (f.fuel_nested I fuel).1 (g.fuel_nested I fuel).1, RatInterval.add_mono (f.fuel_nested I fuel).2 (g.fuel_nested I fuel).2⟩ input_mono := by intro I J hIJ fuel exact ⟨RatInterval.add_mono (f.input_mono hIJ fuel).1 (g.input_mono hIJ fuel).1, RatInterval.add_mono (f.input_mono hIJ fuel).2 (g.input_mono hIJ fuel).2⟩ amplification := f.amplification + g.amplification amplification_nonneg := add_nonneg f.amplification_nonneg g.amplification_nonneg algorithmError := fun fuel => f.algorithmError fuel + g.algorithmError fuel algorithmError_nonneg := fun fuel => add_nonneg (f.algorithmError_nonneg fuel) (g.algorithmError_nonneg fuel) algorithmError_antitone := fun a b hab => add_le_add (f.algorithmError_antitone hab) (g.algorithmError_antitone hab) width_le := by intro I fuel rw [ComplexRatInterval.width_add] have hf := f.width_le I fuel have hg := g.width_le I fuel have hfre := (le_max_left (f.eval I fuel).re.width (f.eval I fuel).im.width).trans hf have hfim := (le_max_right (f.eval I fuel).re.width (f.eval I fuel).im.width).trans hf have hgre := (le_max_left (g.eval I fuel).re.width (g.eval I fuel).im.width).trans hg have hgim := (le_max_right (g.eval I fuel).re.width (g.eval I fuel).im.width).trans hg exact max_le (by nlinarith) (by nlinarith) errorModulus := fun ε => max (f.errorModulus (δ ε)) (g.errorModulus (δ ε)) error_at_modulus := by intro ε have hf := (f.algorithmError_antitone (show f.errorModulus (δ ε) ≤ max (f.errorModulus (δ ε)) (g.errorModulus (δ ε)) from le_max_left _ _)).trans (f.error_at_modulus (δ ε)) have hg := (g.algorithmError_antitone (show g.errorModulus (δ ε) ≤ max (f.errorModulus (δ ε)) (g.errorModulus (δ ε)) from le_max_right _ _)).trans (g.error_at_modulus (δ ε)) dsimp [δ] at hf hg ⊢ linarith }
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplexMap.add · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Program.lean:109 · uses CertifiedComplexMap
def sub reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplexMap

For two certified complex maps, their certified pointwise difference denotes the difference of their exact values, evaluates by subtracting their output rectangles at a common fuel level, and adds their operation counts, width amplifications, and algorithmic errors.

Definition (Lean source)
by let δ : PosRat → PosRat := fun ε
=> ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩ exact { value := fun z => f.value z - g.value z eval := fun I fuel => ComplexRatInterval.sub (f.eval I fuel) (g.eval I fuel) operationCount := f.operationCount + g.operationCount + 1 sound := by intro I z hz fuel exact ComplexRatInterval.sub_sound (f.sound hz fuel) (g.sound hz fuel) fuel_nested := by intro I fuel exact ⟨RatInterval.sub_mono (f.fuel_nested I fuel).1 (g.fuel_nested I fuel).1, RatInterval.sub_mono (f.fuel_nested I fuel).2 (g.fuel_nested I fuel).2⟩ input_mono := by intro I J hIJ fuel exact ⟨RatInterval.sub_mono (f.input_mono hIJ fuel).1 (g.input_mono hIJ fuel).1, RatInterval.sub_mono (f.input_mono hIJ fuel).2 (g.input_mono hIJ fuel).2⟩ amplification := f.amplification + g.amplification amplification_nonneg := add_nonneg f.amplification_nonneg g.amplification_nonneg algorithmError := fun fuel => f.algorithmError fuel + g.algorithmError fuel algorithmError_nonneg := fun fuel => add_nonneg (f.algorithmError_nonneg fuel) (g.algorithmError_nonneg fuel) algorithmError_antitone := fun a b hab => add_le_add (f.algorithmError_antitone hab) (g.algorithmError_antitone hab) width_le := by intro I fuel change max ((f.eval I fuel).re.sub (g.eval I fuel).re).width ((f.eval I fuel).im.sub (g.eval I fuel).im).width ≤ _ rw [RatInterval.width_sub, RatInterval.width_sub] have hf := f.width_le I fuel have hg := g.width_le I fuel have hfre := (le_max_left (f.eval I fuel).re.width (f.eval I fuel).im.width).trans hf have hfim := (le_max_right (f.eval I fuel).re.width (f.eval I fuel).im.width).trans hf have hgre := (le_max_left (g.eval I fuel).re.width (g.eval I fuel).im.width).trans hg have hgim := (le_max_right (g.eval I fuel).re.width (g.eval I fuel).im.width).trans hg exact max_le (by nlinarith) (by nlinarith) errorModulus := fun ε => max (f.errorModulus (δ ε)) (g.errorModulus (δ ε)) error_at_modulus := by intro ε have hf := (f.algorithmError_antitone (show f.errorModulus (δ ε) ≤ max (f.errorModulus (δ ε)) (g.errorModulus (δ ε)) from le_max_left _ _)).trans (f.error_at_modulus (δ ε)) have hg := (g.algorithmError_antitone (show g.errorModulus (δ ε) ≤ max (f.errorModulus (δ ε)) (g.errorModulus (δ ε)) from le_max_right _ _)).trans (g.error_at_modulus (δ ε)) dsimp [δ] at hf hg ⊢ linarith }
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplexMap.sub · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Program.lean:162 · uses CertifiedComplexMap
def mulWithBounds reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplexMap

The certified pointwise product of two certified complex maps denotes the product of their exact values and propagates error and input-width amplification using magnitude bounds for their supplied output rectangles. The construction requires both bounds to be nonnegative, every output rectangle of the first map to obey its bound, and every output rectangle of the second map to obey its bound.

Definition (Lean source)
Bf Bg :
ℚ
hBf :
0 ≤ Bf
hBg :
0 ≤ Bg
hf :
∀ I fuel, ComplexRatInterval.maxAbs (f.eval I fuel) ≤ Bf
hg :
∀ I fuel, ComplexRatInterval.maxAbs (g.eval I fuel) ≤ Bg
mulWithBounds f g Bf Bg hBf hBg hf hg :
by let δf : PosRat → PosRat := fun ε
=> ⟨ε.1 / (4 * (Bg + 1)), by exact div_pos ε.2 (mul_pos (by norm_num) (by linarith))⟩ let δg : PosRat → PosRat := fun ε => ⟨ε.1 / (4 * (Bf + 1)), by exact div_pos ε.2 (mul_pos (by norm_num) (by linarith))⟩ exact { value := fun z => f.value z * g.value z eval := fun I fuel => ComplexRatInterval.mul (f.eval I fuel) (g.eval I fuel) operationCount := f.operationCount + g.operationCount + 1 sound := by intro I z hz fuel exact ComplexRatInterval.mul_sound (f.sound hz fuel) (g.sound hz fuel) fuel_nested := by intro I fuel have hfuel := f.fuel_nested I fuel have gfuel := g.fuel_nested I fuel exact ⟨ RatInterval.sub_mono (RatInterval.mul_mono hfuel.1 gfuel.1) (RatInterval.mul_mono hfuel.2 gfuel.2), RatInterval.add_mono (RatInterval.mul_mono hfuel.1 gfuel.2) (RatInterval.mul_mono hfuel.2 gfuel.1)⟩ input_mono := by intro I J hIJ fuel have hfuel := f.input_mono hIJ fuel have gfuel := g.input_mono hIJ fuel exact ⟨ RatInterval.sub_mono (RatInterval.mul_mono hfuel.1 gfuel.1) (RatInterval.mul_mono hfuel.2 gfuel.2), RatInterval.add_mono (RatInterval.mul_mono hfuel.1 gfuel.2) (RatInterval.mul_mono hfuel.2 gfuel.1)⟩ amplification := 2 * (Bf * g.amplification + Bg * f.amplification) amplification_nonneg := by have hga := g.amplification_nonneg have hfa := f.amplification_nonneg nlinarith [mul_nonneg hBf hga, mul_nonneg hBg hfa] algorithmError := fun fuel => 2 * (Bf * g.algorithmError fuel + Bg * f.algorithmError fuel) algorithmError_nonneg := by intro fuel have hge := g.algorithmError_nonneg fuel have hfe := f.algorithmError_nonneg fuel nlinarith [mul_nonneg hBf hge, mul_nonneg hBg hfe] algorithmError_antitone := by intro a b hab have hfa := f.algorithmError_antitone hab have hga := g.algorithmError_antitone hab nlinarith [mul_le_mul_of_nonneg_left hfa hBg, mul_le_mul_of_nonneg_left hga hBf] width_le := by intro I fuel have hout := ComplexRatInterval.mul_width (f.eval I fuel) (g.eval I fuel) have hfw := f.width_le I fuel have hgw := g.width_le I fuel have hfA := hf I fuel have hgA := hg I fuel have hfA0 : 0 ≤ ComplexRatInterval.maxAbs (f.eval I fuel) := (abs_nonneg (f.eval I fuel).re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hgA0 : 0 ≤ ComplexRatInterval.maxAbs (g.eval I fuel) := (abs_nonneg (g.eval I fuel).re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hfw0 : 0 ≤ ComplexRatInterval.width (f.eval I fuel) := (RatInterval.width_nonneg (f.eval I fuel).re).trans (le_max_left _ _) have hgw0 : 0 ≤ ComplexRatInterval.width (g.eval I fuel) := (RatInterval.width_nonneg (g.eval I fuel).re).trans (le_max_left _ _) have hp1 := mul_le_mul hfA hgw hgw0 hBf have hp2 := mul_le_mul hgA hfw hfw0 hBg exact hout.trans (by nlinarith) errorModulus := fun ε => max (f.errorModulus (δf ε)) (g.errorModulus (δg ε)) error_at_modulus := by intro ε have hfe := (f.algorithmError_antitone (show f.errorModulus (δf ε) ≤ max (f.errorModulus (δf ε)) (g.errorModulus (δg ε)) from le_max_left _ _)).trans (f.error_at_modulus (δf ε)) have hge := (g.algorithmError_antitone (show g.errorModulus (δg ε) ≤ max (f.errorModulus (δf ε)) (g.errorModulus (δg ε)) from le_max_right _ _)).trans (g.error_at_modulus (δg ε)) have hBg1 : 0 < Bg + 1 := by linarith have hBf1 : 0 < Bf + 1 := by linarith dsimp [δf, δg] at hfe hge ⊢ have hfp : Bg * f.algorithmError (max (f.errorModulus ⟨ε.1 / (4 * (Bg + 1)), div_pos ε.2 (mul_pos (by norm_num) hBg1)⟩) (g.errorModulus ⟨ε.1 / (4 * (Bf + 1)), div_pos ε.2 (mul_pos (by norm_num) hBf1)⟩)) ≤ ε.1 / 4 := by calc _ ≤ Bg * (ε.1 / (4 * (Bg + 1))) := mul_le_mul_of_nonneg_left hfe hBg _ ≤ ε.1 / 4 := by rw [show Bg * (ε.1 / (4 * (Bg + 1))) = (Bg * ε.1) / (4 * (Bg + 1)) by ring] apply (div_le_iff₀ (mul_pos (by norm_num) hBg1)).2 calc Bg * ε.1 ≤ (Bg + 1) * ε.1 := mul_le_mul_of_nonneg_right (by linarith) ε.2.le _ = ε.1 / 4 * (4 * (Bg + 1)) := by ring have hgp : Bf * g.algorithmError (max (f.errorModulus ⟨ε.1 / (4 * (Bg + 1)), div_pos ε.2 (mul_pos (by norm_num) hBg1)⟩) (g.errorModulus ⟨ε.1 / (4 * (Bf + 1)), div_pos ε.2 (mul_pos (by norm_num) hBf1)⟩)) ≤ ε.1 / 4 := by calc _ ≤ Bf * (ε.1 / (4 * (Bf + 1))) := mul_le_mul_of_nonneg_left hge hBf _ ≤ ε.1 / 4 := by rw [show Bf * (ε.1 / (4 * (Bf + 1))) = (Bf * ε.1) / (4 * (Bf + 1)) by ring] apply (div_le_iff₀ (mul_pos (by norm_num) hBf1)).2 calc Bf * ε.1 ≤ (Bf + 1) * ε.1 := mul_le_mul_of_nonneg_right (by linarith) ε.2.le _ = ε.1 / 4 * (4 * (Bf + 1)) := by ring nlinarith }
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplexMap.mulWithBounds · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Program.lean:217 · uses ComplexRatInterval , CertifiedComplexMap , maxAbs
theorem algorithmError_le_of_modulus reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplexMap

Fuel sufficiency bound. For a certified complex-map evaluation algorithm and a requested positive rational error tolerance, if the number of iterations supplied is at least the algorithm's certified error modulus at that tolerance, then the algorithm's declared error allowance at that number of iterations, the additive term in its certified output-width bound, is at most the requested tolerance.

Formal statement
ε :
fuel :
ℕ
h :
f.errorModulus ε ≤ fuel
f.algorithmError fuel ≤ ε.1
Proof (Lean source)
theorem algorithmError_le_of_modulus {f : CertifiedComplexMap} {ε : PosRat} {fuel : ℕ} (h : f.errorModulus ε ≤ fuel) : f.algorithmError fuel ≤ ε.1 := by exact (f.algorithmError_antitone h).trans (f.error_at_modulus ε)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.CertifiedComplexMap.algorithmError_le_of_modulus · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/Program.lean:344 · uses CertifiedComplexMap , PosRat
Trig­Names 6 core · 4 supporting This module turns refining rational real names into certified sine and cosine names with width-controlled Taylor-error bounds. ★ sinName_width_at_precision

Certified sine and cosine names

This module turns refining rational real names into certified sine and cosine names with width-controlled Taylor-error bounds. The construction uses each input name's supplied precision rule.

def sinNameApprox reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

For a certified real number and a natural-number fuel level, the sine name approximation at that level is the sine interval of the level-zero input enclosure, and at every successor level is the intersection of the preceding sine approximation and the sine interval of the corresponding input enclosure.

Definition (Lean source)
sinNameApprox x :
ℕ → RatInterval
clause 1
| 0 => sinInterval (x.approx 0) 0
clause 2
| fuel + 1
=> (sinNameApprox x fuel).tighten (sinInterval (x.approx (fuel + 1)) (fuel + 1))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.sinNameApprox · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/TrigNames.lean:20 · uses CertifiedReal , RatInterval
def cosNameApprox reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

For a certified real number and a natural-number fuel level, the cosine name approximation at that level is the cosine interval of the level-zero input enclosure, and at every successor level is the intersection of the preceding cosine approximation and the cosine interval of the corresponding input enclosure.

Definition (Lean source)
cosNameApprox x :
ℕ → RatInterval
clause 1
| 0 => cosInterval (x.approx 0) 0
clause 2
| fuel + 1
=> (cosNameApprox x fuel).tighten (cosInterval (x.approx (fuel + 1)) (fuel + 1))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.cosNameApprox · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/TrigNames.lean:26 · uses CertifiedReal , RatInterval
def trigNamePrecision reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a certified real number and a positive rational target width, the trigonometric name precision is computed by taking half the target width as an internal input tolerance and returning the larger of the input precision the certified real requires for that tolerance and an explicit Taylor-fuel bound based on the target denominator and the initial enclosure's magnitude.

Definition (Lean source)
trigNamePrecision x ε :
ℕ
δ :
⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩ (: PosRat)
max (x.modulus δ) (32 * (ε.1.den + 1) * ((x.approx 0).maxAbs.num.natAbs + 2) ^ 2)
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.trigNamePrecision · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/TrigNames.lean:32 · uses CertifiedReal , PosRat
theorem sinName_width_at_precision reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

For a certified real input and a requested positive rational tolerance ε, evaluating the certified sine name-approximation at the precision level selected for that tolerance yields an output enclosure whose width is no larger than ε.

Formal statement
(sinNameApprox x (trigNamePrecision x ε)).width ≤ ε.1
Proof (Lean source)
theorem sinName_width_at_precision (x : CertifiedReal) (ε : PosRat) : (sinNameApprox x (trigNamePrecision x ε)).width ≤ ε.1 := by let δ : PosRat := ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩ let d : ℕ := ε.1.den + 1 let A : ℕ := (x.approx 0).maxAbs.num.natAbs + 2 let N : ℕ := trigNamePrecision x ε let K := x.approx N have hmod : x.modulus δ ≤ N := by exact le_max_left _ _ have hN : 32 * d * A ^ 2 ≤ N := by exact le_max_right _ _ have hKw : K.width ≤ δ.1 := (RatInterval.width_mono (CertifiedReal.approx_mono x hmod)).trans (x.width_modulus δ) have hKK0 : K.Subinterval (x.approx 0) := CertifiedReal.approx_mono x (zero_le N) have hmidK : K.Contains (intervalMid K : ℝ) := by constructor <;> exact_mod_cast (by dsimp [intervalMid] linarith [K.lo_le_hi]) have hmid0 := RatInterval.Contains.mono hKK0 hmidK have hM0 : 0 ≤ (x.approx 0).maxAbs := (abs_nonneg (x.approx 0).lo).trans (le_max_left _ _) have hMle : (x.approx 0).maxAbs ≤ ((x.approx 0).maxAbs.num.natAbs : ℕ) := by have hn0 : 0 ≤ (x.approx 0).maxAbs.num := Rat.num_nonneg.mpr hM0 calc (x.approx 0).maxAbs = ((x.approx 0).maxAbs.num : ℚ) / ((x.approx 0).maxAbs.den : ℕ) := (Rat.num_div_den _).symm _ ≤ ((x.approx 0).maxAbs.num : ℚ) := div_le_self (by exact_mod_cast hn0) (by exact_mod_cast Rat.den_pos _) _ = ((x.approx 0).maxAbs.num.natAbs : ℕ) := by have hi : ((x.approx 0).maxAbs.num.natAbs : ℤ) = (x.approx 0).maxAbs.num := Int.natAbs_of_nonneg hn0 exact (congrArg (fun z : ℤ => (z : ℚ)) hi).symm have hmidA : |intervalMid K| ≤ (A : ℚ) := by exact (abs_le_max_abs_abs (by exact_mod_cast hmid0.1) (by exact_mod_cast hmid0.2)).trans (hMle.trans (by exact_mod_cast le_add_right (x.approx 0).maxAbs.num.natAbs 2)) have herr : sinError (intervalMid K) N ≤ 1 / (4 * d : ℕ) := by simpa [sinError] using power_div_factorial_le (intervalMid K) A d N 3 hmidA (by dsimp [A]; omega) (by dsimp [d]; omega) (by omega) hN have hinv : 1 / (d : ℚ) ≤ ε.1 := by exact (div_le_div_of_nonneg_left (by norm_num) (by positivity) (by dsimp [d]; exact_mod_cast le_succ ε.1.den)).trans (Transcendental.inv_den_le_of_pos ε.1 ε.2) have hcur := sinInterval_width K N have hout := RatInterval.width_mono (sinNameApprox_subinterval_current x N) have herr' : sinError (intervalMid K) N ≤ ε.1 / 4 := by calc _ ≤ (1 : ℚ) / ((4 * d : ℕ) : ℚ) := herr _ = (1 / (d : ℚ)) / 4 := by push_cast; field_simp _ ≤ _ := div_le_div_of_nonneg_right hinv (by norm_num) dsimp [δ] at hKw exact hout.trans (hcur.trans (by nlinarith [herr']))
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.sinName_width_at_precision · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/TrigNames.lean:144 · uses CertifiedReal , sinNameApprox , trigNamePrecision , PosRat , width
def sinName reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a certified real number, the certified sine name has exact value the sine of the input value, uses the recursively refined sine intervals as approximations, and uses the trigonometric precision rule for requested positive rational widths.

Definition (Lean source)
sinName x :
clause 1
value := sin x.value
clause 2
approx := sinNameApprox x
clause 3
nested := fun fuel => (sinNameApprox_spec x fuel).2
clause 4
contains := by intro fuel; exact (sinNameApprox_spec x fuel).1
clause 6
width_modulus := sinName_width_at_precision x
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.sinName · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/TrigNames.lean:255 · uses CertifiedReal
def cosName reviewed
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental

Given a certified real number, the certified cosine name has exact value the cosine of the input value, uses the recursively refined cosine intervals as approximations, and uses the trigonometric precision rule for requested positive rational widths.

Definition (Lean source)
cosName x :
clause 1
value := cos x.value
clause 2
approx := cosNameApprox x
clause 3
nested := fun fuel => (cosNameApprox_spec x fuel).2
clause 4
contains := by intro fuel; exact (cosNameApprox_spec x fuel).1
clause 6
width_modulus := cosName_width_at_precision x
Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.cosName · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/TrigNames.lean:264 · uses CertifiedReal
4 supporting declarations (lemmas, instances)
  • sinNameApprox_spec theorem — Recursive sine-name approximations remain sound and adjacent-fuel nested.
    fuel :
    ℕ
    conclusion 1
    (sinNameApprox x fuel).Contains (sin x.value)
    conclusion 2
    (sinNameApprox x (fuel + 1)).Subinterval (sinNameApprox x fuel)
    Proof (Lean source)
    theorem sinNameApprox_spec (x : CertifiedReal) (fuel : ℕ) : (sinNameApprox x fuel).Contains (sin x.value) ∧ (sinNameApprox x (fuel + 1)).Subinterval (sinNameApprox x fuel) := by induction fuel with | zero => have h0 := sinInterval_sound (x.contains 0) 0 have h1 := sinInterval_sound (x.contains 1) 1 exact ⟨h0, RatInterval.tighten_subinterval_left h0 h1⟩ | succ fuel ih => have hnew := sinInterval_sound (x.contains (fuel + 1)) (fuel + 1) have hcur : (sinNameApprox x (fuel + 1)).Contains (sin x.value) := by rw [sinNameApprox] exact RatInterval.tighten_sound ih.1 hnew have hnext := sinInterval_sound (x.contains (fuel + 2)) (fuel + 2) constructor · exact hcur · rw [show fuel + 1 + 1 = fuel + 2 by omega, sinNameApprox] exact RatInterval.tighten_subinterval_left hcur hnext
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.sinNameApprox_spec · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/TrigNames.lean:38
  • cosNameApprox_spec theorem — Recursive cosine-name approximations remain sound and adjacent-fuel nested.
    fuel :
    ℕ
    conclusion 1
    (cosNameApprox x fuel).Contains (cos x.value)
    conclusion 2
    (cosNameApprox x (fuel + 1)).Subinterval (cosNameApprox x fuel)
    Proof (Lean source)
    theorem cosNameApprox_spec (x : CertifiedReal) (fuel : ℕ) : (cosNameApprox x fuel).Contains (cos x.value) ∧ (cosNameApprox x (fuel + 1)).Subinterval (cosNameApprox x fuel) := by induction fuel with | zero => have h0 := cosInterval_sound (x.contains 0) 0 have h1 := cosInterval_sound (x.contains 1) 1 exact ⟨h0, RatInterval.tighten_subinterval_left h0 h1⟩ | succ fuel ih => have hnew := cosInterval_sound (x.contains (fuel + 1)) (fuel + 1) have hcur : (cosNameApprox x (fuel + 1)).Contains (cos x.value) := by rw [cosNameApprox] exact RatInterval.tighten_sound ih.1 hnew have hnext := cosInterval_sound (x.contains (fuel + 2)) (fuel + 2) constructor · exact hcur · rw [show fuel + 1 + 1 = fuel + 2 by omega, cosNameApprox] exact RatInterval.tighten_subinterval_left hcur hnext
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.cosNameApprox_spec · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/TrigNames.lean:58
  • power_div_factorial_le theorem — If the Taylor fuel dominates a rational magnitude and denominator scale, the corresponding rational power-over-factorial remainder is explicitly small.
    q :
    ℚ
    A d N r :
    ℕ
    hq :
    |q| ≤ A
    hA :
    1 ≤ A
    hd :
    1 ≤ d
    hr :
    1 ≤ r
    hN :
    32 * d * A ^ 2 ≤ N
    |q| ^ (2 * N + r) / ((2 * N + r).factorial : ℚ) ≤ 1 / (4 * d : ℕ)
    Proof (Lean source)
    theorem power_div_factorial_le (q : ℚ) (A d N r : ℕ) (hq : |q| ≤ A) (hA : 1 ≤ A) (hd : 1 ≤ d) (hr : 1 ≤ r) (hN : 32 * d * A ^ 2 ≤ N) : |q| ^ (2 * N + r) / ((2 * N + r).factorial : ℚ) ≤ 1 / (4 * d : ℕ) := by have hp : |q| ^ (2 * N + r) ≤ (A : ℚ) ^ (2 * N + r) := pow_le_pow_left₀ (abs_nonneg q) hq _ have hf : (4 * d : ℚ) * (A : ℚ) ^ (2 * N + r) ≤ ((2 * N + r).factorial : ℚ) := by exact_mod_cast factorial_power_bound A d N r hA hd hr hN apply (div_le_div_iff₀ (by positivity : (0 : ℚ) < (2 * N + r).factorial) (by positivity : (0 : ℚ) < (4 * d : ℕ))).2 calc |q| ^ (2 * N + r) * (4 * d : ℕ) ≤ (A : ℚ) ^ (2 * N + r) * (4 * d : ℕ) := mul_le_mul_of_nonneg_right hp (by positivity) _ = (4 * d : ℚ) * (A : ℚ) ^ (2 * N + r) := by push_cast ring _ ≤ ((2 * N + r).factorial : ℚ) := hf _ = 1 * ((2 * N + r).factorial : ℚ) := by ring
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.power_div_factorial_le · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/TrigNames.lean:103
  • cosName_width_at_precision theorem — For a certified real input and a positive rational tolerance ε, the cosine enclosure at the selected precision has width at most ε, using the input name's supplied precision rule together with an explicit Taylor-fuel bound.
    (cosNameApprox x (trigNamePrecision x ε)).width ≤ ε.1
    Proof (Lean source)
    theorem cosName_width_at_precision (x : CertifiedReal) (ε : PosRat) : (cosNameApprox x (trigNamePrecision x ε)).width ≤ ε.1 := by let δ : PosRat := ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩ let d : ℕ := ε.1.den + 1 let A : ℕ := (x.approx 0).maxAbs.num.natAbs + 2 let N : ℕ := trigNamePrecision x ε let K := x.approx N have hmod : x.modulus δ ≤ N := by exact le_max_left _ _ have hN : 32 * d * A ^ 2 ≤ N := by exact le_max_right _ _ have hKw : K.width ≤ δ.1 := (RatInterval.width_mono (CertifiedReal.approx_mono x hmod)).trans (x.width_modulus δ) have hKK0 : K.Subinterval (x.approx 0) := CertifiedReal.approx_mono x (zero_le N) have hmidK : K.Contains (intervalMid K : ℝ) := by constructor <;> exact_mod_cast (by dsimp [intervalMid] linarith [K.lo_le_hi]) have hmid0 := RatInterval.Contains.mono hKK0 hmidK have hM0 : 0 ≤ (x.approx 0).maxAbs := (abs_nonneg (x.approx 0).lo).trans (le_max_left _ _) have hMle : (x.approx 0).maxAbs ≤ ((x.approx 0).maxAbs.num.natAbs : ℕ) := by have hn0 : 0 ≤ (x.approx 0).maxAbs.num := Rat.num_nonneg.mpr hM0 calc (x.approx 0).maxAbs = ((x.approx 0).maxAbs.num : ℚ) / ((x.approx 0).maxAbs.den : ℕ) := (Rat.num_div_den _).symm _ ≤ ((x.approx 0).maxAbs.num : ℚ) := div_le_self (by exact_mod_cast hn0) (by exact_mod_cast Rat.den_pos _) _ = ((x.approx 0).maxAbs.num.natAbs : ℕ) := by have hi : ((x.approx 0).maxAbs.num.natAbs : ℤ) = (x.approx 0).maxAbs.num := Int.natAbs_of_nonneg hn0 exact (congrArg (fun z : ℤ => (z : ℚ)) hi).symm have hmidA : |intervalMid K| ≤ (A : ℚ) := by exact (abs_le_max_abs_abs (by exact_mod_cast hmid0.1) (by exact_mod_cast hmid0.2)).trans (hMle.trans (by exact_mod_cast le_add_right (x.approx 0).maxAbs.num.natAbs 2)) have herr : cosError (intervalMid K) N ≤ 1 / (4 * d : ℕ) := by simpa [cosError] using power_div_factorial_le (intervalMid K) A d N 2 hmidA (by dsimp [A]; omega) (by dsimp [d]; omega) (by omega) hN have hinv : 1 / (d : ℚ) ≤ ε.1 := by exact (div_le_div_of_nonneg_left (by norm_num) (by positivity) (by dsimp [d]; exact_mod_cast le_succ ε.1.den)).trans (Transcendental.inv_den_le_of_pos ε.1 ε.2) have hcur := cosInterval_width K N have hout := RatInterval.width_mono (cosNameApprox_subinterval_current x N) have herr' : cosError (intervalMid K) N ≤ ε.1 / 4 := by calc _ ≤ (1 : ℚ) / ((4 * d : ℕ) : ℚ) := herr _ = (1 / (d : ℚ)) / 4 := by push_cast; field_simp _ ≤ _ := div_le_div_of_nonneg_right hinv (by norm_num) dsimp [δ] at hKw exact hout.trans (hcur.trans (by nlinarith [herr']))
    Causalean.Mathlib.Analysis.IntervalArithmetic.Contour.Transcendental.cosName_width_at_precision · Causalean/Mathlib/Analysis/IntervalArithmetic/Contour/TrigNames.lean:200