import Mathlib /-! # Non-Termination of Graham's Congruence-Restricted Greedy Egyptian Fraction Algorithm # (Refutation of Erdős Problem #282, Graham Variant) Ronald Graham (1964) proved that a positive rational `x = m / n` can be expressed as a finite sum of distinct unit fractions with denominators congruent to `a (mod d)` (`d > 1`) if and only if `gcd(n / gcd(n, gcd(a, d)), d / gcd(a, d)) = 1`. Erdős and Graham (1980, p. 31; cataloged as `Erdos282.erdos_282.variants.graham` in Google DeepMind's `FormalConjectures`) asked whether the greedy algorithm restricted to `{n : ℕ | n ≡ a [MOD d]}` always terminates whenever Graham's representability criterion holds. We **disprove** this conjecture completely and constructively, and establish a rich infinite dynamical family of counterexamples: 1. **Exact Period-12 Mod-420 Dynamical Attractor (`attractor_orbit_spec`):** For both `d = 3` and `d = 6` (with `a = 1`), every rational `x = 1 / q` with `q ≡ 119 [MOD 420]` (equivalently `q ≡ 3 [MOD 4]`, `q ≡ 2 [MOD 3]`, `q ≡ 4 [MOD 5]`, and `7 ∣ q`, starting at `q = 119`) enters a closed 12-step modular cycle under the greedy algorithm: * The reduced numerator cycles periodically with period 6 through `(1, 2, 3, 4, 5, 6)`, * The chosen greedy denominators `n_t = (q_t + k_t + 1) / k_t` are strictly increasing, all satisfy `n_t ≡ 1 [MOD 6]` (hence also `n_t ≡ 1 [MOD 3]`), and never repeat, * The remainder denominator `q_t` grows doubly exponentially (`42 * q_{t+1} > q_t^2` and `q_{t+1} ≥ 2 * q_t`) and returns to `q ≡ 119 [MOD 420]` every 12 steps, * In particular, `greedyUnitFractionRem {n | n ≡ 1 [MOD d]} (1 / q) t > 0` for all `t : ℕ`. 2. **Small Benchmark Counterexample (`nontermination_three_seventeenths`):** For both `d = 3` and `d = 6` (`a = 1`), `x = 3 / 17` takes four greedy steps `7, 31, 739, 454363` to land on `1 / 176953033439`, where `176953033439 % 420 = 119`, and never terminates—even though `3 / 17 = 1/7 + 1/34 + 1/238` (`explicit_rep_three_div_17_mod3`). 3. **Constructive Representability (`explicit_rep_one_div_119_mod6`):** `1 / 119 = 1/169 + 1/805 + 1/1105 + 1/4225 + 1/9775`, with all 5 denominators distinct and `≡ 1 [MOD 6]` (hence also `≡ 1 [MOD 3]`), giving a self-contained demonstration that representability does not imply greedy termination. 4. **Universal Scaling to Infinitely Many Arithmetic Progressions (`scaled_family_nontermination`):** Via the exact scaling identity `greedy_scale_pos`, for **every** `m ≥ 1`, **every** `d ∈ {3 * m, 6 * m}` with `a = m`, and **every** `q` with `q % 420 = 119`, the rational `x = 1 / (m * q) ∈ (0, 1)` satisfies Graham's condition yet never terminates. 5. **Direct Refutation (`not_erdos_282_graham`) & Infinitude Theorems:** Directly disproves the verbatim formal statement of `erdos_282.variants.graham`, and proves there are infinitely many failing progressions `(a, d)` and infinitely many failing rationals in each such progression. -/ namespace OpenAdditiveNumberTheory.GreedyEgyptian open Filter /-! ## Section 1: Exact Greedy Algorithm Definition & General Infrastructure -/ /-- Exact definition of `greedyUnitFractionRem` matching `FormalConjectures/ErdosProblems/282.lean`: at each step, if `x ≤ 0` return `0`; otherwise choose the minimal `n ∈ A` with `1 / x ≤ n`, subtract `1 / n`, and continue on `A \ {n}`. -/ noncomputable def greedyUnitFractionRem (A : Set ℕ) (x : ℚ) (t : ℕ) : ℚ := if x ≤ 0 then 0 else let n := sInf { n | n ∈ A ∧ 1 / x ≤ n } let rem := x - 1 / n match t with | 0 => rem | t + 1 => greedyUnitFractionRem (A \ {n}) rem t /-- Graham's arithmetic representability condition for `x : ℚ` with denominators `≡ a [MOD d]`. -/ def GrahamCond (x : ℚ) (a d : ℕ) : Prop := (x.den / x.den.gcd (a.gcd d)).gcd (d / a.gcd d) = 1 /-- Existence of a finite representation of `x` as a sum of distinct unit fractions from `A`. -/ def IsEgyptianRepFrom (A : Set ℕ) (x : ℚ) : Prop := ∃ S : Finset ℕ, (∀ n ∈ S, n ∈ A ∧ 0 < n) ∧ ∑ n ∈ S, (1 : ℚ) / (n : ℚ) = x /-- If `n` is the least element of `{ m | m ∈ A ∧ 1 / x ≤ (m : ℚ) }`, then `sInf` equals `n`. -/ theorem sInf_greedy_eq {A : Set ℕ} {x : ℚ} {n : ℕ} (hnA : n ∈ A) (hnx : 1 / x ≤ (n : ℚ)) (hmin : ∀ m : ℕ, m ∈ A → 1 / x ≤ (m : ℚ) → n ≤ m) : sInf { m : ℕ | m ∈ A ∧ 1 / x ≤ (m : ℚ) } = n := IsLeast.csInf_eq ⟨⟨hnA, hnx⟩, fun _ hm => hmin _ hm.1 hm.2⟩ theorem greedy_step_zero {A : Set ℕ} {x : ℚ} {n : ℕ} (hx : 0 < x) (hnA : n ∈ A) (hnx : 1 / x ≤ (n : ℚ)) (hmin : ∀ m : ℕ, m ∈ A → 1 / x ≤ (m : ℚ) → n ≤ m) : greedyUnitFractionRem A x 0 = x - 1 / (n : ℚ) := by unfold greedyUnitFractionRem rw [if_neg (not_le.mpr hx), sInf_greedy_eq hnA hnx hmin] theorem greedy_step_succ {A : Set ℕ} {x : ℚ} {n : ℕ} (t : ℕ) (hx : 0 < x) (hnA : n ∈ A) (hnx : 1 / x ≤ (n : ℚ)) (hmin : ∀ m : ℕ, m ∈ A → 1 / x ≤ (m : ℚ) → n ≤ m) : greedyUnitFractionRem A x (t + 1) = greedyUnitFractionRem (A \ {n}) (x - 1 / (n : ℚ)) t := by conv_lhs => unfold greedyUnitFractionRem rw [if_neg (not_le.mpr hx), sInf_greedy_eq hnA hnx hmin] /-- Exact scaling symmetry of `greedyUnitFractionRem`: multiplying the denominator set `A` by `c > 0` and dividing `x` by `c` scales every remainder by `1 / c`. -/ theorem greedy_scale_pos {c : ℕ} (hc : 0 < c) : ∀ (t : ℕ) (A : Set ℕ) (x : ℚ), greedyUnitFractionRem ((fun n => c * n) '' A) (x / (c : ℚ)) t = greedyUnitFractionRem A x t / (c : ℚ) | t, A, x => by have hcQ : (0 : ℚ) < (c : ℚ) := by exact_mod_cast hc by_cases hx : x ≤ 0 · have hxc : x / (c : ℚ) ≤ 0 := div_nonpos_of_nonpos_of_nonneg hx hcQ.le unfold greedyUnitFractionRem rw [if_pos hxc, if_pos hx, zero_div] · push Not at hx have hxc : 0 < x / (c : ℚ) := div_pos hx hcQ have hset : { m : ℕ | m ∈ (fun n => c * n) '' A ∧ 1 / (x / (c : ℚ)) ≤ (m : ℚ) } = (fun n => c * n) '' { n : ℕ | n ∈ A ∧ 1 / x ≤ (n : ℚ) } := by ext m simp only [Set.mem_ofPred_eq, Set.mem_image] constructor · rintro ⟨⟨n, hnA, rfl⟩, hle⟩ refine ⟨n, ⟨hnA, ?_⟩, rfl⟩ have h1 : (c : ℚ) * (1 / x) ≤ (c : ℚ) * (n : ℚ) := by have e : 1 / (x / (c : ℚ)) = (c : ℚ) * (1 / x) := by field_simp rw [← e]; simpa [Nat.cast_mul] using hle exact le_of_mul_le_mul_left h1 hcQ · rintro ⟨n, ⟨hnA, hle⟩, rfl⟩ refine ⟨⟨n, hnA, rfl⟩, ?_⟩ have e : 1 / (x / (c : ℚ)) = (c : ℚ) * (1 / x) := by field_simp rw [e, Nat.cast_mul] exact mul_le_mul_of_nonneg_left hle hcQ.le have hsInf : sInf { m : ℕ | m ∈ (fun n => c * n) '' A ∧ 1 / (x / (c : ℚ)) ≤ (m : ℚ) } = c * sInf { n : ℕ | n ∈ A ∧ 1 / x ≤ (n : ℚ) } := by rw [hset] set S : Set ℕ := { n : ℕ | n ∈ A ∧ 1 / x ≤ (n : ℚ) } by_cases hne : S.Nonempty · have hmem : sInf S ∈ S := Nat.sInf_mem hne apply IsLeast.csInf_eq refine ⟨⟨sInf S, hmem, rfl⟩, ?_⟩ rintro _ ⟨n, hnS, rfl⟩ exact Nat.mul_le_mul_left c (Nat.sInf_le hnS) · rw [Set.not_nonempty_iff_eq_empty] at hne simp [hne] set n₀ : ℕ := sInf { n : ℕ | n ∈ A ∧ 1 / x ≤ (n : ℚ) } have hrem : x / (c : ℚ) - 1 / ((c * n₀ : ℕ) : ℚ) = (x - 1 / (n₀ : ℚ)) / (c : ℚ) := by rw [Nat.cast_mul] by_cases hn0 : n₀ = 0 · simp [hn0] · have hn0Q : (n₀ : ℚ) ≠ 0 := by exact_mod_cast hn0 have hcQ0 : (c : ℚ) ≠ 0 := hcQ.ne' field_simp cases t with | zero => unfold greedyUnitFractionRem rw [if_neg (not_le.mpr hxc), if_neg (not_le.mpr hx)] dsimp only rw [hsInf] exact hrem | succ t' => have hdiff : ((fun n => c * n) '' A) \ {c * n₀} = (fun n => c * n) '' (A \ {n₀}) := by ext m simp only [Set.mem_sdiff, Set.mem_image, Set.mem_singleton_iff] constructor · rintro ⟨⟨n, hnA, rfl⟩, hne⟩ exact ⟨n, ⟨hnA, fun h => hne (by rw [h])⟩, rfl⟩ · rintro ⟨n, ⟨hnA, hne⟩, rfl⟩ exact ⟨⟨n, hnA, rfl⟩, fun h => hne (Nat.eq_of_mul_eq_mul_left hc h)⟩ conv_lhs => unfold greedyUnitFractionRem conv_rhs => unfold greedyUnitFractionRem rw [if_neg (not_le.mpr hxc), if_neg (not_le.mpr hx)] dsimp only rw [hsInf, hdiff, hrem] exact greedy_scale_pos hc t' (A \ {n₀}) (x - 1 / (n₀ : ℚ)) /-- The image of `{n | n ≡ 1 [MOD d]}` under `n ↦ c * n` is `{m | m ≡ c [MOD c * d]}` when `c > 0`. -/ theorem image_mul_modEq_one {c d : ℕ} (hc : 0 < c) : (fun n => c * n) '' { n : ℕ | n ≡ 1 [MOD d] } = { m : ℕ | m ≡ c [MOD c * d] } := by ext m simp only [Set.mem_image, Set.mem_ofPred_eq, Nat.ModEq] have hc1 : c % (c * d) = c * (1 % d) := by simpa [mul_one] using Nat.mul_mod_mul_left c 1 d constructor · rintro ⟨n, hn, rfl⟩ rw [Nat.mul_mod_mul_left, hn, ← hc1] · intro hm have hc_dvd : c ∣ m := by rw [Nat.dvd_iff_mod_eq_zero] have h1 : m % c = (m % (c * d)) % c := (Nat.mod_mul_right_mod m c d).symm rw [h1, hm, Nat.mod_mul_right_mod, Nat.mod_self] obtain ⟨n, rfl⟩ := hc_dvd refine ⟨n, ?_, rfl⟩ rw [Nat.mul_mod_mul_left, hc1] at hm exact Nat.eq_of_mul_eq_mul_left hc hm /-! ## Section 2: Elementary Modular-Step & Greedy-Step Lemmas -/ /-- Instant kernel-fast divisibility `vk ∣ q + k + 1` from a single congruence `q % m = r`. -/ theorem dvd_add_of_mod_eq {q m r vk k : ℕ} (hq : q % m = r) (hm : vk ∣ m) (hr : vk ∣ r + k + 1) : vk ∣ q + k + 1 := by have h1 : q = m * (q / m) + r := by rw [← hq]; exact (Nat.div_add_mod q m).symm have h2 : q + k + 1 = m * (q / m) + (r + k + 1) := by omega rw [h2] exact dvd_add (dvd_mul_of_dvd_left hm _) hr /-- Instant kernel-fast divisibility `vk ∣ q + 1` from a single congruence `q % m = r`. -/ theorem dvd_succ_of_mod_eq {q m r vk : ℕ} (hq : q % m = r) (hm : vk ∣ m) (hr : vk ∣ r + 1) : vk ∣ q + 1 := by simpa using dvd_add_of_mod_eq (k := 0) hq hm hr /-- Instant kernel-fast coprimality via an explicit Bézout witness (avoids `Nat.gcd` reduction). -/ theorem coprime_of_bezout {a b : ℕ} (x y : ℤ) (h : (a : ℤ) * x + (b : ℤ) * y = 1) : Nat.Coprime a b := by rw [Nat.coprime_iff_gcd_eq_one] have hd : ((Nat.gcd a b : ℕ) : ℤ) ∣ 1 := by rw [← h] exact dvd_add (dvd_mul_of_dvd_left (Int.natCast_dvd_natCast.mpr (Nat.gcd_dvd_left a b)) x) (dvd_mul_of_dvd_left (Int.natCast_dvd_natCast.mpr (Nat.gcd_dvd_right a b)) y) exact Nat.eq_one_of_dvd_one (Int.natCast_dvd_natCast.mp hd) /-- If `a * q' ≡ a * nr [MOD nm]` and `Nat.Coprime a nm` with `nr < nm`, then `q' % nm = nr`. -/ theorem mod_eq_of_mul_mod_eq {a q' nm nr : ℕ} (hcop : Nat.Coprime a nm) (hnr : nr < nm) (h : (a * q') % nm = (a * nr) % nm) : q' % nm = nr := by have hdvd : (nm : ℤ) ∣ (a : ℤ) * ((q' : ℤ) - (nr : ℤ)) := by have hZ : ((a : ℤ) * (q' : ℤ)) % (nm : ℤ) = ((a : ℤ) * (nr : ℤ)) % (nm : ℤ) := by exact_mod_cast h have hsub : (nm : ℤ) ∣ (a : ℤ) * (nr : ℤ) - (a : ℤ) * (q' : ℤ) := Int.ModEq.dvd hZ have e : (a : ℤ) * ((q' : ℤ) - (nr : ℤ)) = -((a : ℤ) * (nr : ℤ) - (a : ℤ) * (q' : ℤ)) := by ring rw [e]; exact dvd_neg.mpr hsub have hcopZ : IsCoprime (nm : ℤ) (a : ℤ) := Nat.isCoprime_iff_coprime.mpr hcop.symm have hdvd2 : (nm : ℤ) ∣ (q' : ℤ) - (nr : ℤ) := hcopZ.dvd_of_dvd_mul_left hdvd have hmodZ2 : (q' : ℤ) % (nm : ℤ) = (nr : ℤ) % (nm : ℤ) := Int.ModEq.symm (Int.modEq_iff_dvd.mpr hdvd2) have hmodN : q' % nm = nr % nm := by exact_mod_cast hmodZ2 rwa [Nat.mod_eq_of_lt hnr] at hmodN /-- Universal quadratic modular transition lemma (covers 35 of the 36 local prime-power transitions). -/ theorem quad_step_mod {a q q' m r vk k nm nr : ℕ} (hcop : Nat.Coprime a nm) (hnr : nr < nm) (hvk : 0 < vk) (hq : q % m = r) (hm_div : vk ∣ m) (hr_div : vk ∣ r + k + 1) (heq : a * q' = q * ((q + k + 1) / vk)) (hA : nm ∣ m * (m / vk)) (hB : nm ∣ m * ((r + k + 1) / vk) + (m / vk) * r) (hC : (r * ((r + k + 1) / vk)) % nm = (a * nr) % nm) : q' % nm = nr := by apply mod_eq_of_mul_mod_eq hcop hnr rw [heq] set u : ℕ := q / m have hq_eq : q = m * u + r := by rw [← hq]; exact (Nat.div_add_mod q m).symm have hdiv : (q + k + 1) / vk = (m / vk) * u + (r + k + 1) / vk := by obtain ⟨m', hm'⟩ := hm_div obtain ⟨r', hr'⟩ := hr_div have h1 : q + k + 1 = vk * (m' * u + r') := by calc q + k + 1 = m * u + (r + k + 1) := by omega _ = (vk * m') * u + vk * r' := by rw [hm', hr'] _ = vk * (m' * u + r') := by ring rw [h1, Nat.mul_div_cancel_left _ hvk, hm', hr', Nat.mul_div_cancel_left _ hvk, Nat.mul_div_cancel_left _ hvk] rw [hdiv] have hexp : q * ((m / vk) * u + (r + k + 1) / vk) = (m * (m / vk)) * u ^ 2 + (m * ((r + k + 1) / vk) + (m / vk) * r) * u + r * ((r + k + 1) / vk) := by rw [hq_eq]; ring rw [hexp] obtain ⟨cA, hcA⟩ := hA obtain ⟨cB, hcB⟩ := hB have hmul : (m * (m / vk)) * u ^ 2 + (m * ((r + k + 1) / vk) + (m / vk) * r) * u + r * ((r + k + 1) / vk) = nm * (cA * u ^ 2 + cB * u) + r * ((r + k + 1) / vk) := by rw [hcA, hcB]; ring rw [hmul, Nat.mul_add_mod, hC] /-- Variant of `quad_step_mod` for the `j = 4, p = 2` transition where `A = 16`, `B = 48`, `nm = 32`, using `2 ∣ u * (u + 1)` and `nm ∣ B - A`. -/ theorem quad_step_mod_even {a q q' m r vk k nm nr : ℕ} (hcop : Nat.Coprime a nm) (hnr : nr < nm) (hvk : 0 < vk) (hq : q % m = r) (hm_div : vk ∣ m) (hr_div : vk ∣ r + k + 1) (heq : a * q' = q * ((q + k + 1) / vk)) (hAB_le : m * (m / vk) ≤ m * ((r + k + 1) / vk) + (m / vk) * r) (hAB_diff : nm ∣ (m * ((r + k + 1) / vk) + (m / vk) * r) - m * (m / vk)) (h2A : nm ∣ 2 * (m * (m / vk))) (hC : (r * ((r + k + 1) / vk)) % nm = (a * nr) % nm) : q' % nm = nr := by apply mod_eq_of_mul_mod_eq hcop hnr rw [heq] set u : ℕ := q / m have hq_eq : q = m * u + r := by rw [← hq]; exact (Nat.div_add_mod q m).symm have hdiv : (q + k + 1) / vk = (m / vk) * u + (r + k + 1) / vk := by obtain ⟨m', hm'⟩ := hm_div obtain ⟨r', hr'⟩ := hr_div have h1 : q + k + 1 = vk * (m' * u + r') := by calc q + k + 1 = m * u + (r + k + 1) := by omega _ = (vk * m') * u + vk * r' := by rw [hm', hr'] _ = vk * (m' * u + r') := by ring rw [h1, Nat.mul_div_cancel_left _ hvk, hm', hr', Nat.mul_div_cancel_left _ hvk, Nat.mul_div_cancel_left _ hvk] rw [hdiv] have heven : 2 ∣ u * (u + 1) := by rcases Nat.even_or_odd u with ⟨w, hw⟩ | ⟨w, hw⟩ · exact ⟨w * (u + 1), by rw [hw]; ring⟩ · exact ⟨u * (w + 1), by rw [hw]; ring⟩ obtain ⟨t, ht⟩ := heven obtain ⟨cA, hcA⟩ := h2A obtain ⟨cD, hcD⟩ := hAB_diff have hB_eq : m * ((r + k + 1) / vk) + (m / vk) * r = m * (m / vk) + nm * cD := by omega have hquad : q * ((m / vk) * u + (r + k + 1) / vk) = nm * (cA * t + cD * u) + r * ((r + k + 1) / vk) := by have h1 : q * ((m / vk) * u + (r + k + 1) / vk) = (m * (m / vk)) * (u * (u + 1)) + (nm * cD) * u + r * ((r + k + 1) / vk) := by rw [hq_eq] calc (m * u + r) * ((m / vk) * u + (r + k + 1) / vk) = (m * (m / vk)) * u ^ 2 + (m * ((r + k + 1) / vk) + (m / vk) * r) * u + r * ((r + k + 1) / vk) := by ring _ = (m * (m / vk)) * u ^ 2 + (m * (m / vk) + nm * cD) * u + r * ((r + k + 1) / vk) := by rw [hB_eq] _ = (m * (m / vk)) * (u * (u + 1)) + (nm * cD) * u + r * ((r + k + 1) / vk) := by ring rw [h1, ht] calc (m * (m / vk)) * (2 * t) + (nm * cD) * u + r * ((r + k + 1) / vk) = (2 * (m * (m / vk))) * t + (nm * cD) * u + r * ((r + k + 1) / vk) := by ring _ = (nm * cA) * t + (nm * cD) * u + r * ((r + k + 1) / vk) := by rw [hcA] _ = nm * (cA * t + cD * u) + r * ((r + k + 1) / vk) := by ring rw [hquad, Nat.mul_add_mod, hC] /-- Exact one-step greedy choice for `x = k / q` when `d ∈ {3, 6}`, `6 * k ∣ (q + 1)`, `A ⊆ {m | m ≡ 1 [MOD d]}`, and `A` contains all `m ≥ B` with `m ≡ 1 [MOD d]` for `B ≤ (q + 1) / k`. -/ theorem greedy_choice_mod36 {d k q B : ℕ} {A : Set ℕ} (hd : d = 3 ∨ d = 6) (hk : 1 ≤ k) (_hq : 1 ≤ q) (hdiv : 6 * k ∣ q + 1) (hB : B ≤ (q + 1) / k) (hA_sub : ∀ m : ℕ, m ∈ A → m ≡ 1 [MOD d]) (hA_sup : ∀ m : ℕ, B ≤ m → m ≡ 1 [MOD d] → m ∈ A) : let n := (q + k + 1) / k n ∈ A ∧ 1 / ((k : ℚ) / (q : ℚ)) ≤ (n : ℚ) ∧ (∀ m : ℕ, m ∈ A → 1 / ((k : ℚ) / (q : ℚ)) ≤ (m : ℚ) → n ≤ m) ∧ k * n = q + k + 1 ∧ n % 6 = 1 := by obtain ⟨s, hs⟩ := hdiv have hkpos : 0 < k := by omega have hq1_div : (q + 1) / k = 6 * s := by have h1 : q + 1 = k * (6 * s) := by linarith rw [h1, Nat.mul_div_cancel_left _ hkpos] have hn_eq : (q + k + 1) / k = 6 * s + 1 := by have h1 : q + k + 1 = k * (6 * s + 1) := by linarith rw [h1, Nat.mul_div_cancel_left _ hkpos] have hkn : k * ((q + k + 1) / k) = q + k + 1 := by rw [hn_eq]; linarith have hn_mod6 : ((q + k + 1) / k) % 6 = 1 := by rw [hn_eq]; omega have hn_modd : ((q + k + 1) / k) ≡ 1 [MOD d] := by rcases hd with rfl | rfl · change ((q + k + 1) / k) % 3 = 1 % 3; omega · change ((q + k + 1) / k) % 6 = 1 % 6; omega have hn_ge_B : B ≤ (q + k + 1) / k := by omega have hnA : (q + k + 1) / k ∈ A := hA_sup _ hn_ge_B hn_modd have h1x : 1 / ((k : ℚ) / (q : ℚ)) = (q : ℚ) / (k : ℚ) := by simp [one_div] have hkQ : (0 : ℚ) < (k : ℚ) := by exact_mod_cast hkpos have hnx : 1 / ((k : ℚ) / (q : ℚ)) ≤ (((q + k + 1) / k : ℕ) : ℚ) := by rw [h1x, div_le_iff₀ hkQ] have hle : q ≤ ((q + k + 1) / k) * k := by linarith exact_mod_cast hle refine ⟨hnA, hnx, ?_, hkn, hn_mod6⟩ intro m hmA hmx rw [h1x, div_le_iff₀ hkQ] at hmx have hq_le_mk : q ≤ m * k := by exact_mod_cast hmx have hm_modd : m ≡ 1 [MOD d] := hA_sub m hmA have hm_mod3 : m % 3 = 1 := by rcases hd with rfl | rfl · exact hm_modd · change m % 6 = 1 at hm_modd; omega rw [hn_eq] -- If `m ≤ 6 * s`, then `m % 3 = 1` forces `m ≤ 6 * s - 2` (or `s = 0`), contradicting `q ≤ m * k`. by_contra hlt have hle : m ≤ 6 * s := by omega have hs_pos : 1 ≤ s := by rcases eq_or_ne s 0 with rfl | hs0 · omega · omega have hm_le_sub2 : m + 2 ≤ 6 * s := by omega have hmul_le : (m + 2) * k ≤ (6 * s) * k := Nat.mul_le_mul_right k hm_le_sub2 have h6sk : (6 * s) * k = q + 1 := by linarith have : m * k + 2 * k ≤ q + 1 := by linarith omega /-- Rational subtraction formula for `k < 6`: `k / q - 1 / n = (k + 1) / (q * n)`. -/ theorem rat_sub_climb {k q n : ℕ} (hq : 0 < q) (hn : 0 < n) (hkn : k * n = q + k + 1) : (k : ℚ) / (q : ℚ) - 1 / (n : ℚ) = ((k + 1 : ℕ) : ℚ) / ((q * n : ℕ) : ℚ) := by have hqQ : (q : ℚ) ≠ 0 := by exact_mod_cast hq.ne' have hnQ : (n : ℚ) ≠ 0 := by exact_mod_cast hn.ne' have hknQ : (k : ℚ) * (n : ℚ) = (q : ℚ) + (k : ℚ) + 1 := by exact_mod_cast hkn push_cast field_simp linarith /-- Rational subtraction formula for `k = 6` with `7 ∣ q`: `6 / q - 1 / n = 1 / ((q / 7) * n)`. -/ theorem rat_sub_cancel7 {q n : ℕ} (hq : 7 ≤ q) (hn : 0 < n) (hq7 : 7 ∣ q) (h6n : 6 * n = q + 7) : (6 : ℚ) / (q : ℚ) - 1 / (n : ℚ) = 1 / (((q / 7) * n : ℕ) : ℚ) := by have hq0 : (q : ℚ) ≠ 0 := by exact_mod_cast (by omega : q ≠ 0) have hn0 : (n : ℚ) ≠ 0 := by exact_mod_cast hn.ne' have hq7_pos : 0 < q / 7 := Nat.div_pos hq (by norm_num) have hq70 : ((q / 7 : ℕ) : ℚ) ≠ 0 := by exact_mod_cast hq7_pos.ne' have hq_eq : (7 : ℚ) * ((q / 7 : ℕ) : ℚ) = (q : ℚ) := by exact_mod_cast Nat.mul_div_cancel' hq7 have h6nQ : (6 : ℚ) * (n : ℚ) = (q : ℚ) + 7 := by exact_mod_cast h6n rw [Nat.cast_mul] field_simp linear_combination ((q / 7 : ℕ) : ℚ) * h6nQ + hq_eq /-! ## Section 3: The Exact 12-Step Mod-420 Attractor -/ /-- Reduced numerator along the 12-step attractor: `1, 2, 3, 4, 5, 6` repeating periodically. -/ def numOf (j : ℕ) : ℕ := (j % 6) + 1 theorem numOf_pos (j : ℕ) : 1 ≤ numOf j := by unfold numOf; omega theorem numOf_le_six (j : ℕ) : numOf j ≤ 6 := by unfold numOf; omega theorem numOf_succ_eq (j : ℕ) : numOf (j + 1) = if numOf j < 6 then numOf j + 1 else 1 := by unfold numOf; split_ifs <;> omega /-- The exact 12-state prime-power modular invariant on the denominator `q` (periodic in `j mod 12`). -/ def Inv (j : ℕ) (q : ℕ) : Prop := match j % 12 with | 0 => q % 4 = 3 ∧ q % 3 = 2 ∧ q % 5 = 4 ∧ q % 7 = 0 | 1 => q % 16 = 15 ∧ q % 9 = 8 ∧ q % 25 = 24 ∧ q % 7 = 0 | 2 => q % 8 = 7 ∧ q % 9 = 8 ∧ q % 25 = 24 ∧ q % 7 = 0 | 3 => q % 16 = 15 ∧ q % 3 = 2 ∧ q % 25 = 24 ∧ q % 7 = 0 | 4 => q % 4 = 3 ∧ q % 9 = 8 ∧ q % 25 = 24 ∧ q % 7 = 0 | 5 => q % 32 = 31 ∧ q % 9 = 8 ∧ q % 5 = 4 ∧ q % 7 = 0 | 6 => q % 16 = 9 ∧ q % 3 = 2 ∧ q % 25 = 7 ∧ q % 7 = 0 | 7 => q % 64 = 35 ∧ q % 9 = 8 ∧ q % 25 = 13 ∧ q % 7 = 0 | 8 => q % 32 = 25 ∧ q % 9 = 8 ∧ q % 25 = 4 ∧ q % 7 = 0 | 9 => q % 64 = 7 ∧ q % 3 = 2 ∧ q % 25 = 19 ∧ q % 7 = 0 | 10 => q % 16 = 5 ∧ q % 9 = 8 ∧ q % 25 = 14 ∧ q % 7 = 0 | _ => q % 32 = 11 ∧ q % 9 = 8 ∧ q % 5 = 1 ∧ q % 7 = 0 /-- State `j = 0` is equivalent to `q % 420 = 119`. -/ theorem inv_zero_iff_mod_420 (q : ℕ) : Inv 0 q ↔ q % 420 = 119 := by unfold Inv; simp only [Nat.zero_mod]; omega /-- Next denominator along the attractor step. -/ def nextQ (j : ℕ) (q : ℕ) : ℕ := let k := numOf j let n := (q + k + 1) / k if k < 6 then q * n else (q / 7) * n /-- Every state `Inv j q` guarantees `6 * numOf j ∣ q + 1`. -/ theorem inv_six_mul_dvd (j : ℕ) {q : ℕ} (h : Inv j q) : 6 * numOf j ∣ q + 1 := by have hj : j % 12 < 12 := Nat.mod_lt j (by omega) unfold Inv at h unfold numOf match hr : j % 12 with | 0 => rw [hr] at h; rcases h with ⟨h2, h3, _, _⟩ have h6 : 6 * (j % 6 + 1) = 2 * 3 := by omega rw [h6]; exact (coprime_of_bezout (-1) 1 (by norm_num)).mul_dvd_of_dvd_of_dvd (dvd_succ_of_mod_eq h2 (by norm_num) (by norm_num)) (dvd_succ_of_mod_eq h3 (by norm_num) (by norm_num)) | 1 => rw [hr] at h; rcases h with ⟨h2, h3, _, _⟩ have h6 : 6 * (j % 6 + 1) = 4 * 3 := by omega rw [h6]; exact (coprime_of_bezout 1 (-1) (by norm_num)).mul_dvd_of_dvd_of_dvd (dvd_succ_of_mod_eq h2 (by norm_num) (by norm_num)) (dvd_succ_of_mod_eq h3 (by norm_num) (by norm_num)) | 2 => rw [hr] at h; rcases h with ⟨h2, h3, _, _⟩ have h6 : 6 * (j % 6 + 1) = 2 * 9 := by omega rw [h6]; exact (coprime_of_bezout 5 (-1) (by norm_num)).mul_dvd_of_dvd_of_dvd (dvd_succ_of_mod_eq h2 (by norm_num) (by norm_num)) (dvd_succ_of_mod_eq h3 (by norm_num) (by norm_num)) | 3 => rw [hr] at h; rcases h with ⟨h2, h3, _, _⟩ have h6 : 6 * (j % 6 + 1) = 8 * 3 := by omega rw [h6]; exact (coprime_of_bezout (-1) 3 (by norm_num)).mul_dvd_of_dvd_of_dvd (dvd_succ_of_mod_eq h2 (by norm_num) (by norm_num)) (dvd_succ_of_mod_eq h3 (by norm_num) (by norm_num)) | 4 => rw [hr] at h; rcases h with ⟨h2, h3, h5, _⟩ have h6 : 6 * (j % 6 + 1) = (2 * 3) * 5 := by omega rw [h6] have h23 : 2 * 3 ∣ q + 1 := (coprime_of_bezout (-1) 1 (by norm_num)).mul_dvd_of_dvd_of_dvd (dvd_succ_of_mod_eq h2 (by norm_num) (by norm_num)) (dvd_succ_of_mod_eq h3 (by norm_num) (by norm_num)) exact (coprime_of_bezout 1 (-1) (by norm_num)).mul_dvd_of_dvd_of_dvd h23 (dvd_succ_of_mod_eq h5 (by norm_num) (by norm_num)) | 5 => rw [hr] at h; rcases h with ⟨h2, h3, _, _⟩ have h6 : 6 * (j % 6 + 1) = 4 * 9 := by omega rw [h6]; exact (coprime_of_bezout (-2) 1 (by norm_num)).mul_dvd_of_dvd_of_dvd (dvd_succ_of_mod_eq h2 (by norm_num) (by norm_num)) (dvd_succ_of_mod_eq h3 (by norm_num) (by norm_num)) | 6 => rw [hr] at h; rcases h with ⟨h2, h3, _, _⟩ have h6 : 6 * (j % 6 + 1) = 2 * 3 := by omega rw [h6]; exact (coprime_of_bezout (-1) 1 (by norm_num)).mul_dvd_of_dvd_of_dvd (dvd_succ_of_mod_eq h2 (by norm_num) (by norm_num)) (dvd_succ_of_mod_eq h3 (by norm_num) (by norm_num)) | 7 => rw [hr] at h; rcases h with ⟨h2, h3, _, _⟩ have h6 : 6 * (j % 6 + 1) = 4 * 3 := by omega rw [h6]; exact (coprime_of_bezout 1 (-1) (by norm_num)).mul_dvd_of_dvd_of_dvd (dvd_succ_of_mod_eq h2 (by norm_num) (by norm_num)) (dvd_succ_of_mod_eq h3 (by norm_num) (by norm_num)) | 8 => rw [hr] at h; rcases h with ⟨h2, h3, _, _⟩ have h6 : 6 * (j % 6 + 1) = 2 * 9 := by omega rw [h6]; exact (coprime_of_bezout 5 (-1) (by norm_num)).mul_dvd_of_dvd_of_dvd (dvd_succ_of_mod_eq h2 (by norm_num) (by norm_num)) (dvd_succ_of_mod_eq h3 (by norm_num) (by norm_num)) | 9 => rw [hr] at h; rcases h with ⟨h2, h3, _, _⟩ have h6 : 6 * (j % 6 + 1) = 8 * 3 := by omega rw [h6]; exact (coprime_of_bezout (-1) 3 (by norm_num)).mul_dvd_of_dvd_of_dvd (dvd_succ_of_mod_eq h2 (by norm_num) (by norm_num)) (dvd_succ_of_mod_eq h3 (by norm_num) (by norm_num)) | 10 => rw [hr] at h; rcases h with ⟨h2, h3, h5, _⟩ have h6 : 6 * (j % 6 + 1) = (2 * 3) * 5 := by omega rw [h6] have h23 : 2 * 3 ∣ q + 1 := (coprime_of_bezout (-1) 1 (by norm_num)).mul_dvd_of_dvd_of_dvd (dvd_succ_of_mod_eq h2 (by norm_num) (by norm_num)) (dvd_succ_of_mod_eq h3 (by norm_num) (by norm_num)) exact (coprime_of_bezout 1 (-1) (by norm_num)).mul_dvd_of_dvd_of_dvd h23 (dvd_succ_of_mod_eq h5 (by norm_num) (by norm_num)) | 11 => rw [hr] at h; rcases h with ⟨h2, h3, _, _⟩ have h6 : 6 * (j % 6 + 1) = 4 * 9 := by omega rw [h6]; exact (coprime_of_bezout (-2) 1 (by norm_num)).mul_dvd_of_dvd_of_dvd (dvd_succ_of_mod_eq h2 (by norm_num) (by norm_num)) (dvd_succ_of_mod_eq h3 (by norm_num) (by norm_num)) | _ + 12 => omega /-- Every state `Inv j q` guarantees `7 ∣ q`. -/ theorem inv_seven_dvd (j : ℕ) {q : ℕ} (h : Inv j q) : 7 ∣ q := by rw [Nat.dvd_iff_mod_eq_zero] unfold Inv at h have hj : j % 12 < 12 := Nat.mod_lt j (by omega) set r := j % 12 interval_cases r <;> exact h.2.2.2 /-- Preservation of `7 ∣ q` under `nextQ`. -/ theorem nextQ_mod_seven (j : ℕ) {q : ℕ} (h : Inv j q) : nextQ j q % 7 = 0 := by have h7 : 7 ∣ q := inv_seven_dvd j h have h6k : 6 * numOf j ∣ q + 1 := inv_six_mul_dvd j h unfold nextQ dsimp only split_ifs with hlt · obtain ⟨r, hr⟩ := h7 rw [hr, mul_assoc, Nat.mul_mod_right] · have hk6 : numOf j = 6 := by have := numOf_le_six j; omega rw [hk6] at h6k ⊢ have h6n : 6 * ((q + 6 + 1) / 6) = q + 7 := by have : 6 ∣ q + 7 := by obtain ⟨s, hs⟩ := h6k exact ⟨6 * s + 1, by omega⟩ exact Nat.mul_div_cancel' this have h7n : 7 ∣ (q + 6 + 1) / 6 := by have h7_6n : 7 ∣ 6 * ((q + 6 + 1) / 6) := by rw [h6n]; exact dvd_add h7 (dvd_refl 7) exact (show Nat.Coprime 7 6 by decide).dvd_of_dvd_mul_left h7_6n obtain ⟨r, hr⟩ := h7n rw [hr, ← mul_assoc, mul_comm (q / 7) 7, mul_assoc, Nat.mul_mod_right] /-- Algebraic relation `k * nextQ j q = q * (q + k + 1)` when `k < 6`. -/ theorem mul_nextQ_lt {j q : ℕ} (h : Inv j q) (hlt : numOf j < 6) : numOf j * nextQ j q = q * (q + numOf j + 1) := by have h6k := inv_six_mul_dvd j h have hk_dvd : numOf j ∣ q + numOf j + 1 := by obtain ⟨s, hs⟩ := h6k exact ⟨6 * s + 1, by linarith⟩ unfold nextQ rw [if_pos hlt] have hkn : numOf j * ((q + numOf j + 1) / numOf j) = q + numOf j + 1 := Nat.mul_div_cancel' hk_dvd calc numOf j * (q * ((q + numOf j + 1) / numOf j)) = q * (numOf j * ((q + numOf j + 1) / numOf j)) := by ring _ = q * (q + numOf j + 1) := by rw [hkn] /-- Algebraic relation `42 * nextQ j q = q * (q + 7)` when `numOf j = 6`. -/ theorem mul_nextQ_six {j q : ℕ} (h : Inv j q) (hk6 : numOf j = 6) : 42 * nextQ j q = q * (q + 7) := by have h7 := inv_seven_dvd j h have h6k := inv_six_mul_dvd j h rw [hk6] at h6k have h6_dvd : 6 ∣ q + 7 := by obtain ⟨s, hs⟩ := h6k; exact ⟨6 * s + 1, by omega⟩ unfold nextQ rw [if_neg (by omega : ¬ numOf j < 6), hk6] have h1 : 7 * (q / 7) = q := Nat.mul_div_cancel' h7 have h2 : 6 * ((q + 6 + 1) / 6) = q + 7 := Nat.mul_div_cancel' h6_dvd calc 42 * ((q / 7) * ((q + 6 + 1) / 6)) = (7 * (q / 7)) * (6 * ((q + 6 + 1) / 6)) := by ring _ = q * (q + 7) := by rw [h1, h2] /-- Derived cancellation helper: if `vk * a * q' = q * (q + k + 1)` with `vk ∣ q + k + 1`, then `a * q' = q * ((q + k + 1) / vk)`. -/ theorem eq_of_mul_vk {vk a q q' k : ℕ} (hvk : 0 < vk) (hdiv : vk ∣ q + k + 1) (heq : vk * a * q' = q * (q + k + 1)) : a * q' = q * ((q + k + 1) / vk) := by apply Nat.eq_of_mul_eq_mul_left hvk have h1 : vk * ((q + k + 1) / vk) = q + k + 1 := Nat.mul_div_cancel' hdiv calc vk * (a * q') = vk * a * q' := by ring _ = q * (q + k + 1) := heq _ = q * (vk * ((q + k + 1) / vk)) := by rw [h1] _ = vk * (q * ((q + k + 1) / vk)) := by ring -- Modular transition lemmas for each of the 12 residue classes `j % 12 = 0 .. 11` (kept small -- for fast default-heartbeat verification). private theorem inv_step_0 {j q : ℕ} (hr : j % 12 = 0) (h : Inv j q) : Inv (j + 1) (nextQ j q) := by have h7 := nextQ_mod_seven j h have hk : numOf j = 1 := by unfold numOf; omega have hmul : 1 * nextQ j q = q * (q + 1 + 1) := by simpa [hk] using mul_nextQ_lt h (by omega) have hmod : (j + 1) % 12 = 1 := by omega unfold Inv at h ⊢; rw [hr] at h; rw [hmod] generalize nextQ j q = q' at h7 hmul ⊢ rcases h with ⟨h2, h3, h5, _⟩ refine ⟨?_, ?_, ?_, h7⟩ · exact quad_step_mod (a := 1) (m := 4) (r := 3) (vk := 1) (k := 1) (nm := 16) (nr := 15) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h2 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 1) (m := 3) (r := 2) (vk := 1) (k := 1) (nm := 9) (nr := 8) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h3 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 1) (m := 5) (r := 4) (vk := 1) (k := 1) (nm := 25) (nr := 24) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h5 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) private theorem inv_step_1 {j q : ℕ} (hr : j % 12 = 1) (h : Inv j q) : Inv (j + 1) (nextQ j q) := by have h7 := nextQ_mod_seven j h have hk : numOf j = 2 := by unfold numOf; omega have hmul : 2 * nextQ j q = q * (q + 2 + 1) := by simpa [hk] using mul_nextQ_lt h (by omega) have hmod : (j + 1) % 12 = 2 := by omega unfold Inv at h ⊢; rw [hr] at h; rw [hmod] generalize nextQ j q = q' at h7 hmul ⊢ rcases h with ⟨h2, h3, h5, _⟩ have hmul1 : 1 * q' = q * ((q + 2 + 1) / 2) := eq_of_mul_vk (vk := 2) (a := 1) (by norm_num) (dvd_add_of_mod_eq h2 (by norm_num) (by norm_num)) (by rw [mul_one]; exact hmul) refine ⟨?_, ?_, ?_, h7⟩ · exact quad_step_mod (a := 1) (m := 16) (r := 15) (vk := 2) (k := 2) (nm := 8) (nr := 7) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h2 (by norm_num) (by norm_num) hmul1 (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 2) (m := 9) (r := 8) (vk := 1) (k := 2) (nm := 9) (nr := 8) (coprime_of_bezout 5 (-1) (by norm_num)) (by norm_num) (by norm_num) h3 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 2) (m := 25) (r := 24) (vk := 1) (k := 2) (nm := 25) (nr := 24) (coprime_of_bezout 13 (-1) (by norm_num)) (by norm_num) (by norm_num) h5 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) private theorem inv_step_2 {j q : ℕ} (hr : j % 12 = 2) (h : Inv j q) : Inv (j + 1) (nextQ j q) := by have h7 := nextQ_mod_seven j h have hk : numOf j = 3 := by unfold numOf; omega have hmul : 3 * nextQ j q = q * (q + 3 + 1) := by simpa [hk] using mul_nextQ_lt h (by omega) have hmod : (j + 1) % 12 = 3 := by omega unfold Inv at h ⊢; rw [hr] at h; rw [hmod] generalize nextQ j q = q' at h7 hmul ⊢ rcases h with ⟨h2, h3, h5, _⟩ have hmul1 : 1 * q' = q * ((q + 3 + 1) / 3) := eq_of_mul_vk (vk := 3) (a := 1) (by norm_num) (dvd_add_of_mod_eq h3 (by norm_num) (by norm_num)) (by rw [mul_one]; exact hmul) refine ⟨?_, ?_, ?_, h7⟩ · exact quad_step_mod (a := 3) (m := 8) (r := 7) (vk := 1) (k := 3) (nm := 16) (nr := 15) (coprime_of_bezout (-5) 1 (by norm_num)) (by norm_num) (by norm_num) h2 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 1) (m := 9) (r := 8) (vk := 3) (k := 3) (nm := 3) (nr := 2) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h3 (by norm_num) (by norm_num) hmul1 (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 3) (m := 25) (r := 24) (vk := 1) (k := 3) (nm := 25) (nr := 24) (coprime_of_bezout (-8) 1 (by norm_num)) (by norm_num) (by norm_num) h5 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) private theorem inv_step_3 {j q : ℕ} (hr : j % 12 = 3) (h : Inv j q) : Inv (j + 1) (nextQ j q) := by have h7 := nextQ_mod_seven j h have hk : numOf j = 4 := by unfold numOf; omega have hmul : 4 * nextQ j q = q * (q + 4 + 1) := by simpa [hk] using mul_nextQ_lt h (by omega) have hmod : (j + 1) % 12 = 4 := by omega unfold Inv at h ⊢; rw [hr] at h; rw [hmod] generalize nextQ j q = q' at h7 hmul ⊢ rcases h with ⟨h2, h3, h5, _⟩ have hmul1 : 1 * q' = q * ((q + 4 + 1) / 4) := eq_of_mul_vk (vk := 4) (a := 1) (by norm_num) (dvd_add_of_mod_eq h2 (by norm_num) (by norm_num)) (by rw [mul_one]; exact hmul) refine ⟨?_, ?_, ?_, h7⟩ · exact quad_step_mod (a := 1) (m := 16) (r := 15) (vk := 4) (k := 4) (nm := 4) (nr := 3) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h2 (by norm_num) (by norm_num) hmul1 (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 4) (m := 3) (r := 2) (vk := 1) (k := 4) (nm := 9) (nr := 8) (coprime_of_bezout (-2) 1 (by norm_num)) (by norm_num) (by norm_num) h3 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 4) (m := 25) (r := 24) (vk := 1) (k := 4) (nm := 25) (nr := 24) (coprime_of_bezout (-6) 1 (by norm_num)) (by norm_num) (by norm_num) h5 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) private theorem inv_step_4 {j q : ℕ} (hr : j % 12 = 4) (h : Inv j q) : Inv (j + 1) (nextQ j q) := by have h7 := nextQ_mod_seven j h have hk : numOf j = 5 := by unfold numOf; omega have hmul : 5 * nextQ j q = q * (q + 5 + 1) := by simpa [hk] using mul_nextQ_lt h (by omega) have hmod : (j + 1) % 12 = 5 := by omega unfold Inv at h ⊢; rw [hr] at h; rw [hmod] generalize nextQ j q = q' at h7 hmul ⊢ rcases h with ⟨h2, h3, h5, _⟩ have hmul1 : 1 * q' = q * ((q + 5 + 1) / 5) := eq_of_mul_vk (vk := 5) (a := 1) (by norm_num) (dvd_add_of_mod_eq h5 (by norm_num) (by norm_num)) (by rw [mul_one]; exact hmul) refine ⟨?_, ?_, ?_, h7⟩ · exact quad_step_mod_even (a := 5) (m := 4) (r := 3) (vk := 1) (k := 5) (nm := 32) (nr := 31) (coprime_of_bezout 13 (-2) (by norm_num)) (by norm_num) (by norm_num) h2 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 5) (m := 9) (r := 8) (vk := 1) (k := 5) (nm := 9) (nr := 8) (coprime_of_bezout 2 (-1) (by norm_num)) (by norm_num) (by norm_num) h3 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 1) (m := 25) (r := 24) (vk := 5) (k := 5) (nm := 5) (nr := 4) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h5 (by norm_num) (by norm_num) hmul1 (by norm_num) (by norm_num) (by norm_num) private theorem inv_step_5 {j q : ℕ} (hr : j % 12 = 5) (h : Inv j q) : Inv (j + 1) (nextQ j q) := by have h7 := nextQ_mod_seven j h have hk : numOf j = 6 := by unfold numOf; omega have hmul : 42 * nextQ j q = q * (q + 6 + 1) := by have := mul_nextQ_six h hk; linarith have hmod : (j + 1) % 12 = 6 := by omega unfold Inv at h ⊢; rw [hr] at h; rw [hmod] generalize nextQ j q = q' at h7 hmul ⊢ rcases h with ⟨h2, h3, h5, _⟩ have hmul2 : 21 * q' = q * ((q + 6 + 1) / 2) := eq_of_mul_vk (vk := 2) (a := 21) (k := 6) (by norm_num) (dvd_add_of_mod_eq h2 (by norm_num) (by norm_num)) (by exact hmul) have hmul3 : 14 * q' = q * ((q + 6 + 1) / 3) := eq_of_mul_vk (vk := 3) (a := 14) (k := 6) (by norm_num) (dvd_add_of_mod_eq h3 (by norm_num) (by norm_num)) (by exact hmul) refine ⟨?_, ?_, ?_, h7⟩ · exact quad_step_mod (a := 21) (m := 32) (r := 31) (vk := 2) (k := 6) (nm := 16) (nr := 9) (coprime_of_bezout (-3) 4 (by norm_num)) (by norm_num) (by norm_num) h2 (by norm_num) (by norm_num) hmul2 (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 14) (m := 9) (r := 8) (vk := 3) (k := 6) (nm := 3) (nr := 2) (coprime_of_bezout (-1) 5 (by norm_num)) (by norm_num) (by norm_num) h3 (by norm_num) (by norm_num) hmul3 (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 42) (m := 5) (r := 4) (vk := 1) (k := 6) (nm := 25) (nr := 7) (coprime_of_bezout 3 (-5) (by norm_num)) (by norm_num) (by norm_num) h5 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) private theorem inv_step_6 {j q : ℕ} (hr : j % 12 = 6) (h : Inv j q) : Inv (j + 1) (nextQ j q) := by have h7 := nextQ_mod_seven j h have hk : numOf j = 1 := by unfold numOf; omega have hmul : 1 * nextQ j q = q * (q + 1 + 1) := by simpa [hk] using mul_nextQ_lt h (by omega) have hmod : (j + 1) % 12 = 7 := by omega unfold Inv at h ⊢; rw [hr] at h; rw [hmod] generalize nextQ j q = q' at h7 hmul ⊢ rcases h with ⟨h2, h3, h5, _⟩ refine ⟨?_, ?_, ?_, h7⟩ · exact quad_step_mod (a := 1) (m := 16) (r := 9) (vk := 1) (k := 1) (nm := 64) (nr := 35) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h2 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 1) (m := 3) (r := 2) (vk := 1) (k := 1) (nm := 9) (nr := 8) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h3 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 1) (m := 25) (r := 7) (vk := 1) (k := 1) (nm := 25) (nr := 13) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h5 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) private theorem inv_step_7 {j q : ℕ} (hr : j % 12 = 7) (h : Inv j q) : Inv (j + 1) (nextQ j q) := by have h7 := nextQ_mod_seven j h have hk : numOf j = 2 := by unfold numOf; omega have hmul : 2 * nextQ j q = q * (q + 2 + 1) := by simpa [hk] using mul_nextQ_lt h (by omega) have hmod : (j + 1) % 12 = 8 := by omega unfold Inv at h ⊢; rw [hr] at h; rw [hmod] generalize nextQ j q = q' at h7 hmul ⊢ rcases h with ⟨h2, h3, h5, _⟩ have hmul1 : 1 * q' = q * ((q + 2 + 1) / 2) := eq_of_mul_vk (vk := 2) (a := 1) (by norm_num) (dvd_add_of_mod_eq h2 (by norm_num) (by norm_num)) (by rw [mul_one]; exact hmul) refine ⟨?_, ?_, ?_, h7⟩ · exact quad_step_mod (a := 1) (m := 64) (r := 35) (vk := 2) (k := 2) (nm := 32) (nr := 25) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h2 (by norm_num) (by norm_num) hmul1 (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 2) (m := 9) (r := 8) (vk := 1) (k := 2) (nm := 9) (nr := 8) (coprime_of_bezout 5 (-1) (by norm_num)) (by norm_num) (by norm_num) h3 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 2) (m := 25) (r := 13) (vk := 1) (k := 2) (nm := 25) (nr := 4) (coprime_of_bezout 13 (-1) (by norm_num)) (by norm_num) (by norm_num) h5 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) private theorem inv_step_8 {j q : ℕ} (hr : j % 12 = 8) (h : Inv j q) : Inv (j + 1) (nextQ j q) := by have h7 := nextQ_mod_seven j h have hk : numOf j = 3 := by unfold numOf; omega have hmul : 3 * nextQ j q = q * (q + 3 + 1) := by simpa [hk] using mul_nextQ_lt h (by omega) have hmod : (j + 1) % 12 = 9 := by omega unfold Inv at h ⊢; rw [hr] at h; rw [hmod] generalize nextQ j q = q' at h7 hmul ⊢ rcases h with ⟨h2, h3, h5, _⟩ have hmul1 : 1 * q' = q * ((q + 3 + 1) / 3) := eq_of_mul_vk (vk := 3) (a := 1) (by norm_num) (dvd_add_of_mod_eq h3 (by norm_num) (by norm_num)) (by rw [mul_one]; exact hmul) refine ⟨?_, ?_, ?_, h7⟩ · exact quad_step_mod (a := 3) (m := 32) (r := 25) (vk := 1) (k := 3) (nm := 64) (nr := 7) (coprime_of_bezout (-21) 1 (by norm_num)) (by norm_num) (by norm_num) h2 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 1) (m := 9) (r := 8) (vk := 3) (k := 3) (nm := 3) (nr := 2) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h3 (by norm_num) (by norm_num) hmul1 (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 3) (m := 25) (r := 4) (vk := 1) (k := 3) (nm := 25) (nr := 19) (coprime_of_bezout (-8) 1 (by norm_num)) (by norm_num) (by norm_num) h5 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) private theorem inv_step_9 {j q : ℕ} (hr : j % 12 = 9) (h : Inv j q) : Inv (j + 1) (nextQ j q) := by have h7 := nextQ_mod_seven j h have hk : numOf j = 4 := by unfold numOf; omega have hmul : 4 * nextQ j q = q * (q + 4 + 1) := by simpa [hk] using mul_nextQ_lt h (by omega) have hmod : (j + 1) % 12 = 10 := by omega unfold Inv at h ⊢; rw [hr] at h; rw [hmod] generalize nextQ j q = q' at h7 hmul ⊢ rcases h with ⟨h2, h3, h5, _⟩ have hmul1 : 1 * q' = q * ((q + 4 + 1) / 4) := eq_of_mul_vk (vk := 4) (a := 1) (by norm_num) (dvd_add_of_mod_eq h2 (by norm_num) (by norm_num)) (by rw [mul_one]; exact hmul) refine ⟨?_, ?_, ?_, h7⟩ · exact quad_step_mod (a := 1) (m := 64) (r := 7) (vk := 4) (k := 4) (nm := 16) (nr := 5) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h2 (by norm_num) (by norm_num) hmul1 (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 4) (m := 3) (r := 2) (vk := 1) (k := 4) (nm := 9) (nr := 8) (coprime_of_bezout (-2) 1 (by norm_num)) (by norm_num) (by norm_num) h3 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 4) (m := 25) (r := 19) (vk := 1) (k := 4) (nm := 25) (nr := 14) (coprime_of_bezout (-6) 1 (by norm_num)) (by norm_num) (by norm_num) h5 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) private theorem inv_step_10 {j q : ℕ} (hr : j % 12 = 10) (h : Inv j q) : Inv (j + 1) (nextQ j q) := by have h7 := nextQ_mod_seven j h have hk : numOf j = 5 := by unfold numOf; omega have hmul : 5 * nextQ j q = q * (q + 5 + 1) := by simpa [hk] using mul_nextQ_lt h (by omega) have hmod : (j + 1) % 12 = 11 := by omega unfold Inv at h ⊢; rw [hr] at h; rw [hmod] generalize nextQ j q = q' at h7 hmul ⊢ rcases h with ⟨h2, h3, h5, _⟩ have hmul1 : 1 * q' = q * ((q + 5 + 1) / 5) := eq_of_mul_vk (vk := 5) (a := 1) (by norm_num) (dvd_add_of_mod_eq h5 (by norm_num) (by norm_num)) (by rw [mul_one]; exact hmul) refine ⟨?_, ?_, ?_, h7⟩ · exact quad_step_mod (a := 5) (m := 16) (r := 5) (vk := 1) (k := 5) (nm := 32) (nr := 11) (coprime_of_bezout 13 (-2) (by norm_num)) (by norm_num) (by norm_num) h2 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 5) (m := 9) (r := 8) (vk := 1) (k := 5) (nm := 9) (nr := 8) (coprime_of_bezout 2 (-1) (by norm_num)) (by norm_num) (by norm_num) h3 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 1) (m := 25) (r := 14) (vk := 5) (k := 5) (nm := 5) (nr := 1) (Nat.coprime_one_left _) (by norm_num) (by norm_num) h5 (by norm_num) (by norm_num) hmul1 (by norm_num) (by norm_num) (by norm_num) private theorem inv_step_11 {j q : ℕ} (hr : j % 12 = 11) (h : Inv j q) : Inv (j + 1) (nextQ j q) := by have h7 := nextQ_mod_seven j h have hk : numOf j = 6 := by unfold numOf; omega have hmul : 42 * nextQ j q = q * (q + 6 + 1) := by have := mul_nextQ_six h hk; linarith have hmod : (j + 1) % 12 = 0 := by omega unfold Inv at h ⊢; rw [hr] at h; rw [hmod] generalize nextQ j q = q' at h7 hmul ⊢ rcases h with ⟨h2, h3, h5, _⟩ have hmul2 : 21 * q' = q * ((q + 6 + 1) / 2) := eq_of_mul_vk (vk := 2) (a := 21) (k := 6) (by norm_num) (dvd_add_of_mod_eq h2 (by norm_num) (by norm_num)) (by exact hmul) have hmul3 : 14 * q' = q * ((q + 6 + 1) / 3) := eq_of_mul_vk (vk := 3) (a := 14) (k := 6) (by norm_num) (dvd_add_of_mod_eq h3 (by norm_num) (by norm_num)) (by exact hmul) refine ⟨?_, ?_, ?_, h7⟩ · exact quad_step_mod (a := 21) (m := 32) (r := 11) (vk := 2) (k := 6) (nm := 4) (nr := 3) (coprime_of_bezout 1 (-5) (by norm_num)) (by norm_num) (by norm_num) h2 (by norm_num) (by norm_num) hmul2 (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 14) (m := 9) (r := 8) (vk := 3) (k := 6) (nm := 3) (nr := 2) (coprime_of_bezout (-1) 5 (by norm_num)) (by norm_num) (by norm_num) h3 (by norm_num) (by norm_num) hmul3 (by norm_num) (by norm_num) (by norm_num) · exact quad_step_mod (a := 42) (m := 5) (r := 1) (vk := 1) (k := 6) (nm := 5) (nr := 4) (coprime_of_bezout 3 (-25) (by norm_num)) (by norm_num) (by norm_num) h5 (by norm_num) (by norm_num) (by simpa [Nat.div_one] using hmul) (by norm_num) (by norm_num) (by norm_num) /-- **Main Modular Closure Theorem:** `Inv j q → Inv (j + 1) (nextQ j q)` for all `j : ℕ`. -/ theorem inv_step (j : ℕ) {q : ℕ} (h : Inv j q) : Inv (j + 1) (nextQ j q) := by have hj : j % 12 < 12 := Nat.mod_lt j (by omega) match hr : j % 12 with | 0 => exact inv_step_0 hr h | 1 => exact inv_step_1 hr h | 2 => exact inv_step_2 hr h | 3 => exact inv_step_3 hr h | 4 => exact inv_step_4 hr h | 5 => exact inv_step_5 hr h | 6 => exact inv_step_6 hr h | 7 => exact inv_step_7 hr h | 8 => exact inv_step_8 hr h | 9 => exact inv_step_9 hr h | 10 => exact inv_step_10 hr h | 11 => exact inv_step_11 hr h | _ + 12 => omega /-- Growth and freshness bounds for `nextQ`: whenever `q ≥ 77` and `Inv j q`, the chosen denominator `n = (q + k + 1) / k` satisfies `n + 1 ≤ (nextQ j q + 1) / numOf (j + 1)`, `nextQ j q ≥ 2 * q`, and `42 * nextQ j q > q * q`. -/ theorem nextQ_growth (j : ℕ) {q : ℕ} (hq : 77 ≤ q) (h : Inv j q) : let k := numOf j let n := (q + k + 1) / k n + 1 ≤ (nextQ j q + 1) / numOf (j + 1) ∧ 2 * q ≤ nextQ j q ∧ q * q < 42 * nextQ j q := by dsimp only have hk1 : 1 ≤ numOf j := numOf_pos j have hk6 : numOf j ≤ 6 := numOf_le_six j have hnext_k_le : numOf (j + 1) ≤ 6 := numOf_le_six (j + 1) have hnext_k_pos : 0 < numOf (j + 1) := numOf_pos (j + 1) have h6k := inv_six_mul_dvd j h have hkn : numOf j * ((q + numOf j + 1) / numOf j) = q + numOf j + 1 := by obtain ⟨s, hs⟩ := h6k have hdvd : numOf j ∣ q + numOf j + 1 := ⟨6 * s + 1, by linarith⟩ exact Nat.mul_div_cancel' hdvd set n := (q + numOf j + 1) / numOf j with hn_def have hn_ge : 13 ≤ n := by nlinarith by_cases hlt : numOf j < 6 · have hq'_eq : nextQ j q = q * n := by unfold nextQ; rw [if_pos hlt] have hmul : numOf j * nextQ j q = q * (q + numOf j + 1) := mul_nextQ_lt h hlt refine ⟨?_, ?_, ?_⟩ · rw [hq'_eq, Nat.le_div_iff_mul_le hnext_k_pos] nlinarith · rw [hq'_eq]; nlinarith · nlinarith · have hk_eq : numOf j = 6 := by omega have hq'_eq : nextQ j q = (q / 7) * n := by unfold nextQ; rw [if_neg hlt] have hmul : 42 * nextQ j q = q * (q + 7) := mul_nextQ_six h hk_eq have hq7 : 11 ≤ q / 7 := by omega have hnext_k1 : numOf (j + 1) = 1 := by rw [numOf_succ_eq, if_neg hlt] refine ⟨?_, ?_, ?_⟩ · rw [hq'_eq, hnext_k1, Nat.div_one] nlinarith · rw [hq'_eq]; nlinarith · nlinarith /-! ## Section 4: Complete Orbit Characterization Along the Attractor -/ /-- The exact sequence of denominators produced along the attractor starting from `(j, q)`. -/ def orbitQ : ℕ → ℕ → ℕ → ℕ | _, q, 0 => q | j, q, t + 1 => orbitQ (j + 1) (nextQ j q) t theorem orbitQ_inv : ∀ (t j q : ℕ), Inv j q → Inv (j + t) (orbitQ j q t) | 0, j, q, h => by simpa [orbitQ] using h | t + 1, j, q, h => by have ih := orbitQ_inv t (j + 1) (nextQ j q) (inv_step j h) have hfin : (j + 1) + t = j + (t + 1) := by omega simpa [orbitQ, hfin] using ih theorem orbitQ_ge : ∀ (t j q : ℕ), 77 ≤ q → Inv j q → 77 ≤ orbitQ j q t | 0, _, _, hq, _ => hq | t + 1, j, q, hq, h => by have hq' : 77 ≤ nextQ j q := by have := (nextQ_growth j hq h).2.1; omega exact orbitQ_ge t (j + 1) (nextQ j q) hq' (inv_step j h) /-- Doubly exponential lower bound along the attractor: at every step `42 * q_{t+1} > q_t^2` and `q_{t+1} ≥ 2 * q_t`. -/ theorem orbitQ_step_growth (t j : ℕ) {q : ℕ} (hq : 77 ≤ q) (h : Inv j q) : orbitQ j q t * orbitQ j q t < 42 * orbitQ j q (t + 1) ∧ 2 * orbitQ j q t ≤ orbitQ j q (t + 1) := by induction t generalizing j q with | zero => have hg := nextQ_growth j hq h exact ⟨hg.2.2, hg.2.1⟩ | succ t ih => have hq' : 77 ≤ nextQ j q := by have := (nextQ_growth j hq h).2.1; omega exact ih (j + 1) hq' (inv_step j h) /-- **Core Attractor Theorem:** For `d ∈ {3, 6}`, any state `(j, q)` with `q ≥ 77` and `Inv j q`, and any set `A ⊆ {m | m ≡ 1 [MOD d]}` containing all `m ≥ B` (`B ≤ (q + 1) / numOf j`) with `m ≡ 1 [MOD d]`, the `t`-th greedy remainder equals `numOf (j + t + 1) / orbitQ j q (t + 1)`. -/ theorem attractor_orbit_spec {d : ℕ} (hd : d = 3 ∨ d = 6) : ∀ (t j q B : ℕ) (A : Set ℕ), 77 ≤ q → Inv j q → B ≤ (q + 1) / numOf j → (∀ m : ℕ, m ∈ A → m ≡ 1 [MOD d]) → (∀ m : ℕ, B ≤ m → m ≡ 1 [MOD d] → m ∈ A) → greedyUnitFractionRem A ((numOf j : ℚ) / (q : ℚ)) t = (numOf (j + (t + 1)) : ℚ) / (orbitQ j q (t + 1) : ℚ) | 0, j, q, B, A, hq, hinv, hB, hA_sub, hA_sup => by have hk1 := numOf_pos j have hk6 := numOf_le_six j have hx : (0 : ℚ) < (numOf j : ℚ) / (q : ℚ) := by apply div_pos <;> exact_mod_cast (by omega : 0 < _) have h6k := inv_six_mul_dvd j hinv obtain ⟨hnA, hnx, hmin, hkn, _⟩ := greedy_choice_mod36 hd hk1 (by omega) h6k hB hA_sub hA_sup rw [greedy_step_zero hx hnA hnx hmin] set n := (q + numOf j + 1) / numOf j have hn_pos : 0 < n := by nlinarith rw [orbitQ, orbitQ] by_cases hlt : numOf j < 6 · have hsub := rat_sub_climb (by omega : 0 < q) hn_pos hkn rw [hsub, numOf_succ_eq, if_pos hlt] unfold nextQ; rw [if_pos hlt] · have hk_eq : numOf j = 6 := by omega have h7 := inv_seven_dvd j hinv have h6n : 6 * n = q + 7 := by rw [hk_eq] at hkn; omega have hsub := rat_sub_cancel7 (by omega : 7 ≤ q) hn_pos h7 h6n have hsub' : (numOf j : ℚ) / (q : ℚ) - 1 / (n : ℚ) = 1 / (((q / 7) * n : ℕ) : ℚ) := by simpa [hk_eq] using hsub rw [hsub', numOf_succ_eq, if_neg hlt] unfold nextQ; rw [if_neg hlt, hk_eq] simp [n, hk_eq] | t + 1, j, q, B, A, hq, hinv, hB, hA_sub, hA_sup => by have hk1 := numOf_pos j have hk6 := numOf_le_six j have hx : (0 : ℚ) < (numOf j : ℚ) / (q : ℚ) := by apply div_pos <;> exact_mod_cast (by omega : 0 < _) have h6k := inv_six_mul_dvd j hinv obtain ⟨hnA, hnx, hmin, hkn, _⟩ := greedy_choice_mod36 hd hk1 (by omega) h6k hB hA_sub hA_sup rw [greedy_step_succ t hx hnA hnx hmin] set n := (q + numOf j + 1) / numOf j have hn_pos : 0 < n := by nlinarith have hrem : (numOf j : ℚ) / (q : ℚ) - 1 / (n : ℚ) = (numOf (j + 1) : ℚ) / (nextQ j q : ℚ) := by by_cases hlt : numOf j < 6 · rw [rat_sub_climb (by omega : 0 < q) hn_pos hkn, numOf_succ_eq, if_pos hlt] unfold nextQ; rw [if_pos hlt] · have hk_eq : numOf j = 6 := by omega have h7 := inv_seven_dvd j hinv have h6n : 6 * n = q + 7 := by rw [hk_eq] at hkn; omega have hsub : (numOf j : ℚ) / (q : ℚ) - 1 / (n : ℚ) = 1 / (((q / 7) * n : ℕ) : ℚ) := by simpa [hk_eq] using rat_sub_cancel7 (by omega : 7 ≤ q) hn_pos h7 h6n rw [hsub, numOf_succ_eq, if_neg hlt] unfold nextQ; rw [if_neg hlt, hk_eq] simp [n, hk_eq] rw [hrem] have hg := nextQ_growth j hq hinv have hq' : 77 ≤ nextQ j q := by omega have hinv' := inv_step j hinv have hB' : n + 1 ≤ (nextQ j q + 1) / numOf (j + 1) := hg.1 have hA'_sub : ∀ m : ℕ, m ∈ A \ {n} → m ≡ 1 [MOD d] := fun m hm => hA_sub m hm.1 have hA'_sup : ∀ m : ℕ, n + 1 ≤ m → m ≡ 1 [MOD d] → m ∈ A \ {n} := by intro m hm hmod have hne : m ≠ n := by omega have hBm : B ≤ m := by have : (q + 1) / numOf j ≤ n := Nat.div_le_div_right (by omega) omega exact ⟨hA_sup m hBm hmod, by simp [hne]⟩ have ih := attractor_orbit_spec hd t (j + 1) (nextQ j q) (n + 1) (A \ {n}) hq' hinv' hB' hA'_sub hA'_sup have hfin : (j + 1) + (t + 1) = j + (t + 1 + 1) := by omega simpa [orbitQ, hfin] using ih /-- For `d ∈ {3, 6}` and ANY `q` with `q % 420 = 119`, the greedy remainder of `1 / q` on `{n | n ≡ 1 [MOD d]}` is strictly positive for ALL `t : ℕ`. -/ theorem attractor_pos {d : ℕ} (hd : d = 3 ∨ d = 6) {q : ℕ} (hq : q % 420 = 119) (t : ℕ) : 0 < greedyUnitFractionRem { n : ℕ | n ≡ 1 [MOD d] } (1 / (q : ℚ)) t := by have hinv0 : Inv 0 q := (inv_zero_iff_mod_420 q).mpr hq have hq77 : 77 ≤ q := by omega have hspec := attractor_orbit_spec hd t 0 q 0 { n : ℕ | n ≡ 1 [MOD d] } hq77 hinv0 (Nat.zero_le _) (fun _ hm => hm) (fun _ _ hm => hm) simp only [numOf, Nat.zero_mod, zero_add, Nat.cast_one] at hspec rw [hspec] have hnum_pos : 0 < numOf (t + 1) := numOf_pos _ have hden_pos : 0 < orbitQ 0 q (t + 1) := by have := orbitQ_ge (t + 1) 0 q hq77 hinv0; omega exact div_pos (by exact_mod_cast hnum_pos) (by exact_mod_cast hden_pos) theorem attractor_not_eventually_zero {d : ℕ} (hd : d = 3 ∨ d = 6) {q : ℕ} (hq : q % 420 = 119) : ¬ (greedyUnitFractionRem { n : ℕ | n ≡ 1 [MOD d] } (1 / (q : ℚ)) =ᶠ[atTop] 0) := by intro hev rw [Filter.EventuallyEq, Filter.eventually_atTop] at hev obtain ⟨N, hN⟩ := hev have h0 : greedyUnitFractionRem { n : ℕ | n ≡ 1 [MOD d] } (1 / (q : ℚ)) N = 0 := by simpa only [Pi.zero_apply] using hN N le_rfl have hpos := attractor_pos hd hq N linarith /-! ## Section 5: Explicit Small Counterexample `3 / 17` and Constructive Representations -/ /-- Exact helper for checking a single greedy step on `p / q`. -/ theorem greedy_step_concrete {p q n : ℕ} {A : Set ℕ} (hp : 0 < p) (hq : 0 < q) (hnA : n ∈ A) (hle : q ≤ p * n) (hmin : ∀ m : ℕ, m ∈ A → q ≤ p * m → n ≤ m) : (∀ t : ℕ, greedyUnitFractionRem A ((p : ℚ) / (q : ℚ)) (t + 1) = greedyUnitFractionRem (A \ {n}) ((p : ℚ) / (q : ℚ) - 1 / (n : ℚ)) t) ∧ greedyUnitFractionRem A ((p : ℚ) / (q : ℚ)) 0 = (p : ℚ) / (q : ℚ) - 1 / (n : ℚ) := by have hx : (0 : ℚ) < (p : ℚ) / (q : ℚ) := div_pos (by exact_mod_cast hp) (by exact_mod_cast hq) have h1x : 1 / ((p : ℚ) / (q : ℚ)) = (q : ℚ) / (p : ℚ) := by simp [one_div] have hpQ : (0 : ℚ) < (p : ℚ) := by exact_mod_cast hp have hnx : 1 / ((p : ℚ) / (q : ℚ)) ≤ (n : ℚ) := by rw [h1x, div_le_iff₀ hpQ] have : q ≤ n * p := by linarith exact_mod_cast this have hminQ : ∀ m : ℕ, m ∈ A → 1 / ((p : ℚ) / (q : ℚ)) ≤ (m : ℚ) → n ≤ m := by intro m hmA hmx rw [h1x, div_le_iff₀ hpQ] at hmx have hqmp : q ≤ m * p := by exact_mod_cast hmx exact hmin m hmA (by linarith) exact ⟨fun t => greedy_step_succ t hx hnA hnx hminQ, greedy_step_zero hx hnA hnx hminQ⟩ /-- **Benchmark Small Counterexample `3 / 17`:** For both `d = 3` and `d = 6` (`a = 1`), `3 / 17` enters the `q ≡ 119 [MOD 420]` attractor at step 4 (`1 / 176953033439`) and never terminates! -/ theorem nontermination_three_seventeenths {d : ℕ} (hd : d = 3 ∨ d = 6) : (3 / 17 : ℚ) ∈ Set.Ioo (0 : ℚ) 1 ∧ GrahamCond (3 / 17 : ℚ) 1 d ∧ ∀ t : ℕ, 0 < greedyUnitFractionRem { n : ℕ | n ≡ 1 [MOD d] } (3 / 17 : ℚ) t := by refine ⟨by norm_num, ?_, ?_⟩ · have hden : (3 / 17 : ℚ).den = 17 := by norm_num rcases hd with rfl | rfl <;> unfold GrahamCond <;> rw [hden] <;> decide · set A₀ : Set ℕ := { n : ℕ | n ≡ 1 [MOD d] } have hmod_ge : ∀ m : ℕ, m ∈ A₀ → m % 3 = 1 := by intro m hm; rcases hd with rfl | rfl · exact hm · change m % 6 = 1 at hm; omega have h7A : 7 ∈ A₀ := by rcases hd with rfl | rfl <;> decide have h31A : 31 ∈ A₀ \ {7} := ⟨by rcases hd with rfl | rfl <;> decide, by norm_num⟩ have h739A : 739 ∈ (A₀ \ {7}) \ {31} := ⟨⟨by rcases hd with rfl | rfl <;> decide, by norm_num⟩, by norm_num⟩ have h454363A : 454363 ∈ ((A₀ \ {7}) \ {31}) \ {739} := ⟨⟨⟨by rcases hd with rfl | rfl <;> decide, by norm_num⟩, by norm_num⟩, by norm_num⟩ -- Step 0: 3/17 -> 4/119 (n = 7) have hs0 := greedy_step_concrete (A := A₀) (p := 3) (q := 17) (n := 7) (by norm_num) (by norm_num) h7A (by norm_num) (fun m hm hle => by have := hmod_ge m hm; omega) -- Step 1: 4/119 -> 5/3689 (n = 31) have hs1 := greedy_step_concrete (A := A₀ \ {7}) (p := 4) (q := 119) (n := 31) (by norm_num) (by norm_num) h31A (by norm_num) (fun m hm hle => by have := hmod_ge m hm.1; omega) -- Step 2: 5/3689 -> 6/2726171 (n = 739) have hs2 := greedy_step_concrete (A := (A₀ \ {7}) \ {31}) (p := 5) (q := 3689) (n := 739) (by norm_num) (by norm_num) h739A (by norm_num) (fun m hm hle => by have := hmod_ge m hm.1.1; omega) -- Step 3: 6/2726171 -> 1/176953033439 (n = 454363) have hs3 := greedy_step_concrete (A := ((A₀ \ {7}) \ {31}) \ {739}) (p := 6) (q := 2726171) (n := 454363) (by norm_num) (by norm_num) h454363A (by norm_num) (fun m hm hle => by have := hmod_ge m hm.1.1.1; omega) intro t match t with | 0 => have h := hs0.2; norm_num at h; rw [h]; norm_num | 1 => have h0 := hs0.1 0; norm_num at h0; rw [h0] have h1 := hs1.2; norm_num at h1; rw [h1]; norm_num | 2 => have h0 := hs0.1 1; norm_num at h0; rw [h0] have h1 := hs1.1 0; norm_num at h1; rw [h1] have h2 := hs2.2; norm_num at h2; rw [h2]; norm_num | 3 => have h0 := hs0.1 2; norm_num at h0; rw [h0] have h1 := hs1.1 1; norm_num at h1; rw [h1] have h2 := hs2.1 0; norm_num at h2; rw [h2] have h3 := hs3.2; norm_num at h3; rw [h3]; norm_num | t' + 4 => have h0 := hs0.1 (t' + 3); norm_num at h0; rw [h0] have h1 := hs1.1 (t' + 2); norm_num at h1; rw [h1] have h2 := hs2.1 (t' + 1); norm_num at h2; rw [h2] have h3 := hs3.1 t'; norm_num at h3; rw [h3] set A₄ : Set ℕ := (((A₀ \ {7}) \ {31}) \ {739}) \ {454363} have hinv4 : Inv 0 176953033439 := (inv_zero_iff_mod_420 _).mpr (by norm_num) have hA₄_sub : ∀ m : ℕ, m ∈ A₄ → m ≡ 1 [MOD d] := fun m hm => hm.1.1.1.1 have hA₄_sup : ∀ m : ℕ, 454364 ≤ m → m ≡ 1 [MOD d] → m ∈ A₄ := by intro m hm hmod simp only [A₄, A₀, Set.mem_sdiff, Set.mem_singleton_iff, Set.mem_ofPred_eq] refine ⟨⟨⟨⟨hmod, by omega⟩, by omega⟩, by omega⟩, by omega⟩ have hspec := attractor_orbit_spec hd t' 0 176953033439 454364 A₄ (by norm_num) hinv4 (by norm_num [numOf]) hA₄_sub hA₄_sup simp only [numOf, Nat.zero_mod, zero_add, Nat.cast_one] at hspec have hcast : (1 : ℚ) / 176953033439 = (1 : ℚ) / ((176953033439 : ℕ) : ℚ) := by norm_num rw [hcast, hspec] have hnum_pos : 0 < numOf (t' + 1) := numOf_pos _ have hden_pos : 0 < orbitQ 0 176953033439 (t' + 1) := by have := orbitQ_ge (t' + 1) 0 176953033439 (by norm_num) hinv4; omega exact div_pos (by exact_mod_cast hnum_pos) (by exact_mod_cast hden_pos) /-- Constructive 5-term Egyptian representation of `1 / 119` with distinct denominators all `≡ 1 [MOD 6]` (hence also `≡ 1 [MOD 3]`): `1/119 = 1/169 + 1/805 + 1/1105 + 1/4225 + 1/9775`. -/ theorem explicit_rep_one_div_119_mod6 {d : ℕ} (hd : d = 3 ∨ d = 6) : IsEgyptianRepFrom { n : ℕ | n ≡ 1 [MOD d] } (1 / 119 : ℚ) := by refine ⟨{169, 805, 1105, 4225, 9775}, ?_, ?_⟩ · intro n hn simp only [Finset.mem_insert, Finset.mem_singleton] at hn rcases hn with rfl | rfl | rfl | rfl | rfl <;> ( rcases hd with rfl | rfl <;> exact ⟨by decide, by norm_num⟩ ) · norm_num [Finset.sum_insert, Finset.mem_insert, Finset.mem_singleton] /-- Constructive 3-term Egyptian representation of `3 / 17` with distinct denominators all `≡ 1 [MOD 3]`: `3/17 = 1/7 + 1/34 + 1/238`. -/ theorem explicit_rep_three_div_17_mod3 : IsEgyptianRepFrom { n : ℕ | n ≡ 1 [MOD 3] } (3 / 17 : ℚ) := by refine ⟨{7, 34, 238}, ?_, ?_⟩ · intro n hn simp only [Finset.mem_insert, Finset.mem_singleton] at hn rcases hn with rfl | rfl | rfl <;> exact ⟨by decide, by norm_num⟩ · norm_num [Finset.sum_insert, Finset.mem_insert, Finset.mem_singleton] /-! ## Section 6: Universal Scaled Family & Refutation of `erdos_282.variants.graham` -/ /-- Exact denominator of `1 / (k : ℚ)` is `k` when `0 < k`. -/ theorem den_one_div_nat {k : ℕ} (hk : 0 < k) : ((1 / (k : ℚ)) : ℚ).den = k := by set r : ℚ := 1 / (k : ℚ) have hr_pos : 0 < r := div_pos one_pos (by exact_mod_cast hk) have hnd : (r.num : ℚ) / (r.den : ℚ) = 1 / (k : ℚ) := by simpa [r] using Rat.num_div_den r have hden_pos : 0 < r.den := r.den_pos have hkQ : (k : ℚ) ≠ 0 := by exact_mod_cast hk.ne' have hdQ : (r.den : ℚ) ≠ 0 := by exact_mod_cast hden_pos.ne' have hmulQ : (r.num : ℚ) * (k : ℚ) = (r.den : ℚ) := by field_simp at hnd linarith have hmulZ : r.num * (k : ℤ) = (r.den : ℤ) := by exact_mod_cast hmulQ have hnum_pos : 0 < r.num := by nlinarith have hmulN : r.num.natAbs * k = r.den := by have : ((r.num.natAbs * k : ℕ) : ℤ) = (r.den : ℤ) := by push_cast; rw [abs_of_pos hnum_pos]; exact hmulZ exact_mod_cast this have hdvd : r.num.natAbs ∣ r.den := ⟨k, hmulN.symm⟩ have hcop : Nat.Coprime r.num.natAbs r.den := r.reduced have h1 : r.num.natAbs = 1 := Nat.eq_one_of_dvd_one (hcop.gcd_eq_one ▸ Nat.dvd_gcd (dvd_refl _) hdvd) rw [← hmulN, h1, one_mul] /-- **Universal Scaled Non-Termination Family:** For EVERY `m ≥ 1`, EVERY `d ∈ {3 * m, 6 * m}` (with `a = m`), and EVERY `q` with `q % 420 = 119`: 1. `x = 1 / (m * q) ∈ (0, 1)`, 2. `x` satisfies Graham's representability criterion `GrahamCond x m d`, 3. `greedyUnitFractionRem {n | n ≡ m [MOD d]} x t > 0` for ALL `t : ℕ`, hence NEVER terminates! -/ theorem scaled_family_nontermination {m d₀ q : ℕ} (hm : 1 ≤ m) (hd₀ : d₀ = 3 ∨ d₀ = 6) (hq : q % 420 = 119) : let d := m * d₀ let x : ℚ := 1 / ((m * q : ℕ) : ℚ) 1 < d ∧ x ∈ Set.Ioo (0 : ℚ) 1 ∧ GrahamCond x m d ∧ (∀ t : ℕ, 0 < greedyUnitFractionRem { n : ℕ | n ≡ m [MOD d] } x t) ∧ ¬ (greedyUnitFractionRem { n : ℕ | n ≡ m [MOD d] } x =ᶠ[atTop] 0) := by have hmpos : 0 < m := by omega have hq119 : 119 ≤ q := by omega have hmq_pos : 0 < m * q := Nat.mul_pos hmpos (by omega) have hd_gt1 : 1 < m * d₀ := by rcases hd₀ with rfl | rfl <;> omega have hx_mem : (1 / ((m * q : ℕ) : ℚ)) ∈ Set.Ioo (0 : ℚ) 1 := by refine ⟨div_pos one_pos (by exact_mod_cast hmq_pos), ?_⟩ rw [div_lt_one (by exact_mod_cast hmq_pos)] have hgt1 : 1 < m * q := by nlinarith exact_mod_cast hgt1 have hgraham : GrahamCond (1 / ((m * q : ℕ) : ℚ)) m (m * d₀) := by unfold GrahamCond rw [den_one_div_nat hmq_pos] have hgcd_ad : m.gcd (m * d₀) = m := Nat.gcd_eq_left (dvd_mul_right m d₀) have hgcd_nad : (m * q).gcd m = m := Nat.gcd_eq_right (dvd_mul_right m q) rw [hgcd_ad, hgcd_nad, Nat.mul_div_cancel_left q hmpos, Nat.mul_div_cancel_left d₀ hmpos] rcases hd₀ with rfl | rfl · have : q % 3 = 2 := by omega have hcop : Nat.Coprime q 3 := by rw [Nat.coprime_comm, Nat.Prime.coprime_iff_not_dvd (by norm_num)] omega exact hcop.gcd_eq_one · have h2 : Nat.Coprime q 2 := by rw [Nat.coprime_comm, Nat.Prime.coprime_iff_not_dvd (by norm_num)] omega have h3 : Nat.Coprime q 3 := by rw [Nat.coprime_comm, Nat.Prime.coprime_iff_not_dvd (by norm_num)] omega exact (h2.mul_right h3).gcd_eq_one have hpos : ∀ t : ℕ, 0 < greedyUnitFractionRem { n : ℕ | n ≡ m [MOD m * d₀] } (1 / ((m * q : ℕ) : ℚ)) t := by intro t rw [← image_mul_modEq_one hmpos] have hx_eq : (1 : ℚ) / ((m * q : ℕ) : ℚ) = (1 / (q : ℚ)) / (m : ℚ) := by rw [Nat.cast_mul]; ring rw [hx_eq, greedy_scale_pos hmpos] exact div_pos (attractor_pos hd₀ hq t) (by exact_mod_cast hmpos) refine ⟨hd_gt1, hx_mem, hgraham, hpos, ?_⟩ intro hev rw [Filter.EventuallyEq, Filter.eventually_atTop] at hev obtain ⟨N, hN⟩ := hev have h0 : greedyUnitFractionRem { n : ℕ | n ≡ m [MOD m * d₀] } (1 / ((m * q : ℕ) : ℚ)) N = 0 := by simpa only [Pi.zero_apply] using hN N le_rfl have hp := hpos N linarith /-- Explicit scaled representation for `1 / (119 * m)` with denominators `≡ m [MOD m * d₀]`. -/ theorem explicit_rep_scaled_119 {m d₀ : ℕ} (hm : 1 ≤ m) (hd₀ : d₀ = 3 ∨ d₀ = 6) : IsEgyptianRepFrom { n : ℕ | n ≡ m [MOD m * d₀] } (1 / ((m * 119 : ℕ) : ℚ)) := by have hmpos : 0 < m := by omega obtain ⟨S, hS_mem, hS_sum⟩ := explicit_rep_one_div_119_mod6 hd₀ refine ⟨S.image (fun n => m * n), ?_, ?_⟩ · intro x hx obtain ⟨n, hnS, rfl⟩ := Finset.mem_image.mp hx obtain ⟨hnA, hn_pos⟩ := hS_mem n hnS refine ⟨?_, Nat.mul_pos hmpos hn_pos⟩ rw [← image_mul_modEq_one hmpos] exact ⟨n, hnA, rfl⟩ · have hinj : Set.InjOn (fun n => m * n) (S : Set ℕ) := fun _ _ _ _ h => Nat.eq_of_mul_eq_mul_left hmpos h rw [Finset.sum_image hinj] have hterm : ∀ n ∈ S, (1 : ℚ) / ((m * n : ℕ) : ℚ) = (1 / (m : ℚ)) * ((1 : ℚ) / (n : ℚ)) := by intro n _; rw [Nat.cast_mul]; ring rw [Finset.sum_congr rfl hterm, ← Finset.mul_sum, hS_sum, Nat.cast_mul] ring /-- **Main Refutation Theorem (Disproof of `Erdos282.erdos_282.variants.graham`):** It is FALSE that Graham's arithmetic representability condition implies termination of the greedy Egyptian fraction algorithm on `{n | n ≡ a [MOD d]}`. -/ theorem not_erdos_282_graham : ¬ (∀ x : ℚ, x ∈ Set.Ioo (0 : ℚ) 1 → ∀ a d : ℕ, 1 < d → (x.den / x.den.gcd (a.gcd d)).gcd (d / a.gcd d) = 1 → greedyUnitFractionRem { n | n ≡ a [MOD d] } x =ᶠ[atTop] 0) := by intro hall obtain ⟨hd, hx, hg, _, hnot⟩ := scaled_family_nontermination (m := 1) (d₀ := 3) (q := 119) le_rfl (Or.inl rfl) (by norm_num) exact hnot (hall _ hx 1 3 hd hg) /-- **Infinitely Many Counterexample Arithmetic Progressions:** There are infinitely many pairs `(a, d)` with `1 < d` admitting a Graham-representable rational `x ∈ (0, 1)` on which `greedyUnitFractionRem {n | n ≡ a [MOD d]} x` never terminates. -/ theorem infinitely_many_counterexample_progressions : { p : ℕ × ℕ | 1 < p.2 ∧ ∃ x : ℚ, x ∈ Set.Ioo (0 : ℚ) 1 ∧ GrahamCond x p.1 p.2 ∧ IsEgyptianRepFrom { n | n ≡ p.1 [MOD p.2] } x ∧ ¬ (greedyUnitFractionRem { n | n ≡ p.1 [MOD p.2] } x =ᶠ[atTop] 0) }.Infinite := by refine Set.infinite_of_injective_forall_mem (f := fun k : ℕ => (k + 1, (k + 1) * 3)) ?_ ?_ · intro k₁ k₂ h have h1 : k₁ + 1 = k₂ + 1 := congrArg Prod.fst h omega · intro k obtain ⟨hd, hx, hg, _, hnot⟩ := scaled_family_nontermination (m := k + 1) (d₀ := 3) (q := 119) (by omega) (Or.inl rfl) (by norm_num) exact ⟨hd, 1 / (((k + 1) * 119 : ℕ) : ℚ), hx, hg, explicit_rep_scaled_119 (by omega) (Or.inl rfl), hnot⟩ /-- **Infinitely Many Counterexamples in Each Progression `(m, 3m)` and `(m, 6m)`:** For every `m ≥ 1` and `d ∈ {3 * m, 6 * m}`, there are infinitely many Graham-representable rationals `x ∈ (0, 1)` on which the greedy algorithm never terminates. -/ theorem infinitely_many_counterexamples_per_progression {m d₀ : ℕ} (hm : 1 ≤ m) (hd₀ : d₀ = 3 ∨ d₀ = 6) : { x : ℚ | x ∈ Set.Ioo (0 : ℚ) 1 ∧ GrahamCond x m (m * d₀) ∧ ¬ (greedyUnitFractionRem { n | n ≡ m [MOD m * d₀] } x =ᶠ[atTop] 0) }.Infinite := by have hmpos : 0 < m := by omega refine Set.infinite_of_injective_forall_mem (f := fun k : ℕ => (1 : ℚ) / ((m * (420 * k + 119) : ℕ) : ℚ)) ?_ ?_ · intro k₁ k₂ h have h1 : (1 : ℚ) / ((m * (420 * k₁ + 119) : ℕ) : ℚ) = (1 : ℚ) / ((m * (420 * k₂ + 119) : ℕ) : ℚ) := h have hden1 := den_one_div_nat (Nat.mul_pos hmpos (by omega : 0 < 420 * k₁ + 119)) have hden2 := den_one_div_nat (Nat.mul_pos hmpos (by omega : 0 < 420 * k₂ + 119)) have hden_eq : m * (420 * k₁ + 119) = m * (420 * k₂ + 119) := by rw [← hden1, ← hden2, h1] have hq_eq := Nat.eq_of_mul_eq_mul_left hmpos hden_eq omega · intro k have hq : (420 * k + 119) % 420 = 119 := by omega obtain ⟨_, hx, hg, _, hnot⟩ := scaled_family_nontermination hm hd₀ hq exact ⟨hx, hg, hnot⟩ end OpenAdditiveNumberTheory.GreedyEgyptian #print axioms OpenAdditiveNumberTheory.GreedyEgyptian.inv_step #print axioms OpenAdditiveNumberTheory.GreedyEgyptian.attractor_orbit_spec #print axioms OpenAdditiveNumberTheory.GreedyEgyptian.attractor_pos #print axioms OpenAdditiveNumberTheory.GreedyEgyptian.nontermination_three_seventeenths #print axioms OpenAdditiveNumberTheory.GreedyEgyptian.explicit_rep_one_div_119_mod6 #print axioms OpenAdditiveNumberTheory.GreedyEgyptian.explicit_rep_three_div_17_mod3 #print axioms OpenAdditiveNumberTheory.GreedyEgyptian.scaled_family_nontermination #print axioms OpenAdditiveNumberTheory.GreedyEgyptian.not_erdos_282_graham #print axioms OpenAdditiveNumberTheory.GreedyEgyptian.infinitely_many_counterexample_progressions #print axioms OpenAdditiveNumberTheory.GreedyEgyptian.infinitely_many_counterexamples_per_progression