Mathlib.Analysis.Certified­Contour­Interval­Arithmetic.Complex

Certified complex numerical semantics: rational rectangle arithmetic, refining complex names, elementary transcendental enclosures, scheduled circle nodes, and finite contour quadrature.

Transcendental 20 core · 12 supporting 20 to review This module defines executable Machin/Taylor enclosures for π, sine, cosine, and the real exponential. ★ piInterval_width

Rational real transcendental enclosures

This module defines executable Machin/Taylor enclosures for π, sine, cosine, and the real exponential. 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 ComplexExp.

def atanPartial unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

The rational alternating Taylor sum through degree 2 * fuel + 1 approximates arctangent on the unit interval.

Definition (Lean source)
def atanPartial (q : ℚ) (fuel : ℕ) : ℚ := ∑ k ∈ range (fuel + 1), (-1 : ℚ) ^ k * q ^ (2 * k + 1) / (2 * k + 1 : ℕ)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.atanPartial · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:30
def atanError unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

The first omitted arctangent term is a rational absolute error bound when the argument has absolute value at most one.

Definition (Lean source)
def atanError (q : ℚ) (fuel : ℕ) : ℚ := |q| ^ (2 * fuel + 3) / (2 * fuel + 3 : ℕ)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.atanError · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:36
def atanRaw unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

A rational arctangent Taylor sum widened by its first omitted term.

Definition (Lean source)
def atanRaw (q : ℚ) (fuel : ℕ) : RatInterval := ⟨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.CertifiedContourIntervalArithmetic.Complex.Transcendental.atanRaw · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:41 · uses RatInterval
def piRaw unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Machin's formula combines two rational arctangent enclosures without using an exact π endpoint.

Definition (Lean source)
def piRaw (fuel : ℕ) : RatInterval := (RatInterval.point 4).mul ((RatInterval.point 4).mul (atanRaw (1 / 5) fuel) |>.sub (atanRaw (1 / 239) fuel))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.piRaw · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:50 · uses RatInterval
def piInterval unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Successive π approximations are recursive finite intersections of Machin bounds.

