/-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.AngularGeneralApublic import Formalizations.Combinatorics.Caballero.AngularWindowspublic import Formalizations.Combinatorics.Caballero.AngularUpperTailpublic import Formalizations.Combinatorics.Caballero.AngularCentralInjectivepublic import Formalizations.Combinatorics.Caballero.AngularBlockpublic import Formalizations.Combinatorics.Caballero.AngularMarkerpublic import Formalizations.Combinatorics.Caballero.AngularBandpublic import Mathlib.Algebra.Order.Floor.Ringpublic import Mathlib.Algebra.BigOperators.Ring.Finsetpublic import Mathlib.Order.Interval.Finset.Natpublic import Mathlib.NumberTheory.Real.Irrationalpublic import Mathlib.Combinatorics.Pigeonhole /-!# Central rigidity of the cells of the section for general a (Caballero, Part IV) Proposition 14 of Part IV. For a >= 2 and 0 < theta <= 1/a, a central cell of the section at theta(the vector c of a point (Lambda, theta) off the lines with 4a+5 <= floor Lambda <= b - C_a) that isnot of the form O_1(s) has a singleton fibre: every realisable vector d with Z(d) = Z(c) equals c.The fibre is taken over all realisable vectors, realised at any point (Lambda', theta') off thelines. Stated for any b (the paper fixes b >= 1; centrality forces b to be large). The module buildson the base module of Part IV and on its lemmas on window sums, the upper tail, the local block, thesingle marker and the band. ## Main results * `CaballeroRigid.central_rigidity`: Proposition 14: a central cell with 0 < theta <= 1/a that is not of the form O_1(s) has a singleton fibre ## 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 CaballeroRigid open Finset CaballeroGeneralA CaballeroMarker /-! ### Stability of the floors near a point off the lines -/ /-- Near a point off the lines, the floors `⌊Λ + hθ'⌋` do not change with `θ'`. -/theorem floor_stable (a : ℕ) (Λ θ : ℝ) (hoff : OffLines a Λ θ) : ∃ ε : ℝ, 0 < ε ∧ ∀ θ' : ℝ, |θ' - θ| < ε → OffLines a Λ θ' ∧ ∀ h : ℤ, -(a : ℤ) ≤ h → h ≤ a → ⌊Λ + (h : ℝ) * θ'⌋ = ⌊Λ + (h : ℝ) * θ⌋ := by set g : ℤ → ℝ := fun h => min (Int.fract (Λ + (h : ℝ) * θ)) (1 - Int.fract (Λ + (h : ℝ) * θ)) with hg have hne : (Icc (-(a : ℤ)) a).Nonempty := ⟨0, by simp⟩ obtain ⟨h0, hh0, hmin⟩ := (Icc (-(a : ℤ)) a).exists_min_image g hne have hgpos : ∀ h : ℤ, -(a : ℤ) ≤ h → h ≤ a → 0 < g h := by intro h h1 h2 have hfr : Int.fract (Λ + (h : ℝ) * θ) ≠ 0 := by intro e rw [Int.fract_eq_iff] at e obtain ⟨-, -, z, hz⟩ := e exact hoff h h1 h2 z (by linarith) have h1' := Int.fract_nonneg (Λ + (h : ℝ) * θ) have h2' := Int.fract_lt_one (Λ + (h : ℝ) * θ) simp only [hg] apply lt_min · exact lt_of_le_of_ne h1' (Ne.symm hfr) · linarith have hδ : 0 < g h0 := hgpos h0 (mem_Icc.1 hh0).1 (mem_Icc.1 hh0).2 refine ⟨g h0 / ((a : ℝ) + 1), by positivity, fun θ' hθ' => ?_⟩ have key : ∀ h : ℤ, -(a : ℤ) ≤ h → h ≤ a → (⌊Λ + (h : ℝ) * θ⌋ : ℝ) < Λ + (h : ℝ) * θ' ∧ Λ + (h : ℝ) * θ' < (⌊Λ + (h : ℝ) * θ⌋ : ℝ) + 1 := by intro h h1 h2 have hgh : g h0 ≤ g h := hmin h (mem_Icc.2 ⟨h1, h2⟩) have hmin1 : g h ≤ Int.fract (Λ + (h : ℝ) * θ) := min_le_left _ _ have hmin2 : g h ≤ 1 - Int.fract (Λ + (h : ℝ) * θ) := min_le_right _ _ have hfl := Int.self_sub_floor (Λ + (h : ℝ) * θ) have habs : |(h : ℝ) * (θ' - θ)| < g h0 := by rw [abs_mul] have hh : |(h : ℝ)| ≤ a := by have h1r : -(a : ℝ) ≤ h := by exact_mod_cast h1 have h2r : (h : ℝ) ≤ a := by exact_mod_cast h2 rw [abs_le] exact ⟨h1r, h2r⟩ have hd : |θ' - θ| * ((a : ℝ) + 1) < g h0 := by have := (lt_div_iff₀ (by positivity : (0 : ℝ) < (a : ℝ) + 1)).1 hθ' exact this have h3 : 0 ≤ |θ' - θ| := abs_nonneg _ nlinarith [abs_nonneg (h : ℝ)] rw [abs_lt] at habs constructor <;> nlinarith refine ⟨fun h h1 h2 z hz => ?_, fun h h1 h2 => ?_⟩ · obtain ⟨k1, k2⟩ := key h h1 h2 have k3 : (⌊Λ + (h : ℝ) * θ⌋ : ℝ) < z := by linarith have k4 : (z : ℝ) < (⌊Λ + (h : ℝ) * θ⌋ : ℝ) + 1 := by linarith have a1 : ⌊Λ + (h : ℝ) * θ⌋ < z := by exact_mod_cast k3 have a2 : z < ⌊Λ + (h : ℝ) * θ⌋ + 1 := by exact_mod_cast k4 omega · obtain ⟨k1, k2⟩ := key h h1 h2 rw [Int.floor_eq_iff] exact ⟨k1.le, k2⟩ /-- A realisable vector is realised at a point with irrational `θ`. -/theorem exists_irrational_point (a b : ℕ) (d : Vec a) (hd : Realisable a b d) : ∃ Λ' θ' : ℝ, 0 < Λ' ∧ 0 < θ' ∧ Irrational θ' ∧ OffLines a Λ' θ' ∧ cellVec a b Λ' θ' = d := by obtain ⟨Λ, θ, hΛ, hθ, hoff, rfl⟩ := hd obtain ⟨ε, hε, hst⟩ := floor_stable a Λ θ hoff have hε' : 0 < min ε θ := lt_min hε hθ obtain ⟨q, hq, hq1, hq2⟩ := exists_irrational_btwn (show θ < θ + min ε θ by linarith) have hqε : |q - θ| < ε := by rw [abs_lt] have := min_le_left ε θ constructor <;> linarith obtain ⟨hoff', hfl⟩ := hst q hqε refine ⟨Λ, q, hΛ, by linarith, hq, hoff', ?_⟩ funext k unfold cellVec rw [hfl ((k : ℕ) - a) (by omega) (by omega)] /-- At `θ = 1/a` the cell can be realised at a smaller `θ`, strictly below `1/a`. -/theorem exists_strict_point (a b : ℕ) (Λ θ : ℝ) (hθ0 : 0 < θ) (hθ : θ ≤ 1 / (a : ℝ)) (hoff : OffLines a Λ θ) : ∃ θ1 : ℝ, 0 < θ1 ∧ θ1 < 1 / (a : ℝ) ∧ OffLines a Λ θ1 ∧ cellVec a b Λ θ1 = cellVec a b Λ θ := by obtain ⟨ε, hε, hst⟩ := floor_stable a Λ θ hoff have hε' : 0 < min ε θ := lt_min hε hθ0 have h1 := min_le_left ε θ have h2 := min_le_right ε θ have hθ1 : |(θ - min ε θ / 2) - θ| < ε := by rw [abs_lt] constructor <;> linarith obtain ⟨hoff', hfl⟩ := hst _ hθ1 refine ⟨θ - min ε θ / 2, by linarith, by linarith, hoff', ?_⟩ funext k unfold cellVec rw [hfl ((k : ℕ) - a) (by omega) (by omega)] /-! ### The window mass `G` of the partner (the function `G` of the paper) -/ /-- Length of `[x - Λ', x) ∩ [iθ', iθ' + b]`, written as `max 0 (min (Λ', x - iθ', iθ' + b - x + Λ',b))`, which is `min(x, u) - max(x - Λ', l)` for `l = iθ'`, `u = iθ' + b`. -/noncomputable def rowLen (b : ℕ) (θ' Λ' : ℝ) (i : ℕ) (x : ℝ) : ℝ := max (min (min Λ' (x - i * θ')) (min (i * θ' + b - x + Λ') b)) 0 /-- `G(x) = ∫_{x-Λ'}^{x} ρ(y) dy`, the sum over the opening rows `i = 0, …, a` of the lengths ofthe windows `[x - Λ', x)` inside the rows `[iθ', iθ' + b]`. -/noncomputable def windowMass (a b : ℕ) (θ' Λ' x : ℝ) : ℝ := ∑ i ∈ range (a + 1), rowLen b θ' Λ' i x /-- The inequality (B) of the paper: `|G(p'_k) - G(Λ')| ≤ 3m` at every opening position `p'_k ≥ Λ'`. -/def BandBound (a b : ℕ) (Λ' θ' : ℝ) : Prop := ∀ y ∈ openingSet a b θ', Λ' ≤ y → |windowMass a b θ' Λ' y - windowMass a b θ' Λ' Λ'| ≤ 3 * ((a : ℝ) + 1) theorem rowLen_lip (b : ℕ) (θ' Λ' : ℝ) (i : ℕ) (x x' : ℝ) : |rowLen b θ' Λ' i x - rowLen b θ' Λ' i x'| ≤ |x - x'| := by unfold rowLen refine (abs_max_sub_max_le_abs _ _ _).trans ?_ have h1 := abs_min_sub_min_le_max Λ' (x - i * θ') Λ' (x' - i * θ') have h2 := abs_min_sub_min_le_max (i * θ' + b - x + Λ') (b : ℝ) (i * θ' + b - x' + Λ') (b : ℝ) have e1 : |Λ' - Λ'| = 0 := by simp have e2 : |(x - i * θ') - (x' - i * θ')| = |x - x'| := by congr 1; ring have e3 : |(i * θ' + b - x + Λ') - (i * θ' + b - x' + Λ')| = |x - x'| := by have : (i * θ' + b - x + Λ') - (i * θ' + b - x' + Λ') = -(x - x') := by ring rw [this, abs_neg] have e4 : |(b : ℝ) - b| = 0 := by simp rw [e1, e2] at h1 rw [e3, e4] at h2 have k1 := h1.trans (max_le (abs_nonneg _) le_rfl) have k2 := h2.trans (max_le le_rfl (abs_nonneg _)) have h3 := abs_min_sub_min_le_max (min Λ' (x - i * θ')) (min (i * θ' + b - x + Λ') (b : ℝ)) (min Λ' (x' - i * θ')) (min (i * θ' + b - x' + Λ') (b : ℝ)) exact h3.trans (max_le k1 k2) theorem windowMass_lip (a b : ℕ) (θ' Λ' x x' : ℝ) : |windowMass a b θ' Λ' x - windowMass a b θ' Λ' x'| ≤ ((a : ℝ) + 1) * |x - x'| := by unfold windowMass rw [← sum_sub_distrib] refine (abs_sum_le_sum_abs _ _).trans ?_ calc ∑ i ∈ range (a + 1), |rowLen b θ' Λ' i x - rowLen b θ' Λ' i x'| ≤ ∑ _i ∈ range (a + 1), |x - x'| := sum_le_sum (fun i _ => rowLen_lip b θ' Λ' i x x') _ = ((a : ℝ) + 1) * |x - x'| := by simp theorem windowMass_top (a b : ℕ) (θ' Λ' : ℝ) (hθ' : 0 ≤ θ') (hΛ' : 0 < Λ') (hx : Λ' + a * θ' < b) : windowMass a b θ' Λ' (Λ' + a * θ') = ((a : ℝ) + 1) * Λ' := by unfold windowMass rw [sum_congr rfl (g := fun _ => Λ')] · simp intro i hi have hi' : (i : ℝ) ≤ a := by exact_mod_cast (by simpa [Nat.lt_succ_iff] using hi : i ≤ a) have hiθ : (i : ℝ) * θ' ≤ a * θ' := mul_le_mul_of_nonneg_right hi' hθ' have hiθ0 : 0 ≤ (i : ℝ) * θ' := by positivity have haθ0 : 0 ≤ (a : ℝ) * θ' := by positivity unfold rowLen rw [min_eq_left (show Λ' ≤ Λ' + a * θ' - i * θ' by linarith), min_eq_left (le_min (show Λ' ≤ i * θ' + b - (Λ' + a * θ') + Λ' by linarith) (show Λ' ≤ (b : ℝ) by linarith)), max_eq_left hΛ'.le] theorem rowLen_at (b : ℕ) (θ' Λ' : ℝ) (i : ℕ) (hθ' : 0 ≤ θ') (hΛ'b : Λ' < b) : rowLen b θ' Λ' i Λ' = max (Λ' - i * θ') 0 := by have hiθ0 : 0 ≤ (i : ℝ) * θ' := by positivity unfold rowLen rw [min_eq_right (show Λ' - i * θ' ≤ Λ' by linarith), min_eq_left (le_min (show Λ' - i * θ' ≤ i * θ' + b - Λ' + Λ' by linarith) (show Λ' - i * θ' ≤ (b : ℝ) by linarith))] theorem sum_range_cast (n : ℕ) : ∑ i ∈ range n, (i : ℝ) = n * (n - 1) / 2 := by induction n with | zero => simp | succ n ih => rw [sum_range_succ, ih]; push_cast; ring theorem windowMass_at_A (a b : ℕ) (θ' Λ' : ℝ) (hθ' : 0 ≤ θ') (hΛ'b : Λ' < b) (hA : a * θ' ≤ Λ') : windowMass a b θ' Λ' Λ' = ((a : ℝ) + 1) * Λ' - θ' * ((a : ℝ) * ((a : ℝ) + 1) / 2) := by unfold windowMass rw [sum_congr rfl (g := fun i : ℕ => Λ' - i * θ')] · rw [sum_sub_distrib, ← sum_mul, sum_range_cast] simp only [sum_const, card_range, nsmul_eq_mul] push_cast ring intro i hi have hi' : (i : ℝ) ≤ a := by exact_mod_cast (by simpa [Nat.lt_succ_iff] using hi : i ≤ a) have hiθ : (i : ℝ) * θ' ≤ a * θ' := mul_le_mul_of_nonneg_right hi' hθ' rw [rowLen_at b θ' Λ' i hθ' hΛ'b] exact max_eq_left (by linarith) theorem windowMass_at_B (a b : ℕ) (θ' Λ' : ℝ) (hθ' : 0 ≤ θ') (hΛ'b : Λ' < b) (hΛ' : 0 < Λ') (hB : Λ' < a * θ') : windowMass a b θ' Λ' Λ' ≤ (a : ℝ) * Λ' := by unfold windowMass rw [sum_range_succ, rowLen_at b θ' Λ' a hθ' hΛ'b, max_eq_right (by linarith)] calc ∑ i ∈ range a, rowLen b θ' Λ' i Λ' + 0 ≤ ∑ _i ∈ range a, Λ' + 0 := by gcongr with i hi rw [rowLen_at b θ' Λ' i hθ' hΛ'b] have : 0 ≤ (i : ℝ) * θ' := by positivity exact max_le (by linarith) hΛ'.le _ = (a : ℝ) * Λ' := by simp /-- If `0 < x < b`, the first opening of row `0` at or after `x` is an opening position within `1`of `x`. -/theorem ceil_opening (a b : ℕ) (θ' x : ℝ) (hx0 : 0 < x) (hxb : x < b) : ∃ y ∈ openingSet a b θ', x ≤ y ∧ y < x + 1 := by have hc1 : (0 : ℤ) < ⌈x⌉ := Int.ceil_pos.2 hx0 have hc2 : ⌈x⌉ ≤ (b : ℤ) := Int.ceil_le.2 (by exact_mod_cast hxb.le) refine ⟨((⌈x⌉.toNat : ℕ) : ℝ), ?_, ?_, ?_⟩ · unfold openingSet rw [mem_image] refine ⟨(0, ⌈x⌉.toNat), ?_, ?_⟩ · simp only [mem_product, mem_range] omega · simp [opos] · have : ((⌈x⌉.toNat : ℕ) : ℝ) = ((⌈x⌉ : ℤ) : ℝ) := by rw [← Int.cast_natCast, Int.toNat_of_nonneg hc1.le] rw [this] exact Int.le_ceil x · have : ((⌈x⌉.toNat : ℕ) : ℝ) = ((⌈x⌉ : ℤ) : ℝ) := by rw [← Int.cast_natCast, Int.toNat_of_nonneg hc1.le] rw [this] exact Int.ceil_lt_add_one x theorem zeroCount_le (a b : ℕ) (θ' Λ' : ℝ) (hθ' : 0 < θ') (N : ℕ) (hN : Λ' ≤ N) : zeroCount a b θ' Λ' ≤ (a + 1) * N := by unfold zeroCount openingSet rw [Finset.filter_image] refine card_image_le.trans ?_ calc _ ≤ (range (a + 1) ×ˢ range N).card := by apply card_le_card intro v hv simp only [mem_filter, mem_product, mem_range] at hv ⊢ refine ⟨hv.1.1, ?_⟩ have h1 : (0 : ℝ) ≤ (v.1 : ℝ) * θ' := by positivity have h2 : (v.2 : ℝ) < N := by have := hv.2.2 unfold opos at this linarith exact_mod_cast h2 _ = (a + 1) * N := by simp /-! ### Vectors: spread and coordinates -/ theorem spread_le_of_bounds {a : ℕ} (c : Vec a) (lo hi : ℤ) (h : ∀ k, lo ≤ c k ∧ c k ≤ hi) : spread c ≤ hi - lo := by unfold spread exact sub_le_sub (Finset.sup'_le _ _ fun k _ => (h k).2) (Finset.le_inf' _ _ fun k _ => (h k).1) theorem vec_apply_eq_coord {a : ℕ} (c : Vec a) (k : Fin (2 * a + 1)) : c k = coord c (((k : ℕ) : ℤ) - a) := by have hk := k.2 rw [coord_eq c _ (by omega) (by omega)] congr 1 apply Fin.ext simp only omega /-! ### Cases A and B (the partner has `Λ' + aθ' < b`) -/ theorem caseA (a b : ℕ) (ha : 2 ≤ a) (Λ θ : ℝ) (hθ0 : 0 < θ) (hθ : θ < 1 / (a : ℝ)) (hoff : OffLines a Λ θ) (hc : IsCentral a b Λ) (Λ' θ' : ℝ) (hΛ' : 0 < Λ') (hθ'0 : 0 < θ') (hoff' : OffLines a Λ' θ') (hZ : Z a b (cellVec a b Λ' θ') = Z a b (cellVec a b Λ θ)) (hx : Λ' + a * θ' < b) (hA : a * θ' ≤ Λ') (hB : BandBound a b Λ' θ') : cellVec a b Λ' θ' = cellVec a b Λ θ := by have ha1 : 1 ≤ a := by omega have haθ : (a : ℝ) * θ ≤ 1 := aθ_le ha1 hθ.le have hCa : Ca a ≥ 22 := by unfold Ca; omega have hc' := hc obtain ⟨hJ1, hJ2⟩ := hc have hb1 : 1 ≤ b := by omega have hm : (0 : ℝ) < (a : ℝ) + 1 := by positivity have haθ'0 : 0 ≤ (a : ℝ) * θ' := by positivity have hxpos : 0 < Λ' + a * θ' := by linarith obtain ⟨y, hy, hxy, hyx⟩ := ceil_opening a b θ' _ hxpos hx have hGx := windowMass_top a b θ' Λ' hθ'0.le hΛ' hx have hGL := windowMass_at_A a b θ' Λ' hθ'0.le (by linarith) hA have hlip := windowMass_lip a b θ' Λ' y (Λ' + a * θ') have hBy := hB y hy (by linarith) rw [abs_of_nonneg (by linarith : 0 ≤ y - (Λ' + a * θ'))] at hlip have hlip' := (abs_le.1 hlip).1 rw [abs_le] at hBy have h8 : (a : ℝ) * θ' ≤ 8 := by by_contra hcon push Not at hcon nlinarith [mul_pos (sub_pos.2 hcon) hm, hBy.2, hlip'] -- the vector of `d` have hdk : ∀ k : Fin (2 * a + 1), ⌊Λ' + a * θ'⌋ - 16 ≤ cellVec a b Λ' θ' k ∧ cellVec a b Λ' θ' k ≤ ⌊Λ' + a * θ'⌋ ∧ 0 ≤ cellVec a b Λ' θ' k ∧ cellVec a b Λ' θ' k ≤ (b : ℤ) - 1 := by intro k have hk := k.2 have hk0 : (0 : ℝ) ≤ ((k : ℕ) : ℝ) := Nat.cast_nonneg _ have hk1 : ((k : ℕ) : ℝ) ≤ 2 * a := by exact_mod_cast (by omega : (k : ℕ) ≤ 2 * a) have p1 : ((k : ℕ) : ℝ) * θ' ≤ 2 * a * θ' := mul_le_mul_of_nonneg_right hk1 hθ'0.le have p2 : 0 ≤ ((k : ℕ) : ℝ) * θ' := by positivity have hfl1 : ⌊Λ' + ((((k : ℕ) : ℤ) - a : ℤ) : ℝ) * θ'⌋ ≤ ⌊Λ' + a * θ'⌋ := by apply Int.floor_mono; push_cast; nlinarith have hfl2 : ⌊Λ' + a * θ'⌋ - 16 ≤ ⌊Λ' + ((((k : ℕ) : ℤ) - a : ℤ) : ℝ) * θ'⌋ := by have : ⌊Λ' + a * θ' - 16⌋ ≤ ⌊Λ' + ((((k : ℕ) : ℤ) - a : ℤ) : ℝ) * θ'⌋ := by apply Int.floor_mono; push_cast; nlinarith have e : ⌊Λ' + a * θ' - 16⌋ = ⌊Λ' + a * θ'⌋ - 16 := by simp omega have hfl3 : 0 ≤ ⌊Λ' + ((((k : ℕ) : ℤ) - a : ℤ) : ℝ) * θ'⌋ := by apply Int.floor_nonneg.2; push_cast; nlinarith have hfl4 : ⌊Λ' + a * θ'⌋ ≤ (b : ℤ) - 1 := by have : ⌊Λ' + a * θ'⌋ < b := Int.floor_lt.2 (by exact_mod_cast hx) omega have hcl := CaballeroPeaks.clip_casos b ⌊Λ' + ((((k : ℕ) : ℤ) - a : ℤ) : ℝ) * θ'⌋ (by omega) unfold cellVec omega have hdb : ∀ k, -1 ≤ cellVec a b Λ' θ' k ∧ cellVec a b Λ' θ' k ≤ (b : ℤ) - 1 := fun k => ⟨by have := (hdk k).2.2.1; omega, (hdk k).2.2.2⟩ have hds : spread (cellVec a b Λ' θ') ≤ 16 := by have := spread_le_of_bounds (cellVec a b Λ' θ') (⌊Λ' + a * θ'⌋ - 16) ⌊Λ' + a * θ'⌋ (fun k => ⟨(hdk k).1, (hdk k).2.1⟩) omega -- the vector of `c` have hck : ∀ k : Fin (2 * a + 1), ⌊Λ⌋ - 1 ≤ cellVec a b Λ θ k ∧ cellVec a b Λ θ k ≤ ⌊Λ⌋ + 1 := by intro k have hk := k.2 rw [vec_apply_eq_coord (cellVec a b Λ θ) k, coord_eq_floor a b Λ θ hθ0 haθ hc' _ (by omega) (by omega)] exact floor_add_mul_bounds Λ θ a hθ0 haθ _ (by omega) (by omega) have hcE : CentralE a b 16 (cellVec a b Λ θ) := by refine ⟨fun k => ⟨by have := (hck k).1; omega, by have := (hck k).2; omega⟩, ?_⟩ have := spread_le_of_bounds (cellVec a b Λ θ) (⌊Λ⌋ - 1) (⌊Λ⌋ + 1) hck omega have hΛpos : 0 < Λ := by have : (13 : ℝ) ≤ ⌊Λ⌋ := by exact_mod_cast (by omega : (13 : ℤ) ≤ ⌊Λ⌋) have := Int.floor_le Λ linarith exact CaballeroCentralInjective.eq_of_Z_eq a b hb1 16 (by norm_num) (cellVec a b Λ θ) (cellVec a b Λ' θ') ⟨Λ, θ, hΛpos, hθ0, hoff, rfl⟩ ⟨Λ', θ', hΛ', hθ'0, hoff', rfl⟩ hcE hdb hds hZ theorem caseB (a b : ℕ) (Λ : ℝ) (hc : IsCentral a b Λ) (Λ' θ' : ℝ) (hΛ' : 0 < Λ') (hθ'0 : 0 < θ') (hx : Λ' + a * θ' < b) (hA : Λ' < a * θ') (hB : BandBound a b Λ' θ') (hz0 : ((a : ℤ) + 1) * ⌊Λ⌋ ≤ (zeroCount a b θ' Λ' : ℤ)) : False := by obtain ⟨hJ1, hJ2⟩ := hc have hm : (0 : ℝ) < (a : ℝ) + 1 := by positivity have haθ'0 : 0 ≤ (a : ℝ) * θ' := by positivity have hxpos : 0 < Λ' + a * θ' := by linarith obtain ⟨y, hy, hxy, hyx⟩ := ceil_opening a b θ' _ hxpos hx have hGx := windowMass_top a b θ' Λ' hθ'0.le hΛ' hx have hGL := windowMass_at_B a b θ' Λ' hθ'0.le (by linarith) hΛ' hA have hlip := windowMass_lip a b θ' Λ' y (Λ' + a * θ') have hBy := hB y hy (by linarith) rw [abs_of_nonneg (by linarith : 0 ≤ y - (Λ' + a * θ'))] at hlip have hlip' := (abs_le.1 hlip).1 rw [abs_le] at hBy have h4 : Λ' ≤ 4 * ((a : ℝ) + 1) := by nlinarith [hBy.2, hlip'] have hN : Λ' ≤ ((4 * (a + 1) : ℕ) : ℝ) := by push_cast; exact h4 have hzc := zeroCount_le a b θ' Λ' hθ'0 (4 * (a + 1)) hN have hzc' : (zeroCount a b θ' Λ' : ℤ) ≤ ((a : ℤ) + 1) * (4 * ((a : ℤ) + 1)) := by exact_mod_cast hzc have : ((a : ℤ) + 1) * (4 * (a : ℤ) + 5) ≤ ((a : ℤ) + 1) * ⌊Λ⌋ := mul_le_mul_of_nonneg_left hJ1 (by positivity) nlinarith /-! ### The gaps -/ /-! ### The partner: `D` and `z₀` are common to `c` and `d` -/ /-- The number of closing brackets before the opening bracket `y`: `#{z ∈ P : z < y - Λ}`(`Z_k` of the paper, for `y = p_k`). -/noncomputable def closeBefore (a b : ℕ) (θ Λ y : ℝ) : ℕ := ((openingSet a b θ).filter fun z => z < y - Λ).card theorem closeBefore_mono (a b : ℕ) (θ Λ : ℝ) : Monotone (closeBefore a b θ Λ) := by intro y y' h unfold closeBefore apply card_le_card intro z hz rw [mem_filter] at hz ⊢ exact ⟨hz.1, by linarith [hz.2]⟩ /-- For irrational `θ` the opening positions `iθ + j` are pairwise distinct. -/theorem opos_injOn_irr (a b : ℕ) (θ : ℝ) (hirr : Irrational θ) : Set.InjOn (opos θ) ↑(range (a + 1) ×ˢ range (b + 1)) := by intro u hu v hv e unfold opos at e have h1 : u.1 = v.1 := by by_contra hne apply hirr refine ⟨(((v.2 : ℤ) - u.2 : ℤ) : ℚ) / (((u.1 : ℤ) - v.1 : ℤ) : ℚ), ?_⟩ have hne' : ((u.1 : ℤ) - v.1 : ℤ) ≠ 0 := by omega have hne'' : (((u.1 : ℤ) - v.1 : ℤ) : ℝ) ≠ 0 := by exact_mod_cast hne' push_cast at hne'' ⊢ field_simp linarith have h2 : u.2 = v.2 := by rw [h1] at e have : (u.2 : ℝ) = v.2 := by linarith exact_mod_cast this exact Prod.ext h1 h2 /-- Counting the opening positions that satisfy `p`, row by row, when `opos θ` is injective. -/theorem card_openingSet_filter_of_injOn (a b : ℕ) (θ : ℝ) (hinj : Set.InjOn (opos θ) ↑(range (a + 1) ×ˢ range (b + 1))) (p : ℝ → Prop) [DecidablePred p] : ((openingSet a b θ).filter p).card = ∑ i ∈ range (a + 1), ((range (b + 1)).filter fun j : ℕ => p ((i : ℝ) * θ + j)).card := by unfold openingSet rw [filter_image, card_image_of_injOn (hinj.mono (by intro v hv exact (mem_filter.mp (mem_coe.mp hv)).1))] rw [card_filter, sum_product] apply sum_congr rfl intro i _ rw [card_filter] rfl theorem Zr_eq_map (a b : ℕ) (Λ θ : ℝ) (hoff : OffLines a Λ θ) (hinj : Set.InjOn (opos θ) ↑(range (a + 1) ×ˢ range (b + 1))) : Zr a b (cellVec a b Λ θ) = ((openingSet a b θ).val.map (closeBefore a b θ Λ)).map (Nat.cast : ℕ → ℤ) := by rw [Zr_eq a b Λ θ hoff] congr 1 unfold openingSet rw [image_val_of_injOn hinj, Multiset.map_map] apply Multiset.map_congr rfl intro v _ simp only [Function.comp] unfold before closeBefore openingSet rw [filter_image, card_image_of_injOn (hinj.mono (by intro x hx simp only [coe_filter, Set.mem_ofPred_eq] at hx exact hx.1))] congr 2 funext u apply propext unfold opos cpos constructor <;> intro h <;> linarith /-- Ranks: if two monotone functions on two finite sets of reals have the same multiset of values,then they agree at points of the same rank (the same number of smaller points). -/theorem rank_aux (S S' : Finset ℝ) (f f' : ℝ → ℕ) (hf : Monotone f) (hf' : Monotone f') (hm : S.val.map f = S'.val.map f') (y y' : ℝ) (hy : y ∈ S) (hr : (S'.filter fun z => z < y').card ≤ (S.filter fun z => z < y).card) : ¬ f y < f' y' := by intro hlt have h1 : (S.filter fun z => z < y).card + 1 ≤ below S f (f y + 1) := by have hs : insert y (S.filter fun z => z < y) ⊆ S.filter fun z => f z < f y + 1 := by intro z hz rw [mem_insert] at hz rcases hz with rfl | hz · exact mem_filter.2 ⟨hy, Nat.lt_succ_self _⟩ · obtain ⟨hzS, hzy⟩ := mem_filter.1 hz exact mem_filter.2 ⟨hzS, Nat.lt_succ_of_le (hf hzy.le)⟩ have hn : y ∉ S.filter fun z => z < y := by simp calc (S.filter fun z => z < y).card + 1 = (insert y (S.filter fun z => z < y)).card := (card_insert_of_notMem hn).symm _ ≤ _ := card_le_card hs have h2 : below S f (f y + 1) = below S' f' (f y + 1) := by rw [below_eq_card, below_eq_card, hm] have h3 : (S'.filter fun z => f' z < f y + 1) ⊆ S'.filter fun z => z < y' := by intro z hz obtain ⟨hzS, hz2⟩ := mem_filter.1 hz refine mem_filter.2 ⟨hzS, ?_⟩ by_contra hcon have := hf' (not_lt.1 hcon) omega have h4 := card_le_card h3 unfold below at h1 h2 omega theorem rank_eq (S S' : Finset ℝ) (f f' : ℝ → ℕ) (hf : Monotone f) (hf' : Monotone f') (hm : S.val.map f = S'.val.map f') (y y' : ℝ) (hy : y ∈ S) (hy' : y' ∈ S') (hr : (S.filter fun z => z < y).card = (S'.filter fun z => z < y').card) : f y = f' y' := by have h1 := rank_aux S S' f f' hf hf' hm y y' hy hr.ge have h2 := rank_aux S' S f' f hf' hf hm.symm y' y hy' hr.le omega /-- `D(k) + Z_k = k`: the openings before `x` are those in the window `[x - Λ, x)` and those before`x - Λ`. -/theorem windowCount_add (a b : ℕ) (θ Λ x : ℝ) (hΛ : 0 ≤ Λ) : windowCount a b θ Λ x + closeBefore a b θ Λ x = openingIndex a b θ x := by unfold windowCount closeBefore openingIndex have h2 := card_filter_add_card_filter_not (s := (openingSet a b θ).filter fun z => z < x) (fun z => z < x - Λ) have e1 : ((openingSet a b θ).filter (fun z => z < x)).filter (fun z => z < x - Λ) = (openingSet a b θ).filter (fun z => z < x - Λ) := by ext z simp only [mem_filter] constructor · rintro ⟨⟨h1, _⟩, h3⟩ exact ⟨h1, h3⟩ · rintro ⟨h1, h3⟩ exact ⟨⟨h1, by linarith⟩, h3⟩ have e2 : ((openingSet a b θ).filter (fun z => z < x)).filter (fun z => ¬ z < x - Λ) = (openingSet a b θ).filter fun z => x - Λ ≤ z ∧ z < x := by ext z simp only [mem_filter, not_lt] constructor · rintro ⟨⟨h1, h2⟩, h3⟩ exact ⟨h1, h3, h2⟩ · rintro ⟨h1, h3, h2⟩ exact ⟨⟨h1, h2⟩, h3⟩ rw [e1, e2] at h2 omega theorem opos_ne_Λ (a b : ℕ) (Λ θ : ℝ) (hoff : OffLines a Λ θ) (y : ℝ) (hy : y ∈ openingSet a b θ) : y ≠ Λ := by unfold openingSet at hy obtain ⟨v, hv, rfl⟩ := mem_image.mp hy simp only [mem_product, mem_range] at hv intro e unfold opos at e apply hoff (-(v.1 : ℤ)) (by omega) (by omega) (v.2 : ℤ) push_cast linarith /-- `z₀ = #{k : Z_k = 0}`: the openings with no closing bracket before them. -/theorem zeroCount_eq_below (a b : ℕ) (θ Λ : ℝ) (hθ : 0 < θ) (hoff : OffLines a Λ θ) : zeroCount a b θ Λ = below (openingSet a b θ) (closeBefore a b θ Λ) 1 := by have h0 : (0 : ℝ) ∈ openingSet a b θ := by unfold openingSet exact mem_image.2 ⟨(0, 0), by simp, by simp [opos]⟩ unfold zeroCount below congr 1 ext y simp only [mem_filter] constructor · rintro ⟨hy, h1, h2⟩ refine ⟨hy, ?_⟩ have hz : closeBefore a b θ Λ y = 0 := by unfold closeBefore rw [card_eq_zero, filter_eq_empty_iff] intro z hz have := (openingSet_bounds a b θ hθ z hz).1 linarith omega · rintro ⟨hy, h1⟩ have hz : closeBefore a b θ Λ y = 0 := by omega unfold closeBefore at hz rw [card_eq_zero, filter_eq_empty_iff] at hz have h2 := hz h0 have h3 := (openingSet_bounds a b θ hθ y hy).1 refine ⟨hy, h3, ?_⟩ have h4 : y ≤ Λ := by by_contra hcon exact h2 (by linarith [not_le.1 hcon]) exact lt_of_le_of_ne h4 (opos_ne_Λ a b Λ θ hoff y hy) /-- One row: the number of `j ∈ [0, b]` with `α ≤ j < β` differs from the length of `[α, β) ∩ [0, b]`by at most `1`. -/theorem row_card_close (b : ℕ) (α β : ℝ) : |(((range (b + 1)).filter fun j : ℕ => α ≤ (j : ℝ) ∧ (j : ℝ) < β).card : ℝ) - max (min β b - max α 0) 0| ≤ 1 := by have e : ((range (b + 1)).filter fun j : ℕ => α ≤ (j : ℝ) ∧ (j : ℝ) < β) = (range (b + 1)).filter fun j : ℕ => max α 0 ≤ (j : ℝ) ∧ (j : ℝ) < min β ((b : ℝ) + 1) := by apply filter_congr intro j hj rw [mem_range] at hj have hjb : (j : ℝ) < b + 1 := by exact_mod_cast hj have hj0 : (0 : ℝ) ≤ j := Nat.cast_nonneg j simp only [max_le_iff, lt_min_iff] constructor · rintro ⟨h1, h2⟩ exact ⟨⟨h1, hj0⟩, h2, hjb⟩ · rintro ⟨⟨h1, _⟩, h2, _⟩ exact ⟨h1, h2⟩ rw [e] have hα0 : 0 ≤ max α 0 := le_max_right _ _ have hαα : α ≤ max α 0 := le_max_left _ _ by_cases h : max α 0 ≤ min β ((b : ℝ) + 1) · have hc := band_card_row b (max α 0) (min β ((b : ℝ) + 1)) (by linarith) (min_le_right _ _) h have hc' : (((range (b + 1)).filter fun j : ℕ => max α 0 ≤ (j : ℝ) ∧ (j : ℝ) < min β ((b : ℝ) + 1)).card : ℝ) = (⌈min β ((b : ℝ) + 1)⌉ : ℝ) - ⌈max α 0⌉ := by exact_mod_cast hc rw [hc'] have a1 := Int.le_ceil (max α 0) have a2 := Int.ceil_lt_add_one (max α 0) rcases le_or_gt β b with hβb | hβb · rw [min_eq_left hβb, min_eq_left (show β ≤ (b : ℝ) + 1 by linarith)] have b1 := Int.le_ceil β have b2 := Int.ceil_lt_add_one β rw [min_eq_left (show β ≤ (b : ℝ) + 1 by linarith)] at h rw [abs_le] rcases le_total (β - max α 0) 0 with h0 | h0 · rw [max_eq_right h0] constructor <;> linarith · rw [max_eq_left h0] constructor <;> linarith · rw [min_eq_right hβb.le] have hb1 : (b : ℝ) < min β ((b : ℝ) + 1) := lt_min hβb (by linarith) have hb2 : min β ((b : ℝ) + 1) ≤ (b : ℝ) + 1 := min_le_right _ _ have hce : ⌈min β ((b : ℝ) + 1)⌉ = (b : ℤ) + 1 := by rw [Int.ceil_eq_iff] push_cast constructor <;> linarith rw [hce] push_cast rw [abs_le] rcases le_total ((b : ℝ) - max α 0) 0 with h0 | h0 · rw [max_eq_right h0] constructor <;> linarith · rw [max_eq_left h0] constructor <;> linarith · have hempty : ((range (b + 1)).filter fun j : ℕ => max α 0 ≤ (j : ℝ) ∧ (j : ℝ) < min β ((b : ℝ) + 1)) = ∅ := by rw [filter_eq_empty_iff] intro j _ hj exact h (by linarith [hj.1, hj.2]) rw [hempty, card_empty] have hn := not_le.1 h have hm : min β (b : ℝ) ≤ min β ((b : ℝ) + 1) := min_le_min le_rfl (by linarith) rw [max_eq_right (by linarith)] simp /-- The count of the opening positions in a window differs from the window mass by at most`m = a + 1` (one unit per row). -/theorem window_close (a b : ℕ) (θ' Λ' x : ℝ) (hinj : Set.InjOn (opos θ') ↑(range (a + 1) ×ˢ range (b + 1))) : |(((openingSet a b θ').filter fun y => x - Λ' ≤ y ∧ y < x).card : ℝ) - windowMass a b θ' Λ' x| ≤ (a : ℝ) + 1 := by rw [card_openingSet_filter_of_injOn a b θ' hinj, Nat.cast_sum] unfold windowMass rw [← sum_sub_distrib] refine (abs_sum_le_sum_abs _ _).trans ((sum_le_sum (g := fun _ => (1 : ℝ)) (fun i hi => ?_)).trans ?_) · have e : ((range (b + 1)).filter fun j : ℕ => x - Λ' ≤ (i : ℝ) * θ' + j ∧ (i : ℝ) * θ' + j < x) = (range (b + 1)).filter fun j : ℕ => x - Λ' - (i : ℝ) * θ' ≤ (j : ℝ) ∧ (j : ℝ) < x - (i : ℝ) * θ' := by apply filter_congr intro j _ constructor <;> rintro ⟨h1, h2⟩ <;> constructor <;> linarith have e2 : rowLen b θ' Λ' i x = max (min (x - (i : ℝ) * θ') b - max (x - Λ' - (i : ℝ) * θ') 0) 0 := by unfold rowLen congr 1 simp only [min_def, max_def] split_ifs <;> linarith rw [e, e2] exact row_card_close b _ _ · simp theorem zeroCount_ge (a b : ℕ) (Λ θ : ℝ) (hθ : 0 < θ) (haθ : (a : ℝ) * θ < 1) (hc : IsCentral a b Λ) : ((a : ℤ) + 1) * ⌊Λ⌋ ≤ (zeroCount a b θ Λ : ℤ) := by obtain ⟨hJ1, hJ2⟩ := hc have hCa : 0 < Ca a := by unfold Ca; positivity have hΛJ := Int.floor_le Λ have hΛJ' := Int.lt_floor_add_one Λ have hJ5 : (5 : ℝ) ≤ ((⌊Λ⌋ : ℤ) : ℝ) := by exact_mod_cast (by omega : (5 : ℤ) ≤ ⌊Λ⌋) have hJb : ((⌊Λ⌋ : ℤ) : ℝ) ≤ b := by exact_mod_cast (by omega : ⌊Λ⌋ ≤ (b : ℤ)) rw [zeroCount_eq a b θ Λ hθ haθ (by linarith) (by linarith)] refine (sum_bounds a _ ⌊Λ⌋ ?_).1 intro i hi rw [mem_range] at hi have hia : (i : ℝ) ≤ a := by exact_mod_cast (by omega : i ≤ a) have hit : (i : ℝ) * θ ≤ a * θ := mul_le_mul_of_nonneg_right hia hθ.le have hit0 : 0 ≤ (i : ℝ) * θ := by positivity constructor · have := Int.lt_ceil.mpr (show (((⌊Λ⌋ - 1 : ℤ)) : ℝ) < Λ - (i : ℝ) * θ by push_cast; linarith) omega · exact Int.ceil_le.mpr (by push_cast; linarith) /-- GAP 1 (paper, "The partner", from the start to (B)): for `θ < 1/a`, a central `c` and a partner`d` at `(Λ', θ')` with irrational `θ'` and `Z d = Z c`, the functions `D` and `z₀` are common to`c` and `d` as functions of the index `k` (Zʳ sorted), so Lemma 13 (band) for `c` gives (B) for `d`and `z₀(d) ≥ mJ`. -/theorem partner_facts (a b : ℕ) (ha : 2 ≤ a) (Λ θ : ℝ) (hθ0 : 0 < θ) (hθ : θ < 1 / (a : ℝ)) (hoff : OffLines a Λ θ) (hc : IsCentral a b Λ) (Λ' θ' : ℝ) (hΛ' : 0 < Λ') (hθ'0 : 0 < θ') (hirr : Irrational θ') (hoff' : OffLines a Λ' θ') (hZ : Z a b (cellVec a b Λ' θ') = Z a b (cellVec a b Λ θ)) : BandBound a b Λ' θ' ∧ ((a : ℤ) + 1) * ⌊Λ⌋ ≤ (zeroCount a b θ' Λ' : ℤ) := by have ha0 : (0 : ℝ) < a := by exact_mod_cast (by omega : 0 < a) have haθ : (a : ℝ) * θ < 1 := by rw [lt_div_iff₀ ha0] at hθ linarith have hc' := hc obtain ⟨hJ1, hJ2⟩ := hc have hΛJ := Int.floor_le Λ have hJ5 : (5 : ℝ) ≤ ((⌊Λ⌋ : ℤ) : ℝ) := by exact_mod_cast (by omega : (5 : ℤ) ≤ ⌊Λ⌋) have hΛ : 0 < Λ := by linarith have hinj := CaballeroGeneralA.opos_injOn a b θ hθ0 haθ have hinj' := opos_injOn_irr a b θ' hirr have hcR : Realisable a b (cellVec a b Λ θ) := ⟨Λ, θ, hΛ, hθ0, hoff, rfl⟩ have hdR : Realisable a b (cellVec a b Λ' θ') := ⟨Λ', θ', hΛ', hθ'0, hoff', rfl⟩ have hrows : Zr a b (cellVec a b Λ θ) = Zr a b (cellVec a b Λ' θ') := (rows_iff a b _ _ hcR hdR).2 hZ.symm rw [Zr_eq_map a b Λ θ hoff hinj, Zr_eq_map a b Λ' θ' hoff' hinj'] at hrows have hmulti := (Multiset.map_injective Nat.cast_injective) hrows have hz : zeroCount a b θ Λ = zeroCount a b θ' Λ' := by rw [zeroCount_eq_below a b θ Λ hθ0 hoff, zeroCount_eq_below a b θ' Λ' hθ'0 hoff', below_eq_card, below_eq_card, hmulti] have hzc := zeroCount_ge a b Λ θ hθ0 haθ hc' rw [hz] at hzc refine ⟨?_, hzc⟩ intro y hy hΛy have hcardP' : (openingSet a b θ').card = (a + 1) * (b + 1) := by unfold openingSet rw [card_image_of_injOn hinj', card_product, card_range, card_range] obtain ⟨r, hr⟩ : ∃ r, r = ((openingSet a b θ').filter fun z => z < y).card := ⟨_, rfl⟩ have hrK : r < (a + 1) * (b + 1) := by rw [← hcardP', hr] exact card_lt_card (filter_ssubset.2 ⟨y, hy, lt_irrefl y⟩) have hxP : CaballeroBlock.pk a b θ r ∈ openingSet a b θ := by have : CaballeroBlock.pk a b θ r ∈ CaballeroBlock.openPos a b θ := by rw [CaballeroBlock.pk_eq a b θ hθ0 haθ r hrK, CaballeroBlock.openPos_eq, mem_image] exact ⟨r, mem_range.2 hrK, rfl⟩ exact this have hxr : ((openingSet a b θ).filter fun z => z < CaballeroBlock.pk a b θ r).card = r := CaballeroBlock.card_lt_pk a b θ hθ0 haθ r hrK have hZeq := rank_eq (openingSet a b θ) (openingSet a b θ') (closeBefore a b θ Λ) (closeBefore a b θ' Λ') (closeBefore_mono a b θ Λ) (closeBefore_mono a b θ' Λ') hmulti (CaballeroBlock.pk a b θ r) y hxP hy (hxr.trans hr) have h1 : windowCount a b θ Λ (CaballeroBlock.pk a b θ r) + closeBefore a b θ Λ (CaballeroBlock.pk a b θ r) = r := by rw [windowCount_add a b θ Λ _ hΛ.le] exact hxr have h2 : windowCount a b θ' Λ' y + closeBefore a b θ' Λ' y = r := by rw [windowCount_add a b θ' Λ' _ hΛ'.le, hr] rfl have hW : windowCount a b θ Λ (CaballeroBlock.pk a b θ r) = windowCount a b θ' Λ' y := by omega have hk : zeroCount a b θ Λ ≤ openingIndex a b θ (CaballeroBlock.pk a b θ r) := by have e : openingIndex a b θ (CaballeroBlock.pk a b θ r) = r := hxr rw [e, hz, hr] unfold zeroCount apply card_le_card intro z hz' rw [mem_filter] at hz' ⊢ exact ⟨hz'.1, by linarith [hz'.2.2]⟩ have hband := band_le a b Λ θ hθ0 haθ hoff hc' _ hxP hk rw [hW, hz] at hband have hband' : |((windowCount a b θ' Λ' y : ℕ) : ℝ) - ((zeroCount a b θ' Λ' : ℕ) : ℝ)| ≤ (a : ℝ) + 1 := by exact_mod_cast hband have e1 : |((windowCount a b θ' Λ' y : ℕ) : ℝ) - windowMass a b θ' Λ' y| ≤ (a : ℝ) + 1 := window_close a b θ' Λ' y hinj' have e2 : |((zeroCount a b θ' Λ' : ℕ) : ℝ) - windowMass a b θ' Λ' Λ'| ≤ (a : ℝ) + 1 := by have := window_close a b θ' Λ' Λ' hinj' simp only [sub_self] at this exact this rw [abs_le] at hband' e1 e2 ⊢ constructor <;> linarith [hband'.1, hband'.2, e1.1, e1.2, e2.1, e2.2] /-! ### The counting function of the openings, row by row -/ theorem openingIndex_eq (a b : ℕ) (θ' : ℝ) (hinj : Set.InjOn (opos θ') ↑(range (a + 1) ×ˢ range (b + 1))) (t : ℝ) : (openingIndex a b θ' t : ℤ) = ∑ i ∈ range (a + 1), min ((b : ℤ) + 1) (max 0 ⌈t - (i : ℝ) * θ'⌉) := by unfold openingIndex rw [card_openingSet_filter_of_injOn a b θ' hinj (fun y => y < t), Nat.cast_sum] apply sum_congr rfl intro i _ have e : ((range (b + 1)).filter fun j : ℕ => (i : ℝ) * θ' + j < t) = (range (b + 1)).filter fun j : ℕ => (j : ℤ) ≤ ⌈t - (i : ℝ) * θ'⌉ - 1 := by apply filter_congr intro j _ have key := Int.lt_ceil (a := t - (i : ℝ) * θ') (z := (j : ℤ)) have e2 : ((j : ℤ) : ℝ) < t - (i : ℝ) * θ' ↔ (i : ℝ) * θ' + j < t := by push_cast constructor <;> intro h <;> linarith rw [← e2, ← key] omega rw [e, card_range_filter_le] congr 2 omega /-- No cut point `iθ'` or `iθ' + b` in the closed interval `[t, t']`. -/def OFree (a b : ℕ) (θ' t t' : ℝ) : Prop := ∀ i ∈ range (a + 1), ((i : ℝ) * θ' < t ∨ t' < (i : ℝ) * θ') ∧ ((i : ℝ) * θ' + b < t ∨ t' < (i : ℝ) * θ' + b) theorem OFree.mono {a b : ℕ} {θ' t t' s s' : ℝ} (h : OFree a b θ' t t') (h1 : t ≤ s) (h2 : s' ≤ t') : OFree a b θ' s s' := by intro i hi obtain ⟨h1', h2'⟩ := h i hi constructor · rcases h1' with p | p · left; linarith · right; linarith · rcases h2' with p | p · left; linarith · right; linarith /-- The number of opening rows active at `t`: `#{i ≤ a : iθ' < t < iθ' + b}`. -/noncomputable def rr (a b : ℕ) (θ' t : ℝ) : ℕ := ((range (a + 1)).filter fun i : ℕ => (i : ℝ) * θ' < t ∧ t < (i : ℝ) * θ' + b).card theorem rr_le (a b : ℕ) (θ' t : ℝ) : rr a b θ' t ≤ a + 1 := by unfold rr exact (card_filter_le _ _).trans (by simp) theorem openingIndex_sub (a b : ℕ) (θ' : ℝ) (hinj : Set.InjOn (opos θ') ↑(range (a + 1) ×ˢ range (b + 1))) (t t' : ℝ) (htt : t ≤ t') (hfree : OFree a b θ' t t') : (openingIndex a b θ' t' : ℤ) - openingIndex a b θ' t = ∑ i ∈ (range (a + 1)).filter (fun i : ℕ => (i : ℝ) * θ' < t ∧ t < (i : ℝ) * θ' + b), (⌈t' - (i : ℝ) * θ'⌉ - ⌈t - (i : ℝ) * θ'⌉) := by rw [openingIndex_eq a b θ' hinj t', openingIndex_eq a b θ' hinj t, ← sum_sub_distrib, ← sum_filter_add_sum_filter_not (range (a + 1)) (fun i : ℕ => (i : ℝ) * θ' < t ∧ t < (i : ℝ) * θ' + b)] have h0 : ∑ i ∈ (range (a + 1)).filter (fun i : ℕ => ¬ ((i : ℝ) * θ' < t ∧ t < (i : ℝ) * θ' + b)), (min ((b : ℤ) + 1) (max 0 ⌈t' - (i : ℝ) * θ'⌉) - min ((b : ℤ) + 1) (max 0 ⌈t - (i : ℝ) * θ'⌉)) = 0 := by apply sum_eq_zero intro i hi rw [mem_filter] at hi obtain ⟨hi1, hi2⟩ := hi obtain ⟨f1, f2⟩ := hfree i hi1 rcases le_or_gt t ((i : ℝ) * θ') with hlow | hlow · have h1 : t' < (i : ℝ) * θ' := by rcases f1 with p | p · linarith · exact p have c1 : ⌈t' - (i : ℝ) * θ'⌉ ≤ 0 := Int.ceil_le.2 (by simp; linarith) have c2 : ⌈t - (i : ℝ) * θ'⌉ ≤ 0 := Int.ceil_le.2 (by simp; linarith) omega · have hhigh : (i : ℝ) * θ' + b ≤ t := by by_contra hc push Not at hc exact hi2 ⟨hlow, hc⟩ have h1 : (i : ℝ) * θ' + b < t := by rcases f2 with p | p · exact p · linarith have c2 : (b : ℤ) < ⌈t - (i : ℝ) * θ'⌉ := by rw [Int.lt_ceil] push_cast linarith have c3 : ⌈t - (i : ℝ) * θ'⌉ ≤ ⌈t' - (i : ℝ) * θ'⌉ := Int.ceil_mono (by linarith) omega rw [h0, add_zero] apply sum_congr rfl intro i hi rw [mem_filter] at hi obtain ⟨hi1, hi2, hi3⟩ := hi obtain ⟨f1, f2⟩ := hfree i hi1 have h1 : t' < (i : ℝ) * θ' + b := by rcases f2 with p | p · linarith · exact p have c1 : (0 : ℤ) < ⌈t - (i : ℝ) * θ'⌉ := by rw [Int.lt_ceil] push_cast linarith have c2 : ⌈t' - (i : ℝ) * θ'⌉ ≤ (b : ℤ) := Int.ceil_le.2 (by push_cast; linarith) have c3 : ⌈t - (i : ℝ) * θ'⌉ ≤ ⌈t' - (i : ℝ) * θ'⌉ := Int.ceil_mono (by linarith) omega theorem openingIndex_add_one (a b : ℕ) (θ' : ℝ) (hinj : Set.InjOn (opos θ') ↑(range (a + 1) ×ˢ range (b + 1))) (t : ℝ) (hfree : OFree a b θ' t (t + 1)) : (openingIndex a b θ' (t + 1) : ℤ) = openingIndex a b θ' t + rr a b θ' t := by have h := openingIndex_sub a b θ' hinj t (t + 1) (by linarith) hfree have e : ∀ i ∈ (range (a + 1)).filter (fun i : ℕ => (i : ℝ) * θ' < t ∧ t < (i : ℝ) * θ' + b), (⌈t + 1 - (i : ℝ) * θ'⌉ - ⌈t - (i : ℝ) * θ'⌉) = 1 := by intro i _ rw [show t + 1 - (i : ℝ) * θ' = (t - (i : ℝ) * θ') + 1 by ring, Int.ceil_add_one] ring rw [sum_congr rfl e] at h simp only [sum_const, nsmul_eq_mul, mul_one] at h unfold rr linarith theorem rr_congr (a b : ℕ) (θ' t t' : ℝ) (htt : t ≤ t') (hfree : OFree a b θ' t t') : rr a b θ' t = rr a b θ' t' := by unfold rr congr 1 apply filter_congr intro i hi obtain ⟨f1, f2⟩ := hfree i hi constructor · rintro ⟨h1, h2⟩ refine ⟨by linarith, ?_⟩ rcases f2 with p | p · linarith · exact p · rintro ⟨h1, h2⟩ refine ⟨?_, by linarith⟩ rcases f1 with p | p · exact p · linarith /-! ### Ranks of the openings -/ theorem openingIndex_mono (a b : ℕ) (θ' : ℝ) {s t : ℝ} (h : s ≤ t) : openingIndex a b θ' s ≤ openingIndex a b θ' t := by unfold openingIndex apply card_le_card intro z hz rw [mem_filter] at hz ⊢ exact ⟨hz.1, by linarith [hz.2]⟩ theorem openingIndex_lt (a b : ℕ) (θ' : ℝ) {y y' : ℝ} (hy : y ∈ openingSet a b θ') (h : y < y') : openingIndex a b θ' y < openingIndex a b θ' y' := by unfold openingIndex have hsub : (openingSet a b θ').filter (fun z => z < y) ⊆ (openingSet a b θ').filter (fun z => z < y') := by intro z hz rw [mem_filter] at hz ⊢ exact ⟨hz.1, by linarith [hz.2]⟩ apply card_lt_card rw [Finset.ssubset_iff_of_subset hsub] exact ⟨y, mem_filter.2 ⟨hy, h⟩, fun hh => lt_irrefl y (mem_filter.1 hh).2⟩ theorem openingSet_card (a b : ℕ) (θ' : ℝ) (hinj : Set.InjOn (opos θ') ↑(range (a + 1) ×ˢ range (b + 1))) : (openingSet a b θ').card = (a + 1) * (b + 1) := by unfold openingSet rw [card_image_of_injOn hinj, card_product, card_range, card_range] theorem openingIndex_inj (a b : ℕ) (θ' : ℝ) {y y' : ℝ} (hy : y ∈ openingSet a b θ') (hy' : y' ∈ openingSet a b θ') (e : openingIndex a b θ' y = openingIndex a b θ' y') : y = y' := by rcases lt_trichotomy y y' with h | h | h · exact absurd e (openingIndex_lt a b θ' hy h).ne · exact h · exact absurd e.symm (openingIndex_lt a b θ' hy' h).ne theorem exists_rank (a b : ℕ) (θ' : ℝ) (hinj : Set.InjOn (opos θ') ↑(range (a + 1) ×ˢ range (b + 1))) : ∃ yk : ℕ → ℝ, ∀ k < (a + 1) * (b + 1), yk k ∈ openingSet a b θ' ∧ openingIndex a b θ' (yk k) = k := by have hcard := openingSet_card a b θ' hinj have hinjc : Set.InjOn (openingIndex a b θ') ↑(openingSet a b θ') := by intro y hy y' hy' e exact openingIndex_inj a b θ' hy hy' e have himg : (openingSet a b θ').image (openingIndex a b θ') = range ((a + 1) * (b + 1)) := by apply eq_of_subset_of_card_le · intro k hk obtain ⟨y, hy, rfl⟩ := mem_image.1 hk rw [mem_range, ← hcard] exact card_lt_card (filter_ssubset.2 ⟨y, hy, lt_irrefl y⟩) · rw [card_image_of_injOn hinjc, hcard, card_range] have hex : ∀ k, k < (a + 1) * (b + 1) → ∃ y, y ∈ openingSet a b θ' ∧ openingIndex a b θ' y = k := by intro k hk have : k ∈ (openingSet a b θ').image (openingIndex a b θ') := by rw [himg]; exact mem_range.2 hk obtain ⟨y, hy, hyk⟩ := mem_image.1 this exact ⟨y, hy, hyk⟩ choose! yk hyk using hex exact ⟨yk, hyk⟩ /-- An opening that is not a cut point lies in an active row and `x + 1` is an opening. -/theorem opening_active (a b : ℕ) (θ' x : ℝ) (hx : x ∈ openingSet a b θ') (hne : ∀ i ∈ range (a + 1), x ≠ (i : ℝ) * θ' ∧ x ≠ (i : ℝ) * θ' + b) : ∃ i ∈ range (a + 1), (i : ℝ) * θ' < x ∧ x < (i : ℝ) * θ' + b ∧ x + 1 ∈ openingSet a b θ' := by unfold openingSet at hx ⊢ obtain ⟨v, hv, rfl⟩ := mem_image.1 hx simp only [mem_product, mem_range] at hv obtain ⟨h1, h2⟩ := hv have hne' := hne v.1 (mem_range.2 h1) simp only [opos] at hne' have j0 : v.2 ≠ 0 := by intro h apply hne'.1 rw [h] simp have jb : v.2 ≠ b := by intro h apply hne'.2 rw [h] refine ⟨v.1, mem_range.2 h1, ?_, ?_, ?_⟩ · have : (0 : ℝ) < v.2 := by exact_mod_cast Nat.pos_of_ne_zero j0 simp only [opos] linarith · have : (v.2 : ℝ) < b := by exact_mod_cast (by omega : v.2 < b) simp only [opos] linarith · rw [mem_image] refine ⟨(v.1, v.2 + 1), ?_, ?_⟩ · simp only [mem_product, mem_range] omega · simp only [opos] push_cast ring theorem rr_pos (a b : ℕ) (θ' x : ℝ) (hx : x ∈ openingSet a b θ') (hne : ∀ i ∈ range (a + 1), x ≠ (i : ℝ) * θ' ∧ x ≠ (i : ℝ) * θ' + b) : 1 ≤ rr a b θ' x := by obtain ⟨i, hi, h1, h2, -⟩ := opening_active a b θ' x hx hne unfold rr rw [Nat.one_le_iff_ne_zero, Ne, card_eq_zero, ← Ne, ← nonempty_iff_ne_empty] exact ⟨i, mem_filter.2 ⟨hi, h1, h2⟩⟩ /-- Translation by `1` inside a zone without cuts: an opening `t` of rank `rank(x) + r`, where `r`opening rows are active at `x` and `[x, t]` contains no cut point, is `x + 1`. -/theorem trans_rank_eq (a b : ℕ) (θ' : ℝ) (hinj : Set.InjOn (opos θ') ↑(range (a + 1) ×ˢ range (b + 1))) (x t : ℝ) (hx : x ∈ openingSet a b θ') (ht : t ∈ openingSet a b θ') (hxt : x < t) (hfree : OFree a b θ' x t) (hcnt : (openingIndex a b θ' t : ℤ) = openingIndex a b θ' x + rr a b θ' x) : t = x + 1 := by have hne : ∀ i ∈ range (a + 1), x ≠ (i : ℝ) * θ' ∧ x ≠ (i : ℝ) * θ' + b := by intro i hi obtain ⟨f1, f2⟩ := hfree i hi constructor · intro e rcases f1 with p | p <;> linarith · intro e rcases f2 with p | p <;> linarith obtain ⟨-, -, -, -, hx1⟩ := opening_active a b θ' x hx hne rcases lt_trichotomy t (x + 1) with hlt | heq | hgt · exfalso have ht' := ht unfold openingSet at ht' obtain ⟨v, hv, hvt⟩ := mem_image.1 ht' simp only [mem_product, mem_range] at hv simp only [opos] at hvt have hv2 : (v.2 : ℝ) ≤ b := by exact_mod_cast (by omega : v.2 ≤ b) have hv0 : (0 : ℝ) ≤ v.2 := by positivity obtain ⟨f1, f2⟩ := hfree v.1 (mem_range.2 hv.1) have g1 : (v.1 : ℝ) * θ' < x := by rcases f1 with p | p · exact p · linarith have g2 : x < (v.1 : ℝ) * θ' + b := by rcases f2 with p | p · linarith · linarith have hsum := openingIndex_sub a b θ' hinj x t hxt.le hfree have hrrF : rr a b θ' x = ((range (a + 1)).filter (fun i : ℕ => (i : ℝ) * θ' < x ∧ x < (i : ℝ) * θ' + b)).card := rfl set F := (range (a + 1)).filter (fun i : ℕ => (i : ℝ) * θ' < x ∧ x < (i : ℝ) * θ' + b) with hF have hmem : v.1 ∈ F := by rw [hF, mem_filter] exact ⟨mem_range.2 hv.1, g1, g2⟩ have hsplit := add_sum_erase F (fun i : ℕ => ⌈t - (i : ℝ) * θ'⌉ - ⌈x - (i : ℝ) * θ'⌉) hmem beta_reduce at hsplit have hterm0 : ⌈t - (v.1 : ℝ) * θ'⌉ - ⌈x - (v.1 : ℝ) * θ'⌉ = 0 := by have e1 : t - (v.1 : ℝ) * θ' = ((v.2 : ℤ) : ℝ) := by rw [← hvt]; push_cast; ring have e2 : ⌈x - (v.1 : ℝ) * θ'⌉ = (v.2 : ℤ) := by rw [Int.ceil_eq_iff] constructor <;> push_cast <;> linarith rw [e1, Int.ceil_intCast, e2, sub_self] have hpos : 1 ≤ F.card := card_pos.2 ⟨_, hmem⟩ have hrest : ∑ i ∈ F.erase v.1, (⌈t - (i : ℝ) * θ'⌉ - ⌈x - (i : ℝ) * θ'⌉) ≤ (F.card : ℤ) - 1 := by have hc := card_erase_of_mem hmem calc _ ≤ ∑ _i ∈ F.erase v.1, (1 : ℤ) := by apply sum_le_sum intro i _ have : ⌈t - (i : ℝ) * θ'⌉ ≤ ⌈(x - (i : ℝ) * θ') + 1⌉ := Int.ceil_mono (by linarith) rw [Int.ceil_add_one] at this omega _ = ((F.erase v.1).card : ℤ) := by rw [sum_const, nsmul_eq_mul, mul_one] _ = (F.card : ℤ) - 1 := by rw [hc]; omega rw [hrrF] at hcnt linarith · exact heq · have hfx : OFree a b θ' x (x + 1) := hfree.mono le_rfl hgt.le have h1 := openingIndex_add_one a b θ' hinj x hfx have h2 : openingIndex a b θ' (x + 1) = openingIndex a b θ' t := by omega exact (openingIndex_inj a b θ' hx1 ht h2).symm /-! ### The cut points and the pigeonhole -/ /-- The cut points of the opening rows: `iθ'` and `iθ' + b`. -/noncomputable def SO (a b : ℕ) (θ' : ℝ) : Finset ℝ := (range (a + 1)).image (fun i : ℕ => (i : ℝ) * θ') ∪ (range (a + 1)).image (fun i : ℕ => (i : ℝ) * θ' + b) /-- The cut points of the openings and of the closings (the latter shifted by `Λ'`). -/noncomputable def SS (a b : ℕ) (θ' Λ' : ℝ) : Finset ℝ := SO a b θ' ∪ (SO a b θ').image (fun s => s + Λ') theorem SS_card_le (a b : ℕ) (θ' Λ' : ℝ) : (SS a b θ' Λ').card ≤ 4 * (a + 1) := by have h1 : (SO a b θ').card ≤ 2 * (a + 1) := by unfold SO refine (card_union_le _ _).trans ?_ have e1 : ((range (a + 1)).image (fun i : ℕ => (i : ℝ) * θ')).card ≤ a + 1 := card_image_le.trans (by simp) have e2 : ((range (a + 1)).image (fun i : ℕ => (i : ℝ) * θ' + b)).card ≤ a + 1 := card_image_le.trans (by simp) omega unfold SS refine (card_union_le _ _).trans ?_ have := card_image_le (s := SO a b θ') (f := fun s => s + Λ') omega theorem SS_free (a b : ℕ) (θ' Λ' u v : ℝ) (h : ∀ s ∈ SS a b θ' Λ', s < u ∨ v < s) : OFree a b θ' u v ∧ OFree a b θ' (u - Λ') (v - Λ') := by constructor · intro i hi have m1 : (i : ℝ) * θ' ∈ SS a b θ' Λ' := by unfold SS SO exact mem_union.2 (Or.inl (mem_union.2 (Or.inl (mem_image.2 ⟨i, hi, rfl⟩)))) have m2 : (i : ℝ) * θ' + b ∈ SS a b θ' Λ' := by unfold SS SO exact mem_union.2 (Or.inl (mem_union.2 (Or.inr (mem_image.2 ⟨i, hi, rfl⟩)))) exact ⟨h _ m1, h _ m2⟩ · intro i hi have m1 : (i : ℝ) * θ' + Λ' ∈ SS a b θ' Λ' := by unfold SS refine mem_union.2 (Or.inr (mem_image.2 ⟨(i : ℝ) * θ', ?_, rfl⟩)) unfold SO exact mem_union.2 (Or.inl (mem_image.2 ⟨i, hi, rfl⟩)) have m2 : (i : ℝ) * θ' + b + Λ' ∈ SS a b θ' Λ' := by unfold SS refine mem_union.2 (Or.inr (mem_image.2 ⟨(i : ℝ) * θ' + b, ?_, rfl⟩)) unfold SO exact mem_union.2 (Or.inr (mem_image.2 ⟨i, hi, rfl⟩)) constructor · rcases h _ m1 with p | p · left; linarith · right; linarith · rcases h _ m2 with p | p · left; linarith · right; linarith theorem g_free (S : Finset ℝ) (y : ℕ → ℝ) (k k' : ℕ) (hnext : y k' < y (k' + 1)) (hg : (S.filter fun s => s < y k).card = (S.filter fun s => s < y (k' + 1)).card) : ∀ s ∈ S, s < y k ∨ y k' < s := by intro s hs by_contra h push Not at h obtain ⟨h1, h2⟩ := h have hsub : S.filter (fun z => z < y k) ⊆ S.filter (fun z => z < y (k' + 1)) := by intro z hz rw [mem_filter] at hz ⊢ exact ⟨hz.1, by linarith [hz.2]⟩ have hlt : (S.filter fun z => z < y k).card < (S.filter fun z => z < y (k' + 1)).card := by apply card_lt_card rw [Finset.ssubset_iff_of_subset hsub] exact ⟨s, mem_filter.2 ⟨hs, by linarith⟩, fun hh => by linarith [(mem_filter.1 hh).2]⟩ omega theorem fiber_window (g : ℕ → ℕ) (K q M A : ℕ) (hmono : ∀ k k', k ≤ k' → k' < K → g k ≤ g k') (hq : ∀ k < K, g k < q) (hA : A + (q * M + 1) ≤ K) : ∃ k1, A ≤ k1 ∧ k1 + M < A + (q * M + 1) ∧ ∀ k, k1 ≤ k → k ≤ k1 + M → g k = g k1 := by have hmap : ∀ k ∈ Ico A (A + (q * M + 1)), g k ∈ range q := by intro k hk rw [mem_Ico] at hk rw [mem_range] exact hq k (by omega) have hcard : (range q).card * M < (Ico A (A + (q * M + 1))).card := by rw [card_range, Nat.card_Ico] omega obtain ⟨v, -, hF⟩ := Finset.exists_lt_card_fiber_of_mul_lt_card_of_maps_to hmap hcard have hFne : ((Ico A (A + (q * M + 1))).filter fun x => g x = v).Nonempty := by rw [← card_pos] omega set F := (Ico A (A + (q * M + 1))).filter fun x => g x = v with hFdef have hk1 : F.min' hFne ∈ F := min'_mem _ _ have hk2 : F.max' hFne ∈ F := max'_mem _ _ have hsubF : F ⊆ Icc (F.min' hFne) (F.max' hFne) := fun k hk => mem_Icc.2 ⟨min'_le _ _ hk, le_max' _ _ hk⟩ have hc := card_le_card hsubF rw [Nat.card_Icc] at hc obtain ⟨hk1a, hk1v⟩ := mem_filter.1 hk1 obtain ⟨hk2a, hk2v⟩ := mem_filter.1 hk2 rw [mem_Ico] at hk1a hk2a have hk12 : F.min' hFne ≤ F.max' hFne := min'_le _ _ hk2 refine ⟨F.min' hFne, hk1a.1, by omega, fun k hk hk' => ?_⟩ have e1 := hmono (F.min' hFne) k hk (by omega) have e2 := hmono k (F.max' hFne) (by omega) (by omega) omega /-- The core of Case C on the partner's side (linear count): among `(4m+1)(2m-1) + 1` consecutiveopenings from the rank `A` on, `2m - 1` consecutive ones `k1, …, k1 + 2m - 2` lie in one piecewithout cut points. On it `r` opening rows are active, `1 ≤ r ≤ m`; the closing counts betweenconsecutive openings are `r`-periodic there, and if `r = m` then the `m` closing counts from `k1` onadd up to at most `a` (`m = a + 1`). -/theorem zone_lin (a b : ℕ) (ha : 1 ≤ a) (θ' Λ' : ℝ) (hinj : Set.InjOn (opos θ') ↑(range (a + 1) ×ˢ range (b + 1))) (hx : (b : ℝ) < Λ' + a * θ') (A : ℕ) (hA : A + ((4 * (a + 1) + 1) * (2 * a + 1) + 1) ≤ (a + 1) * (b + 1)) : ∃ yk : ℕ → ℝ, (∀ k < (a + 1) * (b + 1), yk k ∈ openingSet a b θ' ∧ openingIndex a b θ' (yk k) = k) ∧ ∃ k1 r : ℕ, A ≤ k1 ∧ 1 ≤ r ∧ r ≤ a + 1 ∧ k1 + 2 * a + 1 < (a + 1) * (b + 1) ∧ (r < a + 1 → ∀ k, k1 ≤ k → k + r + 1 ≤ k1 + 2 * a → ((openingIndex a b θ' (yk (k + r + 1) - Λ') : ℤ) - openingIndex a b θ' (yk (k + r) - Λ')) = (openingIndex a b θ' (yk (k + 1) - Λ') : ℤ) - openingIndex a b θ' (yk k - Λ')) ∧ (r = a + 1 → ((openingIndex a b θ' (yk (k1 + (a + 1)) - Λ') : ℤ) - openingIndex a b θ' (yk k1 - Λ')) ≤ a) := by obtain ⟨yk, hyk⟩ := exists_rank a b θ' hinj refine ⟨yk, hyk, ?_⟩ set K := (a + 1) * (b + 1) with hK have hstrict : ∀ k k', k < k' → k' < K → yk k < yk k' := by intro k k' hkk hk' by_contra hcon push Not at hcon have h1 := openingIndex_mono a b θ' hcon rw [(hyk k' hk').2, (hyk k (by omega)).2] at h1 omega have hmono_y : ∀ u v, u ≤ v → v < K → yk u ≤ yk v := by intro u v huv hv rcases Nat.eq_or_lt_of_le huv with h | h · rw [h] · exact (hstrict u v h hv).le set S := SS a b θ' Λ' with hS set g : ℕ → ℕ := fun k => (S.filter fun s => s < yk k).card with hg have hmono_g : ∀ k k', k ≤ k' → k' < K → g k ≤ g k' := by intro k k' hkk hk' apply card_le_card intro s hs rw [mem_filter] at hs ⊢ exact ⟨hs.1, lt_of_lt_of_le hs.2 (hmono_y k k' hkk hk')⟩ have hq : ∀ k < K, g k < 4 * (a + 1) + 1 := by intro k _ have := (card_filter_le S (fun s => s < yk k)).trans (SS_card_le a b θ' Λ') show (S.filter fun s => s < yk k).card < _ omega obtain ⟨k1, hk1A, hk1K, hconst⟩ := fiber_window g K (4 * (a + 1) + 1) (2 * a + 1) A hmono_g hq hA set L := k1 + 2 * a with hL have hLK : L + 1 < K := by omega have hgL : g k1 = g (L + 1) := (hconst (L + 1) (by omega) (by omega)).symm have hfreeS : ∀ s ∈ S, s < yk k1 ∨ yk L < s := g_free S yk k1 L (hstrict L (L + 1) (by omega) hLK) hgL have hfree : ∀ u v, k1 ≤ u → u ≤ v → v ≤ L → OFree a b θ' (yk u) (yk v) ∧ OFree a b θ' (yk u - Λ') (yk v - Λ') := by intro u v hu huv hv apply SS_free intro s hs rcases hfreeS s hs with p | p · left exact lt_of_lt_of_le p (hmono_y k1 u hu (by omega)) · right exact lt_of_le_of_lt (hmono_y v L hv (by omega)) p have hne0 : ∀ i ∈ range (a + 1), yk k1 ≠ (i : ℝ) * θ' ∧ yk k1 ≠ (i : ℝ) * θ' + b := by intro i hi obtain ⟨f1, f2⟩ := (hfree k1 k1 le_rfl le_rfl (by omega)).1 i hi constructor · intro e rcases f1 with p | p <;> linarith · intro e rcases f2 with p | p <;> linarith have hr1 : 1 ≤ rr a b θ' (yk k1) := rr_pos a b θ' _ (hyk k1 (by omega)).1 hne0 obtain ⟨r, hr⟩ : ∃ r, r = rr a b θ' (yk k1) := ⟨_, rfl⟩ rw [← hr] at hr1 have hrle : r ≤ a + 1 := by rw [hr]; exact rr_le a b θ' _ have hrk : ∀ k', k1 ≤ k' → k' ≤ L → rr a b θ' (yk k') = r := by intro k' h1 h2 rw [hr] exact (rr_congr a b θ' _ _ (hmono_y k1 k' h1 (by omega)) (hfree k1 k' le_rfl h1 h2).1).symm have htr : ∀ k', k1 ≤ k' → k' + r ≤ L → yk (k' + r) = yk k' + 1 := by intro k' h1 h2 obtain ⟨f1, -⟩ := hfree k' (k' + r) h1 (by omega) h2 have hxt : yk k' < yk (k' + r) := hstrict k' (k' + r) (by omega) (by omega) have hcnt : (openingIndex a b θ' (yk (k' + r)) : ℤ) = openingIndex a b θ' (yk k') + rr a b θ' (yk k') := by rw [(hyk (k' + r) (by omega)).2, (hyk k' (by omega)).2, hrk k' h1 (by omega)] push_cast ring exact trans_rank_eq a b θ' hinj (yk k') (yk (k' + r)) (hyk k' (by omega)).1 (hyk (k' + r) (by omega)).1 hxt f1 hcnt refine ⟨k1, r, hk1A, hr1, hrle, by omega, ?_, ?_⟩ · intro _ k hk hkL have e1 := htr k hk (by omega) have e2 := htr (k + 1) (by omega) (by omega) have e2' : yk (k + r + 1) = yk (k + 1) + 1 := by rw [show k + r + 1 = k + 1 + r by omega] exact e2 have hfr := (hfree k (k + r + 1) hk (by omega) (by omega)).2 rw [e2'] at hfr have hα1 : yk k + 1 - Λ' = (yk k - Λ') + 1 := by ring have hβ1 : yk (k + 1) + 1 - Λ' = (yk (k + 1) - Λ') + 1 := by ring rw [hβ1] at hfr have hαβ : yk k - Λ' ≤ yk (k + 1) - Λ' := by have := hstrict k (k + 1) (by omega) (by omega) linarith rw [e1, e2', hα1, hβ1] have hA1 := openingIndex_add_one a b θ' hinj (yk k - Λ') (hfr.mono le_rfl (by linarith)) have hB1 := openingIndex_add_one a b θ' hinj (yk (k + 1) - Λ') (hfr.mono hαβ le_rfl) have hrr := rr_congr a b θ' (yk k - Λ') (yk (k + 1) - Λ') hαβ (hfr.mono le_rfl (by linarith)) omega · intro hreq have e1 : yk (k1 + (a + 1)) = yk k1 + 1 := by have := htr k1 le_rfl (by omega) rw [hreq] at this exact this have hfr := (hfree k1 (k1 + (a + 1)) le_rfl (by omega) (by omega)).2 rw [e1, show yk k1 + 1 - Λ' = (yk k1 - Λ') + 1 by ring] at hfr have hadd := openingIndex_add_one a b θ' hinj (yk k1 - Λ') hfr rw [e1, show yk k1 + 1 - Λ' = (yk k1 - Λ') + 1 by ring, hadd] have hle2 : rr a b θ' (yk k1 - Λ') ≤ a := by by_contra hcon push Not at hcon have heq2 : rr a b θ' (yk k1 - Λ') = a + 1 := le_antisymm (rr_le a b θ' _) (by omega) have heq : rr a b θ' (yk k1) = a + 1 := by rw [← hr]; exact hreq have h1 := (card_filter_eq_iff (s := range (a + 1)) (p := fun i : ℕ => (i : ℝ) * θ' < yk k1 ∧ yk k1 < (i : ℝ) * θ' + b)).1 (by unfold rr at heq; rw [heq, card_range]) have h2 := (card_filter_eq_iff (s := range (a + 1)) (p := fun i : ℕ => (i : ℝ) * θ' < yk k1 - Λ' ∧ yk k1 - Λ' < (i : ℝ) * θ' + b)).1 (by unfold rr at heq2; rw [heq2, card_range]) have a1 : yk k1 < b := by have := (h1 0 (by simp)).2 simpa using this have a2 := (h2 a (by simp)).1 linarith have : (rr a b θ' (yk k1 - Λ') : ℤ) ≤ a := by exact_mod_cast hle2 linarith theorem zeroCount_upper (a b : ℕ) (Λ θ : ℝ) (hθ : 0 < θ) (haθ : (a : ℝ) * θ < 1) (hc : IsCentral a b Λ) : (zeroCount a b θ Λ : ℤ) ≤ ((a : ℤ) + 1) * (⌊Λ⌋ + 1) := by obtain ⟨hJ1, hJ2⟩ := hc have hCa : 0 < Ca a := by unfold Ca; positivity have hΛJ := Int.floor_le Λ have hΛJ' := Int.lt_floor_add_one Λ have hJ5 : (5 : ℝ) ≤ ((⌊Λ⌋ : ℤ) : ℝ) := by exact_mod_cast (by omega : (5 : ℤ) ≤ ⌊Λ⌋) have hJb : ((⌊Λ⌋ : ℤ) : ℝ) ≤ b := by exact_mod_cast (by omega : ⌊Λ⌋ ≤ (b : ℤ)) rw [zeroCount_eq a b θ Λ hθ haθ (by linarith) (by linarith)] refine (sum_bounds a _ ⌊Λ⌋ ?_).2 intro i hi rw [mem_range] at hi have hia : (i : ℝ) ≤ a := by exact_mod_cast (by omega : i ≤ a) have hit : (i : ℝ) * θ ≤ a * θ := mul_le_mul_of_nonneg_right hia hθ.le have hit0 : 0 ≤ (i : ℝ) * θ := by positivity constructor · have := Int.lt_ceil.mpr (show (((⌊Λ⌋ - 1 : ℤ)) : ℝ) < Λ - (i : ℝ) * θ by push_cast; linarith) omega · exact Int.ceil_le.mpr (by push_cast; linarith) /-- What the partner `d` inherits from `c`: the function `D`, the numbers `Z_k` (as functions of therank `k`) and `z₀`. -/theorem partner_data (a b : ℕ) (ha : 2 ≤ a) (Λ θ : ℝ) (hθ0 : 0 < θ) (hθ : θ < 1 / (a : ℝ)) (hoff : OffLines a Λ θ) (hc : IsCentral a b Λ) (Λ' θ' : ℝ) (hΛ' : 0 < Λ') (hθ'0 : 0 < θ') (hirr : Irrational θ') (hoff' : OffLines a Λ' θ') (hZ : Z a b (cellVec a b Λ' θ') = Z a b (cellVec a b Λ θ)) : (∀ y ∈ openingSet a b θ', zeroCount a b θ' Λ' ≤ openingIndex a b θ' y → |(windowCount a b θ' Λ' y : ℤ) - (zeroCount a b θ' Λ' : ℤ)| ≤ (a : ℤ) + 1) ∧ (∀ y ∈ openingSet a b θ', (openingIndex a b θ' (y - Λ') : ℤ) = CaballeroBlock.Zk a b Λ θ (openingIndex a b θ' y)) ∧ ((a : ℤ) + 1) * ⌊Λ⌋ ≤ (zeroCount a b θ' Λ' : ℤ) ∧ (zeroCount a b θ' Λ' : ℤ) ≤ ((a : ℤ) + 1) * (⌊Λ⌋ + 1) := by have ha0 : (0 : ℝ) < a := by exact_mod_cast (by omega : 0 < a) have haθ : (a : ℝ) * θ < 1 := by rw [lt_div_iff₀ ha0] at hθ linarith have hc' := hc obtain ⟨hJ1, hJ2⟩ := hc have hΛJ := Int.floor_le Λ have hJ5 : (5 : ℝ) ≤ ((⌊Λ⌋ : ℤ) : ℝ) := by exact_mod_cast (by omega : (5 : ℤ) ≤ ⌊Λ⌋) have hΛ : 0 < Λ := by linarith have hinj := CaballeroGeneralA.opos_injOn a b θ hθ0 haθ have hinj' := opos_injOn_irr a b θ' hirr have hcR : Realisable a b (cellVec a b Λ θ) := ⟨Λ, θ, hΛ, hθ0, hoff, rfl⟩ have hdR : Realisable a b (cellVec a b Λ' θ') := ⟨Λ', θ', hΛ', hθ'0, hoff', rfl⟩ have hrows : Zr a b (cellVec a b Λ θ) = Zr a b (cellVec a b Λ' θ') := (rows_iff a b _ _ hcR hdR).2 hZ.symm rw [Zr_eq_map a b Λ θ hoff hinj, Zr_eq_map a b Λ' θ' hoff' hinj'] at hrows have hmulti := (Multiset.map_injective Nat.cast_injective) hrows have hz : zeroCount a b θ Λ = zeroCount a b θ' Λ' := by rw [zeroCount_eq_below a b θ Λ hθ0 hoff, zeroCount_eq_below a b θ' Λ' hθ'0 hoff', below_eq_card, below_eq_card, hmulti] have hcardP' : (openingSet a b θ').card = (a + 1) * (b + 1) := by unfold openingSet rw [card_image_of_injOn hinj', card_product, card_range, card_range] have key : ∀ y ∈ openingSet a b θ', ∃ x ∈ openingSet a b θ, x = CaballeroBlock.pk a b θ (openingIndex a b θ' y) ∧ openingIndex a b θ' y < (a + 1) * (b + 1) ∧ openingIndex a b θ x = openingIndex a b θ' y ∧ closeBefore a b θ Λ x = closeBefore a b θ' Λ' y ∧ windowCount a b θ Λ x = windowCount a b θ' Λ' y := by intro y hy obtain ⟨r, hr⟩ : ∃ r, r = ((openingSet a b θ').filter fun z => z < y).card := ⟨_, rfl⟩ have hrK : r < (a + 1) * (b + 1) := by rw [← hcardP', hr] exact card_lt_card (filter_ssubset.2 ⟨y, hy, lt_irrefl y⟩) have hxP : CaballeroBlock.pk a b θ r ∈ openingSet a b θ := by have : CaballeroBlock.pk a b θ r ∈ CaballeroBlock.openPos a b θ := by rw [CaballeroBlock.pk_eq a b θ hθ0 haθ r hrK, CaballeroBlock.openPos_eq, mem_image] exact ⟨r, mem_range.2 hrK, rfl⟩ exact this have hxr : ((openingSet a b θ).filter fun z => z < CaballeroBlock.pk a b θ r).card = r := CaballeroBlock.card_lt_pk a b θ hθ0 haθ r hrK have hZeq := rank_eq (openingSet a b θ) (openingSet a b θ') (closeBefore a b θ Λ) (closeBefore a b θ' Λ') (closeBefore_mono a b θ Λ) (closeBefore_mono a b θ' Λ') hmulti (CaballeroBlock.pk a b θ r) y hxP hy (hxr.trans hr) have h1 : windowCount a b θ Λ (CaballeroBlock.pk a b θ r) + closeBefore a b θ Λ (CaballeroBlock.pk a b θ r) = r := by rw [windowCount_add a b θ Λ _ hΛ.le] exact hxr have h2 : windowCount a b θ' Λ' y + closeBefore a b θ' Λ' y = r := by rw [windowCount_add a b θ' Λ' _ hΛ'.le, hr] rfl have hW : windowCount a b θ Λ (CaballeroBlock.pk a b θ r) = windowCount a b θ' Λ' y := by omega have hcy : openingIndex a b θ' y = r := by rw [hr]; rfl refine ⟨CaballeroBlock.pk a b θ r, hxP, by rw [hcy], by rw [hcy]; exact hrK, by rw [hcy]; exact hxr, hZeq, hW⟩ refine ⟨?_, ?_, ?_, ?_⟩ · intro y hy hk obtain ⟨x, hxP, -, -, hxi, -, hwc⟩ := key y hy have hk' : zeroCount a b θ Λ ≤ openingIndex a b θ x := by rw [hxi, hz] exact hk have hband := band_le a b Λ θ hθ0 haθ hoff hc' x hxP hk' rw [hwc, hz] at hband exact hband · intro y hy obtain ⟨x, hxP, hxeq, hrK, -, hcl, -⟩ := key y hy rw [CaballeroBlock.Zk_eq_card a b Λ θ hθ0 haθ hΛ _ hrK, ← hxeq] exact_mod_cast hcl.symm · have := zeroCount_ge a b Λ θ hθ0 haθ hc' rw [hz] at this exact this · have := zeroCount_upper a b Λ θ hθ0 haθ hc' rw [hz] at this exact this theorem exists_mod_eq (m k1 i0 : ℕ) (hm : 0 < m) (hi : i0 < m) : ∃ k, k1 ≤ k ∧ k < k1 + m ∧ k % m = i0 := by have h := Nat.div_add_mod k1 m have hρ := Nat.mod_lt k1 hm by_cases hcase : k1 % m ≤ i0 · refine ⟨m * (k1 / m) + i0, by omega, by omega, ?_⟩ rw [Nat.mul_add_mod] exact Nat.mod_eq_of_lt hi · refine ⟨m * (k1 / m + 1) + i0, ?_, ?_, ?_⟩ · rw [Nat.mul_add] omega · rw [Nat.mul_add] omega · rw [Nat.mul_add_mod] exact Nat.mod_eq_of_lt hi theorem mod_add_ne (m k r i0 : ℕ) (hr1 : 0 < r) (hr2 : r < m) (h : k % m = i0) : (k + r) % m ≠ i0 := by intro h2 have h3 : (k + r) % m = k % m := by rw [h2, h] have h4 : k + r ≡ k + 0 [MOD m] := by show (k + r) % m = (k + 0) % m rw [Nat.add_zero] exact h3 have h5 := Nat.ModEq.add_left_cancel' k h4 unfold Nat.ModEq at h5 rw [Nat.mod_eq_of_lt hr2] at h5 simp at h5 omega /-- The period sum of the block: `Z_{k+m} - Z_k = m` in the periodic range `m(J+1) ≤ k`,`k + m < K`. -/theorem Zk_period (a b : ℕ) (Λ θ : ℝ) (hθ0 : 0 < θ) (haθ : (a : ℝ) * θ < 1) (hoff : OffLines a Λ θ) (hc : IsCentral a b Λ) (k : ℕ) (hk1 : ((a : ℤ) + 1) * (⌊Λ⌋ + 1) ≤ k) (hk2 : k + (a + 1) < (a + 1) * (b + 1)) : CaballeroBlock.Zk a b Λ θ (k + (a + 1)) - CaballeroBlock.Zk a b Λ θ k = (a : ℤ) + 1 := by obtain ⟨j, i, hi, rfl⟩ : ∃ j i, i ≤ a ∧ k = (a + 1) * j + i := ⟨k / (a + 1), k % (a + 1), by have := Nat.mod_lt k (show 0 < a + 1 by omega); omega, (Nat.div_add_mod k (a + 1)).symm⟩ have hj1 : ⌊Λ⌋ + 1 ≤ (j : ℤ) := by by_contra hlt push Not at hlt have h1 : (j : ℤ) + 1 ≤ ⌊Λ⌋ + 1 := by omega have h2 : ((a : ℤ) + 1) * ((j : ℤ) + 1) ≤ ((a : ℤ) + 1) * (⌊Λ⌋ + 1) := mul_le_mul_of_nonneg_left h1 (by omega) push_cast at hk1 have h3 : (i : ℤ) ≤ a := by exact_mod_cast hi nlinarith have hjb : j + 1 ≤ b := by have h1 : (a + 1) * (j + 1) < (a + 1) * (b + 1) := by rw [Nat.mul_add] omega have := Nat.lt_of_mul_lt_mul_left h1 omega have e2 : (a + 1) * j + i + (a + 1) = (a + 1) * (j + 1) + i := by ring rw [e2, CaballeroBlock.Zk_eq a b Λ θ hθ0 haθ hoff hc i (j + 1) hi (by push_cast; omega) hjb, CaballeroBlock.Zk_eq a b Λ θ hθ0 haθ hoff hc i j hi hj1 (by omega)] push_cast ring /-- Case C of the paper (`x = Λ' + aθ' > b`), linear count: some piece of the partner without cutpoints holds `2m - 1` consecutive tail openings. If `r < m` opening rows are active there, thedifferences `δ` of `c` would repeat at distance `r`, giving a second marker in a period; if `r = m`,then `m` consecutive values of `δ` would add up to at most `a`, against the period sum `m`. -/theorem caseC (a b : ℕ) (ha : 2 ≤ a) (Λ θ : ℝ) (hθ0 : 0 < θ) (hθ : θ < 1 / (a : ℝ)) (hoff : OffLines a Λ θ) (hc : IsCentral a b Λ) (hO1 : ¬ IsO1 a (cellVec a b Λ θ)) (Λ' θ' : ℝ) (hΛ' : 0 < Λ') (hθ'0 : 0 < θ') (hirr : Irrational θ') (hoff' : OffLines a Λ' θ') (hZ : Z a b (cellVec a b Λ' θ') = Z a b (cellVec a b Λ θ)) (hx : (b : ℝ) < Λ' + a * θ') : False := by obtain ⟨-, hZk, -, -⟩ := partner_data a b ha Λ θ hθ0 hθ hoff hc Λ' θ' hΛ' hθ'0 hirr hoff' hZ have hinj' := opos_injOn_irr a b θ' hirr have ha0 : (0 : ℝ) < a := by exact_mod_cast (by omega : 0 < a) have haθ : (a : ℝ) * θ < 1 := by rw [lt_div_iff₀ ha0] at hθ linarith have hc' := hc obtain ⟨hJ1, hJ2⟩ := hc obtain ⟨n, hn⟩ : ∃ n : ℕ, (n : ℤ) = ⌊Λ⌋ := ⟨⌊Λ⌋.toNat, by omega⟩ have hA : (a + 1) * (n + 1) + ((4 * (a + 1) + 1) * (2 * a + 1) + 1) ≤ (a + 1) * (b + 1) := by have h1 : (0 : ℤ) ≤ ((a : ℤ) + 1) * ((b : ℤ) - n - Ca a) := mul_nonneg (by positivity) (by omega) have : (((a + 1) * (n + 1) + ((4 * (a + 1) + 1) * (2 * a + 1) + 1) : ℕ) : ℤ) ≤ (((a + 1) * (b + 1) : ℕ) : ℤ) := by push_cast unfold Ca at h1 nlinarith [h1] exact_mod_cast this obtain ⟨yk, hyk, k1, r, hk1A, hr1, hrle, hk1K, hper, hsum⟩ := zone_lin a b (by omega) θ' Λ' hinj' hx ((a + 1) * (n + 1)) hA have zk : ∀ k, k < (a + 1) * (b + 1) → CaballeroBlock.Zk a b Λ θ k = (openingIndex a b θ' (yk k - Λ') : ℤ) := by intro k hk have := hZk (yk k) (hyk k hk).1 rw [(hyk k hk).2] at this exact this.symm have hAk : ∀ k, (a + 1) * (n + 1) ≤ k → ((a : ℤ) + 1) * (⌊Λ⌋ + 1) ≤ (k : ℤ) := by intro k hk rw [← hn] exact_mod_cast hk rcases Nat.lt_or_ge r (a + 1) with hrlt | hrge · obtain ⟨i0, ⟨hi0, hd0⟩, huniq⟩ := exactly_one_marker a b ha Λ θ hθ0 hθ.le hoff hc' hO1 obtain ⟨k, hk1, hk2, hkmod⟩ := exists_mod_eq (a + 1) k1 i0 (by omega) (by omega) obtain ⟨j, hj1, hj2, hjk⟩ : ∃ j, k1 ≤ j ∧ j + r + 1 ≤ k1 + 2 * a ∧ (j = k ∨ j + r = k) := by by_cases hcase : k + r + 1 ≤ k1 + 2 * a · exact ⟨k, hk1, hcase, Or.inl rfl⟩ · exact ⟨k - r, by omega, by omega, Or.inr (by omega)⟩ have hdelj := hper hrlt j hj1 hj2 have hblk := (CaballeroBlock.block_structure a b (by omega) Λ θ hθ0 hθ hoff hc').1 have d1 := hblk j (hAk j (by omega)) (by omega) have d2 := hblk (j + r) (hAk (j + r) (by omega)) (by omega) have hdel : CaballeroBlock.deltaK a b Λ θ (j + r) = CaballeroBlock.deltaK a b Λ θ j := by unfold CaballeroBlock.deltaK rw [zk (j + r + 1) (by omega), zk (j + r) (by omega), zk (j + 1) (by omega), zk j (by omega)] exact hdelj have hmj : CaballeroBlock.blockDelta a (cellVec a b Λ θ) (j % (a + 1)) = CaballeroBlock.blockDelta a (cellVec a b Λ θ) ((j + r) % (a + 1)) := by rw [← d1, ← d2, hdel] have hneq := mod_add_ne (a + 1) j r (j % (a + 1)) hr1 hrlt rfl have hmod_lt : ∀ t, t % (a + 1) ≤ a := fun t => by have := Nat.mod_lt t (show 0 < a + 1 by omega) omega rcases hjk with hjk | hjk · have hjm : j % (a + 1) = i0 := by rw [hjk]; exact hkmod have h2 : 2 ≤ markerDelta a (cellVec a b Λ θ) ((j + r) % (a + 1)) := by show 2 ≤ CaballeroBlock.blockDelta a (cellVec a b Λ θ) ((j + r) % (a + 1)) rw [← hmj, hjm] exact hd0 exact hneq ((huniq _ ⟨hmod_lt _, h2⟩).trans hjm.symm) · have hjm : (j + r) % (a + 1) = i0 := by rw [hjk]; exact hkmod have h2 : 2 ≤ markerDelta a (cellVec a b Λ θ) (j % (a + 1)) := by show 2 ≤ CaballeroBlock.blockDelta a (cellVec a b Λ θ) (j % (a + 1)) rw [hmj, hjm] exact hd0 exact hneq (hjm.trans (huniq _ ⟨hmod_lt _, h2⟩).symm) · have hreq : r = a + 1 := le_antisymm hrle hrge have hs := hsum hreq have hp := Zk_period a b Λ θ hθ0 haθ hoff hc' k1 (hAk k1 hk1A) (by omega) rw [zk (k1 + (a + 1)) (by omega), zk k1 (by omega)] at hp omega /-- The core of Proposition 14 for `θ < 1/a` and a partner `d` realised at a point `(Λ', θ')` withirrational `θ'` (Cases A, B, C of the paper). -/theorem partner_eq (a b : ℕ) (ha : 2 ≤ a) (Λ θ : ℝ) (hθ0 : 0 < θ) (hθ : θ < 1 / (a : ℝ)) (hoff : OffLines a Λ θ) (hc : IsCentral a b Λ) (hO1 : ¬ IsO1 a (cellVec a b Λ θ)) (Λ' θ' : ℝ) (hΛ' : 0 < Λ') (hθ'0 : 0 < θ') (hirr : Irrational θ') (hoff' : OffLines a Λ' θ') (hZ : Z a b (cellVec a b Λ' θ') = Z a b (cellVec a b Λ θ)) : cellVec a b Λ' θ' = cellVec a b Λ θ := by have hxb : Λ' + a * θ' ≠ b := by have := hoff' a (by omega) le_rfl b simpa using this obtain ⟨hB, hz0⟩ := partner_facts a b ha Λ θ hθ0 hθ hoff hc Λ' θ' hΛ' hθ'0 hirr hoff' hZ rcases lt_or_gt_of_ne hxb with hlt | hgt · by_cases hA : (a : ℝ) * θ' ≤ Λ' · exact caseA a b ha Λ θ hθ0 hθ hoff hc Λ' θ' hΛ' hθ'0 hoff' hZ hlt hA hB · exact (caseB a b Λ hc Λ' θ' hΛ' hθ'0 hlt (not_le.1 hA) hB hz0).elim · exact (caseC a b ha Λ θ hθ0 hθ hoff hc hO1 Λ' θ' hΛ' hθ'0 hirr hoff' hZ hgt).elim /-- Proposition 14 (central rigidity). -/theorem central_rigidity (a b : ℕ) (ha : 2 ≤ a) (Λ θ : ℝ) (hΛ : 0 < Λ) (hθ0 : 0 < θ) (hθ : θ ≤ 1 / (a : ℝ)) (hoff : OffLines a Λ θ) (hc : IsCentral a b Λ) (hO1 : ¬ IsO1 a (cellVec a b Λ θ)) : ∀ d : Vec a, Realisable a b d → Z a b d = Z a b (cellVec a b Λ θ) → d = cellVec a b Λ θ := by intro d hd hZ have _ := hΛ obtain ⟨θ1, h0, h1, hoff1, hcv⟩ := exists_strict_point a b Λ θ hθ0 hθ hoff obtain ⟨Λ', θ', hΛ', hθ', hirr, hoff', rfl⟩ := exists_irrational_point a b d hd rw [← hcv] at hO1 hZ ⊢ exact partner_eq a b ha Λ θ1 h0 h1 hoff1 hc hO1 Λ' θ' hΛ' hθ' hirr hoff' hZ end CaballeroRigid