🏛️ Atlas✒️Formalizations.Combinatorics.Caballero.AngularPhaseMass view on GitHub ↗9 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: geometría del paso tres del Paper III, medida de los huecos. Usa los patrones,las fibras y la tabla de fases ya verificados, y la invariancia de la medida de Lebesgue.Modelo solicitado gpt-6.2-astra, esfuerzo max. Valores efectivos no expuestos. Superficie: agente Codex.Tarea: sumar las anchuras de patrones distintos en cada intervalo unitario insertado.Resultado: los huecos aportan U₁, U₁ y U₁+U₂; su suma es 3F₂ para toda pendiente positiva.-/module public import Formalizations.Combinatorics.Caballero.AngularGapPatternspublic import Formalizations.Combinatorics.Caballero.AngularPhaseTablepublic import Mathlib.MeasureTheory.Function.Floorpublic import Mathlib.MeasureTheory.Group.Measurepublic import Mathlib.MeasureTheory.Measure.Real /-!# AngularPhaseMass-/ /-!## 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 CaballeroPhaseMass open Set MeasureTheory CaballeroExact CaballeroPeaks CaballeroStepPartitionopen CaballeroPhaseFiber CaballeroGapPatterns /-- Points in a portion of the section whose word belongs to the complete Part I list. -/noncomputable def labelSet (b : ℕ) (θ : ℝ) (s : Set ℝ) : Set ℝ :=  {x | x ∈ s ∧ enLista (b : ℤ) (cellWord (b : ℤ) x θ)} /-- The new indices `1,3,5` of the three inserted units. -/def gapIndex (i : Fin 3) : Fin 7 := ⟨2 * i.val + 1, by omega⟩ private def modes (m : ℤ) : Finset Palabra := {pattern m 0, pattern m 1, pattern m 2} private def allowedModes (i : Fin 3) : Finset Palabra :=  if i.val = 2 then modes 1 ∪ modes 2 else modes 1 private theorem phase_iff_mem (m : ℤ) (θ u : ℝ) :    phase m θ u ↔ rawWord θ u ∈ modes m := by  simp only [phase, modes, Finset.mem_insert, Finset.mem_singleton]  constructor  · rintro ⟨r, hr0, hr2, hw⟩    rcases (show r = 0 ∨ r = 1 ∨ r = 2 by omega) with rfl | rfl | rfl <;> tauto  · rintro (hw | hw | hw)    · exact ⟨0, by decide, by decide, hw⟩    · exact ⟨1, by decide, by decide, hw⟩    · exact ⟨2, by decide, by decide, hw⟩ private theorem mem_allowed (i : Fin 3) (θ u : ℝ) :    rawWord θ u ∈ allowedModes i ↔ phase 1 θ u ∨ (i.val = 2 ∧ phase 2 θ u) := by  by_cases h : i.val = 2 <;> simp [allowedModes, h, phase_iff_mem] private theorem volume_of_modes (s : Finset Palabra) (θ : ℝ) :    volume.real (⋃ k ∈ s, phaseFiber θ k) = ∑ k ∈ s, phaseWidth k θ := by  trans ∑ k ∈ s, volume.real (phaseFiber θ k)  · refine measureReal_biUnion_finset ?_ ?_ ?_    · intro k _ l _ hkl      apply Set.disjoint_left.mpr      intro u hk hl      exact hkl (hk.2.symm.trans hl.2)    · intro k _      rw [phaseFiber_eq_Ico]      exact measurableSet_Ico    · intro k _      rw [phaseFiber_eq_Ico, Real.volume_Ico]      exact ENNReal.ofReal_ne_top  · simp only [volume_phase_fiber] private theorem width_as_w (a b c d e : ℤ) (θ : ℝ) :    phaseWidth (a, b, c, d, e) θ = CaballeroPhaseTable.w a b c d e θ := rfl private theorem widths1 (θ : ℝ) :    ∑ k ∈ modes 1, phaseWidth k θ = CaballeroPhaseTable.Ufase1 θ := by  norm_num [modes, pattern, Finset.sum_insert, width_as_w, CaballeroPhaseTable.Ufase1, add_assoc] private theorem widths2 (θ : ℝ) :    ∑ k ∈ modes 2, phaseWidth k θ = CaballeroPhaseTable.Ufase2 θ := by  norm_num [modes, pattern, Finset.sum_insert, width_as_w, CaballeroPhaseTable.Ufase2, add_assoc] private theorem gap_piece (b : ℕ) (θ : ℝ) (i : Fin 3) :    piece b θ (gapIndex i) = Ico (gapStart b i : ℝ) ((gapStart b i : ℝ) + 1) := by  fin_cases i  · change Ico (j1 b : ℝ) ((j1 b : ℝ) + 1) = Ico ((j1 b : ℤ) : ℝ) (((j1 b : ℤ) : ℝ) + 1)    push_cast    rfl  · change Ico ((j2 b : ℝ) + 1) ((j2 b : ℝ) + 2) =      Ico (((j2 b : ℤ) + 1 : ℤ) : ℝ) ((((j2 b : ℤ) + 1 : ℤ) : ℝ) + 1)    push_cast    congr 1    ring  · change Ico ((j3 b : ℝ) + 2) ((j3 b : ℝ) + 3) =      Ico (((j3 b : ℤ) + 2 : ℤ) : ℝ) ((((j3 b : ℤ) + 2 : ℤ) : ℝ) + 1)    push_cast    congr 1    ring /-- The first two units contribute `U₁` each; the third contributes `U₁ + U₂`. -/theorem gap_length (b : ℕ) (θ : ℝ) (i : Fin 3) (hθ : 0 < θ) (hb : 12 * θ + 18 ≤ (b : ℝ)) :    volume.real (labelSet (b + 3) θ (piece b θ (gapIndex i))) =      CaballeroPhaseTable.Ufase1 θ + (if i.val = 2 then CaballeroPhaseTable.Ufase2 θ else 0) := by  let j : ℝ := gapStart b i  let S := labelSet (b + 3) θ (piece b θ (gapIndex i))  have pre : (fun u : ℝ => j + u) ⁻¹' S = ⋃ k ∈ allowedModes i, phaseFiber θ k := by    ext u    change (j + u ∈ piece b θ (gapIndex i) ∧      enLista ((b : ℤ) + 3) (cellWord ((b : ℤ) + 3) (j + u) θ)) ↔ _    rw [gap_piece]    change (j + u ∈ Ico j (j + 1) ∧ _) ↔ _    have hu : j + u ∈ Ico j (j + 1) ↔ u ∈ Ico 0 1 := by      simp only [Set.mem_Ico]      constructor <;> rintro ⟨h0, h1⟩ <;> constructor <;> linarith    rw [hu]    simp only [Set.mem_iUnion, phaseFiber, Set.mem_ofPred_eq]    constructor    · rintro ⟨hunit, hw⟩      exact ⟨rawWord θ u, (mem_allowed i θ u).mpr ((gap_iff b θ u i hθ hb hunit).mp hw), hunit, rfl⟩    · rintro ⟨k, hk, hunit, hword⟩      exact ⟨hunit, (gap_iff b θ u i hθ hb hunit).mpr ((mem_allowed i θ u).mp (hword ▸ hk))⟩  calc    volume.real S = volume.real ((fun u : ℝ => j + u) ⁻¹' S) :=      congrArg ENNReal.toReal (measure_preimage_add volume j S).symm    _ = ∑ k ∈ allowedModes i, phaseWidth k θ := by rw [pre, volume_of_modes]    _ = _ := by      by_cases hi : i.val = 2      · simp [allowedModes, hi, Finset.sum_union (by decide : Disjoint (modes 1) (modes 2)), widths1, widths2]      · simp [allowedModes, hi, widths1] /-- Translation from the phase-table definition of the profile to the formula used by `secLen`. -/theorem phase_sum (θ : ℝ) (hθ : 0 < θ) :    3 * CaballeroPhaseTable.Ufase1 θ + CaballeroPhaseTable.Ufase2 θ = 3 * CaballeroExact.F2 θ := by  unfold CaballeroExact.F2  split_ifs with h1 h2 h3 h4 h5 h6  · obtain ⟨e1,e2⟩ := CaballeroPhaseTable.fases_tramo1 θ hθ.le h1    rw [e1,e2]; ring  · obtain ⟨e1,e2⟩ := CaballeroPhaseTable.fases_tramo2 θ (by linarith) h2    rw [e1,e2]; ring  · obtain ⟨e1,e2⟩ := CaballeroPhaseTable.fases_tramo3 θ (by linarith) h3    rw [e1,e2]; ring  · obtain ⟨e1,e2⟩ := CaballeroPhaseTable.fases_tramo4 θ (by linarith) h4    rw [e1,e2]; ring  · obtain ⟨e1,e2⟩ := CaballeroPhaseTable.fases_tramo5 θ (by linarith) h5    rw [e1,e2]; ring  · obtain ⟨e1,e2⟩ := CaballeroPhaseTable.fases_tramo6 θ (by linarith) h6    rw [e1,e2]; ring  · obtain ⟨e1,e2⟩ := CaballeroPhaseTable.fases_tramo7 θ (by linarith)    rw [e1,e2]; ring  end CaballeroPhaseMass