🏛️ Atlas✒️Formalizations.Combinatorics.Caballero.AngularPhaseTable view on GitHub ↗55 theorems
/-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: integración bajo espacio de nombres propio de Fases_extra.lean, fuente de Argox para el Lema 2.Modelo solicitado gpt-6.2-astra, esfuerzo max. Valores efectivos no expuestos. Superficie: agente Codex.Tarea: poner la tabla de fases ya demostrada a disposición de la prueba del Teorema A.Alcance: los seis patrones de las dos familias, su reflexión y las fórmulas por tramos.-/module public import Formalizations.Combinatorics.Caballero.AngularPeakspublic import Mathlib.Tactic.FunProp /-!# AngularPhaseTable-/ /-!## 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 CaballeroPhaseTable /-! ## Lema 2 del III: tabla de fases U₁, U₂ sobre ℝ (obligación 4 del barrido de Prometeox, 0177)GENERADO por generar_fases.py: por patrón y tramo, el término activo del mínimo y del máximo; Lean lo comprueba. -/ /-- Anchura de fase de un vector k: [min(1, min_h(k_h+1−hθ)) − max(0, max_h(k_h−hθ))]₊ (III, antes del Lema 2). -/noncomputable def w (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 * θ)))))) /-- Los seis patrones (⌊(r + m h)/3⌋)_h, r = 0, 1, 2, m = 1, 2, calculados con la división entera. -/theorem patrones :    (((0 + 1 * (-2)) / 3, (0 + 1 * (-1)) / 3, (0 + 1 * (0)) / 3, (0 + 1 * (1)) / 3, (0 + 1 * (2)) / 3) : ℤ × ℤ × ℤ × ℤ × ℤ) = (-1, -1, 0, 0, 0) ∧    (((1 + 1 * (-2)) / 3, (1 + 1 * (-1)) / 3, (1 + 1 * (0)) / 3, (1 + 1 * (1)) / 3, (1 + 1 * (2)) / 3) : ℤ × ℤ × ℤ × ℤ × ℤ) = (-1, 0, 0, 0, 1) ∧    (((2 + 1 * (-2)) / 3, (2 + 1 * (-1)) / 3, (2 + 1 * (0)) / 3, (2 + 1 * (1)) / 3, (2 + 1 * (2)) / 3) : ℤ × ℤ × ℤ × ℤ × ℤ) = (0, 0, 0, 1, 1) ∧    (((0 + 2 * (-2)) / 3, (0 + 2 * (-1)) / 3, (0 + 2 * (0)) / 3, (0 + 2 * (1)) / 3, (0 + 2 * (2)) / 3) : ℤ × ℤ × ℤ × ℤ × ℤ) = (-2, -1, 0, 0, 1) ∧    (((1 + 2 * (-2)) / 3, (1 + 2 * (-1)) / 3, (1 + 2 * (0)) / 3, (1 + 2 * (1)) / 3, (1 + 2 * (2)) / 3) : ℤ × ℤ × ℤ × ℤ × ℤ) = (-1, -1, 0, 1, 1) ∧    (((2 + 2 * (-2)) / 3, (2 + 2 * (-1)) / 3, (2 + 2 * (0)) / 3, (2 + 2 * (1)) / 3, (2 + 2 * (2)) / 3) : ℤ × ℤ × ℤ × ℤ × ℤ) = (-1, 0, 0, 1, 2) := by decide theorem w_m1_r0_t0 (θ : ℝ) (_h1 : θ ≤ (0 : ℝ)) :    w (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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_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 w_m1_r0_t1 (θ : ℝ) (_h0 : (0 : ℝ) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 4)) :    w (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((0 : ℝ) + (1 : ℝ) * θ) := by  unfold w  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 w_m1_r0_t2 (θ : ℝ) (_h0 : ((1 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 3)) :    w (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((0 : ℝ) + (1 : ℝ) * θ) := by  unfold w  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 w_m1_r0_t3 (θ : ℝ) (_h0 : ((1 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 2)) :    w (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((1 : ℝ) + (-2 : ℝ) * θ) := by  unfold w  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 w_m1_r0_t4 (θ : ℝ) (_h0 : ((1 : ℝ) / 2) ≤ θ) (_h1 : θ ≤ ((2 : ℝ) / 3)) :    w (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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 w_m1_r0_t5 (θ : ℝ) (_h0 : ((2 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((3 : ℝ) / 4)) :    w (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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 w_m1_r0_t6 (θ : ℝ) (_h0 : ((3 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ (1 : ℝ)) :    w (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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 w_m1_r0_t7 (θ : ℝ) (_h0 : (1 : ℝ) ≤ θ) :    w (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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 w_m1_r1_t0 (θ : ℝ) (_h1 : θ ≤ (0 : ℝ)) :    w (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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 w_m1_r1_t1 (θ : ℝ) (_h0 : (0 : ℝ) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 4)) :    w (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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 w_m1_r1_t2 (θ : ℝ) (_h0 : ((1 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 3)) :    w (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((-1 : ℝ) + (4 : ℝ) * θ) := by  unfold w  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 w_m1_r1_t3 (θ : ℝ) (_h0 : ((1 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 2)) :    w (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((1 : ℝ) + (-2 : ℝ) * θ) := by  unfold w  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 w_m1_r1_t4 (θ : ℝ) (_h0 : ((1 : ℝ) / 2) ≤ θ) (_h1 : θ ≤ ((2 : ℝ) / 3)) :    w (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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 w_m1_r1_t5 (θ : ℝ) (_h0 : ((2 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((3 : ℝ) / 4)) :    w (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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 w_m1_r1_t6 (θ : ℝ) (_h0 : ((3 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ (1 : ℝ)) :    w (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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 w_m1_r1_t7 (θ : ℝ) (_h0 : (1 : ℝ) ≤ θ) :    w (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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 w_m1_r2_t0 (θ : ℝ) (_h1 : θ ≤ (0 : ℝ)) :    w (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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_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 w_m1_r2_t1 (θ : ℝ) (_h0 : (0 : ℝ) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 4)) :    w (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (1 : ℝ) * θ) := by  unfold w  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 w_m1_r2_t2 (θ : ℝ) (_h0 : ((1 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 3)) :    w (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (1 : ℝ) * θ) := by  unfold w  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 w_m1_r2_t3 (θ : ℝ) (_h0 : ((1 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((1 : ℝ) / 2)) :    w (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((1 : ℝ) + (-2 : ℝ) * θ) := by  unfold w  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 w_m1_r2_t4 (θ : ℝ) (_h0 : ((1 : ℝ) / 2) ≤ θ) (_h1 : θ ≤ ((2 : ℝ) / 3)) :    w (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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 w_m1_r2_t5 (θ : ℝ) (_h0 : ((2 : ℝ) / 3) ≤ θ) (_h1 : θ ≤ ((3 : ℝ) / 4)) :    w (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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 w_m1_r2_t6 (θ : ℝ) (_h0 : ((3 : ℝ) / 4) ≤ θ) (_h1 : θ ≤ (1 : ℝ)) :    w (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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 w_m1_r2_t7 (θ : ℝ) (_h0 : (1 : ℝ) ≤ θ) :    w (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold w  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) noncomputable def Ufase1 (θ : ℝ) : ℝ := w (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) θ + w (-1 : ℝ) (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ + w (0 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θnoncomputable def Ufase2 (θ : ℝ) : ℝ := w (-2 : ℝ) (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) θ + w (-1 : ℝ) (-1 : ℝ) (0 : ℝ) (1 : ℝ) (1 : ℝ) θ + w (-1 : ℝ) (0 : ℝ) (0 : ℝ) (1 : ℝ) (2 : ℝ) θ theorem refl_min (a0 a1 a2 a3 a4 : ℝ) :    min 1 (min (1 - a0) (min (1 - a1) (min (1 - a2) (min (1 - a3) (1 - a4)))))      = 1 - max 0 (max a0 (max a1 (max a2 (max a3 a4)))) := by  simp only [← min_sub_sub_left, sub_zero] theorem refl_max (b0 b1 b2 b3 b4 : ℝ) :    max 0 (max (1 - b0) (max (1 - b1) (max (1 - b2) (max (1 - b3) (1 - b4)))))      = 1 - min 1 (min b0 (min b1 (min b2 (min b3 b4)))) := by  simp only [← max_sub_sub_left, sub_self] /-- La unidad −1 de (ℤ/3)ˣ en la celda: la reflexión x ↦ 1 − x de [0,1] junto con θ ↦ 1 − θlleva el vector k al vector (h − k_h)_h, h = −2,…,2. -/theorem w_reflejo (k0 k1 k2 k3 k4 θ : ℝ) :    w k0 k1 k2 k3 k4 (1 - θ) = w (-2 - k0) (-1 - k1) (-k2) (1 - k3) (2 - k4) θ := by  unfold w  rw [show -2 - k0 + 1 + 2 * θ = 1 - (k0 + 2 * (1 - θ)) by ring,    show -1 - k1 + 1 + θ = 1 - (k1 + (1 - θ)) by ring,    show -k2 + 1 = 1 - k2 by ring,    show 1 - k3 + 1 - θ = 1 - (k3 - (1 - θ)) by ring,    show 2 - k4 + 1 - 2 * θ = 1 - (k4 - 2 * (1 - θ)) by ring,    show -2 - k0 + 2 * θ = 1 - (k0 + 1 + 2 * (1 - θ)) by ring,    show -1 - k1 + θ = 1 - (k1 + 1 + (1 - θ)) by ring,    show -k2 = 1 - (k2 + 1) by ring,    show 1 - k3 - θ = 1 - (k3 + 1 - (1 - θ)) by ring,    show 2 - k4 - 2 * θ = 1 - (k4 + 1 - 2 * (1 - θ)) by ring,    refl_min, refl_max]  congr 1  ring /-- m = 2 ≡ −1 (mód 3): k ↦ (h − k_h) lleva el patrón (r, 1) al patrón (2 − r, 2), luegola fase 2 es la fase 1 reflejada. -/theorem fases_reflejo (θ : ℝ) : Ufase2 θ = Ufase1 (1 - θ) := by  unfold Ufase1 Ufase2  rw [w_reflejo, w_reflejo, w_reflejo]  norm_num  ring theorem fase1_tramo0 (θ : ℝ) (h1 : θ ≤ (0 : ℝ)) : Ufase1 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold Ufase1  rw [w_m1_r0_t0 θ h1, w_m1_r1_t0 θ h1, w_m1_r2_t0 θ h1]  ring theorem fase1_tramo1 (θ : ℝ) (h0 : (0 : ℝ) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 4)) : Ufase1 θ = ((0 : ℝ) + (2 : ℝ) * θ) := by  unfold Ufase1  rw [w_m1_r0_t1 θ h0 h1, w_m1_r1_t1 θ h0 h1, w_m1_r2_t1 θ h0 h1]  ring theorem fase1_tramo2 (θ : ℝ) (h0 : ((1 : ℝ) / 4) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 3)) : Ufase1 θ = ((-1 : ℝ) + (6 : ℝ) * θ) := by  unfold Ufase1  rw [w_m1_r0_t2 θ h0 h1, w_m1_r1_t2 θ h0 h1, w_m1_r2_t2 θ h0 h1]  ring theorem fase1_tramo3 (θ : ℝ) (h0 : ((1 : ℝ) / 3) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 2)) : Ufase1 θ = ((3 : ℝ) + (-6 : ℝ) * θ) := by  unfold Ufase1  rw [w_m1_r0_t3 θ h0 h1, w_m1_r1_t3 θ h0 h1, w_m1_r2_t3 θ h0 h1]  ring theorem fase1_tramo4 (θ : ℝ) (h0 : ((1 : ℝ) / 2) ≤ θ) (h1 : θ ≤ ((2 : ℝ) / 3)) : Ufase1 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold Ufase1  rw [w_m1_r0_t4 θ h0 h1, w_m1_r1_t4 θ h0 h1, w_m1_r2_t4 θ h0 h1]  ring theorem fase1_tramo5 (θ : ℝ) (h0 : ((2 : ℝ) / 3) ≤ θ) (h1 : θ ≤ ((3 : ℝ) / 4)) : Ufase1 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold Ufase1  rw [w_m1_r0_t5 θ h0 h1, w_m1_r1_t5 θ h0 h1, w_m1_r2_t5 θ h0 h1]  ring theorem fase1_tramo6 (θ : ℝ) (h0 : ((3 : ℝ) / 4) ≤ θ) (h1 : θ ≤ (1 : ℝ)) : Ufase1 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold Ufase1  rw [w_m1_r0_t6 θ h0 h1, w_m1_r1_t6 θ h0 h1, w_m1_r2_t6 θ h0 h1]  ring theorem fase1_tramo7 (θ : ℝ) (h0 : (1 : ℝ) ≤ θ) : Ufase1 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  unfold Ufase1  rw [w_m1_r0_t7 θ h0, w_m1_r1_t7 θ h0, w_m1_r2_t7 θ h0]  ring /-- Tabla del Lema 2, tramo 0: θ ∈ [−∞, 0]; la fase 2 sale del tramo 7 de la fase 1 por reflexión. -/theorem fases_tramo0 (θ : ℝ) (h1 : θ ≤ (0 : ℝ)) : Ufase1 θ = ((0 : ℝ) + (0 : ℝ) * θ) ∧ Ufase2 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  refine ⟨fase1_tramo0 θ h1, ?_⟩  rw [fases_reflejo, fase1_tramo7 (1 - θ) (by linarith)]  ring /-- Tabla del Lema 2, tramo 1: θ ∈ [0, 1/4]; la fase 2 sale del tramo 6 de la fase 1 por reflexión. -/theorem fases_tramo1 (θ : ℝ) (h0 : (0 : ℝ) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 4)) : Ufase1 θ = ((0 : ℝ) + (2 : ℝ) * θ) ∧ Ufase2 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  refine ⟨fase1_tramo1 θ h0 h1, ?_⟩  rw [fases_reflejo, fase1_tramo6 (1 - θ) (by linarith) (by linarith)]  ring /-- Tabla del Lema 2, tramo 2: θ ∈ [1/4, 1/3]; la fase 2 sale del tramo 5 de la fase 1 por reflexión. -/theorem fases_tramo2 (θ : ℝ) (h0 : ((1 : ℝ) / 4) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 3)) : Ufase1 θ = ((-1 : ℝ) + (6 : ℝ) * θ) ∧ Ufase2 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  refine ⟨fase1_tramo2 θ h0 h1, ?_⟩  rw [fases_reflejo, fase1_tramo5 (1 - θ) (by linarith) (by linarith)]  ring /-- Tabla del Lema 2, tramo 3: θ ∈ [1/3, 1/2]; la fase 2 sale del tramo 4 de la fase 1 por reflexión. -/theorem fases_tramo3 (θ : ℝ) (h0 : ((1 : ℝ) / 3) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 2)) : Ufase1 θ = ((3 : ℝ) + (-6 : ℝ) * θ) ∧ Ufase2 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  refine ⟨fase1_tramo3 θ h0 h1, ?_⟩  rw [fases_reflejo, fase1_tramo4 (1 - θ) (by linarith) (by linarith)]  ring /-- Tabla del Lema 2, tramo 4: θ ∈ [1/2, 2/3]; la fase 2 sale del tramo 3 de la fase 1 por reflexión. -/theorem fases_tramo4 (θ : ℝ) (h0 : ((1 : ℝ) / 2) ≤ θ) (h1 : θ ≤ ((2 : ℝ) / 3)) : Ufase1 θ = ((0 : ℝ) + (0 : ℝ) * θ) ∧ Ufase2 θ = ((-3 : ℝ) + (6 : ℝ) * θ) := by  refine ⟨fase1_tramo4 θ h0 h1, ?_⟩  rw [fases_reflejo, fase1_tramo3 (1 - θ) (by linarith) (by linarith)]  ring /-- Tabla del Lema 2, tramo 5: θ ∈ [2/3, 3/4]; la fase 2 sale del tramo 2 de la fase 1 por reflexión. -/theorem fases_tramo5 (θ : ℝ) (h0 : ((2 : ℝ) / 3) ≤ θ) (h1 : θ ≤ ((3 : ℝ) / 4)) : Ufase1 θ = ((0 : ℝ) + (0 : ℝ) * θ) ∧ Ufase2 θ = ((5 : ℝ) + (-6 : ℝ) * θ) := by  refine ⟨fase1_tramo5 θ h0 h1, ?_⟩  rw [fases_reflejo, fase1_tramo2 (1 - θ) (by linarith) (by linarith)]  ring /-- Tabla del Lema 2, tramo 6: θ ∈ [3/4, 1]; la fase 2 sale del tramo 1 de la fase 1 por reflexión. -/theorem fases_tramo6 (θ : ℝ) (h0 : ((3 : ℝ) / 4) ≤ θ) (h1 : θ ≤ (1 : ℝ)) : Ufase1 θ = ((0 : ℝ) + (0 : ℝ) * θ) ∧ Ufase2 θ = ((2 : ℝ) + (-2 : ℝ) * θ) := by  refine ⟨fase1_tramo6 θ h0 h1, ?_⟩  rw [fases_reflejo, fase1_tramo1 (1 - θ) (by linarith) (by linarith)]  ring /-- Tabla del Lema 2, tramo 7: θ ∈ [1, ∞]; la fase 2 sale del tramo 0 de la fase 1 por reflexión. -/theorem fases_tramo7 (θ : ℝ) (h0 : (1 : ℝ) ≤ θ) : Ufase1 θ = ((0 : ℝ) + (0 : ℝ) * θ) ∧ Ufase2 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  refine ⟨fase1_tramo7 θ h0, ?_⟩  rw [fases_reflejo, fase1_tramo0 (1 - θ) (by linarith)]  ring /-- Perfil límite del Teorema 1 del III: F₂ = U₁ + U₂/3 (pesos 1 y 1/3 = fracción del rango de s de O₁ y de G). -/noncomputable def F2 (θ : ℝ) : ℝ := Ufase1 θ + Ufase2 θ / 3 /-- Forma mínima: el perfil entero sale de U₁ sola. -/theorem F2_reflejo (θ : ℝ) : F2 θ = Ufase1 θ + Ufase1 (1 - θ) / 3 := by  unfold F2; rw [fases_reflejo] /-- Teorema 1 del III, fórmula de F₂ en el tramo 0. -/theorem F2_tramo0 (θ : ℝ) (h1 : θ ≤ (0 : ℝ)) : F2 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  obtain ⟨e1, e2⟩ := fases_tramo0 θ h1  unfold F2; rw [e1, e2]; ring /-- Teorema 1 del III, fórmula de F₂ en el tramo 1. -/theorem F2_tramo1 (θ : ℝ) (h0 : (0 : ℝ) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 4)) : F2 θ = ((0 : ℝ) + (2 : ℝ) * θ) := by  obtain ⟨e1, e2⟩ := fases_tramo1 θ h0 h1  unfold F2; rw [e1, e2]; ring /-- Teorema 1 del III, fórmula de F₂ en el tramo 2. -/theorem F2_tramo2 (θ : ℝ) (h0 : ((1 : ℝ) / 4) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 3)) : F2 θ = ((-1 : ℝ) + (6 : ℝ) * θ) := by  obtain ⟨e1, e2⟩ := fases_tramo2 θ h0 h1  unfold F2; rw [e1, e2]; ring /-- Teorema 1 del III, fórmula de F₂ en el tramo 3. -/theorem F2_tramo3 (θ : ℝ) (h0 : ((1 : ℝ) / 3) ≤ θ) (h1 : θ ≤ ((1 : ℝ) / 2)) : F2 θ = ((3 : ℝ) + (-6 : ℝ) * θ) := by  obtain ⟨e1, e2⟩ := fases_tramo3 θ h0 h1  unfold F2; rw [e1, e2]; ring /-- Teorema 1 del III, fórmula de F₂ en el tramo 4. -/theorem F2_tramo4 (θ : ℝ) (h0 : ((1 : ℝ) / 2) ≤ θ) (h1 : θ ≤ ((2 : ℝ) / 3)) : F2 θ = ((-1 : ℝ) + (2 : ℝ) * θ) := by  obtain ⟨e1, e2⟩ := fases_tramo4 θ h0 h1  unfold F2; rw [e1, e2]; ring /-- Teorema 1 del III, fórmula de F₂ en el tramo 5. -/theorem F2_tramo5 (θ : ℝ) (h0 : ((2 : ℝ) / 3) ≤ θ) (h1 : θ ≤ ((3 : ℝ) / 4)) : F2 θ = (((5 : ℝ) / 3) + (-2 : ℝ) * θ) := by  obtain ⟨e1, e2⟩ := fases_tramo5 θ h0 h1  unfold F2; rw [e1, e2]; ring /-- Teorema 1 del III, fórmula de F₂ en el tramo 6. -/theorem F2_tramo6 (θ : ℝ) (h0 : ((3 : ℝ) / 4) ≤ θ) (h1 : θ ≤ (1 : ℝ)) : F2 θ = (((2 : ℝ) / 3) + ((-2 : ℝ) / 3) * θ) := by  obtain ⟨e1, e2⟩ := fases_tramo6 θ h0 h1  unfold F2; rw [e1, e2]; ring /-- Teorema 1 del III, fórmula de F₂ en el tramo 7. -/theorem F2_tramo7 (θ : ℝ) (h0 : (1 : ℝ) ≤ θ) : F2 θ = ((0 : ℝ) + (0 : ℝ) * θ) := by  obtain ⟨e1, e2⟩ := fases_tramo7 θ h0  unfold F2; rw [e1, e2]; ring /-- Lema 2, primera parte: U₁ y U₂ son continuas (composición de mínimos, máximos y funciones afines). -/theorem fases_continuas : Continuous Ufase1 ∧ Continuous Ufase2 := by  constructor  · unfold Ufase1 w; fun_prop  · have h : Ufase2 = fun θ => Ufase1 (1 - θ) := funext fases_reflejo    rw [h]; unfold Ufase1 w; fun_prop  end CaballeroPhaseTable