/-Copyright (c) 2026 Carles Marín. All rights reserved.Released under Apache 2.0 license as described in the file LICENSE.Authors: Carles Marín, Claude (AI assistant)-//-encaje: pruebas de la fase 2 del Paper III; enunciados copiados literalmente de ENUNCIADOS_FASE2.lean (puerta 92f7fa66eef47977, 12 FIEL en su alcance); reutiliza AngularExact, AngularPeaks y AngularPhaseFiber.-/module public import Formalizations.Combinatorics.Caballero.AngularExactpublic import Formalizations.Combinatorics.Caballero.AngularPhaseFiberpublic import Formalizations.Combinatorics.Caballero.AngularListStabilitypublic import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basicpublic import Mathlib.MeasureTheory.Integral.IntegrableOnpublic import Mathlib.MeasureTheory.Function.Floorpublic import Mathlib.Analysis.SpecialFunctions.Integrals.Basic /-!# Paper III, phase 2: proofs Proofs of the twelve statements of `ENUNCIADOS_FASE2.lean` that passed the statement gate (batch92f7fa66eef47977); the statements are copied verbatim. The two diagonal statements (`diagonal_b12`,`diagonal_completa`, gate NO_FIEL) are NOT here: the cases `b = 1, 2` stay as direct enumeration in thesupplement, as in the paper. The classification of Part I enters as the explicit hypothesis `hcl`; thethree-step law (Theorem `thm:step`, Prometeox) as the named hypothesis `LeyTresPasos`, never proved here.-/ /-!## References * C. Marín, Exact angular ambiguity profile for Dyck words of divisors (Part III), Zenodo (2026), doi:10.5281/zenodo.24699411.* C. Marín, How Many Dyck Words Do the Divisors of an Integer Make? Exact Counts and Quasipolynomial Growth (Part I), Zenodo (2026), doi:10.5281/zenodo.24536372 (concept DOI).-/ @[expose] public section namespace CaballeroFase2 open CaballeroPeaks CaballeroExact CaballeroPhaseFiber MeasureTheory Set /-! ## Shared definitions -/ /-- The Farey sequence of order four, `F₄ = {0, 1/4, 1/3, 1/2, 2/3, 3/4, 1}` (paper l.282). -/noncomputable def farey4 : Fin 7 → ℝ := ![0, 1 / 4, 1 / 3, 1 / 2, 2 / 3, 3 / 4, 1] /-- Theorem `thm:step` (paper l.351-357) in the exact form of Prometeox's contract(`GEOMETRIA_TEOR_A_CONTRATO.md`, canal 0319/0320): for `θ > 0` and `b ≥ 12θ + 18`, with the classificationof Part I at `b` and `b + 3`, `L_{b+3}(θ) - L_b(θ) = 3 F₂(θ)`. Used here ONLY as a hypothesis. -/def LeyTresPasos (Amb : ℤ → Palabra → Prop) : Prop := ∀ (b : ℕ) (θ : ℝ), 0 < θ → (12 : ℝ) * θ + 18 ≤ (b : ℝ) → (∀ w, Amb (b : ℤ) w ↔ enLista (b : ℤ) w) → (∀ w, Amb ((b + 3 : ℕ) : ℤ) w ↔ enLista ((b + 3 : ℕ) : ℤ) w) → secLen Amb (b + 3) θ - secLen Amb b θ = 3 * F2 θ /-- The ambiguous fraction `A_{2,b}(θ) = L_b(θ) / (b + 2θ)` (paper l.161 and l.175). -/noncomputable def fracAmb (Amb : ℤ → Palabra → Prop) (b : ℕ) (θ : ℝ) : ℝ := secLen Amb b θ / ((b : ℝ) + 2 * θ) /-- The floor pattern `k^{(m,r)}_h = ⌊(r + m h)/3⌋`, `h = -2, …, 2` (paper l.261 and l.292);`/` on `ℤ` rounds down for the positive divisor 3. -/def patronFase (m r : ℤ) : Palabra := ((r + m * (-2)) / 3, (r + m * (-1)) / 3, (r + m * 0) / 3, (r + m * 1) / 3, (r + m * 2) / 3) /-- The phase function `U_m(θ) = ∑_{r=0}^{2} w_{k^{(m,r)}}(θ)` (paper l.259-262), with Prometeox's`phaseWidth` as `w_k`. -/noncomputable def Ufase (m : ℤ) (θ : ℝ) : ℝ := ∑ r ∈ Finset.range 3, phaseWidth (patronFase m (r : ℤ)) θ /-! ### Phase table (Lemma `lem:phases`), generated by gen_fases2.py from generar_fases.py -/ /-- The body of `phaseWidth` with real arguments (definitionally equal, `phaseWidth_tupla`). -/noncomputable def anchoW (k0 k1 k2 k3 k4 θ : ℝ) : ℝ := max 0 (min 1 (min (k0 + 1 + 2 * θ) (min (k1 + 1 + θ) (min (k2 + 1) (min (k3 + 1 - θ) (k4 + 1 - 2 * θ))))) - max 0 (max (k0 + 2 * θ) (max (k1 + θ) (max k2 (max (k3 - θ) (k4 - 2 * θ)))))) theorem phaseWidth_tupla (a b c d e : ℤ) (θ : ℝ) : phaseWidth (a, b, c, d, e) θ = anchoW a b c d e θ := rfl theorem aw_m1_r0_t1 (θ : ℝ) (_h0 : (0 : ℝ) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 4)) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((0 : ℝ) + (1 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-1 : ℝ) + 1 + (1 : ℝ) * θ)) (c := (0 : ℝ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((0 : ℝ) + (1 : ℝ) * θ) ≤ ((-1 : ℝ) + 1 + (1 : ℝ) * θ) - (0 : ℝ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m1_r0_t2 (θ : ℝ) (_h0 : ((1 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 3)) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((0 : ℝ) + (1 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-1 : ℝ) + 1 + (1 : ℝ) * θ)) (c := (0 : ℝ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((0 : ℝ) + (1 : ℝ) * θ) ≤ ((-1 : ℝ) + 1 + (1 : ℝ) * θ) - (0 : ℝ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m1_r0_t3 (θ : ℝ) (_h0 : ((1 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 2)) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((1 : ℝ) + (-2 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((0 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := (0 : ℝ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((1 : ℝ) + (-2 : ℝ) * θ) ≤ ((0 : ℝ) + 1 + (-2 : ℝ) * θ) - (0 : ℝ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m1_r0_t4 (θ : ℝ) (_h0 : ((1 : ℝ) / 2) ≤ θ) (_h1 : θ ≤ ((2 : ℝ) / 3)) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((0 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((-1 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m1_r0_t5 (θ : ℝ) (_h0 : ((2 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((3 : ℝ) / 4)) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((0 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((-1 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m1_r0_t6 (θ : ℝ) (_h0 : ((3 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ (1 : ℝ)) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((0 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((-1 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m1_r0_t7 (θ : ℝ) (_h0 : (1 : ℝ) ≤ θ) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((0 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((-1 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m1_r1_t1 (θ : ℝ) (_h0 : (0 : ℝ) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 4)) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-1 : ℝ) + 1 + (2 : ℝ) * θ)) (c := ((1 : ℝ) + (-2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m1_r1_t2 (θ : ℝ) (_h0 : ((1 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 3)) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((-1 : ℝ) + (4 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-1 : ℝ) + 1 + (2 : ℝ) * θ)) (c := ((1 : ℝ) + (-2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((-1 : ℝ) + (4 : ℝ) * θ) ≤ ((-1 : ℝ) + 1 + (2 : ℝ) * θ) - ((1 : ℝ) + (-2 : ℝ) * θ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m1_r1_t3 (θ : ℝ) (_h0 : ((1 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 2)) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((1 : ℝ) + (-2 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((0 : ℝ) + 1 + (-1 : ℝ) * θ)) (c := ((0 : ℝ) + (1 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((1 : ℝ) + (-2 : ℝ) * θ) ≤ ((0 : ℝ) + 1 + (-1 : ℝ) * θ) - ((0 : ℝ) + (1 : ℝ) * θ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m1_r1_t4 (θ : ℝ) (_h0 : ((1 : ℝ) / 2) ≤ θ) (_h1 : θ ≤ ((2 : ℝ) / 3)) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((0 : ℝ) + 1 + (-1 : ℝ) * θ)) (c := ((0 : ℝ) + (1 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m1_r1_t5 (θ : ℝ) (_h0 : ((2 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((3 : ℝ) / 4)) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((0 : ℝ) + 1 + (-1 : ℝ) * θ)) (c := ((0 : ℝ) + (1 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m1_r1_t6 (θ : ℝ) (_h0 : ((3 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ (1 : ℝ)) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((0 : ℝ) + 1 + (-1 : ℝ) * θ)) (c := ((0 : ℝ) + (1 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m1_r1_t7 (θ : ℝ) (_h0 : (1 : ℝ) ≤ θ) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((1 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((-1 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m1_r2_t1 (θ : ℝ) (_h0 : (0 : ℝ) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 4)) : anchoW (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (1 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := (1 : ℝ)) (c := ((1 : ℝ) + (-1 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((0 : ℝ) + (1 : ℝ) * θ) ≤ (1 : ℝ) - ((1 : ℝ) + (-1 : ℝ) * θ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m1_r2_t2 (θ : ℝ) (_h0 : ((1 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 3)) : anchoW (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (1 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := (1 : ℝ)) (c := ((1 : ℝ) + (-1 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((0 : ℝ) + (1 : ℝ) * θ) ≤ (1 : ℝ) - ((1 : ℝ) + (-1 : ℝ) * θ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m1_r2_t3 (θ : ℝ) (_h0 : ((1 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 2)) : anchoW (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((1 : ℝ) + (-2 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := (1 : ℝ)) (c := ((0 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((1 : ℝ) + (-2 : ℝ) * θ) ≤ (1 : ℝ) - ((0 : ℝ) + (2 : ℝ) * θ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m1_r2_t4 (θ : ℝ) (_h0 : ((1 : ℝ) / 2) ≤ θ) (_h1 : θ ≤ ((2 : ℝ) / 3)) : anchoW (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((1 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((0 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m1_r2_t5 (θ : ℝ) (_h0 : ((2 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((3 : ℝ) / 4)) : anchoW (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((1 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((0 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m1_r2_t6 (θ : ℝ) (_h0 : ((3 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ (1 : ℝ)) : anchoW (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((1 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((0 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m1_r2_t7 (θ : ℝ) (_h0 : (1 : ℝ) ≤ θ) : anchoW (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((1 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((0 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m2_r0_t1 (θ : ℝ) (_h0 : (0 : ℝ) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 4)) : anchoW (-2 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-2 : ℝ) + 1 + (2 : ℝ) * θ)) (c := ((1 : ℝ) + (-2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m2_r0_t2 (θ : ℝ) (_h0 : ((1 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 3)) : anchoW (-2 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-2 : ℝ) + 1 + (2 : ℝ) * θ)) (c := ((1 : ℝ) + (-2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m2_r0_t3 (θ : ℝ) (_h0 : ((1 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 2)) : anchoW (-2 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-2 : ℝ) + 1 + (2 : ℝ) * θ)) (c := ((1 : ℝ) + (-2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m2_r0_t4 (θ : ℝ) (_h0 : ((1 : ℝ) / 2) ≤ θ) (_h1 : θ ≤ ((2 : ℝ) / 3)) : anchoW (-2 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((-1 : ℝ) + (2 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-2 : ℝ) + 1 + (2 : ℝ) * θ)) (c := (0 : ℝ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((-1 : ℝ) + (2 : ℝ) * θ) ≤ ((-2 : ℝ) + 1 + (2 : ℝ) * θ) - (0 : ℝ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m2_r0_t5 (θ : ℝ) (_h0 : ((2 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((3 : ℝ) / 4)) : anchoW (-2 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((1 : ℝ) + (-1 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((0 : ℝ) + 1 + (-1 : ℝ) * θ)) (c := (0 : ℝ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((1 : ℝ) + (-1 : ℝ) * θ) ≤ ((0 : ℝ) + 1 + (-1 : ℝ) * θ) - (0 : ℝ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m2_r0_t6 (θ : ℝ) (_h0 : ((3 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ (1 : ℝ)) : anchoW (-2 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((1 : ℝ) + (-1 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((0 : ℝ) + 1 + (-1 : ℝ) * θ)) (c := (0 : ℝ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((1 : ℝ) + (-1 : ℝ) * θ) ≤ ((0 : ℝ) + 1 + (-1 : ℝ) * θ) - (0 : ℝ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m2_r0_t7 (θ : ℝ) (_h0 : (1 : ℝ) ≤ θ) : anchoW (-2 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((1 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((-2 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m2_r1_t1 (θ : ℝ) (_h0 : (0 : ℝ) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 4)) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-1 : ℝ) + 1 + (1 : ℝ) * θ)) (c := ((1 : ℝ) + (-1 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m2_r1_t2 (θ : ℝ) (_h0 : ((1 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 3)) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-1 : ℝ) + 1 + (1 : ℝ) * θ)) (c := ((1 : ℝ) + (-1 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m2_r1_t3 (θ : ℝ) (_h0 : ((1 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 2)) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-1 : ℝ) + 1 + (1 : ℝ) * θ)) (c := ((1 : ℝ) + (-1 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m2_r1_t4 (θ : ℝ) (_h0 : ((1 : ℝ) / 2) ≤ θ) (_h1 : θ ≤ ((2 : ℝ) / 3)) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((-1 : ℝ) + (2 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-1 : ℝ) + 1 + (1 : ℝ) * θ)) (c := ((1 : ℝ) + (-1 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((-1 : ℝ) + (2 : ℝ) * θ) ≤ ((-1 : ℝ) + 1 + (1 : ℝ) * θ) - ((1 : ℝ) + (-1 : ℝ) * θ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m2_r1_t5 (θ : ℝ) (_h0 : ((2 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((3 : ℝ) / 4)) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((3 : ℝ) + (-4 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((1 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((-1 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((3 : ℝ) + (-4 : ℝ) * θ) ≤ ((1 : ℝ) + 1 + (-2 : ℝ) * θ) - ((-1 : ℝ) + (2 : ℝ) * θ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m2_r1_t6 (θ : ℝ) (_h0 : ((3 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ (1 : ℝ)) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((1 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((-1 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m2_r1_t7 (θ : ℝ) (_h0 : (1 : ℝ) ≤ θ) : anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((1 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((-1 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m2_r2_t1 (θ : ℝ) (_h0 : (0 : ℝ) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 4)) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (2 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-1 : ℝ) + 1 + (2 : ℝ) * θ)) (c := ((2 : ℝ) + (-2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m2_r2_t2 (θ : ℝ) (_h0 : ((1 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 3)) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (2 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-1 : ℝ) + 1 + (2 : ℝ) * θ)) (c := ((2 : ℝ) + (-2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m2_r2_t3 (θ : ℝ) (_h0 : ((1 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 2)) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (2 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((-1 : ℝ) + 1 + (2 : ℝ) * θ)) (c := ((2 : ℝ) + (-2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem aw_m2_r2_t4 (θ : ℝ) (_h0 : ((1 : ℝ) / 2) ≤ θ) (_h1 : θ ≤ ((2 : ℝ) / 3)) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (2 : ℝ) θ = ((-1 : ℝ) + (2 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := (1 : ℝ)) (c := ((2 : ℝ) + (-2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_right; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((-1 : ℝ) + (2 : ℝ) * θ) ≤ (1 : ℝ) - ((2 : ℝ) + (-2 : ℝ) * θ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m2_r2_t5 (θ : ℝ) (_h0 : ((2 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((3 : ℝ) / 4)) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (2 : ℝ) θ = ((1 : ℝ) + (-1 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := (1 : ℝ)) (c := ((0 : ℝ) + (1 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((1 : ℝ) + (-1 : ℝ) * θ) ≤ (1 : ℝ) - ((0 : ℝ) + (1 : ℝ) * θ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m2_r2_t6 (θ : ℝ) (_h0 : ((3 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ (1 : ℝ)) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (2 : ℝ) θ = ((1 : ℝ) + (-1 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := (1 : ℝ)) (c := ((0 : ℝ) + (1 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_left_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · apply le_max_of_le_right refine le_trans (by linarith : ((1 : ℝ) + (-1 : ℝ) * θ) ≤ (1 : ℝ) - ((0 : ℝ) + (1 : ℝ) * θ)) (sub_le_sub ?_ ?_) · exact (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (le_min (by linarith) (by linarith)))))) · exact (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (max_le (by linarith) (by linarith)))))) theorem aw_m2_r2_t7 (θ : ℝ) (_h0 : (1 : ℝ) ≤ θ) : anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (2 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold anchoW apply le_antisymm · apply max_le (by linarith) refine le_trans (sub_le_sub (b := ((2 : ℝ) + 1 + (-2 : ℝ) * θ)) (c := ((-1 : ℝ) + (2 : ℝ) * θ)) ?_ ?_) (by linarith) · apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; apply min_le_of_right_le; exact le_of_eq (by ring) · apply le_max_of_le_right; apply le_max_of_le_left; exact le_of_eq (by ring) · exact le_max_of_le_left (by linarith) theorem Ufase_1_eq (θ : ℝ) : Ufase 1 θ = anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ + anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ + anchoW (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ := by have e0 : patronFase 1 ((0 : ℕ) : ℤ) = (-1, -1, 0, 0, 0) := by decide have e1 : patronFase 1 ((1 : ℕ) : ℤ) = (-1, 0, 0, 0, 1) := by decide have e2 : patronFase 1 ((2 : ℕ) : ℤ) = (0, 0, 0, 1, 1) := by decide simp only [Ufase, Finset.sum_range_succ, Finset.sum_range_zero, zero_add, e0, e1, e2, phaseWidth_tupla] push_cast ring theorem Ufase_2_eq (θ : ℝ) : Ufase 2 θ = anchoW (-2 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ + anchoW (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ + anchoW (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (2 : ℝ) θ := by have e0 : patronFase 2 ((0 : ℕ) : ℤ) = (-2, -1, 0, 0, 1) := by decide have e1 : patronFase 2 ((1 : ℕ) : ℤ) = (-1, -1, 0, 1, 1) := by decide have e2 : patronFase 2 ((2 : ℕ) : ℤ) = (-1, 0, 0, 1, 2) := by decide simp only [Ufase, Finset.sum_range_succ, Finset.sum_range_zero, zero_add, e0, e1, e2, phaseWidth_tupla] push_cast ring theorem Ufase_tramo1 (θ : ℝ) (h0 : (0 : ℝ) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 4)) : Ufase 1 θ = ((0 : ℝ) + (2 : ℝ) * θ) ∧ Ufase 2 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by rw [Ufase_1_eq, Ufase_2_eq, aw_m1_r0_t1 θ h0 h1, aw_m1_r1_t1 θ h0 h1, aw_m1_r2_t1 θ h0 h1, aw_m2_r0_t1 θ h0 h1, aw_m2_r1_t1 θ h0 h1, aw_m2_r2_t1 θ h0 h1] constructor <;> ring theorem F2_tramo1 (θ : ℝ) (_h0 : (0 : ℝ) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 4)) : F2 θ = ((0 : ℝ) + (2 : ℝ) * θ) := by unfold F2 split_ifs <;> linarith theorem Ufase_tramo2 (θ : ℝ) (h0 : ((1 : ℝ) / 4) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 3)) : Ufase 1 θ = ((-1 : ℝ) + (6 : ℝ) * θ) ∧ Ufase 2 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by rw [Ufase_1_eq, Ufase_2_eq, aw_m1_r0_t2 θ h0 h1, aw_m1_r1_t2 θ h0 h1, aw_m1_r2_t2 θ h0 h1, aw_m2_r0_t2 θ h0 h1, aw_m2_r1_t2 θ h0 h1, aw_m2_r2_t2 θ h0 h1] constructor <;> ring theorem F2_tramo2 (θ : ℝ) (h0 : ((1 : ℝ) / 4) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 3)) : F2 θ = ((-1 : ℝ) + (6 : ℝ) * θ) := by unfold F2 split_ifs <;> linarith theorem Ufase_tramo3 (θ : ℝ) (h0 : ((1 : ℝ) / 3) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 2)) : Ufase 1 θ = ((3 : ℝ) + (-6 : ℝ) * θ) ∧ Ufase 2 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by rw [Ufase_1_eq, Ufase_2_eq, aw_m1_r0_t3 θ h0 h1, aw_m1_r1_t3 θ h0 h1, aw_m1_r2_t3 θ h0 h1, aw_m2_r0_t3 θ h0 h1, aw_m2_r1_t3 θ h0 h1, aw_m2_r2_t3 θ h0 h1] constructor <;> ring theorem F2_tramo3 (θ : ℝ) (h0 : ((1 : ℝ) / 3) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 2)) : F2 θ = ((3 : ℝ) + (-6 : ℝ) * θ) := by unfold F2 split_ifs <;> linarith theorem Ufase_tramo4 (θ : ℝ) (h0 : ((1 : ℝ) / 2) ≤ θ) (h1 : θ ≤ ((2 : ℝ) / 3)) : Ufase 1 θ = ((0 : ℝ) + (0 : ℝ) * θ) ∧ Ufase 2 θ = ((-3 : ℝ) + (6 : ℝ) * θ) := by rw [Ufase_1_eq, Ufase_2_eq, aw_m1_r0_t4 θ h0 h1, aw_m1_r1_t4 θ h0 h1, aw_m1_r2_t4 θ h0 h1, aw_m2_r0_t4 θ h0 h1, aw_m2_r1_t4 θ h0 h1, aw_m2_r2_t4 θ h0 h1] constructor <;> ring theorem F2_tramo4 (θ : ℝ) (h0 : ((1 : ℝ) / 2) ≤ θ) (h1 : θ ≤ ((2 : ℝ) / 3)) : F2 θ = ((-1 : ℝ) + (2 : ℝ) * θ) := by unfold F2 split_ifs <;> linarith theorem Ufase_tramo5 (θ : ℝ) (h0 : ((2 : ℝ) / 3) ≤ θ) (h1 : θ ≤ ((3 : ℝ) / 4)) : Ufase 1 θ = ((0 : ℝ) + (0 : ℝ) * θ) ∧ Ufase 2 θ = ((5 : ℝ) + (-6 : ℝ) * θ) := by rw [Ufase_1_eq, Ufase_2_eq, aw_m1_r0_t5 θ h0 h1, aw_m1_r1_t5 θ h0 h1, aw_m1_r2_t5 θ h0 h1, aw_m2_r0_t5 θ h0 h1, aw_m2_r1_t5 θ h0 h1, aw_m2_r2_t5 θ h0 h1] constructor <;> ring theorem F2_tramo5 (θ : ℝ) (h0 : ((2 : ℝ) / 3) ≤ θ) (h1 : θ ≤ ((3 : ℝ) / 4)) : F2 θ = (((5 : ℝ) / 3) + (-2 : ℝ) * θ) := by unfold F2 split_ifs <;> linarith theorem Ufase_tramo6 (θ : ℝ) (h0 : ((3 : ℝ) / 4) ≤ θ) (h1 : θ ≤ (1 : ℝ)) : Ufase 1 θ = ((0 : ℝ) + (0 : ℝ) * θ) ∧ Ufase 2 θ = ((2 : ℝ) + (-2 : ℝ) * θ) := by rw [Ufase_1_eq, Ufase_2_eq, aw_m1_r0_t6 θ h0 h1, aw_m1_r1_t6 θ h0 h1, aw_m1_r2_t6 θ h0 h1, aw_m2_r0_t6 θ h0 h1, aw_m2_r1_t6 θ h0 h1, aw_m2_r2_t6 θ h0 h1] constructor <;> ring theorem F2_tramo6 (θ : ℝ) (h0 : ((3 : ℝ) / 4) ≤ θ) (h1 : θ ≤ (1 : ℝ)) : F2 θ = (((2 : ℝ) / 3) + ((-2 : ℝ) / 3) * θ) := by unfold F2 split_ifs <;> linarith theorem Ufase_tramo7 (θ : ℝ) (h0 : (1 : ℝ) ≤ θ) : Ufase 1 θ = ((0 : ℝ) + (0 : ℝ) * θ) ∧ Ufase 2 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by rw [Ufase_1_eq, Ufase_2_eq, aw_m1_r0_t7 θ h0, aw_m1_r1_t7 θ h0, aw_m1_r2_t7 θ h0, aw_m2_r0_t7 θ h0, aw_m2_r1_t7 θ h0, aw_m2_r2_t7 θ h0] constructor <;> ring theorem F2_tramo7 (θ : ℝ) (h0 : (1 : ℝ) ≤ θ) : F2 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by unfold F2 split_ifs <;> linarith /-! ## Auxiliary results (not gated statements) Everything in this section is proved; it only serves the gated statements below. -/ /-! ### Elementary facts on `F₂` -/ theorem F2_bounds (θ : ℝ) (hθ : 0 < θ) : 0 ≤ F2 θ ∧ F2 θ ≤ 1 := by unfold F2 split_ifs <;> constructor <;> linarith theorem F2_continuous : Continuous F2 := by have c : ∀ (a : ℝ) (f g : ℝ → ℝ), Continuous f → Continuous g → f a = g a → Continuous fun θ => if θ ≤ a then f θ else g θ := fun a f g hf hg h => Continuous.if_le hf hg continuous_id continuous_const (fun x hx => by have hx' : x = a := hx rw [hx']; exact h) unfold F2 apply c _ _ _ (by fun_prop) _ (by norm_num) apply c _ _ _ (by fun_prop) _ (by norm_num) apply c _ _ _ (by fun_prop) _ (by norm_num) apply c _ _ _ (by fun_prop) _ (by norm_num) apply c _ _ _ (by fun_prop) _ (by norm_num) exact c _ _ _ (by fun_prop) (by fun_prop) (by norm_num) /-! ### Integrals of affine pieces -/ theorem integral_afin (a b α β : ℝ) : ∫ x in a..b, (α + β * x) = α * (b - a) + β * ((b ^ 2 - a ^ 2) / 2) := by have h1 : IntervalIntegrable (fun _ : ℝ => α) volume a b := continuous_const.intervalIntegrable a b have h2 : IntervalIntegrable (fun x : ℝ => β * x) volume a b := (continuous_const.mul continuous_id).intervalIntegrable a b have h3 : ∫ x in a..b, β * x = β * ((b ^ 2 - a ^ 2) / 2) := by rw [intervalIntegral.integral_const_mul, integral_id] rw [intervalIntegral.integral_add h1 h2, h3, intervalIntegral.integral_const, smul_eq_mul] ring theorem integral_tramo (f : ℝ → ℝ) (a b α β : ℝ) (hab : a ≤ b) (h : ∀ x, a ≤ x → x ≤ b → f x = α + β * x) : ∫ x in a..b, f x = α * (b - a) + β * ((b ^ 2 - a ^ 2) / 2) := by rw [← integral_afin] apply intervalIntegral.integral_congr intro x hx rw [Set.uIcc_of_le hab] at hx exact h x hx.1 hx.2 /-! ### Chambers of `F₄`: sign of integer affine functions -/ /-- A function affine on the open chamber `i`. -/def AfinC (i : Fin 6) (f : ℝ → ℝ) : Prop := ∃ α β : ℝ, ∀ θ ∈ Ioo (farey4 i.castSucc) (farey4 i.succ), f θ = α + β * θ /-- A function equal on the open chamber `i` to `p + qθ` with `p, q ∈ ℤ`, `|q| ≤ 2`. -/def Basico (i : Fin 6) (f : ℝ → ℝ) : Prop := ∃ p q : ℤ, -2 ≤ q ∧ q ≤ 2 ∧ ∀ θ ∈ Ioo (farey4 i.castSucc) (farey4 i.succ), f θ = p + q * θ /-- The chamber endpoints are `A/12` and `C/12`, and no fraction `n/d` with `1 ≤ d ≤ 4` lies strictlybetween them. -/theorem camara_doce (i : Fin 6) : ∃ A C : ℤ, farey4 i.castSucc = (A : ℝ) / 12 ∧ farey4 i.succ = (C : ℝ) / 12 ∧ 0 ≤ A ∧ C ≤ 12 ∧ ∀ n d : ℤ, 1 ≤ d → d ≤ 4 → A * d < 12 * n → 12 * n < C * d → False := by fin_cases i · exact ⟨0, 3, by change (0 : ℝ) = _; norm_num, by change (1 / 4 : ℝ) = _; norm_num, by norm_num, by norm_num, fun n d h1 h4 ha hc => by omega⟩ · exact ⟨3, 4, by change (1 / 4 : ℝ) = _; norm_num, by change (1 / 3 : ℝ) = _; norm_num, by norm_num, by norm_num, fun n d h1 h4 ha hc => by omega⟩ · exact ⟨4, 6, by change (1 / 3 : ℝ) = _; norm_num, by change (1 / 2 : ℝ) = _; norm_num, by norm_num, by norm_num, fun n d h1 h4 ha hc => by omega⟩ · exact ⟨6, 8, by change (1 / 2 : ℝ) = _; norm_num, by change (2 / 3 : ℝ) = _; norm_num, by norm_num, by norm_num, fun n d h1 h4 ha hc => by omega⟩ · exact ⟨8, 9, by change (2 / 3 : ℝ) = _; norm_num, by change (3 / 4 : ℝ) = _; norm_num, by norm_num, by norm_num, fun n d h1 h4 ha hc => by omega⟩ · exact ⟨9, 12, by change (3 / 4 : ℝ) = _; norm_num, by change (1 : ℝ) = _; norm_num, by norm_num, by norm_num, fun n d h1 h4 ha hc => by omega⟩ theorem camara_bounds (i : Fin 6) (θ : ℝ) (h : θ ∈ Ioo (farey4 i.castSucc) (farey4 i.succ)) : 0 < θ ∧ θ < 1 := by obtain ⟨A, C, hA, hC, hA0, hC1, -⟩ := camara_doce i rw [hA, hC] at h obtain ⟨h0, h1⟩ := h have hA0' : (0 : ℝ) ≤ A := by exact_mod_cast hA0 have hC1' : (C : ℝ) ≤ 12 := by exact_mod_cast hC1 constructor <;> linarith /-- On an open chamber, an affine function with integer coefficients and slope in `[-4, 4]` has constant sign:its zero would be a fraction of denominator at most four. -/theorem signo (i : Fin 6) (p q : ℤ) (hq0 : -4 ≤ q) (hq1 : q ≤ 4) : (∀ θ ∈ Ioo (farey4 i.castSucc) (farey4 i.succ), 0 ≤ (p : ℝ) + q * θ) ∨ (∀ θ ∈ Ioo (farey4 i.castSucc) (farey4 i.succ), (p : ℝ) + q * θ ≤ 0) := by obtain ⟨A, C, hA, hC, -, -, hno⟩ := camara_doce i by_contra hcon rw [not_or] at hcon obtain ⟨h1, h2⟩ := hcon simp only [not_forall, not_le] at h1 h2 obtain ⟨θ1, hθ1, n1⟩ := h1 obtain ⟨θ2, hθ2, n2⟩ := h2 rw [hA, hC] at hθ1 hθ2 obtain ⟨a1, c1⟩ := hθ1 obtain ⟨a2, c2⟩ := hθ2 rcases lt_trichotomy q 0 with hq | hq | hq · have hqr : (q : ℝ) < 0 := by exact_mod_cast hq apply hno p (-q) (by omega) (by omega) · have e : ((A * (-q) : ℤ) : ℝ) < ((12 * p : ℤ) : ℝ) := by push_cast nlinarith [mul_pos (neg_pos.mpr hqr) (sub_pos.mpr a2)] exact_mod_cast e · have e : ((12 * p : ℤ) : ℝ) < ((C * (-q) : ℤ) : ℝ) := by push_cast nlinarith [mul_pos (neg_pos.mpr hqr) (sub_pos.mpr c1)] exact_mod_cast e · subst hq push_cast at n1 n2 linarith · have hqr : (0 : ℝ) < q := by exact_mod_cast hq apply hno (-p) q (by omega) (by omega) · have e : ((A * q : ℤ) : ℝ) < ((12 * (-p) : ℤ) : ℝ) := by push_cast nlinarith [mul_pos hqr (sub_pos.mpr a1)] exact_mod_cast e · have e : ((12 * (-p) : ℤ) : ℝ) < ((C * q : ℤ) : ℝ) := by push_cast nlinarith [mul_pos hqr (sub_pos.mpr c2)] exact_mod_cast e theorem basico_lin (i : Fin 6) (p q : ℤ) (h0 : -2 ≤ q) (h1 : q ≤ 2) (f : ℝ → ℝ) (hf : ∀ θ, f θ = (p : ℝ) + q * θ) : Basico i f := ⟨p, q, h0, h1, fun θ _ => hf θ⟩ theorem basico_min (i : Fin 6) {f g : ℝ → ℝ} (hf : Basico i f) (hg : Basico i g) : Basico i (fun θ => min (f θ) (g θ)) := by obtain ⟨p, q, hq0, hq1, ef⟩ := hf obtain ⟨p', q', hq0', hq1', eg⟩ := hg rcases signo i (p - p') (q - q') (by omega) (by omega) with h | h · refine ⟨p', q', hq0', hq1', fun θ hθ => ?_⟩ have := h θ hθ push_cast at this beta_reduce rw [ef θ hθ, eg θ hθ] exact min_eq_right (by linarith) · refine ⟨p, q, hq0, hq1, fun θ hθ => ?_⟩ have := h θ hθ push_cast at this beta_reduce rw [ef θ hθ, eg θ hθ] exact min_eq_left (by linarith) theorem basico_max (i : Fin 6) {f g : ℝ → ℝ} (hf : Basico i f) (hg : Basico i g) : Basico i (fun θ => max (f θ) (g θ)) := by obtain ⟨p, q, hq0, hq1, ef⟩ := hf obtain ⟨p', q', hq0', hq1', eg⟩ := hg rcases signo i (p - p') (q - q') (by omega) (by omega) with h | h · refine ⟨p, q, hq0, hq1, fun θ hθ => ?_⟩ have := h θ hθ push_cast at this beta_reduce rw [ef θ hθ, eg θ hθ] exact max_eq_left (by linarith) · refine ⟨p', q', hq0', hq1', fun θ hθ => ?_⟩ have := h θ hθ push_cast at this beta_reduce rw [ef θ hθ, eg θ hθ] exact max_eq_right (by linarith) theorem basico_addN (i : Fin 6) (j : ℕ) {f : ℝ → ℝ} (hf : Basico i f) : Basico i (fun θ => (j : ℝ) + f θ) := by obtain ⟨p, q, hq0, hq1, ef⟩ := hf refine ⟨j + p, q, hq0, hq1, fun θ hθ => ?_⟩ beta_reduce rw [ef θ hθ] push_cast ring theorem afinC_pos_sub (i : Fin 6) {f g : ℝ → ℝ} (hf : Basico i f) (hg : Basico i g) : AfinC i (fun θ => max 0 (f θ - g θ)) := by obtain ⟨p, q, hq0, hq1, ef⟩ := hf obtain ⟨p', q', hq0', hq1', eg⟩ := hg rcases signo i (p - p') (q - q') (by omega) (by omega) with h | h · refine ⟨(p : ℝ) - p', (q : ℝ) - q', fun θ hθ => ?_⟩ have := h θ hθ push_cast at this beta_reduce rw [ef θ hθ, eg θ hθ, max_eq_right (by linarith)] ring · refine ⟨0, 0, fun θ hθ => ?_⟩ have := h θ hθ push_cast at this beta_reduce rw [ef θ hθ, eg θ hθ, max_eq_left (by linarith)] ring theorem afinC_sum {ι : Type*} (i : Fin 6) (s : Finset ι) (f : ι → ℝ → ℝ) (h : ∀ x ∈ s, AfinC i (f x)) : AfinC i (fun θ => ∑ x ∈ s, f x θ) := by classical induction s using Finset.induction_on with | empty => exact ⟨0, 0, fun θ _ => by simp⟩ | @insert a s ha ih => obtain ⟨α, β, e⟩ := h a (Finset.mem_insert_self a s) obtain ⟨α', β', e'⟩ := ih (fun x hx => h x (Finset.mem_insert_of_mem hx)) refine ⟨α + α', β + β', fun θ hθ => ?_⟩ have e'' : ∑ x ∈ s, f x θ = α' + β' * θ := e' θ hθ beta_reduce rw [Finset.sum_insert ha, e θ hθ, e''] ring theorem basico_up (i : Fin 6) (j : ℕ) (k : Palabra) : Basico i (fun θ => (j : ℝ) + phaseUpper k θ) := by obtain ⟨a, b, c, d, e⟩ := k apply basico_addN show Basico i (fun θ => min 1 (min ((a : ℝ) + 1 + 2 * θ) (min ((b : ℝ) + 1 + θ) (min ((c : ℝ) + 1) (min ((d : ℝ) + 1 - θ) ((e : ℝ) + 1 - 2 * θ)))))) refine basico_min i (basico_lin i 1 0 (by norm_num) (by norm_num) (fun _ => (1 : ℝ)) (fun θ => by simp)) ?_ refine basico_min i (basico_lin i (a + 1) 2 (by norm_num) (by norm_num) (fun θ => (a : ℝ) + 1 + 2 * θ) (fun θ => by push_cast; ring)) ?_ refine basico_min i (basico_lin i (b + 1) 1 (by norm_num) (by norm_num) (fun θ => (b : ℝ) + 1 + θ) (fun θ => by push_cast; ring)) ?_ refine basico_min i (basico_lin i (c + 1) 0 (by norm_num) (by norm_num) (fun θ => (c : ℝ) + 1) (fun θ => by push_cast; ring)) ?_ exact basico_min i (basico_lin i (d + 1) (-1) (by norm_num) (by norm_num) (fun θ => (d : ℝ) + 1 - θ) (fun θ => by push_cast; ring)) (basico_lin i (e + 1) (-2) (by norm_num) (by norm_num) (fun θ => (e : ℝ) + 1 - 2 * θ) (fun θ => by push_cast; ring)) theorem basico_lo (i : Fin 6) (j : ℕ) (k : Palabra) : Basico i (fun θ => (j : ℝ) + phaseLower k θ) := by obtain ⟨a, b, c, d, e⟩ := k apply basico_addN show Basico i (fun θ => max 0 (max ((a : ℝ) + 2 * θ) (max ((b : ℝ) + θ) (max (c : ℝ) (max ((d : ℝ) - θ) ((e : ℝ) - 2 * θ)))))) refine basico_max i (basico_lin i 0 0 (by norm_num) (by norm_num) (fun _ => (0 : ℝ)) (fun θ => by simp)) ?_ refine basico_max i (basico_lin i a 2 (by norm_num) (by norm_num) (fun θ => (a : ℝ) + 2 * θ) (fun θ => by push_cast; ring)) ?_ refine basico_max i (basico_lin i b 1 (by norm_num) (by norm_num) (fun θ => (b : ℝ) + θ) (fun θ => by push_cast; ring)) ?_ refine basico_max i (basico_lin i c 0 (by norm_num) (by norm_num) (fun θ => (c : ℝ)) (fun θ => by push_cast; ring)) ?_ exact basico_max i (basico_lin i d (-1) (by norm_num) (by norm_num) (fun θ => (d : ℝ) - θ) (fun θ => by push_cast; ring)) (basico_lin i e (-2) (by norm_num) (by norm_num) (fun θ => (e : ℝ) - 2 * θ) (fun θ => by push_cast; ring)) /-! ### Decomposition of a section into unit intervals and phase fibres -/ /-- The clipped word `(clip_b (j + k_h))_h`. -/def clipW (b j : ℤ) (k : Palabra) : Palabra := (clip b (j + k.1), clip b (j + k.2.1), clip b (j + k.2.2.1), clip b (j + k.2.2.2.1), clip b (j + k.2.2.2.2)) /-- The cube `[-N, N]⁵` of floor patterns. -/def cuboK (N : ℕ) : Finset Palabra := Finset.Icc (-(N : ℤ)) N ×ˢ Finset.Icc (-(N : ℤ)) N ×ˢ Finset.Icc (-(N : ℤ)) N ×ˢ Finset.Icc (-(N : ℤ)) N ×ˢ Finset.Icc (-(N : ℤ)) N theorem floor_shift (j : ℤ) (x y : ℝ) (h : x = y + j) : ⌊x⌋ = j + ⌊y⌋ := by rw [h, Int.floor_add_intCast] ring theorem cellWord_shift (b j : ℤ) (Λ θ : ℝ) : cellWord b Λ θ = clipW b j (rawWord θ (Λ - j)) := by have e : ∀ c : ℤ, ⌊Λ + (c : ℝ) * θ⌋ = j + ⌊(Λ - j) + (c : ℝ) * θ⌋ := fun c => floor_shift j _ _ (by ring) simp only [cellWord, clipW, rawWord, e, Prod.mk.injEq] refine ⟨?_, ?_, ?_, ?_, ?_⟩ <;> congr 3 <;> push_cast <;> ring theorem rawWord_mem_cubo (N : ℕ) (θ u : ℝ) (hθ : 0 < θ) (hN : 2 * θ < N) (hu0 : 0 ≤ u) (hu1 : u < 1) : rawWord θ u ∈ cuboK N := by have lo : ∀ x : ℝ, -(N : ℝ) ≤ x → -(N : ℤ) ≤ ⌊x⌋ := fun x h => Int.le_floor.mpr (by push_cast; linarith) have hi : ∀ x : ℝ, x < N + 1 → ⌊x⌋ ≤ N := fun x h => by have : ⌊x⌋ < (N : ℤ) + 1 := Int.floor_lt.mpr (by push_cast; linarith) omega simp only [cuboK, rawWord, Finset.mem_product, Finset.mem_Icc] exact ⟨⟨lo _ (by linarith), hi _ (by linarith)⟩, ⟨lo _ (by linarith), hi _ (by linarith)⟩, ⟨lo _ (by linarith), hi _ (by linarith)⟩, ⟨lo _ (by linarith), hi _ (by linarith)⟩, lo _ (by linarith), hi _ (by linarith)⟩ theorem vol_Ico_inter_Iic (a c B : ℝ) : volume (Ico a c ∩ Iic B) = ENNReal.ofReal (max 0 (min c B - a)) := by have e : ENNReal.ofReal (max 0 (min c B - a)) = ENNReal.ofReal (min c B - a) := by rcases le_total 0 (min c B - a) with h | h · rw [max_eq_right h] · rw [max_eq_left h, ENNReal.ofReal_zero, ENNReal.ofReal_of_nonpos h] rw [e] apply le_antisymm · calc volume (Ico a c ∩ Iic B) ≤ volume (Icc a (min c B)) := measure_mono (fun x hx => ⟨hx.1.1, le_min hx.1.2.le hx.2⟩) _ = _ := Real.volume_Icc · calc ENNReal.ofReal (min c B - a) = volume (Ico a (min c B)) := Real.volume_Ico.symm _ ≤ volume (Ico a c ∩ Iic B) := measure_mono (fun x hx => ⟨⟨hx.1, lt_of_lt_of_le hx.2 (min_le_left _ _)⟩, (lt_of_lt_of_le hx.2 (min_le_right _ _)).le⟩) open Classical in/-- The section length as a finite sum over unit intervals `j` and floor patterns `k`: each pair contributesthe length of its phase interval, cut at the end `b + 2θ` of the section. -/theorem secLen_descomp (R : ℤ → Palabra → Prop) (b N : ℕ) (θ : ℝ) (hθ : 0 < θ) (hN : 2 * θ < N) : secLen R b θ = ∑ x ∈ Finset.range (b + N) ×ˢ cuboK N, if R (b : ℤ) (clipW (b : ℤ) (x.1 : ℤ) x.2) then max 0 (min ((x.1 : ℝ) + phaseUpper x.2 θ) ((b : ℝ) + 2 * θ) - ((x.1 : ℝ) + phaseLower x.2 θ)) else 0 := by let Q : ℕ × Palabra → Set ℝ := fun x => Ico ((x.1 : ℝ) + phaseLower x.2 θ) ((x.1 : ℝ) + phaseUpper x.2 θ) ∩ Iic ((b : ℝ) + 2 * θ) let T := (Finset.range (b + N) ×ˢ cuboK N).filter (fun x => R (b : ℤ) (clipW (b : ℤ) (x.1 : ℤ) x.2)) have memQ : ∀ (x : ℕ × Palabra) (Λ : ℝ), Λ ∈ Q x ↔ ((0 ≤ Λ - x.1 ∧ Λ - x.1 < 1) ∧ rawWord θ (Λ - x.1) = x.2) ∧ Λ ≤ (b : ℝ) + 2 * θ := by intro x Λ have h2 : (Λ - x.1 ∈ phaseFiber θ x.2) ↔ ((0 ≤ Λ - x.1 ∧ Λ - x.1 < 1) ∧ rawWord θ (Λ - x.1) = x.2) := Iff.rfl rw [phaseFiber_eq_Ico, Set.mem_Ico] at h2 simp only [Q, Set.mem_inter_iff, Set.mem_Ico, Set.mem_Iic] constructor · rintro ⟨⟨h0, h1⟩, hb⟩ exact ⟨h2.mp ⟨by linarith, by linarith⟩, hb⟩ · rintro ⟨h, hb⟩ obtain ⟨h0, h1⟩ := h2.mpr h exact ⟨⟨by linarith, by linarith⟩, hb⟩ have hS : {Λ : ℝ | 0 ≤ Λ ∧ Λ ≤ (b : ℝ) + 2 * θ ∧ R (b : ℤ) (cellWord (b : ℤ) Λ θ)} = ⋃ x ∈ T, Q x := by ext Λ simp only [Set.mem_ofPred_eq, Set.mem_iUnion, exists_prop] constructor · rintro ⟨h0, h1, hR⟩ have hj0 : 0 ≤ ⌊Λ⌋ := Int.floor_nonneg.mpr h0 have hjr : ((⌊Λ⌋.toNat : ℕ) : ℝ) = ((⌊Λ⌋ : ℤ) : ℝ) := by exact_mod_cast Int.toNat_of_nonneg hj0 have hjz : ((⌊Λ⌋.toNat : ℕ) : ℤ) = ⌊Λ⌋ := Int.toNat_of_nonneg hj0 have hu0 : 0 ≤ Λ - ⌊Λ⌋ := by linarith [Int.floor_le Λ] have hu1 : Λ - ⌊Λ⌋ < 1 := by linarith [Int.lt_floor_add_one Λ] have hjN : ⌊Λ⌋ < ((b + N : ℕ) : ℤ) := by rw [Int.floor_lt] push_cast linarith refine ⟨(⌊Λ⌋.toNat, rawWord θ (Λ - ⌊Λ⌋)), ?_, ?_⟩ · simp only [T, Finset.mem_filter, Finset.mem_product, Finset.mem_range] refine ⟨⟨by omega, rawWord_mem_cubo N θ _ hθ hN hu0 hu1⟩, ?_⟩ rw [hjz, ← cellWord_shift] exact hR · rw [memQ] simp only [hjr] exact ⟨⟨⟨hu0, hu1⟩, trivial⟩, h1⟩ · rintro ⟨x, hx, hΛ⟩ rw [memQ] at hΛ obtain ⟨⟨⟨hu0, hu1⟩, hw⟩, hb⟩ := hΛ simp only [T, Finset.mem_filter] at hx refine ⟨by have : (0 : ℝ) ≤ x.1 := Nat.cast_nonneg _; linarith, hb, ?_⟩ rw [cellWord_shift (b : ℤ) (x.1 : ℤ) Λ θ] have : ((x.1 : ℤ) : ℝ) = (x.1 : ℝ) := Int.cast_natCast _ rw [this, hw] exact hx.2 have hdisj : (T : Set (ℕ × Palabra)).PairwiseDisjoint Q := by intro x _ y _ hxy refine Set.disjoint_left.mpr (fun Λ hx hy => hxy ?_) rw [memQ] at hx hy obtain ⟨⟨⟨hx0, hx1⟩, hxw⟩, -⟩ := hx obtain ⟨⟨⟨hy0, hy1⟩, hyw⟩, -⟩ := hy have e1 : x.1 = y.1 := by have a : (x.1 : ℝ) < y.1 + 1 := by linarith have c : (y.1 : ℝ) < x.1 + 1 := by linarith have a' : x.1 < y.1 + 1 := by exact_mod_cast a have c' : y.1 < x.1 + 1 := by exact_mod_cast c omega have e2 : x.2 = y.2 := by rw [← hxw, ← hyw, e1] exact Prod.ext e1 e2 have hmeas : ∀ x ∈ T, MeasurableSet (Q x) := fun x _ => measurableSet_Ico.inter measurableSet_Iic unfold secLen rw [hS, measure_biUnion_finset hdisj hmeas, ENNReal.toReal_sum (fun x _ => by simp only [Q]; rw [vol_Ico_inter_Iic]; exact ENNReal.ofReal_ne_top), Finset.sum_filter] apply Finset.sum_congr rfl intro x _ split_ifs · simp only [Q] rw [vol_Ico_inter_Iic, ENNReal.toReal_ofReal (le_max_left _ _)] · rfl /-! ### Bounds and measurability of the section length -/ theorem secLen_nonneg (R : ℤ → Palabra → Prop) (b : ℕ) (θ : ℝ) : 0 ≤ secLen R b θ := ENNReal.toReal_nonneg theorem secLen_le (R : ℤ → Palabra → Prop) (b : ℕ) (θ : ℝ) (hθ : 0 ≤ θ) : secLen R b θ ≤ b + 2 * θ := by unfold secLen have hsub : {Λ : ℝ | 0 ≤ Λ ∧ Λ ≤ (b : ℝ) + 2 * θ ∧ R (b : ℤ) (cellWord (b : ℤ) Λ θ)} ⊆ Icc 0 ((b : ℝ) + 2 * θ) := fun Λ h => ⟨h.1, h.2.1⟩ calc (volume {Λ : ℝ | 0 ≤ Λ ∧ Λ ≤ (b : ℝ) + 2 * θ ∧ R (b : ℤ) (cellWord (b : ℤ) Λ θ)}).toReal ≤ (volume (Icc 0 ((b : ℝ) + 2 * θ))).toReal := ENNReal.toReal_mono (by rw [Real.volume_Icc]; exact ENNReal.ofReal_ne_top) (measure_mono hsub) _ = b + 2 * θ := by rw [Real.volume_Icc, ENNReal.toReal_ofReal (by linarith)]; ring theorem secLen_measurable (R : ℤ → Palabra → Prop) (b : ℕ) : Measurable (fun θ => secLen R b θ) := by let E : Set (ℝ × ℝ) := {p | 0 ≤ p.2 ∧ p.2 ≤ (b : ℝ) + 2 * p.1 ∧ R (b : ℤ) (cellWord (b : ℤ) p.2 p.1)} have hc : ∀ c : ℤ, Measurable (fun p : ℝ × ℝ => clip (b : ℤ) ⌊p.2 + (c : ℝ) * p.1⌋) := fun c => (measurable_of_countable (clip (b : ℤ))).comp (Int.measurable_floor.comp (by fun_prop)) have hcw : Measurable (fun p : ℝ × ℝ => cellWord (b : ℤ) p.2 p.1) := (hc _).prodMk ((hc _).prodMk ((hc _).prodMk ((hc _).prodMk (hc _)))) have h1 : MeasurableSet {p : ℝ × ℝ | 0 ≤ p.2} := measurableSet_le measurable_const measurable_snd have h2 : MeasurableSet {p : ℝ × ℝ | p.2 ≤ (b : ℝ) + 2 * p.1} := measurableSet_le measurable_snd (by fun_prop) have h3 : MeasurableSet {p : ℝ × ℝ | R (b : ℤ) (cellWord (b : ℤ) p.2 p.1)} := hcw (Set.to_countable {w : Palabra | R (b : ℤ) w}).measurableSet have hE : MeasurableSet E := h1.inter (h2.inter h3) exact (measurable_measure_prodMk_left hE).ennreal_toReal theorem fracAmb_intervalIntegrable (Amb : ℤ → Palabra → Prop) (b : ℕ) (a c : ℝ) (ha : 0 < a) (hac : a ≤ c) : IntervalIntegrable (fracAmb Amb b) volume a c := by rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hac] refine Measure.integrableOn_of_bounded (M := 1) (by rw [Real.volume_Ioc]; exact ENNReal.ofReal_ne_top) ((secLen_measurable Amb b).div (by fun_prop)).aestronglyMeasurable ?_ rw [ae_restrict_iff' measurableSet_Ioc] refine Filter.Eventually.of_forall (fun θ hθ => ?_) have hθ0 : 0 < θ := lt_trans ha hθ.1 have h0 := secLen_nonneg Amb b θ have h1 := secLen_le Amb b θ hθ0.le have hd : (0 : ℝ) < b + 2 * θ := by positivity rw [Real.norm_eq_abs, fracAmb, abs_div, abs_of_nonneg h0, abs_of_pos hd, div_le_one hd] exact h1 theorem integral_F2_01 : ∫ θ in (0 : ℝ)..1, F2 θ = 5 / 18 := by have ii : ∀ a b : ℝ, IntervalIntegrable F2 volume a b := fun a b => F2_continuous.intervalIntegrable a b rw [← intervalIntegral.integral_add_adjacent_intervals (ii 0 (1 / 4)) (ii (1 / 4) 1), ← intervalIntegral.integral_add_adjacent_intervals (ii (1 / 4) (1 / 3)) (ii (1 / 3) 1), ← intervalIntegral.integral_add_adjacent_intervals (ii (1 / 3) (1 / 2)) (ii (1 / 2) 1), ← intervalIntegral.integral_add_adjacent_intervals (ii (1 / 2) (2 / 3)) (ii (2 / 3) 1), ← intervalIntegral.integral_add_adjacent_intervals (ii (2 / 3) (3 / 4)) (ii (3 / 4) 1), integral_tramo F2 0 (1 / 4) _ _ (by norm_num) (fun x h0 h1 => F2_tramo1 x h0 h1), integral_tramo F2 (1 / 4) (1 / 3) _ _ (by norm_num) (fun x h0 h1 => F2_tramo2 x h0 h1), integral_tramo F2 (1 / 3) (1 / 2) _ _ (by norm_num) (fun x h0 h1 => F2_tramo3 x h0 h1), integral_tramo F2 (1 / 2) (2 / 3) _ _ (by norm_num) (fun x h0 h1 => F2_tramo4 x h0 h1), integral_tramo F2 (2 / 3) (3 / 4) _ _ (by norm_num) (fun x h0 h1 => F2_tramo5 x h0 h1), integral_tramo F2 (3 / 4) 1 _ _ (by norm_num) (fun x h0 h1 => F2_tramo6 x h0 h1)] norm_num /-! ### Lemma `lem:length`: units in the middle of the section -/ theorem phaseUpper_le_one (k : Palabra) (θ : ℝ) : phaseUpper k θ ≤ 1 := by obtain ⟨a, b, c, d, e⟩ := k show min 1 _ ≤ 1 exact min_le_left _ _ theorem phaseLower_nonneg (k : Palabra) (θ : ℝ) : 0 ≤ phaseLower k θ := by obtain ⟨a, b, c, d, e⟩ := k show 0 ≤ max 0 _ exact le_max_left _ _ theorem pw_nonneg (k : Palabra) (θ : ℝ) : 0 ≤ phaseWidth k θ := le_max_left _ _ theorem pw_le_one (k : Palabra) (θ : ℝ) : phaseWidth k θ ≤ 1 := by unfold phaseWidth exact max_le (by norm_num) (by linarith [phaseUpper_le_one k θ, phaseLower_nonneg k θ]) /-- The phase fibres are disjoint subsets of `[0, 1)`, so their widths add up to at most one. -/theorem sum_pw_le_one (θ : ℝ) (s : Finset Palabra) : ∑ k ∈ s, phaseWidth k θ ≤ 1 := by have hd : (s : Set Palabra).PairwiseDisjoint (phaseFiber θ) := by intro k _ k' _ hkk' refine Set.disjoint_left.mpr (fun u hu hu' => hkk' ?_) exact hu.2.symm.trans hu'.2 have hm : ∀ k ∈ s, MeasurableSet (phaseFiber θ k) := fun k _ => by rw [phaseFiber_eq_Ico]; exact measurableSet_Ico have hfin : ∀ k ∈ s, volume (phaseFiber θ k) ≠ ⊤ := fun k _ => by rw [phaseFiber_eq_Ico, Real.volume_Ico]; exact ENNReal.ofReal_ne_top have hsub : (⋃ k ∈ s, phaseFiber θ k) ⊆ Ico 0 1 := by intro u hu simp only [Set.mem_iUnion] at hu obtain ⟨k, _, hk⟩ := hu exact hk.1 calc ∑ k ∈ s, phaseWidth k θ = ∑ k ∈ s, volume.real (phaseFiber θ k) := by simp only [volume_phase_fiber] _ = volume.real (⋃ k ∈ s, phaseFiber θ k) := (measureReal_biUnion_finset hd hm hfin).symm _ ≤ volume.real (Ico (0 : ℝ) 1) := measureReal_mono hsub (by rw [Real.volume_Ico]; exact ENNReal.ofReal_ne_top) _ = 1 := by rw [Real.volume_real_Ico]; norm_num /-- A pattern of positive width is a real floor pattern: monotone, with middle coordinate `0`. -/theorem realizado (k : Palabra) (θ : ℝ) (hθ : 0 < θ) (hk : 0 < phaseWidth k θ) : k.2.2.1 = 0 ∧ k.1 ≤ k.2.1 ∧ k.2.1 ≤ k.2.2.1 ∧ k.2.2.1 ≤ k.2.2.2.1 ∧ k.2.2.2.1 ≤ k.2.2.2.2 := by have hlt : 0 < phaseUpper k θ - phaseLower k θ := by by_contra h rw [not_lt] at h unfold phaseWidth at hk rw [max_eq_left h] at hk exact lt_irrefl _ hk have hmem : phaseLower k θ ∈ phaseFiber θ k := by rw [phaseFiber_eq_Ico]; exact ⟨le_rfl, by linarith⟩ obtain ⟨⟨hu0, hu1⟩, hw⟩ := hmem obtain ⟨a, b, c, d, e⟩ := k simp only [rawWord, Prod.mk.injEq] at hw obtain ⟨ha, hb, hc, hd, he⟩ := hw refine ⟨hc.symm.trans (Int.floor_eq_zero_iff.mpr ⟨hu0, hu1⟩), ?_, ?_, ?_, ?_⟩ · exact (ha.symm.le.trans (Int.floor_le_floor (by linarith))).trans hb.le · exact (hb.symm.le.trans (Int.floor_le_floor (by linarith))).trans hc.le · exact (hc.symm.le.trans (Int.floor_le_floor (by linarith))).trans hd.le · exact (hd.symm.le.trans (Int.floor_le_floor (by linarith))).trans he.le theorem Ufase_1_pw (θ : ℝ) : Ufase 1 θ = phaseWidth (-1, -1, 0, 0, 0) θ + phaseWidth (-1, 0, 0, 0, 1) θ + phaseWidth (0, 0, 0, 1, 1) θ := by have e0 : patronFase 1 ((0 : ℕ) : ℤ) = (-1, -1, 0, 0, 0) := by decide have e1 : patronFase 1 ((1 : ℕ) : ℤ) = (-1, 0, 0, 0, 1) := by decide have e2 : patronFase 1 ((2 : ℕ) : ℤ) = (0, 0, 0, 1, 1) := by decide simp only [Ufase, Finset.sum_range_succ, Finset.sum_range_zero, zero_add, e0, e1, e2] theorem Ufase_2_pw (θ : ℝ) : Ufase 2 θ = phaseWidth (-2, -1, 0, 0, 1) θ + phaseWidth (-1, -1, 0, 1, 1) θ + phaseWidth (-1, 0, 0, 1, 2) θ := by have e0 : patronFase 2 ((0 : ℕ) : ℤ) = (-2, -1, 0, 0, 1) := by decide have e1 : patronFase 2 ((1 : ℕ) : ℤ) = (-1, -1, 0, 1, 1) := by decide have e2 : patronFase 2 ((2 : ℕ) : ℤ) = (-1, 0, 0, 1, 2) := by decide simp only [Ufase, Finset.sum_range_succ, Finset.sum_range_zero, zero_add, e0, e1, e2] /-- The index set of the `G` side of the last family and of the isolated pairs of Part I:`s ∈ {b, b+1} ∪ [2b+1, 3b-1]`. -/def IG (b s : ℤ) : Prop := s = b ∨ s = b + 1 ∨ (2 * b + 1 ≤ s ∧ s ≤ 3 * b - 1) open Classical in/-- The contribution of the unit `[j, j+1)` of the section. -/noncomputable def Gunit (R : ℤ → Palabra → Prop) (b N j : ℕ) (θ : ℝ) : ℝ := ∑ k ∈ cuboK N, if R (b : ℤ) (clipW (b : ℤ) (j : ℤ) k) then max 0 (min ((j : ℝ) + phaseUpper k θ) ((b : ℝ) + 2 * θ) - ((j : ℝ) + phaseLower k θ)) else 0 theorem secLen_Gunit (R : ℤ → Palabra → Prop) (b N : ℕ) (θ : ℝ) (hθ : 0 < θ) (hN : 2 * θ < N) : secLen R b θ = ∑ j ∈ Finset.range (b + N), Gunit R b N j θ := by rw [secLen_descomp R b N θ hθ hN, Finset.sum_product] rfl theorem Gunit_bounds (R : ℤ → Palabra → Prop) (b N j : ℕ) (θ : ℝ) : 0 ≤ Gunit R b N j θ ∧ Gunit R b N j θ ≤ 1 := by unfold Gunit constructor · apply Finset.sum_nonneg intro k _ split_ifs · exact le_max_left _ _ · exact le_rfl · refine le_trans (Finset.sum_le_sum (fun k _ => ?_)) (sum_pw_le_one θ (cuboK N)) split_ifs · unfold phaseWidth apply max_le_max le_rfl linarith [min_le_left ((j : ℝ) + phaseUpper k θ) ((b : ℝ) + 2 * θ)] · exact pw_nonneg k θ open Classical in/-- A unit in the middle of the section (no clipping, `b ≥ 6`) contributes `U₁` plus the `G` phases whoseindex `3j + r` lies in `IG`. Uses `car_medio` (the list of Part I on unclipped words) and `hcl` at `b`. -/theorem unidad_central (Amb : ℤ → Palabra → Prop) (b N j : ℕ) (θ : ℝ) (hθ : 0 < θ) (hN2 : 2 ≤ N) (hb6 : 6 ≤ b) (hj : 1 ≤ j) (hjb : j + N < b) (hcl : ∀ w, Amb (b : ℤ) w ↔ enLista (b : ℤ) w) : Gunit Amb b N j θ = Ufase 1 θ + ((if IG b (3 * (j : ℤ) + 0) then phaseWidth (-2, -1, 0, 0, 1) θ else 0) + (if IG b (3 * (j : ℤ) + 1) then phaseWidth (-1, -1, 0, 1, 1) θ else 0) + (if IG b (3 * (j : ℤ) + 2) then phaseWidth (-1, 0, 0, 1, 2) θ else 0)) := by have hjr : (j : ℝ) + 1 ≤ b := by have : j + 1 ≤ b := by omega exact_mod_cast this have step1 : ∀ k ∈ cuboK N, (if Amb (b : ℤ) (clipW (b : ℤ) (j : ℤ) k) then max 0 (min ((j : ℝ) + phaseUpper k θ) ((b : ℝ) + 2 * θ) - ((j : ℝ) + phaseLower k θ)) else 0) = if enLista (b : ℤ) ((j : ℤ) + k.1, (j : ℤ) + k.2.1, (j : ℤ) + k.2.2.1, (j : ℤ) + k.2.2.2.1, (j : ℤ) + k.2.2.2.2) then phaseWidth k θ else 0 := by intro k hk have hcw : clipW (b : ℤ) (j : ℤ) k = ((j : ℤ) + k.1, (j : ℤ) + k.2.1, (j : ℤ) + k.2.2.1, (j : ℤ) + k.2.2.2.1, (j : ℤ) + k.2.2.2.2) := by simp only [cuboK, Finset.mem_product, Finset.mem_Icc] at hk simp only [clipW, clip, Prod.mk.injEq] omega have ht : max 0 (min ((j : ℝ) + phaseUpper k θ) ((b : ℝ) + 2 * θ) - ((j : ℝ) + phaseLower k θ)) = phaseWidth k θ := by have hu := phaseUpper_le_one k θ rw [min_eq_left (by linarith)] unfold phaseWidth congr 1 ring rw [hcw, ht] simp only [hcl] unfold Gunit rw [Finset.sum_congr rfl step1] have hS6 : ({(-1, -1, 0, 0, 0), (-1, 0, 0, 0, 1), (0, 0, 0, 1, 1), (-2, -1, 0, 0, 1), (-1, -1, 0, 1, 1), (-1, 0, 0, 1, 2)} : Finset Palabra) ⊆ cuboK N := by intro k hk simp only [Finset.mem_insert, Finset.mem_singleton] at hk simp only [cuboK, Finset.mem_product, Finset.mem_Icc] rcases hk with rfl | rfl | rfl | rfl | rfl | rfl <;> dsimp only <;> omega rw [← Finset.sum_subset hS6 ?_] · rw [Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_singleton] dsimp only have c10 : enLista (b : ℤ) ((j : ℤ) + -1, (j : ℤ) + -1, (j : ℤ) + 0, (j : ℤ) + 0, (j : ℤ) + 0) := (CaballeroListStability.car_medio (b : ℤ) _ _ _ _ _ (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega)).mpr (Or.inl ⟨3 * (j : ℤ), by omega, by omega, by omega, by omega, by omega, by omega, by omega⟩) have c11 : enLista (b : ℤ) ((j : ℤ) + -1, (j : ℤ) + 0, (j : ℤ) + 0, (j : ℤ) + 0, (j : ℤ) + 1) := (CaballeroListStability.car_medio (b : ℤ) _ _ _ _ _ (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega)).mpr (Or.inl ⟨3 * (j : ℤ) + 1, by omega, by omega, by omega, by omega, by omega, by omega, by omega⟩) have c12 : enLista (b : ℤ) ((j : ℤ) + 0, (j : ℤ) + 0, (j : ℤ) + 0, (j : ℤ) + 1, (j : ℤ) + 1) := (CaballeroListStability.car_medio (b : ℤ) _ _ _ _ _ (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega)).mpr (Or.inl ⟨3 * (j : ℤ) + 2, by omega, by omega, by omega, by omega, by omega, by omega, by omega⟩) have c20 : enLista (b : ℤ) ((j : ℤ) + -2, (j : ℤ) + -1, (j : ℤ) + 0, (j : ℤ) + 0, (j : ℤ) + 1) ↔ IG b (3 * (j : ℤ) + 0) := by rw [CaballeroListStability.car_medio (b : ℤ) ((j : ℤ) + -2) ((j : ℤ) + -1) ((j : ℤ) + 0) ((j : ℤ) + 0) ((j : ℤ) + 1) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega)] unfold IG constructor · rintro (⟨s, h1, h2, e0, e1, e2, e3, e4⟩ | ⟨s, hs, e0, e1, e2, e3, e4⟩) <;> omega · intro h exact Or.inr ⟨3 * (j : ℤ) + 0, h, by omega, by omega, by omega, by omega, by omega⟩ have c21 : enLista (b : ℤ) ((j : ℤ) + -1, (j : ℤ) + -1, (j : ℤ) + 0, (j : ℤ) + 1, (j : ℤ) + 1) ↔ IG b (3 * (j : ℤ) + 1) := by rw [CaballeroListStability.car_medio (b : ℤ) ((j : ℤ) + -1) ((j : ℤ) + -1) ((j : ℤ) + 0) ((j : ℤ) + 1) ((j : ℤ) + 1) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega)] unfold IG constructor · rintro (⟨s, h1, h2, e0, e1, e2, e3, e4⟩ | ⟨s, hs, e0, e1, e2, e3, e4⟩) <;> omega · intro h exact Or.inr ⟨3 * (j : ℤ) + 1, h, by omega, by omega, by omega, by omega, by omega⟩ have c22 : enLista (b : ℤ) ((j : ℤ) + -1, (j : ℤ) + 0, (j : ℤ) + 0, (j : ℤ) + 1, (j : ℤ) + 2) ↔ IG b (3 * (j : ℤ) + 2) := by rw [CaballeroListStability.car_medio (b : ℤ) ((j : ℤ) + -1) ((j : ℤ) + 0) ((j : ℤ) + 0) ((j : ℤ) + 1) ((j : ℤ) + 2) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega)] unfold IG constructor · rintro (⟨s, h1, h2, e0, e1, e2, e3, e4⟩ | ⟨s, hs, e0, e1, e2, e3, e4⟩) <;> omega · intro h exact Or.inr ⟨3 * (j : ℤ) + 2, h, by omega, by omega, by omega, by omega, by omega⟩ rw [Ufase_1_pw] by_cases g0 : IG b (3 * (j : ℤ) + 0) <;> by_cases g1 : IG b (3 * (j : ℤ) + 1) <;> by_cases g2 : IG b (3 * (j : ℤ) + 2) <;> simp only [c10, c11, c12, c20, c21, c22, g0, g1, g2, ↓reduceIte] <;> ring · intro k hk hkS obtain ⟨k0, k1, k2, k3, k4⟩ := k by_cases hp : phaseWidth (k0, k1, k2, k3, k4) θ = 0 · simp [hp] have hpos : 0 < phaseWidth (k0, k1, k2, k3, k4) θ := lt_of_le_of_ne (pw_nonneg _ θ) (Ne.symm hp) rw [ite_eq_right_iff] intro hL exfalso apply hkS obtain ⟨e2, m1, m2, m3, m4⟩ := realizado _ θ hθ hpos dsimp only at e2 m1 m2 m3 m4 hL simp only [cuboK, Finset.mem_product, Finset.mem_Icc] at hk subst e2 have hc := CaballeroListStability.car_medio (b : ℤ) ((j : ℤ) + k0) ((j : ℤ) + k1) ((j : ℤ) + 0) ((j : ℤ) + k3) ((j : ℤ) + k4) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) (by omega) rw [hc] at hL clear hc hkS hp hpos rcases hL with ⟨s, h1, h2, f0, f1, f2, f3, f4⟩ | ⟨s, hs, f0, f1, f2, f3, f4⟩ · have hr : s = 3 * (j : ℤ) ∨ s = 3 * (j : ℤ) + 1 ∨ s = 3 * (j : ℤ) + 2 := by omega rcases hr with rfl | rfl | rfl · obtain rfl : k0 = -1 := by omega obtain rfl : k1 = -1 := by omega obtain rfl : k3 = 0 := by omega obtain rfl : k4 = 0 := by omega decide · obtain rfl : k0 = -1 := by omega obtain rfl : k1 = 0 := by omega obtain rfl : k3 = 0 := by omega obtain rfl : k4 = 1 := by omega decide · obtain rfl : k0 = 0 := by omega obtain rfl : k1 = 0 := by omega obtain rfl : k3 = 1 := by omega obtain rfl : k4 = 1 := by omega decide · have hr : s = 3 * (j : ℤ) ∨ s = 3 * (j : ℤ) + 1 ∨ s = 3 * (j : ℤ) + 2 := by omega rcases hr with rfl | rfl | rfl · obtain rfl : k0 = -2 := by omega obtain rfl : k1 = -1 := by omega obtain rfl : k3 = 0 := by omega obtain rfl : k4 = 1 := by omega decide · obtain rfl : k0 = -1 := by omega obtain rfl : k1 = -1 := by omega obtain rfl : k3 = 1 := by omega obtain rfl : k4 = 1 := by omega decide · obtain rfl : k0 = -1 := by omega obtain rfl : k1 = 0 := by omega obtain rfl : k3 = 1 := by omega obtain rfl : k4 = 2 := by omega decide open Classical intheorem card_IG (b N : ℕ) (r : ℤ) (hr0 : 0 ≤ r) (hr2 : r ≤ 2) (hb : 3 * N + 10 ≤ b) : 3 *((Finset.Icc 1 (b - N - 1)).filter (fun j : ℕ => IG (b : ℤ) (3 * (j : ℤ) + r))).card ≤ b + 12 ∧ b ≤ 3 * ((Finset.Icc 1 (b - N - 1)).filter (fun j : ℕ => IG (b : ℤ) (3 * (j : ℤ) + r))).card + 3 * N + 3 := by classical obtain ⟨m, rfl⟩ : ∃ m, b = m + N + 1 := ⟨b - N - 1, by omega⟩ have em : m + N + 1 - N - 1 = m := by omega rw [em] constructor · have hsub : (Finset.Icc 1 m).filter (fun j : ℕ => IG ((m + N + 1 : ℕ) : ℤ) (3 * (j : ℤ) + r)) ⊆ Finset.Icc ((2 * (m + N + 1) - 1) / 3) m ∪ Finset.Icc ((m + N + 1) / 3 - 1) ((m + N + 1) / 3 + 1) := by intro j hj rw [Finset.mem_filter, Finset.mem_Icc] at hj obtain ⟨⟨hj1, hj2⟩, hIG⟩ := hj unfold IG at hIG push_cast at hIG rw [Finset.mem_union, Finset.mem_Icc, Finset.mem_Icc] omega have := (Finset.card_le_card hsub).trans (Finset.card_union_le _ _) rw [Nat.card_Icc, Nat.card_Icc] at this omega · have hsub : Finset.Icc ((2 * (m + N + 1) + 3) / 3) m ⊆ (Finset.Icc 1 m).filter (fun j : ℕ => IG ((m + N + 1 : ℕ) : ℤ) (3 * (j : ℤ) + r)) := by intro j hj rw [Finset.mem_Icc] at hj rw [Finset.mem_filter, Finset.mem_Icc] unfold IG push_cast omega have := Finset.card_le_card hsub rw [Nat.card_Icc] at this omega open Classical intheorem sum_ite_card {ι : Type*} (s : Finset ι) (P : ι → Prop) (a : ℝ) : ∑ j ∈ s, (if P j then a else 0) = (s.filter P).card * a := by rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul] /-! ## (2) Theorem `thm:exact` -/ /-- (2a.i) Between consecutive points of `F₄` the section length is affine in `θ`, for ANY predicate onwords and every `b` (paper l.475-482). No classification is needed. -/theorem secLen_afin_camara (R : ℤ → Palabra → Prop) (b : ℕ) (i : Fin 6) : ∃ α β : ℝ, ∀ θ ∈ Ioo (farey4 i.castSucc) (farey4 i.succ), secLen R b θ = α + β * θ := by classical have hA : AfinC i (fun θ => ∑ x ∈ Finset.range (b + 2) ×ˢ cuboK 2, if R (b : ℤ) (clipW (b : ℤ) (x.1 : ℤ) x.2) then max 0 (min ((x.1 : ℝ) + phaseUpper x.2 θ) ((b : ℝ) + 2 * θ) - ((x.1 : ℝ) + phaseLower x.2 θ)) else 0) := by apply afinC_sum intro x _ by_cases hR : R (b : ℤ) (clipW (b : ℤ) (x.1 : ℤ) x.2) · simp only [hR, ↓reduceIte] exact afinC_pos_sub i (basico_min i (basico_up i x.1 x.2) (basico_lin i b 2 (by norm_num) (by norm_num) (fun θ => (b : ℝ) + 2 * θ) (fun θ => by push_cast; ring))) (basico_lo i x.1 x.2) · simp only [hR, ↓reduceIte] exact ⟨0, 0, fun θ _ => by ring⟩ obtain ⟨α, β, h⟩ := hA refine ⟨α, β, fun θ hθ => ?_⟩ obtain ⟨h0, h1⟩ := camara_bounds i θ hθ exact (secLen_descomp R b 2 θ h0 (by push_cast; linarith)).trans (h θ hθ) /-- (2a.ii) The right-hand side `b F₂ + κ + ε_{b mod 3} δ / 3` is affine on each closed chamber of `F₄`(paper l.482: «so are F₂, κ, δ»). -/theorem perfil_afin_camara (b : ℕ) (i : Fin 6) : ∃ α β : ℝ, ∀ θ ∈ Icc (farey4 i.castSucc) (farey4 i.succ), (b : ℝ) * F2 θ + kappa θ + epsilon (b % 3) / 3 * delta θ = α + β * θ := by have key : ∀ (lo hi aF bF aK bK aD bD : ℝ), (∀ θ, lo ≤ θ → θ ≤ hi → F2 θ = aF + bF * θ) → (∀ θ, lo ≤ θ → θ ≤ hi → kappa θ = aK + bK * θ) → (∀ θ, lo ≤ θ → θ ≤ hi → delta θ = aD + bD * θ) → ∃ α β : ℝ, ∀ θ ∈ Icc lo hi, (b : ℝ) * F2 θ + kappa θ + epsilon (b % 3) / 3 * delta θ = α + β * θ := by intro lo hi aF bF aK bK aD bD hF hK hD refine ⟨b * aF + aK + epsilon (b % 3) / 3 * aD, b * bF + bK + epsilon (b % 3) / 3 * bD, ?_⟩ rintro θ ⟨h0, h1⟩ rw [hF θ h0 h1, hK θ h0 h1, hD θ h0 h1] ring fin_cases i · exact key 0 (1 / 4) 0 2 0 1 0 0 (fun θ h0 h1 => by unfold F2; split_ifs <;> linarith) (fun θ h0 h1 => by unfold kappa; split_ifs <;> linarith) (fun θ h0 h1 => by unfold delta; split_ifs <;> linarith) · exact key (1 / 4) (1 / 3) (-1) 6 0 1 0 0 (fun θ h0 h1 => by unfold F2; split_ifs <;> linarith) (fun θ h0 h1 => by unfold kappa; split_ifs <;> linarith) (fun θ h0 h1 => by unfold delta; split_ifs <;> linarith) · exact key (1 / 3) (1 / 2) 3 (-6) (-1) 4 0 0 (fun θ h0 h1 => by unfold F2; split_ifs <;> linarith) (fun θ h0 h1 => by unfold kappa; split_ifs <;> linarith) (fun θ h0 h1 => by unfold delta; split_ifs <;> linarith) · exact key (1 / 2) (2 / 3) (-1) 2 1 0 0 0 (fun θ h0 h1 => by unfold F2; split_ifs <;> linarith) (fun θ h0 h1 => by unfold kappa; split_ifs <;> linarith) (fun θ h0 h1 => by unfold delta; split_ifs <;> linarith) · exact key (2 / 3) (3 / 4) (5 / 3) (-2) 1 0 (-2) 3 (fun θ h0 h1 => by unfold F2; split_ifs <;> linarith) (fun θ h0 h1 => by unfold kappa; split_ifs <;> linarith) (fun θ h0 h1 => by unfold delta; split_ifs <;> linarith) · exact key (3 / 4) 1 (2 / 3) (-2 / 3) 4 (-4) 1 (-1) (fun θ h0 h1 => by unfold F2; split_ifs <;> linarith) (fun θ h0 h1 => by unfold kappa; split_ifs <;> linarith) (fun θ h0 h1 => by unfold delta; split_ifs <;> linarith) /-- (2a.iii) Two affine functions on an open interval that agree at two distinct interior points agree onthe whole interval (paper l.483-484: «Two interior rational values per interval … suffice»). -/theorem afin_por_dos_puntos (f g : ℝ → ℝ) (a c x y : ℝ) (hf : ∃ α β : ℝ, ∀ θ ∈ Ioo a c, f θ = α + β * θ) (hg : ∃ α β : ℝ, ∀ θ ∈ Ioo a c, g θ = α + β * θ) (hx : x ∈ Ioo a c) (hy : y ∈ Ioo a c) (hxy : x ≠ y) (hfx : f x = g x) (hfy : f y = g y) : ∀ θ ∈ Ioo a c, f θ = g θ := by obtain ⟨α, β, ef⟩ := hf obtain ⟨α', β', eg⟩ := hg have ex : α + β * x = α' + β' * x := by rw [← ef x hx, ← eg x hx]; exact hfx have ey : α + β * y = α' + β' * y := by rw [← ef y hy, ← eg y hy]; exact hfy have hm : (x - y) * (β - β') = 0 := by linear_combination ex - ey have hββ : β = β' := by rcases mul_eq_zero.mp hm with h | h · exact absurd (sub_eq_zero.mp h) hxy · linarith have hαα : α = α' := by subst hββ; linarith intro θ hθ rw [ef θ hθ, eg θ hθ, hαα, hββ] /-- (2a.iv) The three base sections hold for EVERY slope `0 < θ ≤ 1`, not only at the 18 points of`thetaPts` (`base_54` + (2a.i)-(2a.iii)). Same hypothesis `hcl` as `base_54`. -/theorem base_continua (Amb : ℤ → Palabra → Prop) (hcl : ∀ b : ℤ, (b = 30 ∨ b = 31 ∨ b = 32) → ∀ w, Amb b w ↔ enLista b w) : ∀ b : ℕ, (b = 30 ∨ b = 31 ∨ b = 32) → ∀ θ : ℝ, 0 < θ → θ ≤ 1 → secLen Amb b θ = (b : ℝ) * F2 θ + kappa θ + epsilon (b % 3) / 3 * delta θ := by intro b hb θ h0 h1 have B := base_54 Amb hcl b hb have cam : ∀ (i : Fin 6) (x y : ℝ), x ∈ thetaPts → y ∈ thetaPts → x ≠ y → x ∈ Ioo (farey4 i.castSucc) (farey4 i.succ) → y ∈ Ioo (farey4 i.castSucc) (farey4 i.succ) → θ ∈ Ioo (farey4 i.castSucc) (farey4 i.succ) → secLen Amb b θ = (b : ℝ) * F2 θ + kappa θ + epsilon (b % 3) / 3 * delta θ := by intro i x y hx hy hxy hxi hyi hθi obtain ⟨αR, βR, eR⟩ := perfil_afin_camara b i exact afin_por_dos_puntos (fun t => secLen Amb b t) (fun t => (b : ℝ) * F2 t + kappa t + epsilon (b % 3) / 3 * delta t) _ _ x y (secLen_afin_camara Amb b i) ⟨αR, βR, fun t ht => eR t (Ioo_subset_Icc_self ht)⟩ hxi hyi hxy (B x hx) (B y hy) θ hθi have mem : ∀ (i : Fin 6) (a c t : ℝ), farey4 i.castSucc = a → farey4 i.succ = c → a < t → t < c → t ∈ Ioo (farey4 i.castSucc) (farey4 i.succ) := fun i a c t ha hc h1 h2 => by rw [ha, hc]; exact ⟨h1, h2⟩ have pts : ∀ t : ℝ, t ∈ thetaPts → secLen Amb b t = (b : ℝ) * F2 t + kappa t + epsilon (b % 3) / 3 * delta t := B rcases lt_trichotomy θ (1 / 4) with g | g | g · exact cam 0 (1 / 12) (1 / 6) (by simp [thetaPts]) (by simp [thetaPts]) (by norm_num) (mem 0 0 (1 / 4) _ rfl rfl (by norm_num) (by norm_num)) (mem 0 0 (1 / 4) _ rfl rfl (by norm_num) (by norm_num)) (mem 0 0 (1 / 4) _ rfl rfl h0 g) · rw [g]; exact pts _ (by simp [thetaPts]) rcases lt_trichotomy θ (1 / 3) with g' | g' | g' · exact cam 1 (5 / 18) (11 / 36) (by simp [thetaPts]) (by simp [thetaPts]) (by norm_num) (mem 1 (1 / 4) (1 / 3) _ rfl rfl (by norm_num) (by norm_num)) (mem 1 (1 / 4) (1 / 3) _ rfl rfl (by norm_num) (by norm_num)) (mem 1 (1 / 4) (1 / 3) _ rfl rfl g g') · rw [g']; exact pts _ (by simp [thetaPts]) rcases lt_trichotomy θ (1 / 2) with g2 | g2 | g2 · exact cam 2 (7 / 18) (4 / 9) (by simp [thetaPts]) (by simp [thetaPts]) (by norm_num) (mem 2 (1 / 3) (1 / 2) _ rfl rfl (by norm_num) (by norm_num)) (mem 2 (1 / 3) (1 / 2) _ rfl rfl (by norm_num) (by norm_num)) (mem 2 (1 / 3) (1 / 2) _ rfl rfl g' g2) · rw [g2]; exact pts _ (by simp [thetaPts]) rcases lt_trichotomy θ (2 / 3) with g3 | g3 | g3 · exact cam 3 (5 / 9) (11 / 18) (by simp [thetaPts]) (by simp [thetaPts]) (by norm_num) (mem 3 (1 / 2) (2 / 3) _ rfl rfl (by norm_num) (by norm_num)) (mem 3 (1 / 2) (2 / 3) _ rfl rfl (by norm_num) (by norm_num)) (mem 3 (1 / 2) (2 / 3) _ rfl rfl g2 g3) · rw [g3]; exact pts _ (by simp [thetaPts]) rcases lt_trichotomy θ (3 / 4) with g4 | g4 | g4 · exact cam 4 (25 / 36) (13 / 18) (by simp [thetaPts]) (by simp [thetaPts]) (by norm_num) (mem 4 (2 / 3) (3 / 4) _ rfl rfl (by norm_num) (by norm_num)) (mem 4 (2 / 3) (3 / 4) _ rfl rfl (by norm_num) (by norm_num)) (mem 4 (2 / 3) (3 / 4) _ rfl rfl g3 g4) · rw [g4]; exact pts _ (by simp [thetaPts]) rcases lt_or_eq_of_le h1 with g5 | g5 · exact cam 5 (5 / 6) (11 / 12) (by simp [thetaPts]) (by simp [thetaPts]) (by norm_num) (mem 5 (3 / 4) 1 _ rfl rfl (by norm_num) (by norm_num)) (mem 5 (3 / 4) 1 _ rfl rfl (by norm_num) (by norm_num)) (mem 5 (3 / 4) 1 _ rfl rfl g4 g5) · rw [g5]; exact pts _ (by simp [thetaPts]) /-- (2b) Theorem `thm:exact` (paper l.206-216): for `0 < θ ≤ 1` and integer `b ≥ 12θ + 18`,`L_b(θ) = b F₂(θ) + κ(θ) + ε_{b mod 3} δ(θ) / 3`, conditional on the classification of Part I (`hcl`)and on the three-step law (`hstep`, Prometeox). -/theorem exact_profile (Amb : ℤ → Palabra → Prop) (hcl : ∀ b : ℤ, 3 ≤ b → ∀ w, Amb b w ↔ enLista b w) (hstep : LeyTresPasos Amb) (θ : ℝ) (hθ0 : 0 < θ) (hθ1 : θ ≤ 1) (b : ℕ) (hb : (12 : ℝ) * θ + 18 ≤ (b : ℝ)) : secLen Amb b θ = (b : ℝ) * F2 θ + kappa θ + epsilon (b % 3) / 3 * delta θ := by have hN30 : ⌈(12 : ℝ) * θ + 18⌉₊ ≤ 30 := Nat.ceil_le.mpr (by push_cast; linarith) have hNb : ⌈(12 : ℝ) * θ + 18⌉₊ ≤ b := Nat.ceil_le.mpr hb have hN18 : 18 ≤ ⌈(12 : ℝ) * θ + 18⌉₊ := by have : (18 : ℝ) ≤ ⌈(12 : ℝ) * θ + 18⌉₊ := le_trans (by linarith) (Nat.le_ceil _) exact_mod_cast this refine profile_from_three_bases (fun k => secLen Amb k θ) ⌈(12 : ℝ) * θ + 18⌉₊ b (F2 θ) (kappa θ) (delta θ) hN30 ?_ ?_ hNb · intro k hk have hk' : (12 : ℝ) * θ + 18 ≤ k := le_trans (Nat.le_ceil _) (by exact_mod_cast hk) exact hstep k θ hθ0 hk' (hcl k (by omega)) (hcl ((k + 3 : ℕ) : ℤ) (by omega)) · intro r hr have hb' : 30 + r = 30 ∨ 30 + r = 31 ∨ 30 + r = 32 := by omega have e := base_continua Amb (fun c hc => hcl c (by omega)) (30 + r) hb' θ hθ0 hθ1 have hm : (30 + r) % 3 = r := by omega rw [hm] at e show secLen Amb (30 + r) θ - _ = _ rw [e] ring /-- (2c) Last sentence of `thm:exact` (paper l.214-215): on `0 < θ ≤ 1` the residue correction is nonzeroexactly when `2/3 < θ < 1` and `b ≢ 0 (mod 3)`. -/theorem residuo_ne_cero_iff (b : ℕ) (θ : ℝ) (hθ0 : 0 < θ) (hθ1 : θ ≤ 1) : epsilon (b % 3) / 3 * delta θ ≠ 0 ↔ (2 / 3 < θ ∧ θ < 1 ∧ b % 3 ≠ 0) := by have _hpos := hθ0 have hε :epsilon (b % 3) / 3 ≠ 0 ↔ b % 3 ≠ 0 := by have h3 : b % 3 = 0 ∨ b % 3 = 1 ∨ b % 3 = 2 := by omega rcases h3 with h | h | h <;> norm_num [h, epsilon] have hδ0 : 0 ≤ delta θ := by unfold delta split_ifs <;> linarith have hδ : delta θ ≠ 0 ↔ (2 / 3 < θ ∧ θ < 1) := by rw [← delta_pos_iff] exact ⟨fun h => lt_of_le_of_ne hδ0 (Ne.symm h), fun h => ne_of_gt h⟩ rw [mul_ne_zero_iff, hε, hδ] tauto /-! ## (3) Lemma `lem:length`, Corollary `thm:profile` and the integrals -/ /-- (3a) Profile identity used in the proof of `thm:profile` (paper l.535-541): `F₂ = U₁ + U₂/3` onpositive slopes. Unconditional. -/theorem F2_eq_fases (θ : ℝ) (hθ : 0 < θ) : F2 θ = Ufase 1 θ + Ufase 2 θ / 3 := by have h0 : (0 : ℝ) ≤ θ := hθ.le rcases le_total θ ((1 : ℝ) / 4) with h1 | g1 · obtain ⟨e1, e2⟩ := Ufase_tramo1 θ h0 h1 rw [F2_tramo1 θ h0 h1, e1, e2]; ring rcases le_total θ ((1 : ℝ) / 3) with h2 | g2 · obtain ⟨e1, e2⟩ := Ufase_tramo2 θ g1 h2 rw [F2_tramo2 θ g1 h2, e1, e2]; ring rcases le_total θ ((1 : ℝ) / 2) with h3 | g3 · obtain ⟨e1, e2⟩ := Ufase_tramo3 θ g2 h3 rw [F2_tramo3 θ g2 h3, e1, e2]; ring rcases le_total θ ((2 : ℝ) / 3) with h4 | g4 · obtain ⟨e1, e2⟩ := Ufase_tramo4 θ g3 h4 rw [F2_tramo4 θ g3 h4, e1, e2]; ring rcases le_total θ ((3 : ℝ) / 4) with h5 | g5 · obtain ⟨e1, e2⟩ := Ufase_tramo5 θ g4 h5 rw [F2_tramo5 θ g4 h5, e1, e2]; ring rcases le_total θ (1 : ℝ) with h6 | g6 · obtain ⟨e1, e2⟩ := Ufase_tramo6 θ g5 h6 rw [F2_tramo6 θ g5 h6, e1, e2]; ring obtain ⟨e1, e2⟩ := Ufase_tramo7 θ g6 rw [F2_tramo7 θ g6, e1, e2]; ring /-- (3b) Lemma `lem:length` (paper l.494-500): uniformly on a compact `J ⊂ (0,∞)`,`(b + 2θ) A_{2,b}(θ) = b U₁(θ) + (b/3) U₂(θ) + O_J(1)`. -/theorem longitud_uniforme (Amb : ℤ → Palabra → Prop) (hcl : ∀ b : ℤ, 3 ≤ b → ∀ w, Amb b w ↔ enLista b w) (J : Set ℝ) (hJ : IsCompact J) (hJ0 : J ⊆ Ioi 0) : ∃ C : ℝ, ∀ b : ℕ, ∀ θ ∈ J, |secLen Amb b θ - ((b : ℝ) * Ufase 1 θ + (b : ℝ) / 3 * Ufase 2 θ)| ≤ C := by classical obtain ⟨M, hM⟩ := hJ.bddAbove have hM0 : (0 : ℝ) ≤ max M 0 := le_max_right _ _ refine ⟨5 * ((3 * (⌈2 * max M 0⌉₊ + 2) + 10 : ℕ) : ℝ) + 2 * max M 0 + (2 * ((⌈2 * max M 0⌉₊ + 2 : ℕ) : ℝ) + 1) + 3 * (((⌈2 * max M 0⌉₊ + 2 : ℕ) : ℝ) + 1) + 3 * (((⌈2 * max M 0⌉₊ + 2 : ℕ) : ℝ) + 4), fun b θ hθJ => ?_⟩ set M' := max M 0 with hM' set N : ℕ := ⌈2 * M'⌉₊ + 2 with hN have hθ : 0 < θ := hJ0 hθJ have hθM : θ ≤ M' := le_trans (hM hθJ) (le_max_left _ _) have hN2 : 2 ≤ N := by omega have h2θN : 2 * θ < N := by have : 2 * M' ≤ ⌈2 * M'⌉₊ := Nat.le_ceil _ rw [hN] push_cast linarith have hN0 : (0 : ℝ) ≤ N := Nat.cast_nonneg _ have hU1 : 0 ≤ Ufase 1 θ ∧ Ufase 1 θ ≤ 3 := by rw [Ufase_1_pw] constructor · linarith [pw_nonneg (-1, -1, 0, 0, 0) θ, pw_nonneg (-1, 0, 0, 0, 1) θ, pw_nonneg (0, 0, 0, 1, 1) θ] · linarith [pw_le_one (-1, -1, 0, 0, 0) θ, pw_le_one (-1, 0, 0, 0, 1) θ, pw_le_one (0, 0, 0, 1, 1) θ] have p0 := pw_nonneg (-2, -1, 0, 0, 1) θ have p1 := pw_nonneg (-1, -1, 0, 1, 1) θ have p2 := pw_nonneg (-1, 0, 0, 1, 2) θ have q0 := pw_le_one (-2, -1, 0, 0, 1) θ have q1 := pw_le_one (-1, -1, 0, 1, 1) θ have q2 := pw_le_one (-1, 0, 0, 1, 2) θ have hU2 := Ufase_2_pw θ have hL0 := secLen_nonneg Amb b θ have hL1 := secLen_le Amb b θ hθ.le by_cases hbb : b < 3 * N + 10 · have hb' : (b : ℝ) ≤ ((3 * N + 10 : ℕ) : ℝ) := by exact_mod_cast hbb.le have hb0 : (0 : ℝ) ≤ b := Nat.cast_nonneg _ rw [hU2] push_cast at hb' ⊢ rw [abs_le] constructor <;> nlinarith [mul_le_mul_of_nonneg_left hU1.2 hb0, mul_nonneg hb0 hU1.1, mul_nonneg hb0 p0, mul_nonneg hb0 p1, mul_nonneg hb0 p2, mul_le_mul_of_nonneg_left q0 hb0, mul_le_mul_of_nonneg_left q1 hb0, mul_le_mul_of_nonneg_left q2 hb0] · rw [not_lt] at hbb have hb6 : 6 ≤ b := by omega have hcb : ∀ w, Amb (b : ℤ) w ↔ enLista (b : ℤ) w := hcl b (by omega) have hCen : Finset.Icc 1 (b - N - 1) ⊆ Finset.range (b + N) := by intro j hj simp only [Finset.mem_Icc, Finset.mem_range] at hj ⊢ omega rw [secLen_Gunit Amb b N θ hθ h2θN, ← Finset.sum_sdiff hCen] have hcen : ∑ j ∈ Finset.Icc 1 (b - N - 1), Gunit Amb b N j θ = ((Finset.Icc 1 (b - N - 1)).card : ℝ) * Ufase 1 θ + (((Finset.Icc 1 (b - N - 1)).filter (fun j : ℕ => IG (b : ℤ) (3 * (j : ℤ) + 0))).card * phaseWidth (-2, -1, 0, 0, 1) θ + ((Finset.Icc 1 (b - N - 1)).filter (fun j : ℕ => IG (b : ℤ) (3 * (j : ℤ) + 1))).card * phaseWidth (-1, -1, 0, 1, 1) θ + ((Finset.Icc 1 (b - N - 1)).filter (fun j : ℕ => IG (b : ℤ) (3 * (j : ℤ) + 2))).card * phaseWidth (-1, 0, 0, 1, 2) θ) := by rw [Finset.sum_congr rfl (fun j hj => by simp only [Finset.mem_Icc] at hj exact unidad_central Amb b N j θ hθ hN2 hb6 hj.1 (by omega) hcb)] rw [Finset.sum_add_distrib, Finset.sum_const, nsmul_eq_mul, Finset.sum_add_distrib, Finset.sum_add_distrib, sum_ite_card, sum_ite_card, sum_ite_card] have hcard : (((Finset.Icc 1 (b - N - 1)).card : ℕ) : ℝ) = b - N - 1 := by have : (Finset.Icc 1 (b - N - 1)).card + N + 1 = b := by rw [Nat.card_Icc]; omega have : (((Finset.Icc 1 (b - N - 1)).card : ℕ) : ℝ) + N + 1 = b := by exact_mod_cast this linarith have hrest : ∑ j ∈ Finset.range (b + N) \ Finset.Icc 1 (b - N - 1), Gunit Amb b N j θ ≤ 2 * N + 1 := by calc ∑ j ∈ Finset.range (b + N) \ Finset.Icc 1 (b - N - 1), Gunit Amb b N j θ ≤ ∑ j ∈ Finset.range (b + N) \ Finset.Icc 1 (b - N - 1), (1 : ℝ) := Finset.sum_le_sum (fun j _ => (Gunit_bounds Amb b N j θ).2) _ = 2 * N + 1 := by rw [Finset.sum_const, nsmul_eq_mul, mul_one, Finset.card_sdiff_of_subset hCen, Finset.card_range, Nat.card_Icc] have : b + N - (b - N - 1 + 1 - 1) = 2 * N + 1 := by omega rw [this] push_cast ring have hrest0 : 0 ≤ ∑ j ∈ Finset.range (b + N) \ Finset.Icc 1 (b - N - 1), Gunit Amb b N j θ := Finset.sum_nonneg (fun j _ => (Gunit_bounds Amb b N j θ).1) obtain ⟨u0, l0⟩ := card_IG b N 0 (by norm_num) (by norm_num) hbb obtain ⟨u1, l1⟩ := card_IG b N 1 (by norm_num) (by norm_num) hbb obtain ⟨u2, l2⟩ := card_IG b N 2 (by norm_num) (by norm_num) hbb set n0 := ((Finset.Icc 1 (b - N - 1)).filter (fun j : ℕ => IG (b : ℤ) (3 * (j : ℤ) + 0))).card set n1 := ((Finset.Icc 1 (b - N - 1)).filter (fun j : ℕ => IG (b : ℤ) (3 * (j : ℤ) + 1))).card set n2 := ((Finset.Icc 1 (b - N - 1)).filter (fun j : ℕ => IG (b : ℤ) (3 * (j : ℤ) + 2))).card have r0u : 3 * (n0 : ℝ) ≤ b + 12 := by exact_mod_cast u0 have r0l : (b : ℝ) ≤ 3 * n0 + 3 * N + 3 := by exact_mod_cast l0 have r1u : 3 * (n1 : ℝ) ≤ b + 12 := by exact_mod_cast u1 have r1l : (b : ℝ) ≤ 3 * n1 + 3 * N + 3 := by exact_mod_cast l1 have r2u : 3 * (n2 : ℝ) ≤ b + 12 := by exact_mod_cast u2 have r2l : (b : ℝ) ≤ 3 * n2 + 3 * N + 3 := by exact_mod_cast l2 rw [hcen, hcard, hU2] push_cast rw [abs_le] constructor <;> nlinarith [mul_le_mul_of_nonneg_right r0u p0, mul_le_mul_of_nonneg_right r0l p0, mul_le_mul_of_nonneg_right r1u p1, mul_le_mul_of_nonneg_right r1l p1, mul_le_mul_of_nonneg_right r2u p2, mul_le_mul_of_nonneg_right r2l p2, mul_le_mul_of_nonneg_left q0 hN0, mul_le_mul_of_nonneg_left q1 hN0, mul_le_mul_of_nonneg_left q2 hN0, mul_le_mul_of_nonneg_left hU1.2 hN0, mul_nonneg hN0 hU1.1, hM0] /-- (3c) Corollary `thm:profile`, first display (paper l.218-222):`sup_{θ ∈ J} |A_{2,b}(θ) - F₂(θ)| = O_J(b⁻¹)` for every compact `J ⊂ (0,∞)`. -/theorem perfil_uniforme (Amb : ℤ → Palabra → Prop) (hcl : ∀ b : ℤ, 3 ≤ b → ∀ w, Amb b w ↔ enLista b w) (hstep : LeyTresPasos Amb) (J : Set ℝ) (hJ : IsCompact J) (hJ0 : J ⊆ Ioi 0) : ∃ C : ℝ, ∀ b : ℕ, 1 ≤ b → ∀ θ ∈ J, |fracAmb Amb b θ - F2 θ| ≤ C / b := by obtain ⟨M, hM⟩ := hJ.bddAbove have hM0 : (0 : ℝ) ≤ max M 0 := le_max_right _ _ have hN18 : 18 ≤ ⌈(12 : ℝ) * max M 0 + 18⌉₊ := by have : (18 : ℝ) ≤ ⌈(12 : ℝ) * max M 0 + 18⌉₊ := le_trans (by linarith) (Nat.le_ceil _) exact_mod_cast this refine ⟨2 * ((⌈(12 : ℝ) * max M 0 + 18⌉₊ : ℝ) + 2) + 4 * max M 0 + 2 * ⌈(12 : ℝ) * max M 0 + 18⌉₊, fun b hb θ hθJ => ?_⟩ set N := ⌈(12 : ℝ) * max M 0 + 18⌉₊ with hNdef set M' := max M 0 with hM' have hθ : 0 < θ := hJ0 hθJ have hθM : θ ≤ M' := le_trans (hM hθJ) (le_max_left _ _) have hbpos : (0 : ℝ) < b := by exact_mod_cast hb have hden : (0 : ℝ) < b + 2 * θ := by linarith obtain ⟨hF0, hF1⟩ := F2_bounds θ hθ have hL0 := secLen_nonneg Amb b θ have hL1 := secLen_le Amb b θ hθ.le have hN0 : (0 : ℝ) ≤ N := Nat.cast_nonneg _ have key : fracAmb Amb b θ - F2 θ = (secLen Amb b θ - (b + 2 * θ) * F2 θ) / (b + 2 * θ) := by unfold fracAmb field_simp rw [key, abs_div, abs_of_pos hden, div_le_div_iff₀ hden hbpos] have hθF : 0 ≤ 2 * θ * F2 θ := by positivity have hθF' : 2 * θ * F2 θ ≤ 2 * M' := by nlinarith by_cases hbN : N ≤ b · let f : ℕ → ℝ := fun k => secLen Amb k θ - k * F2 θ have hf : ∀ k, N ≤ k → f (k + 3) = f k := by intro k hk have hk' : (12 : ℝ) * θ + 18 ≤ k := by have : (12 : ℝ) * θ + 18 ≤ N := le_trans (by linarith) (Nat.le_ceil _) exact le_trans this (by exact_mod_cast hk) have := hstep k θ hθ hk' (hcl k (by omega)) (hcl ((k + 3 : ℕ) : ℤ) (by omega)) simp only [f] push_cast linarith have hBf : f b = f (N + (b - N) % 3) := stable_residue f N b (N + (b - N) % 3) hf hbN (by omega) (by omega) have hB1 : ((N + (b - N) % 3 : ℕ) : ℝ) ≤ N + 2 := by have : N + (b - N) % 3 ≤ N + 2 := by omega exact_mod_cast this have hBlo := secLen_nonneg Amb (N + (b - N) % 3) θ have hBhi := secLen_le Amb (N + (b - N) % 3) θ hθ.le have hB0 : (0 : ℝ) ≤ ((N + (b - N) % 3 : ℕ) : ℝ) := Nat.cast_nonneg _ have p1 : ((N + (b - N) % 3 : ℕ) : ℝ) * F2 θ ≤ ((N + (b - N) % 3 : ℕ) : ℝ) := by nlinarith have p2 : 0 ≤ ((N + (b - N) % 3 : ℕ) : ℝ) * F2 θ := by positivity have fB_lo : -((N : ℝ) + 2) ≤ f (N + (b - N) % 3) := by simp only [f]; linarith have fB_hi : f (N + (b - N) % 3) ≤ N + 2 + 2 * M' := by simp only [f]; linarith have e : secLen Amb b θ - (b + 2 * θ) * F2 θ = f b - 2 * θ * F2 θ := by simp only [f]; ring have hX : |secLen Amb b θ - (b + 2 * θ) * F2 θ| ≤ 2 * ((N : ℝ) + 2) + 4 * M' := by rw [abs_le] constructor <;> linarith have := mul_le_mul_of_nonneg_right hX hbpos.le nlinarith [mul_nonneg hN0 hbpos.le, mul_nonneg hN0 hθ.le, mul_nonneg hM0 hθ.le] · have hbN' : (b : ℝ) < N := by exact_mod_cast (not_le.mp hbN) have hX : |secLen Amb b θ - (b + 2 * θ) * F2 θ| ≤ b + 2 * θ := by rw [abs_le] constructor <;> nlinarith [mul_le_mul_of_nonneg_left hF1 hden.le, mul_nonneg hden.le hF0] have := mul_le_mul_of_nonneg_right hX hbpos.le have hCb : (b : ℝ) ≤ 2 * ((N : ℝ) + 2) + 4 * M' + 2 * N := by linarith nlinarith [mul_le_mul_of_nonneg_right hCb hden.le] /-- (3d) `∫₀^∞ F₂ = 5/18` (paper l.224), with integrability stated (a non-integrable `F₂` would make theBochner integral `0`). Unconditional. -/theorem integral_F2 : IntegrableOn F2 (Ioi 0) ∧ ∫ θ in Ioi (0 : ℝ), F2 θ = 5 / 18 := by have hz : ∀ x ∈ Ioi (1 : ℝ), F2 x = 0 := fun x hx => by rw [F2_tramo7 x (le_of_lt hx)]; ring have i1 : IntegrableOn F2 (Ioc 0 1) := (F2_continuous.integrableOn_Icc).mono_set Ioc_subset_Icc_self have i2 : IntegrableOn F2 (Ioi 1) := (integrableOn_zero).congr_fun (fun x hx => (hz x hx).symm) measurableSet_Ioi have hU : Ioc (0 : ℝ) 1 ∪ Ioi 1 = Ioi 0 := Ioc_union_Ioi_eq_Ioi zero_le_one refine ⟨hU ▸ i1.union i2, ?_⟩ rw [← hU, setIntegral_union (Ioc_disjoint_Ioi le_rfl) measurableSet_Ioi i1 i2, setIntegral_congr_fun measurableSet_Ioi hz, integral_zero, add_zero, ← intervalIntegral.integral_of_le zero_le_one, integral_F2_01] /-- (3e) The limiting mean on `I = [7/50, 69/10]` (paper l.225-228 and l.548-551):`(1/|I|) ∫_I F₂ = 5809/152100`. Unconditional. -/theorem media_F2_I : (∫ θ in (7 / 50 : ℝ)..(69 / 10), F2 θ) / ((69 : ℝ) / 10 - 7 / 50) = 5809 / 152100 := by have ii : ∀ a b : ℝ, IntervalIntegrable F2 volume a b := fun a b => F2_continuous.intervalIntegrable a b rw [← intervalIntegral.integral_add_adjacent_intervals (ii (7 / 50) (1 / 4)) (ii (1 / 4) (69 / 10)), ← intervalIntegral.integral_add_adjacent_intervals (ii (1 / 4) (1 / 3)) (ii (1 / 3) (69 / 10)), ← intervalIntegral.integral_add_adjacent_intervals (ii (1 / 3) (1 / 2)) (ii (1 / 2) (69 / 10)), ← intervalIntegral.integral_add_adjacent_intervals (ii (1 / 2) (2 / 3)) (ii (2 / 3) (69 / 10)), ← intervalIntegral.integral_add_adjacent_intervals (ii (2 / 3) (3 / 4)) (ii (3 / 4) (69 / 10)), ← intervalIntegral.integral_add_adjacent_intervals (ii (3 / 4) 1) (ii 1 (69 / 10)), integral_tramo F2 (7 / 50) (1 / 4) _ _ (by norm_num) (fun x h0 h1 => F2_tramo1 x (by linarith) h1), integral_tramo F2 (1 / 4) (1 / 3) _ _ (by norm_num) (fun x h0 h1 => F2_tramo2 x h0 h1), integral_tramo F2 (1 / 3) (1 / 2) _ _ (by norm_num) (fun x h0 h1 => F2_tramo3 x h0 h1), integral_tramo F2 (1 / 2) (2 / 3) _ _ (by norm_num) (fun x h0 h1 => F2_tramo4 x h0 h1), integral_tramo F2 (2 / 3) (3 / 4) _ _ (by norm_num) (fun x h0 h1 => F2_tramo5 x h0 h1), integral_tramo F2 (3 / 4) 1 _ _ (by norm_num) (fun x h0 h1 => F2_tramo6 x h0 h1), integral_tramo F2 1 (69 / 10) _ _ (by norm_num) (fun x h0 _ => F2_tramo7 x h0)] norm_num /-- (3f) Corollary `thm:profile`, second display (paper l.225-229):`(1/|I|) ∫_I A_{2,b} = 5809/152100 + O(b⁻¹)`, with interval integrability of `A_{2,b}` stated.Integrability: `L_b` is affine on each chamber, but `A_{2,b} = L_b/(b+2θ)` is NOT (at `b = 30` the first chambergives `61θ/(30+2θ)`; error EQ085). It is proved from the measurability of `θ ↦ L_b(θ)` and `0 ≤ A_{2,b} ≤ 1`. -/theorem media_perfil (Amb : ℤ → Palabra → Prop) (hcl : ∀ b : ℤ, 3 ≤ b → ∀ w, Amb b w ↔ enLista b w) (hstep : LeyTresPasos Amb) : ∃ C : ℝ, ∀ b : ℕ, 1 ≤ b → IntervalIntegrable (fracAmb Amb b) volume (7 / 50) (69 / 10) ∧ |(∫ θ in (7 / 50 : ℝ)..(69 / 10), fracAmb Amb b θ) / ((69 : ℝ) / 10 - 7 / 50) - 5809 / 152100| ≤ C / b := by obtain ⟨C, hC⟩ := perfil_uniforme Amb hcl hstep (Icc (7 / 50) (69 / 10)) isCompact_Icc (fun θ hθ => lt_of_lt_of_le (by norm_num) hθ.1) refine ⟨C, fun b hb => ⟨fracAmb_intervalIntegrable Amb b _ _ (by norm_num) (by norm_num), ?_⟩⟩ have hI := fracAmb_intervalIntegrable Amb b (7 / 50) (69 / 10) (by norm_num) (by norm_num) have hF : IntervalIntegrable F2 volume (7 / 50) (69 / 10) := F2_continuous.intervalIntegrable _ _ have hdiff : ‖∫ θ in (7 / 50 : ℝ)..(69 / 10), (fracAmb Amb b θ - F2 θ)‖ ≤ C / b * |(69 / 10 : ℝ) - 7 / 50| := intervalIntegral.norm_integral_le_of_norm_le_const (fun θ hθ => by have hθ' : θ ∈ Icc (7 / 50 : ℝ) (69 / 10) := by rw [Set.uIoc_of_le (by norm_num)] at hθ exact ⟨hθ.1.le, hθ.2⟩ rw [Real.norm_eq_abs] exact hC b hb θ hθ') rw [intervalIntegral.integral_sub hI hF, Real.norm_eq_abs, show |(69 / 10 : ℝ) - 7 / 50| = 169 / 25 by norm_num] at hdiff have hmF := media_F2_I rw [show (69 : ℝ) / 10 - 7 / 50 = 169 / 25 by norm_num] at hmF ⊢ have e : (∫ θ in (7 / 50 : ℝ)..(69 / 10), fracAmb Amb b θ) / (169 / 25) - 5809 / 152100 = ((∫ θ in (7 / 50 : ℝ)..(69 / 10), fracAmb Amb b θ) - ∫ θ in (7 / 50 : ℝ)..(69 / 10), F2 θ) / (169 / 25) := by rw [← hmF] ring rw [e, abs_div, abs_of_pos (by norm_num : (0 : ℝ) < 169 / 25), div_le_iff₀ (by norm_num)] exact hdiff end CaballeroFase2