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 This module defines executable Machin/Taylor enclosures for π, sine and cosine; real interval exponential evaluation lives in Complex/IntervalExp.lean. ★ piInterval_width

Rational real transcendental enclosures

This module defines executable Machin/Taylor enclosures for π, sine and cosine; real interval exponential evaluation lives in Complex/IntervalExp.lean. 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 reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Definition (Lean source)
cosInterval I :
ℕ → RatInterval
clause 1
| 0 => cosIntervalRaw I 0
clause 2
| fuel + 1 => (cosInterval I fuel).tighten (cosIntervalRaw I (fuel + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.cosInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Transcendental.lean:280 · uses RatInterval
12 supporting declarations (lemmas, instances)
Basic 5 core · 11 supporting 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 reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval

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

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

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

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

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

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

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

Definition (Lean source)
hI :
0 ≤ I.lo
fuel :
sqrtInterval I hI fuel :
⟨sqrtLower I.lo fuel, sqrtUpper I.hi fuel, by have hhi : 0
≤ I.hi := hI.trans I.lo_le_hi have hlo_sound := sqrt_iterates_sound I.lo hI fuel have hhi_sound := sqrt_iterates_sound I.hi hhi fuel have hsqrt : sqrt (I.lo : ℝ) ≤ sqrt (I.hi : ℝ) := Real.sqrt_le_sqrt (by exact_mod_cast I.lo_le_hi) exact_mod_cast hlo_sound.1.trans (hsqrt.trans hhi_sound.2)⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.RatInterval.sqrtInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Basic.lean:180 · 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:25
  • 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:48
  • 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:138
  • 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:168
  • 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:190
  • 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:202
  • 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:209
  • 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:236
  • 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:240
  • 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:251
  • 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:256
Rectangles 12 core · 20 supporting This module equips rational complex rectangles with sound arithmetic, guarded division, modulus bounds, and explicit width propagation. ★ div_sound

Rational complex rectangle operations

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

def width reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Definition (Lean source)
hJ :
J.normSq.AwayFromZero
div I J hJ :
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:40 · uses ComplexRatInterval , normSq , AwayFromZero
def tighten reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

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

Definition (Lean source)
tighten I J :
⟨I.re.tighten J.re, I.im.tighten J.im⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.tighten · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:45 · uses ComplexRatInterval
theorem div_sound reviewed
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:99 · uses ComplexRatInterval , Contains , div , normSq , AwayFromZero
def normInterval reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval

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

Definition (Lean source)
fuel :
normInterval I fuel :
RatInterval.sqrtInterval I.normSq (normSq_lo_nonneg I) fuel
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.ComplexRatInterval.normInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Rectangles.lean:472 · 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:49
  • 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:56
  • 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:70
  • 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:76
  • 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:81
  • 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:92
  • 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:121
  • 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:125
  • tighten_sound_left theorem — Tightening two rectangles containing a common value preserves that value and produces a subrectangle of the first argument.
    z :
    hI :
    I.Contains z
    hJ :
    J.Contains z
    conclusion 1
    (I.tighten J).Contains z
    conclusion 2
    (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:129
  • 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:139
  • 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:145
  • 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:278
  • 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:284
  • 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:299
  • 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:306
  • 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:353
  • 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:370
  • 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:409
  • normSq_lo_nonneg theorem — For a rational complex rectangle, the lower endpoint of its squared-modulus interval is nonnegative.
    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:463
  • 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:478
Interval­Exp 3 core · 2 supporting This module evaluates the real exponential on rational intervals using midpoint enclosures and a magnitude-dependent Lipschitz allowance. ★ expInterval_width

Certified exponential interval evaluation

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

def expIntervalRaw reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

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

Definition (Lean source)
fuel :
expIntervalRaw I fuel :
center :
ecenter :
expScalar center fuel
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 reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

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

Definition (Lean source)
expInterval I :
ℕ → RatInterval
clause 1
| 0 => expIntervalRaw I 0
clause 2
| fuel + 1 => (expInterval I fuel).tighten (expIntervalRaw I (fuel + 1))
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.expInterval · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/IntervalExp.lean:33 · uses RatInterval
theorem expInterval_width reviewed
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:106 · 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:88
  • 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:96
Names 8 core · 2 supporting 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 reviewed
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 reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex

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

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

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

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

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

Definition (Lean source)
add z w :
clause 1
value := z.value + w.value
clause 2
approx := fun n => (z.approx n).add (w.approx n)
clause 3
nested := by intro n exact ⟨RatInterval.add_mono (z.nested n).1 (w.nested n).1, RatInterval.add_mono (z.nested n).2 (w.nested n).2⟩
clause 4
contains := by intro n; exact ComplexRatInterval.add_sound (z.contains n) (w.contains n)
clause 5
modulus := fun ε
=> max (z.modulus ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩) (w.modulus ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩)
clause 6
width_modulus := by intro ε let δ : PosRat := ⟨ε.1 / 2, div_pos ε.2 (by norm_num)⟩ let k := max (z.modulus δ) (w.modulus δ) have hz : (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 reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex

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

Definition (Lean source)
normApprox z :
ℕ → RatInterval
clause 1
| 0 => (z.approx 0).normInterval 0
clause 2
| 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:101 · uses CertifiedComplex , RatInterval
def normPrecision reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex

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

Definition (Lean source)
normPrecision z ε :
M :
(z.approx 0).maxAbs
δ :
⟨ε.1 ^ 2 / (16 * (M + 1)), by have hM : 0
≤ M := by exact le_max_of_le_left ((abs_nonneg _).trans (le_max_left _ _)) exact div_pos (sq_pos_of_pos ε.2) (by nlinarith)⟩ (: PosRat)
max (z.modulus δ) (64 * (ε.1.den + 1) * (M.num.natAbs + 2) ^ 2)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex.normPrecision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Names.lean:107 · uses CertifiedComplex , PosRat
theorem norm_width_at_precision reviewed
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:161 · uses CertifiedComplex , normApprox , normPrecision , PosRat , width
def norm reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplex

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

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

Certified complex exponential semantics

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

def complexExpRaw reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Definition (Lean source)
complexExpPrecision _z ε :
ε.1.den
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExpPrecision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:536 · uses CertifiedComplex , PosRat
theorem complexExp_width_at_precision reviewed
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:539 · uses CertifiedComplex , complexExpNameApprox , complexExpPrecision , width , PosRat
def complexExpName reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

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

Definition (Lean source)
complexExpName z :
clause 1
value := exp z.value
clause 2
clause 3
nested := fun n => (complexExpNameApprox_spec z n).2
clause 4
contains := by intro n; exact (complexExpNameApprox_spec z n).1
clause 5
modulus := complexExpPrecision z
clause 6
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExpName · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:562 · 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:40
  • 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:49
  • 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:67
  • complexExpNameApprox_spec theorem — Recursive complex-exponential name approximations remain sound and adjacent stages are nested by their defining finite intersection.
    n :
    conclusion 1
    (complexExpNameApprox z n).Contains (exp z.value)
    conclusion 2
    (complexExpNameApprox z (n + 1)).Subinterval (complexExpNameApprox z n)
    Proof (Lean source)
    theorem complexExpNameApprox_spec (z : CertifiedComplex) (n : ℕ) : (complexExpNameApprox z n).Contains (exp z.value) ∧ (complexExpNameApprox z (n + 1)).Subinterval (complexExpNameApprox z n) := by induction n with | zero => have h0 := complexExpStage_sound z 0 have h1 := complexExpStage_sound z 1 exact ⟨h0, (ComplexRatInterval.tighten_sound_left h0 h1).2⟩ | succ n ih => have hnew := complexExpStage_sound z (n + 1) have hcur : (complexExpNameApprox z (n + 1)).Contains (exp z.value) := by rw [complexExpNameApprox] exact (ComplexRatInterval.tighten_sound_left ih.1 hnew).1 have hnext := complexExpStage_sound z (n + 2) constructor · exact hcur · rw [show n + 1 + 1 = n + 2 by omega, complexExpNameApprox] exact (ComplexRatInterval.tighten_sound_left hcur hnext).2
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.complexExpNameApprox_spec · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ComplexExp.lean:173
  • 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:268
Circle­Schedule 11 core · 5 supporting 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 reviewed
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 reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Schedule

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

Definition (Lean source)
tolerance :
operationCount :
magnitude :
hmagnitude :
0 ≤ magnitude
canonical tolerance operationCount magnitude hmagnitude :
Schedule
clause 1
tolerance := tolerance
clause 2
operationCount := operationCount
clause 3
inputPrecision := 64 * (operationCount + 1) * (tolerance.1.den + 1) * (magnitude.num.natAbs + 2) ^ 2
clause 4
mesh := 3 * (magnitude.num.natAbs + 1) * tolerance.1.den
clause 5
mesh_pos := by positivity
clause 6
fuel := 64 * (operationCount + 1) * (tolerance.1.den + 1) * (magnitude.num.natAbs + 2) ^ 2
clause 7
magnitude := magnitude
clause 8
magnitude_nonneg := hmagnitude
clause 9
nodeBudget := tolerance.1 / 3
clause 10
meshBudget := tolerance.1 / 3
clause 11
quadratureBudget := tolerance.1 / 3
clause 12
nodeBudget_nonneg := by exact (div_nonneg tolerance.2.le (by norm_num))
clause 13
meshBudget_nonneg := by exact (div_nonneg tolerance.2.le (by norm_num))
clause 14
quadratureBudget_nonneg := by exact (div_nonneg tolerance.2.le (by norm_num))
clause 15
budget_sum_le := by linarith
clause 16
mesh_error_le := by have hMle : 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 reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

A trace event records the shared schedule, the index of the evaluated endpoint, and the ordinal of the primitive operation performed. Retaining the schedule object itself means execution and semantic audit cannot silently disagree about fuel, mesh, or precision.

Definition (Lean source)
The exact shared schedule used for this event.
schedule :
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:123
def circleNodeEvent reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

Given a contour schedule, a mesh-endpoint index, and a primitive-operation index, the circle-node trace event records exactly those three quantities.

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

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

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

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

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

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

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

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

Definition (Lean source)
radius :
target :
circleInputPrecision radius target :
Transcendental.piPrecision (circleInnerTolerance radius target)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.circleInputPrecision · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:158 · uses PosRat
def circleExpFuel reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

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

Definition (Lean source)
radius :
_mesh :
target :
circleExpFuel radius _mesh target :
max (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 reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

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

Definition (Lean source)
radius :
schedule :
Schedule
k :
exactCircleNode radius schedule k :
(radius : ℂ) * exp (((2 : ℝ) * pi * ((k : ℝ) / schedule.mesh)) * I)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.exactCircleNode · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:384 · uses Schedule
theorem circleNode_sound reviewed
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 :
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:407 · 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 :
    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:220
  • circleAngle_sound theorem — The angle rectangle contains the exact pure-imaginary angle at every endpoint from zero through the terminal mesh endpoint.
    schedule :
    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:389
  • circleNode_endpoint theorem — The terminal endpoint k = mesh, which is explicitly used by the trapezoidal program, is certified and denotes the same point as endpoint zero.
    radius :
    schedule :
    Schedule
    conclusion 1
    (circleNode radius schedule schedule.mesh).Contains (radius : ℂ)
    conclusion 2
    exactCircleNode radius schedule schedule.mesh = (radius : ℂ)
    Proof (Lean source)
    theorem circleNode_endpoint (radius : ℚ) (schedule : Schedule) : (circleNode radius schedule schedule.mesh).Contains (radius : ℂ) ∧ exactCircleNode radius schedule schedule.mesh = (radius : ℂ) := by have hratio : ((schedule.mesh : ℝ) : ℂ) / schedule.mesh = 1 := by apply div_self exact_mod_cast schedule.mesh_pos.ne' have hexact : exactCircleNode radius schedule schedule.mesh = (radius : ℂ) := by rw [exactCircleNode, hratio] simp [Complex.exp_two_pi_mul_I] constructor · rw [← hexact] exact circleNode_sound radius schedule (le_refl schedule.mesh) · exact hexact
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.circleNode_endpoint · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/CircleSchedule.lean:417
  • circleNode_width theorem — Circle-node width propagation exposes radius scaling and the scheduled complex-exponential approximation width.
    radius :
    hradius :
    0 ≤ radius
    schedule :
    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:433
  • 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 :
    Schedule
    k operation :
    conclusion 1
    (circleNodeEvent schedule k operation).schedule.operationCount = schedule.operationCount
    conclusion 2
    (circleNodeEvent schedule k operation).schedule.inputPrecision = schedule.inputPrecision
    conclusion 3
    (circleNodeEvent schedule k operation).schedule.fuel = schedule.fuel
    conclusion 4
    (circleNodeEvent schedule k operation).schedule.mesh = schedule.mesh
    conclusion 5
    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:456
Contour­Program 20 core · 0 supporting This module packages executable interval extensions of numerator and denominator maps into contour programs, together with uniform value bounds, node boxes and node-error propagation bounds, denominator-separation certif ★ nodeTrace_spec

Certified finite contour programs

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

structure ContourProgram reviewed
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:22
def operationCount reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

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

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

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

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

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

Definition (Lean source)
program :
schedule :
Schedule
k :
nodeBox program schedule k :
circleNode program.radius schedule k
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram.nodeBox · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:47 · uses ContourProgram , Schedule , ComplexRatInterval
structure ContourValueBounds reviewed
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 reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

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

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

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

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

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

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

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

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

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

Definition (Lean source)
numeratorRe numeratorIm radius :
hradius :
0 < radius
constantUnitBounds numeratorRe numeratorIm radius hradius :
ContourValueBounds (ContourProgram.constantUnit numeratorRe numeratorIm radius hradius)
by refine { numerator := max |numeratorRe| |numeratorIm| denominator := 1 numerator_nonneg := (abs_nonneg numeratorRe).trans (le_max_left _ _) denominator_nonneg := by norm_num numerator_bound := ?_ denominator_bound := ?_ } · intro u hu simp only [ContourProgram.constantUnit, CertifiedComplexMap.constant] norm_num · intro u hu simp only [ContourProgram.constantUnit, CertifiedComplexMap.constant] norm_num
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram.constantUnitBounds · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourProgram.lean:306 · uses constantUnit , ContourValueBounds
structure DenominatorCertificate reviewed
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 :
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:325 · uses ContourProgram , Schedule
structure CertifiedProgramSchedule reviewed
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 :
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:342 · uses ContourProgram , ContourValueBounds , PosRat
def nodeTrace reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

For a contour program, its value bounds, a positive separation target, a certified schedule, and a nonnegative node index, the node trace lists one scheduled trace event for each structural operation of the program.

Definition (Lean source)
separation :
scheduled :
CertifiedProgramSchedule program bounds separation
k :
nodeTrace program scheduled k :
List.ofFn fun operation : Fin program.operationCount
=> circleNodeEvent scheduled.schedule k operation
theorem nodeTrace_spec reviewed
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 :
conclusion 1
(program.nodeTrace scheduled k).length = program.operationCount
conclusion 2
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 reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

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

Definition (Lean source)
program :
bounds :
separation tolerance :
magnitude :
hmagnitude :
0 ≤ magnitude
canonicalScheduled program bounds separation tolerance magnitude hmagnitude :
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:401 · uses CertifiedProgramSchedule , ContourProgram , ContourValueBounds , PosRat
def constantUnitCertificate reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

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

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

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

Definition (Lean source)
program :
schedule :
Schedule
certificate :
DenominatorCertificate program schedule
k :
Fin (schedule.mesh + 1)
integrandNodeFin program schedule certificate k :
node :
program.nodeBox schedule k
numerator :
program.numerator.eval node schedule.fuel
denominator :
program.denominator.eval node schedule.fuel
(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:471 · uses ContourProgram , DenominatorCertificate , Schedule , ComplexRatInterval
def integrandNodes reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

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

Definition (Lean source)
program :
schedule :
Schedule
certificate :
DenominatorCertificate program schedule
k :
integrandNodes program schedule certificate k :
if hk : k
≤ schedule.mesh then let node := program.nodeBox schedule k let numerator := program.numerator.eval node schedule.fuel let denominator := program.denominator.eval node schedule.fuel (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:480 · uses ContourProgram , DenominatorCertificate , Schedule , ComplexRatInterval
def normalizedIntegrand reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

For a contour program, a schedule, and a real circle parameter, the normalized integrand is the quotient of the exact numerator and denominator at the corresponding circle point, multiplied by that point.

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

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

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

Certified finite contour evaluation

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

def evaluate reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.ContourProgram

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

Definition (Lean source)
program :
schedule :
Schedule
certificate :
DenominatorCertificate program schedule
evaluate program schedule certificate :
(CircleMesh.integralEnclosure (program.integrandNodes schedule certificate) schedule.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 reviewed
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|
conclusion 1
(program.evaluate scheduled.schedule certificate).Contains program.normalizedContourIntegral
conclusion 2
(program.evaluate scheduled.schedule certificate).re.width
≤ scheduled.schedule.tolerance.1
Proof (Lean source)
theorem certified_contour_evaluation (program : ContourProgram) (bounds : ContourValueBounds program) (separation : PosRat) (scheduled : CertifiedProgramSchedule program bounds separation) (certificate : DenominatorCertificate program scheduled.schedule) (hseparation : separation.1 ≤ certificate.separation) (hden : ∀ u ∈ Icc (0 : ℝ) 1, program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I)) ≠ 0) (hLip : ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, ‖program.normalizedIntegrand scheduled.schedule s - program.normalizedIntegrand scheduled.schedule t‖ ≤ (scheduled.schedule.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 reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex

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

Definition (Lean source)
n :
inverseMaxTolerance n :
⟨1 / (max n 1 : ℚ), by positivity⟩
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.inverseMaxTolerance · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/ContourEvaluation.lean:388 · uses PosRat
8 supporting declarations (lemmas, instances)
  • normalizedContourIntegral_eq theorem — The canceled unit-parameter integral equals the normalized exact circle contour integral whenever the denominator is nonzero along the circle.
    program :
    schedule :
    Schedule
    hden :
    ∀ u ∈ Icc (0 : ℝ) 1,
    program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I))
    ≠ 0
    program.normalizedContourIntegral
    = ∫ u in (0 : ℝ)..1, program.normalizedIntegrand schedule u
    Proof (Lean source)
    theorem normalizedContourIntegral_eq (program : ContourProgram) (schedule : Schedule) (hden : ∀ u ∈ Icc (0 : ℝ) 1, program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * Real.pi * u) * I)) ≠ 0) : program.normalizedContourIntegral = ∫ u in (0 : ℝ)..1, program.normalizedIntegrand schedule u := by rw [ContourProgram.normalizedContourIntegral, CircleMesh.circleContourIntegral] calc (∫ u in (0 : ℝ)..1, CircleMesh.circleIntegrand (fun z => program.numerator.value z / program.denominator.value z) 0 program.radius u) / (((2 : ℝ) * Real.pi : ℂ) * I) = ∫ u in (0 : ℝ)..1, CircleMesh.circleIntegrand (fun z => program.numerator.value z / program.denominator.value z) 0 program.radius u / (((2 : ℝ) * Real.pi : ℂ) * I) := (intervalIntegral.integral_div _ _).symm _ = ∫ u in (0 : ℝ)..1, program.normalizedIntegrand schedule u := by apply intervalIntegral.integral_congr intro u hu simp only [CircleMesh.circleIntegrand, CircleMesh.circleMap, 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 :
    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 :
    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:299
  • evaluate_contains theorem — Under a Lipschitz bound and denominator nonvanishing on the full circle, the returned rational rectangle contains the normalized exact contour integral.
    program :
    schedule :
    Schedule
    certificate :
    DenominatorCertificate program schedule
    hden :
    ∀ u ∈ Icc (0 : ℝ) 1,
    program.denominator.value ((program.radius : ℂ) * exp (((2 : ℝ) * pi * u) * I))
    ≠ 0
    hLip :
    ∀ s ∈ Icc (0 : ℝ) 1,
    ∀ t ∈ Icc (0 : ℝ) 1,
    ‖program.normalizedIntegrand schedule s - program.normalizedIntegrand schedule t‖
    ≤ (schedule.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:317
  • 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:333
  • 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:392
  • 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:414
Program 7 core · 0 supporting 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 reviewed
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 reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap

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

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

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

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

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

Definition (Lean source)
by let δ : 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:105 · uses CertifiedComplexMap
def sub reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap

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

Definition (Lean source)
by let δ : 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:158 · uses CertifiedComplexMap
def mulWithBounds reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap

Given two certified complex maps, rational magnitude bounds for their executable output rectangles, the condition that both bounds are nonnegative, the condition that every output rectangle of the first map has maximum coordinate magnitude at most its bound, and the analogous condition for the second map, the certified pointwise product denotes the product of their exact values and uses the product-width propagation formula for its error and width amplification.

Definition (Lean source)
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
mulWithBounds f g Bf Bg hBf hBg hf hg :
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:213 · uses CertifiedComplexMap , ComplexRatInterval , maxAbs
theorem algorithmError_le_of_modulus reviewed
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 the algorithm's declared error allowance at that number of iterations, the additive term in its certified output-width bound, is at most the requested tolerance.

Formal statement
ε :
fuel :
h :
f.errorModulus ε ≤ fuel
f.algorithmError fuel ≤ ε.1
Proof (Lean source)
theorem algorithmError_le_of_modulus {f : CertifiedComplexMap} {ε : PosRat} {fuel : ℕ} (h : f.errorModulus ε ≤ fuel) : f.algorithmError fuel ≤ ε.1 := by exact (f.algorithmError_antitone h).trans (f.error_at_modulus ε)
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.CertifiedComplexMap.algorithmError_le_of_modulus · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/Program.lean:335 · uses CertifiedComplexMap , PosRat
Trig­Names 6 core · 4 supporting 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 reviewed
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental

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

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

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

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

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

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

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

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

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

Definition (Lean source)
cosName x :
clause 1
value := cos x.value
clause 2
approx := cosNameApprox x
clause 3
nested := fun fuel => (cosNameApprox_spec x fuel).2
clause 4
contains := by intro fuel; exact (cosNameApprox_spec x fuel).1
clause 5
modulus := trigNamePrecision x
clause 6
width_modulus := cosName_width_at_precision x
Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.cosName · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/TrigNames.lean:257 · uses CertifiedReal
4 supporting declarations (lemmas, instances)
  • sinNameApprox_spec theorem — Recursive sine-name approximations remain sound and adjacent-fuel nested.
    fuel :
    conclusion 1
    (sinNameApprox x fuel).Contains (sin x.value)
    conclusion 2
    (sinNameApprox x (fuel + 1)).Subinterval (sinNameApprox x fuel)
    Proof (Lean source)
    theorem sinNameApprox_spec (x : CertifiedReal) (fuel : ℕ) : (sinNameApprox x fuel).Contains (sin x.value) ∧ (sinNameApprox x (fuel + 1)).Subinterval (sinNameApprox x fuel) := by induction fuel with | zero => have h0 := sinInterval_sound (x.contains 0) 0 have h1 := sinInterval_sound (x.contains 1) 1 exact ⟨h0, RatInterval.tighten_subinterval_left h0 h1⟩ | succ fuel ih => have hnew := sinInterval_sound (x.contains (fuel + 1)) (fuel + 1) have hcur : (sinNameApprox x (fuel + 1)).Contains (sin x.value) := by rw [sinNameApprox] exact RatInterval.tighten_sound ih.1 hnew have hnext := sinInterval_sound (x.contains (fuel + 2)) (fuel + 2) constructor · exact hcur · rw [show fuel + 1 + 1 = fuel + 2 by omega, sinNameApprox] exact RatInterval.tighten_subinterval_left hcur hnext
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.sinNameApprox_spec · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/TrigNames.lean:33
  • cosNameApprox_spec theorem — Recursive cosine-name approximations remain sound and adjacent-fuel nested.
    fuel :
    conclusion 1
    (cosNameApprox x fuel).Contains (cos x.value)
    conclusion 2
    (cosNameApprox x (fuel + 1)).Subinterval (cosNameApprox x fuel)
    Proof (Lean source)
    theorem cosNameApprox_spec (x : CertifiedReal) (fuel : ℕ) : (cosNameApprox x fuel).Contains (cos x.value) ∧ (cosNameApprox x (fuel + 1)).Subinterval (cosNameApprox x fuel) := by induction fuel with | zero => have h0 := cosInterval_sound (x.contains 0) 0 have h1 := cosInterval_sound (x.contains 1) 1 exact ⟨h0, RatInterval.tighten_subinterval_left h0 h1⟩ | succ fuel ih => have hnew := cosInterval_sound (x.contains (fuel + 1)) (fuel + 1) have hcur : (cosNameApprox x (fuel + 1)).Contains (cos x.value) := by rw [cosNameApprox] exact RatInterval.tighten_sound ih.1 hnew have hnext := cosInterval_sound (x.contains (fuel + 2)) (fuel + 2) constructor · exact hcur · rw [show fuel + 1 + 1 = fuel + 2 by omega, cosNameApprox] exact RatInterval.tighten_subinterval_left hcur hnext
    Causalean.Mathlib.Analysis.CertifiedContourIntervalArithmetic.Complex.Transcendental.cosNameApprox_spec · Causalean/Mathlib/Analysis/CertifiedContourIntervalArithmetic/Complex/TrigNames.lean:53
  • 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:98
  • 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:195