import Mathlib /-! # Exact Covering-System Density Obstruction for Non-Homogeneous Rado Equations We consider the non-homogeneous linear equation $$E_{k, c} : \quad x_1 + x_2 + \dots + x_k + c = x_{k+1} \qquad (k \ge 2,\ c \ge 0)$$ and the Adhikari–Boza–Eliahou–Marín–Revuelta–Sanz Finiteness Conjecture (*Math. Comp.* **85** (2016); *Experimental Math.* **28** (2019)), which asserts that the $n$-color Rado number $R_k(n, c)$ is finite if and only if every divisor $d \le n$ of $k - 1$ also divides $c$. A natural strategy to look for counterexamples to the conjecture for large $n$ is to cover $\mathbb{Z}$ by $n$ arithmetic progressions (congruence classes) $a_i + d_i \mathbb{Z}$ ($1 \le i \le n$, $d_i \ge 1$) such that each class individually avoids solutions to $E_{k, c}$. If such a covering system existed, coloring each integer by the least index $i$ whose class contains it would produce an $n$-coloring of $\mathbb{Z}$ avoiding $E_{k, c}$, yielding $R_k(n, c) = \infty$. ## Main Result We prove (`hasAvoidingCoveringSystem_iff`) for **all** $k \ge 2$, $n \ge 1$, and $c \ge 0$: > There exists a covering of $\mathbb{Z}$ by $n$ congruence classes $a_i + d_i \mathbb{Z}$, each > avoiding $E_{k, c}$, **if and only if** there exists a divisor $d \le n$ of $k - 1$ with > $d \nmid c$. In particular (`no_avoiding_covering_system_of_admissible`), whenever the Adhikari–Boza–Eliahou admissibility condition holds, **no** finite covering system of $\mathbb{Z}$ by $n$ congruence classes can ever refute the conjecture—for any number of colors $n \ge 1$. ## Proof Idea 1. A single congruence class $a + d\mathbb{Z}$ avoids $E_{k, c}$ if and only if $d \nmid ((k - 1) a + c)$ (`avoidsEqClass_iff_not_dvd`). 2. Partition the $n$ classes into $T = \{i : \gcd(k - 1, d_i) \mid c\}$ and $S = \{i : \gcd(k - 1, d_i) \nmid c\}$. 3. Set $M_T = \operatorname{lcm}_{i \in T} d_i$, $G_T = \gcd(k - 1, M_T)$, and $M'_T = M_T / G_T$. Since $G_T = \operatorname{lcm}_{i \in T} \gcd(k - 1, d_i)$ divides $c$, Bézout's identity yields $x_0 \in \mathbb{Z}$ with $(k - 1) x_0 + c \equiv 0 \pmod{M_T}$. 4. Every integer $x \in x_0 + M'_T \mathbb{Z}$ still satisfies $(k - 1) x + c \equiv 0 \pmod{M_T}$, hence cannot belong to any class in $T$, so $x_0 + M'_T \mathbb{Z}$ must be completely covered by $\{a_i + d_i \mathbb{Z}\}_{i \in S}$. 5. For each $i \in S$, let $q'_i = d_i / \gcd(M'_T, d_i)$ and $D_i = \gcd(q'_i, \gcd(k - 1, d_i))$. Comparing $p$-adic valuations at every prime $p$ shows $D_i \nmid c$, while $D_i \mid (k - 1)$. By admissibility, $q'_i \ge D_i \ge n + 1$. 6. Counting hits in a full period $L = \operatorname{lcm}_{i \in S} q'_i$ gives $(n + 1) L \le |S| \cdot L \le n L$, a contradiction. -/ namespace CoveringSystemObstruction open Finset /-- A congruence class `a + d * ℤ` avoids the equation `x₁ + ... + xₖ + c = z` if no tuple of elements in `a + d * ℤ` satisfies the equation. -/ def AvoidsEqClass (k c : ℕ) (a : ℤ) (d : ℕ) : Prop := ¬ ∃ (x : Fin k → ℤ) (z : ℤ), (∀ i, (d : ℤ) ∣ (x i - a)) ∧ (d : ℤ) ∣ (z - a) ∧ (∑ i : Fin k, x i) + (c : ℤ) = z /-- Exact modular characterization: `a + d * ℤ` avoids `E_{k, c}` if and only if `d ∤ ((k - 1) * a + c)`. -/ theorem avoidsEqClass_iff_not_dvd {k c : ℕ} (a : ℤ) (d : ℕ) : AvoidsEqClass k c a d ↔ ¬ ((d : ℤ) ∣ ((k : ℤ) - 1) * a + (c : ℤ)) := by constructor · intro hAvoid hDvd apply hAvoid rcases hDvd with ⟨t, ht⟩ refine ⟨fun _ => a, a + (d : ℤ) * t, ?_, ?_, ?_⟩ · intro _; simp · exact ⟨t, by ring⟩ · simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] linarith · intro hNotDvd ⟨x, z, hx, hz, hsum⟩ apply hNotDvd have hdiff : (d : ℤ) ∣ (∑ i : Fin k, (x i - a)) - (z - a) := dvd_sub (Finset.dvd_sum (fun i _ => hx i)) hz have hEq : (∑ i : Fin k, (x i - a)) - (z - a) = -(((k : ℤ) - 1) * a + (c : ℤ)) := by have h1 : ∑ i : Fin k, (x i - a) = (∑ i : Fin k, x i) - (k : ℤ) * a := by simp [Finset.sum_sub_distrib] linarith rw [hEq, dvd_neg] at hdiff exact hdiff /-- Existence of a finite covering of `ℤ` by `n` congruence classes `aᵢ + dᵢ * ℤ` (`dᵢ ≥ 1`), each avoiding `E_{k, c}`. -/ def HasAvoidingCoveringSystem (k n c : ℕ) : Prop := ∃ (a : Fin n → ℤ) (d : Fin n → ℕ), (∀ i, 1 ≤ d i) ∧ (∀ i, AvoidsEqClass k c (a i) (d i)) ∧ (∀ x : ℤ, ∃ i : Fin n, (d i : ℤ) ∣ (x - a i)) /-- Constructive direction: if some divisor `d` with `1 ≤ d ≤ n` divides `k - 1` and does not divide `c`, then the `d` residue classes modulo `d` (padded to `n` classes) form an avoiding covering system of `ℤ`. -/ theorem hasAvoidingCoveringSystem_of_non_dvd {k n c d : ℕ} (hk : 1 ≤ k) (hd1 : 1 ≤ d) (hdn : d ≤ n) (hdk : d ∣ (k - 1)) (hdc : ¬ d ∣ c) : HasAvoidingCoveringSystem k n c := by refine ⟨fun i => (i.val % d : ℕ), fun _ => d, fun _ => hd1, ?_, ?_⟩ · intro i rw [avoidsEqClass_iff_not_dvd] intro hDvd have hdkZ : (d : ℤ) ∣ ((k : ℤ) - 1) := by rcases hdk with ⟨m, hm⟩ refine ⟨m, ?_⟩ omega have hterm : (d : ℤ) ∣ ((k : ℤ) - 1) * ((i.val % d : ℕ) : ℤ) := dvd_mul_of_dvd_left hdkZ _ have hcZ : (d : ℤ) ∣ (c : ℤ) := by have := dvd_sub hDvd hterm simpa using this exact hdc (Int.ofNat_dvd.mp hcZ) · intro x have hdpos : (0 : ℤ) < (d : ℤ) := by omega have hmod_nonneg : 0 ≤ x % (d : ℤ) := Int.emod_nonneg x (by omega) have hmod_lt : x % (d : ℤ) < (d : ℤ) := Int.emod_lt_of_pos x hdpos set r : ℕ := (x % (d : ℤ)).toNat have hr_lt_d : r < d := by omega have hr_lt_n : r < n := lt_of_lt_of_le hr_lt_d hdn refine ⟨⟨r, hr_lt_n⟩, ?_⟩ dsimp only have hr_mod : r % d = r := Nat.mod_eq_of_lt hr_lt_d rw [hr_mod] have hr_cast : (r : ℤ) = x % (d : ℤ) := Int.toNat_of_nonneg hmod_nonneg rw [hr_cast] exact ⟨x / (d : ℤ), by have := Int.mul_ediv_add_emod x (d : ℤ); linarith⟩ /-- Helper: `lcm` of a `Finset` of positive natural numbers is positive. -/ private lemma finset_lcm_pos {α : Type*} (s : Finset α) (f : α → ℕ) (hpos : ∀ i ∈ s, 0 < f i) : 0 < s.lcm f := by classical induction s using Finset.induction_on with | empty => simp | insert a s ha ih => rw [Finset.lcm_insert] exact Nat.lcm_pos (hpos a (mem_insert_self a s)) (ih (fun i hi => hpos i (mem_insert_of_mem hi))) /-- Helper: if `gcd m a ∣ c` and `gcd m b ∣ c`, then `gcd m (lcm a b) ∣ c`. -/ private lemma gcd_lcm_dvd_of_dvd {m a b c : ℕ} (h1 : Nat.gcd m a ∣ c) (h2 : Nat.gcd m b ∣ c) : Nat.gcd m (Nat.lcm a b) ∣ c := by by_cases hc0 : c = 0 · subst hc0; exact dvd_zero _ by_cases hm0 : m = 0 · subst hm0; simpa using Nat.lcm_dvd (by simpa using h1) (by simpa using h2) by_cases ha0 : a = 0 · subst ha0; simpa using h1 by_cases hb0 : b = 0 · subst hb0; simpa using h2 have hLne : Nat.lcm a b ≠ 0 := (Nat.lcm_pos (Nat.pos_of_ne_zero ha0) (Nat.pos_of_ne_zero hb0)).ne' have hgne : Nat.gcd m (Nat.lcm a b) ≠ 0 := (Nat.gcd_pos_of_pos_left _ (Nat.pos_of_ne_zero hm0)).ne' rw [← Nat.factorization_le_iff_dvd hgne hc0] intro p have h1p : (Nat.gcd m a).factorization p ≤ c.factorization p := (Nat.factorization_le_iff_dvd (Nat.gcd_pos_of_pos_left _ (Nat.pos_of_ne_zero hm0)).ne' hc0).mpr h1 p have h2p : (Nat.gcd m b).factorization p ≤ c.factorization p := (Nat.factorization_le_iff_dvd (Nat.gcd_pos_of_pos_left _ (Nat.pos_of_ne_zero hm0)).ne' hc0).mpr h2 p rw [Nat.factorization_gcd hm0 hLne, Finsupp.inf_apply, Nat.factorization_lcm ha0 hb0, Finsupp.sup_apply] rw [Nat.factorization_gcd hm0 ha0, Finsupp.inf_apply] at h1p rw [Nat.factorization_gcd hm0 hb0, Finsupp.inf_apply] at h2p omega /-- Helper: if `gcd m (f i) ∣ c` for every `i ∈ s`, then `gcd m (s.lcm f) ∣ c`. -/ private lemma gcd_finset_lcm_dvd {α : Type*} (s : Finset α) (f : α → ℕ) (m c : ℕ) (h : ∀ i ∈ s, Nat.gcd m (f i) ∣ c) : Nat.gcd m (s.lcm f) ∣ c := by classical induction s using Finset.induction_on with | empty => simp | insert a s ha ih => rw [Finset.lcm_insert] exact gcd_lcm_dvd_of_dvd (h a (mem_insert_self a s)) (ih (fun i hi => h i (mem_insert_of_mem hi))) /-- Key valuation lemma: if `G = gcd m M` divides `c`, `M' = M / G`, `g = gcd m d` does NOT divide `c`, and `q' = d / gcd M' d`, then `D = gcd q' g` does NOT divide `c`. -/ private lemma gcd_quot_not_dvd_of_gcd_not_dvd {m M d c : ℕ} (hm : 0 < m) (hM : 0 < M) (hd : 0 < d) (hGc : Nat.gcd m M ∣ c) (hgc : ¬ Nat.gcd m d ∣ c) : ¬ Nat.gcd (d / Nat.gcd (M / Nat.gcd m M) d) (Nat.gcd m d) ∣ c := by set G := Nat.gcd m M set M' := M / G set g := Nat.gcd m d set q' := d / Nat.gcd M' d intro hDc apply hgc have hGpos : 0 < G := Nat.gcd_pos_of_pos_left M hm have hM'_pos : 0 < M' := Nat.div_pos (Nat.le_of_dvd hM (Nat.gcd_dvd_right m M)) hGpos have hgpos : 0 < g := Nat.gcd_pos_of_pos_left d hm have hq'_pos : 0 < q' := Nat.div_pos (Nat.le_of_dvd hd (Nat.gcd_dvd_right M' d)) (Nat.gcd_pos_of_pos_right M' hd) -- Show `g ∣ c` by comparing prime-power divisibility for every prime `p`. by_cases hc0 : c = 0 · subst hc0; exact dvd_zero g have hcpos : 0 < c := Nat.pos_of_ne_zero hc0 rw [← Nat.factorization_le_iff_dvd hgpos.ne' hcpos.ne'] intro p by_cases hp : p.Prime · have hM_eq : G * M' = M := Nat.mul_div_cancel' (Nat.gcd_dvd_right m M) have hM_fac : M.factorization p = G.factorization p + M'.factorization p := by rw [← hM_eq, Nat.factorization_mul hGpos.ne' hM'_pos.ne', Finsupp.coe_add, Pi.add_apply] have hG_fac : G.factorization p = min (m.factorization p) (M.factorization p) := by simp [G, Nat.factorization_gcd hm.ne' hM.ne'] have hg_fac : g.factorization p = min (m.factorization p) (d.factorization p) := by simp [g, Nat.factorization_gcd hm.ne' hd.ne'] have hG_le_c : G.factorization p ≤ c.factorization p := (Nat.factorization_le_iff_dvd hGpos.ne' hcpos.ne').mpr hGc p have hD_le_c : (Nat.gcd q' g).factorization p ≤ c.factorization p := (Nat.factorization_le_iff_dvd (Nat.gcd_pos_of_pos_left g hq'_pos).ne' hcpos.ne').mpr hDc p have hD_fac : (Nat.gcd q' g).factorization p = min (q'.factorization p) (g.factorization p) := by simp [Nat.factorization_gcd hq'_pos.ne' hgpos.ne'] by_cases hM'_p : M'.factorization p = 0 · -- Case 1: `p ∤ M'`, so `v_p(gcd(M', d)) = 0`, hence `v_p(q') = v_p(d) ≥ v_p(g)`. have hgcd_eq : (Nat.gcd M' d).factorization p = 0 := by rw [Nat.factorization_gcd hM'_pos.ne' hd.ne', Finsupp.inf_apply, hM'_p, Nat.zero_min] have hd_eq : Nat.gcd M' d * q' = d := Nat.mul_div_cancel' (Nat.gcd_dvd_right M' d) have hq'_fac : q'.factorization p = d.factorization p := by have := congr_arg (fun n => n.factorization p) hd_eq rw [Nat.factorization_mul (Nat.gcd_pos_of_pos_right M' hd).ne' hq'_pos.ne', Finsupp.coe_add, Pi.add_apply, hgcd_eq, zero_add] at this exact this have hg_le_q' : g.factorization p ≤ q'.factorization p := by rw [hg_fac, hq'_fac]; exact min_le_right _ _ rw [hD_fac, min_eq_right hg_le_q'] at hD_le_c exact hD_le_c · -- Case 2: `v_p(M') > 0`, so `v_p(M) > v_p(G) = v_p(m)`, hence `v_p(g) ≤ v_p(m) = v_p(G) ≤ v_p(c)`. have hGm : G.factorization p = m.factorization p := by omega calc g.factorization p ≤ m.factorization p := by rw [hg_fac]; exact min_le_left _ _ _ = G.factorization p := hGm.symm _ ≤ c.factorization p := hG_le_c · simp [Nat.factorization_eq_zero_of_not_prime _ hp] /-- Density counting lemma inside `{0, ..., L - 1}`: if `q ∣ L` and `A ⊆ range L` satisfies `∀ x ∈ A, ∀ y ∈ A, (q : ℤ) ∣ (x - y)`, then `q * A.card ≤ L`. -/ private lemma card_mul_le_of_congr_mod {q L : ℕ} (hqL : q ∣ L) (A : Finset ℕ) (hA : A ⊆ Finset.range L) (hcong : ∀ x ∈ A, ∀ y ∈ A, (q : ℤ) ∣ ((x : ℤ) - (y : ℤ))) : q * A.card ≤ L := by by_cases hEmpty : A = ∅ · subst hEmpty; simp obtain ⟨x0, hx0⟩ := Finset.nonempty_iff_ne_empty.mpr hEmpty have hinj : Set.InjOn (fun x : ℕ => x / q) (A : Set ℕ) := by intro x hx y hy hdiv dsimp only at hdiv have hdvd : (q : ℤ) ∣ ((x : ℤ) - (y : ℤ)) := hcong x hx y hy have hmod_eq : x % q = y % q := by have h1 : (x : ℤ) % (q : ℤ) = (y : ℤ) % (q : ℤ) := Int.emod_eq_emod_iff_emod_sub_eq_zero.mpr (Int.emod_eq_zero_of_dvd hdvd) exact_mod_cast h1 have hx_eq := Nat.div_add_mod x q have hy_eq := Nat.div_add_mod y q rw [hdiv] at hx_eq omega have hmaps : Finset.image (fun x => x / q) A ⊆ Finset.range (L / q) := by intro u hu rcases Finset.mem_image.mp hu with ⟨x, hxA, rfl⟩ rw [Finset.mem_range] have hxL : x < L := Finset.mem_range.mp (hA hxA) exact Nat.div_lt_of_lt_mul (by rwa [Nat.mul_div_cancel' hqL]) have hcard : A.card ≤ L / q := by calc A.card = (Finset.image (fun x => x / q) A).card := (Finset.card_image_of_injOn hinj).symm _ ≤ (Finset.range (L / q)).card := Finset.card_le_card hmaps _ = L / q := Finset.card_range _ calc q * A.card ≤ q * (L / q) := Nat.mul_le_mul_left q hcard _ = L := Nat.mul_div_cancel' hqL /-- **Covering-System Density Obstruction Theorem (All `k ≥ 2`, `n ≥ 1`, `c ≥ 0`)**: If every divisor `d` with `1 ≤ d ≤ n` of `k - 1` also divides `c`, then NO covering of `ℤ` by `n` congruence classes `aᵢ + dᵢ * ℤ` can have every class avoiding `E_{k, c}`. -/ theorem no_avoiding_covering_system_of_admissible {k n c : ℕ} (hk : 2 ≤ k) (hadm : ∀ d, 1 ≤ d → d ≤ n → d ∣ (k - 1) → d ∣ c) : ¬ HasAvoidingCoveringSystem k n c := by classical rintro ⟨a, d, hd_pos, hAvoid, hCover⟩ have hm_pos : 0 < k - 1 := by omega -- Partition indices into T = {i | gcd(k - 1, d i) ∣ c} and S = {i | ¬ gcd(k - 1, d i) ∣ c}. set T : Finset (Fin n) := Finset.univ.filter (fun i => Nat.gcd (k - 1) (d i) ∣ c) set S : Finset (Fin n) := Finset.univ.filter (fun i => ¬ Nat.gcd (k - 1) (d i) ∣ c) set M_T : ℕ := T.lcm d have hMT_pos : 0 < M_T := finset_lcm_pos T d (fun i _ => hd_pos i) set G_T : ℕ := Nat.gcd (k - 1) M_T have hGT_pos : 0 < G_T := Nat.gcd_pos_of_pos_left M_T hm_pos have hGT_dvd_c : G_T ∣ c := gcd_finset_lcm_dvd T d (k - 1) c (fun i hi => (Finset.mem_filter.mp hi).2) set M'_T : ℕ := M_T / G_T have hM'_pos : 0 < M'_T := Nat.div_pos (Nat.le_of_dvd hMT_pos (Nat.gcd_dvd_right _ _)) hGT_pos -- Step 1: Find x₀ ∈ ℤ such that (k - 1) * x₀ + c ≡ 0 (mod M_T) via Bézout's identity. rcases hGT_dvd_c with ⟨u, hu⟩ have hbez : (G_T : ℤ) = ((k - 1 : ℕ) : ℤ) * Nat.gcdA (k - 1) M_T + (M_T : ℤ) * Nat.gcdB (k - 1) M_T := Nat.gcd_eq_gcd_ab (k - 1) M_T set x0 : ℤ := -(u : ℤ) * Nat.gcdA (k - 1) M_T have hx0_congr : (M_T : ℤ) ∣ (((k : ℤ) - 1) * x0 + (c : ℤ)) := by refine ⟨(u : ℤ) * Nat.gcdB (k - 1) M_T, ?_⟩ have hkm1 : ((k - 1 : ℕ) : ℤ) = (k : ℤ) - 1 := by omega have hc_eq : (c : ℤ) = (G_T : ℤ) * (u : ℤ) := by exact_mod_cast hu rw [hkm1] at hbez dsimp only [x0] nlinarith -- Step 2: Every x = x₀ + t * M'_T satisfies (k - 1) * x + c ≡ 0 (mod M_T), hence avoids all of T. have hAP_in_S : ∀ t : ℕ, ∃ i ∈ S, (d i : ℤ) ∣ (x0 + (t : ℤ) * (M'_T : ℤ) - a i) := by intro t obtain ⟨i, hi_div⟩ := hCover (x0 + (t : ℤ) * (M'_T : ℤ)) refine ⟨i, ?_, hi_div⟩ rw [Finset.mem_filter] refine ⟨Finset.mem_univ i, ?_⟩ intro hiT_cond have hiT : i ∈ T := Finset.mem_filter.mpr ⟨Finset.mem_univ i, hiT_cond⟩ have hdi_MT : (d i : ℤ) ∣ (M_T : ℤ) := Int.ofNat_dvd.mpr (Finset.dvd_lcm hiT) have hMT_step : (M_T : ℤ) ∣ ((k : ℤ) - 1) * ((t : ℤ) * (M'_T : ℤ)) := by have h1 : (M_T : ℤ) ∣ ((k : ℤ) - 1) * (M'_T : ℤ) := by have hkm1 : (G_T : ℤ) ∣ ((k : ℤ) - 1) := by have := Int.ofNat_dvd.mpr (Nat.gcd_dvd_left (k - 1) M_T) have hcast : ((k - 1 : ℕ) : ℤ) = (k : ℤ) - 1 := by omega rwa [hcast] at this rcases hkm1 with ⟨w, hw⟩ refine ⟨w, ?_⟩ have hmul : (G_T : ℤ) * (M'_T : ℤ) = (M_T : ℤ) := by exact_mod_cast Nat.mul_div_cancel' (Nat.gcd_dvd_right (k - 1) M_T) nlinarith rcases h1 with ⟨w, hw⟩ refine ⟨w * (t : ℤ), ?_⟩ nlinarith have hMT_x : (M_T : ℤ) ∣ ((k : ℤ) - 1) * (x0 + (t : ℤ) * (M'_T : ℤ)) + (c : ℤ) := by have hre : ((k : ℤ) - 1) * (x0 + (t : ℤ) * (M'_T : ℤ)) + (c : ℤ) = (((k : ℤ) - 1) * x0 + (c : ℤ)) + ((k : ℤ) - 1) * ((t : ℤ) * (M'_T : ℤ)) := by ring rw [hre] exact dvd_add hx0_congr hMT_step have hdi_x : (d i : ℤ) ∣ ((k : ℤ) - 1) * (x0 + (t : ℤ) * (M'_T : ℤ)) + (c : ℤ) := dvd_trans hdi_MT hMT_x have hdi_ai : (d i : ℤ) ∣ ((k : ℤ) - 1) * a i + (c : ℤ) := by have hsub := dvd_sub hdi_x (dvd_mul_of_dvd_right hi_div ((k : ℤ) - 1)) have hre : ((k : ℤ) - 1) * (x0 + (t : ℤ) * (M'_T : ℤ)) + (c : ℤ) - ((k : ℤ) - 1) * (x0 + (t : ℤ) * (M'_T : ℤ) - a i) = ((k : ℤ) - 1) * a i + (c : ℤ) := by ring rwa [hre] at hsub exact ((avoidsEqClass_iff_not_dvd (a i) (d i)).mp (hAvoid i)) hdi_ai -- Step 3: For each i ∈ S, q' i = d i / gcd(M'_T, d i) satisfies q' i ≥ n + 1. let q' : Fin n → ℕ := fun i => d i / Nat.gcd M'_T (d i) have hq'_pos : ∀ i, 0 < q' i := fun i => Nat.div_pos (Nat.le_of_dvd (hd_pos i) (Nat.gcd_dvd_right _ _)) (Nat.gcd_pos_of_pos_right M'_T (hd_pos i)) have hq'_ge : ∀ i ∈ S, n + 1 ≤ q' i := by intro i hiS have hnot : ¬ Nat.gcd (k - 1) (d i) ∣ c := (Finset.mem_filter.mp hiS).2 set D := Nat.gcd (q' i) (Nat.gcd (k - 1) (d i)) have hD_not_c : ¬ D ∣ c := gcd_quot_not_dvd_of_gcd_not_dvd hm_pos hMT_pos (hd_pos i) (gcd_finset_lcm_dvd T d (k - 1) c (fun j hj => (Finset.mem_filter.mp hj).2)) hnot have hD_pos : 1 ≤ D := Nat.gcd_pos_of_pos_left _ (hq'_pos i) have hD_dvd_k1 : D ∣ (k - 1) := dvd_trans (Nat.gcd_dvd_right _ _) (Nat.gcd_dvd_left _ _) have hD_gt_n : n < D := by by_contra hle push Not at hle exact hD_not_c (hadm D hD_pos hle hD_dvd_k1) have hD_le_q' : D ≤ q' i := Nat.le_of_dvd (hq'_pos i) (Nat.gcd_dvd_left _ _) omega -- Step 4: Count hits in range L where L = lcm_{i ∈ S} q' i. set L : ℕ := S.lcm q' have hL_pos : 0 < L := finset_lcm_pos S q' (fun i _ => hq'_pos i) let A : Fin n → Finset ℕ := fun i => (Finset.range L).filter (fun t => (d i : ℤ) ∣ (x0 + (t : ℤ) * (M'_T : ℤ) - a i)) have hRange_sub : Finset.range L ⊆ S.biUnion A := by intro t ht obtain ⟨i, hiS, hiDiv⟩ := hAP_in_S t exact Finset.mem_biUnion.mpr ⟨i, hiS, Finset.mem_filter.mpr ⟨ht, hiDiv⟩⟩ have hL_le_sum : L ≤ ∑ i ∈ S, (A i).card := by calc L = (Finset.range L).card := (Finset.card_range L).symm _ ≤ (S.biUnion A).card := Finset.card_le_card hRange_sub _ ≤ ∑ i ∈ S, (A i).card := Finset.card_biUnion_le have hAi_bound : ∀ i ∈ S, (n + 1) * (A i).card ≤ L := by intro i hiS have hcong : ∀ x ∈ A i, ∀ y ∈ A i, (q' i : ℤ) ∣ ((x : ℤ) - (y : ℤ)) := by intro x hx y hy have hxD : (d i : ℤ) ∣ (x0 + (x : ℤ) * (M'_T : ℤ) - a i) := (Finset.mem_filter.mp hx).2 have hyD : (d i : ℤ) ∣ (x0 + (y : ℤ) * (M'_T : ℤ) - a i) := (Finset.mem_filter.mp hy).2 have hdiff : (d i : ℤ) ∣ ((x : ℤ) - (y : ℤ)) * (M'_T : ℤ) := by have hsub := dvd_sub hxD hyD have hre : (x0 + (x : ℤ) * (M'_T : ℤ) - a i) - (x0 + (y : ℤ) * (M'_T : ℤ) - a i) = ((x : ℤ) - (y : ℤ)) * (M'_T : ℤ) := by ring rwa [hre] at hsub set g_i := Nat.gcd M'_T (d i) have hg_pos : 0 < g_i := Nat.gcd_pos_of_pos_right M'_T (hd_pos i) have hdi_eq : (d i : ℤ) = (g_i : ℤ) * (q' i : ℤ) := by exact_mod_cast (Nat.mul_div_cancel' (Nat.gcd_dvd_right M'_T (d i))).symm have hM'_eq : (M'_T : ℤ) = (g_i : ℤ) * ((M'_T / g_i : ℕ) : ℤ) := by exact_mod_cast (Nat.mul_div_cancel' (Nat.gcd_dvd_left M'_T (d i))).symm have hq'_div : (q' i : ℤ) ∣ ((x : ℤ) - (y : ℤ)) * ((M'_T / g_i : ℕ) : ℤ) := by rw [hdi_eq, hM'_eq] at hdiff rcases hdiff with ⟨w, hw⟩ refine ⟨w, ?_⟩ have hg_ne : (g_i : ℤ) ≠ 0 := by omega nlinarith have hcop : IsCoprime (q' i : ℤ) ((M'_T / g_i : ℕ) : ℤ) := by have hnc : Nat.Coprime (M'_T / g_i) (q' i) := Nat.coprime_div_gcd_div_gcd hg_pos exact (Nat.isCoprime_iff_coprime.mpr hnc.symm) exact hcop.dvd_of_dvd_mul_right hq'_div have hq_mul : q' i * (A i).card ≤ L := card_mul_le_of_congr_mod (Finset.dvd_lcm hiS) (A i) (Finset.filter_subset _ _) hcong calc (n + 1) * (A i).card ≤ q' i * (A i).card := Nat.mul_le_mul_right _ (hq'_ge i hiS) _ ≤ L := hq_mul have hContra : (n + 1) * L ≤ n * L := by calc (n + 1) * L ≤ (n + 1) * ∑ i ∈ S, (A i).card := Nat.mul_le_mul_left _ hL_le_sum _ = ∑ i ∈ S, (n + 1) * (A i).card := Finset.mul_sum _ _ _ _ ≤ ∑ _i ∈ S, L := Finset.sum_le_sum hAi_bound _ = S.card * L := by simp _ ≤ n * L := Nat.mul_le_mul_right L (by calc S.card ≤ (Finset.univ : Finset (Fin n)).card := Finset.card_le_card (Finset.subset_univ _) _ = n := by simp) nlinarith /-- **Exact Characterization of Avoiding Covering Systems (All `k ≥ 2`, `n ≥ 1`, `c ≥ 0`)**: A covering of `ℤ` by `n` congruence classes avoiding `E_{k, c}` exists if and only if there exists a divisor `d` of `k - 1` with `1 ≤ d ≤ n` and `d ∤ c`. -/ theorem hasAvoidingCoveringSystem_iff {k n c : ℕ} (hk : 2 ≤ k) : HasAvoidingCoveringSystem k n c ↔ ∃ d, 1 ≤ d ∧ d ≤ n ∧ d ∣ (k - 1) ∧ ¬ d ∣ c := by constructor · intro hCov by_contra hAll push Not at hAll exact no_avoiding_covering_system_of_admissible hk hAll hCov · rintro ⟨d, hd1, hdn, hdk, hdc⟩ exact hasAvoidingCoveringSystem_of_non_dvd (by omega) hd1 hdn hdk hdc /-! ### Axiom Audit -/ #print axioms avoidsEqClass_iff_not_dvd #print axioms no_avoiding_covering_system_of_admissible #print axioms hasAvoidingCoveringSystem_iff end CoveringSystemObstruction