/-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.AngularPrimaryPhase /-!# The explicit rate on the first strip (Caballero, Part IV, end of the proof of Theorem 1) End of the proof of Theorem 1 of Part IV: for a >= 2, 0 < theta <= 1/a and b >= 1, the ambiguousproportion satisfies A_{a,b}(theta) - U_a(theta) in [-1/b, (12a+11)/b]. The proof follows the paper:R = L_b(theta) - b U_a(theta) lies in [0, 12a+11] by Theorem 1(CaballeroPrimaryPhase.primary_phase), 0 <= U_a <= 1 on the strip (primaryPhase_nonneg and thethree-piece formula), a theta <= 1, and A - U = (R - a theta U)/(b + a theta). A_{a,b} isCaballeroLowerBound.ambProportion and U_a is CaballeroWidths.primaryPhase. ## Main results * `CaballeroRate.ambProportion_sub_primaryPhase_mem`: End of the proof of Theorem 1: A_{a,b}(theta) - U_a(theta) lies in [-1/b, (12a+11)/b] for 0 < theta <= 1/a, b >= 1* `CaballeroRate.primaryPhase_le_one`: U_a(theta) <= 1 on the first strip 0 < theta <= 1/a ## 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 CaballeroRate open CaballeroLowerBound CaballeroWidths /-- On the first strip the primary phase function is at most `1`. -/theorem primaryPhase_le_one (a : ℕ) (ha : 2 ≤ a) (θ : ℝ) (hθ0 : 0 < θ) (hθ : θ ≤ 1 / (a : ℝ)) : primaryPhase a θ ≤ 1 := by obtain ⟨-, -, -, h1, h2, h3⟩ := CaballeroPrimaryPhase.primary_phase a ha have ha0 : (0 : ℝ) < a := by exact_mod_cast (by omega : 0 < a) have ha2 : (2 : ℝ) ≤ a := by exact_mod_cast ha rcases le_or_gt θ (1 / ((a : ℝ) + 2)) with hA | hA · rw [h1 θ hθ0 hA] have : θ * ((a : ℝ) + 2) ≤ 1 := by rw [le_div_iff₀ (by positivity)] at hA linarith nlinarith rcases le_or_gt θ (1 / ((a : ℝ) + 1)) with hB | hB · rw [h2 θ hA.le hB] have : θ * ((a : ℝ) + 1) ≤ 1 := by rw [le_div_iff₀ (by positivity)] at hB linarith nlinarith · rw [h3 θ hB.le hθ] have : 1 < θ * ((a : ℝ) + 1) := by rw [div_lt_iff₀ (by positivity)] at hB linarith nlinarith /-- End of the proof of Theorem 1 (Part IV): with `R = L_b(θ) - b U_a(θ) ∈ [0, 12a+11]`,`0 ≤ U_a ≤ 1` and `aθ ≤ 1`, for every `θ ∈ (0, 1/a]` and every `b ≥ 1`,`A_{a,b}(θ) - U_a(θ) ∈ [-1/b, (12a+11)/b]`. -/theorem ambProportion_sub_primaryPhase_mem (a : ℕ) (ha : 2 ≤ a) (θ : ℝ) (hθ0 : 0 < θ) (hθ : θ ≤ 1 / (a : ℝ)) (b : ℕ) (hb : 1 ≤ b) : -(1 / (b : ℝ)) ≤ ambProportion a b θ - primaryPhase a θ ∧ ambProportion a b θ - primaryPhase a θ ≤ (12 * (a : ℝ) + 11) / (b : ℝ) := by obtain ⟨hbound, -⟩ := CaballeroPrimaryPhase.primary_phase a ha obtain ⟨hl, hu⟩ := hbound θ hθ0 hθ b hb have haθ : (a : ℝ) * θ ≤ 1 := CaballeroMarker.aθ_le (by omega) hθ have haθ0 : 0 ≤ (a : ℝ) * θ := by positivity have hb0 : (0 : ℝ) < b := by exact_mod_cast hb have hD : (b : ℝ) ≤ (b : ℝ) + a * θ := by linarith have hD0 : 0 < (b : ℝ) + a * θ := lt_of_lt_of_le hb0 hD have hU0 := CaballeroPrimaryPhase.primaryPhase_nonneg a θ have hU1 := primaryPhase_le_one a ha θ hθ0 hθ have haU : (a : ℝ) * θ * primaryPhase a θ ≤ 1 := by have : (a : ℝ) * θ * primaryPhase a θ ≤ 1 * 1 := mul_le_mul haθ hU1 hU0 (by norm_num) linarith have haU0 : 0 ≤ (a : ℝ) * θ * primaryPhase a θ := by positivity have key : ambProportion a b θ - primaryPhase a θ = (ambLength a b θ - (b : ℝ) * primaryPhase a θ - (a : ℝ) * θ * primaryPhase a θ) / ((b : ℝ) + a * θ) := by unfold ambProportion field_simp ring rw [key] have h12 : (0 : ℝ) ≤ 12 * (a : ℝ) + 11 := by positivity constructor · rw [le_div_iff₀ hD0] have hnum : -1 ≤ ambLength a b θ - (b : ℝ) * primaryPhase a θ - (a : ℝ) * θ * primaryPhase a θ := by linarith have hfrac : -(1 / (b : ℝ)) * ((b : ℝ) + a * θ) ≤ -1 := by have : 1 ≤ 1 / (b : ℝ) * ((b : ℝ) + a * θ) := by rw [div_mul_eq_mul_div, one_mul, le_div_iff₀ hb0] linarith linarith linarith · calc _ ≤ (12 * (a : ℝ) + 11) / ((b : ℝ) + a * θ) := by apply div_le_div_of_nonneg_right _ hD0.le linarith _ ≤ _ := div_le_div_of_nonneg_left h12 hb0 hD end CaballeroRate