Definition (Lean source)
def piInterval : ℕ → RatInterval | 0 => piRaw 0 | fuel + 1 => (piInterval fuel).tighten (piRaw (fuel + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.piInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:57 · uses RatInterval
def piPrecision unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

A denominator-sensitive executable fuel for a requested π width.

Definition (Lean source)
def piPrecision (ε : PosRat) : ℕ := 8 * (ε.1.den + 1)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.piPrecision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:62 · uses PosRat
theorem piInterval_width unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.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.CertifiedContourIntervalArithmetic.Complex.Transcendental.piInterval_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:162 · uses piInterval , piPrecision , PosRat , width
def piName unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

The Machin enclosure sequence packages π as an effectively refining certified real name.

Definition (Lean source)
noncomputable def piName : CertifiedReal where value := pi approx := piInterval nested := piInterval_nested contains := piInterval_sound modulus := piPrecision width_modulus := piInterval_width
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.piName · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:205 · uses CertifiedReal
def sinPartial unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

The rational sine Taylor polynomial retains terms through the requested fuel.

Definition (Lean source)
def sinPartial (q : ℚ) (fuel : ℕ) : ℚ := ∑ k ∈ range (fuel + 1), (-1 : ℚ) ^ k * q ^ (2 * k + 1) / ((2 * k + 1).factorial : ℚ)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.sinPartial · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:214
def sinError unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

The absolute first omitted sine Taylor scale is an executable rational remainder bound.

Definition (Lean source)
def sinError (q : ℚ) (fuel : ℕ) : ℚ := |q| ^ (2 * fuel + 3) / ((2 * fuel + 3).factorial : ℚ)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.sinError · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:219
def cosPartial unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

The rational cosine Taylor polynomial retains terms through the requested fuel.

Definition (Lean source)
def cosPartial (q : ℚ) (fuel : ℕ) : ℚ := ∑ k ∈ range (fuel + 1), (-1 : ℚ) ^ k * q ^ (2 * k) / ((2 * k).factorial : ℚ)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.cosPartial · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:223
def cosError unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

The absolute first omitted cosine Taylor scale is an executable rational remainder bound.

Definition (Lean source)
def cosError (q : ℚ) (fuel : ℕ) : ℚ := |q| ^ (2 * fuel + 2) / ((2 * fuel + 2).factorial : ℚ)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.cosError · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:228
def sinRaw unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

A rational sine Taylor value widened by its explicit remainder.

Definition (Lean source)
def sinRaw (q : ℚ) (fuel : ℕ) : RatInterval := ⟨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.CertifiedContourIntervalArithmetic.Complex.Transcendental.sinRaw · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:232 · uses RatInterval
def cosRaw unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

A rational cosine Taylor value widened by its explicit remainder.

Definition (Lean source)
def cosRaw (q : ℚ) (fuel : ℕ) : RatInterval := ⟨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.CertifiedContourIntervalArithmetic.Complex.Transcendental.cosRaw · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:241 · uses RatInterval
def intervalMid unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

The rational midpoint of an interval is used only as a Taylor expansion center.

Definition (Lean source)
def intervalMid (I : RatInterval) : ℚ := (I.lo + I.hi) / 2
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.intervalMid · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:250 · uses RatInterval
def intervalRadius unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Half the rational interval width bounds distance from every enclosed point to its midpoint.

Definition (Lean source)
def intervalRadius (I : RatInterval) : ℚ := I.width / 2
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.intervalRadius · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:253 · uses RatInterval
def sinIntervalRaw unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Raw sine interval evaluation adds the input-radius Lipschitz error to a rational Taylor enclosure at the midpoint.

Definition (Lean source)
def sinIntervalRaw (I : RatInterval) (fuel : ℕ) : RatInterval := (sinRaw (intervalMid I) fuel).expand (intervalRadius I) (by exact div_nonneg (RatInterval.width_nonneg I) (by norm_num))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.sinIntervalRaw · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:256 · uses RatInterval
def cosIntervalRaw unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Raw cosine interval evaluation adds the input-radius Lipschitz error to a rational Taylor enclosure at the midpoint.

Definition (Lean source)
def cosIntervalRaw (I : RatInterval) (fuel : ℕ) : RatInterval := (cosRaw (intervalMid I) fuel).expand (intervalRadius I) (by exact div_nonneg (RatInterval.width_nonneg I) (by norm_num))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.cosIntervalRaw · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:262 · uses RatInterval
def sinInterval unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Sine interval outputs recursively intersect all raw bounds seen so far.

Definition (Lean source)
def sinInterval (I : RatInterval) : ℕ → RatInterval | 0 => sinIntervalRaw I 0 | fuel + 1 => (sinInterval I fuel).tighten (sinIntervalRaw I (fuel + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.sinInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:268 · uses RatInterval
def cosInterval unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Cosine interval outputs recursively intersect all raw bounds seen so far.

Definition (Lean source)
def cosInterval (I : RatInterval) : ℕ → RatInterval | 0 => cosIntervalRaw I 0 | fuel + 1 => (cosInterval I fuel).tighten (cosIntervalRaw I (fuel + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.cosInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:273 · uses RatInterval
12 supporting declarations (lemmas, instances)
Basic 5 core · 11 supporting 5 to review This module extends the promoted real interval layer with exact rational rectangle operations, guarded complex division, square-root/modulus bounds, and nested names for complex numbers. ★ sqrt_iterates_sound

Executable rational complex rectangles

This module extends the promoted real interval layer with exact rational rectangle operations, guarded complex division, square-root/modulus bounds, and nested names for complex numbers. Every returned rectangle is computed from rational endpoints; exact values occur only in containment semantics.

def sq unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

Squaring a rational interval uses zero as the lower bound exactly when the interval crosses zero and the larger squared endpoint as the upper bound.

Definition (Lean source)
def sq (I : RatInterval) : RatInterval := 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.CertifiedContourIntervalArithmetic.RatInterval.sq · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:16 · uses RatInterval
def sqrtUpper unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

The Newton upper iterate is an executable rational approximation to the square root of a nonnegative rational.

Definition (Lean source)
def sqrtUpper (q : ℚ) : ℕ → ℚ | 0 => |q| + 1 | n + 1 => let u := sqrtUpper q n (u + q / u) / 2
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.sqrtUpper · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:77
def sqrtLower unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

Dividing a nonnegative rational by its Newton upper iterate gives a matching executable lower square-root bound.

Definition (Lean source)
def sqrtLower (q : ℚ) (n : ℕ) : ℚ := q / sqrtUpper q n
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.sqrtLower · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:85
theorem sqrt_iterates_sound unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.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 :
(sqrtLower q n : ℝ) ≤ sqrt q ∧ 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.CertifiedContourIntervalArithmetic.RatInterval.sqrt_iterates_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:106 · uses sqrtLower , sqrtUpper
def sqrtInterval unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

A nonnegative rational interval is mapped to a rational square-root interval by applying lower and upper Newton bounds to its endpoints.

Definition (Lean source)
def sqrtInterval (I : RatInterval) (hI : 0 ≤ I.lo) (fuel : ℕ) : RatInterval := ⟨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.CertifiedContourIntervalArithmetic.RatInterval.sqrtInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/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
    I.sq.Contains (x ^ 2)
    Proof (Lean source)
    theorem sq_sound {I : RatInterval} {x : ℝ} (hx : I.Contains x) : I.sq.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.CertifiedContourIntervalArithmetic.RatInterval.sq_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:26
  • sq_mono theorem — Squaring is inclusion-isotone for rational intervals.
    I J :
    hIJ :
    I.Subinterval J
    I.sq.Subinterval J.sq
    Proof (Lean source)
    theorem sq_mono {I J : RatInterval} (hIJ : I.Subinterval J) : I.sq.Subinterval J.sq := 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.CertifiedContourIntervalArithmetic.RatInterval.sq_mono · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:49
  • 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.CertifiedContourIntervalArithmetic.RatInterval.sqrt_gap_rate · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:141
  • sqrt_iterates_converge theorem — The gap between the Newton lower and upper square-root bounds converges effectively to zero.
    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.CertifiedContourIntervalArithmetic.RatInterval.sqrt_iterates_converge · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/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.CertifiedContourIntervalArithmetic.RatInterval.sqrtInterval_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:194
  • 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.CertifiedContourIntervalArithmetic.RatInterval.sqrtInterval_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:206
  • 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.CertifiedContourIntervalArithmetic.RatInterval.maxAbs_le_of_contains_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:213
  • 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.CertifiedContourIntervalArithmetic.RatInterval.maxAbs_neg · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:240
  • 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.CertifiedContourIntervalArithmetic.RatInterval.maxAbs_add · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:244
  • 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.CertifiedContourIntervalArithmetic.RatInterval.maxAbs_sub · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:255
  • 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.CertifiedContourIntervalArithmetic.RatInterval.maxAbs_mul · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:260
Rectangles 12 core · 20 supporting 12 to review 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 unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

The width of a complex rectangle is the larger of its two coordinate widths.

Definition (Lean source)
def width (I : ComplexRatInterval) : ℚ := max I.re.width I.im.width
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:13 · uses ComplexRatInterval
def maxAbs unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

The maximum coordinate endpoint magnitude controls arithmetic error amplification.

Definition (Lean source)
def maxAbs (I : ComplexRatInterval) : ℚ := max I.re.maxAbs I.im.maxAbs
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.maxAbs · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:16 · uses ComplexRatInterval
def point unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

A rational pair determines a point rectangle in the complex plane.

Definition (Lean source)
def point (x y : ℚ) : ComplexRatInterval := ⟨RatInterval.point x, RatInterval.point y⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.point · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:19 · uses ComplexRatInterval
def neg unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

Complex rectangle negation reverses both coordinate intervals.

Definition (Lean source)
def neg (I : ComplexRatInterval) : ComplexRatInterval := ⟨I.re.neg, I.im.neg⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.neg · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:23 · uses ComplexRatInterval
def sub unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

Complex rectangle subtraction adds the coordinatewise negation.

Definition (Lean source)
def sub (I J : ComplexRatInterval) : ComplexRatInterval := I.add J.neg
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.sub · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:26 · uses ComplexRatInterval
def mul unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

Complex rectangle multiplication evaluates the Cartesian formula with outward rational real interval operations.

Definition (Lean source)
def mul (I J : ComplexRatInterval) : ComplexRatInterval := ⟨(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.CertifiedContourIntervalArithmetic.ComplexRatInterval.mul · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:29 · uses ComplexRatInterval
def conj unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

Complex conjugation negates only the imaginary coordinate interval.

Definition (Lean source)
def conj (I : ComplexRatInterval) : ComplexRatInterval := ⟨I.re, I.im.neg⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.conj · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:35 · uses ComplexRatInterval
def normSq unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

The squared-modulus interval sums the sign-aware squares of both coordinates.

Definition (Lean source)
def normSq (I : ComplexRatInterval) : RatInterval := I.re.sq.add I.im.sq
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.normSq · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:38 · uses ComplexRatInterval , RatInterval
def div unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

Guarded complex division multiplies by the conjugate and divides both resulting coordinates by the denominator squared-modulus interval.

Definition (Lean source)
def div (I J : ComplexRatInterval) (hJ : J.normSq.AwayFromZero) : ComplexRatInterval := let numerator := I.mul J.conj ⟨numerator.re.div J.normSq hJ, numerator.im.div J.normSq hJ⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.div · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:41 · uses ComplexRatInterval , normSq , AwayFromZero
def tighten unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

Coordinatewise conditional intersection makes a rectangle no larger while retaining a common enclosed complex value.

Definition (Lean source)
def tighten (I J : ComplexRatInterval) : ComplexRatInterval := ⟨I.re.tighten J.re, I.im.tighten J.im⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.tighten · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:47 · uses ComplexRatInterval
theorem div_sound unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.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 :
J.normSq.AwayFromZero
hz :
I.Contains z
hw :
J.Contains w
(I.div J hJ).Contains (z / w)
Proof (Lean source)
theorem div_sound {I J : ComplexRatInterval} {z w : ℂ} (hJ : J.normSq.AwayFromZero) (hz : I.Contains z) (hw : J.Contains w) : (I.div J hJ).Contains (z / w) := by have hconj : J.conj.Contains (starRingEnd ℂ w) := by exact ⟨by simpa [conj] using hw.1, by simpa [conj] using RatInterval.neg_sound hw.2⟩ have hnum : (I.mul J.conj).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.CertifiedContourIntervalArithmetic.ComplexRatInterval.div_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:102 · uses ComplexRatInterval , Contains , div , normSq , AwayFromZero
def normInterval unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

Applying rational square-root bounds to the squared-modulus interval produces an executable enclosure of the complex norm.

Definition (Lean source)
def normInterval (I : ComplexRatInterval) (fuel : ℕ) : RatInterval := RatInterval.sqrtInterval I.normSq (normSq_lo_nonneg I) fuel
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.normInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:475 · 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.CertifiedContourIntervalArithmetic.ComplexRatInterval.point_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/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 :
    I.width ≤ w
    I.maxAbs ≤ 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 : I.width ≤ w) : I.maxAbs ≤ 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.CertifiedContourIntervalArithmetic.ComplexRatInterval.maxAbs_le_of_contains_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:59
  • neg_sound theorem — Complex rectangle negation encloses negated complex values.
    z :
    hz :
    I.Contains z
    I.neg.Contains (-z)
    Proof (Lean source)
    theorem neg_sound {I : ComplexRatInterval} {z : ℂ} (hz : I.Contains z) : I.neg.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.CertifiedContourIntervalArithmetic.ComplexRatInterval.neg_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:73
  • sub_sound theorem — Complex rectangle subtraction encloses differences of enclosed values.
    z w :
    hz :
    I.Contains z
    hw :
    J.Contains w
    (I.sub J).Contains (z - w)
    Proof (Lean source)
    theorem sub_sound {I J : ComplexRatInterval} {z w : ℂ} (hz : I.Contains z) (hw : J.Contains w) : (I.sub J).Contains (z - w) := by simpa [sub, sub_eq_add_neg] using add_sound hz (neg_sound hw)
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.sub_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:79
  • mul_sound theorem — Complex rectangle multiplication encloses products of enclosed values.
    z w :
    hz :
    I.Contains z
    hw :
    J.Contains w
    (I.mul J).Contains (z * w)
    Proof (Lean source)
    theorem mul_sound {I J : ComplexRatInterval} {z w : ℂ} (hz : I.Contains z) (hw : J.Contains w) : (I.mul 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.CertifiedContourIntervalArithmetic.ComplexRatInterval.mul_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:84
  • normSq_sound theorem — The squared-modulus interval contains the squared complex norm.
    z :
    hz :
    I.Contains z
    I.normSq.Contains (‖z‖ ^ 2)
    Proof (Lean source)
    theorem normSq_sound {I : ComplexRatInterval} {z : ℂ} (hz : I.Contains z) : I.normSq.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.CertifiedContourIntervalArithmetic.ComplexRatInterval.normSq_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:95
  • width_conj theorem — Conjugation preserves rectangle width.
    I.conj.width = I.width
    Proof (Lean source)
    theorem width_conj (I : ComplexRatInterval) : I.conj.width = I.width := by simp [width, conj, RatInterval.width_neg]
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.width_conj · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:124
  • maxAbs_conj theorem — Conjugation preserves the maximum coordinate endpoint magnitude.
    I.conj.maxAbs = I.maxAbs
    Proof (Lean source)
    theorem maxAbs_conj (I : ComplexRatInterval) : I.conj.maxAbs = I.maxAbs := by simp [maxAbs, conj, RatInterval.maxAbs_neg]
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.maxAbs_conj · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:128
  • 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
    (I.tighten J).Contains z ∧ (I.tighten J).Subinterval I
    Proof (Lean source)
    theorem tighten_sound_left {I J : ComplexRatInterval} {z : ℂ} (hI : I.Contains z) (hJ : J.Contains z) : (I.tighten J).Contains z ∧ (I.tighten 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.CertifiedContourIntervalArithmetic.ComplexRatInterval.tighten_sound_left · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:132
  • width_add theorem — Complex rectangle addition has exactly the maximum of the two summed coordinate widths.
    (I.add J).width = max (I.re.width + J.re.width) (I.im.width + J.im.width)
    Proof (Lean source)
    theorem width_add (I J : ComplexRatInterval) : (I.add J).width = max (I.re.width + J.re.width) (I.im.width + J.im.width) := by simp [width, add, RatInterval.width_add]
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.width_add · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:142
  • mul_maxAbs theorem — Complex rectangle multiplication has twice the product of operand coordinate magnitude bounds as an executable magnitude bound.
    (I.mul J).maxAbs ≤ 2 * I.maxAbs * J.maxAbs
    Proof (Lean source)
    theorem mul_maxAbs (I J : ComplexRatInterval) : (I.mul J).maxAbs ≤ 2 * I.maxAbs * J.maxAbs := by have hIre : I.re.maxAbs ≤ I.maxAbs := le_max_left _ _ have hIim : I.im.maxAbs ≤ I.maxAbs := le_max_right _ _ have hJre : J.re.maxAbs ≤ J.maxAbs := le_max_left _ _ have hJim : J.im.maxAbs ≤ J.maxAbs := le_max_right _ _ have hI0 : 0 ≤ I.maxAbs := (abs_nonneg I.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hJ0 : 0 ≤ J.maxAbs := (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 ≤ I.maxAbs * J.maxAbs := 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 ≤ I.maxAbs * J.maxAbs := 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 ≤ I.maxAbs * J.maxAbs := 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 ≤ I.maxAbs * J.maxAbs := 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.CertifiedContourIntervalArithmetic.ComplexRatInterval.mul_maxAbs · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:148
  • rat_sq_width_le theorem — Squaring an interval has width at most twice its maximum endpoint magnitude times its width.
    K.sq.width ≤ 2 * K.maxAbs * K.width
    Proof (Lean source)
    theorem rat_sq_width_le (K : RatInterval) : K.sq.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.CertifiedContourIntervalArithmetic.ComplexRatInterval.rat_sq_width_le · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:281
  • rat_sq_hi_le theorem — The upper endpoint of a squared interval is bounded by the square of its maximum endpoint magnitude.
    K.sq.hi ≤ K.maxAbs ^ 2
    Proof (Lean source)
    theorem rat_sq_hi_le (K : RatInterval) : K.sq.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.CertifiedContourIntervalArithmetic.ComplexRatInterval.rat_sq_hi_le · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:287
  • 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.CertifiedContourIntervalArithmetic.ComplexRatInterval.rat_maxAbs_mono · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:302
  • mul_width theorem — Each coordinate width after complex multiplication is bounded explicitly by the operand widths and endpoint magnitudes.
    (I.mul J).width ≤ 2 * (I.maxAbs * J.width + J.maxAbs * I.width)
    Proof (Lean source)
    theorem mul_width (I J : ComplexRatInterval) : (I.mul J).width ≤ 2 * (I.maxAbs * J.width + J.maxAbs * I.width) := by have hIreA : I.re.maxAbs ≤ I.maxAbs := le_max_left _ _ have hIimA : I.im.maxAbs ≤ I.maxAbs := le_max_right _ _ have hJreA : J.re.maxAbs ≤ J.maxAbs := le_max_left _ _ have hJimA : J.im.maxAbs ≤ J.maxAbs := le_max_right _ _ have hIrew : I.re.width ≤ I.width := le_max_left _ _ have hIimw : I.im.width ≤ I.width := le_max_right _ _ have hJrew : J.re.width ≤ J.width := le_max_left _ _ have hJimw : J.im.width ≤ J.width := le_max_right _ _ have hIA0 : 0 ≤ I.maxAbs := (abs_nonneg I.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hJA0 : 0 ≤ J.maxAbs := (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 ≤ I.maxAbs * J.width + J.maxAbs * I.width := 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 ≤ I.maxAbs * J.width + J.maxAbs * I.width := 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 ≤ I.maxAbs * J.width + J.maxAbs * I.width := 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 ≤ I.maxAbs * J.width + J.maxAbs * I.width := 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 * (I.maxAbs * J.width + J.maxAbs * I.width) rw [RatInterval.width_sub, RatInterval.width_add] exact max_le (by linarith) (by linarith)
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.mul_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:309
  • normSq_width theorem — The squared-modulus interval width is controlled by rectangle magnitude and rectangle width.
    I.normSq.width ≤ 4 * I.maxAbs * I.width
    Proof (Lean source)
    theorem normSq_width (I : ComplexRatInterval) : I.normSq.width ≤ 4 * I.maxAbs * I.width := by have hre := rat_sq_width_le I.re have him := rat_sq_width_le I.im have hA0 : 0 ≤ I.maxAbs := (abs_nonneg I.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hreprod : I.re.maxAbs * I.re.width ≤ I.maxAbs * I.width := mul_le_mul (le_max_left _ _) (le_max_left _ _) (RatInterval.width_nonneg I.re) hA0 have himprod : I.im.maxAbs * I.im.width ≤ I.maxAbs * I.width := mul_le_mul (le_max_right _ _) (le_max_right _ _) (RatInterval.width_nonneg I.im) hA0 rw [normSq, RatInterval.width_add] nlinarith
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.normSq_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:356
  • 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 :
    J.normSq.AwayFromZero
    δ :
    :
    0 < δ
    hsep :
    δ ≤ J.normSq.lo
    (I.div J hJ).maxAbs ≤ (I.mul J.conj).maxAbs / δ
    Proof (Lean source)
    theorem div_maxAbs {I J : ComplexRatInterval} (hJ : J.normSq.AwayFromZero) {δ : ℚ} (hδ : 0 < δ) (hsep : δ ≤ J.normSq.lo) : (I.div J hJ).maxAbs ≤ (I.mul J.conj).maxAbs / δ := by let N := I.mul J.conj let D := J.normSq 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 ≤ N.maxAbs := (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 ≤ N.maxAbs / δ := by calc _ ≤ N.re.maxAbs * (D.inv hJ).maxAbs := hre _ ≤ N.maxAbs * (1 / δ) := mul_le_mul (le_max_left _ _) hinvA hinv0 hN0 _ = N.maxAbs / δ := by ring have him' : (N.im.mul (D.inv hJ)).maxAbs ≤ N.maxAbs / δ := by calc _ ≤ N.im.maxAbs * (D.inv hJ).maxAbs := him _ ≤ N.maxAbs * (1 / δ) := mul_le_mul (le_max_right _ _) hinvA hinv0 hN0 _ = N.maxAbs / δ := by ring change max (N.re.div D hJ).maxAbs (N.im.div D hJ).maxAbs ≤ N.maxAbs / δ change max (N.re.mul (D.inv hJ)).maxAbs (N.im.mul (D.inv hJ)).maxAbs ≤ N.maxAbs / δ exact max_le hre' him'
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.div_maxAbs · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:373
  • div_width theorem — If the squared-modulus denominator has certified lower bound δ, guarded division propagates widths with the usual inverse-square factor.
    hJ :
    J.normSq.AwayFromZero
    δ :
    :
    0 < δ
    hsep :
    δ ≤ J.normSq.lo
    (I.div J hJ).width
    ≤ (I.mul J.conj).maxAbs * J.normSq.width / (δ ^ 2) + (I.mul J.conj).width / δ
    Proof (Lean source)
    theorem div_width {I J : ComplexRatInterval} (hJ : J.normSq.AwayFromZero) {δ : ℚ} (hδ : 0 < δ) (hsep : δ ≤ J.normSq.lo) : (I.div J hJ).width ≤ (I.mul J.conj).maxAbs * J.normSq.width / (δ ^ 2) + (I.mul J.conj).width / δ := by let N := I.mul J.conj let D := J.normSq 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 ≤ N.maxAbs := (abs_nonneg N.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hNW : 0 ≤ N.width := (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 ≤ N.maxAbs := le_max_left _ _ have himA : N.im.maxAbs ≤ N.maxAbs := le_max_right _ _ have hrew : N.re.width ≤ N.width := le_max_left _ _ have himw : N.im.width ≤ N.width := le_max_right _ _ have hre' : (N.re.mul (D.inv hJ)).width ≤ N.maxAbs * (D.width / δ ^ 2) + (1 / δ) * N.width := 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 ≤ N.maxAbs * (D.width / δ ^ 2) + (1 / δ) * N.width := 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 ≤ N.maxAbs * D.width / δ ^ 2 + N.width / δ 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.CertifiedContourIntervalArithmetic.ComplexRatInterval.div_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:412
  • normSq_lo_nonneg theorem — Applying rational square-root bounds to the squared-modulus interval produces an executable enclosure of the complex norm.
    0 ≤ I.normSq.lo
    Proof (Lean source)
    theorem normSq_lo_nonneg (I : ComplexRatInterval) : 0 ≤ I.normSq.lo := by have hsquare (K : RatInterval) : 0 ≤ K.sq.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.CertifiedContourIntervalArithmetic.ComplexRatInterval.normSq_lo_nonneg · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:466
  • normInterval_sound theorem — The executable modulus interval contains the norm of every enclosed complex value.
    z :
    hz :
    I.Contains z
    fuel :
    (I.normInterval fuel).Contains ‖z‖
    Proof (Lean source)
    theorem normInterval_sound {I : ComplexRatInterval} {z : ℂ} (hz : I.Contains z) (fuel : ℕ) : (I.normInterval 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.CertifiedContourIntervalArithmetic.ComplexRatInterval.normInterval_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:480
Interval­Exp 3 core · 2 supporting 3 to review 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 unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

The exponential midpoint extension uses the promoted scalar exponential and a magnitude-dependent Lipschitz expansion for the input radius.

Definition (Lean source)
def expIntervalRaw (I : RatInterval) (fuel : ℕ) : RatInterval := let center := intervalMid I let ecenter := expScalar center fuel let upper := (expScalar I.maxAbs fuel).hi ecenter.expand (upper * intervalRadius I) (by have hs := Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.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.CertifiedContourIntervalArithmetic.Complex.Transcendental.expIntervalRaw · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/IntervalExp.lean:15 · uses RatInterval
def expInterval unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Exponential interval outputs recursively intersect all midpoint bounds seen so far.

Definition (Lean source)
def expInterval (I : RatInterval) : ℕ → RatInterval | 0 => expIntervalRaw I 0 | fuel + 1 => (expInterval I fuel).tighten (expIntervalRaw I (fuel + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.expInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/IntervalExp.lean:34 · uses RatInterval
theorem expInterval_width unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.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
≤ (expScalar (intervalMid I) fuel).width
+ 2 * (expScalar I.maxAbs fuel).hi * intervalRadius I
Proof (Lean source)
theorem expInterval_width (I : RatInterval) (fuel : ℕ) : (expInterval I fuel).width ≤ (expScalar (intervalMid I) fuel).width + 2 * (expScalar I.maxAbs fuel).hi * intervalRadius I := by have hraw : (expIntervalRaw I fuel).width = (expScalar (intervalMid I) fuel).width + 2 * (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 (tighten_subinterval_right (expInterval_sound hmid fuel) (expIntervalRaw_sound hmid (fuel + 1)))).trans_eq hraw
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.expInterval_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/IntervalExp.lean:107 · uses expInterval , intervalMid , intervalRadius , RatInterval , maxAbs , width , expScalar
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.CertifiedContourIntervalArithmetic.Complex.Transcendental.expInterval_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/IntervalExp.lean:89
  • 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.CertifiedContourIntervalArithmetic.Complex.Transcendental.expInterval_nested · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/IntervalExp.lean:97
Names 8 core · 2 supporting 8 to review This module represents complex values by effectively refining nested rational rectangles and derives certified modulus names from them. ★ norm_width_at_precision

Certified complex names

This module represents complex values by effectively refining nested rational rectangles and derives certified modulus names from them.

structure CertifiedComplex unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

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 computable 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 executable fuel selected for a requested positive rational width.
modulus :
PosRat → ℕ
The selected rectangle meets the requested coordinate-width tolerance.
width_modulus :
∀ ε, (approx (modulus ε)).width ≤ ε.1
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Names.lean:13
def refine unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex

A certified complex name refines effectively to a requested rational width.

Definition (Lean source)
def refine (z : CertifiedComplex) (ε : PosRat) : ComplexRatInterval := z.approx (z.modulus ε)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex.refine · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Names.lean:47 · uses CertifiedComplex , ComplexRatInterval , PosRat
def ofRatPair unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex

A rational complex point has the constant point rectangle as its certified name.

Definition (Lean source)
def ofRatPair (x y : ℚ) : CertifiedComplex where value := (x : ℝ) + (y : ℝ) * I approx := fun _ => ComplexRatInterval.point x y nested := by intro n exact ⟨RatInterval.subinterval_refl _, RatInterval.subinterval_refl _⟩ contains := by intro n; exact ComplexRatInterval.point_sound x y modulus := fun _ => 0 width_modulus := by intro ε simpa [ComplexRatInterval.width, ComplexRatInterval.point, RatInterval.width, RatInterval.point] using ε.2.le
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex.ofRatPair · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Names.lean:55 · uses CertifiedComplex
def add unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex

Adding certified complex names uses equal-fuel rectangle addition and a half-tolerance refinement for each operand.

Definition (Lean source)
def add (z w : CertifiedComplex) : CertifiedComplex where value := z.value + w.value approx := fun n => (z.approx n).add (w.approx n) 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⟩ contains := by intro n; exact ComplexRatInterval.add_sound (z.contains n) (w.contains n) modulus := fun ε => max (z.modulus ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩) (w.modulus ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩) width_modulus := by intro ε let δ : PosRat := ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩ let k := max (z.modulus δ) (w.modulus δ) have hz : (z.approx k).width ≤ δ.1 := (rectangle_width_mono (approx_mono z (le_max_left _ _))).trans (z.width_modulus δ) have hw : (w.approx k).width ≤ δ.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.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex.add · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Names.lean:69 · uses CertifiedComplex
def normApprox unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex

Modulus evaluation on a refining complex name recursively intersects the current Newton enclosure with every preceding output.

Definition (Lean source)
def normApprox (z : CertifiedComplex) : ℕ → RatInterval | 0 => (z.approx 0).normInterval 0 | fuel + 1 => (normApprox z fuel).tighten ((z.approx (fuel + 1)).normInterval (fuel + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex.normApprox · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Names.lean:102 · uses CertifiedComplex , RatInterval
def normPrecision unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex

A conservative executable modulus precision includes both input-name diameter and Newton iteration fuel, including the nondifferentiable origin.

Definition (Lean source)
def normPrecision (z : CertifiedComplex) (ε : PosRat) : ℕ := let M := (z.approx 0).maxAbs let δ : PosRat := ⟨ε.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)⟩ max (z.modulus δ) (64 * (ε.1.den + 1) * (M.num.natAbs + 2) ^ 2)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex.normPrecision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Names.lean:109 · uses CertifiedComplex , PosRat
theorem norm_width_at_precision unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.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 := (z.approx 0).maxAbs 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 := K.normSq have hKK0 : K.Subinterval K0 := approx_mono z (zero_le k) have hKw : K.width ≤ δ.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 = K.re.sq.width + K.im.sq.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 K.re.sq.hi + K.im.sq.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 : (K.normInterval 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.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex.norm_width_at_precision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Names.lean:164 · uses CertifiedComplex , normApprox , normPrecision , PosRat , width
def norm unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex

Complex modulus lifts a refining certified complex name to a certified real name.

Definition (Lean source)
noncomputable def norm (z : CertifiedComplex) : CertifiedReal where value := ‖z.value‖ approx := normApprox z nested := fun fuel => (normApprox_spec z fuel).2 contains := by intro fuel; exact (normApprox_spec z fuel).1 modulus := normPrecision z width_modulus := norm_width_at_precision z
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex.norm · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Names.lean:307 · uses CertifiedReal , CertifiedComplex
2 supporting declarations (lemmas, instances)
  • refine_spec theorem — Effective refinement preserves containment and meets its requested width.
    (z.refine ε).Contains z.value ∧ (z.refine ε).width ≤ ε.1
    Proof (Lean source)
    theorem refine_spec (z : CertifiedComplex) (ε : PosRat) : (z.refine ε).Contains z.value ∧ (z.refine ε).width ≤ ε.1 := by exact ⟨z.contains _, z.width_modulus ε⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex.refine_spec · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Names.lean:50
  • normApprox_spec theorem — Recursive modulus approximations contain the norm and are adjacent-fuel nested.
    fuel :
    (normApprox z fuel).Contains ‖z.value‖ ∧
    (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.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex.normApprox_spec · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Names.lean:120
Complex­Exp 13 core · 5 supporting 13 to review 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 unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Raw complex exponential evaluation composes certified real exponential, cosine, and sine interval extensions coordinatewise.

Definition (Lean source)
def complexExpRaw (I : ComplexRatInterval) (fuel : ℕ) : ComplexRatInterval := ⟨(expInterval I.re fuel).mul (cosInterval I.im fuel), (expInterval I.re fuel).mul (sinInterval I.im fuel)⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExpRaw · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:21 · uses ComplexRatInterval
def complexExp unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Complex exponential outputs recursively intersect raw compositional bounds for one fixed input rectangle.

Definition (Lean source)
def complexExp (I : ComplexRatInterval) : ℕ → ComplexRatInterval | 0 => complexExpRaw I 0 | fuel + 1 => (complexExp I fuel).tighten (complexExpRaw I (fuel + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExp · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:27 · uses ComplexRatInterval
def complexExpMagnitude unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

The initial real-part enclosure gives a positive rational amplification scale for all later exponential stages.

Definition (Lean source)
def complexExpMagnitude (z : CertifiedComplex) : ℚ := |(expScalar (z.approx 0).re.maxAbs 0).hi| + 2
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExpMagnitude · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:120 · uses CertifiedComplex
def complexExpStageTolerance unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

The canonical error target at name stage n is the reciprocal of n + 1.

Definition (Lean source)
def complexExpStageTolerance (n : ℕ) : PosRat := ⟨1 / (n + 1 : ℚ), by positivity⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExpStageTolerance · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:126 · uses PosRat
def complexExpInnerTolerance unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

The inner scalar-operation tolerance spends the stage budget after dividing by the certified magnitude amplification scale.

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

The input-name tolerance also pays for exponential Lipschitz amplification, so a large positive real part requests a proportionally narrower input box.

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

A complex exponential stage refines its input using the magnitude-sensitive tolerance selected for that stage.

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

Taylor fuel for a stage is computed from the rational midpoint and magnitude of the input rectangle actually returned, not from a denominator ordering heuristic.

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

One executable complex exponential name stage uses its scheduled input rectangle and the Taylor fuel computed from that same rectangle.

Definition (Lean source)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExpStage · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:168 · uses CertifiedComplex , ComplexRatInterval
def complexExpNameApprox unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Certified complex-exponential name approximations recursively intersect every scheduled stage output seen so far.

Definition (Lean source)
def complexExpNameApprox (z : CertifiedComplex) : ℕ → ComplexRatInterval | 0 => complexExpStage z 0 | n + 1 => (complexExpNameApprox z n).tighten (complexExpStage z (n + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExpNameApprox · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:173 · uses CertifiedComplex , ComplexRatInterval
def complexExpPrecision unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

The denominator of a requested rational tolerance selects a stage whose canonical reciprocal target is no larger than that tolerance.

Definition (Lean source)
def complexExpPrecision (_z : CertifiedComplex) (ε : PosRat) : ℕ := ε.1.den
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExpPrecision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:546 · uses CertifiedComplex , PosRat
theorem complexExp_width_at_precision unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.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
(complexExpNameApprox z (complexExpPrecision z ε)).width ≤ ε.1
Proof (Lean source)
theorem complexExp_width_at_precision (z : CertifiedComplex) (ε : PosRat) : (complexExpNameApprox z (complexExpPrecision z ε)).width ≤ ε.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 : (complexExpNameApprox z N).width ≤ (complexExpStage z N).width := 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 Nat.le_succ ε.1.den) exact hmono.trans (hstage.trans (hrecip.trans (inv_den_le_of_pos ε.1 ε.2)))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExp_width_at_precision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:550 · uses CertifiedComplex , complexExpNameApprox , complexExpPrecision , width , PosRat
def complexExpName unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Complex exponential lifts a certified complex input to a certified complex output without storing exact values in any returned rectangle.

Definition (Lean source)
noncomputable def complexExpName (z : CertifiedComplex) : CertifiedComplex where value := exp z.value approx := complexExpNameApprox z nested := fun n => (complexExpNameApprox_spec z n).2 contains := by intro n; exact (complexExpNameApprox_spec z n).1 modulus := complexExpPrecision z width_modulus := complexExp_width_at_precision z
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExpName · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:573 · 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.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExp_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:42
  • 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.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExp_nested · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:51
  • complexExp_width theorem — Complex exponential width is bounded explicitly by the widths and endpoint magnitudes of its certified exponential and trigonometric factors.
    fuel :
    (complexExp I fuel).width
    ≤ 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 : ℕ) : (complexExp I fuel).width ≤ 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 ⟨ Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.tighten_subinterval_right hprev.1 hraw.1, Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Transcendental.tighten_subinterval_right hprev.2 hraw.2⟩ have hwidth : (complexExp I fuel).width ≤ (complexExpRaw I fuel).width := max_le_max (RatInterval.width_mono hsub.1) (RatInterval.width_mono hsub.2) have hraw_eq : complexExpRaw I fuel = A.mul 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.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExp_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:69
  • complexExpNameApprox_spec theorem — Recursive complex-exponential name approximations remain sound and adjacent stages are nested by their defining finite intersection.
    n :
    (complexExpNameApprox z n).Contains (exp z.value) ∧
    (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.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExpNameApprox_spec · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:183
  • 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 :
    Proof (Lean source)
    theorem complexExpStage_width (z : CertifiedComplex) (n : ℕ) : (complexExpStage z n).width ≤ (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 := 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 ((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 : K.width ≤ τ / (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 : expPrecision (intervalMid K.re) α ≤ N := by dsimp [N, complexExpStageFuel, K, α] exact (le_max_left _ _).trans (le_max_right _ _) have hNexpAbs : 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 Nat.le_succ α.1.den)).trans (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 Nat.le_succ α.1.den)).trans (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 : (expScalar (intervalMid K.re) N).width ≤ α.1 := by exact (RatInterval.width_mono (expScalar_subinterval_of_le (intervalMid K.re) hNexpMid)).trans (expScalar_width (intervalMid K.re) α) have hscalarAbs : (expScalar K.re.maxAbs N).width ≤ α.1 := by exact (RatInterval.width_mono (expScalar_subinterval_of_le K.re.maxAbs hNexpAbs)).trans (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 := Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.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 : (expScalar K.re.maxAbs N).hi ≤ B := by change (expScalar K.re.maxAbs N).hi ≤ |S0.hi| + 2 have hUs := Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.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 : ((expScalar K.re.maxAbs N).hi : ℝ) ≤ exp (K.re.maxAbs : ℝ) + α.1 := by have hw : (((expScalar K.re.maxAbs N).hi : ℝ) - (expScalar K.re.maxAbs N).lo) ≤ α.1 := by exact_mod_cast hscalarAbs nlinarith [hUs.1] have hUS0 : ((expScalar K.re.maxAbs N).hi : ℝ) ≤ (S0.hi : ℝ) + α.1 := by nlinarith [hS0.2] have hUS0q : (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 : (expScalar K.re.maxAbs N).hi * K.re.width ≤ τ / 4 := by have hu0 : 0 ≤ (expScalar K.re.maxAbs N).hi := by exact_mod_cast (Real.exp_pos (K.re.maxAbs : ℝ)).le.trans (Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.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 (abs_nonneg S0.hi) 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 (by norm_num) 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 (by norm_num) hτpos.le).trans (by nlinarith [hτone]) have hout := complexExp_width K N change (complexExp K N).width ≤ η 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' : (complexExp K N).width ≤ 2 * (E.maxAbs * max C.width S.width + -- … truncated; follow the source link for the rest …
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExpStage_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:278
Circle­Schedule 11 core · 5 supporting 11 to review This module defines the single schedule record consumed by execution, traces, and specifications. ★ circleNode_sound

Shared schedules and certified circle nodes

This module defines the single schedule record consumed by execution, traces, 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 unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

A contour schedule packages a requested rational error tolerance, an operation count, an input precision, a mesh size that is nonempty, a fuel budget for transcendental evaluation, and a nonnegative magnitude-amplification bound, together with three nonnegative error budgets — [for node evaluation](hyp:nodeBudget, nodeBudget_nonneg), for the uniform mesh, and for the final quadrature widening — such that the three budgets together fit within the tolerance and the mesh budget absorbs the magnitude-amplified discretization error.

Definition (Lean source)
The requested final rational tolerance.
tolerance :
Number of primitive interval operations in 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 nonnegative bound for magnitude-dependent error amplification.
magnitude :
The magnitude amplification bound is nonnegative.
magnitude_nonneg :
0 ≤ magnitude
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 magnitude-amplified discretization error.
mesh_error_le :
magnitude / mesh ≤ meshBudget
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Schedule · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:16
def canonical unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Schedule

A canonical schedule splits tolerance equally and chooses conservative integer fuel and mesh from the exact rational denominator and magnitude.

Definition (Lean source)
def Schedule.canonical (tolerance : PosRat) (operationCount : ℕ) (magnitude : ℚ) (hmagnitude : 0 ≤ magnitude) : Schedule where tolerance := tolerance operationCount := operationCount inputPrecision := 64 * (operationCount + 1) * (tolerance.1.den + 1) * (magnitude.num.natAbs + 2) ^ 2 mesh := 3 * (magnitude.num.natAbs + 1) * tolerance.1.den mesh_pos := by positivity fuel := 64 * (operationCount + 1) * (tolerance.1.den + 1) * (magnitude.num.natAbs + 2) ^ 2 magnitude := magnitude magnitude_nonneg := hmagnitude nodeBudget := tolerance.1 / 3 meshBudget := tolerance.1 / 3 quadratureBudget := tolerance.1 / 3 nodeBudget_nonneg := by exact (div_nonneg tolerance.2.le (by norm_num)) meshBudget_nonneg := by exact (div_nonneg tolerance.2.le (by norm_num)) quadratureBudget_nonneg := by exact (div_nonneg tolerance.2.le (by norm_num)) budget_sum_le := by linarith mesh_error_le := by have hMle : magnitude ≤ (magnitude.num.natAbs : ℕ) := by have hnum0 : 0 ≤ magnitude.num := Rat.num_nonneg.mpr hmagnitude calc magnitude = (magnitude.num : ℚ) / (magnitude.den : ℕ) := (Rat.num_div_den magnitude).symm _ ≤ (magnitude.num : ℚ) := div_le_self (by exact_mod_cast hnum0) (by exact_mod_cast Rat.den_pos magnitude) _ = (magnitude.num.natAbs : ℕ) := by have hi : (magnitude.num.natAbs : ℤ) = magnitude.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 : ℚ) ≤ magnitude.num.natAbs + 1 := by positivity have hcoarse : magnitude ≤ tolerance.1 * (((magnitude.num.natAbs : ℚ) + 1) * tolerance.1.den) := by calc magnitude ≤ (magnitude.num.natAbs : ℕ) := hMle _ ≤ (magnitude.num.natAbs + 1 : ℕ) := by exact_mod_cast Nat.le_succ _ _ ≤ tolerance.1 * (((magnitude.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, cast_one] calc magnitude / (3 * (magnitude.num.natAbs + 1) * tolerance.1.den) ≤ (tolerance.1 * ((magnitude.num.natAbs + 1) * tolerance.1.den)) / (3 * (magnitude.num.natAbs + 1) * tolerance.1.den) := div_le_div_of_nonneg_right hcoarse (by positivity) _ = tolerance.1 / 3 := by field_simp
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Schedule.canonical · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:59 · uses Schedule , PosRat
structure TraceEvent unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

A trace event retains the schedule object itself, so execution and semantic audit cannot silently disagree about fuel, mesh, or precision.

Definition (Lean source)
The exact shared schedule used for this event.
schedule :
The endpoint index evaluated by the event.
node :
The primitive-operation ordinal within the node program.
operation :
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.TraceEvent · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:122
def circleNodeEvent unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

A circle-node trace event uses the schedule definitionally, not a copied fuel field.

Definition (Lean source)
def circleNodeEvent (schedule : Schedule) (node operation : ℕ) : TraceEvent := ⟨schedule, node, operation⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.circleNodeEvent · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:132 · uses Schedule , TraceEvent
def circleAngle unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

The rational rectangle for the pure-imaginary angle 2 * π * k / mesh uses the π enclosure at the schedule's input precision.

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

The scheduled rational circle node computes radius * exp(2 * π * i * k / mesh) entirely through executable rational rectangle operations.

Definition (Lean source)
def circleNode (radius : ℚ) (schedule : Schedule) (k : ℕ) : ComplexRatInterval := (Transcendental.complexExp (circleAngle schedule k) schedule.fuel).smulRat radius
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.circleNode · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:143 · uses Schedule , ComplexRatInterval
def circleInnerTolerance unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

The internal circle tolerance is capped by one so the elementary-factor magnitude estimates used in complex multiplication remain uniform.

Definition (Lean source)
def circleInnerTolerance (radius : ℚ) (target : PosRat) : PosRat := ⟨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.CertifiedContourIntervalArithmetic.Complex.circleInnerTolerance · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:148 · uses PosRat
def circleInputPrecision unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

The uniform π precision selected for a requested circle-node width uses only rational data and is shared by every endpoint of the mesh.

Definition (Lean source)
def circleInputPrecision (radius : ℚ) (target : PosRat) : ℕ := Transcendental.piPrecision (circleInnerTolerance radius target)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.circleInputPrecision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:157 · uses PosRat
def circleExpFuel unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

A uniform Taylor fuel selected for a requested circle-node width is an explicit rational-data bound valid for all endpoints of the finite mesh.

Definition (Lean source)
def circleExpFuel (radius : ℚ) (_mesh : ℕ) (target : PosRat) : ℕ := max (expPrecision 0 (circleInnerTolerance radius target)) (32 * ((circleInnerTolerance radius target).1.den + 1) * 12 ^ 2)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.circleExpFuel · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:162 · uses PosRat
def exactCircleNode unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

The exact semantic circle node corresponding to the scheduled rational endpoint.

Definition (Lean source)
noncomputable def exactCircleNode (radius : ℚ) (schedule : Schedule) (k : ℕ) : ℂ := (radius : ℂ) * exp (((2 : ℝ) * pi * ((k : ℝ) / schedule.mesh)) * I)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.exactCircleNode · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:383 · uses Schedule
theorem circleNode_sound unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

For a rational radius, a quadrature schedule, and a mesh index k, if k does not exceed the schedule's mesh size, then 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 :
k :
hk :
k ≤ schedule.mesh
(circleNode radius schedule k).Contains (exactCircleNode radius schedule k)
Proof (Lean source)
theorem circleNode_sound (radius : ℚ) (schedule : Schedule) {k : ℕ} (hk : k ≤ schedule.mesh) : (circleNode radius schedule k).Contains (exactCircleNode radius schedule k) := by exact ComplexRatInterval.smulRat_sound radius (Transcendental.complexExp_sound (circleAngle_sound schedule hk) schedule.fuel)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.circleNode_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:406 · uses Schedule , circleNode , exactCircleNode , Contains
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 :
    target :
    hprecision :
    schedule.inputPrecision = circleInputPrecision radius target
    hfuel :
    circleExpFuel radius schedule.mesh target ≤ schedule.fuel
    k :
    hk :
    k ≤ schedule.mesh
    (circleNode radius schedule k).width ≤ 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) : (circleNode radius schedule k).width ≤ 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 : 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 : (expScalar 0 schedule.fuel).width ≤ τ.1 := by exact (RatInterval.width_mono (CertifiedReal.approx_mono (expName 0) hfuelExp)).trans (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 Nat.le_succ τ.1.den)).trans (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 Nat.le_succ τ.1.den)).trans (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' : (Transcendental.complexExp (circleAngle schedule k) schedule.fuel).width ≤ 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 : (Transcendental.complexExp (circleAngle schedule k) schedule.fuel).width ≤ 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 * (Transcendental.complexExp (circleAngle schedule k) schedule.fuel).width ≤ radius * (14 * τ.1) := mul_le_mul_of_nonneg_left hcomplex hradius _ ≤ target.1 := by nlinarith
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.circleNode_width_at_selected_precision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:219
  • circleAngle_sound theorem — The angle rectangle contains the exact pure-imaginary angle at every endpoint from zero through the terminal mesh endpoint.
    schedule :
    k :
    hk :
    k ≤ schedule.mesh
    (circleAngle schedule k).Contains (((2 : ℝ) * pi * ((k : ℝ) / schedule.mesh)) * I)
    Proof (Lean source)
    theorem circleAngle_sound (schedule : Schedule) {k : ℕ} (hk : k ≤ schedule.mesh) : (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.CertifiedContourIntervalArithmetic.Complex.circleAngle_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:388
  • 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 :
    (circleNode radius schedule schedule.mesh).Contains (radius : ℂ) ∧
    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 (le_refl schedule.mesh) · exact hexact
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.circleNode_endpoint · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:416
  • circleNode_width theorem — Circle-node width propagation exposes radius scaling and the scheduled complex-exponential approximation width.
    radius :
    hradius :
    0 ≤ radius
    schedule :
    k :
    (circleNode radius schedule k).width
    ≤ radius * (Transcendental.complexExp (circleAngle schedule k) schedule.fuel).width
    Proof (Lean source)
    theorem circleNode_width (radius : ℚ) (hradius : 0 ≤ radius) (schedule : Schedule) (k : ℕ) : (circleNode radius schedule k).width ≤ radius * (Transcendental.complexExp (circleAngle schedule k) schedule.fuel).width := 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.CertifiedContourIntervalArithmetic.Complex.circleNode_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:432
  • circleNode_schedule_correspondence theorem — Reading operation count, input precision, fuel, and mesh from the trace and from execution gives definitionally the same data because both retain the shared schedule object.
    radius :
    schedule :
    k operation :
    (circleNodeEvent schedule k operation).schedule.operationCount = schedule.operationCount ∧
    (circleNodeEvent schedule k operation).schedule.inputPrecision = schedule.inputPrecision ∧
    (circleNodeEvent schedule k operation).schedule.fuel = schedule.fuel ∧
    (circleNodeEvent schedule k operation).schedule.mesh = schedule.mesh ∧
    circleNode radius (circleNodeEvent schedule k operation).schedule k
    = circleNode radius schedule k
    Proof (Lean source)
    theorem circleNode_schedule_correspondence (radius : ℚ) (schedule : Schedule) (k operation : ℕ) : (circleNodeEvent schedule k operation).schedule.operationCount = schedule.operationCount ∧ (circleNodeEvent schedule k operation).schedule.inputPrecision = schedule.inputPrecision ∧ (circleNodeEvent schedule k operation).schedule.fuel = schedule.fuel ∧ (circleNodeEvent schedule k operation).schedule.mesh = schedule.mesh ∧ circleNode radius (circleNodeEvent schedule k operation).schedule k = circleNode radius schedule k := by exact ⟨rfl, rfl, rfl, rfl, rfl⟩
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.circleNode_schedule_correspondence · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:455
Contour­Program 20 core · 0 supporting 20 to review This module packages executable interval extensions of numerator and denominator maps, evaluates their normalized circle integrand at every mesh endpoint, and feeds those rectangles to deterministic trapezoidal quadratur ★ nodeTrace_spec

Certified finite contour programs

This module packages executable interval extensions of numerator and denominator maps, evaluates their normalized circle integrand at every mesh endpoint, and feeds those rectangles to deterministic trapezoidal quadrature. The final theorem combines denominator separation, node soundness, mesh error, and the shared split budget into one containment-and-width certificate.

structure ContourProgram unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

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.CertifiedContourIntervalArithmetic.Complex.ContourProgram · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:20
def operationCount unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

The structural operation count of one contour node includes both certified map programs, guarded division, and multiplication by the circle node.

Definition (Lean source)
def ContourProgram.operationCount (program : ContourProgram) : ℕ := program.numerator.operationCount + program.denominator.operationCount + 2
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram.operationCount · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:33 · uses ContourProgram
def constantUnit unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

A concrete canonical rational program uses a rational constant numerator, the unit denominator, and a positive rational circle radius.

Definition (Lean source)
def ContourProgram.constantUnit (numeratorRe numeratorIm radius : ℚ) (hradius : 0 < radius) : ContourProgram where numerator := CertifiedComplexMap.constant numeratorRe numeratorIm denominator := CertifiedComplexMap.constant 1 0 radius := radius radius_pos := hradius
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram.constantUnit · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:38 · uses ContourProgram
def nodeBox unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

The scheduled rational rectangle fed to both function interval extensions.

Definition (Lean source)
def ContourProgram.nodeBox (program : ContourProgram) (schedule : Schedule) (k : ℕ) : ComplexRatInterval := circleNode program.radius schedule k
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram.nodeBox · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:47 · uses ContourProgram , Schedule , ComplexRatInterval
structure ContourValueBounds unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

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.CertifiedContourIntervalArithmetic.Complex.ContourValueBounds · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:52 · uses ContourProgram
def mapWidthBounds unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

A common leaf-error and circle-input target gives these numerator and denominator rectangle width bounds by CertifiedComplexMap.width_le.

Definition (Lean source)
def ContourProgram.mapWidthBounds (program : ContourProgram) (target : ℚ) : ℚ × ℚ := (target + program.numerator.amplification * target, target + program.denominator.amplification * target)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram.mapWidthBounds · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:81 · uses ContourProgram
def nodePropagationBound unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

The explicit arithmetic propagation bound for one guarded contour node combines map errors, input refinement, magnitude amplification, separation, division, and the final multiplication by the circle point.

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

A conservative positive scale controls every coefficient in the node propagation polynomial on targets no larger than one.

Definition (Lean source)
def ContourProgram.nodeScale (program : ContourProgram) (bounds : ContourValueBounds program) (separation : PosRat) : ℚ := |program.nodePropagationBound bounds separation.1 1| + 1
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram.nodeScale · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:105 · uses ContourProgram , ContourValueBounds , PosRat
def canonicalNodeTarget unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

The canonical common target spends the node budget after accounting for all program operations, map amplification, magnitudes, and denominator separation.

Definition (Lean source)
def ContourProgram.canonicalNodeTarget (program : ContourProgram) (bounds : ContourValueBounds program) (separation tolerance : PosRat) : PosRat := ⟨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.CertifiedContourIntervalArithmetic.Complex.ContourProgram.canonicalNodeTarget · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:111 · uses ContourProgram , ContourValueBounds , PosRat
def constantUnitBounds unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

The canonical constant-over-unit program has explicit global coordinate magnitude bounds computed only from its rational numerator coordinates.

Definition (Lean source)
def ContourProgram.constantUnitBounds (numeratorRe numeratorIm radius : ℚ) (hradius : 0 < radius) : 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.CertifiedContourIntervalArithmetic.Complex.ContourProgram.constantUnitBounds · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:311 · uses constantUnit , ContourValueBounds
structure DenominatorCertificate unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

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 executable and 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 :
Common positive squared-modulus separation.
separation :
The common separation is strictly positive.
separation_pos :
0 < separation
Every endpoint denominator rectangle is executable and away from zero.
away :
∀ k
if
k ≤ schedule.mesh
then
((program.denominator.eval (program.nodeBox schedule k) schedule.fuel).normSq).AwayFromZero
The same rational separation lies below every squared-modulus lower endpoint.
lower :
∀ k
if
k ≤ schedule.mesh
then
separation
≤ (program.denominator.eval (program.nodeBox schedule k) schedule.fuel).normSq.lo
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.DenominatorCertificate · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:331 · uses ContourProgram , Schedule
structure CertifiedProgramSchedule unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

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 operation count matches the program's structural operation 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 execution, tracing, and specifications.
schedule :
The schedule operation count is the structural count of the executable program.
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.CertifiedContourIntervalArithmetic.Complex.CertifiedProgramSchedule · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:348 · uses ContourProgram , ContourValueBounds , PosRat
def nodeTrace unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

The finite trace for one scheduled node has one event for each structural primitive operation and every event retains the exact execution schedule.

Definition (Lean source)
def ContourProgram.nodeTrace (program : ContourProgram) {bounds : ContourValueBounds program} {separation : PosRat} (scheduled : CertifiedProgramSchedule program bounds separation) (k : ℕ) : List TraceEvent := List.ofFn fun operation : Fin program.operationCount => circleNodeEvent scheduled.schedule k operation
theorem nodeTrace_spec unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

For a contour program, a target error separation, a certified schedule for that program, and a stage index k, the executable node trace at stage k has exactly one event per structural operation of the program, and every event in it records the full schedule together with that schedule's operation count.

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

The canonical certified schedule derives operation count, input precision, fuel, mesh, and all three budgets from the program and rational bounds.

Definition (Lean source)
def ContourProgram.canonicalScheduled (program : ContourProgram) (bounds : ContourValueBounds program) (separation tolerance : PosRat) (magnitude : ℚ) (hmagnitude : 0 ≤ magnitude) : CertifiedProgramSchedule program bounds separation := by let base := Schedule.canonical tolerance program.operationCount magnitude hmagnitude 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.CertifiedContourIntervalArithmetic.Complex.ContourProgram.canonicalScheduled · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:408 · uses CertifiedProgramSchedule , ContourProgram , ContourValueBounds , PosRat
def constantUnitCertificate unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

The concrete unit-denominator program has an executable separation certificate with squared-modulus lower bound one at every endpoint.

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

The node function with an explicit endpoint-bound argument avoids ever constructing a division guard outside the scheduled finite endpoint range.

Definition (Lean source)
def ContourProgram.integrandNodeFin (program : ContourProgram) (schedule : Schedule) (certificate : DenominatorCertificate program schedule) (k : Fin (schedule.mesh + 1)) : ComplexRatInterval := let node := program.nodeBox schedule k let numerator := program.numerator.eval node schedule.fuel let denominator := program.denominator.eval node schedule.fuel (numerator.div denominator (certificate.away k (Nat.le_of_lt_succ k.isLt))).mul node
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram.integrandNodeFin · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:480 · uses ContourProgram , DenominatorCertificate , Schedule , ComplexRatInterval
def integrandNodes unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

A total natural-indexed node family agrees with certified endpoints and uses the terminal endpoint outside the range, which quadrature never queries.

Definition (Lean source)
def ContourProgram.integrandNodes (program : ContourProgram) (schedule : Schedule) (certificate : DenominatorCertificate program schedule) (k : ℕ) : ComplexRatInterval := 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 (numerator.div denominator (certificate.away k hk)).mul node else program.integrandNodeFin schedule certificate ⟨schedule.mesh, Nat.lt_succ_self _⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram.integrandNodes · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:490 · uses ContourProgram , DenominatorCertificate , Schedule , ComplexRatInterval
def normalizedIntegrand unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

The exact normalized integrand after cancellation of the circle tangent's 2 * π * i factor is the quotient times the circle point.

Definition (Lean source)
noncomputable def ContourProgram.normalizedIntegrand (program : ContourProgram) (schedule : Schedule) (u : ℝ) : ℂ := let z : ℂ := (program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I) (program.numerator.value z / program.denominator.value z) * z
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram.normalizedIntegrand · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:503 · uses ContourProgram , Schedule
def normalizedContourIntegral unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

The normalized exact contour integral is the usual circle contour integral divided by 2 * π * i; it is used only as the semantic target.

Definition (Lean source)
noncomputable def ContourProgram.normalizedContourIntegral (program : ContourProgram) : ℂ := CircleMesh.circleContourIntegral (fun z => program.numerator.value z / program.denominator.value z) 0 program.radius / (((2 : ℝ) * Real.pi : ℂ) * I)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram.normalizedContourIntegral · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:511 · uses ContourProgram
Contour­Evaluation 3 core · 8 supporting 3 to review 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 unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

The executable contour result applies promoted deterministic quadrature and then spends the schedule's final symmetric quadrature budget.

Definition (Lean source)
def ContourProgram.evaluate (program : ContourProgram) (schedule : Schedule) (certificate : DenominatorCertificate program schedule) : ComplexRatInterval := (CircleMesh.integralEnclosure (program.integrandNodes schedule certificate) schedule.magnitude schedule.magnitude_nonneg schedule.mesh schedule.mesh_pos).expand (schedule.quadratureBudget / 2) (div_nonneg schedule.quadratureBudget_nonneg (by norm_num))
theorem certified_contour_evaluation unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

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.magnitude : ℝ) * |s - t|
(program.evaluate scheduled.schedule certificate).Contains program.normalizedContourIntegral ∧
(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.magnitude : ℝ) * |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 unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

The canonical statistical tolerance is the positive rational reciprocal of max n 1.

Definition (Lean source)
def inverseMaxTolerance (n : ℕ) : PosRat := ⟨1 / (max n 1 : ℚ), by positivity⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.inverseMaxTolerance · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourEvaluation.lean:389 · 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 :
    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, CircleMesh.circleTangent, ContourProgram.normalizedIntegrand, zero_add] 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.CertifiedContourIntervalArithmetic.Complex.normalizedContourIntegral_eq · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourEvaluation.lean:16
  • integrandNodes_sound theorem — Every certified finite endpoint rectangle contains the exact normalized integrand.
    program :
    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 hk 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.CertifiedContourIntervalArithmetic.Complex.integrandNodes_sound · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourEvaluation.lean:53
  • 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
    (program.integrandNodes scheduled.schedule certificate k).width
    ≤ 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) : (program.integrandNodes scheduled.schedule certificate k).width ≤ 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 : node.width ≤ 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 hk 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 : numerator.width ≤ numeratorWidth := by calc numerator.width ≤ program.numerator.algorithmError schedule.fuel + program.numerator.amplification * node.width := 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 : denominator.width ≤ denominatorWidth := by calc denominator.width ≤ program.denominator.algorithmError schedule.fuel + program.denominator.amplification * node.width := 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 : numerator.maxAbs ≤ numeratorMax := by exact (ComplexRatInterval.maxAbs_le_of_contains_width hnumContains hnumValueBound hnumWidth) have hdenMax : denominator.maxAbs ≤ 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 : (numerator.mul denominator.conj).maxAbs ≤ divisionMax := by calc (numerator.mul denominator.conj).maxAbs ≤ 2 * numerator.maxAbs * denominator.conj.maxAbs := ComplexRatInterval.mul_maxAbs numerator denominator.conj _ = 2 * numerator.maxAbs * denominator.maxAbs := 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 : (numerator.mul denominator.conj).width ≤ divisionWidth := by calc (numerator.mul denominator.conj).width ≤ 2 * (numerator.maxAbs * denominator.conj.width + denominator.conj.maxAbs * numerator.width) := ComplexRatInterval.mul_width numerator denominator.conj _ = 2 * (numerator.maxAbs * denominator.width + denominator.maxAbs * numerator.width) := by rw [ComplexRatInterval.width_conj, ComplexRatInterval.maxAbs_conj] _ ≤ 2 * (numeratorMax * denominatorWidth + denominatorMax * numeratorWidth) := by have hnumA0 : 0 ≤ numerator.maxAbs := (abs_nonneg numerator.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hdenA0 : 0 ≤ denominator.maxAbs := (abs_nonneg denominator.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) nlinarith [mul_le_mul hnumMax hdenWidth (show 0 ≤ denominator.width from (RatInterval.width_nonneg denominator.re).trans (le_max_left _ _)) hnMax0, mul_le_mul hdenMax hnumWidth (show 0 ≤ numerator.width from (RatInterval.width_nonneg numerator.re).trans (le_max_left _ _)) hdMax0] _ = divisionWidth := rfl have hnormWidth : denominator.normSq.width ≤ normWidth := by calc denominator.normSq.width ≤ 4 * denominator.maxAbs * denominator.width := ComplexRatInterval.normSq_width denominator _ ≤ 4 * denominatorMax * denominatorWidth := by nlinarith [mul_le_mul hdenMax hdenWidth (show 0 ≤ denominator.width from (RatInterval.width_nonneg denominator.re).trans (le_max_left _ _)) hdMax0] _ = normWidth := rfl have hsep : separation.1 ≤ denominator.normSq.lo := hseparation.trans (certificate.lower k hk) have hquotientWidth : (numerator.div denominator (certificate.away k hk)).width ≤ quotientWidth := by calc _ ≤ (numerator.mul denominator.conj).maxAbs * denominator.normSq.width / separation.1 ^ 2 + (numerator.mul denominator.conj).width / 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 denominator.normSq) 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 : (numerator.div denominator (certificate.away k hk)).maxAbs ≤ 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 : node.maxAbs ≤ 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 ((numerator.div denominator (certificate.away k hk)).mul node).width ≤ _ calc ((numerator.div denominator (certificate.away k hk)).mul node).width ≤ 2 * ((numerator.div denominator (certificate.away k hk)).maxAbs * node.width + node.maxAbs * (numerator.div denominator (certificate.away k hk)).width) := ComplexRatInterval.mul_width _ _ _ ≤ 2 * ((divisionMax / separation.1) * scheduled.target.1 + (program.radius + scheduled.target.1) * quotientWidth) := by have hquotientA0 : 0 ≤ (numerator.div denominator (certificate.away k hk)).maxAbs := (abs_nonneg (numerator.div denominator (certificate.away k hk)).re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hnodeA0 : 0 ≤ node.maxAbs := (abs_nonneg node.re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) nlinarith [mul_le_mul hquotientMax hnodeWidth (show 0 ≤ node.width from (RatInterval.width_nonneg node.re).trans (le_max_left _ _)) (div_nonneg hdivisionMax0 separation.2.le), mul_le_mul hnodeMax hquotientWidth (show 0 ≤ (numerator.div denominator (certificate.away k hk)).width from (RatInterval.width_nonneg (numerator.div denominator (certificate.away k hk)).re).trans (le_max_left _ _)) (by linarith [program.radius_pos])] _ = program.nodePropagationBound bounds separation.1 scheduled.target.1 := by rfl
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.integrandNodes_width_le_propagation · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourEvaluation.lean:69
  • denominator_ne_zero_at_nodes theorem — Denominator separation at all certified nodes implies nonvanishing of the exact denominator at all mesh endpoints.
    program :
    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 hk 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.CertifiedContourIntervalArithmetic.Complex.denominator_ne_zero_at_nodes · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourEvaluation.lean:300
  • 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 :
    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.magnitude : ℝ) * |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.magnitude : ℝ) * |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.magnitude_nonneg schedule.mesh_pos hLip (fun k hk => integrandNodes_sound program schedule certificate hk)
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.evaluate_contains · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourEvaluation.lean:318
  • 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
    (program.evaluate scheduled.schedule certificate).width ≤ 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) : (program.evaluate scheduled.schedule certificate).width ≤ 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.nodeBudget_nonneg schedule.magnitude_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.CertifiedContourIntervalArithmetic.Complex.evaluate_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourEvaluation.lean:334
  • certified_contour_evaluation_inverseMax theorem — Specializing the generic contour certificate to reciprocal-max tolerance gives the width required by canonical finite-rational statistics.
    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.magnitude : ℝ) * |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.magnitude : ℝ) * |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.CertifiedContourIntervalArithmetic.Complex.certified_contour_evaluation_inverseMax · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourEvaluation.lean:393
  • midpoint_error_le_half_width theorem — Containment in a rational real interval bounds its midpoint error by half the interval width, turning the reciprocal-max width into a statistic error bound.
    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.CertifiedContourIntervalArithmetic.Complex.midpoint_error_le_half_width · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourEvaluation.lean:415
Program 7 core · 0 supporting 7 to review This module defines certified complex interval maps with a structural operation count and executable composition combinators. ★ algorithmError_le_of_modulus

Certified finite complex programs

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

structure CertifiedComplexMap unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

A certified complex map packages an exact complex function with an executable interval-evaluation program over rational input rectangles and a fuel level whose primitive-operation count is recorded, proved sound — every executable 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 Lipschitz bound on how input width amplifies into output width](hyp:amplification, amplification_nonneg) and a nonincreasing sequence of algorithmic-error bounds in the fuel, such that the evaluated width never exceeds the algorithmic error plus the amplified input width, together with a computable fuel rule meeting any requested positive algorithmic-error target.

Definition (Lean source)
The exact function described by the interval program.
value :
ℂ → ℂ
Executable interval evaluation at a rational input rectangle and fuel.
The number of primitive arithmetic operations performed by one evaluation.
operationCount :
Every executable 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, (eval I fuel).width ≤ algorithmError fuel + amplification * I.width
Executable fuel 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.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Program.lean:16
def identity unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap

The identity interval program performs no primitive arithmetic and has unit input amplification with zero algorithmic error.

Definition (Lean source)
def identity : CertifiedComplexMap where value := id eval := fun I _ => I operationCount := 0 sound := by intro I z hz fuel; exact hz fuel_nested := by intro I fuel exact ⟨RatInterval.subinterval_refl _, RatInterval.subinterval_refl _⟩ input_mono := by intro I J hIJ fuel; exact hIJ amplification := 1 amplification_nonneg := by norm_num algorithmError := fun _ => 0 algorithmError_nonneg := by intro fuel; norm_num algorithmError_antitone := by intro a b hab; rfl width_le := by intro I fuel; simp errorModulus := fun _ => 0 error_at_modulus := by intro ε; exact ε.2.le
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap.identity · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Program.lean:62 · uses CertifiedComplexMap
def constant unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap

A rational complex constant is a zero-operation certified program returning the same point rectangle for every input and fuel.

Definition (Lean source)
def constant (x y : ℚ) : CertifiedComplexMap where value := fun _ => (x : ℝ) + (y : ℝ) * I eval := fun _ _ => ComplexRatInterval.point x y operationCount := 0 sound := by intro I z hz fuel; exact ComplexRatInterval.point_sound x y fuel_nested := by intro I fuel exact ⟨RatInterval.subinterval_refl _, RatInterval.subinterval_refl _⟩ input_mono := by intro I J hIJ fuel exact ⟨RatInterval.subinterval_refl _, RatInterval.subinterval_refl _⟩ amplification := 0 amplification_nonneg := by norm_num algorithmError := fun _ => 0 algorithmError_nonneg := by intro fuel; norm_num algorithmError_antitone := by intro a b hab; rfl width_le := by intro I fuel simp [ComplexRatInterval.width, ComplexRatInterval.point, RatInterval.width, RatInterval.point] errorModulus := fun _ => 0 error_at_modulus := by intro ε; exact ε.2.le
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap.constant · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Program.lean:82 · uses CertifiedComplexMap
def add unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap

Pointwise addition composes two certified interval programs, adds their width amplifications and algorithmic errors, and records one new operation.

Definition (Lean source)
def add (f g : CertifiedComplexMap) : CertifiedComplexMap := by let δ : PosRatPosRat := 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.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap.add · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Program.lean:107 · uses CertifiedComplexMap
def sub unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap

Pointwise subtraction is a certified operation combinator with the same width accounting as addition and one newly counted primitive operation.

Definition (Lean source)
def sub (f g : CertifiedComplexMap) : CertifiedComplexMap := by let δ : PosRatPosRat := 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).sub (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.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap.sub · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Program.lean:161 · uses CertifiedComplexMap
def mulWithBounds unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap

Multiplication composes two certified programs when uniform executable magnitude bounds are supplied; its error and amplification use the standard product-width propagation formula and its operation count is structural.

Definition (Lean source)
def mulWithBounds (f g : CertifiedComplexMap) (Bf Bg : ℚ) (hBf : 0 ≤ Bf) (hBg : 0 ≤ Bg) (hf : ∀ I fuel, (f.eval I fuel).maxAbs ≤ Bf) (hg : ∀ I fuel, (g.eval I fuel).maxAbs ≤ Bg) : CertifiedComplexMap := by let δf : PosRatPosRat := fun ε => ⟨ε.1 / (4 * (Bg + 1)), by exact div_pos ε.2 (mul_pos (by norm_num) (by linarith))⟩ let δg : PosRatPosRat := 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 => (f.eval I fuel).mul (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 ≤ (f.eval I fuel).maxAbs := (abs_nonneg (f.eval I fuel).re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hgA0 : 0 ≤ (g.eval I fuel).maxAbs := (abs_nonneg (g.eval I fuel).re.lo).trans ((le_max_left _ _).trans (le_max_left _ _)) have hfw0 : 0 ≤ (f.eval I fuel).width := (RatInterval.width_nonneg (f.eval I fuel).re).trans (le_max_left _ _) have hgw0 : 0 ≤ (g.eval I fuel).width := (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.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap.mulWithBounds · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Program.lean:217 · uses CertifiedComplexMap , ComplexRatInterval , maxAbs
theorem algorithmError_le_of_modulus unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.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 running the algorithm for that many iterations yields an approximation whose error 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.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap.algorithmError_le_of_modulus · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Program.lean:341 · uses CertifiedComplexMap , PosRat
Trig­Names 6 core · 4 supporting 6 to review This module turns refining rational real names into certified sine and cosine names with effective 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 effective Taylor-error bounds.

def sinNameApprox unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

A sine output on a refining real name recursively intersects the current input enclosure result with every preceding output.

Definition (Lean source)
def sinNameApprox (x : CertifiedReal) : ℕ → RatInterval | 0 => sinInterval (x.approx 0) 0 | fuel + 1 => (sinNameApprox x fuel).tighten (sinInterval (x.approx (fuel + 1)) (fuel + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.sinNameApprox · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/TrigNames.lean:15 · uses CertifiedReal , RatInterval
def cosNameApprox unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

A cosine output on a refining real name recursively intersects the current input enclosure result with every preceding output.

Definition (Lean source)
def cosNameApprox (x : CertifiedReal) : ℕ → RatInterval | 0 => cosInterval (x.approx 0) 0 | fuel + 1 => (cosNameApprox x fuel).tighten (cosInterval (x.approx (fuel + 1)) (fuel + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.cosNameApprox · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/TrigNames.lean:22 · uses CertifiedReal , RatInterval
def trigNamePrecision unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Conservative trigonometric precision combines the input modulus, initial argument magnitude, and target denominator.

Definition (Lean source)
def trigNamePrecision (x : CertifiedReal) (ε : PosRat) : ℕ := let δ : PosRat := ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩ max (x.modulus δ) (32 * (ε.1.den + 1) * ((x.approx 0).maxAbs.num.natAbs + 2) ^ 2)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.trigNamePrecision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/TrigNames.lean:29 · uses CertifiedReal , PosRat
theorem sinName_width_at_precision unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.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 Nat.le_succ ε.1.den)).trans (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.CertifiedContourIntervalArithmetic.Complex.Transcendental.sinName_width_at_precision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/TrigNames.lean:142 · uses CertifiedReal , sinNameApprox , trigNamePrecision , PosRat , width
def sinName unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Sine lifts a refining certified real input to a certified real output.

Definition (Lean source)
noncomputable def sinName (x : CertifiedReal) : CertifiedReal where value := sin x.value approx := sinNameApprox x nested := fun fuel => (sinNameApprox_spec x fuel).2 contains := by intro fuel; exact (sinNameApprox_spec x fuel).1 modulus := trigNamePrecision x width_modulus := sinName_width_at_precision x
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.sinName · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/TrigNames.lean:251 · uses CertifiedReal
def cosName unreviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

Cosine lifts a refining certified real input to a certified real output.

Definition (Lean source)
noncomputable def cosName (x : CertifiedReal) : CertifiedReal where value := cos x.value approx := cosNameApprox x nested := fun fuel => (cosNameApprox_spec x fuel).2 contains := by intro fuel; exact (cosNameApprox_spec x fuel).1 modulus := trigNamePrecision x width_modulus := cosName_width_at_precision x
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.cosName · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/TrigNames.lean:260 · uses CertifiedReal
4 supporting declarations (lemmas, instances)
  • sinNameApprox_spec theorem — Recursive sine-name approximations remain sound and adjacent-fuel nested.
    fuel :
    (sinNameApprox x fuel).Contains (sin x.value) ∧
    (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.CertifiedContourIntervalArithmetic.Complex.Transcendental.sinNameApprox_spec · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/TrigNames.lean:36
  • cosNameApprox_spec theorem — Recursive cosine-name approximations remain sound and adjacent-fuel nested.
    fuel :
    (cosNameApprox x fuel).Contains (cos x.value) ∧
    (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.CertifiedContourIntervalArithmetic.Complex.Transcendental.cosNameApprox_spec · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/TrigNames.lean:56
  • 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.CertifiedContourIntervalArithmetic.Complex.Transcendental.power_div_factorial_le · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/TrigNames.lean:101
  • cosName_width_at_precision theorem — Refinement of the input name plus Taylor fuel makes cosine output width effective.
    (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 Nat.le_succ ε.1.den)).trans (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.CertifiedContourIntervalArithmetic.Complex.Transcendental.cosName_width_at_precision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/TrigNames.lean:198