/-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)-/module public import Formalizations.Combinatorics.Caballero.AngularWidthspublic import Mathlib.Order.LiminfLimsuppublic import Mathlib.Topology.Order.LiminfLimsuppublic import Mathlib.Analysis.SpecificLimits.Basic /-!# The lower bound L_b(theta) >= b U_a(theta) for general a (Caballero, Part IV, Theorem 5) Theorem 5 of Part IV: for a >= 2, b >= 1 and theta > 0, the ambiguous length L_b(theta) of thevertical section at theta is at least b U_a(theta), and hence liminf_b A_{a,b}(theta) >= U_a(theta).L_b(theta) is the Lebesgue measure (MeasureTheory.volume, toReal) of the set of Lambda with 0 <Lambda < b + a theta, off the lines Lambda + h theta in Z (|h| <= a), whose clipped floor vector isambiguous (realisable, with another realisable vector of the same multiset Z); A_{a,b}(theta) =L_b(theta)/(b + a theta). The phase width of the formula is identified with the length of the phaseset {u in (0,1) : floor(u + h theta) = k_h for all h}, which is an interval squeezed between theopen and the half-open interval with the same ends. For Lambda = j + u with u in the phase set ofk^(r), the vector is that of the point P_1(s), s = (a+1)j + r, of Part II, Proposition 6.3; itsfibre also contains the vector of P_2(s) = (s + 1/2, b + 1): Z is computed at both points throughthe bracket counts of Lemma 7 (the two radix numerations of 0, ..., K-1), and the two vectors differin the coordinate c_{-a}. Part (ii) of that proposition is thus proved here, for these s, ratherthan cited. The intervals for different (j, r) are disjoint, so their lengths add to b U_a(theta). ## Main results * `CaballeroLowerBound.lower_bound`: Theorem 5: L_b(theta) >= b U_a(theta) for a >= 2, b >= 1, theta > 0* `CaballeroLowerBound.le_liminf_ambProportion`: Theorem 5, consequence: liminf_b A_{a,b}(theta) >= U_a(theta) for theta > 0* `CaballeroLowerBound.volume_phaseSet`: the phase width w_k(theta) is the Lebesgue measure of the set of u in (0,1) with floor(u + h theta) = k_h for all h* `CaballeroLowerBound.ambiguous_of_mem_phaseSet`: every Lambda = j + u, 0 <= j <= b-1, u in the phase set of k^(r), off the lines, lies in an ambiguous cell ## References * C. Marín, How Many Dyck Words Do the Divisors of an Integer Make? IV. The Primary Phase of the Ambiguity Profile for General a, draft (2 December 2026), unpublished.* 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 CaballeroLowerBound open Finset MeasureTheory Filter Topology CaballeroGeneralA CaballeroWidths /-- The ambiguous length `L_b(θ)` of the vertical section at `θ`: the Lebesgue measure of the set of`Λ` with `0 < Λ < b + aθ`, off the lines of the arrangement, whose cell vector `c(Λ, θ)` isambiguous. (Points on the lines have length zero and are left out, as in the paper.) -/noncomputable def ambLength (a b : ℕ) (θ : ℝ) : ℝ := (volume {Λ : ℝ | 0 < Λ ∧ Λ < (b : ℝ) + (a : ℝ) * θ ∧ OffLines a Λ θ ∧ Ambiguous a b (cellVec a b Λ θ)}).toReal /-- The ambiguous proportion `A_{a,b}(θ) = L_b(θ) / (b + aθ)` of the section. -/noncomputable def ambProportion (a b : ℕ) (θ : ℝ) : ℝ := ambLength a b θ / ((b : ℝ) + (a : ℝ) * θ) /-- The phase set of a floor pattern `k`: the `u ∈ (0,1)` with `⌊u + hθ⌋ = k_h` for every`|h| ≤ a` (index `i = h + a`). -/def phaseSet (a : ℕ) (k : Vec a) (θ : ℝ) : Set ℝ := {u | 0 < u ∧ u < 1 ∧ ∀ i : Fin (2 * a + 1), ⌊u + ((((i : ℕ) : ℤ) - a : ℤ) : ℝ) * θ⌋ = k i} /-! ### The phase set is an interval of length `w_k(θ)` -/ /-- Left end `max(0, max_h (k_h - hθ))` of the phase interval. -/noncomputable def phaseLo (a : ℕ) (k : Vec a) (θ : ℝ) : ℝ := max 0 (univ.sup' univ_nonempty (lowTerm a k θ)) /-- Right end `min(1, min_h (k_h + 1 - hθ))` of the phase interval. -/noncomputable def phaseHi (a : ℕ) (k : Vec a) (θ : ℝ) : ℝ := min 1 (univ.inf' univ_nonempty (upTerm a k θ)) theorem phaseWidth_eq_hi_sub_lo (a : ℕ) (k : Vec a) (θ : ℝ) : phaseWidth a k θ = max (phaseHi a k θ - phaseLo a k θ) 0 := rfl theorem Ioo_subset_phaseSet (a : ℕ) (k : Vec a) (θ : ℝ) : Set.Ioo (phaseLo a k θ) (phaseHi a k θ) ⊆ phaseSet a k θ := by rintro u ⟨h1, h2⟩ refine ⟨lt_of_le_of_lt (le_max_left _ _) h1, lt_of_lt_of_le h2 (min_le_left _ _), fun i => ?_⟩ have hlo : lowTerm a k θ i < u := lt_of_le_of_lt ((le_sup' (lowTerm a k θ) (mem_univ i)).trans (le_max_right _ _)) h1 have hup : u < upTerm a k θ i := lt_of_lt_of_le h2 ((min_le_right _ _).trans (inf'_le (upTerm a k θ) (mem_univ i))) unfold lowTerm at hlo unfold upTerm at hup rw [Int.floor_eq_iff] constructor <;> linarith theorem phaseSet_subset_Ico (a : ℕ) (k : Vec a) (θ : ℝ) : phaseSet a k θ ⊆ Set.Ico (phaseLo a k θ) (phaseHi a k θ) := by rintro u ⟨h0, h1, hf⟩ constructor · refine max_le h0.le (Finset.sup'_le _ _ fun i _ => ?_) have := Int.floor_le (u + ((((i : ℕ) : ℤ) - a : ℤ) : ℝ) * θ) rw [hf i] at this unfold lowTerm linarith · refine lt_min h1 ((Finset.lt_inf'_iff _).2 fun i _ => ?_) have := Int.lt_floor_add_one (u + ((((i : ℕ) : ℤ) - a : ℤ) : ℝ) * θ) rw [hf i] at this unfold upTerm linarith /-- The phase width is the length of the phase set (the identification used in Theorem 5). -/theorem volume_phaseSet (a : ℕ) (k : Vec a) (θ : ℝ) : (volume (phaseSet a k θ)).toReal = phaseWidth a k θ := by have h1 := measure_mono (μ := volume) (Ioo_subset_phaseSet a k θ) have h2 := measure_mono (μ := volume) (phaseSet_subset_Ico a k θ) rw [Real.volume_Ioo] at h1 rw [Real.volume_Ico] at h2 rw [le_antisymm h2 h1, ENNReal.toReal_ofReal', phaseWidth_eq_hi_sub_lo] /-! ### Arithmetic of the primary patterns -/ theorem pf_spec (a r : ℕ) (h : ℤ) : pf a r h * ((a : ℤ) + 1) ≤ r + h ∧ (r : ℤ) + h + 1 ≤ (pf a r h + 1) * ((a : ℤ) + 1) := by have hpos : (0 : ℝ) < (a : ℝ) + 1 := by positivity have l1 := Int.floor_le ((((r : ℤ) + h : ℤ) : ℝ) / ((a : ℝ) + 1)) have l2 := Int.lt_floor_add_one ((((r : ℤ) + h : ℤ) : ℝ) / ((a : ℝ) + 1)) rw [le_div_iff₀ hpos] at l1 rw [div_lt_iff₀ hpos] at l2 have c1 : pf a r h * ((a : ℤ) + 1) ≤ r + h := by unfold pf; exact_mod_cast l1 have c2 : (r : ℤ) + h < (pf a r h + 1) * ((a : ℤ) + 1) := by unfold pf; exact_mod_cast l2 exact ⟨c1, by omega⟩ theorem pf_range (a r : ℕ) (hr : r ≤ a) (h : ℤ) (h1 : -(a : ℤ) ≤ h) (h2 : h ≤ a) : -1 ≤ pf a r h ∧ pf a r h ≤ 1 := by rcases pf_cases a r hr h h1 h2 with ⟨_, e⟩ | ⟨_, _, e⟩ | ⟨_, e⟩ <;> omega theorem clip_of_bounds (b : ℕ) (v : ℤ) (h1 : -(b : ℤ) - 1 ≤ v) (h2 : v ≤ b) : CaballeroPeaks.clip b v = v := by unfold CaballeroPeaks.clip omega /-- Distinct primary patterns: `k^(r)` determines `r` for `r ≤ a`. -/theorem primaryPattern_inj (a r r' : ℕ) (hr : r ≤ a) (hr' : r' ≤ a) (h : ∀ i, primaryPattern a r i = primaryPattern a r' i) : r = r' := by have key : ∀ r r' : ℕ, r < r' → r' ≤ a → (∀ i, primaryPattern a r i = primaryPattern a r' i) → False := by intro r r' hlt hr' h obtain ⟨i, hi⟩ := exists_idx a (-(r' : ℤ)) (by omega) (by omega) have e := h i rw [primaryPattern_apply, primaryPattern_apply, hi] at e have e1 : pf a r (-(r' : ℤ)) = -1 := pf_eq a r _ (-1) (by omega) (by omega) have e2 : pf a r' (-(r' : ℤ)) = 0 := pf_eq a r' _ 0 (by omega) (by omega) omega rcases lt_trichotomy r r' with hlt | heq | hlt · exact (key r r' hlt hr' h).elim · exact heq · exact (key r' r hlt hr fun i => (h i).symm).elim /-! ### The cell vector on a phase interval -/ theorem floor_of_phase (a r j : ℕ) (θ Λ : ℝ) (hu : Λ - j ∈ phaseSet a (primaryPattern a r) θ) (i : Fin (2 * a + 1)) : ⌊Λ + ((((i : ℕ) : ℤ) - a : ℤ) : ℝ) * θ⌋ = (j : ℤ) + pf a r (((i : ℕ) : ℤ) - a) := by have h := hu.2.2 i rw [primaryPattern_apply] at h have e : Λ + ((((i : ℕ) : ℤ) - a : ℤ) : ℝ) * θ = (((j : ℤ) : ℝ)) + ((Λ - j) + ((((i : ℕ) : ℤ) - a : ℤ) : ℝ) * θ) := by push_cast; ring rw [e, Int.floor_intCast_add, h] theorem cellVec_of_phase (a b j r : ℕ) (hr : r ≤ a) (hj : j < b) (θ Λ : ℝ) (hu : Λ - j ∈ phaseSet a (primaryPattern a r) θ) (i : Fin (2 * a + 1)) : cellVec a b Λ θ i = (j : ℤ) + pf a r (((i : ℕ) : ℤ) - a) := by unfold cellVec rw [floor_of_phase a r j θ Λ hu i] obtain ⟨h1, h2⟩ := idx_bounds a i have := pf_range a r hr _ h1 h2 exact clip_of_bounds b _ (by omega) (by omega) /-! ### The two points of Part II, Proposition 6.3 -/ /-- `Λ` of the point `P_1(s) = ((s + 1/2)/(a+1), 1/(a+1))`. -/noncomputable def ptLam (a s : ℕ) : ℝ := ((s : ℝ) + 1 / 2) / ((a : ℝ) + 1) /-- `θ` of the point `P_1(s)`. -/noncomputable def ptTheta (a : ℕ) : ℝ := 1 / ((a : ℝ) + 1) theorem ptLam_add (a s : ℕ) (h : ℝ) : ptLam a s + h * ptTheta a = ((s : ℝ) + h + 1 / 2) / ((a : ℝ) + 1) := by unfold ptLam ptTheta ring theorem floor_P1 (a r j : ℕ) (h : ℤ) : ⌊ptLam a ((a + 1) * j + r) + (h : ℝ) * ptTheta a⌋ = (j : ℤ) + pf a r h := by obtain ⟨s1, s2⟩ := pf_spec a r h have hpos : (0 : ℝ) < (a : ℝ) + 1 := by positivity have c1 : ((pf a r h : ℤ) : ℝ) * ((a : ℝ) + 1) ≤ (r : ℝ) + h := by exact_mod_cast s1 have c2 : (r : ℝ) + h + 1 ≤ (((pf a r h : ℤ) : ℝ) + 1) * ((a : ℝ) + 1) := by exact_mod_cast s2 rw [ptLam_add, Int.floor_eq_iff, le_div_iff₀ hpos, div_lt_iff₀ hpos] push_cast constructor <;> nlinarith theorem cellVec_P1 (a b j r : ℕ) (hr : r ≤ a) (hj : j < b) (i : Fin (2 * a + 1)) : cellVec a b (ptLam a ((a + 1) * j + r)) (ptTheta a) i = (j : ℤ) + pf a r (((i : ℕ) : ℤ) - a) := by unfold cellVec rw [floor_P1] obtain ⟨h1, h2⟩ := idx_bounds a i have := pf_range a r hr _ h1 h2 exact clip_of_bounds b _ (by omega) (by omega) theorem offLines_P1 (a s : ℕ) : OffLines a (ptLam a s) (ptTheta a) := by intro h _ _ z e have hpos : (0 : ℝ) < (a : ℝ) + 1 := by positivity rw [ptLam_add, div_eq_iff hpos.ne'] at e have e2 : ((2 * ((s : ℤ) + h) + 1 : ℤ) : ℝ) = ((2 * (z * ((a : ℤ) + 1)) : ℤ) : ℝ) := by push_cast linarith have e3 : 2 * ((s : ℤ) + h) + 1 = 2 * (z * ((a : ℤ) + 1)) := by exact_mod_cast e2 generalize z * ((a : ℤ) + 1) = t at e3 omega theorem offLines_P2 (a b s : ℕ) : OffLines a ((s : ℝ) + 1 / 2) ((b : ℝ) + 1) := by intro h _ _ z e have e2 : ((2 * (s : ℤ) + 1 + 2 * (h * ((b : ℤ) + 1)) : ℤ) : ℝ) = ((2 * z : ℤ) : ℝ) := by push_cast linarith have e3 : 2 * (s : ℤ) + 1 + 2 * (h * ((b : ℤ) + 1)) = 2 * z := by exact_mod_cast e2 generalize h * ((b : ℤ) + 1) = t at e3 omega /-! ### The two numerations of `0, …, K-1` give the same multiset `Z` -/ theorem nat_lt_add_half (n m : ℕ) : (n : ℝ) < (m : ℝ) + 1 / 2 ↔ n ≤ m := by constructor · intro h by_contra hc have h2 : m + 1 ≤ n := by omega have h3 : (m : ℝ) + 1 ≤ n := by exact_mod_cast h2 linarith · intro h have h3 : (n : ℝ) ≤ m := by exact_mod_cast h linarith theorem card_filter_le_of_image (I : Finset (ℕ × ℕ)) (N : ℕ × ℕ → ℕ) (hinj : Set.InjOn N I) (K : ℕ) (himg : I.image N = range K) (m : ℕ) : (I.filter fun u => N u ≤ m).card = min K (m + 1) := by rw [← card_image_of_injOn (hinj.mono (coe_subset.mpr (filter_subset _ _))), ← filter_image (p := fun n => n ≤ m), himg] have e : (range K).filter (fun n => n ≤ m) = range (min K (m + 1)) := by ext n simp only [mem_filter, mem_range] omega rw [e, card_range] theorem map_before_eq (I : Finset (ℕ × ℕ)) (N : ℕ × ℕ → ℕ) (hinj : Set.InjOn N I) (K s : ℕ) (himg : I.image N = range K) (p q : ℕ × ℕ → ℝ) (hpq : ∀ u v, p u < q v ↔ N u ≤ N v + s) : I.val.map (before I p q) = (range K).val.map (fun n => min K (n + s + 1)) := by have h1 : ∀ v, before I p q v = min K (N v + s + 1) := by intro v unfold before rw [filter_congr (fun u _ => hpq u v)] exact card_filter_le_of_image I N hinj K himg _ rw [← himg, image_val_of_injOn hinj, Multiset.map_map] exact Multiset.map_congr rfl (fun v _ => h1 v) theorem image_eq_range (I : Finset (ℕ × ℕ)) (N : ℕ × ℕ → ℕ) (hinj : Set.InjOn N I) (K : ℕ) (hK : I.card = K) (hlt : ∀ u ∈ I, N u < K) : I.image N = range K := by apply eq_of_subset_of_card_le · intro n hn obtain ⟨u, hu, rfl⟩ := mem_image.mp hn exact mem_range.mpr (hlt u hu) · rw [card_range, card_image_of_injOn hinj, hK] /-- Mixed-radix numeration `x + m y`, injective for `x < m`. -/theorem numeration_inj (m x y x' y' : ℕ) (hx : x < m) (hx' : x' < m) (e : x + m * y = x' + m * y') : x = x' ∧ y = y' := by have h1 : x = x' := by have := congrArg (· % m) e simp only [Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt hx, Nat.mod_eq_of_lt hx'] at this exact this subst h1 exact ⟨rfl, Nat.eq_of_mul_eq_mul_left (by omega) (Nat.add_left_cancel e)⟩ /-- First numeration `N_1(i, j) = i + (a+1) j` (the positions at `P_1`). -/def num1 (a : ℕ) (u : ℕ × ℕ) : ℕ := u.1 + (a + 1) * u.2 /-- Second numeration `N_2(i, j) = j + (b+1) i` (the positions at `P_2`). -/def num2 (b : ℕ) (u : ℕ × ℕ) : ℕ := u.2 + (b + 1) * u.1 theorem injOn_num1 (a b : ℕ) : Set.InjOn (num1 a) ↑(range (a + 1) ×ˢ range (b + 1)) := by rintro ⟨i, j⟩ hu ⟨i', j'⟩ hu' e simp only [mem_coe, mem_product, mem_range] at hu hu' obtain ⟨h1, h2⟩ := numeration_inj (a + 1) i j i' j' hu.1 hu'.1 e rw [h1, h2] theorem injOn_num2 (a b : ℕ) : Set.InjOn (num2 b) ↑(range (a + 1) ×ˢ range (b + 1)) := by rintro ⟨i, j⟩ hu ⟨i', j'⟩ hu' e simp only [mem_coe, mem_product, mem_range] at hu hu' obtain ⟨h1, h2⟩ := numeration_inj (b + 1) j i j' i' hu.2 hu'.2 e rw [h1, h2] theorem image_num1 (a b : ℕ) : (range (a + 1) ×ˢ range (b + 1)).image (num1 a) = range ((a + 1) * (b + 1)) := by apply image_eq_range _ _ (injOn_num1 a b) · rw [card_product, card_range, card_range] · rintro ⟨i, j⟩ hu simp only [mem_product, mem_range] at hu unfold num1 nlinarith theorem image_num2 (a b : ℕ) : (range (a + 1) ×ˢ range (b + 1)).image (num2 b) = range ((a + 1) * (b + 1)) := by apply image_eq_range _ _ (injOn_num2 a b) · rw [card_product, card_range, card_range] · rintro ⟨i, j⟩ hu simp only [mem_product, mem_range] at hu unfold num2 nlinarith theorem Z_P1 (a b s : ℕ) : Z a b (cellVec a b (ptLam a s) (ptTheta a)) = ((range ((a + 1) * (b + 1))).val.map (fun n => min ((a + 1) * (b + 1)) (n + s + 1))).map (Nat.cast : ℕ → ℤ) := by rw [Z_eq a b _ _ (offLines_P1 a s)] congr 1 apply map_before_eq _ (num1 a) (injOn_num1 a b) _ s (image_num1 a b) intro u v have hpos : (0 : ℝ) < (a : ℝ) + 1 := by positivity have e1 : opos (ptTheta a) u = ((num1 a u : ℕ) : ℝ) / ((a : ℝ) + 1) := by unfold opos ptTheta num1 push_cast field_simp have e2 : cpos (ptLam a s) (ptTheta a) v = (((num1 a v + s : ℕ) : ℝ) + 1 / 2) / ((a : ℝ) + 1) := by unfold cpos ptLam ptTheta num1 push_cast field_simp ring rw [e1, e2, div_lt_div_iff_of_pos_right hpos] exact nat_lt_add_half _ _ theorem Z_P2 (a b s : ℕ) : Z a b (cellVec a b ((s : ℝ) + 1 / 2) ((b : ℝ) + 1)) = ((range ((a + 1) * (b + 1))).val.map (fun n => min ((a + 1) * (b + 1)) (n + s + 1))).map (Nat.cast : ℕ → ℤ) := by rw [Z_eq a b _ _ (offLines_P2 a b s)] congr 1 apply map_before_eq _ (num2 b) (injOn_num2 a b) _ s (image_num2 a b) intro u v have e1 : opos ((b : ℝ) + 1) u = ((num2 b u : ℕ) : ℝ) := by unfold opos num2 push_cast ring have e2 : cpos ((s : ℝ) + 1 / 2) ((b : ℝ) + 1) v = ((num2 b v + s : ℕ) : ℝ) + 1 / 2 := by unfold cpos num2 push_cast ring rw [e1, e2] exact nat_lt_add_half _ _ /-! ### Every point of a primary phase interval lies in an ambiguous cell -/ theorem cellVec_P2_zero (a b s : ℕ) : cellVec a b ((s : ℝ) + 1 / 2) ((b : ℝ) + 1) ⟨0, by omega⟩ = CaballeroPeaks.clip b ((s : ℤ) - a * ((b : ℤ) + 1)) := by unfold cellVec congr 1 rw [Int.floor_eq_iff] push_cast constructor <;> nlinarith /-- Part of the proof of Theorem 5: if `Λ = j + u` with `0 ≤ j ≤ b - 1` and `u` in the phase set of`k^(r)`, the cell vector of `(Λ, θ)` is that of `P_1((a+1)j + r)`, whose fibre also contains thevector of `P_2((a+1)j + r)`. -/theorem ambiguous_of_mem_phaseSet (a b : ℕ) (ha : 2 ≤ a) (hb : 1 ≤ b) (θ : ℝ) (hθ : 0 < θ) (j r : ℕ) (hj : j < b) (hr : r ≤ a) (Λ : ℝ) (hu : Λ - j ∈ phaseSet a (primaryPattern a r) θ) (hoff : OffLines a Λ θ) (hΛ : 0 < Λ) : Ambiguous a b (cellVec a b Λ θ) := by have hc : cellVec a b Λ θ = cellVec a b (ptLam a ((a + 1) * j + r)) (ptTheta a) := by funext i rw [cellVec_of_phase a b j r hr hj θ Λ hu i, cellVec_P1 a b j r hr hj i] refine ⟨⟨Λ, θ, hΛ, hθ, hoff, rfl⟩, cellVec a b (((a + 1) * j + r : ℕ) + 1 / 2) ((b : ℝ) + 1), ⟨_, _, by positivity, by positivity, offLines_P2 a b _, rfl⟩, ?_, ?_⟩ · intro e have e0 := congrFun e ⟨0, by omega⟩ rw [cellVec_P2_zero, cellVec_of_phase a b j r hr hj θ Λ hu] at e0 simp only [Nat.cast_zero, zero_sub] at e0 have hjb : (j : ℤ) + 1 ≤ b := by omega have ha0 : (0 : ℤ) ≤ a := by positivity have hprod := mul_le_mul_of_nonneg_left hjb ha0 have hlt : ((((a + 1) * j + r : ℕ) : ℤ) - a * ((b : ℤ) + 1)) < (j : ℤ) + pf a r (-(a : ℤ)) := by push_cast rcases pf_cases a r hr (-(a : ℤ)) (by omega) (by omega) with ⟨h1, e1⟩ | ⟨h1, _, e1⟩ | ⟨h1, _⟩ · rw [e1] have : (r : ℤ) + 1 ≤ a := by omega nlinarith · rw [e1] have : (r : ℤ) = a := by omega nlinarith · omega have hq := pf_range a r hr (-(a : ℤ)) (by omega) (by omega) unfold CaballeroPeaks.clip at e0 omega · rw [hc, Z_P1, Z_P2] /-! ### Theorem 5 -/ /-- The set whose length is `L_b(θ)`. -/def ambSet (a b : ℕ) (θ : ℝ) : Set ℝ := {Λ : ℝ | 0 < Λ ∧ Λ < (b : ℝ) + (a : ℝ) * θ ∧ OffLines a Λ θ ∧ Ambiguous a b (cellVec a b Λ θ)} theorem ambLength_eq (a b : ℕ) (θ : ℝ) : ambLength a b θ = (volume (ambSet a b θ)).toReal := rfl theorem volume_ambSet_le (a b : ℕ) (θ : ℝ) : volume (ambSet a b θ) ≤ ENNReal.ofReal ((b : ℝ) + (a : ℝ) * θ) := by have h : volume (ambSet a b θ) ≤ volume (Set.Ioo (0 : ℝ) ((b : ℝ) + (a : ℝ) * θ)) := measure_mono fun Λ hΛ => ⟨hΛ.1, hΛ.2.1⟩ rwa [Real.volume_Ioo, sub_zero] at h theorem ambLength_le (a b : ℕ) (θ : ℝ) (hθ : 0 ≤ θ) : ambLength a b θ ≤ (b : ℝ) + (a : ℝ) * θ := by rw [ambLength_eq] have := ENNReal.toReal_mono ENNReal.ofReal_ne_top (volume_ambSet_le a b θ) rwa [ENNReal.toReal_ofReal (by positivity)] at this /-- The lines `Λ + hθ ∈ ℤ` have length zero. -/theorem volume_lines (a : ℕ) (θ : ℝ) : volume {Λ : ℝ | ¬ OffLines a Λ θ} = 0 := by apply measure_mono_null _ ((Set.countable_range fun q : ℤ × ℤ => (q.2 : ℝ) - (q.1 : ℝ) * θ).measure_zero volume) intro Λ hΛ change ¬ OffLines a Λ θ at hΛ unfold OffLines at hΛ push Not at hΛ obtain ⟨h, _, _, z, hz⟩ := hΛ exact ⟨(h, z), by dsimp only; linarith⟩ /-- Two primary phase intervals `j + (phase set of k^(r))` meet only if they are the same. -/theorem block_unique (a : ℕ) (θ : ℝ) (p p' : ℕ × ℕ) (hr : p.2 ≤ a) (hr' : p'.2 ≤ a) (Λ : ℝ) (h1 : Λ - p.1 ∈ phaseSet a (primaryPattern a p.2) θ) (h2 : Λ - p'.1 ∈ phaseSet a (primaryPattern a p'.2) θ) : p = p' := by have hj : p.1 = p'.1 := by have f1 : ⌊Λ⌋ = (p.1 : ℤ) := by rw [Int.floor_eq_iff]; push_cast; constructor <;> linarith [h1.1, h1.2.1] have f2 : ⌊Λ⌋ = (p'.1 : ℤ) := by rw [Int.floor_eq_iff]; push_cast; constructor <;> linarith [h2.1, h2.2.1] omega have hr2 : p.2 = p'.2 := by rw [← hj] at h2 exact primaryPattern_inj a p.2 p'.2 hr hr' fun i => (h1.2.2 i).symm.trans (h2.2.2 i) exact Prod.ext hj hr2 /-- Theorem 5: for `a ≥ 2`, `b ≥ 1` and `θ > 0`, `L_b(θ) ≥ b U_a(θ)`. -/theorem lower_bound (a b : ℕ) (ha : 2 ≤ a) (hb : 1 ≤ b) (θ : ℝ) (hθ : 0 < θ) : (b : ℝ) * primaryPhase a θ ≤ ambLength a b θ := by rw [ambLength_eq] let T : Finset (ℕ × ℕ) := range b ×ˢ range (a + 1) let blk : ℕ × ℕ → Set ℝ := fun p => Set.Ioo ((p.1 : ℝ) + phaseLo a (primaryPattern a p.2) θ) ((p.1 : ℝ) + phaseHi a (primaryPattern a p.2) θ) have hmem : ∀ p, ∀ Λ ∈ blk p, Λ - p.1 ∈ phaseSet a (primaryPattern a p.2) θ := by intro p Λ hΛ apply Ioo_subset_phaseSet exact ⟨by linarith [hΛ.1], by linarith [hΛ.2]⟩ have hdisj : (T : Set (ℕ × ℕ)).PairwiseDisjoint blk := by intro p hp p' hp' hne rw [Function.onFun, Set.disjoint_left] intro Λ h1 h2 simp only [T, mem_coe, mem_product, mem_range] at hp hp' exact hne (block_unique a θ p p' (by omega) (by omega) Λ (hmem p Λ h1) (hmem p' Λ h2)) have hsub : (⋃ p ∈ T, blk p) \ {Λ : ℝ | ¬ OffLines a Λ θ} ⊆ ambSet a b θ := by rintro Λ ⟨hU, hL⟩ obtain ⟨p, hp, hΛ⟩ := Set.mem_iUnion₂.mp hU have hoff : OffLines a Λ θ := not_not.mp hL have hu := hmem p Λ hΛ simp only [T, mem_product, mem_range] at hp have hpos : 0 < Λ := by have := hu.1 have : (0 : ℝ) ≤ p.1 := Nat.cast_nonneg _ linarith refine ⟨hpos, ?_, hoff, ambiguous_of_mem_phaseSet a b ha hb θ hθ p.1 p.2 hp.1 (by omega) Λ hu hoff hpos⟩ have := hu.2.1 have h1 : (p.1 : ℝ) + 1 ≤ b := by exact_mod_cast hp.1 have h2 : 0 ≤ (a : ℝ) * θ := by positivity linarith have hfin : volume (ambSet a b θ) ≠ ⊤ := ne_top_of_le_ne_top ENNReal.ofReal_ne_top (volume_ambSet_le a b θ) have hU : volume (⋃ p ∈ T, blk p) = ∑ p ∈ T, ENNReal.ofReal (phaseHi a (primaryPattern a p.2) θ - phaseLo a (primaryPattern a p.2) θ) := by rw [measure_biUnion_finset hdisj (fun p _ => measurableSet_Ioo)] apply sum_congr rfl intro p _ rw [Real.volume_Ioo] congr 1 ring have hsum : (∑ p ∈ T, ENNReal.ofReal (phaseHi a (primaryPattern a p.2) θ - phaseLo a (primaryPattern a p.2) θ)).toReal = (b : ℝ) * primaryPhase a θ := by rw [ENNReal.toReal_sum (fun p _ => ENNReal.ofReal_ne_top), sum_product] have : ∀ x ∈ range b, ∑ y ∈ range (a + 1), (ENNReal.ofReal (phaseHi a (primaryPattern a (x, y).2) θ - phaseLo a (primaryPattern a (x, y).2) θ)).toReal = primaryPhase a θ := by intro x _ unfold primaryPhase apply sum_congr rfl intro y _ rw [ENNReal.toReal_ofReal', phaseWidth_eq_hi_sub_lo] rw [sum_congr rfl this, sum_const, card_range, nsmul_eq_mul] calc (b : ℝ) * primaryPhase a θ = (volume ((⋃ p ∈ T, blk p) \ {Λ : ℝ | ¬ OffLines a Λ θ})).toReal := by rw [measure_sdiff_null (volume_lines a θ), hU, hsum] _ ≤ (volume (ambSet a b θ)).toReal := ENNReal.toReal_mono hfin (measure_mono hsub) /-- Theorem 5, consequence: `liminf_b A_{a,b}(θ) ≥ U_a(θ)` for every `θ > 0`. -/theorem le_liminf_ambProportion (a : ℕ) (ha : 2 ≤ a) (θ : ℝ) (hθ : 0 < θ) : primaryPhase a θ ≤ Filter.liminf (fun b : ℕ => ambProportion a b θ) Filter.atTop := by have hden : ∀ b : ℕ, 0 < (b : ℝ) + (a : ℝ) * θ := fun b => by have : (0 : ℝ) < a := by exact_mod_cast (show 0 < a by omega) positivity let g : ℕ → ℝ := fun b => (b : ℝ) / ((b : ℝ) + (a : ℝ) * θ) * primaryPhase a θ have hg : Tendsto g atTop (𝓝 (primaryPhase a θ)) := by have := (tendsto_natCast_div_add_atTop ((a : ℝ) * θ)).mul_const (primaryPhase a θ) rwa [one_mul] at this have hle : ∀ᶠ b in atTop, g b ≤ ambProportion a b θ := by filter_upwards [eventually_ge_atTop 1] with b hb unfold ambProportion simp only [g] rw [div_mul_eq_mul_div, div_le_div_iff_of_pos_right (hden b)] exact lower_bound a b ha hb θ hθ have hco : IsCoboundedUnder (· ≥ ·) atTop (fun b : ℕ => ambProportion a b θ) := isCoboundedUnder_ge_of_le atTop (x := 1) fun b => div_le_one_of_le₀ (ambLength_le a b θ hθ.le) (hden b).le calc primaryPhase a θ = Filter.liminf g atTop := hg.liminf_eq.symm _ ≤ Filter.liminf (fun b : ℕ => ambProportion a b θ) atTop := Filter.liminf_le_liminf hle (hv := hg.isBoundedUnder_ge) (hu := hco) end CaballeroLowerBound