/- Copyright (c) 2026. All rights reserved. # Novel 2-adic Beyond-Dumas & Newton-Polygon Breakthroughs on Zhi-Wei Sun's # Open Polynomial Irreducibility Conjecture (OEIS A115257) Zhi-Wei Sun (March 23, 2013, OEIS A115257 / `FormalConjectures/OEIS/115257.lean`) conjectured that for every integer `n ≥ 1`, both polynomials $$P_n(x) = \sum_{k=0}^{n} \binom{2k}{k}^2 x^k \quad\text{and}\quad Q_n(x) = \sum_{k=0}^{n} \frac{\binom{2k}{k}^2}{k+1} x^k$$ are irreducible over `ℚ`. We prove: 1. **Beyond-Dumas Mod-16 Irreducibility Criterion** (`irreducible_of_mod16_two_pow`): A general 2-adic polynomial irreducibility criterion that breaks the `2^{r-1} + 2^{r-1}` Newton-polygon barrier via an exact mod-16 polynomial obstruction. 2. **First Infinite Irreducibility Family for `P_n`** (`polyP_irreducible_two_pow`): `P_{2^r}(x)` is irreducible over `ℚ` for **every** `r ≥ 0`. 3. **Generalized Central-Binomial Power Family** (`centralBinomPowPoly_irreducible_two_pow_odd`): `\sum_{k=0}^{2^r} \binom{2k}{k}^e x^k` is irreducible over `ℚ` for every `r ≥ 0` and odd `e ≥ 1`. 4. **General Elementary Dumas Newton-Polygon Engine** (`npWidth_mul`, `dvd_npWidth`, `npWidth_sum_le_natDegree`, `dumas_single_segment_dvd_natDegree`, `irreducible_of_dumas_single_segment`, `exists_irred_factor_natDegree_ge_of_npWidth`, `dvd_natDegree_of_all_npWidths`) — completely self-contained in `ℤ[X]`, requiring no `ℚ_p`. 5. **Exact Factor-Degree Structure for `Q_{2^r}` and Sporadic Irreducibility**: - `Q_{2^r}(x)` (`r ≥ 2`): every rational factor has degree divisible by `2^{r-1}` (`polyQ_two_pow_factor_deg_dvd`). - `Q_1, Q_3, Q_7` are irreducible over `ℚ` by single-segment 2-adic Dumas. 6. **Universal Even-Factor-Degree Law for `4 ∣ n`** (`polyP_four_mul_even_factor_deg`, `polyQ_four_mul_even_factor_deg`): for every `m ≥ 1`, every rational factor of `P_{4m}(x)` and every rational factor of `Q_{4m}(x)` has **even** degree. 7. **Half-Degree Prime-Family Irreducible Factor Lower Bounds** (`polyQ_prime_sub_one_large_irred_factor`, `polyP_prime_sub_one_large_irred_factor`): for every odd prime `p`, `Q_{p-1}(x)` has an irreducible factor of degree `≥ (p - 1)/2`; for every prime `p ≡ 3 (mod 4)`, `P_{p-1}(x)` has an irreducible factor of degree `≥ (p - 1)/2`. 8. **Universal Rational-Root Nonexistence** (`polyP_no_rat_root`, `polyQ_no_rat_root`): for **every** `n ≥ 2`, neither `P_n(x)` nor `Q_n(x)` has any rational root. 9. **3-adic Shifted Newton Polygon Irreducibility of `P_{13}`** (`polyP_irreducible_thirteen`). -/ import Mathlib namespace OeisA115257 open Polynomial Finset BigOperators /-! ## Section 1: Core Definitions and 2-adic Central-Binomial Theory -/ /-- Partial sums of $\binom{2k}{k}^2$ (OEIS A115257). -/ def a (n : ℕ) : ℕ := ∑ k ∈ Finset.range (n + 1), (Nat.centralBinom k) ^ 2 theorem a_0 : a 0 = 1 := by rfl theorem a_1 : a 1 = 5 := by rfl theorem a_2 : a 2 = 41 := by rfl theorem a_3 : a 3 = 441 := by rfl /-- The polynomial $P_n(x) = \sum_{k=0}^{n} \binom{2k}{k}^2 x^k \in \mathbb{Q}[x]$. -/ noncomputable def polyP (n : ℕ) : ℚ[X] := ∑ k ∈ Finset.range (n + 1), C ((Nat.centralBinom k : ℚ) ^ 2) * X ^ k /-- The polynomial $Q_n(x) = \sum_{k=0}^{n} \frac{\binom{2k}{k}^2}{k+1} x^k \in \mathbb{Q}[x]$. -/ noncomputable def polyQ (n : ℕ) : ℚ[X] := ∑ k ∈ Finset.range (n + 1), C (((Nat.centralBinom k : ℚ) ^ 2) / (k + 1 : ℚ)) * X ^ k /-- Integer coefficient $c_k^P = \binom{2k}{k}^2$. -/ def pCoeff (k : ℕ) : ℕ := (Nat.centralBinom k) ^ 2 /-- Integer coefficient $c_k^Q = C_k \binom{2k}{k} = \frac{\binom{2k}{k}^2}{k+1}$, where $C_k = \frac{1}{k+1}\binom{2k}{k}$ is the $k$-th Catalan number. -/ def qCoeff (k : ℕ) : ℕ := (Nat.centralBinom k / (k + 1)) * Nat.centralBinom k /-- Integer form of $P_n(x)$ in $\mathbb{Z}[x]$. -/ noncomputable def polyPInt (n : ℕ) : ℤ[X] := ∑ k ∈ Finset.range (n + 1), C (pCoeff k : ℤ) * X ^ k /-- Integer form of $Q_n(x)$ in $\mathbb{Z}[x]$. -/ noncomputable def polyQInt (n : ℕ) : ℤ[X] := ∑ k ∈ Finset.range (n + 1), C (qCoeff k : ℤ) * X ^ k /-- Generalized central-binomial power polynomial $\sum_{k=0}^n \binom{2k}{k}^e x^k \in \mathbb{Q}[x]$. -/ noncomputable def centralBinomPowPoly (e n : ℕ) : ℚ[X] := ∑ k ∈ Finset.range (n + 1), C ((Nat.centralBinom k : ℚ) ^ e) * X ^ k /-- Integer form of $\sum_{k=0}^n \binom{2k}{k}^e x^k$ in $\mathbb{Z}[x]$. -/ noncomputable def centralBinomPowInt (e n : ℕ) : ℤ[X] := ∑ k ∈ Finset.range (n + 1), C (((Nat.centralBinom k) ^ e : ℕ) : ℤ) * X ^ k lemma succ_dvd_centralBinom (k : ℕ) : k + 1 ∣ Nat.centralBinom k := by have h1 := Nat.choose_succ_right_eq (2 * k) k rw [show 2 * k - k = k by omega] at h1 have hle : (2 * k).choose (k + 1) ≤ (2 * k).choose k := by have hmul : (2 * k).choose (k + 1) * (k + 1) ≤ (2 * k).choose k * (k + 1) := by rw [h1]; exact Nat.mul_le_mul_left _ (Nat.le_succ k) exact Nat.le_of_mul_le_mul_right hmul (Nat.succ_pos k) refine ⟨(2 * k).choose k - (2 * k).choose (k + 1), ?_⟩ rw [Nat.centralBinom_eq_two_mul_choose] zify [hle] at h1 ⊢ linarith lemma qCoeff_mul_succ (k : ℕ) : qCoeff k * (k + 1) = (Nat.centralBinom k) ^ 2 := by unfold qCoeff have hdvd := succ_dvd_centralBinom k calc Nat.centralBinom k / (k + 1) * Nat.centralBinom k * (k + 1) = (Nat.centralBinom k / (k + 1) * (k + 1)) * Nat.centralBinom k := by ring _ = Nat.centralBinom k * Nat.centralBinom k := by rw [Nat.div_mul_cancel hdvd] _ = (Nat.centralBinom k) ^ 2 := by ring lemma polyPInt_map_rat (n : ℕ) : (polyPInt n).map (Int.castRingHom ℚ) = polyP n := by unfold polyPInt polyP pCoeff rw [Polynomial.map_sum] refine Finset.sum_congr rfl fun k _ => ?_ simp lemma polyQInt_map_rat (n : ℕ) : (polyQInt n).map (Int.castRingHom ℚ) = polyQ n := by unfold polyQInt polyQ rw [Polynomial.map_sum] refine Finset.sum_congr rfl fun k _ => ?_ rw [Polynomial.map_mul, Polynomial.map_C, Polynomial.map_pow, Polynomial.map_X] congr 2 have hq : ((qCoeff k : ℚ) * (k + 1 : ℚ)) = (Nat.centralBinom k : ℚ) ^ 2 := by exact_mod_cast qCoeff_mul_succ k have hk : (k + 1 : ℚ) ≠ 0 := by positivity simp only [eq_intCast, Int.cast_natCast] exact eq_div_of_mul_eq hk hq lemma centralBinomPowInt_map_rat (e n : ℕ) : (centralBinomPowInt e n).map (Int.castRingHom ℚ) = centralBinomPowPoly e n := by unfold centralBinomPowInt centralBinomPowPoly rw [Polynomial.map_sum] refine Finset.sum_congr rfl fun k _ => ?_ simp /-- Generic coefficient lemma for finite sums `∑ k ∈ range (n + 1), C (c k) * X ^ k`. -/ lemma coeff_sum_C_mul_X_pow {R : Type*} [Semiring R] (c : ℕ → R) (n k : ℕ) : (∑ j ∈ Finset.range (n + 1), C (c j) * X ^ j).coeff k = if k ≤ n then c k else 0 := by rw [Polynomial.finsetSum_coeff] simp only [Polynomial.coeff_C_mul, Polynomial.coeff_X_pow, mul_ite, mul_one, mul_zero] by_cases hkn : k ≤ n · rw [if_pos hkn, Finset.sum_eq_single k] · simp · intro b _ hbk; exact if_neg (Ne.symm hbk) · intro hk; exact absurd (Finset.mem_range.mpr (Nat.lt_succ_of_le hkn)) hk · rw [if_neg hkn] refine Finset.sum_eq_zero fun b hb => ?_ have hbn : b ≤ n := Nat.lt_succ_iff.mp (Finset.mem_range.mp hb) exact if_neg (by omega) lemma polyPInt_coeff (n k : ℕ) : (polyPInt n).coeff k = if k ≤ n then (pCoeff k : ℤ) else 0 := coeff_sum_C_mul_X_pow (fun j => (pCoeff j : ℤ)) n k lemma polyQInt_coeff (n k : ℕ) : (polyQInt n).coeff k = if k ≤ n then (qCoeff k : ℤ) else 0 := coeff_sum_C_mul_X_pow (fun j => (qCoeff j : ℤ)) n k lemma centralBinomPowInt_coeff (e n k : ℕ) : (centralBinomPowInt e n).coeff k = if k ≤ n then (((Nat.centralBinom k) ^ e : ℕ) : ℤ) else 0 := coeff_sum_C_mul_X_pow (fun j => (((Nat.centralBinom j) ^ e : ℕ) : ℤ)) n k lemma pCoeff_pos (k : ℕ) : 0 < pCoeff k := by unfold pCoeff; exact pow_pos (Nat.centralBinom_pos k) 2 lemma qCoeff_pos (k : ℕ) : 0 < qCoeff k := by have h := qCoeff_mul_succ k by_contra h0 have hq0 : qCoeff k = 0 := by omega rw [hq0, zero_mul] at h exact (pow_pos (Nat.centralBinom_pos k) 2).ne' h.symm lemma polyPInt_natDegree (n : ℕ) : (polyPInt n).natDegree = n := by refine Polynomial.natDegree_eq_of_le_of_coeff_ne_zero ?_ ?_ · refine Polynomial.natDegree_le_iff_coeff_eq_zero.mpr fun m hm => ?_ rw [polyPInt_coeff, if_neg (by omega)] · rw [polyPInt_coeff, if_pos le_rfl] exact Int.natCast_ne_zero.mpr (pCoeff_pos n).ne' lemma polyQInt_natDegree (n : ℕ) : (polyQInt n).natDegree = n := by refine Polynomial.natDegree_eq_of_le_of_coeff_ne_zero ?_ ?_ · refine Polynomial.natDegree_le_iff_coeff_eq_zero.mpr fun m hm => ?_ rw [polyQInt_coeff, if_neg (by omega)] · rw [polyQInt_coeff, if_pos le_rfl] exact Int.natCast_ne_zero.mpr (qCoeff_pos n).ne' lemma centralBinomPowInt_natDegree (e n : ℕ) : (centralBinomPowInt e n).natDegree = n := by refine Polynomial.natDegree_eq_of_le_of_coeff_ne_zero ?_ ?_ · refine Polynomial.natDegree_le_iff_coeff_eq_zero.mpr fun m hm => ?_ rw [centralBinomPowInt_coeff, if_neg (by omega)] · rw [centralBinomPowInt_coeff, if_pos le_rfl] exact Int.natCast_ne_zero.mpr (pow_pos (Nat.centralBinom_pos n) e).ne' lemma polyPInt_coeff_zero (n : ℕ) : (polyPInt n).coeff 0 = 1 := by rw [polyPInt_coeff, if_pos (Nat.zero_le n)]; rfl lemma polyQInt_coeff_zero (n : ℕ) : (polyQInt n).coeff 0 = 1 := by rw [polyQInt_coeff, if_pos (Nat.zero_le n)]; rfl lemma centralBinomPowInt_coeff_zero (e n : ℕ) : (centralBinomPowInt e n).coeff 0 = 1 := by rw [centralBinomPowInt_coeff, if_pos (Nat.zero_le n)] simp [Nat.centralBinom] lemma isPrimitive_of_coeff_zero_eq_one {P : ℤ[X]} (h0 : P.coeff 0 = 1) : P.IsPrimitive := by rw [Polynomial.isPrimitive_iff_isUnit_of_C_dvd] intro r hr obtain ⟨q, hq⟩ := hr have h := congrArg (fun Q => Q.coeff 0) hq rw [h0, Polynomial.coeff_C_mul] at h exact isUnit_of_dvd_one ⟨q.coeff 0, h⟩ lemma polyPInt_isPrimitive (n : ℕ) : (polyPInt n).IsPrimitive := isPrimitive_of_coeff_zero_eq_one (polyPInt_coeff_zero n) lemma polyQInt_isPrimitive (n : ℕ) : (polyQInt n).IsPrimitive := isPrimitive_of_coeff_zero_eq_one (polyQInt_coeff_zero n) lemma centralBinomPowInt_isPrimitive (e n : ℕ) : (centralBinomPowInt e n).IsPrimitive := isPrimitive_of_coeff_zero_eq_one (centralBinomPowInt_coeff_zero e n) /-- Leading product coefficient for polynomials of bounded degree. -/ lemma coeff_mul_of_natDegree_le {R : Type*} [Semiring R] {p q : R[X]} {m n : ℕ} (hp : p.natDegree ≤ m) (hq : q.natDegree ≤ n) : (p * q).coeff (m + n) = p.coeff m * q.coeff n := by rw [Polynomial.coeff_mul, Finset.sum_eq_single (m, n)] · intro x hx hne have hsum : x.1 + x.2 = m + n := by simpa using hx by_cases h1 : m < x.1 · rw [Polynomial.coeff_eq_zero_of_natDegree_lt (p := p) (by omega), zero_mul] · by_cases h2 : n < x.2 · rw [Polynomial.coeff_eq_zero_of_natDegree_lt (p := q) (by omega), mul_zero] · exfalso; apply hne; ext <;> omega · intro hm; exact absurd (by simp : (m, n) ∈ Finset.HasAntidiagonal.antidiagonal (m + n)) hm /-! ### Exact 2-adic valuation of $\binom{2k}{k}$ via binary digit sum -/ /-- Exact 2-adic factorial recurrence: $v_2((2k)!) = k + v_2(k!)$. -/ lemma padicValNat_two_mul_factorial (k : ℕ) : padicValNat 2 (2 * k).factorial = k + padicValNat 2 k.factorial := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ induction k with | zero => simp | succ m ih => have h1 : (2 * (m + 1)).factorial = (2 * m + 2) * (2 * m + 1) * (2 * m).factorial := by rw [show 2 * (m + 1) = (2 * m + 1) + 1 by omega, Nat.factorial_succ, Nat.factorial_succ] ring have h2 : 2 * m + 2 = 2 * (m + 1) := by ring rw [h1, h2] have hne1 : 2 * (m + 1) ≠ 0 := by omega have hne2 : 2 * m + 1 ≠ 0 := by omega have hne3 : (2 * m).factorial ≠ 0 := Nat.factorial_ne_zero _ rw [padicValNat.mul (mul_ne_zero hne1 hne2) hne3, padicValNat.mul hne1 hne2, padicValNat.mul (by norm_num) (Nat.succ_ne_zero m), padicValNat.self (by norm_num)] have hodd : padicValNat 2 (2 * m + 1) = 0 := padicValNat.eq_zero_of_not_dvd (by omega) rw [hodd, ih, Nat.factorial_succ, padicValNat.mul (Nat.succ_ne_zero m) (Nat.factorial_ne_zero m)] omega /-- Legendre's 2-adic identity: $k = v_2(k!) + s_2(k)$, proved by binary strong induction. -/ lemma self_eq_padicValNat_factorial_add_sum_digits (k : ℕ) : k = padicValNat 2 k.factorial + (Nat.digits 2 k).sum := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ induction k using Nat.strongRecOn with | ind n ih => rcases n with _ | n · simp · by_cases hpar : (n + 1) % 2 = 0 · set m := (n + 1) / 2 with hm_def have hm_pos : 0 < m := by omega have hn_eq : n + 1 = 2 * m := by omega have hm_lt : m < n + 1 := by omega rw [hn_eq, padicValNat_two_mul_factorial] have hdig : (Nat.digits 2 (2 * m)).sum = (Nat.digits 2 m).sum := by rw [Nat.digits_def' (by norm_num : 1 < 2) (by omega : 0 < 2 * m)] simp [Nat.mul_mod_right, Nat.mul_div_right _ (by norm_num : 0 < 2)] rw [hdig] have := ih m hm_lt omega · set m := n / 2 with hm_def have hn_eq : n + 1 = 2 * m + 1 := by omega have hm_lt : m < n + 1 := by omega rw [hn_eq, Nat.factorial_succ, padicValNat.mul (by omega) (Nat.factorial_ne_zero _)] have hodd : padicValNat 2 (2 * m + 1) = 0 := padicValNat.eq_zero_of_not_dvd (by omega) rw [hodd, zero_add, padicValNat_two_mul_factorial] have hdig : (Nat.digits 2 (2 * m + 1)).sum = 1 + (Nat.digits 2 m).sum := by rw [Nat.digits_def' (by norm_num : 1 < 2) (by omega : 0 < 2 * m + 1)] simp [show (2 * m + 1) % 2 = 1 by omega, show (2 * m + 1) / 2 = m by omega] rw [hdig] have := ih m hm_lt omega /-- **Kummer's 2-adic Central Binomial Theorem**: $v_2\!\left(\binom{2k}{k}\right) = s_2(k)$ for every $k \in \mathbb{N}$. -/ theorem padicValNat_centralBinom_eq_sum_digits (k : ℕ) : padicValNat 2 (Nat.centralBinom k) = (Nat.digits 2 k).sum := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ have hmul : Nat.centralBinom k * (k.factorial * k.factorial) = (2 * k).factorial := by rw [Nat.centralBinom_eq_two_mul_choose] have h := Nat.choose_mul_factorial_mul_factorial (show k ≤ 2 * k by omega) rw [show 2 * k - k = k by omega] at h simpa [mul_assoc] using h have hne_cb : Nat.centralBinom k ≠ 0 := (Nat.centralBinom_pos k).ne' have hne_f : k.factorial ≠ 0 := Nat.factorial_ne_zero k have hv := congrArg (padicValNat 2) hmul rw [padicValNat.mul hne_cb (mul_ne_zero hne_f hne_f), padicValNat.mul hne_f hne_f, padicValNat_two_mul_factorial] at hv have hleg := self_eq_padicValNat_factorial_add_sum_digits k omega lemma digits_two_sum_pos {k : ℕ} (hk : 0 < k) : 1 ≤ (Nat.digits 2 k).sum := by induction k using Nat.strongRecOn with | ind n ih => rw [Nat.digits_def' (by norm_num : 1 < 2) hk] simp only [List.sum_cons] by_cases hodd : n % 2 = 1 · omega · have hdiv : 0 < n / 2 := by omega have hlt : n / 2 < n := by omega have := ih (n / 2) hlt hdiv omega lemma digits_two_sum_pow_two (j : ℕ) : (Nat.digits 2 (2 ^ j)).sum = 1 := by induction j with | zero => decide | succ m ih => rw [pow_succ', Nat.digits_def' (by norm_num : 1 < 2) (by positivity)] simp only [List.sum_cons, Nat.mul_mod_right, Nat.mul_div_right _ (by norm_num : 0 < 2), zero_add, ih] /-- If $s_2(k) = 1$, then $k = 2^j$ for some $j \in \mathbb{N}$. -/ lemma exists_pow_two_of_digits_sum_eq_one {k : ℕ} (hs : (Nat.digits 2 k).sum = 1) : ∃ j : ℕ, k = 2 ^ j := by induction k using Nat.strongRecOn with | ind n ih => rcases n with _ | n · simp at hs · have hpos : 0 < n + 1 := Nat.succ_pos n rw [Nat.digits_def' (by norm_num : 1 < 2) hpos] at hs simp only [List.sum_cons] at hs by_cases hmod : (n + 1) % 2 = 1 · rw [hmod] at hs have hzero : (Nat.digits 2 ((n + 1) / 2)).sum = 0 := by omega have hdiv0 : (n + 1) / 2 = 0 := by by_contra hne have hpos' := digits_two_sum_pos (Nat.pos_of_ne_zero hne) omega exact ⟨0, by omega⟩ · have hmod0 : (n + 1) % 2 = 0 := by omega rw [hmod0] at hs have hdiv_lt : (n + 1) / 2 < n + 1 := by omega obtain ⟨j, hj⟩ := ih ((n + 1) / 2) hdiv_lt (by omega) exact ⟨j + 1, by rw [pow_succ', ← hj]; omega⟩ lemma two_pow_sum_digits_dvd_centralBinom (k : ℕ) : 2 ^ (Nat.digits 2 k).sum ∣ Nat.centralBinom k := by rw [← padicValNat_centralBinom_eq_sum_digits k] exact pow_padicValNat_dvd lemma four_dvd_pCoeff {k : ℕ} (hk : 1 ≤ k) : 4 ∣ pCoeff k := by have h1 : 2 ∣ Nat.centralBinom k := by have hle : 1 ≤ (Nat.digits 2 k).sum := digits_two_sum_pos hk exact (pow_dvd_pow 2 hle).trans (two_pow_sum_digits_dvd_centralBinom k) obtain ⟨m, hm⟩ := h1 exact ⟨m ^ 2, by unfold pCoeff; rw [hm]; ring⟩ lemma pCoeff_two_pow_div_four_modEq (j : ℕ) : pCoeff (2 ^ j) / 4 ≡ 1 [MOD 4] := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ have hv : padicValNat 2 (Nat.centralBinom (2 ^ j)) = 1 := by rw [padicValNat_centralBinom_eq_sum_digits, digits_two_sum_pow_two] have hdvd2 : 2 ∣ Nat.centralBinom (2 ^ j) := by have := @pow_padicValNat_dvd 2 (Nat.centralBinom (2 ^ j)) rwa [hv, pow_one] at this obtain ⟨m, hm⟩ := hdvd2 have hm_odd : m % 2 = 1 := by by_contra h have h2m : 2 ∣ m := Nat.dvd_of_mod_eq_zero (by omega) obtain ⟨t, rfl⟩ := h2m have h4 : 2 ^ 2 ∣ Nat.centralBinom (2 ^ j) := ⟨t, by rw [hm]; ring⟩ have hle : 2 ≤ padicValNat 2 (Nat.centralBinom (2 ^ j)) := (padicValNat_dvd_iff_le (Nat.centralBinom_pos _).ne').mp h4 omega have hp : pCoeff (2 ^ j) / 4 = m ^ 2 := by unfold pCoeff rw [hm, show (2 * m) ^ 2 = 4 * m ^ 2 by ring, Nat.mul_div_cancel_left _ (by norm_num)] rw [hp] change m ^ 2 % 4 = 1 % 4 have : m % 4 = 1 ∨ m % 4 = 3 := by omega rcases this with h1 | h3 · rw [Nat.pow_mod, h1] · rw [Nat.pow_mod, h3] lemma sixteen_dvd_pCoeff_of_not_pow_two {k : ℕ} (hk : 1 ≤ k) (hnot : ∀ j : ℕ, k ≠ 2 ^ j) : 16 ∣ pCoeff k := by have hs1 : 1 ≤ (Nat.digits 2 k).sum := digits_two_sum_pos hk have hsne : (Nat.digits 2 k).sum ≠ 1 := by intro h1 obtain ⟨j, hj⟩ := exists_pow_two_of_digits_sum_eq_one h1 exact hnot j hj have hs2 : 2 ≤ (Nat.digits 2 k).sum := by omega have h4 : 4 ∣ Nat.centralBinom k := (pow_dvd_pow 2 hs2).trans (two_pow_sum_digits_dvd_centralBinom k) obtain ⟨m, hm⟩ := h4 exact ⟨m ^ 2, by unfold pCoeff; rw [hm]; ring⟩ /-! ## Section 2: General Beyond-Dumas Mod-16 Irreducibility Criterion -/ /-- The binary power-sum polynomial $\sum_{j=0}^{r} X^{2^j}$ in $R[X]$. -/ noncomputable def powTwoSumPoly (R : Type*) [Semiring R] (r : ℕ) : R[X] := ∑ j ∈ Finset.range (r + 1), (X : R[X]) ^ (2 ^ j) lemma coeff_powTwoSumPoly {R : Type*} [Semiring R] (r k : ℕ) : (powTwoSumPoly R r).coeff k = if ∃ j ≤ r, k = 2 ^ j then 1 else 0 := by unfold powTwoSumPoly rw [Polynomial.finsetSum_coeff] simp only [Polynomial.coeff_X_pow] by_cases hex : ∃ j ≤ r, k = 2 ^ j · rw [if_pos hex] obtain ⟨j, hjr, hjk⟩ := hex rw [Finset.sum_eq_single j] · simp [hjk] · intro b _ hbj refine if_neg ?_ intro hbk have : 2 ^ b = 2 ^ j := by omega exact hbj (Nat.pow_right_injective (by norm_num) this) · intro hj; exact absurd (Finset.mem_range.mpr (Nat.lt_succ_of_le hjr)) hj · rw [if_neg hex] refine Finset.sum_eq_zero fun b hb => ?_ refine if_neg fun hbk => hex ⟨b, Nat.lt_succ_iff.mp (Finset.mem_range.mp hb), hbk⟩ /-- **Beyond-Dumas 2-adic Mod-16 Irreducibility Criterion**: Let $r \ge 2$, $n = 2^r$, and $f \in \mathbb{Z}[X]$ have degree $n$, $f(0) = 1$, $4 \mid f_k$ for all $1 \le k \le n$, and $$\frac{f_k}{4} \equiv \begin{cases} 1 \pmod 4 & \text{if } k = 2^j \; (0 \le j \le r), \\ 0 \pmod 4 & \text{otherwise.} \end{cases}$$ Then $f$ is irreducible in $\mathbb{Z}[X]$ (and hence in $\mathbb{Q}[X]$). Notice that the $2$-adic Newton polygon of $f$ is a single segment $(0, 0) \to (2^r, 2)$ of slope $1 / 2^{r-1}$, so Dumas's criterion alone leaves open a $2^{r-1} + 2^{r-1}$ factorization. Our exact mod-16 polynomial identity eliminates this factorization unconditionally. -/ theorem irreducible_of_mod16_two_pow {r : ℕ} (hr : 2 ≤ r) {f : ℤ[X]} (hdeg : f.natDegree = 2 ^ r) (h0 : f.coeff 0 = 1) (h4 : ∀ k, 1 ≤ k → (4 : ℤ) ∣ f.coeff k) (hmod : ∀ k, 1 ≤ k → k ≤ 2 ^ r → (f.coeff k / 4 : ℤ) ≡ (if ∃ j ≤ r, k = 2 ^ j then 1 else 0) [ZMOD 4]) : Irreducible f := by have hprim : f.IsPrimitive := isPrimitive_of_coeff_zero_eq_one h0 have hf_ne : f ≠ 0 := by intro h; rw [h, Polynomial.coeff_zero] at h0; norm_num at h0 -- A primitive polynomial in ℤ[X] is irreducible if it has no factorization into non-units. refine ⟨?_, ?_⟩ · -- f is not a unit since natDegree f = 2^r ≥ 4 > 0 intro hu have hdeg0 : f.natDegree = 0 := Polynomial.natDegree_eq_zero_of_isUnit hu have hpos : 0 < 2 ^ r := by positivity omega · intro A B hAB by_contra hnot push Not at hnot obtain ⟨hA_nu, hB_nu⟩ := hnot have hA_ne : A ≠ 0 := fun h => hf_ne (by rw [hAB, h, zero_mul]) have hB_ne : B ≠ 0 := fun h => hf_ne (by rw [hAB, h, mul_zero]) -- Neither A nor B is a constant (since f is primitive) have hA_deg_pos : 0 < A.natDegree := by by_contra h0A have hA0 : A.natDegree = 0 := by omega have hAeq : A = C (A.coeff 0) := Polynomial.eq_C_of_natDegree_eq_zero hA0 have hdvd : A.coeff 0 ∣ f.coeff 0 := by refine ⟨B.coeff 0, ?_⟩ rw [hAB, Polynomial.mul_coeff_zero] rw [h0] at hdvd have huA : IsUnit (A.coeff 0) := isUnit_of_dvd_one hdvd exact hA_nu (hAeq ▸ Polynomial.isUnit_C.mpr huA) have hB_deg_pos : 0 < B.natDegree := by by_contra h0B have hB0 : B.natDegree = 0 := by omega have hBeq : B = C (B.coeff 0) := Polynomial.eq_C_of_natDegree_eq_zero hB0 have hdvd : B.coeff 0 ∣ f.coeff 0 := by refine ⟨A.coeff 0, ?_⟩ rw [hAB, Polynomial.mul_coeff_zero, mul_comm] rw [h0] at hdvd have huB : IsUnit (B.coeff 0) := isUnit_of_dvd_one hdvd exact hB_nu (hBeq ▸ Polynomial.isUnit_C.mpr huB) have hdeg_sum : A.natDegree + B.natDegree = 2 ^ r := by rw [← Polynomial.natDegree_mul hA_ne hB_ne, ← hAB, hdeg] -- Normalize constant terms to +1 (replacing (A, B) by (-A, -B) if both are -1) have hAB0 : A.coeff 0 * B.coeff 0 = 1 := by rw [← Polynomial.mul_coeff_zero, ← hAB, h0] have hA0_pm : A.coeff 0 = 1 ∨ A.coeff 0 = -1 := Int.eq_one_or_neg_one_of_mul_eq_one hAB0 -- Work with normalized A', B' having coeff 0 = 1 let sgn : ℤ := A.coeff 0 have hsgn_sq : sgn * sgn = 1 := by rcases hA0_pm with h | h <;> simp [sgn, h] let A' : ℤ[X] := C sgn * A let B' : ℤ[X] := C sgn * B have hA'B' : f = A' * B' := by dsimp [A', B'] rw [show C sgn * A * (C sgn * B) = C (sgn * sgn) * (A * B) by rw [map_mul]; ring, hsgn_sq, map_one, one_mul, hAB] have hA'0 : A'.coeff 0 = 1 := by dsimp [A']; rw [Polynomial.coeff_C_mul]; exact hsgn_sq have hB'0 : B'.coeff 0 = 1 := by dsimp [B']; rw [Polynomial.coeff_C_mul]; exact hAB0 have hA'_deg : A'.natDegree = A.natDegree := by dsimp [A']; rw [Polynomial.natDegree_C_mul (by rcases hA0_pm with h | h <;> simp [sgn, h])] have hB'_deg : B'.natDegree = B.natDegree := by dsimp [B']; rw [Polynomial.natDegree_C_mul (by rcases hA0_pm with h | h <;> simp [sgn, h])] have hA'_ne : A' ≠ 0 := by intro h; rw [h, zero_mul] at hA'B'; exact hf_ne hA'B' have hB'_ne : B' ≠ 0 := by intro h; rw [h, mul_zero] at hA'B'; exact hf_ne hA'B' -- Step 1: Reduce f = A' * B' mod 2 -> A' ≡ 1 and B' ≡ 1 (mod 2) have hf_mod2 : f.map (Int.castRingHom (ZMod 2)) = 1 := by ext k rw [Polynomial.coeff_map, Polynomial.coeff_one] rcases k with _ | k · simp [h0] · rw [if_neg (Nat.succ_ne_zero k)] have h2 : (2 : ℤ) ∣ f.coeff (k + 1) := dvd_trans (by decide) (h4 (k + 1) (Nat.succ_pos k)) exact (ZMod.intCast_zmod_eq_zero_iff_dvd _ 2).mpr h2 have hprod_mod2 : A'.map (Int.castRingHom (ZMod 2)) * B'.map (Int.castRingHom (ZMod 2)) = 1 := by rw [← Polynomial.map_mul, ← hA'B', hf_mod2] have hA'_mod2 : A'.map (Int.castRingHom (ZMod 2)) = 1 := by have hu : IsUnit (A'.map (Int.castRingHom (ZMod 2))) := isUnit_iff_exists_inv.mpr ⟨_, hprod_mod2⟩ have hdeg0 : (A'.map (Int.castRingHom (ZMod 2))).natDegree = 0 := Polynomial.natDegree_eq_zero_of_isUnit hu rw [Polynomial.eq_C_of_natDegree_eq_zero hdeg0, Polynomial.coeff_map, hA'0] simp have hB'_mod2 : B'.map (Int.castRingHom (ZMod 2)) = 1 := by rw [hA'_mod2, one_mul] at hprod_mod2; exact hprod_mod2 -- Hence A' = 1 + 2 * A1 and B' = 1 + 2 * B1 with A1(0) = B1(0) = 0 have h2_A' : ∀ k ≥ 1, (2 : ℤ) ∣ A'.coeff k := by intro k hk have h := congrArg (fun P => P.coeff k) hA'_mod2 rw [Polynomial.coeff_map, Polynomial.coeff_one, if_neg (by omega)] at h exact (ZMod.intCast_zmod_eq_zero_iff_dvd _ 2).mp h have h2_B' : ∀ k ≥ 1, (2 : ℤ) ∣ B'.coeff k := by intro k hk have h := congrArg (fun P => P.coeff k) hB'_mod2 rw [Polynomial.coeff_map, Polynomial.coeff_one, if_neg (by omega)] at h exact (ZMod.intCast_zmod_eq_zero_iff_dvd _ 2).mp h let A1 : ℤ[X] := ∑ k ∈ Finset.range (A'.natDegree + 1), C ((A'.coeff k) / 2) * X ^ k let B1 : ℤ[X] := ∑ k ∈ Finset.range (B'.natDegree + 1), C ((B'.coeff k) / 2) * X ^ k have hA1_coeff : ∀ k, A1.coeff k = if k ≤ A'.natDegree then A'.coeff k / 2 else 0 := coeff_sum_C_mul_X_pow (fun j => A'.coeff j / 2) A'.natDegree have hB1_coeff : ∀ k, B1.coeff k = if k ≤ B'.natDegree then B'.coeff k / 2 else 0 := coeff_sum_C_mul_X_pow (fun j => B'.coeff j / 2) B'.natDegree have hA1_zero : A1.coeff 0 = 0 := by rw [hA1_coeff, if_pos (Nat.zero_le _), hA'0]; rfl have hB1_zero : B1.coeff 0 = 0 := by rw [hB1_coeff, if_pos (Nat.zero_le _), hB'0]; rfl have hA'_eq : A' = 1 + C 2 * A1 := by ext k simp only [Polynomial.coeff_add, Polynomial.coeff_one, Polynomial.coeff_C_mul, hA1_coeff] rcases k with _ | k · simp [hA'0] · rw [if_neg (Nat.succ_ne_zero k), zero_add] split_ifs with hk · exact (Int.mul_ediv_cancel' (h2_A' (k + 1) (Nat.succ_pos k))).symm · rw [mul_zero]; exact Polynomial.coeff_eq_zero_of_natDegree_lt (by omega) have hB'_eq : B' = 1 + C 2 * B1 := by ext k simp only [Polynomial.coeff_add, Polynomial.coeff_one, Polynomial.coeff_C_mul, hB1_coeff] rcases k with _ | k · simp [hB'0] · rw [if_neg (Nat.succ_ne_zero k), zero_add] split_ifs with hk · exact (Int.mul_ediv_cancel' (h2_B' (k + 1) (Nat.succ_pos k))).symm · rw [mul_zero]; exact Polynomial.coeff_eq_zero_of_natDegree_lt (by omega) -- Step 2: Reduce f = (1 + 2 A1)(1 + 2 B1) mod 4 -> A1 + B1 ≡ 0 (mod 2) have hAB1_even : ∀ k, (2 : ℤ) ∣ (A1.coeff k + B1.coeff k) := by intro k rcases k with _ | k · rw [hA1_zero, hB1_zero, add_zero]; exact dvd_zero 2 · have hfk : f.coeff (k + 1) = 2 * (A1.coeff (k + 1) + B1.coeff (k + 1)) + 4 * (A1 * B1).coeff (k + 1) := by have h := congrArg (fun P => P.coeff (k + 1)) hA'B' rw [hA'_eq, hB'_eq] at h have hexp : (1 + C (2 : ℤ) * A1) * (1 + C 2 * B1) = 1 + C 2 * (A1 + B1) + C 4 * (A1 * B1) := by have h4C : (C (4 : ℤ) : ℤ[X]) = C 2 * C 2 := by rw [← map_mul]; norm_num rw [h4C]; ring rw [hexp, Polynomial.coeff_add, Polynomial.coeff_add, Polynomial.coeff_one, if_neg (Nat.succ_ne_zero k), zero_add, Polynomial.coeff_C_mul, Polynomial.coeff_add, Polynomial.coeff_C_mul] at h exact h have h4k := h4 (k + 1) (Nat.succ_pos k) rw [hfk] at h4k have h4sum : (4 : ℤ) ∣ 2 * (A1.coeff (k + 1) + B1.coeff (k + 1)) := by have := dvd_sub h4k (dvd_mul_right 4 ((A1 * B1).coeff (k + 1))) simpa using this obtain ⟨t, ht⟩ := h4sum exact ⟨t, by omega⟩ -- Step 3: Leading coeffs of A1 and B1 are odd, hence A'.natDegree = B'.natDegree = 2^{r-1} have hf_top_mod4 : (f.coeff (2 ^ r) / 4 : ℤ) ≡ 1 [ZMOD 4] := by have h := hmod (2 ^ r) Nat.one_le_two_pow le_rfl rwa [if_pos ⟨r, le_rfl, rfl⟩] at h have hf_top_odd : ¬ (2 : ℤ) ∣ (f.coeff (2 ^ r) / 4) := by intro hd have h2 := hf_top_mod4.of_dvd (by decide : (2 : ℤ) ∣ 4) have h0' : (f.coeff (2 ^ r) / 4 : ℤ) ≡ 0 [ZMOD 2] := Int.modEq_zero_iff_dvd.mpr hd have : (0 : ℤ) ≡ 1 [ZMOD 2] := h0'.symm.trans h2 norm_num [Int.ModEq] at this have hlead_mul : A1.coeff A'.natDegree * B1.coeff B'.natDegree = f.coeff (2 ^ r) / 4 := by have hlead : f.coeff (2 ^ r) = A'.coeff A'.natDegree * B'.coeff B'.natDegree := by rw [show (2 ^ r : ℕ) = A'.natDegree + B'.natDegree by omega, hA'B'] exact coeff_mul_of_natDegree_le le_rfl le_rfl have hA'top : A'.coeff A'.natDegree = 2 * A1.coeff A'.natDegree := by rw [hA1_coeff, if_pos le_rfl] exact (Int.mul_ediv_cancel' (h2_A' A'.natDegree (by omega))).symm have hB'top : B'.coeff B'.natDegree = 2 * B1.coeff B'.natDegree := by rw [hB1_coeff, if_pos le_rfl] exact (Int.mul_ediv_cancel' (h2_B' B'.natDegree (by omega))).symm rw [hA'top, hB'top] at hlead have : f.coeff (2 ^ r) = 4 * (A1.coeff A'.natDegree * B1.coeff B'.natDegree) := by rw [hlead]; ring rw [this, Int.mul_ediv_cancel_left _ (by norm_num)] have hA1_top_odd : ¬ (2 : ℤ) ∣ A1.coeff A'.natDegree := by intro h2A exact hf_top_odd (hlead_mul ▸ dvd_mul_of_dvd_left h2A _) have hB1_top_odd : ¬ (2 : ℤ) ∣ B1.coeff B'.natDegree := by intro h2B exact hf_top_odd (hlead_mul ▸ dvd_mul_of_dvd_right h2B _) have hdeg_eq : A'.natDegree = B'.natDegree := by by_contra hne rcases lt_or_gt_of_ne hne with hlt | hgt · have hzero : A1.coeff B'.natDegree = 0 := by rw [hA1_coeff, if_neg (by omega)] have h2 := hAB1_even B'.natDegree rw [hzero, zero_add] at h2 exact hB1_top_odd h2 · have hzero : B1.coeff A'.natDegree = 0 := by rw [hB1_coeff, if_neg (by omega)] have h2 := hAB1_even A'.natDegree rw [hzero, add_zero] at h2 exact hA1_top_odd h2 -- Set d = 2^{r-1} ≥ 2 set d : ℕ := 2 ^ (r - 1) with hd_def have hd_two : 2 * d = 2 ^ r := by rw [hd_def, ← pow_succ', Nat.sub_add_cancel (by omega)] have hd_ge2 : 2 ≤ d := by have h1 : 1 ≤ r - 1 := by omega calc 2 = 2 ^ 1 := by norm_num _ ≤ 2 ^ (r - 1) := Nat.pow_le_pow_right (by norm_num) h1 have hd_even : 2 ∣ d := by rw [hd_def]; exact dvd_pow_self 2 (by omega) have hA'_deg_eq : A'.natDegree = d := by omega have hB'_deg_eq : B'.natDegree = d := by omega -- Step 4: Define S = (A1 + B1)/2 of degree ≤ d, so (f - 1)/4 = S - A1^2 + 2 A1 S let S : ℤ[X] := ∑ k ∈ Finset.range (d + 1), C ((A1.coeff k + B1.coeff k) / 2) * X ^ k have hS_coeff : ∀ k, S.coeff k = if k ≤ d then (A1.coeff k + B1.coeff k) / 2 else 0 := coeff_sum_C_mul_X_pow (fun j => (A1.coeff j + B1.coeff j) / 2) d have hS_deg : S.natDegree ≤ d := by refine Polynomial.natDegree_le_iff_coeff_eq_zero.mpr fun m hm => ?_ rw [hS_coeff, if_neg (by omega)] have hA1_deg : A1.natDegree ≤ d := by refine Polynomial.natDegree_le_iff_coeff_eq_zero.mpr fun m hm => ?_ rw [hA1_coeff, if_neg (by omega)] have hB1_eq : B1 = C 2 * S - A1 := by ext k rw [Polynomial.coeff_sub, Polynomial.coeff_C_mul, hS_coeff] by_cases hkd : k ≤ d · rw [if_pos hkd, Int.mul_ediv_cancel' (hAB1_even k)]; ring · rw [if_neg hkd, mul_zero, zero_sub, hA1_coeff, hB1_coeff, if_neg (by omega), if_neg (by omega), neg_zero] -- Define F = (f - 1)/4 as a polynomial in ℤ[X] let F : ℤ[X] := ∑ k ∈ Finset.range (2 ^ r + 1), C (if k = 0 then 0 else f.coeff k / 4) * X ^ k have hF_coeff : ∀ k, F.coeff k = if k ≤ 2 ^ r then (if k = 0 then 0 else f.coeff k / 4) else 0 := coeff_sum_C_mul_X_pow (fun j => if j = 0 then 0 else f.coeff j / 4) (2 ^ r) have hF_eq : F = S - A1 ^ 2 + C 2 * A1 * S := by have hf_ident : f = 1 + C 4 * (S - A1 ^ 2 + C 2 * A1 * S) := by rw [hA'B', hA'_eq, hB'_eq, hB1_eq] have h4C : (C (4 : ℤ) : ℤ[X]) = C 2 * C 2 := by rw [← map_mul]; norm_num rw [h4C]; ring ext k rw [hF_coeff] rcases k with _ | k · rw [if_pos (Nat.zero_le _), if_pos rfl] have h := congrArg (fun P => P.coeff 0) hf_ident rw [h0, Polynomial.coeff_add, Polynomial.coeff_one, if_pos rfl, Polynomial.coeff_C_mul] at h omega · by_cases hk : k + 1 ≤ 2 ^ r · rw [if_pos hk, if_neg (Nat.succ_ne_zero k)] have h := congrArg (fun P => P.coeff (k + 1)) hf_ident rw [Polynomial.coeff_add, Polynomial.coeff_one, if_neg (Nat.succ_ne_zero k), zero_add, Polynomial.coeff_C_mul] at h rw [h, Int.mul_ediv_cancel_left _ (by norm_num)] · rw [if_neg hk] have h := congrArg (fun P => P.coeff (k + 1)) hf_ident have hf0 : f.coeff (k + 1) = 0 := Polynomial.coeff_eq_zero_of_natDegree_lt (by omega) rw [hf0, Polynomial.coeff_add, Polynomial.coeff_one, if_neg (Nat.succ_ne_zero k), zero_add, Polynomial.coeff_C_mul] at h omega -- Step 5: F ≡ ∑_{j=0}^r X^{2^j} (mod 4), hence also mod 2 have hF_mod4 : F.map (Int.castRingHom (ZMod 4)) = powTwoSumPoly (ZMod 4) r := by ext k rw [Polynomial.coeff_map, hF_coeff, coeff_powTwoSumPoly] rcases k with _ | k · simp only [Nat.zero_le, ↓reduceIte, map_zero] rw [if_neg] rintro ⟨j, _, hj⟩ exact absurd hj (by positivity) · by_cases hk : k + 1 ≤ 2 ^ r · rw [if_pos hk, if_neg (Nat.succ_ne_zero k)] have hm := hmod (k + 1) (Nat.succ_pos k) hk have hz := (ZMod.intCast_eq_intCast_iff _ _ 4).mpr hm split_ifs at hz ⊢ <;> simpa using hz · rw [if_neg hk, map_zero, if_neg] rintro ⟨j, hjr, hjk⟩ have : 2 ^ j ≤ 2 ^ r := Nat.pow_le_pow_right (by norm_num) hjr omega have hF_mod2 : F.map (Int.castRingHom (ZMod 2)) = powTwoSumPoly (ZMod 2) r := by ext k rw [Polynomial.coeff_map, hF_coeff, coeff_powTwoSumPoly] rcases k with _ | k · simp only [Nat.zero_le, ↓reduceIte, map_zero] rw [if_neg] rintro ⟨j, _, hj⟩ exact absurd hj (by positivity) · by_cases hk : k + 1 ≤ 2 ^ r · rw [if_pos hk, if_neg (Nat.succ_ne_zero k)] have hm := (hmod (k + 1) (Nat.succ_pos k) hk).of_dvd (by decide : (2 : ℤ) ∣ 4) have hz := (ZMod.intCast_eq_intCast_iff _ _ 2).mpr hm split_ifs at hz ⊢ <;> simpa using hz · rw [if_neg hk, map_zero, if_neg] rintro ⟨j, hjr, hjk⟩ have : 2 ^ j ≤ 2 ^ r := Nat.pow_le_pow_right (by norm_num) hjr omega -- Step 6: Extract mod-2 structure of A1 and S let a2 : (ZMod 2)[X] := A1.map (Int.castRingHom (ZMod 2)) let s2 : (ZMod 2)[X] := S.map (Int.castRingHom (ZMod 2)) have hmod2_eq : s2 + a2 ^ 2 = powTwoSumPoly (ZMod 2) r := by have h := congrArg (Polynomial.map (Int.castRingHom (ZMod 2))) hF_eq rw [hF_mod2, Polynomial.map_add, Polynomial.map_sub, Polynomial.map_pow, Polynomial.map_mul, Polynomial.map_mul, Polynomial.map_C] at h have h2z : (Int.castRingHom (ZMod 2)) 2 = 0 := by decide rw [h2z, map_zero, zero_mul, zero_mul, add_zero] at h have hneg : s2 - a2 ^ 2 = s2 + a2 ^ 2 := by rw [sub_eq_add_neg]; congr 1 ext k; simp only [Polynomial.coeff_neg] have : ∀ x : ZMod 2, -x = x := by decide exact this _ rw [← hneg]; exact h.symm -- In (ZMod 2)[X], p^2 = expand 2 p, so (p^2).coeff (2*m) = p.coeff m and (p^2).coeff (2*m+1) = 0 have hsq_zmod2 : ∀ p : (ZMod 2)[X], (∀ m, (p ^ 2).coeff (2 * m) = p.coeff m) ∧ (∀ m, (p ^ 2).coeff (2 * m + 1) = 0) := by intro p have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ have hsq : p ^ 2 = Polynomial.expand (ZMod 2) 2 p := by induction p using Polynomial.induction_on' with | add f g hf hg => rw [add_pow_char, hf, hg, map_add] | monomial n c => rw [Polynomial.expand_monomial, Polynomial.monomial_pow] have hc : c ^ 2 = c := by have : ∀ x : ZMod 2, x ^ 2 = x := by intro x; fin_cases x <;> rfl exact this c rw [hc, mul_comm n 2] rw [hsq] refine ⟨fun m => ?_, fun m => ?_⟩ · rw [Polynomial.coeff_expand (by norm_num : 0 < 2)] simp [Nat.mul_div_right _ (by norm_num : 0 < 2)] · rw [Polynomial.coeff_expand (by norm_num : 0 < 2)] have : ¬ (2 ∣ 2 * m + 1) := by omega simp [this] have ha2_sq_even := (hsq_zmod2 a2).1 have ha2_sq_odd := (hsq_zmod2 a2).2 -- 6a. a2.coeff d = 1 have ha2_d : a2.coeff d = 1 := by dsimp [a2] rw [Polynomial.coeff_map, ← hA'_deg_eq] have hnz : (Int.castRingHom (ZMod 2)) (A1.coeff A'.natDegree) ≠ 0 := by intro h0z exact hA1_top_odd ((ZMod.intCast_zmod_eq_zero_iff_dvd _ 2).mp h0z) generalize (Int.castRingHom (ZMod 2)) (A1.coeff A'.natDegree) = x at hnz ⊢ revert x hnz; decide -- 6b. For d/2 < m < d, a2.coeff m = 0 have ha2_mid : ∀ m, d / 2 < m → m < d → a2.coeff m = 0 := by intro m hml hmu have h := congrArg (fun P => P.coeff (2 * m)) hmod2_eq rw [Polynomial.coeff_add, ha2_sq_even, coeff_powTwoSumPoly] at h have hs0 : s2.coeff (2 * m) = 0 := by dsimp [s2]; rw [Polynomial.coeff_map, hS_coeff, if_neg (by omega), map_zero] have hnp : ¬ ∃ j ≤ r, 2 * m = 2 ^ j := by rintro ⟨j, hjr, hjeq⟩ have hlt1 : 2 ^ (r - 1) < 2 ^ j := by omega have hlt2 : 2 ^ j < 2 ^ r := by omega have hj1 : r - 1 < j := (Nat.pow_lt_pow_iff_right (by norm_num : 1 < 2)).mp hlt1 have hj2 : j < r := (Nat.pow_lt_pow_iff_right (by norm_num : 1 < 2)).mp hlt2 omega rw [hs0, zero_add, if_neg hnp] at h exact h -- 6c. From [X^(2^r)] of F mod 4, deduce s2.coeff d = 1 have hs2_d : s2.coeff d = 1 := by have h := congrArg (fun P => P.coeff (2 ^ r)) hF_eq have hS0 : S.coeff (2 ^ r) = 0 := by rw [hS_coeff, if_neg (by omega)] have hA1sq : (A1 ^ 2).coeff (2 ^ r) = A1.coeff d * A1.coeff d := by rw [sq, ← hd_two, two_mul] exact coeff_mul_of_natDegree_le hA1_deg hA1_deg have hA1S : (A1 * S).coeff (2 ^ r) = A1.coeff d * S.coeff d := by rw [← hd_two, two_mul] exact coeff_mul_of_natDegree_le hA1_deg hS_deg rw [Polynomial.coeff_add, Polynomial.coeff_sub, hS0, zero_sub, hA1sq, mul_assoc, Polynomial.coeff_C_mul, hA1S] at h have hz4 : ((F.coeff (2 ^ r) : ℤ) : ZMod 4) = 1 := by have hm := congrArg (fun P => P.coeff (2 ^ r)) hF_mod4 rw [Polynomial.coeff_map, coeff_powTwoSumPoly, if_pos ⟨r, le_rfl, rfl⟩] at hm exact hm have h4eq : (1 : ZMod 4) = -(((A1.coeff d : ℤ) : ZMod 4) * ((A1.coeff d : ℤ) : ZMod 4)) + 2 * ((A1.coeff d : ℤ) : ZMod 4) * ((S.coeff d : ℤ) : ZMod 4) := by rw [← hz4, h]; push_cast; ring have hAd_odd : ((A1.coeff d : ℤ) : ZMod 4) = 1 ∨ ((A1.coeff d : ℤ) : ZMod 4) = 3 := by have hnd : ¬ (2 : ℤ) ∣ A1.coeff d := hA'_deg_eq ▸ hA1_top_odd have hne0 : ((A1.coeff d : ℤ) : ZMod 4) ≠ 0 := by intro h0z exact hnd (dvd_trans (by decide : (2 : ℤ) ∣ 4) ((ZMod.intCast_zmod_eq_zero_iff_dvd _ 4).mp h0z)) have hne2 : ((A1.coeff d : ℤ) : ZMod 4) ≠ 2 := by intro h2z have hsub : ((A1.coeff d - 2 : ℤ) : ZMod 4) = 0 := by push_cast; rw [h2z]; decide have hd4 : (4 : ℤ) ∣ A1.coeff d - 2 := (ZMod.intCast_zmod_eq_zero_iff_dvd _ 4).mp hsub obtain ⟨t, ht⟩ := hd4 exact hnd ⟨2 * t + 1, by omega⟩ generalize ((A1.coeff d : ℤ) : ZMod 4) = x at hne0 hne2 ⊢ revert x hne0 hne2; decide have hSd_odd : ((S.coeff d : ℤ) : ZMod 4) = 1 ∨ ((S.coeff d : ℤ) : ZMod 4) = 3 := by rcases hAd_odd with h1 | h3 · rw [h1] at h4eq generalize ((S.coeff d : ℤ) : ZMod 4) = y at h4eq ⊢ revert y h4eq; decide · rw [h3] at h4eq generalize ((S.coeff d : ℤ) : ZMod 4) = y at h4eq ⊢ revert y h4eq; decide have hSd_ndvd : ¬ (2 : ℤ) ∣ S.coeff d := by intro hd2 obtain ⟨t, ht⟩ := hd2 have hev : ((S.coeff d : ℤ) : ZMod 4) = 0 ∨ ((S.coeff d : ℤ) : ZMod 4) = 2 := by rw [ht]; push_cast generalize (t : ZMod 4) = z; revert z; decide rcases hSd_odd with h1 | h3 · rcases hev with h0' | h2' · rw [h1] at h0'; exact absurd h0' (by decide) · rw [h1] at h2'; exact absurd h2' (by decide) · rcases hev with h0' | h2' · rw [h3] at h0'; exact absurd h0' (by decide) · rw [h3] at h2'; exact absurd h2' (by decide) dsimp [s2]; rw [Polynomial.coeff_map] have hnz : (Int.castRingHom (ZMod 2)) (S.coeff d) ≠ 0 := fun h0z => hSd_ndvd ((ZMod.intCast_zmod_eq_zero_iff_dvd _ 2).mp h0z) generalize (Int.castRingHom (ZMod 2)) (S.coeff d) = y at hnz ⊢ revert y hnz; decide -- 6d. From [X^d] of hmod2_eq, deduce a2.coeff (d / 2) = 0 have ha2_half : a2.coeff (d / 2) = 0 := by have h := congrArg (fun P => P.coeff d) hmod2_eq have hd2 : d = 2 * (d / 2) := by obtain ⟨t, ht⟩ := hd_even; omega rw [Polynomial.coeff_add, hs2_d, coeff_powTwoSumPoly, if_pos ⟨r - 1, Nat.sub_le r 1, hd_def⟩] at h conv_lhs at h => rw [hd2, ha2_sq_even] generalize a2.coeff (d / 2) = x at h ⊢ revert x h; decide -- 6e. From [X^1] of hmod2_eq, deduce s2.coeff 1 = 1 have hs2_one : s2.coeff 1 = 1 := by have h := congrArg (fun P => P.coeff 1) hmod2_eq rw [Polynomial.coeff_add, coeff_powTwoSumPoly, if_pos ⟨0, Nat.zero_le r, by norm_num⟩] at h have h1odd : (a2 ^ 2).coeff 1 = 0 := by simpa using ha2_sq_odd 0 rw [h1odd, add_zero] at h exact h -- Step 7: Lift mod-2 parts to U (deg < d/2) and V (1 ≤ deg < d), and get contradiction mod 4! let U : ℤ[X] := ∑ k ∈ Finset.range (d / 2), C (if a2.coeff k = 0 then (0 : ℤ) else 1) * X ^ k let V : ℤ[X] := ∑ k ∈ Finset.range d, C (if s2.coeff k = 0 then (0 : ℤ) else 1) * X ^ k have hU_coeff : ∀ k, U.coeff k = if k < d / 2 then (if a2.coeff k = 0 then 0 else 1) else 0 := by intro k have hd2pos : 1 ≤ d / 2 := by omega have h := coeff_sum_C_mul_X_pow (fun j => if a2.coeff j = 0 then (0 : ℤ) else 1) (d / 2 - 1) k rw [Nat.sub_add_cancel hd2pos] at h change U.coeff k = _ rw [h] split_ifs <;> first | rfl | omega have hV_coeff : ∀ k, V.coeff k = if k < d then (if s2.coeff k = 0 then 0 else 1) else 0 := by intro k have h := coeff_sum_C_mul_X_pow (fun j => if s2.coeff j = 0 then (0 : ℤ) else 1) (d - 1) k rw [Nat.sub_add_cancel (by omega : 1 ≤ d)] at h change V.coeff k = _ rw [h] split_ifs <;> first | rfl | omega -- A1 ≡ X^d + U (mod 2) and S ≡ X^d + V (mod 2) have hA1_lift : ∃ Q1 : ℤ[X], A1 = (X ^ d + U) + C 2 * Q1 := by have hdiff_even : ∀ k, (2 : ℤ) ∣ (A1 - (X ^ d + U)).coeff k := by intro k refine (ZMod.intCast_zmod_eq_zero_iff_dvd _ 2).mp ?_ rw [Polynomial.coeff_sub, Polynomial.coeff_add, Polynomial.coeff_X_pow, hU_coeff] have ha2k : ((A1.coeff k : ℤ) : ZMod 2) = a2.coeff k := by dsimp [a2]; rw [Polynomial.coeff_map]; rfl push_cast rw [ha2k] by_cases hkd : k = d · subst hkd rw [if_pos rfl, if_neg (by omega), ha2_d]; decide · rw [if_neg hkd] by_cases hkl : k < d / 2 · rw [if_pos hkl] generalize a2.coeff k = x; revert x; decide · rw [if_neg hkl] have ha2z : a2.coeff k = 0 := by by_cases hkh : k = d / 2 · exact hkh ▸ ha2_half · by_cases hku : k < d · exact ha2_mid k (by omega) hku · dsimp [a2]; rw [Polynomial.coeff_map, hA1_coeff, if_neg (by omega), map_zero] rw [ha2z]; decide refine ⟨∑ k ∈ Finset.range (d + 1), C ((A1 - (X ^ d + U)).coeff k / 2) * X ^ k, ?_⟩ ext k simp only [Polynomial.coeff_add, Polynomial.coeff_C_mul, coeff_sum_C_mul_X_pow] by_cases hkd : k ≤ d · rw [if_pos hkd, Int.mul_ediv_cancel' (hdiff_even k), Polynomial.coeff_sub, Polynomial.coeff_add]; ring · rw [if_neg hkd, mul_zero, add_zero, Polynomial.coeff_X_pow, if_neg (by omega), hU_coeff, if_neg (by omega), add_zero, hA1_coeff, if_neg (by omega)] have hS_lift : ∃ Q2 : ℤ[X], S = (X ^ d + V) + C 2 * Q2 := by have hdiff_even : ∀ k, (2 : ℤ) ∣ (S - (X ^ d + V)).coeff k := by intro k refine (ZMod.intCast_zmod_eq_zero_iff_dvd _ 2).mp ?_ rw [Polynomial.coeff_sub, Polynomial.coeff_add, Polynomial.coeff_X_pow, hV_coeff] have hs2k : ((S.coeff k : ℤ) : ZMod 2) = s2.coeff k := by dsimp [s2]; rw [Polynomial.coeff_map]; rfl push_cast rw [hs2k] by_cases hkd : k = d · subst hkd rw [if_pos rfl, if_neg (by omega), hs2_d]; decide · rw [if_neg hkd] by_cases hkl : k < d · rw [if_pos hkl] generalize s2.coeff k = x; revert x; decide · rw [if_neg hkl] have hs2z : s2.coeff k = 0 := by dsimp [s2]; rw [Polynomial.coeff_map, hS_coeff, if_neg (by omega), map_zero] rw [hs2z]; decide refine ⟨∑ k ∈ Finset.range (d + 1), C ((S - (X ^ d + V)).coeff k / 2) * X ^ k, ?_⟩ ext k simp only [Polynomial.coeff_add, Polynomial.coeff_C_mul, coeff_sum_C_mul_X_pow] by_cases hkd : k ≤ d · rw [if_pos hkd, Int.mul_ediv_cancel' (hdiff_even k), Polynomial.coeff_sub, Polynomial.coeff_add]; ring · rw [if_neg hkd, mul_zero, add_zero, Polynomial.coeff_X_pow, if_neg (by omega), hV_coeff, if_neg (by omega), add_zero, hS_coeff, if_neg (by omega)] obtain ⟨Q1, hQ1⟩ := hA1_lift obtain ⟨Q2, hQ2⟩ := hS_lift -- Exact polynomial identity mod 4: F ≡ S + X^(2d) - U^2 + 2*(X^d + U)*V (mod 4) have hF_mod4_ident : F.map (Int.castRingHom (ZMod 4)) = (S + X ^ (2 * d) - U ^ 2 + C 2 * (X ^ d + U) * V).map (Int.castRingHom (ZMod 4)) := by have hexact : F = (S + X ^ (2 * d) - U ^ 2 + C 2 * (X ^ d + U) * V) + C 4 * (-(X ^ d + U) * Q1 - Q1 ^ 2 + (X ^ d + U) * Q2 + Q1 * (X ^ d + V) + C 2 * Q1 * Q2) := by have hF_split : F = S + (-A1 ^ 2 + C 2 * A1 * S) := by rw [hF_eq]; ring have hpart : -A1 ^ 2 + C 2 * A1 * S = (X ^ (2 * d) - U ^ 2 + C 2 * (X ^ d + U) * V) + C 4 * (-(X ^ d + U) * Q1 - Q1 ^ 2 + (X ^ d + U) * Q2 + Q1 * (X ^ d + V) + C 2 * Q1 * Q2) := by rw [hQ1, hQ2] have h4C : (C (4 : ℤ) : ℤ[X]) = 4 := by rw [map_ofNat] have h2C : (C (2 : ℤ) : ℤ[X]) = 2 := by rw [map_ofNat] have hX2 : (X : ℤ[X]) ^ (2 * d) = (X ^ d) ^ 2 := by rw [← pow_mul, mul_comm] rw [h4C, h2C, hX2] ring rw [hF_split, hpart]; ring rw [hexact, Polynomial.map_add, Polynomial.map_mul, Polynomial.map_C] have h4z : (Int.castRingHom (ZMod 4)) 4 = 0 := by decide rw [h4z, map_zero, zero_mul, add_zero] -- Step 8: V.coeff 1 = 1, so 1 ≤ V.natDegree < d; evaluate at k0 = d + V.natDegree! have hV_one : V.coeff 1 = 1 := by rw [hV_coeff, if_pos (by omega), hs2_one]; decide have hV_deg_pos : 1 ≤ V.natDegree := Polynomial.le_natDegree_of_ne_zero (by rw [hV_one]; norm_num) have hV_deg_lt : V.natDegree < d := by have hle : V.natDegree ≤ d - 1 := Polynomial.natDegree_le_iff_coeff_eq_zero.mpr fun m hm => by rw [hV_coeff, if_neg (by omega)] omega have hV_lead : V.coeff V.natDegree = 1 := by have hne : V.coeff V.natDegree ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr (by intro h0V; rw [h0V, Polynomial.coeff_zero] at hV_one; norm_num at hV_one) rw [hV_coeff, if_pos hV_deg_lt] at hne ⊢ split_ifs at hne ⊢ · exact absurd rfl hne · rfl set k0 : ℕ := d + V.natDegree with hk0_def have hk0_gt : d < k0 := by omega have hk0_lt : k0 < 2 * d := by omega -- LHS coeff at k0 is 0 in ZMod 4 (no power of 2 strictly between 2^(r-1) and 2^r) have hLHS : (F.map (Int.castRingHom (ZMod 4))).coeff k0 = 0 := by rw [hF_mod4, coeff_powTwoSumPoly, if_neg] rintro ⟨j, hjr, hjeq⟩ have h1 : 2 ^ (r - 1) < 2 ^ j := by omega have h2 : 2 ^ j < 2 ^ r := by omega have hj1 : r - 1 < j := (Nat.pow_lt_pow_iff_right (by norm_num : 1 < 2)).mp h1 have hj2 : j < r := (Nat.pow_lt_pow_iff_right (by norm_num : 1 < 2)).mp h2 omega -- RHS coeff at k0 is 2 in ZMod 4 have hS_k0 : S.coeff k0 = 0 := by rw [hS_coeff, if_neg (by omega)] have hX2d_k0 : (X ^ (2 * d) : ℤ[X]).coeff k0 = 0 := by rw [Polynomial.coeff_X_pow, if_neg (by omega)] have hU2_k0 : (U ^ 2).coeff k0 = 0 := by rw [sq, Polynomial.coeff_mul] refine Finset.sum_eq_zero fun x hx => ?_ have hsum : x.1 + x.2 = k0 := by simpa using hx by_cases hx1 : x.1 < d / 2 · have hx2 : ¬ (x.2 < d / 2) := by omega rw [hU_coeff x.2, if_neg hx2, mul_zero] · rw [hU_coeff x.1, if_neg hx1, zero_mul] have hUV_k0 : (U * V).coeff k0 = 0 := by rw [Polynomial.coeff_mul] refine Finset.sum_eq_zero fun x hx => ?_ have hsum : x.1 + x.2 = k0 := by simpa using hx by_cases hx1 : x.1 < d / 2 · have hx2 : V.natDegree < x.2 := by omega rw [Polynomial.coeff_eq_zero_of_natDegree_lt hx2, mul_zero] · rw [hU_coeff x.1, if_neg hx1, zero_mul] have hXdV_k0 : (X ^ d * V).coeff k0 = 1 := by rw [hk0_def, Polynomial.coeff_X_pow_mul', if_pos (Nat.le_add_right d _), Nat.add_sub_cancel_left, hV_lead] have hRHS : ((S + X ^ (2 * d) - U ^ 2 + C 2 * (X ^ d + U) * V).map (Int.castRingHom (ZMod 4))).coeff k0 = 2 := by rw [Polynomial.coeff_map] have hcoeff : (S + X ^ (2 * d) - U ^ 2 + C 2 * (X ^ d + U) * V).coeff k0 = 2 := by have hdist : C (2 : ℤ) * (X ^ d + U) * V = C 2 * (X ^ d * V + U * V) := by ring rw [hdist, Polynomial.coeff_add, Polynomial.coeff_sub, Polynomial.coeff_add, hS_k0, hX2d_k0, hU2_k0, Polynomial.coeff_C_mul, Polynomial.coeff_add, hXdV_k0, hUV_k0] ring rw [hcoeff]; decide rw [hF_mod4_ident] at hLHS rw [hRHS] at hLHS exact absurd hLHS (by decide) /-- **Theorem 1 (First Infinite Irreducibility Family for OEIS A115257)**: For every $r \ge 0$, $P_{2^r}(x) = \sum_{k=0}^{2^r} \binom{2k}{k}^2 x^k$ is irreducible over $\mathbb{Q}$. -/ theorem polyP_irreducible_two_pow (r : ℕ) : Irreducible (polyP (2 ^ r)) := by rw [← polyPInt_map_rat] rcases r with _ | _ | r' · -- r = 0: P_1(x) = 1 + 4x (degree 1) have hdeg : ((polyPInt 1).map (Int.castRingHom ℚ)).natDegree = 1 := by rw [Polynomial.natDegree_map_eq_of_injective Int.cast_injective, polyPInt_natDegree] have hne : (polyPInt 1).map (Int.castRingHom ℚ) ≠ 0 := fun h0 => by rw [h0, Polynomial.natDegree_zero] at hdeg; omega have hdeg1 : ((polyPInt 1).map (Int.castRingHom ℚ)).degree = 1 := by rw [Polynomial.degree_eq_natDegree hne, hdeg]; rfl exact Polynomial.irreducible_of_degree_eq_one hdeg1 · -- r = 1: P_2(x) = 1 + 4x + 36x^2 (discriminant -128 < 0, no rational roots) have hp2 : (polyPInt (2 ^ 1)).map (Int.castRingHom ℚ) = C (36 : ℚ) * X ^ 2 + C 4 * X + 1 := by rw [polyPInt_map_rat] unfold polyP simp only [Finset.sum_range_succ, Finset.range_zero, Finset.sum_empty, zero_add, pow_zero, pow_one, mul_one] have hcb0 : Nat.centralBinom 0 = 1 := rfl have hcb1 : Nat.centralBinom 1 = 2 := rfl have hcb2 : Nat.centralBinom 2 = 6 := rfl rw [hcb0, hcb1, hcb2] norm_num simp only [map_ofNat] ring rw [hp2] set P2 : ℚ[X] := C (36 : ℚ) * X ^ 2 + C 4 * X + 1 have hP2_deg : P2.natDegree = 2 := by refine Polynomial.natDegree_eq_of_le_of_coeff_ne_zero ?_ ?_ · refine Polynomial.natDegree_le_iff_coeff_eq_zero.mpr fun m hm => ?_ simp only [P2, Polynomial.coeff_add, Polynomial.coeff_C_mul, Polynomial.coeff_X_pow, Polynomial.coeff_X, Polynomial.coeff_one, if_neg (by omega : m ≠ 2), if_neg (by omega : 1 ≠ m), if_neg (by omega : m ≠ 0)] ring · simp [P2, Polynomial.coeff_one] have hP2_ne : P2 ≠ 0 := fun h => by rw [h, Polynomial.natDegree_zero] at hP2_deg; omega have hP2_no_root : ∀ x : ℚ, P2.eval x ≠ 0 := by intro x hx simp only [P2, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_pow, Polynomial.eval_X, Polynomial.eval_one] at hx nlinarith [sq_nonneg (6 * x + 1 / 3 : ℚ)] refine ⟨fun hu => by have := Polynomial.natDegree_eq_zero_of_isUnit hu; omega, fun u v huv => ?_⟩ have hu_ne : u ≠ 0 := fun h => hP2_ne (by rw [huv, h, zero_mul]) have hv_ne : v ≠ 0 := fun h => hP2_ne (by rw [huv, h, mul_zero]) have hsum : u.natDegree + v.natDegree = 2 := by rw [← Polynomial.natDegree_mul hu_ne hv_ne, ← huv, hP2_deg] by_cases hu0 : u.natDegree = 0 · left rw [Polynomial.eq_C_of_natDegree_eq_zero hu0] exact Polynomial.isUnit_C.mpr (isUnit_iff_ne_zero.mpr fun h0 => hu_ne (by rw [Polynomial.eq_C_of_natDegree_eq_zero hu0, h0, map_zero])) · by_cases hv0 : v.natDegree = 0 · right rw [Polynomial.eq_C_of_natDegree_eq_zero hv0] exact Polynomial.isUnit_C.mpr (isUnit_iff_ne_zero.mpr fun h0 => hv_ne (by rw [Polynomial.eq_C_of_natDegree_eq_zero hv0, h0, map_zero])) · exfalso have hu1 : u.natDegree = 1 := by omega have hroot : u.eval (-u.coeff 0 / u.coeff 1) = 0 := by have h1 : u = C (u.coeff 1) * X + C (u.coeff 0) := by ext k rcases k with _ | _ | k · simp · simp · simp [Polynomial.coeff_eq_zero_of_natDegree_lt (show u.natDegree < k + 2 by omega)] have hc1 : u.coeff 1 ≠ 0 := by rw [← hu1]; exact Polynomial.leadingCoeff_ne_zero.mpr hu_ne set r0 : ℚ := -u.coeff 0 / u.coeff 1 have hval : u.eval r0 = u.coeff 1 * r0 + u.coeff 0 := by conv_lhs => rw [h1] simp rw [hval] dsimp [r0] field_simp [hc1] ring have hP2r : P2.eval (-u.coeff 0 / u.coeff 1) = 0 := by rw [huv, Polynomial.eval_mul, hroot, zero_mul] exact hP2_no_root _ hP2r · -- r = r' + 2 ≥ 2: Apply our Beyond-Dumas Mod-16 Irreducibility Criterion! have hirrZ : Irreducible (polyPInt (2 ^ (r' + 2))) := by refine irreducible_of_mod16_two_pow (by omega : 2 ≤ r' + 2) (polyPInt_natDegree _) (polyPInt_coeff_zero _) ?_ ?_ · intro k hk rw [polyPInt_coeff] split_ifs · exact Int.natCast_dvd_natCast.mpr (four_dvd_pCoeff hk) · exact dvd_zero 4 · intro k hk1 hkle rw [polyPInt_coeff, if_pos hkle] by_cases hex : ∃ j ≤ r' + 2, k = 2 ^ j · rw [if_pos hex] obtain ⟨j, _, rfl⟩ := hex have h := pCoeff_two_pow_div_four_modEq j exact_mod_cast h · rw [if_neg hex] have hnot : ∀ j : ℕ, k ≠ 2 ^ j := by intro j hkj apply hex refine ⟨j, ?_, hkj⟩ by_contra hgt have hle' : 2 ^ (r' + 2) < 2 ^ j := Nat.pow_lt_pow_right (by norm_num : 1 < 2) (by omega) omega obtain ⟨m, hm⟩ := sixteen_dvd_pCoeff_of_not_pow_two hk1 hnot have hdiv : ((pCoeff k : ℤ) / 4) = 4 * (m : ℤ) := by rw [hm]; push_cast; omega rw [hdiv] exact Int.modEq_zero_iff_dvd.mpr ⟨m, rfl⟩ exact (Polynomial.IsPrimitive.Int.irreducible_iff_irreducible_map_cast (polyPInt_isPrimitive _)).mp hirrZ /-! ## Section 3: General Elementary Dumas Newton-Polygon Engine -/ section DumasEngine /-- Ultrametric property of `padicValInt`: if `p ^ v ∣ a` for every term of a finite sum, then `p ^ v ∣ ∑ a`. -/ lemma int_pow_dvd_sum {α : Type*} (s : Finset α) (f : α → ℤ) (d : ℤ) (h : ∀ x ∈ s, d ∣ f x) : d ∣ ∑ x ∈ s, f x := Finset.dvd_sum h /-- `padicValInt p` of a finite sum is at least `m` if every nonzero term has `padicValInt p ≥ m`. -/ lemma padicValInt_sum_ge {α : Type*} {p : ℕ} [Fact p.Prime] {s : Finset α} {f : α → ℤ} {m : ℕ} (hsum : ∑ x ∈ s, f x ≠ 0) (h : ∀ x ∈ s, f x ≠ 0 → m ≤ padicValInt p (f x)) : m ≤ padicValInt p (∑ x ∈ s, f x) := by have hdvd : ((p : ℤ) ^ m) ∣ ∑ x ∈ s, f x := by refine Finset.dvd_sum fun x hx => ?_ by_cases hfx : f x = 0 · rw [hfx]; exact dvd_zero _ · have hle := h x hx hfx have hnat : p ^ m ∣ (f x).natAbs := (padicValNat_dvd_iff_le (Int.natAbs_ne_zero.mpr hfx)).mpr hle exact Int.natCast_dvd.mpr (by simpa [Nat.cast_pow] using hnat) have hnat_sum : p ^ m ∣ (∑ x ∈ s, f x).natAbs := Int.natCast_dvd.mp (by rw [Nat.cast_pow]; exact hdvd) exact (padicValNat_dvd_iff_le (Int.natAbs_ne_zero.mpr hsum)).mp hnat_sum /-- Unique minimum-valuation term dominates a finite sum: if `x₀ ∈ s` has `f x₀ ≠ 0` and every other `x ∈ s` with `f x ≠ 0` has `padicValInt p (f x₀) < padicValInt p (f x)`, then `∑ x ∈ s, f x ≠ 0` and `padicValInt p (∑ x ∈ s, f x) = padicValInt p (f x₀)`. -/ lemma padicValInt_sum_eq_of_unique_min {α : Type*} [DecidableEq α] {p : ℕ} [Fact p.Prime] {s : Finset α} {f : α → ℤ} {x₀ : α} (hx₀ : x₀ ∈ s) (hfx₀ : f x₀ ≠ 0) (hstrict : ∀ x ∈ s, x ≠ x₀ → f x ≠ 0 → padicValInt p (f x₀) < padicValInt p (f x)) : ∑ x ∈ s, f x ≠ 0 ∧ padicValInt p (∑ x ∈ s, f x) = padicValInt p (f x₀) := by set m := padicValInt p (f x₀) with hm_def have hsplit : ∑ x ∈ s, f x = f x₀ + ∑ x ∈ s.erase x₀, f x := (Finset.add_sum_erase s f hx₀).symm have hrest_dvd : ((p : ℤ) ^ (m + 1)) ∣ ∑ x ∈ s.erase x₀, f x := by refine Finset.dvd_sum fun x hx => ?_ have hx_ne : x ≠ x₀ := (Finset.mem_erase.mp hx).1 have hx_in : x ∈ s := (Finset.mem_erase.mp hx).2 by_cases hfx : f x = 0 · rw [hfx]; exact dvd_zero _ · have hlt := hstrict x hx_in hx_ne hfx have hnat : p ^ (m + 1) ∣ (f x).natAbs := (padicValNat_dvd_iff_le (Int.natAbs_ne_zero.mpr hfx)).mpr hlt exact Int.natCast_dvd.mpr (by simpa [Nat.cast_pow] using hnat) have hx₀_ndvd : ¬ ((p : ℤ) ^ (m + 1)) ∣ f x₀ := by intro hd have hnat : p ^ (m + 1) ∣ (f x₀).natAbs := Int.natCast_dvd.mp (by simpa [Nat.cast_pow] using hd) have hle : m + 1 ≤ padicValInt p (f x₀) := (padicValNat_dvd_iff_le (Int.natAbs_ne_zero.mpr hfx₀)).mp hnat omega have hsum_ndvd : ¬ ((p : ℤ) ^ (m + 1)) ∣ ∑ x ∈ s, f x := by rw [hsplit] intro hd have := (dvd_add_left hrest_dvd).mp hd exact hx₀_ndvd this have hsum_ne : ∑ x ∈ s, f x ≠ 0 := by intro h0; exact hsum_ndvd (h0 ▸ dvd_zero _) have hge : m ≤ padicValInt p (∑ x ∈ s, f x) := by refine padicValInt_sum_ge hsum_ne fun x hx hfx => ?_ by_cases hxx : x = x₀ · rw [hxx] · exact Nat.le_of_lt (hstrict x hx hxx hfx) have hle : padicValInt p (∑ x ∈ s, f x) ≤ m := by by_contra hgt have hge1 : m + 1 ≤ padicValInt p (∑ x ∈ s, f x) := by omega have hnat : p ^ (m + 1) ∣ (∑ x ∈ s, f x).natAbs := (padicValNat_dvd_iff_le (Int.natAbs_ne_zero.mpr hsum_ne)).mpr hge1 exact hsum_ndvd (Int.natCast_dvd.mpr (by simpa [Nat.cast_pow] using hnat)) exact ⟨hsum_ne, le_antisymm hle hge⟩ /-- Weight function `w * v_p(g.coeff k) - h * k` used to extract the slope-`h/w` face of the `p`-adic Newton polygon of `g ∈ ℤ[X]`. -/ noncomputable def npWeight (p w : ℕ) (h : ℤ) (g : ℤ[X]) (k : ℕ) : ℤ := (w : ℤ) * (padicValInt p (g.coeff k) : ℤ) - h * (k : ℤ) /-- Minimum value of `npWeight p w h g` over `g.support` (0 if `g = 0`). -/ noncomputable def npMinVal (p w : ℕ) (h : ℤ) (g : ℤ[X]) : ℤ := if hg : g.support.Nonempty then (g.support.image (npWeight p w h g)).min' (hg.image _) else 0 /-- Support indices achieving `npMinVal p w h g`. -/ noncomputable def npAttain (p w : ℕ) (h : ℤ) (g : ℤ[X]) : Finset ℕ := g.support.filter fun k => npWeight p w h g k = npMinVal p w h g lemma npAttain_nonempty {p w : ℕ} {h : ℤ} {g : ℤ[X]} (hg : g ≠ 0) : (npAttain p w h g).Nonempty := by have hsupp : g.support.Nonempty := Polynomial.support_nonempty.mpr hg have hmem : npMinVal p w h g ∈ g.support.image (npWeight p w h g) := by unfold npMinVal; rw [dif_pos hsupp]; exact Finset.min'_mem _ _ obtain ⟨k, hk_supp, hk_eq⟩ := Finset.mem_image.mp hmem exact ⟨k, Finset.mem_filter.mpr ⟨hk_supp, hk_eq⟩⟩ /-- Left endpoint of the slope-`h/w` face of the `p`-adic Newton polygon of `g`. -/ noncomputable def npLeft (p w : ℕ) (h : ℤ) (g : ℤ[X]) : ℕ := if hg : g ≠ 0 then (npAttain p w h g).min' (npAttain_nonempty hg) else 0 /-- Right endpoint of the slope-`h/w` face of the `p`-adic Newton polygon of `g`. -/ noncomputable def npRight (p w : ℕ) (h : ℤ) (g : ℤ[X]) : ℕ := if hg : g ≠ 0 then (npAttain p w h g).max' (npAttain_nonempty hg) else 0 /-- Horizontal width of the slope-`h/w` face of the `p`-adic Newton polygon of `g`. -/ noncomputable def npWidth (p w : ℕ) (h : ℤ) (g : ℤ[X]) : ℕ := npRight p w h g - npLeft p w h g lemma npMinVal_le {p w : ℕ} {h : ℤ} {g : ℤ[X]} {k : ℕ} (hk : g.coeff k ≠ 0) : npMinVal p w h g ≤ npWeight p w h g k := by have hk_supp : k ∈ g.support := Polynomial.mem_support_iff.mpr hk have hsupp : g.support.Nonempty := ⟨k, hk_supp⟩ unfold npMinVal; rw [dif_pos hsupp] exact Finset.min'_le _ _ (Finset.mem_image_of_mem _ hk_supp) lemma npLeft_mem_attain {p w : ℕ} {h : ℤ} {g : ℤ[X]} (hg : g ≠ 0) : npLeft p w h g ∈ npAttain p w h g := by unfold npLeft; rw [dif_pos hg]; exact Finset.min'_mem _ _ lemma npRight_mem_attain {p w : ℕ} {h : ℤ} {g : ℤ[X]} (hg : g ≠ 0) : npRight p w h g ∈ npAttain p w h g := by unfold npRight; rw [dif_pos hg]; exact Finset.max'_mem _ _ lemma npLeft_le_right {p w : ℕ} {h : ℤ} {g : ℤ[X]} (hg : g ≠ 0) : npLeft p w h g ≤ npRight p w h g := by unfold npRight; rw [dif_pos hg] exact Finset.le_max' _ _ (npLeft_mem_attain hg) lemma npRight_le_natDegree {p w : ℕ} {h : ℤ} {g : ℤ[X]} (hg : g ≠ 0) : npRight p w h g ≤ g.natDegree := by have hm := (Finset.mem_filter.mp (npRight_mem_attain (p := p) (w := w) (h := h) hg)).1 exact Polynomial.le_natDegree_of_mem_supp _ hm lemma npLeft_le_of_eq {p w : ℕ} {h : ℤ} {g : ℤ[X]} {k : ℕ} (hk : g.coeff k ≠ 0) (heq : npWeight p w h g k = npMinVal p w h g) : npLeft p w h g ≤ k := by have hg : g ≠ 0 := fun h0 => hk (by rw [h0, Polynomial.coeff_zero]) unfold npLeft; rw [dif_pos hg] exact Finset.min'_le _ _ (Finset.mem_filter.mpr ⟨Polynomial.mem_support_iff.mpr hk, heq⟩) lemma le_npRight_of_eq {p w : ℕ} {h : ℤ} {g : ℤ[X]} {k : ℕ} (hk : g.coeff k ≠ 0) (heq : npWeight p w h g k = npMinVal p w h g) : k ≤ npRight p w h g := by have hg : g ≠ 0 := fun h0 => hk (by rw [h0, Polynomial.coeff_zero]) unfold npRight; rw [dif_pos hg] exact Finset.le_max' _ _ (Finset.mem_filter.mpr ⟨Polynomial.mem_support_iff.mpr hk, heq⟩) lemma npMinVal_lt_of_lt_npLeft {p w : ℕ} {h : ℤ} {g : ℤ[X]} {k : ℕ} (hk : g.coeff k ≠ 0) (hlt : k < npLeft p w h g) : npMinVal p w h g < npWeight p w h g k := by refine lt_of_le_of_ne (npMinVal_le hk) ?_ intro heq have := npLeft_le_of_eq hk heq.symm omega lemma npMinVal_lt_of_npRight_lt {p w : ℕ} {h : ℤ} {g : ℤ[X]} {k : ℕ} (hk : g.coeff k ≠ 0) (hlt : npRight p w h g < k) : npMinVal p w h g < npWeight p w h g k := by refine lt_of_le_of_ne (npMinVal_le hk) ?_ intro heq have := le_npRight_of_eq hk heq.symm omega /-- **Core Dumas Additivity Theorem**: For any prime `p`, slope `h / w` (`w > 0`), and nonzero `A, B ∈ ℤ[X]`, the left/right endpoints, minimum weight, and horizontal width of the slope-`h/w` face of the `p`-adic Newton polygon are all **strictly additive** under polynomial multiplication. -/ theorem np_mul_props {p w : ℕ} [Fact p.Prime] (hw : 0 < w) (h : ℤ) {A B : ℤ[X]} (hA : A ≠ 0) (hB : B ≠ 0) : npMinVal p w h (A * B) = npMinVal p w h A + npMinVal p w h B ∧ npLeft p w h (A * B) = npLeft p w h A + npLeft p w h B ∧ npRight p w h (A * B) = npRight p w h A + npRight p w h B ∧ npWidth p w h (A * B) = npWidth p w h A + npWidth p w h B := by have hAB : A * B ≠ 0 := mul_ne_zero hA hB set mA := npMinVal p w h A set mB := npMinVal p w h B set lA := npLeft p w h A set lB := npLeft p w h B set rA := npRight p w h A set rB := npRight p w h B have hlA_att := Finset.mem_filter.mp (npLeft_mem_attain (p := p) (w := w) (h := h) hA) have hlB_att := Finset.mem_filter.mp (npLeft_mem_attain (p := p) (w := w) (h := h) hB) have hrA_att := Finset.mem_filter.mp (npRight_mem_attain (p := p) (w := w) (h := h) hA) have hrB_att := Finset.mem_filter.mp (npRight_mem_attain (p := p) (w := w) (h := h) hB) have hlA_ne : A.coeff lA ≠ 0 := Polynomial.mem_support_iff.mp hlA_att.1 have hlB_ne : B.coeff lB ≠ 0 := Polynomial.mem_support_iff.mp hlB_att.1 have hrA_ne : A.coeff rA ≠ 0 := Polynomial.mem_support_iff.mp hrA_att.1 have hrB_ne : B.coeff rB ≠ 0 := Polynomial.mem_support_iff.mp hrB_att.1 -- 1. Lower bound: every nonzero coefficient of A * B has weight ≥ mA + mB have hge_all : ∀ k, (A * B).coeff k ≠ 0 → mA + mB ≤ npWeight p w h (A * B) k := by intro k hk -- Find minimum valuation among nonzero pairs in antidiagonal k rw [Polynomial.coeff_mul] at hk -- Directly show: for every (i, j) with i + j = k and A_i * B_j ≠ 0, w * v(A_i B_j) ≥ mA + mB + h*k have hterm : ∀ x ∈ Finset.HasAntidiagonal.antidiagonal k, A.coeff x.1 * B.coeff x.2 ≠ 0 → mA + mB + h * (k : ℤ) ≤ (w : ℤ) * (padicValInt p (A.coeff x.1 * B.coeff x.2) : ℤ) := by intro x hx hne have hsum : x.1 + x.2 = k := by simpa using hx have h1 : A.coeff x.1 ≠ 0 := left_ne_zero_of_mul hne have h2 : B.coeff x.2 ≠ 0 := right_ne_zero_of_mul hne rw [padicValInt.mul h1 h2] have hw1 : mA ≤ (w : ℤ) * (padicValInt p (A.coeff x.1) : ℤ) - h * (x.1 : ℤ) := npMinVal_le h1 have hw2 : mB ≤ (w : ℤ) * (padicValInt p (B.coeff x.2) : ℤ) - h * (x.2 : ℤ) := npMinVal_le h2 have hk_eq : (k : ℤ) = (x.1 : ℤ) + (x.2 : ℤ) := by exact_mod_cast hsum.symm rw [hk_eq, mul_add] push_cast linarith -- Pick the minimum padicValInt among nonzero terms in antidiagonal k let S := (Finset.HasAntidiagonal.antidiagonal k).filter fun x => A.coeff x.1 * B.coeff x.2 ≠ 0 have hSne : S.Nonempty := by by_contra hEmp rw [Finset.not_nonempty_iff_eq_empty] at hEmp apply hk refine Finset.sum_eq_zero fun x hx => ?_ by_contra hne have : x ∈ S := Finset.mem_filter.mpr ⟨hx, hne⟩ rw [hEmp] at this; exact Finset.notMem_empty _ this let v0 := (S.image fun x => padicValInt p (A.coeff x.1 * B.coeff x.2)).min' (hSne.image _) have hv0_mem : v0 ∈ S.image fun x => padicValInt p (A.coeff x.1 * B.coeff x.2) := Finset.min'_mem _ _ obtain ⟨x₀, hx₀S, hx₀v⟩ := Finset.mem_image.mp hv0_mem have hv_sum : v0 ≤ padicValInt p (∑ x ∈ Finset.HasAntidiagonal.antidiagonal k, A.coeff x.1 * B.coeff x.2) := by refine padicValInt_sum_ge hk fun x hx hne => ?_ exact Finset.min'_le _ _ (Finset.mem_image_of_mem _ (Finset.mem_filter.mpr ⟨hx, hne⟩)) have hbound := hterm x₀ (Finset.mem_filter.mp hx₀S).1 (Finset.mem_filter.mp hx₀S).2 rw [hx₀v] at hbound unfold npWeight rw [Polynomial.coeff_mul] have hv_z : (v0 : ℤ) ≤ (padicValInt p (∑ x ∈ Finset.HasAntidiagonal.antidiagonal k, A.coeff x.1 * B.coeff x.2) : ℤ) := Nat.cast_le.mpr hv_sum have hw_z : (0 : ℤ) < (w : ℤ) := Nat.cast_pos.mpr hw nlinarith -- 2. At k = lA + lB, (lA, lB) is the unique minimum-valuation term have hl_dom : (A * B).coeff (lA + lB) ≠ 0 ∧ padicValInt p ((A * B).coeff (lA + lB)) = padicValInt p (A.coeff lA) + padicValInt p (B.coeff lB) := by rw [Polynomial.coeff_mul] have hdom := padicValInt_sum_eq_of_unique_min (p := p) (s := Finset.HasAntidiagonal.antidiagonal (lA + lB)) (f := fun x => A.coeff x.1 * B.coeff x.2) (x₀ := (lA, lB)) (by simp) (mul_ne_zero hlA_ne hlB_ne) ?_ · rw [padicValInt.mul hlA_ne hlB_ne] at hdom exact hdom · intro x hx hne hfx have hsum : x.1 + x.2 = lA + lB := by simpa using hx have h1 : A.coeff x.1 ≠ 0 := left_ne_zero_of_mul hfx have h2 : B.coeff x.2 ≠ 0 := right_ne_zero_of_mul hfx rw [padicValInt.mul hlA_ne hlB_ne, padicValInt.mul h1 h2] have hlt_or : x.1 < lA ∨ x.2 < lB := by by_contra hnot push Not at hnot apply hne; ext <;> omega have hstrict_w : mA + mB < npWeight p w h A x.1 + npWeight p w h B x.2 := by rcases hlt_or with hlt1 | hlt2 · linarith [npMinVal_lt_of_lt_npLeft (p := p) (w := w) (h := h) h1 hlt1, npMinVal_le (p := p) (w := w) (h := h) h2] · linarith [npMinVal_le (p := p) (w := w) (h := h) h1, npMinVal_lt_of_lt_npLeft (p := p) (w := w) (h := h) h2 hlt2] have heq_l : mA + mB = npWeight p w h A lA + npWeight p w h B lB := by rw [hlA_att.2, hlB_att.2] unfold npWeight at hstrict_w heq_l have hsum_z : (x.1 : ℤ) + (x.2 : ℤ) = (lA : ℤ) + (lB : ℤ) := by exact_mod_cast hsum have hhl : h * (x.1 : ℤ) + h * (x.2 : ℤ) = h * (lA : ℤ) + h * (lB : ℤ) := by rw [← mul_add, hsum_z, mul_add] have hw_z : (0 : ℤ) < (w : ℤ) := Nat.cast_pos.mpr hw have hv_lt : ((padicValInt p (A.coeff lA) : ℤ) + (padicValInt p (B.coeff lB) : ℤ)) < ((padicValInt p (A.coeff x.1) : ℤ) + (padicValInt p (B.coeff x.2) : ℤ)) := by nlinarith exact_mod_cast hv_lt have hl_weight : npWeight p w h (A * B) (lA + lB) = mA + mB := by unfold npWeight rw [hl_dom.2] have heq_l : mA + mB = npWeight p w h A lA + npWeight p w h B lB := by rw [hlA_att.2, hlB_att.2] unfold npWeight at heq_l push_cast; linarith -- 3. At k = rA + rB, (rA, rB) is the unique minimum-valuation term have hr_dom : (A * B).coeff (rA + rB) ≠ 0 ∧ padicValInt p ((A * B).coeff (rA + rB)) = padicValInt p (A.coeff rA) + padicValInt p (B.coeff rB) := by rw [Polynomial.coeff_mul] have hdom := padicValInt_sum_eq_of_unique_min (p := p) (s := Finset.HasAntidiagonal.antidiagonal (rA + rB)) (f := fun x => A.coeff x.1 * B.coeff x.2) (x₀ := (rA, rB)) (by simp) (mul_ne_zero hrA_ne hrB_ne) ?_ · rw [padicValInt.mul hrA_ne hrB_ne] at hdom exact hdom · intro x hx hne hfx have hsum : x.1 + x.2 = rA + rB := by simpa using hx have h1 : A.coeff x.1 ≠ 0 := left_ne_zero_of_mul hfx have h2 : B.coeff x.2 ≠ 0 := right_ne_zero_of_mul hfx rw [padicValInt.mul hrA_ne hrB_ne, padicValInt.mul h1 h2] have hgt_or : rA < x.1 ∨ rB < x.2 := by by_contra hnot push Not at hnot apply hne; ext <;> omega have hstrict_w : mA + mB < npWeight p w h A x.1 + npWeight p w h B x.2 := by rcases hgt_or with hgt1 | hgt2 · linarith [npMinVal_lt_of_npRight_lt (p := p) (w := w) (h := h) h1 hgt1, npMinVal_le (p := p) (w := w) (h := h) h2] · linarith [npMinVal_le (p := p) (w := w) (h := h) h1, npMinVal_lt_of_npRight_lt (p := p) (w := w) (h := h) h2 hgt2] have heq_r : mA + mB = npWeight p w h A rA + npWeight p w h B rB := by rw [hrA_att.2, hrB_att.2] unfold npWeight at hstrict_w heq_r have hsum_z : (x.1 : ℤ) + (x.2 : ℤ) = (rA : ℤ) + (rB : ℤ) := by exact_mod_cast hsum have hhr : h * (x.1 : ℤ) + h * (x.2 : ℤ) = h * (rA : ℤ) + h * (rB : ℤ) := by rw [← mul_add, hsum_z, mul_add] have hw_z : (0 : ℤ) < (w : ℤ) := Nat.cast_pos.mpr hw have hv_lt : ((padicValInt p (A.coeff rA) : ℤ) + (padicValInt p (B.coeff rB) : ℤ)) < ((padicValInt p (A.coeff x.1) : ℤ) + (padicValInt p (B.coeff x.2) : ℤ)) := by nlinarith exact_mod_cast hv_lt have hr_weight : npWeight p w h (A * B) (rA + rB) = mA + mB := by unfold npWeight rw [hr_dom.2] have heq_r : mA + mB = npWeight p w h A rA + npWeight p w h B rB := by rw [hrA_att.2, hrB_att.2] unfold npWeight at heq_r push_cast; linarith -- 4. Deduce npMinVal (A * B) = mA + mB have hmin_eq : npMinVal p w h (A * B) = mA + mB := by apply le_antisymm · rw [← hl_weight]; exact npMinVal_le hl_dom.1 · obtain ⟨k, hk⟩ := npAttain_nonempty (p := p) (w := w) (h := h) hAB have hk' := Finset.mem_filter.mp hk rw [← hk'.2] exact hge_all k (Polynomial.mem_support_iff.mp hk'.1) -- 5. Strict inequality for k < lA + lB and for k > rA + rB have hstrict_left : ∀ k < lA + lB, (A * B).coeff k ≠ 0 → mA + mB < npWeight p w h (A * B) k := by intro k hklt hk rw [Polynomial.coeff_mul] at hk let S := (Finset.HasAntidiagonal.antidiagonal k).filter fun x => A.coeff x.1 * B.coeff x.2 ≠ 0 have hSne : S.Nonempty := by by_contra hEmp rw [Finset.not_nonempty_iff_eq_empty] at hEmp apply hk refine Finset.sum_eq_zero fun x hx => ?_ by_contra hne have : x ∈ S := Finset.mem_filter.mpr ⟨hx, hne⟩ rw [hEmp] at this; exact Finset.notMem_empty _ this let v0 := (S.image fun x => padicValInt p (A.coeff x.1 * B.coeff x.2)).min' (hSne.image _) have hv0_mem : v0 ∈ S.image fun x => padicValInt p (A.coeff x.1 * B.coeff x.2) := Finset.min'_mem _ _ obtain ⟨x₀, hx₀S, hx₀v⟩ := Finset.mem_image.mp hv0_mem have hx₀_anti := (Finset.mem_filter.mp hx₀S).1 have hx₀_ne := (Finset.mem_filter.mp hx₀S).2 have hsum : x₀.1 + x₀.2 = k := by simpa using hx₀_anti have h1 : A.coeff x₀.1 ≠ 0 := left_ne_zero_of_mul hx₀_ne have h2 : B.coeff x₀.2 ≠ 0 := right_ne_zero_of_mul hx₀_ne have hv_sum : v0 ≤ padicValInt p ((A * B).coeff k) := by rw [Polynomial.coeff_mul] refine padicValInt_sum_ge hk fun x hx hne => ?_ exact Finset.min'_le _ _ (Finset.mem_image_of_mem _ (Finset.mem_filter.mpr ⟨hx, hne⟩)) have hlt_or : x₀.1 < lA ∨ x₀.2 < lB := by omega have hstrict_w : mA + mB < npWeight p w h A x₀.1 + npWeight p w h B x₀.2 := by rcases hlt_or with hlt1 | hlt2 · linarith [npMinVal_lt_of_lt_npLeft (p := p) (w := w) (h := h) h1 hlt1, npMinVal_le (p := p) (w := w) (h := h) h2] · linarith [npMinVal_le (p := p) (w := w) (h := h) h1, npMinVal_lt_of_lt_npLeft (p := p) (w := w) (h := h) h2 hlt2] rw [padicValInt.mul h1 h2] at hx₀v unfold npWeight at hstrict_w ⊢ have hsum_z : (k : ℤ) = (x₀.1 : ℤ) + (x₀.2 : ℤ) := by exact_mod_cast hsum.symm have hhk : h * (k : ℤ) = h * (x₀.1 : ℤ) + h * (x₀.2 : ℤ) := by rw [hsum_z, mul_add] have hv_z : (v0 : ℤ) ≤ (padicValInt p ((A * B).coeff k) : ℤ) := Nat.cast_le.mpr hv_sum have hw_z : (0 : ℤ) < (w : ℤ) := Nat.cast_pos.mpr hw have hx₀v_z : (padicValInt p (A.coeff x₀.1) : ℤ) + (padicValInt p (B.coeff x₀.2) : ℤ) = (v0 : ℤ) := by exact_mod_cast hx₀v nlinarith have hstrict_right : ∀ k, rA + rB < k → (A * B).coeff k ≠ 0 → mA + mB < npWeight p w h (A * B) k := by intro k hkgt hk rw [Polynomial.coeff_mul] at hk let S := (Finset.HasAntidiagonal.antidiagonal k).filter fun x => A.coeff x.1 * B.coeff x.2 ≠ 0 have hSne : S.Nonempty := by by_contra hEmp rw [Finset.not_nonempty_iff_eq_empty] at hEmp apply hk refine Finset.sum_eq_zero fun x hx => ?_ by_contra hne have : x ∈ S := Finset.mem_filter.mpr ⟨hx, hne⟩ rw [hEmp] at this; exact Finset.notMem_empty _ this let v0 := (S.image fun x => padicValInt p (A.coeff x.1 * B.coeff x.2)).min' (hSne.image _) have hv0_mem : v0 ∈ S.image fun x => padicValInt p (A.coeff x.1 * B.coeff x.2) := Finset.min'_mem _ _ obtain ⟨x₀, hx₀S, hx₀v⟩ := Finset.mem_image.mp hv0_mem have hx₀_anti := (Finset.mem_filter.mp hx₀S).1 have hx₀_ne := (Finset.mem_filter.mp hx₀S).2 have hsum : x₀.1 + x₀.2 = k := by simpa using hx₀_anti have h1 : A.coeff x₀.1 ≠ 0 := left_ne_zero_of_mul hx₀_ne have h2 : B.coeff x₀.2 ≠ 0 := right_ne_zero_of_mul hx₀_ne have hv_sum : v0 ≤ padicValInt p ((A * B).coeff k) := by rw [Polynomial.coeff_mul] refine padicValInt_sum_ge hk fun x hx hne => ?_ exact Finset.min'_le _ _ (Finset.mem_image_of_mem _ (Finset.mem_filter.mpr ⟨hx, hne⟩)) have hgt_or : rA < x₀.1 ∨ rB < x₀.2 := by omega have hstrict_w : mA + mB < npWeight p w h A x₀.1 + npWeight p w h B x₀.2 := by rcases hgt_or with hgt1 | hgt2 · linarith [npMinVal_lt_of_npRight_lt (p := p) (w := w) (h := h) h1 hgt1, npMinVal_le (p := p) (w := w) (h := h) h2] · linarith [npMinVal_le (p := p) (w := w) (h := h) h1, npMinVal_lt_of_npRight_lt (p := p) (w := w) (h := h) h2 hgt2] rw [padicValInt.mul h1 h2] at hx₀v unfold npWeight at hstrict_w ⊢ have hsum_z : (k : ℤ) = (x₀.1 : ℤ) + (x₀.2 : ℤ) := by exact_mod_cast hsum.symm have hhk : h * (k : ℤ) = h * (x₀.1 : ℤ) + h * (x₀.2 : ℤ) := by rw [hsum_z, mul_add] have hv_z : (v0 : ℤ) ≤ (padicValInt p ((A * B).coeff k) : ℤ) := Nat.cast_le.mpr hv_sum have hw_z : (0 : ℤ) < (w : ℤ) := Nat.cast_pos.mpr hw have hx₀v_z : (padicValInt p (A.coeff x₀.1) : ℤ) + (padicValInt p (B.coeff x₀.2) : ℤ) = (v0 : ℤ) := by exact_mod_cast hx₀v nlinarith have hleft_eq : npLeft p w h (A * B) = lA + lB := by apply le_antisymm · exact npLeft_le_of_eq hl_dom.1 (hl_weight.trans hmin_eq.symm) · by_contra hlt push Not at hlt have hm := Finset.mem_filter.mp (npLeft_mem_attain (p := p) (w := w) (h := h) hAB) have hst := hstrict_left _ hlt (Polynomial.mem_support_iff.mp hm.1) rw [hm.2, hmin_eq] at hst exact lt_irrefl _ hst have hright_eq : npRight p w h (A * B) = rA + rB := by apply le_antisymm · by_contra hgt push Not at hgt have hm := Finset.mem_filter.mp (npRight_mem_attain (p := p) (w := w) (h := h) hAB) have hst := hstrict_right _ hgt (Polynomial.mem_support_iff.mp hm.1) rw [hm.2, hmin_eq] at hst exact lt_irrefl _ hst · exact le_npRight_of_eq hr_dom.1 (hr_weight.trans hmin_eq.symm) have hwidth_eq : npWidth p w h (A * B) = npWidth p w h A + npWidth p w h B := by unfold npWidth rw [hleft_eq, hright_eq] have hleA := npLeft_le_right (p := p) (w := w) (h := h) hA have hleB := npLeft_le_right (p := p) (w := w) (h := h) hB omega exact ⟨hmin_eq, hleft_eq, hright_eq, hwidth_eq⟩ theorem npWidth_mul {p w : ℕ} [Fact p.Prime] (hw : 0 < w) (h : ℤ) {A B : ℤ[X]} (hA : A ≠ 0) (hB : B ≠ 0) : npWidth p w h (A * B) = npWidth p w h A + npWidth p w h B := (np_mul_props hw h hA hB).2.2.2 /-- **Lattice-Point Divisibility**: If `gcd(w, |h|) = 1`, then `w ∣ npWidth p w h g`. -/ theorem dvd_npWidth {p w : ℕ} {h : ℤ} (hcop : Nat.Coprime w h.natAbs) (g : ℤ[X]) : w ∣ npWidth p w h g := by by_cases hg : g = 0 · subst hg; simp [npWidth, npLeft, npRight] · have hl := (Finset.mem_filter.mp (npLeft_mem_attain (p := p) (w := w) (h := h) hg)).2 have hr := (Finset.mem_filter.mp (npRight_mem_attain (p := p) (w := w) (h := h) hg)).2 have hle := npLeft_le_right (p := p) (w := w) (h := h) hg have heq : npWeight p w h g (npLeft p w h g) = npWeight p w h g (npRight p w h g) := hl.trans hr.symm unfold npWeight at heq have hdvd_z : (w : ℤ) ∣ h * ((npWidth p w h g : ℕ) : ℤ) := by refine ⟨(padicValInt p (g.coeff (npRight p w h g)) : ℤ) - (padicValInt p (g.coeff (npLeft p w h g)) : ℤ), ?_⟩ unfold npWidth rw [Nat.cast_sub hle] linarith have hdvd_nat : w ∣ h.natAbs * npWidth p w h g := by have := Int.natCast_dvd.mp hdvd_z rwa [Int.natAbs_mul, Int.natAbs_natCast] at this exact hcop.dvd_of_dvd_mul_left hdvd_nat /-- Monotonicity of Newton-polygon faces: if `h₁ / w₁ < h₂ / w₂`, then `npRight p w₁ h₁ g ≤ npLeft p w₂ h₂ g`. -/ theorem npRight_le_npLeft_of_slope_lt {p w₁ w₂ : ℕ} {h₁ h₂ : ℤ} (hw₁ : 0 < w₁) (hw₂ : 0 < w₂) (hslope : h₁ * (w₂ : ℤ) < h₂ * (w₁ : ℤ)) {g : ℤ[X]} (hg : g ≠ 0) : npRight p w₁ h₁ g ≤ npLeft p w₂ h₂ g := by set r₁ := npRight p w₁ h₁ g set l₂ := npLeft p w₂ h₂ g have hr₁_att := Finset.mem_filter.mp (npRight_mem_attain (p := p) (w := w₁) (h := h₁) hg) have hl₂_att := Finset.mem_filter.mp (npLeft_mem_attain (p := p) (w := w₂) (h := h₂) hg) have hle1 : npWeight p w₁ h₁ g r₁ ≤ npWeight p w₁ h₁ g l₂ := by rw [hr₁_att.2]; exact npMinVal_le (Polynomial.mem_support_iff.mp hl₂_att.1) have hle2 : npWeight p w₂ h₂ g l₂ ≤ npWeight p w₂ h₂ g r₁ := by rw [hl₂_att.2]; exact npMinVal_le (Polynomial.mem_support_iff.mp hr₁_att.1) unfold npWeight at hle1 hle2 have hw₁_z : (0 : ℤ) < (w₁ : ℤ) := Nat.cast_pos.mpr hw₁ have hw₂_z : (0 : ℤ) < (w₂ : ℤ) := Nat.cast_pos.mpr hw₂ have hm1 := mul_le_mul_of_nonneg_left hle1 hw₂_z.le have hm2 := mul_le_mul_of_nonneg_left hle2 hw₁_z.le have hprod : (h₂ * (w₁ : ℤ) - h₁ * (w₂ : ℤ)) * ((r₁ : ℤ) - (l₂ : ℤ)) ≤ 0 := by linarith have hdiff_le : (r₁ : ℤ) - (l₂ : ℤ) ≤ 0 := by nlinarith omega /-- Sum of widths along any strictly increasing chain of slopes is at most `g.natDegree`. -/ theorem npWidth_sum_le_natDegree (p : ℕ) : ∀ (L : List (ℕ × ℤ)), (∀ s ∈ L, 0 < s.1) → L.IsChain (fun s₁ s₂ => s₁.2 * (s₂.1 : ℤ) < s₂.2 * (s₁.1 : ℤ)) → ∀ (g : ℤ[X]), g ≠ 0 → (L.map fun s => npWidth p s.1 s.2 g).sum ≤ g.natDegree := by have haux : ∀ (s : ℕ × ℤ) (rest : List (ℕ × ℤ)), (∀ t ∈ s :: rest, 0 < t.1) → (s :: rest).IsChain (fun s₁ s₂ => s₁.2 * (s₂.1 : ℤ) < s₂.2 * (s₁.1 : ℤ)) → ∀ (g : ℤ[X]), g ≠ 0 → npLeft p s.1 s.2 g + ((s :: rest).map fun t => npWidth p t.1 t.2 g).sum ≤ g.natDegree := by intro s rest induction rest generalizing s with | nil => intro _ _ g hg simp only [List.map_cons, List.map_nil, List.sum_cons, List.sum_nil, add_zero] have hlr := npLeft_le_right (p := p) (w := s.1) (h := s.2) hg have hrn := npRight_le_natDegree (p := p) (w := s.1) (h := s.2) hg unfold npWidth omega | cons s₂ tl ih => intro hpos hch g hg rw [List.isChain_cons_cons] at hch have hih := ih s₂ (fun t ht => hpos t (List.mem_cons_of_mem s ht)) hch.2 g hg have hrl := npRight_le_npLeft_of_slope_lt (p := p) (hpos s (by simp)) (hpos s₂ (by simp)) hch.1 hg have hlr := npLeft_le_right (p := p) (w := s.1) (h := s.2) hg simp only [List.map_cons, List.sum_cons] at hih ⊢ unfold npWidth at hih ⊢ omega intro L hpos hch g hg cases L with | nil => simp | cons s rest => have := haux s rest hpos hch g hg omega /-- Gauss's Lemma degree-preserving factorization lift: if `f ∈ ℤ[X]` is primitive and `f.map (Int.castRingHom ℚ) = u * v` in `ℚ[X]`, then there exist `A, B ∈ ℤ[X]` with `f = A * B`, `A.natDegree = u.natDegree`, and `B.natDegree = v.natDegree`. -/ lemma gauss_factor_to_int {f : ℤ[X]} (hf : f.IsPrimitive) {u v : ℚ[X]} (huv : f.map (Int.castRingHom ℚ) = u * v) : ∃ A B : ℤ[X], f = A * B ∧ A.natDegree = u.natDegree ∧ B.natDegree = v.natDegree := by have hf_ne : f ≠ 0 := hf.ne_zero have hu_ne : u ≠ 0 := by intro h0; rw [h0, zero_mul] at huv exact hf_ne (Polynomial.map_injective _ Int.cast_injective (by simpa using huv)) have hv_ne : v ≠ 0 := by intro h0; rw [h0, mul_zero] at huv exact hf_ne (Polynomial.map_injective _ Int.cast_injective (by simpa using huv)) -- Clear denominators of a nonzero polynomial in ℚ[X] to a primitive polynomial in ℤ[X] have hclear : ∀ w : ℚ[X], w ≠ 0 → ∃ (c : ℚ) (W : ℤ[X]), c ≠ 0 ∧ W.IsPrimitive ∧ W.map (Int.castRingHom ℚ) = C c * w := by intro w hw let D : ℕ := (Finset.range (w.natDegree + 1)).lcm fun k => (w.coeff k).den have hD_pos : 0 < D := by refine Nat.pos_of_ne_zero ?_ rw [Finset.lcm_ne_zero_iff] intro k _; exact (w.coeff k).den_nz have hW0_ex : ∃ W0 : ℤ[X], W0.map (Int.castRingHom ℚ) = C (D : ℚ) * w := by refine ⟨∑ k ∈ Finset.range (w.natDegree + 1), C ((w.coeff k * (D : ℚ)).num) * X ^ k, ?_⟩ ext k rw [Polynomial.coeff_map, Polynomial.coeff_C_mul, coeff_sum_C_mul_X_pow] by_cases hkw : k ≤ w.natDegree · rw [if_pos hkw] have hdvd : (w.coeff k).den ∣ D := Finset.dvd_lcm (Finset.mem_range.mpr (Nat.lt_succ_of_le hkw)) obtain ⟨m, hm⟩ := hdvd have hden_ne : ((w.coeff k).den : ℚ) ≠ 0 := Nat.cast_ne_zero.mpr (w.coeff k).den_nz have hmul_int : w.coeff k * (D : ℚ) = ((w.coeff k).num * (m : ℤ) : ℤ) := by rw [hm]; push_cast have hq := Rat.num_div_den (w.coeff k) nth_rw 1 [← hq] field_simp [hden_ne] rw [hmul_int, Rat.num_intCast] change (((w.coeff k).num * (m : ℤ) : ℤ) : ℚ) = (D : ℚ) * w.coeff k rw [← hmul_int, mul_comm] · rw [if_neg hkw, map_zero, Polynomial.coeff_eq_zero_of_natDegree_lt (by omega), mul_zero] obtain ⟨W0, hW0_map⟩ := hW0_ex have hW0_ne : W0 ≠ 0 := by intro h0 rw [h0, Polynomial.map_zero] at hW0_map have hCne : (C (D : ℚ) : ℚ[X]) ≠ 0 := Polynomial.C_ne_zero.mpr (Nat.cast_ne_zero.mpr hD_pos.ne') exact (mul_ne_zero hCne hw) hW0_map.symm let W := W0.primPart have hW_prim : W.IsPrimitive := W0.isPrimitive_primPart have hW0_eq : C W0.content * W = W0 := W0.eq_C_content_mul_primPart.symm have hcont_ne : (W0.content : ℚ) ≠ 0 := by intro hc have hc0 : W0.content = 0 := Int.cast_eq_zero.mp hc rw [hc0, map_zero, zero_mul] at hW0_eq exact hW0_ne hW0_eq.symm refine ⟨(D : ℚ) / (W0.content : ℚ), W, div_ne_zero (Nat.cast_ne_zero.mpr hD_pos.ne') hcont_ne, hW_prim, ?_⟩ have hmap : C (W0.content : ℚ) * W.map (Int.castRingHom ℚ) = C (D : ℚ) * w := by rw [← hW0_map] nth_rw 2 [← hW0_eq] rw [Polynomial.map_mul, Polynomial.map_C] rfl have hCne : (C (W0.content : ℚ) : ℚ[X]) ≠ 0 := Polynomial.C_ne_zero.mpr hcont_ne apply mul_left_cancel₀ hCne rw [hmap, ← mul_assoc, ← map_mul, mul_div_cancel₀ _ hcont_ne] obtain ⟨cu, U, hcu_ne, hU_prim, hU_map⟩ := hclear u hu_ne obtain ⟨cv, V, hcv_ne, hV_prim, hV_map⟩ := hclear v hv_ne have hUV_prim : (U * V).IsPrimitive := hU_prim.mul hV_prim have hUV_map : (U * V).map (Int.castRingHom ℚ) = C (cu * cv) * f.map (Int.castRingHom ℚ) := by rw [Polynomial.map_mul, hU_map, hV_map, huv, map_mul]; ring -- Write cu * cv = p / q in lowest terms; then q * (U * V) = p * f in ℤ[X] set r : ℚ := cu * cv have hr_ne : r ≠ 0 := mul_ne_zero hcu_ne hcv_ne have hq_ne : (r.den : ℤ) ≠ 0 := Int.natCast_ne_zero.mpr r.den_nz have hp_ne : r.num ≠ 0 := Rat.num_ne_zero.mpr hr_ne have hint_eq : C (r.den : ℤ) * (U * V) = C r.num * f := by apply Polynomial.map_injective (Int.castRingHom ℚ) Int.cast_injective rw [Polynomial.map_mul, Polynomial.map_C, hUV_map, Polynomial.map_mul, Polynomial.map_C] simp only [eq_intCast, Int.cast_natCast] rw [← mul_assoc, ← map_mul] congr 2 have hq_q : (r.den : ℚ) ≠ 0 := Nat.cast_ne_zero.mpr r.den_nz have := Rat.mul_den_eq_num r linarith -- Since U * V and f are both primitive, |(r.den : ℤ)| = |r.num|, so r.num = ± r.den have hcont_eq := congrArg Polynomial.content hint_eq rw [Polynomial.content_C_mul, Polynomial.content_C_mul, Polynomial.isPrimitive_iff_content_eq_one.mp hUV_prim, Polynomial.isPrimitive_iff_content_eq_one.mp hf, mul_one, mul_one] at hcont_eq -- In ℤ, normalize (r.den : ℤ) = r.den and normalize r.num = |r.num| have habs_eq : (r.den : ℤ) = |r.num| := by have h1 : normalize (r.den : ℤ) = (r.den : ℤ) := Int.normalize_of_nonneg (Nat.cast_nonneg r.den) have h2 : normalize r.num = |r.num| := by rcases le_total 0 r.num with hnn | hnp · rw [Int.normalize_of_nonneg hnn, abs_of_nonneg hnn] · rw [abs_of_nonpos hnp] have heq_norm : normalize r.num = normalize (-r.num) := normalize_eq_normalize_iff.mpr ⟨⟨-1, by ring⟩, ⟨-1, by ring⟩⟩ rw [heq_norm] exact Int.normalize_of_nonneg (by omega) rw [h1, h2] at hcont_eq exact hcont_eq have hU_deg : U.natDegree = u.natDegree := by have := congrArg Polynomial.natDegree hU_map rw [Polynomial.natDegree_map_eq_of_injective (f := Int.castRingHom ℚ) Int.cast_injective, Polynomial.natDegree_C_mul hcu_ne] at this exact this have hV_deg : V.natDegree = v.natDegree := by have := congrArg Polynomial.natDegree hV_map rw [Polynomial.natDegree_map_eq_of_injective (f := Int.castRingHom ℚ) Int.cast_injective, Polynomial.natDegree_C_mul hcv_ne] at this exact this rcases eq_or_eq_neg_of_abs_eq habs_eq.symm with hpos | hneg · -- r.num = r.den => U * V = f rw [hpos] at hint_eq have hfUV : U * V = f := mul_left_cancel₀ (Polynomial.C_ne_zero.mpr hq_ne) hint_eq exact ⟨U, V, hfUV.symm, hU_deg, hV_deg⟩ · -- r.num = -r.den => (-U) * V = f rw [hneg, map_neg] at hint_eq have hfUV : -(U * V) = f := by apply mul_left_cancel₀ (Polynomial.C_ne_zero.mpr hq_ne) rw [mul_neg, hint_eq, neg_mul, neg_neg] exact ⟨-U, V, by rw [neg_mul, hfUV], by rw [Polynomial.natDegree_neg, hU_deg], hV_deg⟩ /-- **Dumas Single-Segment Factor-Degree Divisibility**: If `f ∈ ℤ[X]` is primitive of degree `n ≥ 1`, `gcd(w, |h|) = 1`, `w > 0`, and `npWidth p w h f = n`, then every factor `u ∣ f.map (Int.castRingHom ℚ)` satisfies `w ∣ u.natDegree`. -/ theorem dumas_single_segment_dvd_natDegree {p w : ℕ} [Fact p.Prime] (hw : 0 < w) {h : ℤ} (hcop : Nat.Coprime w h.natAbs) {f : ℤ[X]} (hf : f.IsPrimitive) (hfull : npWidth p w h f = f.natDegree) {u : ℚ[X]} (hdvd : u ∣ f.map (Int.castRingHom ℚ)) : w ∣ u.natDegree := by obtain ⟨v, huv⟩ := hdvd obtain ⟨A, B, hAB, hAdeg, hBdeg⟩ := gauss_factor_to_int hf huv have hf_ne : f ≠ 0 := hf.ne_zero have hA_ne : A ≠ 0 := fun h0 => hf_ne (by rw [hAB, h0, zero_mul]) have hB_ne : B ≠ 0 := fun h0 => hf_ne (by rw [hAB, h0, mul_zero]) have hwm := npWidth_mul (p := p) hw h hA_ne hB_ne rw [← hAB, hfull, hAB, Polynomial.natDegree_mul hA_ne hB_ne] at hwm have hleA : npWidth p w h A ≤ A.natDegree := by have := npRight_le_natDegree (p := p) (w := w) (h := h) hA_ne unfold npWidth; omega have hleB : npWidth p w h B ≤ B.natDegree := by have := npRight_le_natDegree (p := p) (w := w) (h := h) hB_ne unfold npWidth; omega have heqA : npWidth p w h A = A.natDegree := by omega rw [← hAdeg, ← heqA] exact dvd_npWidth hcop A /-- **Dumas Single-Segment Irreducibility Criterion**: If `f ∈ ℤ[X]` is primitive of degree `n ≥ 1`, `gcd(n, |h|) = 1`, and `npWidth p n h f = n`, then `f.map (Int.castRingHom ℚ)` is irreducible over `ℚ`. -/ theorem irreducible_of_dumas_single_segment {p : ℕ} [Fact p.Prime] {h : ℤ} {f : ℤ[X]} (hf : f.IsPrimitive) (hpos : 0 < f.natDegree) (hcop : Nat.Coprime f.natDegree h.natAbs) (hfull : npWidth p f.natDegree h f = f.natDegree) : Irreducible (f.map (Int.castRingHom ℚ)) := by set P := f.map (Int.castRingHom ℚ) have hP_deg : P.natDegree = f.natDegree := by dsimp [P]; exact Polynomial.natDegree_map_eq_of_injective (f := Int.castRingHom ℚ) Int.cast_injective f have hP_ne : P ≠ 0 := fun h0 => by rw [h0, Polynomial.natDegree_zero] at hP_deg; omega refine ⟨fun hu => by have := Polynomial.natDegree_eq_zero_of_isUnit hu; omega, fun u v huv => ?_⟩ have hu_ne : u ≠ 0 := fun h0 => hP_ne (by rw [huv, h0, zero_mul]) have hv_ne : v ≠ 0 := fun h0 => hP_ne (by rw [huv, h0, mul_zero]) have hsum : u.natDegree + v.natDegree = f.natDegree := by rw [← Polynomial.natDegree_mul hu_ne hv_ne, ← huv, hP_deg] have hdvd_u : f.natDegree ∣ u.natDegree := dumas_single_segment_dvd_natDegree hpos hcop hf hfull ⟨v, huv⟩ by_cases hu0 : u.natDegree = 0 · left rw [Polynomial.eq_C_of_natDegree_eq_zero hu0] exact Polynomial.isUnit_C.mpr (isUnit_iff_ne_zero.mpr fun h0 => hu_ne (by rw [Polynomial.eq_C_of_natDegree_eq_zero hu0, h0, map_zero])) · right have hu_ge : f.natDegree ≤ u.natDegree := Nat.le_of_dvd (Nat.pos_of_ne_zero hu0) hdvd_u have hv0 : v.natDegree = 0 := by omega rw [Polynomial.eq_C_of_natDegree_eq_zero hv0] exact Polynomial.isUnit_C.mpr (isUnit_iff_ne_zero.mpr fun h0 => hv_ne (by rw [Polynomial.eq_C_of_natDegree_eq_zero hv0, h0, map_zero])) /-- **Dumas Large-Irreducible-Factor Theorem**: If `f ∈ ℤ[X]` is primitive, `w > 0`, `gcd(w, |h|) = 1`, and `npWidth p w h f = w`, then `f.map (Int.castRingHom ℚ)` has an irreducible factor over `ℚ` of degree `≥ w`. -/ theorem exists_irred_factor_natDegree_ge_of_npWidth {p w : ℕ} [Fact p.Prime] (hw : 0 < w) {h : ℤ} (hcop : Nat.Coprime w h.natAbs) : ∀ (d : ℕ) (f : ℤ[X]), f.natDegree ≤ d → f.IsPrimitive → npWidth p w h f = w → ∃ g : ℚ[X], Irreducible g ∧ g ∣ f.map (Int.castRingHom ℚ) ∧ w ≤ g.natDegree := by intro d induction d using Nat.strongRecOn with | ind n ih => intro f hdeg hf hwidth set P := f.map (Int.castRingHom ℚ) have hP_deg : P.natDegree = f.natDegree := by dsimp [P]; exact Polynomial.natDegree_map_eq_of_injective (f := Int.castRingHom ℚ) Int.cast_injective f have hw_le : w ≤ f.natDegree := by have := npRight_le_natDegree (p := p) (w := w) (h := h) hf.ne_zero unfold npWidth at hwidth; omega have hP_ne : P ≠ 0 := fun h0 => by rw [h0, Polynomial.natDegree_zero] at hP_deg; omega by_cases hIrr : Irreducible P · exact ⟨P, hIrr, dvd_rfl, by omega⟩ · have hnu : ¬ IsUnit P := fun hu => by have := Polynomial.natDegree_eq_zero_of_isUnit hu; omega -- Since P is neither a unit nor irreducible, P = u * v with both u, v non-units have hfac : ∃ u v : ℚ[X], P = u * v ∧ ¬ IsUnit u ∧ ¬ IsUnit v := by by_contra hnone push Not at hnone apply hIrr refine ⟨hnu, fun u v huv => ?_⟩ by_cases hu : IsUnit u · exact Or.inl hu · exact Or.inr (hnone u v huv hu) obtain ⟨u, v, huv, hu_nu, hv_nu⟩ := hfac obtain ⟨A, B, hAB, hAdeg, hBdeg⟩ := gauss_factor_to_int hf huv have hA_ne : A ≠ 0 := fun h0 => hf.ne_zero (by rw [hAB, h0, zero_mul]) have hB_ne : B ≠ 0 := fun h0 => hf.ne_zero (by rw [hAB, h0, mul_zero]) have hA_prim : A.IsPrimitive := by rw [Polynomial.isPrimitive_iff_isUnit_of_C_dvd] intro r hr exact (Polynomial.isPrimitive_iff_isUnit_of_C_dvd.mp hf) r (hAB ▸ dvd_mul_of_dvd_left hr B) have hB_prim : B.IsPrimitive := by rw [Polynomial.isPrimitive_iff_isUnit_of_C_dvd] intro r hr exact (Polynomial.isPrimitive_iff_isUnit_of_C_dvd.mp hf) r (hAB ▸ dvd_mul_of_dvd_right hr A) have hA_pos : 0 < A.natDegree := by by_contra h0 have hu0 : u.natDegree = 0 := by omega have hu_ne : u ≠ 0 := fun h0' => hP_ne (by rw [huv, h0', zero_mul]) apply hu_nu rw [Polynomial.eq_C_of_natDegree_eq_zero hu0] exact Polynomial.isUnit_C.mpr (isUnit_iff_ne_zero.mpr fun h0' => hu_ne (by rw [Polynomial.eq_C_of_natDegree_eq_zero hu0, h0', map_zero])) have hB_pos : 0 < B.natDegree := by by_contra h0 have hv0 : v.natDegree = 0 := by omega have hv_ne : v ≠ 0 := fun h0' => hP_ne (by rw [huv, h0', mul_zero]) apply hv_nu rw [Polynomial.eq_C_of_natDegree_eq_zero hv0] exact Polynomial.isUnit_C.mpr (isUnit_iff_ne_zero.mpr fun h0' => hv_ne (by rw [Polynomial.eq_C_of_natDegree_eq_zero hv0, h0', map_zero])) have hsum_deg : A.natDegree + B.natDegree = f.natDegree := by rw [← Polynomial.natDegree_mul hA_ne hB_ne, ← hAB] have hwm := npWidth_mul (p := p) hw h hA_ne hB_ne rw [← hAB, hwidth] at hwm have hdvdA : w ∣ npWidth p w h A := dvd_npWidth hcop A have hdvdB : w ∣ npWidth p w h B := dvd_npWidth hcop B -- Since w ∣ wA, w ∣ wB, and wA + wB = w, either wA = w or wB = w by_cases hA0 : npWidth p w h A = 0 · have hBw : npWidth p w h B = w := by omega have hBlt : B.natDegree < n := by omega obtain ⟨g, hg_irr, hg_dvd, hg_deg⟩ := ih B.natDegree hBlt B le_rfl hB_prim hBw refine ⟨g, hg_irr, hg_dvd.trans ?_, hg_deg⟩ exact ⟨A.map (Int.castRingHom ℚ), by dsimp [P]; rw [hAB, Polynomial.map_mul, mul_comm]⟩ · have hAw_ge : w ≤ npWidth p w h A := Nat.le_of_dvd (Nat.pos_of_ne_zero hA0) hdvdA have hAw : npWidth p w h A = w := by omega have hAlt : A.natDegree < n := by omega obtain ⟨g, hg_irr, hg_dvd, hg_deg⟩ := ih A.natDegree hAlt A le_rfl hA_prim hAw refine ⟨g, hg_irr, hg_dvd.trans ?_, hg_deg⟩ exact ⟨B.map (Int.castRingHom ℚ), by dsimp [P]; rw [hAB, Polynomial.map_mul]⟩ /-- **Multi-Segment Dumas Factor-Degree Divisibility Theorem**: If `f ∈ ℤ[X]` is primitive and `L` is a strictly increasing list of slopes `(w_i, h_i)` such that `0 < w_i`, `gcd(w_i, |h_i|) = 1`, `d ∣ w_i` for every `(w_i, h_i) ∈ L`, and the Newton-polygon widths along `L` sum to `f.natDegree`, then **every** factor `u ∣ f.map (Int.castRingHom ℚ)` satisfies `d ∣ u.natDegree`. -/ theorem dvd_natDegree_of_slope_list {p d : ℕ} [Fact p.Prime] {L : List (ℕ × ℤ)} (hpos : ∀ s ∈ L, 0 < s.1) (hcop : ∀ s ∈ L, Nat.Coprime s.1 s.2.natAbs) (hd : ∀ s ∈ L, d ∣ s.1) (hch : L.IsChain (fun s₁ s₂ => s₁.2 * (s₂.1 : ℤ) < s₂.2 * (s₁.1 : ℤ))) {f : ℤ[X]} (hf : f.IsPrimitive) (hfull : (L.map fun s => npWidth p s.1 s.2 f).sum = f.natDegree) {u : ℚ[X]} (hdvd : u ∣ f.map (Int.castRingHom ℚ)) : d ∣ u.natDegree := by obtain ⟨v, huv⟩ := hdvd obtain ⟨A, B, hAB, hAdeg, _⟩ := gauss_factor_to_int hf huv have hf_ne : f ≠ 0 := hf.ne_zero have hA_ne : A ≠ 0 := fun h0 => hf_ne (by rw [hAB, h0, zero_mul]) have hB_ne : B ≠ 0 := fun h0 => hf_ne (by rw [hAB, h0, mul_zero]) have hsum_add : ∀ M : List (ℕ × ℤ), (∀ s ∈ M, 0 < s.1) → (M.map fun s => npWidth p s.1 s.2 (A * B)).sum = (M.map fun s => npWidth p s.1 s.2 A).sum + (M.map fun s => npWidth p s.1 s.2 B).sum := by intro M induction M with | nil => intro _; simp | cons s tl ih => intro hM simp only [List.map_cons, List.sum_cons] rw [npWidth_mul (hM s (by simp)) s.2 hA_ne hB_ne, ih (fun t ht => hM t (List.mem_cons_of_mem s ht))] ring have hsum_AB := hsum_add L hpos rw [← hAB, hfull, hAB, Polynomial.natDegree_mul hA_ne hB_ne] at hsum_AB have hleA := npWidth_sum_le_natDegree p L hpos hch A hA_ne have hleB := npWidth_sum_le_natDegree p L hpos hch B hB_ne have heqA : (L.map fun s => npWidth p s.1 s.2 A).sum = A.natDegree := by omega rw [← hAdeg, ← heqA] have hdvd_sum : ∀ M : List (ℕ × ℤ), (∀ s ∈ M, Nat.Coprime s.1 s.2.natAbs) → (∀ s ∈ M, d ∣ s.1) → d ∣ (M.map fun s => npWidth p s.1 s.2 A).sum := by intro M induction M with | nil => intro _ _; simp | cons s tl ih => intro hcM hdM simp only [List.map_cons, List.sum_cons] exact dvd_add ((hdM s (by simp)).trans (dvd_npWidth (hcM s (by simp)) A)) (ih (fun t ht => hcM t (List.mem_cons_of_mem s ht)) (fun t ht => hdM t (List.mem_cons_of_mem s ht))) exact hdvd_sum L hcop hd end DumasEngine /-! ## Section 4: Headline Dumas Theorems for OEIS A115257 -/ /-- Power law for `padicValNat` (self-contained induction from `padicValNat.mul`). -/ lemma padicValNat_pow_eq {p : ℕ} [Fact p.Prime] {a : ℕ} (ha : a ≠ 0) (m : ℕ) : padicValNat p (a ^ m) = m * padicValNat p a := by induction m with | zero => simp | succ k ih => rw [pow_succ', padicValNat.mul ha (pow_ne_zero k ha), ih, Nat.succ_mul] ring /-! ### 4.1 Generalized Central-Binomial Odd-Power Infinite Family -/ /-- **Theorem 2 (Generalized Odd-Power Central-Binomial Family)**: For every $r \ge 0$ and every odd $e \ge 1$, the polynomial $\sum_{k=0}^{2^r} \binom{2k}{k}^e x^k$ is irreducible over $\mathbb{Q}$. -/ theorem centralBinomPowPoly_irreducible_two_pow_odd (r e : ℕ) (he : Odd e) : Irreducible (centralBinomPowPoly e (2 ^ r)) := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ rw [← centralBinomPowInt_map_rat] set f := centralBinomPowInt e (2 ^ r) have hdeg : f.natDegree = 2 ^ r := centralBinomPowInt_natDegree e (2 ^ r) have hprim : f.IsPrimitive := centralBinomPowInt_isPrimitive e (2 ^ r) have hpos : 0 < f.natDegree := by rw [hdeg]; positivity have hcop : Nat.Coprime f.natDegree (e : ℤ).natAbs := by rw [hdeg, Int.natAbs_natCast] exact (Nat.Prime.coprime_iff_not_dvd Nat.prime_two |>.mpr (by obtain ⟨m, rfl⟩ := he; omega)).pow_left r refine irreducible_of_dumas_single_segment (p := 2) (h := (e : ℤ)) hprim hpos hcop ?_ -- Show npLeft = 0 and npRight = 2^r (with npMinVal = 0) have hval : ∀ k ≤ 2 ^ r, padicValInt 2 (f.coeff k) = e * (Nat.digits 2 k).sum := by intro k hk dsimp [f] rw [centralBinomPowInt_coeff, if_pos hk, padicValInt.of_nat, padicValNat_pow_eq (Nat.centralBinom_pos k).ne' e, padicValNat_centralBinom_eq_sum_digits] have hw0 : npWeight 2 f.natDegree (e : ℤ) f 0 = 0 := by unfold npWeight rw [hval 0 (Nat.zero_le _)] simp have hwn : npWeight 2 f.natDegree (e : ℤ) f (2 ^ r) = 0 := by unfold npWeight rw [hval (2 ^ r) le_rfl, digits_two_sum_pow_two, mul_one, hdeg] ring have hge : ∀ k, f.coeff k ≠ 0 → 0 ≤ npWeight 2 f.natDegree (e : ℤ) f k := by intro k hk have hkle : k ≤ 2 ^ r := by by_contra hgt apply hk; dsimp [f]; rw [centralBinomPowInt_coeff, if_neg hgt] unfold npWeight rw [hval k hkle, hdeg] rcases k with _ | k · simp · have hs1 : 1 ≤ (Nat.digits 2 (k + 1)).sum := digits_two_sum_pos (Nat.succ_pos k) have he1 : 1 ≤ e := by obtain ⟨m, rfl⟩ := he; omega have hmul : e ≤ e * (Nat.digits 2 (k + 1)).sum := Nat.le_mul_of_pos_right e hs1 have hle_z : ((k + 1 : ℕ) : ℤ) ≤ ((2 ^ r : ℕ) : ℤ) := by exact_mod_cast hkle have hmul_z : (e : ℤ) ≤ ((e * (Nat.digits 2 (k + 1)).sum : ℕ) : ℤ) := by exact_mod_cast hmul have h2r_nn : (0 : ℤ) ≤ ((2 ^ r : ℕ) : ℤ) := by positivity have he_nn : (0 : ℤ) ≤ (e : ℤ) := by positivity nlinarith have hmin0 : npMinVal 2 f.natDegree (e : ℤ) f = 0 := by apply le_antisymm · rw [← hw0]; exact npMinVal_le (by dsimp [f]; rw [centralBinomPowInt_coeff, if_pos (Nat.zero_le _)]; simp [Nat.centralBinom]) · obtain ⟨k, hk⟩ := npAttain_nonempty (p := 2) (w := f.natDegree) (h := (e : ℤ)) hprim.ne_zero have hk' := Finset.mem_filter.mp hk rw [← hk'.2]; exact hge k (Polynomial.mem_support_iff.mp hk'.1) have hleft0 : npLeft 2 f.natDegree (e : ℤ) f = 0 := by apply Nat.eq_zero_of_le_zero exact npLeft_le_of_eq (by dsimp [f]; rw [centralBinomPowInt_coeff, if_pos (Nat.zero_le _)]; simp [Nat.centralBinom]) (hw0.trans hmin0.symm) have hrightn : npRight 2 f.natDegree (e : ℤ) f = f.natDegree := by apply le_antisymm (npRight_le_natDegree hprim.ne_zero) have hr := le_npRight_of_eq (p := 2) (w := f.natDegree) (h := (e : ℤ)) (g := f) (k := 2 ^ r) (by dsimp [f]; rw [centralBinomPowInt_coeff, if_pos le_rfl] exact Int.natCast_ne_zero.mpr (pow_pos (Nat.centralBinom_pos _) e).ne') (hwn.trans hmin0.symm) omega unfold npWidth; rw [hleft0, hrightn, Nat.sub_zero] /-! ### 4.2 Exact 2-adic Valuation of `qCoeff k` and Dumas Results for `Q_n` -/ /-- Exact 2-adic valuation identity for $c_k^Q$: $v_2(c_k^Q) + v_2(k + 1) = 2 s_2(k)$. -/ lemma padicValNat_qCoeff_add (k : ℕ) : padicValNat 2 (qCoeff k) + padicValNat 2 (k + 1) = 2 * (Nat.digits 2 k).sum := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ have h := congrArg (padicValNat 2) (qCoeff_mul_succ k) rw [padicValNat.mul (qCoeff_pos k).ne' (Nat.succ_ne_zero k), padicValNat_pow_eq (Nat.centralBinom_pos k).ne' 2, padicValNat_centralBinom_eq_sum_digits] at h exact h /-- Binary trailing-ones bound: $v_2(k + 1) \le s_2(k)$ for all $k \in \mathbb{N}$. -/ lemma padicValNat_succ_le_digits_sum (k : ℕ) : padicValNat 2 (k + 1) ≤ (Nat.digits 2 k).sum := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ have h1 := self_eq_padicValNat_factorial_add_sum_digits k have h2 := self_eq_padicValNat_factorial_add_sum_digits (k + 1) have hpos := digits_two_sum_pos (show 0 < k + 1 by omega) rw [Nat.factorial_succ, padicValNat.mul (Nat.succ_ne_zero k) (Nat.factorial_ne_zero k), Nat.succ_eq_add_one] at h2 omega /-- Exact lower bound on $v_2(c_k^Q)$: for $k \ge 2$, $v_2(c_k^Q) \ge 2$. -/ lemma two_le_padicValNat_qCoeff {k : ℕ} (hk : 2 ≤ k) : 2 ≤ padicValNat 2 (qCoeff k) := by have hadd := padicValNat_qCoeff_add k have hle := padicValNat_succ_le_digits_sum k have hs1 := digits_two_sum_pos (by omega : 0 < k) by_cases hs2 : 2 ≤ (Nat.digits 2 k).sum · omega · have hs_eq : (Nat.digits 2 k).sum = 1 := by omega obtain ⟨j, rfl⟩ := exists_pow_two_of_digits_sum_eq_one hs_eq have hj : 1 ≤ j := by rcases j with _ | j · norm_num at hk · exact Nat.succ_pos j have hodd : ¬ (2 ∣ 2 ^ j + 1) := by have : 2 ∣ 2 ^ j := dvd_pow_self 2 (by omega) omega have hv0 : padicValNat 2 (2 ^ j + 1) = 0 := padicValNat.eq_zero_of_not_dvd hodd omega /-- **Theorem 3 (Factor-Degree Dichotomy for $Q_{2^r}$)**: For every $r \ge 2$, every rational factor $u \mid Q_{2^r}(x)$ has degree divisible by $2^{r-1}$. In particular, $Q_{2^r}(x)$ is either irreducible over $\mathbb{Q}$ or a product of two irreducible factors of degree $2^{r-1}$. -/ theorem polyQ_two_pow_factor_deg_dvd {r : ℕ} (hr : 2 ≤ r) {u : ℚ[X]} (hdvd : u ∣ polyQ (2 ^ r)) : 2 ^ (r - 1) ∣ u.natDegree := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ rw [← polyQInt_map_rat] at hdvd set f := polyQInt (2 ^ r) set w := 2 ^ (r - 1) have hdeg : f.natDegree = 2 ^ r := polyQInt_natDegree (2 ^ r) have hprim : f.IsPrimitive := polyQInt_isPrimitive (2 ^ r) have hw2 : 2 * w = 2 ^ r := by dsimp [w]; rw [← pow_succ', Nat.sub_add_cancel (by omega)] have hw_ge2 : 2 ≤ w := by dsimp [w] calc 2 = 2 ^ 1 := by norm_num _ ≤ 2 ^ (r - 1) := Nat.pow_le_pow_right (by norm_num) (by omega) refine dumas_single_segment_dvd_natDegree (p := 2) (w := w) (h := 1) (by omega) (by simp) hprim ?_ hdvd have hval_top : padicValInt 2 (f.coeff (2 ^ r)) = 2 := by dsimp [f] rw [polyQInt_coeff, if_pos le_rfl, padicValInt.of_nat] have hadd := padicValNat_qCoeff_add (2 ^ r) rw [digits_two_sum_pow_two] at hadd have hodd : ¬ (2 ∣ 2 ^ r + 1) := by have : 2 ∣ 2 ^ r := dvd_pow_self 2 (by omega) omega have hv0 : padicValNat 2 (2 ^ r + 1) = 0 := padicValNat.eq_zero_of_not_dvd hodd omega have hw0 : npWeight 2 w 1 f 0 = 0 := by unfold npWeight; dsimp [f]; rw [polyQInt_coeff, if_pos (Nat.zero_le _)]; simp [qCoeff, Nat.centralBinom] have hwn : npWeight 2 w 1 f (2 ^ r) = 0 := by unfold npWeight; rw [hval_top]; omega have hge : ∀ k, f.coeff k ≠ 0 → 0 ≤ npWeight 2 w 1 f k := by intro k hk have hkle : k ≤ 2 ^ r := by by_contra hgt; apply hk; dsimp [f]; rw [polyQInt_coeff, if_neg hgt] unfold npWeight rcases k with _ | _ | k · dsimp [f]; rw [polyQInt_coeff, if_pos (Nat.zero_le _)]; simp [qCoeff, Nat.centralBinom] · have hv1 : padicValInt 2 (f.coeff 1) = 1 := by dsimp [f]; rw [polyQInt_coeff, if_pos (by omega : 1 ≤ 2 ^ r), padicValInt.of_nat] have hq1 : qCoeff 1 = 2 := rfl rw [hq1]; exact padicValNat.self (by norm_num) rw [hv1]; omega · have hv2 : 2 ≤ padicValInt 2 (f.coeff (k + 2)) := by dsimp [f]; rw [polyQInt_coeff, if_pos hkle, padicValInt.of_nat] exact two_le_padicValNat_qCoeff (by omega) have hv2_z : (2 : ℤ) ≤ (padicValInt 2 (f.coeff (k + 2)) : ℤ) := by exact_mod_cast hv2 have hkle_z : ((k + 2 : ℕ) : ℤ) ≤ 2 * (w : ℤ) := by exact_mod_cast (hw2.symm ▸ hkle) have hw_nn : (0 : ℤ) ≤ (w : ℤ) := by positivity nlinarith have hmin0 : npMinVal 2 w 1 f = 0 := by apply le_antisymm · rw [← hw0]; exact npMinVal_le (by rw [polyQInt_coeff_zero]; norm_num) · obtain ⟨k, hk⟩ := npAttain_nonempty (p := 2) (w := w) (h := 1) hprim.ne_zero have hk' := Finset.mem_filter.mp hk rw [← hk'.2]; exact hge k (Polynomial.mem_support_iff.mp hk'.1) have hleft0 : npLeft 2 w 1 f = 0 := Nat.eq_zero_of_le_zero (npLeft_le_of_eq (by rw [polyQInt_coeff_zero]; norm_num) (hw0.trans hmin0.symm)) have hrightn : npRight 2 w 1 f = f.natDegree := by apply le_antisymm (npRight_le_natDegree hprim.ne_zero) rw [hdeg] exact le_npRight_of_eq (by dsimp [f]; rw [polyQInt_coeff, if_pos le_rfl] exact Int.natCast_ne_zero.mpr (qCoeff_pos _).ne') (hwn.trans hmin0.symm) unfold npWidth; rw [hleft0, hrightn, Nat.sub_zero] /-- **Theorem 4 (Single-Segment 2-adic Dumas Irreducibility of $Q_1, Q_3, Q_7$)**: -/ theorem polyQ_irreducible_one : Irreducible (polyQ 1) := by rw [← polyQInt_map_rat] have hdeg : ((polyQInt 1).map (Int.castRingHom ℚ)).natDegree = 1 := by rw [Polynomial.natDegree_map_eq_of_injective (f := Int.castRingHom ℚ) Int.cast_injective, polyQInt_natDegree] have hne : (polyQInt 1).map (Int.castRingHom ℚ) ≠ 0 := fun h0 => by rw [h0, Polynomial.natDegree_zero] at hdeg; omega exact Polynomial.irreducible_of_degree_eq_one (by rw [Polynomial.degree_eq_natDegree hne, hdeg]; rfl) theorem polyQ_irreducible_three : Irreducible (polyQ 3) := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ rw [← polyQInt_map_rat] set f := polyQInt 3 have hdeg : f.natDegree = 3 := polyQInt_natDegree 3 have hprim : f.IsPrimitive := polyQInt_isPrimitive 3 refine irreducible_of_dumas_single_segment (p := 2) (h := 2) hprim (by omega) (by rw [hdeg]; decide) ?_ have hv : ∀ k ≤ 3, 2 * k ≤ 3 * padicValInt 2 (f.coeff k) := by intro k hk dsimp [f]; rw [polyQInt_coeff, if_pos hk, padicValInt.of_nat] interval_cases k · simp · have : padicValNat 2 (qCoeff 1) = 1 := by rw [show qCoeff 1 = 2 by rfl]; exact padicValNat.self (by norm_num) omega · have : 2 ≤ padicValNat 2 (qCoeff 2) := two_le_padicValNat_qCoeff (by omega) omega · have : padicValNat 2 (qCoeff 3) = 2 := by have hadd := padicValNat_qCoeff_add 3 have hd3 : (Nat.digits 2 3).sum = 2 := by decide have hv4 : padicValNat 2 (3 + 1) = 2 := by rw [show (3 + 1 : ℕ) = 2 ^ 2 by norm_num, padicValNat.prime_pow] omega omega have hw0 : npWeight 2 f.natDegree 2 f 0 = 0 := by unfold npWeight; rw [hdeg, polyQInt_coeff_zero]; simp have hw3 : npWeight 2 f.natDegree 2 f 3 = 0 := by unfold npWeight; rw [hdeg] have hv3 : padicValInt 2 (f.coeff 3) = 2 := by dsimp [f]; rw [polyQInt_coeff, if_pos le_rfl, padicValInt.of_nat] have hadd := padicValNat_qCoeff_add 3 have hd3 : (Nat.digits 2 3).sum = 2 := by decide have hv4 : padicValNat 2 (3 + 1) = 2 := by rw [show (3 + 1 : ℕ) = 2 ^ 2 by norm_num, padicValNat.prime_pow] omega rw [hv3]; norm_num have hmin0 : npMinVal 2 f.natDegree 2 f = 0 := by apply le_antisymm · rw [← hw0]; exact npMinVal_le (by rw [polyQInt_coeff_zero]; norm_num) · obtain ⟨k, hk⟩ := npAttain_nonempty (p := 2) (w := f.natDegree) (h := 2) hprim.ne_zero have hk' := Finset.mem_filter.mp hk have hkle : k ≤ 3 := by have := Polynomial.le_natDegree_of_mem_supp k hk'.1; omega rw [← hk'.2]; unfold npWeight; rw [hdeg] have := hv k hkle; omega have hleft0 := Nat.eq_zero_of_le_zero (npLeft_le_of_eq (by rw [polyQInt_coeff_zero]; norm_num) (hw0.trans hmin0.symm)) have hright3 : npRight 2 f.natDegree 2 f = 3 := le_antisymm (hdeg ▸ npRight_le_natDegree hprim.ne_zero) (le_npRight_of_eq (by dsimp [f]; rw [polyQInt_coeff, if_pos le_rfl]; exact Int.natCast_ne_zero.mpr (qCoeff_pos 3).ne') (hw3.trans hmin0.symm)) unfold npWidth; rw [hleft0, hright3, hdeg, Nat.sub_zero] theorem polyQ_irreducible_seven : Irreducible (polyQ 7) := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ rw [← polyQInt_map_rat] set f := polyQInt 7 have hdeg : f.natDegree = 7 := polyQInt_natDegree 7 have hprim : f.IsPrimitive := polyQInt_isPrimitive 7 refine irreducible_of_dumas_single_segment (p := 2) (h := 3) hprim (by omega) (by rw [hdeg]; decide) ?_ have hv7 : padicValInt 2 (f.coeff 7) = 3 := by dsimp [f]; rw [polyQInt_coeff, if_pos le_rfl, padicValInt.of_nat] have hadd := padicValNat_qCoeff_add 7 have hd7 : (Nat.digits 2 7).sum = 3 := by decide have hv8 : padicValNat 2 (7 + 1) = 3 := by rw [show (7 + 1 : ℕ) = 2 ^ 3 by norm_num, padicValNat.prime_pow] omega have hv_le : ∀ k ≤ 7, 3 * k ≤ 7 * padicValInt 2 (f.coeff k) := by intro k hk dsimp [f]; rw [polyQInt_coeff, if_pos hk, padicValInt.of_nat] have hadd := padicValNat_qCoeff_add k interval_cases k · simp · have : (Nat.digits 2 1).sum = 1 := by decide have : padicValNat 2 (1 + 1) = 1 := by rw [show (1 + 1 : ℕ) = 2 by norm_num]; exact padicValNat.self (by norm_num) omega · have : 2 ≤ padicValNat 2 (qCoeff 2) := two_le_padicValNat_qCoeff (by omega) omega · have : (Nat.digits 2 3).sum = 2 := by decide have : padicValNat 2 (3 + 1) = 2 := by rw [show (3 + 1 : ℕ) = 2 ^ 2 by norm_num, padicValNat.prime_pow] omega · have : (Nat.digits 2 4).sum = 1 := by decide have : padicValNat 2 (4 + 1) = 0 := padicValNat.eq_zero_of_not_dvd (by decide) omega · have : (Nat.digits 2 5).sum = 2 := by decide have : padicValNat 2 (5 + 1) = 1 := by rw [show (5 + 1 : ℕ) = 2 * 3 by norm_num, padicValNat.mul (by norm_num) (by norm_num), padicValNat.self (by norm_num), padicValNat.eq_zero_of_not_dvd (by decide)] omega · have : (Nat.digits 2 6).sum = 2 := by decide have : padicValNat 2 (6 + 1) = 0 := padicValNat.eq_zero_of_not_dvd (by decide) omega · have : (Nat.digits 2 7).sum = 3 := by decide have : padicValNat 2 (7 + 1) = 3 := by rw [show (7 + 1 : ℕ) = 2 ^ 3 by norm_num, padicValNat.prime_pow] omega have hw0 : npWeight 2 f.natDegree 3 f 0 = 0 := by unfold npWeight; rw [hdeg, polyQInt_coeff_zero]; simp have hw7 : npWeight 2 f.natDegree 3 f 7 = 0 := by unfold npWeight; rw [hdeg, hv7]; norm_num have hmin0 : npMinVal 2 f.natDegree 3 f = 0 := by apply le_antisymm · rw [← hw0]; exact npMinVal_le (by rw [polyQInt_coeff_zero]; norm_num) · obtain ⟨k, hk⟩ := npAttain_nonempty (p := 2) (w := f.natDegree) (h := 3) hprim.ne_zero have hk' := Finset.mem_filter.mp hk have hkle : k ≤ 7 := by have := Polynomial.le_natDegree_of_mem_supp k hk'.1; omega rw [← hk'.2]; unfold npWeight; rw [hdeg] have := hv_le k hkle; omega have hleft0 := Nat.eq_zero_of_le_zero (npLeft_le_of_eq (by rw [polyQInt_coeff_zero]; norm_num) (hw0.trans hmin0.symm)) have hright7 : npRight 2 f.natDegree 3 f = 7 := le_antisymm (hdeg ▸ npRight_le_natDegree hprim.ne_zero) (le_npRight_of_eq (by dsimp [f]; rw [polyQInt_coeff, if_pos le_rfl]; exact Int.natCast_ne_zero.mpr (qCoeff_pos 7).ne') (hw7.trans hmin0.symm)) unfold npWidth; rw [hleft0, hright7, hdeg, Nat.sub_zero] /-! ### 4.3 Universal Even-Factor-Degree Law for `4 ∣ n` (Both `P_{4m}` and `Q_{4m}`) -/ /-- Binary splitting of digit sums: $s_2(q \cdot 2^e + r) = s_2(q) + s_2(r)$ for $r < 2^e$. -/ lemma digits_two_sum_mul_pow_add (e : ℕ) : ∀ q r : ℕ, r < 2 ^ e → (Nat.digits 2 (q * 2 ^ e + r)).sum = (Nat.digits 2 q).sum + (Nat.digits 2 r).sum := by induction e with | zero => intro q r hr have hr0 : r = 0 := by omega subst hr0; simp | succ e ih => intro q r hr by_cases hqz : q = 0 · subst hqz; simp · have hpos : 0 < q * 2 ^ (e + 1) + r := Nat.add_pos_left (Nat.mul_pos (Nat.pos_of_ne_zero hqz) (by positivity)) r rw [Nat.digits_def' (by norm_num : 1 < 2) hpos] simp only [List.sum_cons] have hdiv : (q * 2 ^ (e + 1) + r) / 2 = q * 2 ^ e + r / 2 := by rw [pow_succ', show q * (2 * 2 ^ e) + r = r + 2 * (q * 2 ^ e) by ring, Nat.add_mul_div_left _ _ (by norm_num : 0 < 2)] ring have hmod : (q * 2 ^ (e + 1) + r) % 2 = r % 2 := by rw [pow_succ', show q * (2 * 2 ^ e) + r = r + 2 * (q * 2 ^ e) by ring, Nat.add_mul_mod_self_left] rw [hdiv, hmod, ih q (r / 2) (by rw [pow_succ'] at hr; omega)] rcases r with _ | r · simp · have hpos_r : 0 < r + 1 := Nat.succ_pos r rw [Nat.digits_def' (by norm_num : 1 < 2) hpos_r] simp only [List.sum_cons]; omega /-- Monotonicity of $v_2(k!)$: if $a \le b$, then $v_2(a!) \le v_2(b!)$. -/ lemma padicValNat_factorial_mono {a b : ℕ} (hab : a ≤ b) : padicValNat 2 a.factorial ≤ padicValNat 2 b.factorial := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ exact (padicValNat_dvd_iff_le (Nat.factorial_ne_zero b)).mp (pow_padicValNat_dvd.trans (Nat.factorial_dvd_factorial hab)) /-- List of strictly decreasing bit positions of `n` (returning bit exponents `e` with `(n / 2^e) % 2 = 1`, from highest bit down to lowest bit). -/ def bitPositionsAux : ℕ → ℕ → List ℕ | 0, _ => [] | b + 1, n => if (n / 2 ^ b) % 2 = 1 then b :: bitPositionsAux b n else bitPositionsAux b n lemma bitPositionsAux_mem_iff (b n e : ℕ) : e ∈ bitPositionsAux b n ↔ e < b ∧ (n / 2 ^ e) % 2 = 1 := by induction b with | zero => simp [bitPositionsAux] | succ b ih => unfold bitPositionsAux split_ifs with hbit · simp only [List.mem_cons, ih] constructor · rintro (rfl | ⟨hlt, h1⟩) · exact ⟨Nat.lt_succ_self e, hbit⟩ · exact ⟨Nat.lt_succ_of_lt hlt, h1⟩ · rintro ⟨hlt, h1⟩ rcases Nat.lt_succ_iff_lt_or_eq.mp hlt with hlt' | rfl · exact Or.inr ⟨hlt', h1⟩ · exact Or.inl rfl · rw [ih] constructor · rintro ⟨hlt, h1⟩; exact ⟨Nat.lt_succ_of_lt hlt, h1⟩ · rintro ⟨hlt, h1⟩ rcases Nat.lt_succ_iff_lt_or_eq.mp hlt with hlt' | rfl · exact ⟨hlt', h1⟩ · exact absurd h1 hbit lemma bitPositionsAux_chain (b n : ℕ) : (bitPositionsAux b n).IsChain (· > ·) := by induction b with | zero => simp [bitPositionsAux] | succ b ih => unfold bitPositionsAux split_ifs with hbit · cases hL : bitPositionsAux b n with | nil => simp | cons e tl => rw [List.isChain_cons_cons] have he_mem : e ∈ bitPositionsAux b n := by rw [hL]; simp have he_lt : e < b := ((bitPositionsAux_mem_iff b n e).mp he_mem).1 exact ⟨he_lt, hL ▸ ih⟩ · exact ih lemma bitPositionsAux_sum (b n : ℕ) : ((bitPositionsAux b n).map fun e => 2 ^ e).sum = n % 2 ^ b := by induction b with | zero => simp [bitPositionsAux, Nat.mod_one] | succ b ih => unfold bitPositionsAux have hsplit : n % 2 ^ (b + 1) = (n / 2 ^ b) % 2 * 2 ^ b + n % 2 ^ b := by have h1 := Nat.div_add_mod n (2 ^ b) have h2 := Nat.div_add_mod (n / 2 ^ b) 2 have h3 : n = (n / 2 ^ b / 2) * 2 ^ (b + 1) + ((n / 2 ^ b) % 2 * 2 ^ b + n % 2 ^ b) := by rw [pow_succ'] have h2' : (n / 2 ^ b) * 2 ^ b = (n / 2 ^ b / 2) * (2 * 2 ^ b) + (n / 2 ^ b) % 2 * 2 ^ b := by have := congrArg (· * 2 ^ b) h2 linarith linarith [mul_comm (2 ^ b) (n / 2 ^ b)] have hlt : (n / 2 ^ b) % 2 * 2 ^ b + n % 2 ^ b < 2 ^ (b + 1) := by have hm1 : (n / 2 ^ b) % 2 ≤ 1 := by omega have hm2 : n % 2 ^ b < 2 ^ b := Nat.mod_lt n (by positivity) have h2b : 0 < 2 ^ b := by positivity rw [pow_succ'] have : (n / 2 ^ b) % 2 * 2 ^ b ≤ 1 * 2 ^ b := Nat.mul_le_mul_right _ hm1 omega conv_lhs => rw [h3] rw [Nat.mul_add_mod_self_right, Nat.mod_eq_of_lt hlt] split_ifs with hbit · simp only [List.map_cons, List.sum_cons, ih, hsplit, hbit, one_mul] · have h0 : (n / 2 ^ b) % 2 = 0 := by omega rw [ih, hsplit, h0, zero_mul, zero_add] /-- Lower bound on the Newton-polygon width of `polyPInt n` at each active bit `e ≥ 1` of `n`: `2 ^ e ≤ npWidth 2 (2 ^ (e - 1)) 1 (polyPInt n)`. -/ lemma pow_two_le_npWidth_polyPInt {n e : ℕ} (he : 1 ≤ e) (hbit : (n / 2 ^ e) % 2 = 1) : 2 ^ e ≤ npWidth 2 (2 ^ (e - 1)) 1 (polyPInt n) := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ set w := 2 ^ (e - 1) have hw2 : 2 * w = 2 ^ e := by dsimp [w]; rw [← pow_succ', Nat.sub_add_cancel he] set q₀ := n / 2 ^ e with hq₀_def have hq₀_odd : q₀ % 2 = 1 := hbit have hq₀_pos : 1 ≤ q₀ := Nat.pos_of_ne_zero (fun h0 => by rw [h0] at hq₀_odd; norm_num at hq₀_odd) set k₁ := (q₀ - 1) * 2 ^ e set k₂ := q₀ * 2 ^ e have hk₂_le : k₂ ≤ n := by dsimp [k₂]; rw [hq₀_def, mul_comm]; exact Nat.mul_div_le n (2 ^ e) have hk₁_le : k₁ ≤ n := le_trans (Nat.mul_le_mul_right _ (Nat.sub_le q₀ 1)) hk₂_le -- Express npWeight 2 w 1 (polyPInt n) k for any k ≤ n have hwt : ∀ k ≤ n, npWeight 2 w 1 (polyPInt n) k = ((2 : ℤ) ^ e) * ((Nat.digits 2 k).sum : ℤ) - (k : ℤ) := by intro k hk unfold npWeight rw [polyPInt_coeff, if_pos hk, padicValInt.of_nat] have hv : padicValNat 2 (pCoeff k) = 2 * (Nat.digits 2 k).sum := by unfold pCoeff rw [padicValNat_pow_eq (Nat.centralBinom_pos k).ne' 2, padicValNat_centralBinom_eq_sum_digits] rw [hv, one_mul, Nat.cast_mul, Nat.cast_ofNat] have hw2_z : (2 : ℤ) * (w : ℤ) = (2 : ℤ) ^ e := by exact_mod_cast hw2 nlinarith -- Target minimum weight M = - 2^e * v_2(q₀!) set M : ℤ := -((2 : ℤ) ^ e) * (padicValNat 2 q₀.factorial : ℤ) have hwt_k₂ : npWeight 2 w 1 (polyPInt n) k₂ = M := by rw [hwt k₂ hk₂_le] have hd : (Nat.digits 2 (q₀ * 2 ^ e)).sum = (Nat.digits 2 q₀).sum := by simpa using digits_two_sum_mul_pow_add e q₀ 0 (by positivity) have hleg := self_eq_padicValNat_factorial_add_sum_digits q₀ have hk₂_z : (k₂ : ℤ) = (q₀ : ℤ) * (2 : ℤ) ^ e := by simp only [k₂, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] rw [show (Nat.digits 2 k₂).sum = (Nat.digits 2 q₀).sum from hd, hk₂_z] have hleg_z : (q₀ : ℤ) = (padicValNat 2 q₀.factorial : ℤ) + ((Nat.digits 2 q₀).sum : ℤ) := by exact_mod_cast hleg dsimp [M]; rw [hleg_z]; ring have hwt_k₁ : npWeight 2 w 1 (polyPInt n) k₁ = M := by rw [hwt k₁ hk₁_le] have hd : (Nat.digits 2 ((q₀ - 1) * 2 ^ e)).sum = (Nat.digits 2 (q₀ - 1)).sum := by simpa using digits_two_sum_mul_pow_add e (q₀ - 1) 0 (by positivity) have hleg := self_eq_padicValNat_factorial_add_sum_digits (q₀ - 1) have hv_eq : padicValNat 2 q₀.factorial = padicValNat 2 (q₀ - 1).factorial := by have hq : q₀ = (q₀ - 1) + 1 := by omega conv_lhs => rw [hq, Nat.factorial_succ, padicValNat.mul (Nat.succ_ne_zero _) (Nat.factorial_ne_zero _)] have hodd : padicValNat 2 ((q₀ - 1) + 1) = 0 := padicValNat.eq_zero_of_not_dvd (by omega) rw [Nat.succ_eq_add_one, hodd, zero_add] have hk₁_z : (k₁ : ℤ) = ((q₀ - 1 : ℕ) : ℤ) * (2 : ℤ) ^ e := by simp only [k₁, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] rw [show (Nat.digits 2 k₁).sum = (Nat.digits 2 (q₀ - 1)).sum from hd, hk₁_z] have hleg_z : ((q₀ - 1 : ℕ) : ℤ) = (padicValNat 2 (q₀ - 1).factorial : ℤ) + ((Nat.digits 2 (q₀ - 1)).sum : ℤ) := by exact_mod_cast hleg dsimp [M]; rw [hv_eq, hleg_z]; ring -- Every nonzero coeff has weight ≥ M have hge_M : ∀ k, (polyPInt n).coeff k ≠ 0 → M ≤ npWeight 2 w 1 (polyPInt n) k := by intro k hk have hkle : k ≤ n := by by_contra hgt; apply hk; rw [polyPInt_coeff, if_neg hgt] rw [hwt k hkle] set q := k / 2 ^ e with hq_def set r := k % 2 ^ e with hr_def have hkr : k = q * 2 ^ e + r := by rw [hq_def, hr_def, mul_comm]; exact (Nat.div_add_mod k (2 ^ e)).symm have hr_lt : r < 2 ^ e := Nat.mod_lt k (by positivity) have hq_le : q ≤ q₀ := Nat.div_le_div_right hkle have hd := digits_two_sum_mul_pow_add e q r hr_lt have hleg := self_eq_padicValNat_factorial_add_sum_digits q have hmono := padicValNat_factorial_mono hq_le have hr_bound : (r : ℤ) ≤ ((2 : ℤ) ^ e) * ((Nat.digits 2 r).sum : ℤ) := by rcases r with _ | r · simp · have hs1 : 1 ≤ (Nat.digits 2 (r + 1)).sum := digits_two_sum_pos (show 0 < r + 1 by omega) have h1 : ((r + 1 : ℕ) : ℤ) ≤ (2 : ℤ) ^ e := by exact_mod_cast hr_lt.le have h2 : (1 : ℤ) ≤ ((Nat.digits 2 (r + 1)).sum : ℤ) := by exact_mod_cast hs1 have h3 : (0 : ℤ) ≤ (2 : ℤ) ^ e := by positivity nlinarith have hk_z : (k : ℤ) = (q : ℤ) * (2 : ℤ) ^ e + (r : ℤ) := by rw [hkr]; push_cast; rfl have hdk_z : ((Nat.digits 2 k).sum : ℤ) = ((Nat.digits 2 q).sum : ℤ) + ((Nat.digits 2 r).sum : ℤ) := by rw [hkr, hd, Nat.cast_add] rw [hk_z, hdk_z] have hleg_z : (q : ℤ) = (padicValNat 2 q.factorial : ℤ) + ((Nat.digits 2 q).sum : ℤ) := by exact_mod_cast hleg have hmono_z : (padicValNat 2 q.factorial : ℤ) ≤ (padicValNat 2 q₀.factorial : ℤ) := by exact_mod_cast hmono have h2e_nn : (0 : ℤ) ≤ (2 : ℤ) ^ e := by positivity dsimp [M] have hq_term : -((2 : ℤ) ^ e) * (padicValNat 2 q₀.factorial : ℤ) ≤ ((2 : ℤ) ^ e) * ((Nat.digits 2 q).sum : ℤ) - (q : ℤ) * ((2 : ℤ) ^ e) := by rw [hleg_z]; nlinarith linarith have hmin_eq : npMinVal 2 w 1 (polyPInt n) = M := by apply le_antisymm · rw [← hwt_k₂] exact npMinVal_le (by rw [polyPInt_coeff, if_pos hk₂_le]; exact Int.natCast_ne_zero.mpr (pCoeff_pos _).ne') · obtain ⟨k, hk⟩ := npAttain_nonempty (p := 2) (w := w) (h := 1) (polyPInt_isPrimitive n).ne_zero have hk' := Finset.mem_filter.mp hk rw [← hk'.2]; exact hge_M k (Polynomial.mem_support_iff.mp hk'.1) have hl : npLeft 2 w 1 (polyPInt n) ≤ k₁ := npLeft_le_of_eq (by rw [polyPInt_coeff, if_pos hk₁_le]; exact Int.natCast_ne_zero.mpr (pCoeff_pos _).ne') (hwt_k₁.trans hmin_eq.symm) have hr : k₂ ≤ npRight 2 w 1 (polyPInt n) := le_npRight_of_eq (by rw [polyPInt_coeff, if_pos hk₂_le]; exact Int.natCast_ne_zero.mpr (pCoeff_pos _).ne') (hwt_k₂.trans hmin_eq.symm) unfold npWidth have hdiff : k₂ - k₁ = 2 ^ e := by dsimp [k₁, k₂] rw [← Nat.sub_mul, Nat.sub_sub_self hq₀_pos, one_mul] omega /-- Helper: for `r + 1 < 2 ^ e`, `v₂(q * 2^e + r + 1) = v₂(r + 1)`. -/ lemma padicValNat_two_mul_pow_add_succ {e q r : ℕ} (hr : r + 1 < 2 ^ e) : padicValNat 2 (q * 2 ^ e + r + 1) = padicValNat 2 (r + 1) := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ have hlt_e : padicValNat 2 (r + 1) < e := by by_contra hge have hpow : 2 ^ e ∣ r + 1 := (pow_dvd_pow 2 (by omega : e ≤ padicValNat 2 (r + 1))).trans pow_padicValNat_dvd have := Nat.le_of_dvd (show 0 < r + 1 by omega) hpow omega set v := padicValNat 2 (r + 1) with hv_def have hdv : 2 ^ v ∣ r + 1 := pow_padicValNat_dvd have hndv : ¬ 2 ^ (v + 1) ∣ r + 1 := by intro hd have hle := (padicValNat_dvd_iff_le (show r + 1 ≠ 0 by omega)).mp hd rw [← hv_def] at hle; omega have hdv_k1 : 2 ^ v ∣ q * 2 ^ e + (r + 1) := dvd_add (dvd_mul_of_dvd_right (pow_dvd_pow 2 (by omega : v ≤ e)) q) hdv have hndv_k1 : ¬ 2 ^ (v + 1) ∣ q * 2 ^ e + (r + 1) := by intro hd exact hndv ((Nat.dvd_add_right (dvd_mul_of_dvd_right (pow_dvd_pow 2 (by omega : v + 1 ≤ e)) q)).mp hd) have hsum : q * 2 ^ e + r + 1 = q * 2 ^ e + (r + 1) := by omega rw [hsum] have hle1 : v ≤ padicValNat 2 (q * 2 ^ e + (r + 1)) := (padicValNat_dvd_iff_le (by omega)).mp hdv_k1 have hle2 : padicValNat 2 (q * 2 ^ e + (r + 1)) ≤ v := by by_contra hgt exact hndv_k1 ((padicValNat_dvd_iff_le (by omega)).mpr (by omega)) omega /-- Helper: weight lower bound for `polyQInt (4 * m)` at slope `1 / 2^(e - 1)` for `e ≥ 2`. -/ lemma polyQInt_four_mul_weight_ge {m e k : ℕ} (he : 2 ≤ e) (hkle : k ≤ 4 * m) : -((2 : ℤ) ^ e) * (padicValNat 2 ((4 * m) / 2 ^ e).factorial : ℤ) ≤ npWeight 2 (2 ^ (e - 1)) 1 (polyQInt (4 * m)) k := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ set n := 4 * m set w := 2 ^ (e - 1) have hw2 : 2 * w = 2 ^ e := by dsimp [w]; rw [← pow_succ', Nat.sub_add_cancel (by omega)] have hw2_z : (2 : ℤ) * (w : ℤ) = (2 : ℤ) ^ e := by exact_mod_cast hw2 set q₀ := n / 2 ^ e with hq₀_def have hwt_k : npWeight 2 w 1 (polyQInt n) k = ((2 : ℤ) ^ e) * ((Nat.digits 2 k).sum : ℤ) - (w : ℤ) * (padicValNat 2 (k + 1) : ℤ) - (k : ℤ) := by unfold npWeight rw [polyQInt_coeff, if_pos hkle, padicValInt.of_nat, one_mul] have hadd := padicValNat_qCoeff_add k have hadd_z : (padicValNat 2 (qCoeff k) : ℤ) + (padicValNat 2 (k + 1) : ℤ) = 2 * ((Nat.digits 2 k).sum : ℤ) := by exact_mod_cast hadd nlinarith rw [hwt_k] set q := k / 2 ^ e with hq_def set r := k % 2 ^ e with hr_def have hkr : k = q * 2 ^ e + r := by rw [hq_def, hr_def, mul_comm]; exact (Nat.div_add_mod k (2 ^ e)).symm have hr_lt : r < 2 ^ e := Nat.mod_lt k (by positivity) have hq_le : q ≤ q₀ := Nat.div_le_div_right hkle have hd := digits_two_sum_mul_pow_add e q r hr_lt by_cases hrmax : r = 2 ^ e - 1 · have hq1_le : q + 1 ≤ q₀ := by by_contra hgt have hqeq : q = q₀ := by omega have hdiv_n : q₀ * 2 ^ e + n % 2 ^ e = n := by rw [hq₀_def, mul_comm]; exact Nat.div_add_mod n (2 ^ e) have hnrem_lt : n % 2 ^ e < 2 ^ e := Nat.mod_lt n (by positivity) have hrem : n % 2 ^ e = 2 ^ e - 1 := by have : q₀ * 2 ^ e + (2 ^ e - 1) ≤ q₀ * 2 ^ e + n % 2 ^ e := by rw [hdiv_n, ← hqeq, ← hrmax, ← hkr]; exact hkle omega have h4_2e : 4 ∣ 2 ^ e := by calc 4 = 2 ^ 2 := by norm_num _ ∣ 2 ^ e := pow_dvd_pow 2 he have h4_rem : 4 ∣ n % 2 ^ e := (Nat.dvd_mod_iff h4_2e).mpr ⟨m, rfl⟩ rw [hrem] at h4_rem obtain ⟨a, ha⟩ := h4_2e obtain ⟨b, hb⟩ := h4_rem omega have hk1_eq : k + 1 = (q + 1) * 2 ^ e := by rw [hkr, hrmax, add_mul, one_mul] have : 1 ≤ 2 ^ e := Nat.one_le_two_pow; omega have hv_k1 : padicValNat 2 (k + 1) = e + padicValNat 2 (q + 1) := by rw [hk1_eq, padicValNat.mul (Nat.succ_ne_zero q) (by positivity), padicValNat.prime_pow, add_comm] have hs_r : (Nat.digits 2 r).sum = e := by rw [hrmax] have hleg1 := self_eq_padicValNat_factorial_add_sum_digits (2 ^ e - 1) have hleg2 := self_eq_padicValNat_factorial_add_sum_digits (2 ^ e) rw [digits_two_sum_pow_two] at hleg2 have hfac : (2 ^ e).factorial = 2 ^ e * (2 ^ e - 1).factorial := by have h1 : 2 ^ e = (2 ^ e - 1) + 1 := by have : 1 ≤ 2 ^ e := Nat.one_le_two_pow; omega conv_lhs => rw [h1, Nat.factorial_succ] rw [← h1] rw [hfac, padicValNat.mul (by positivity) (Nat.factorial_ne_zero _), padicValNat.prime_pow] at hleg2 omega have hleg_q := self_eq_padicValNat_factorial_add_sum_digits q have hmono := padicValNat_factorial_mono hq1_le have hk_z : (k : ℤ) = (q : ℤ) * (2 : ℤ) ^ e + (r : ℤ) := by rw [hkr]; simp only [Nat.cast_add, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] have hdk_z : ((Nat.digits 2 k).sum : ℤ) = ((Nat.digits 2 q).sum : ℤ) + (e : ℤ) := by rw [hkr, hd, hs_r, Nat.cast_add] rw [hv_k1, hk_z, hdk_z, Nat.cast_add] have h2e_pos : (1 : ℕ) ≤ 2 ^ e := Nat.one_le_two_pow have hr_z : (r : ℤ) = (2 : ℤ) ^ e - 1 := by have : (r : ℤ) = ((2 ^ e : ℕ) : ℤ) - 1 := by rw [hrmax]; omega simpa using this have hleg_q_z : (q : ℤ) = (padicValNat 2 q.factorial : ℤ) + ((Nat.digits 2 q).sum : ℤ) := by exact_mod_cast hleg_q have hmono_z : (padicValNat 2 q.factorial : ℤ) + (padicValNat 2 (q + 1) : ℤ) ≤ (padicValNat 2 q₀.factorial : ℤ) := by have hfac_q1 : padicValNat 2 (q + 1).factorial = padicValNat 2 (q + 1) + padicValNat 2 q.factorial := by rw [Nat.factorial_succ, padicValNat.mul (Nat.succ_ne_zero q) (Nat.factorial_ne_zero q), Nat.succ_eq_add_one] rw [hfac_q1] at hmono exact_mod_cast (by omega : padicValNat 2 q.factorial + padicValNat 2 (q + 1) ≤ padicValNat 2 q₀.factorial) have he_z : (2 : ℤ) ≤ (e : ℤ) := by exact_mod_cast he have hw_nn : (0 : ℤ) ≤ (w : ℤ) := by positivity have hvq1_nn : (0 : ℤ) ≤ (padicValNat 2 (q + 1) : ℤ) := by positivity have hterm1 : (0 : ℤ) ≤ (w : ℤ) * ((e : ℤ) + (padicValNat 2 (q + 1) : ℤ) - 2) := mul_nonneg hw_nn (by linarith) have hterm2 : -((2 : ℤ) ^ e) * (padicValNat 2 q₀.factorial : ℤ) ≤ -((2 : ℤ) ^ e) * ((padicValNat 2 q.factorial : ℤ) + (padicValNat 2 (q + 1) : ℤ)) := by have h2e_nn : (0 : ℤ) ≤ (2 : ℤ) ^ e := by positivity nlinarith have hident : ((2 : ℤ) ^ e) * (((Nat.digits 2 q).sum : ℤ) + (e : ℤ)) - (w : ℤ) * ((e : ℤ) + (padicValNat 2 (q + 1) : ℤ)) - ((q : ℤ) * ((2 : ℤ) ^ e) + (r : ℤ)) = -((2 : ℤ) ^ e) * ((padicValNat 2 q.factorial : ℤ) + (padicValNat 2 (q + 1) : ℤ)) + (w : ℤ) * ((e : ℤ) + (padicValNat 2 (q + 1) : ℤ) - 2) + 1 := by rw [hr_z, hleg_q_z, ← hw2_z]; ring rw [hident]; linarith · have hr1_lt : r + 1 < 2 ^ e := by omega have hv_eq : padicValNat 2 (k + 1) = padicValNat 2 (r + 1) := by rw [hkr]; exact padicValNat_two_mul_pow_add_succ hr1_lt have hr_bound : (r : ℤ) ≤ ((2 : ℤ) ^ e) * ((Nat.digits 2 r).sum : ℤ) - (w : ℤ) * (padicValNat 2 (r + 1) : ℤ) := by rcases r with _ | _ | r' · simp · have hv2 : padicValNat 2 (1 + 1) = 1 := by rw [show (1 + 1 : ℕ) = 2 by norm_num]; exact padicValNat.self (by norm_num) have hd1 : (Nat.digits 2 1).sum = 1 := by decide have hw_ge2 : (2 : ℤ) ≤ (w : ℤ) := by have : 2 ≤ 2 ^ (e - 1) := by calc 2 = 2 ^ 1 := by norm_num _ ≤ 2 ^ (e - 1) := Nat.pow_le_pow_right (by norm_num) (by omega) exact_mod_cast this rw [hd1, hv2, ← hw2_z]; omega · have hvr_eq := padicValNat_qCoeff_add (r' + 2) have hvq : 2 ≤ padicValNat 2 (qCoeff (r' + 2)) := two_le_padicValNat_qCoeff (by omega) have hq_z : (2 : ℤ) ≤ 2 * ((Nat.digits 2 (r' + 2)).sum : ℤ) - (padicValNat 2 (r' + 2 + 1) : ℤ) := by omega have hrl_z : ((r' + 2 : ℕ) : ℤ) ≤ (2 : ℤ) ^ e := by exact_mod_cast hr_lt.le have hw_nn : (0 : ℤ) ≤ (w : ℤ) := by positivity have hmul_w := mul_le_mul_of_nonneg_left hq_z hw_nn have h2w_eq : (w : ℤ) * (2 * ((Nat.digits 2 (r' + 2)).sum : ℤ) - (padicValNat 2 (r' + 2 + 1) : ℤ)) = ((2 : ℤ) ^ e) * ((Nat.digits 2 (r' + 2)).sum : ℤ) - (w : ℤ) * (padicValNat 2 (r' + 2 + 1) : ℤ) := by rw [← hw2_z]; ring linarith have hleg := self_eq_padicValNat_factorial_add_sum_digits q have hmono := padicValNat_factorial_mono hq_le have hk_z : (k : ℤ) = (q : ℤ) * (2 : ℤ) ^ e + (r : ℤ) := by rw [hkr]; simp only [Nat.cast_add, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] have hdk_z : ((Nat.digits 2 k).sum : ℤ) = ((Nat.digits 2 q).sum : ℤ) + ((Nat.digits 2 r).sum : ℤ) := by rw [hkr, hd, Nat.cast_add] rw [hv_eq, hk_z, hdk_z] have hleg_z : (q : ℤ) = (padicValNat 2 q.factorial : ℤ) + ((Nat.digits 2 q).sum : ℤ) := by exact_mod_cast hleg have hmono_z : (padicValNat 2 q.factorial : ℤ) ≤ (padicValNat 2 q₀.factorial : ℤ) := by exact_mod_cast hmono have h2e_nn : (0 : ℤ) ≤ (2 : ℤ) ^ e := by positivity have hq_term : -((2 : ℤ) ^ e) * (padicValNat 2 q₀.factorial : ℤ) ≤ ((2 : ℤ) ^ e) * ((Nat.digits 2 q).sum : ℤ) - (q : ℤ) * ((2 : ℤ) ^ e) := by rw [hleg_z]; nlinarith linarith /-- Lower bound on the Newton-polygon width of `polyQInt (4 * m)` at each active bit `e ≥ 2`: `2 ^ e ≤ npWidth 2 (2 ^ (e - 1)) 1 (polyQInt (4 * m))`. -/ lemma pow_two_le_npWidth_polyQInt_four_mul {m e : ℕ} (he : 2 ≤ e) (hbit : ((4 * m) / 2 ^ e) % 2 = 1) : 2 ^ e ≤ npWidth 2 (2 ^ (e - 1)) 1 (polyQInt (4 * m)) := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ set n := 4 * m set w := 2 ^ (e - 1) have hw2 : 2 * w = 2 ^ e := by dsimp [w]; rw [← pow_succ', Nat.sub_add_cancel (by omega)] set q₀ := n / 2 ^ e with hq₀_def have hq₀_odd : q₀ % 2 = 1 := hbit have hq₀_pos : 1 ≤ q₀ := Nat.pos_of_ne_zero (fun h0 => by rw [h0] at hq₀_odd; norm_num at hq₀_odd) set k₁ := (q₀ - 1) * 2 ^ e set k₂ := q₀ * 2 ^ e have hk₂_le : k₂ ≤ n := by dsimp [k₂]; rw [hq₀_def, mul_comm]; exact Nat.mul_div_le n (2 ^ e) have hk₁_le : k₁ ≤ n := le_trans (Nat.mul_le_mul_right _ (Nat.sub_le q₀ 1)) hk₂_le have hwt : ∀ k ≤ n, npWeight 2 w 1 (polyQInt n) k = ((2 : ℤ) ^ e) * ((Nat.digits 2 k).sum : ℤ) - (w : ℤ) * (padicValNat 2 (k + 1) : ℤ) - (k : ℤ) := by intro k hk unfold npWeight rw [polyQInt_coeff, if_pos hk, padicValInt.of_nat, one_mul] have hadd := padicValNat_qCoeff_add k have hadd_z : (padicValNat 2 (qCoeff k) : ℤ) + (padicValNat 2 (k + 1) : ℤ) = 2 * ((Nat.digits 2 k).sum : ℤ) := by exact_mod_cast hadd have hw2_z : (2 : ℤ) * (w : ℤ) = (2 : ℤ) ^ e := by exact_mod_cast hw2 nlinarith set M : ℤ := -((2 : ℤ) ^ e) * (padicValNat 2 q₀.factorial : ℤ) have hv_k₂_succ : padicValNat 2 (k₂ + 1) = 0 := by apply padicValNat.eq_zero_of_not_dvd have : 2 ∣ k₂ := dvd_mul_of_dvd_right (dvd_pow_self 2 (by omega)) _ omega have hv_k₁_succ : padicValNat 2 (k₁ + 1) = 0 := by apply padicValNat.eq_zero_of_not_dvd have : 2 ∣ k₁ := dvd_mul_of_dvd_right (dvd_pow_self 2 (by omega)) _ omega have hwt_k₂ : npWeight 2 w 1 (polyQInt n) k₂ = M := by rw [hwt k₂ hk₂_le, hv_k₂_succ] have hd : (Nat.digits 2 (q₀ * 2 ^ e)).sum = (Nat.digits 2 q₀).sum := by simpa using digits_two_sum_mul_pow_add e q₀ 0 (by positivity) have hleg := self_eq_padicValNat_factorial_add_sum_digits q₀ have hk₂_z : (k₂ : ℤ) = (q₀ : ℤ) * (2 : ℤ) ^ e := by simp only [k₂, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] rw [show (Nat.digits 2 k₂).sum = (Nat.digits 2 q₀).sum from hd, hk₂_z] have hleg_z : (q₀ : ℤ) = (padicValNat 2 q₀.factorial : ℤ) + ((Nat.digits 2 q₀).sum : ℤ) := by exact_mod_cast hleg dsimp [M]; simp only [mul_zero, sub_zero]; rw [hleg_z]; ring have hwt_k₁ : npWeight 2 w 1 (polyQInt n) k₁ = M := by rw [hwt k₁ hk₁_le, hv_k₁_succ] have hd : (Nat.digits 2 ((q₀ - 1) * 2 ^ e)).sum = (Nat.digits 2 (q₀ - 1)).sum := by simpa using digits_two_sum_mul_pow_add e (q₀ - 1) 0 (by positivity) have hleg := self_eq_padicValNat_factorial_add_sum_digits (q₀ - 1) have hv_eq : padicValNat 2 q₀.factorial = padicValNat 2 (q₀ - 1).factorial := by have hq : q₀ = (q₀ - 1) + 1 := by omega conv_lhs => rw [hq, Nat.factorial_succ, padicValNat.mul (Nat.succ_ne_zero _) (Nat.factorial_ne_zero _)] have hodd : padicValNat 2 ((q₀ - 1) + 1) = 0 := padicValNat.eq_zero_of_not_dvd (by omega) rw [Nat.succ_eq_add_one, hodd, zero_add] have hk₁_z : (k₁ : ℤ) = ((q₀ - 1 : ℕ) : ℤ) * (2 : ℤ) ^ e := by simp only [k₁, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] rw [show (Nat.digits 2 k₁).sum = (Nat.digits 2 (q₀ - 1)).sum from hd, hk₁_z] have hleg_z : ((q₀ - 1 : ℕ) : ℤ) = (padicValNat 2 (q₀ - 1).factorial : ℤ) + ((Nat.digits 2 (q₀ - 1)).sum : ℤ) := by exact_mod_cast hleg dsimp [M]; simp only [mul_zero, sub_zero]; rw [hv_eq, hleg_z]; ring have hge_M : ∀ k, (polyQInt n).coeff k ≠ 0 → M ≤ npWeight 2 w 1 (polyQInt n) k := by intro k hk have hkle : k ≤ n := by by_contra hgt; apply hk; rw [polyQInt_coeff, if_neg hgt] exact polyQInt_four_mul_weight_ge he hkle have hmin_eq : npMinVal 2 w 1 (polyQInt n) = M := by apply le_antisymm · rw [← hwt_k₂] exact npMinVal_le (by rw [polyQInt_coeff, if_pos hk₂_le]; exact Int.natCast_ne_zero.mpr (qCoeff_pos _).ne') · obtain ⟨k, hk⟩ := npAttain_nonempty (p := 2) (w := w) (h := 1) (polyQInt_isPrimitive n).ne_zero have hk' := Finset.mem_filter.mp hk rw [← hk'.2]; exact hge_M k (Polynomial.mem_support_iff.mp hk'.1) have hl : npLeft 2 w 1 (polyQInt n) ≤ k₁ := npLeft_le_of_eq (by rw [polyQInt_coeff, if_pos hk₁_le]; exact Int.natCast_ne_zero.mpr (qCoeff_pos _).ne') (hwt_k₁.trans hmin_eq.symm) have hr : k₂ ≤ npRight 2 w 1 (polyQInt n) := le_npRight_of_eq (by rw [polyQInt_coeff, if_pos hk₂_le]; exact Int.natCast_ne_zero.mpr (qCoeff_pos _).ne') (hwt_k₂.trans hmin_eq.symm) unfold npWidth have hdiff : k₂ - k₁ = 2 ^ e := by dsimp [k₁, k₂]; rw [← Nat.sub_mul, Nat.sub_sub_self hq₀_pos, one_mul] omega /-- Helper: every active bit `e` of `4 * m` satisfies `2 ≤ e`. -/ lemma two_le_of_bit_four_mul {m e : ℕ} (hbit : ((4 * m) / 2 ^ e) % 2 = 1) : 2 ≤ e := by by_contra hlt interval_cases e · simp at hbit; omega · simp at hbit; omega /-- **Theorem 5a (Universal Even-Factor-Degree Law for `P_{4m}`)**: For every $m \ge 1$, every rational factor $u \mid P_{4m}(x)$ has **even** degree. -/ theorem polyP_four_mul_even_factor_deg (m : ℕ) (_hm : 1 ≤ m) {u : ℚ[X]} (hdvd : u ∣ polyP (4 * m)) : 2 ∣ u.natDegree := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ rw [← polyPInt_map_rat] at hdvd set n := 4 * m set B := n + 1 have hn_lt : n < 2 ^ B := Nat.lt_two_pow_self.trans (Nat.pow_lt_pow_right (by norm_num) (Nat.lt_succ_self n)) set bits := bitPositionsAux B n set L : List (ℕ × ℤ) := bits.map fun e => (2 ^ (e - 1), 1) have hbits_ge2 : ∀ e ∈ bits, 2 ≤ e ∧ (n / 2 ^ e) % 2 = 1 := by intro e he have hmem := (bitPositionsAux_mem_iff B n e).mp he exact ⟨two_le_of_bit_four_mul hmem.2, hmem.2⟩ have hpos : ∀ s ∈ L, 0 < s.1 := by intro s hs; obtain ⟨e, _, rfl⟩ := List.mem_map.mp hs; positivity have hcop : ∀ s ∈ L, Nat.Coprime s.1 s.2.natAbs := by intro s hs; obtain ⟨e, _, rfl⟩ := List.mem_map.mp hs; simp have hd : ∀ s ∈ L, 2 ∣ s.1 := by intro s hs obtain ⟨e, he, rfl⟩ := List.mem_map.mp hs have he2 := (hbits_ge2 e he).1 exact dvd_pow_self 2 (by omega) have hch : L.IsChain (fun s₁ s₂ => s₁.2 * (s₂.1 : ℤ) < s₂.2 * (s₁.1 : ℤ)) := by have hch_b := bitPositionsAux_chain B n have haux : ∀ M : List ℕ, M.IsChain (· > ·) → (∀ e ∈ M, 2 ≤ e) → (M.map fun e => ((2 ^ (e - 1) : ℕ), (1 : ℤ))).IsChain (fun s₁ s₂ => s₁.2 * (s₂.1 : ℤ) < s₂.2 * (s₁.1 : ℤ)) := by intro M induction M with | nil => intro _ _; simp | cons a tl ih => intro hc h2 cases tl with | nil => simp | cons b tl' => rw [List.isChain_cons_cons] at hc simp only [List.map_cons, List.isChain_cons_cons] refine ⟨?_, ih hc.2 (fun e he => h2 e (List.mem_cons_of_mem a he))⟩ have ha2 := h2 a (by simp) have hb2 := h2 b (by simp) have hlt : b - 1 < a - 1 := by omega have hpow : 2 ^ (b - 1) < 2 ^ (a - 1) := Nat.pow_lt_pow_right (by norm_num) hlt simp only [one_mul]; exact_mod_cast hpow exact haux bits hch_b (fun e he => (hbits_ge2 e he).1) have hsum_ge : n ≤ (L.map fun s => npWidth 2 s.1 s.2 (polyPInt n)).sum := by have hge_list : ∀ M : List ℕ, (∀ e ∈ M, 2 ≤ e ∧ (n / 2 ^ e) % 2 = 1) → (M.map fun e => 2 ^ e).sum ≤ ((M.map fun e => (2 ^ (e - 1), (1 : ℤ))).map fun s => npWidth 2 s.1 s.2 (polyPInt n)).sum := by intro M induction M with | nil => intro _; simp | cons e tl ih => intro hM simp only [List.map_cons, List.sum_cons] have he := hM e (by simp) exact Nat.add_le_add (pow_two_le_npWidth_polyPInt (by omega) he.2) (ih (fun x hx => hM x (List.mem_cons_of_mem e hx))) have h1 := hge_list bits hbits_ge2 rw [bitPositionsAux_sum B n, Nat.mod_eq_of_lt hn_lt] at h1 exact h1 have hsum_le := npWidth_sum_le_natDegree 2 L hpos hch (polyPInt n) (polyPInt_isPrimitive n).ne_zero rw [polyPInt_natDegree] at hsum_le have hfull : (L.map fun s => npWidth 2 s.1 s.2 (polyPInt n)).sum = (polyPInt n).natDegree := by rw [polyPInt_natDegree]; exact le_antisymm hsum_le hsum_ge exact dvd_natDegree_of_slope_list hpos hcop hd hch (polyPInt_isPrimitive n) hfull hdvd /-- **Theorem 5b (Universal Even-Factor-Degree Law for `Q_{4m}`)**: For every $m \ge 1$, every rational factor $u \mid Q_{4m}(x)$ has **even** degree. -/ theorem polyQ_four_mul_even_factor_deg (m : ℕ) (_hm : 1 ≤ m) {u : ℚ[X]} (hdvd : u ∣ polyQ (4 * m)) : 2 ∣ u.natDegree := by have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ rw [← polyQInt_map_rat] at hdvd set n := 4 * m set B := n + 1 have hn_lt : n < 2 ^ B := Nat.lt_two_pow_self.trans (Nat.pow_lt_pow_right (by norm_num) (Nat.lt_succ_self n)) set bits := bitPositionsAux B n set L : List (ℕ × ℤ) := bits.map fun e => (2 ^ (e - 1), 1) have hbits_ge2 : ∀ e ∈ bits, 2 ≤ e ∧ (n / 2 ^ e) % 2 = 1 := by intro e he have hmem := (bitPositionsAux_mem_iff B n e).mp he exact ⟨two_le_of_bit_four_mul hmem.2, hmem.2⟩ have hpos : ∀ s ∈ L, 0 < s.1 := by intro s hs; obtain ⟨e, _, rfl⟩ := List.mem_map.mp hs; positivity have hcop : ∀ s ∈ L, Nat.Coprime s.1 s.2.natAbs := by intro s hs; obtain ⟨e, _, rfl⟩ := List.mem_map.mp hs; simp have hd : ∀ s ∈ L, 2 ∣ s.1 := by intro s hs obtain ⟨e, he, rfl⟩ := List.mem_map.mp hs have he2 := (hbits_ge2 e he).1 exact dvd_pow_self 2 (by omega) have hch : L.IsChain (fun s₁ s₂ => s₁.2 * (s₂.1 : ℤ) < s₂.2 * (s₁.1 : ℤ)) := by have hch_b := bitPositionsAux_chain B n have haux : ∀ M : List ℕ, M.IsChain (· > ·) → (∀ e ∈ M, 2 ≤ e) → (M.map fun e => ((2 ^ (e - 1) : ℕ), (1 : ℤ))).IsChain (fun s₁ s₂ => s₁.2 * (s₂.1 : ℤ) < s₂.2 * (s₁.1 : ℤ)) := by intro M induction M with | nil => intro _ _; simp | cons a tl ih => intro hc h2 cases tl with | nil => simp | cons b tl' => rw [List.isChain_cons_cons] at hc simp only [List.map_cons, List.isChain_cons_cons] refine ⟨?_, ih hc.2 (fun e he => h2 e (List.mem_cons_of_mem a he))⟩ have ha2 := h2 a (by simp) have hb2 := h2 b (by simp) have hlt : b - 1 < a - 1 := by omega have hpow : 2 ^ (b - 1) < 2 ^ (a - 1) := Nat.pow_lt_pow_right (by norm_num) hlt simp only [one_mul]; exact_mod_cast hpow exact haux bits hch_b (fun e he => (hbits_ge2 e he).1) have hsum_ge : n ≤ (L.map fun s => npWidth 2 s.1 s.2 (polyQInt n)).sum := by have hge_list : ∀ M : List ℕ, (∀ e ∈ M, 2 ≤ e ∧ (n / 2 ^ e) % 2 = 1) → (M.map fun e => 2 ^ e).sum ≤ ((M.map fun e => (2 ^ (e - 1), (1 : ℤ))).map fun s => npWidth 2 s.1 s.2 (polyQInt n)).sum := by intro M induction M with | nil => intro _; simp | cons e tl ih => intro hM simp only [List.map_cons, List.sum_cons] have he := hM e (by simp) exact Nat.add_le_add (pow_two_le_npWidth_polyQInt_four_mul he.1 he.2) (ih (fun x hx => hM x (List.mem_cons_of_mem e hx))) have h1 := hge_list bits hbits_ge2 rw [bitPositionsAux_sum B n, Nat.mod_eq_of_lt hn_lt] at h1 exact h1 have hsum_le := npWidth_sum_le_natDegree 2 L hpos hch (polyQInt n) (polyQInt_isPrimitive n).ne_zero rw [polyQInt_natDegree] at hsum_le have hfull : (L.map fun s => npWidth 2 s.1 s.2 (polyQInt n)).sum = (polyQInt n).natDegree := by rw [polyQInt_natDegree]; exact le_antisymm hsum_le hsum_ge exact dvd_natDegree_of_slope_list hpos hcop hd hch (polyQInt_isPrimitive n) hfull hdvd /-! ### 4.4 Half-Degree Prime-Family Irreducible Factor Lower Bounds (`Q_{p-1}` and `P_{p-1}`) -/ lemma padicValNat_centralBinom_lt_half {p k : ℕ} [hp : Fact p.Prime] (hk : 2 * k < p) : padicValNat p (Nat.centralBinom k) = 0 := by apply padicValNat.eq_zero_of_not_dvd intro hd have hfac : p ∣ (2 * k).factorial := by have h := Nat.choose_mul_factorial_mul_factorial (show k ≤ 2 * k by omega) rw [← Nat.centralBinom_eq_two_mul_choose] at h exact hd.trans ⟨k.factorial * (2 * k - k).factorial, by rw [← h]; ring⟩ have hle := (hp.out.dvd_factorial).mp hfac omega lemma padicValNat_centralBinom_ge_half_lt_prime {p k : ℕ} [hp : Fact p.Prime] (hk1 : p ≤ 2 * k) (hk2 : k < p) : padicValNat p (Nat.centralBinom k) = 1 := by have hmul : Nat.centralBinom k * (k.factorial * k.factorial) = (2 * k).factorial := by rw [Nat.centralBinom_eq_two_mul_choose] have h := Nat.choose_mul_factorial_mul_factorial (show k ≤ 2 * k by omega) rw [show 2 * k - k = k by omega] at h simpa [mul_assoc] using h have hvk : padicValNat p k.factorial = 0 := padicValNat.eq_zero_of_not_dvd (fun hd => by have := hp.out.dvd_factorial.mp hd; omega) -- For p ≤ m < 2 * p, padicValNat p m! = 1 have hv2k : padicValNat p (2 * k).factorial = 1 := by have hlt2p : 2 * k < 2 * p := by omega -- Induct from p up to 2 * k have haux : ∀ m, p ≤ m → m < 2 * p → padicValNat p m.factorial = 1 := by intro m hm1 hm2 induction m with | zero => have := hp.out.two_le; omega | succ t ih => rw [Nat.factorial_succ, padicValNat.mul (Nat.succ_ne_zero t) (Nat.factorial_ne_zero t)] by_cases htp : t + 1 = p · rw [Nat.succ_eq_add_one, htp, padicValNat.self hp.out.one_lt] have hvt : padicValNat p t.factorial = 0 := padicValNat.eq_zero_of_not_dvd (fun hd => by have := hp.out.dvd_factorial.mp hd; omega) rw [hvt] · have hnd : ¬ p ∣ t + 1 := by intro hd; obtain ⟨c, hc⟩ := hd rcases c with _ | _ | c · omega · omega · have : 2 * p ≤ p * (c + 1 + 1) := by rw [mul_comm 2 p]; exact Nat.mul_le_mul_left p (show 2 ≤ c + 1 + 1 by omega) omega rw [Nat.succ_eq_add_one, padicValNat.eq_zero_of_not_dvd hnd, zero_add] exact ih (by omega) (by omega) exact haux (2 * k) hk1 hlt2p have hv := congrArg (padicValNat p) hmul rw [padicValNat.mul (Nat.centralBinom_pos k).ne' (mul_ne_zero (Nat.factorial_ne_zero k) (Nat.factorial_ne_zero k)), padicValNat.mul (Nat.factorial_ne_zero k) (Nat.factorial_ne_zero k), hvk, hv2k] at hv omega /-- **Theorem 6a (Half-Degree Irreducible Factor of $Q_{p-1}$ for Every Odd Prime $p$)**: For every odd prime $p$, $Q_{p-1}(x)$ has an irreducible factor over $\mathbb{Q}$ of degree at least $(p - 1) / 2$. -/ theorem polyQ_prime_sub_one_large_irred_factor {p : ℕ} (hp : p.Prime) (hp2 : p ≠ 2) : ∃ g : ℚ[X], Irreducible g ∧ g ∣ polyQ (p - 1) ∧ (p - 1) / 2 ≤ g.natDegree := by have : Fact p.Prime := ⟨hp⟩ rw [← polyQInt_map_rat] set f := polyQInt (p - 1) set w := (p - 1) / 2 have hp3 : 3 ≤ p := by have := hp.two_le; omega have hp_odd : p % 2 = 1 := by rcases hp.eq_two_or_odd with h2 | ho · exact absurd h2 hp2 · exact ho have hw2 : 2 * w = p - 1 := by dsimp [w]; omega have hw_pos : 0 < w := by omega refine exists_irred_factor_natDegree_ge_of_npWidth (p := p) (w := w) (h := 1) hw_pos (by simp) f.natDegree f le_rfl (polyQInt_isPrimitive _) ?_ -- Exact p-adic valuations of qCoeff k for 0 ≤ k ≤ p - 1: -- 0 for k ≤ w; 2 for w < k < p - 1; 1 for k = p - 1 have hv_q : ∀ k ≤ p - 1, padicValNat p (qCoeff k) = if k ≤ w then 0 else if k < p - 1 then 2 else 1 := by intro k hk have hmul := congrArg (padicValNat p) (qCoeff_mul_succ k) rw [padicValNat.mul (qCoeff_pos k).ne' (Nat.succ_ne_zero k), padicValNat_pow_eq (Nat.centralBinom_pos k).ne' 2, Nat.succ_eq_add_one] at hmul by_cases hkw : k ≤ w · rw [if_pos hkw] have hcb0 : padicValNat p (Nat.centralBinom k) = 0 := padicValNat_centralBinom_lt_half (by omega) rw [hcb0] at hmul; omega · rw [if_neg hkw] have hcb1 : padicValNat p (Nat.centralBinom k) = 1 := padicValNat_centralBinom_ge_half_lt_prime (by omega) (by omega) rw [hcb1] at hmul by_cases hlt : k < p - 1 · rw [if_pos hlt] have hv0 : padicValNat p (k + 1) = 0 := padicValNat.eq_zero_of_not_dvd (Nat.not_dvd_of_pos_of_lt (Nat.succ_pos k) (by omega)) omega · rw [if_neg hlt] have hk1 : k + 1 = p := by omega rw [hk1, padicValNat.self hp.one_lt] at hmul; omega -- At slope 1/w: npWeight p w 1 f k = w * v_p(qCoeff k) - k -- Achieves min -(w : ℤ) ONLY at k = w and k = 2*w = p - 1! have hwt_w : npWeight p w 1 f w = -(w : ℤ) := by unfold npWeight; dsimp [f] rw [polyQInt_coeff, if_pos (by omega : w ≤ p - 1), padicValInt.of_nat, hv_q w (by omega), if_pos le_rfl] simp have hwt_top : npWeight p w 1 f (p - 1) = -(w : ℤ) := by unfold npWeight; dsimp [f] rw [polyQInt_coeff, if_pos le_rfl, padicValInt.of_nat, hv_q (p - 1) le_rfl, if_neg (by omega), if_neg (by omega)] omega have hge : ∀ k, f.coeff k ≠ 0 → -(w : ℤ) ≤ npWeight p w 1 f k := by intro k hk have hkle : k ≤ p - 1 := by by_contra hgt; apply hk; dsimp [f]; rw [polyQInt_coeff, if_neg hgt] unfold npWeight; dsimp [f] rw [polyQInt_coeff, if_pos hkle, padicValInt.of_nat, hv_q k hkle] split_ifs <;> omega have hmin : npMinVal p w 1 f = -(w : ℤ) := by apply le_antisymm · rw [← hwt_w]; exact npMinVal_le (by dsimp [f]; rw [polyQInt_coeff, if_pos (by omega)]; exact Int.natCast_ne_zero.mpr (qCoeff_pos _).ne') · obtain ⟨k, hk⟩ := npAttain_nonempty (p := p) (w := w) (h := 1) (polyQInt_isPrimitive _).ne_zero have hk' := Finset.mem_filter.mp hk rw [← hk'.2]; exact hge k (Polynomial.mem_support_iff.mp hk'.1) have hleft_eq : npLeft p w 1 f = w := by apply le_antisymm · exact npLeft_le_of_eq (by dsimp [f]; rw [polyQInt_coeff, if_pos (by omega)]; exact Int.natCast_ne_zero.mpr (qCoeff_pos _).ne') (hwt_w.trans hmin.symm) · by_contra hlt push Not at hlt have hm := Finset.mem_filter.mp (npLeft_mem_attain (p := p) (w := w) (h := 1) (polyQInt_isPrimitive (p - 1)).ne_zero) have hkle : npLeft p w 1 f ≤ p - 1 := by have := Polynomial.le_natDegree_of_mem_supp _ hm.1; rw [polyQInt_natDegree] at this; exact this have hw_eq := hm.2 rw [hmin] at hw_eq unfold npWeight at hw_eq rw [polyQInt_coeff, if_pos hkle, padicValInt.of_nat, hv_q _ hkle, if_pos (by omega)] at hw_eq simp only [Nat.cast_zero, mul_zero, one_mul, zero_sub] at hw_eq have hlt' : npLeft p w 1 (polyQInt (p - 1)) < w := hlt omega have hright_eq : npRight p w 1 f = p - 1 := by apply le_antisymm · have := npRight_le_natDegree (p := p) (w := w) (h := 1) (polyQInt_isPrimitive (p - 1)).ne_zero rwa [polyQInt_natDegree] at this · exact le_npRight_of_eq (by dsimp [f]; rw [polyQInt_coeff, if_pos le_rfl]; exact Int.natCast_ne_zero.mpr (qCoeff_pos _).ne') (hwt_top.trans hmin.symm) unfold npWidth; rw [hleft_eq, hright_eq]; omega /-- **Theorem 6b (Half-Degree Irreducible Factor of $P_{p-1}$ for Every Prime $p \equiv 3 \pmod 4$)**: For every prime $p \equiv 3 \pmod 4$, $P_{p-1}(x)$ has an irreducible factor over $\mathbb{Q}$ of degree at least $(p - 1) / 2$. -/ theorem polyP_prime_sub_one_large_irred_factor {p : ℕ} (hp : p.Prime) (hp4 : p % 4 = 3) : ∃ g : ℚ[X], Irreducible g ∧ g ∣ polyP (p - 1) ∧ (p - 1) / 2 ≤ g.natDegree := by have : Fact p.Prime := ⟨hp⟩ rw [← polyPInt_map_rat] set f := polyPInt (p - 1) set w := (p - 1) / 2 have hw2 : 2 * w = p - 1 := by dsimp [w]; omega have hw_odd : w % 2 = 1 := by dsimp [w]; omega have hw_pos : 0 < w := by omega have hcop : Nat.Coprime w (2 : ℤ).natAbs := by exact (Nat.Prime.coprime_iff_not_dvd Nat.prime_two |>.mpr (by omega)).symm refine exists_irred_factor_natDegree_ge_of_npWidth (p := p) (w := w) (h := 2) hw_pos hcop f.natDegree f le_rfl (polyPInt_isPrimitive _) ?_ have hv_p : ∀ k ≤ p - 1, padicValNat p (pCoeff k) = if k ≤ w then 0 else 2 := by intro k hk unfold pCoeff rw [padicValNat_pow_eq (Nat.centralBinom_pos k).ne' 2] by_cases hkw : k ≤ w · rw [if_pos hkw, padicValNat_centralBinom_lt_half (by omega)] · rw [if_neg hkw, padicValNat_centralBinom_ge_half_lt_prime (by omega) (by omega)] have hwt_w : npWeight p w 2 f w = -2 * (w : ℤ) := by unfold npWeight; dsimp [f] rw [polyPInt_coeff, if_pos (by omega : w ≤ p - 1), padicValInt.of_nat, hv_p w (by omega), if_pos le_rfl] ring have hwt_top : npWeight p w 2 f (p - 1) = -2 * (w : ℤ) := by unfold npWeight; dsimp [f] rw [polyPInt_coeff, if_pos le_rfl, padicValInt.of_nat, hv_p (p - 1) le_rfl, if_neg (by omega)] omega have hge : ∀ k, f.coeff k ≠ 0 → -2 * (w : ℤ) ≤ npWeight p w 2 f k := by intro k hk have hkle : k ≤ p - 1 := by by_contra hgt; apply hk; dsimp [f]; rw [polyPInt_coeff, if_neg hgt] unfold npWeight; dsimp [f] rw [polyPInt_coeff, if_pos hkle, padicValInt.of_nat, hv_p k hkle] split_ifs <;> omega have hmin : npMinVal p w 2 f = -2 * (w : ℤ) := by apply le_antisymm · rw [← hwt_w]; exact npMinVal_le (by dsimp [f]; rw [polyPInt_coeff, if_pos (by omega)]; exact Int.natCast_ne_zero.mpr (pCoeff_pos _).ne') · obtain ⟨k, hk⟩ := npAttain_nonempty (p := p) (w := w) (h := 2) (polyPInt_isPrimitive _).ne_zero have hk' := Finset.mem_filter.mp hk rw [← hk'.2]; exact hge k (Polynomial.mem_support_iff.mp hk'.1) have hleft_eq : npLeft p w 2 f = w := by apply le_antisymm · exact npLeft_le_of_eq (by dsimp [f]; rw [polyPInt_coeff, if_pos (by omega)]; exact Int.natCast_ne_zero.mpr (pCoeff_pos _).ne') (hwt_w.trans hmin.symm) · by_contra hlt push Not at hlt have hm := Finset.mem_filter.mp (npLeft_mem_attain (p := p) (w := w) (h := 2) (polyPInt_isPrimitive (p - 1)).ne_zero) have hkle : npLeft p w 2 f ≤ p - 1 := by have := Polynomial.le_natDegree_of_mem_supp _ hm.1; rw [polyPInt_natDegree] at this; exact this have hw_eq := hm.2 rw [hmin] at hw_eq unfold npWeight at hw_eq rw [polyPInt_coeff, if_pos hkle, padicValInt.of_nat, hv_p _ hkle, if_pos (by omega)] at hw_eq simp only [Nat.cast_zero, mul_zero, zero_sub] at hw_eq have hlt' : npLeft p w 2 (polyPInt (p - 1)) < w := hlt omega have hright_eq : npRight p w 2 f = p - 1 := by apply le_antisymm · have := npRight_le_natDegree (p := p) (w := w) (h := 2) (polyPInt_isPrimitive (p - 1)).ne_zero rwa [polyPInt_natDegree] at this · exact le_npRight_of_eq (by dsimp [f]; rw [polyPInt_coeff, if_pos le_rfl]; exact Int.natCast_ne_zero.mpr (pCoeff_pos _).ne') (hwt_top.trans hmin.symm) unfold npWidth; rw [hleft_eq, hright_eq]; omega /-! ## Section 5: Universal Rational-Root Nonexistence & Shifted 3-adic Irreducibility of $P_{13}$ We prove that for EVERY $n \ge 2$, neither $P_n(x)$ nor $Q_n(x)$ has any rational root: 1. Any rational root of an integer polynomial with $f(0) = 1$, positive coefficients, and even higher coefficients must have the form $q = -1/d$ for an even integer $d \ge 2$. 2. For $d \ge 16$, the cleared alternating sum $\operatorname{altSum}(c, d, n)$ is strictly positive for all $n \ge 0$ because $c_{k+1} < d \cdot c_k$. 3. For each even $d \in \{2, 4, 6, 8, 10, 12, 14\}$, once $k \ge M(d)$ the terms strictly grow ($d \cdot c_k < c_{k+1}$), and the inductive invariant $0 < (-1)^m \operatorname{altSum}(c, d, m) < c_m$ propagates for all $m \ge M(d)$; the finite prefix $2 \le n < M(d)$ and base case at $M(d)$ are verified by exact kernel arithmetic. 4. Combining universal rational-root nonexistence for $P_{13}$ with a shifted $3$-adic Newton polygon of width $12$ for $P_{13}(x - 1)$ proves `Irreducible (polyP 13)`. -/ /-! ### 5.1 Recurrences & Fast Coefficient Evaluators -/ lemma succ_mul_centralBinom_succ (k : ℕ) : (k + 1) * Nat.centralBinom (k + 1) = 2 * (2 * k + 1) * Nat.centralBinom k := by have h1 := Nat.choose_mul_factorial_mul_factorial (show k ≤ 2 * k by omega) have h2 := Nat.choose_mul_factorial_mul_factorial (show k + 1 ≤ 2 * (k + 1) by omega) rw [← Nat.centralBinom_eq_two_mul_choose, show 2 * k - k = k by omega] at h1 rw [← Nat.centralBinom_eq_two_mul_choose, show 2 * (k + 1) - (k + 1) = k + 1 by omega] at h2 have hf : (2 * (k + 1)).factorial = 2 * (k + 1) * (2 * k + 1) * (2 * k).factorial := by rw [show 2 * (k + 1) = (2 * k + 1) + 1 by omega, Nat.factorial_succ, Nat.factorial_succ] ring have hkf : (k + 1).factorial = (k + 1) * k.factorial := Nat.factorial_succ k have hpos : 0 < (k + 1) * (k.factorial * k.factorial) := by positivity apply Nat.eq_of_mul_eq_mul_right hpos calc (k + 1) * Nat.centralBinom (k + 1) * ((k + 1) * (k.factorial * k.factorial)) = Nat.centralBinom (k + 1) * ((k + 1) * k.factorial) * ((k + 1) * k.factorial) := by ring _ = (2 * (k + 1)).factorial := by rw [← hkf]; exact h2 _ = 2 * (k + 1) * (2 * k + 1) * (Nat.centralBinom k * k.factorial * k.factorial) := by rw [hf, ← h1] _ = 2 * (2 * k + 1) * Nat.centralBinom k * ((k + 1) * (k.factorial * k.factorial)) := by ring lemma pCoeff_recurrence (k : ℕ) : (k + 1) ^ 2 * pCoeff (k + 1) = 4 * (2 * k + 1) ^ 2 * pCoeff k := by unfold pCoeff have h := succ_mul_centralBinom_succ k calc (k + 1) ^ 2 * (Nat.centralBinom (k + 1)) ^ 2 = ((k + 1) * Nat.centralBinom (k + 1)) ^ 2 := by ring _ = (2 * (2 * k + 1) * Nat.centralBinom k) ^ 2 := by rw [h] _ = 4 * (2 * k + 1) ^ 2 * (Nat.centralBinom k) ^ 2 := by ring lemma qCoeff_recurrence (k : ℕ) : (k + 1) * (k + 2) * qCoeff (k + 1) = 4 * (2 * k + 1) ^ 2 * qCoeff k := by have hpos : 0 < k + 1 := by omega apply Nat.eq_of_mul_eq_mul_left hpos have hq1 : qCoeff (k + 1) * (k + 2) = pCoeff (k + 1) := by simpa [pCoeff, add_assoc] using qCoeff_mul_succ (k + 1) have hq0 : qCoeff k * (k + 1) = pCoeff k := by simpa [pCoeff] using qCoeff_mul_succ k calc (k + 1) * ((k + 1) * (k + 2) * qCoeff (k + 1)) = (k + 1) ^ 2 * (qCoeff (k + 1) * (k + 2)) := by ring _ = (k + 1) ^ 2 * pCoeff (k + 1) := by rw [hq1] _ = 4 * (2 * k + 1) ^ 2 * pCoeff k := pCoeff_recurrence k _ = 4 * (2 * k + 1) ^ 2 * (qCoeff k * (k + 1)) := by rw [hq0] _ = (k + 1) * (4 * (2 * k + 1) ^ 2 * qCoeff k) := by ring def pCoeffStep (k c : ℕ) : ℕ := 4 * (2 * k + 1) ^ 2 * c / (k + 1) ^ 2 def qCoeffStep (k c : ℕ) : ℕ := 4 * (2 * k + 1) ^ 2 * c / ((k + 1) * (k + 2)) lemma pCoeff_succ_eq_step (k : ℕ) : pCoeff (k + 1) = pCoeffStep k (pCoeff k) := by unfold pCoeffStep rw [← pCoeff_recurrence k, Nat.mul_div_cancel_left _ (by positivity)] lemma qCoeff_succ_eq_step (k : ℕ) : qCoeff (k + 1) = qCoeffStep k (qCoeff k) := by unfold qCoeffStep rw [← qCoeff_recurrence k, Nat.mul_div_cancel_left _ (by positivity)] lemma pCoeff_step_lt_of_ge_16 {d : ℕ} (hd : 16 ≤ d) (k : ℕ) : pCoeff (k + 1) < d * pCoeff k := by have hrec := pCoeff_recurrence k have h16 : 16 * (k + 1) ^ 2 ≤ d * (k + 1) ^ 2 := Nat.mul_le_mul_right _ hd have hlt0 : 4 * (2 * k + 1) ^ 2 < 16 * (k + 1) ^ 2 := by rw [sq, sq]; nlinarith have hlt : 4 * (2 * k + 1) ^ 2 < d * (k + 1) ^ 2 := lt_of_lt_of_le hlt0 h16 have hmul : (k + 1) ^ 2 * pCoeff (k + 1) < (k + 1) ^ 2 * (d * pCoeff k) := by have hp := pCoeff_pos k calc (k + 1) ^ 2 * pCoeff (k + 1) = 4 * (2 * k + 1) ^ 2 * pCoeff k := hrec _ < d * (k + 1) ^ 2 * pCoeff k := Nat.mul_lt_mul_of_pos_right hlt hp _ = (k + 1) ^ 2 * (d * pCoeff k) := by ring exact Nat.lt_of_mul_lt_mul_left hmul lemma qCoeff_step_lt_of_ge_16 {d : ℕ} (hd : 16 ≤ d) (k : ℕ) : qCoeff (k + 1) < d * qCoeff k := by have hrec := qCoeff_recurrence k have hlt : 4 * (2 * k + 1) ^ 2 < d * ((k + 1) * (k + 2)) := by nlinarith have hmul : (k + 1) * (k + 2) * qCoeff (k + 1) < (k + 1) * (k + 2) * (d * qCoeff k) := by have hq := qCoeff_pos k calc (k + 1) * (k + 2) * qCoeff (k + 1) = 4 * (2 * k + 1) ^ 2 * qCoeff k := hrec _ < d * ((k + 1) * (k + 2)) * qCoeff k := Nat.mul_lt_mul_of_pos_right hlt hq _ = (k + 1) * (k + 2) * (d * qCoeff k) := by ring exact Nat.lt_of_mul_lt_mul_left hmul lemma pCoeff_step_gt_of_quad {d k : ℕ} (h : d * (k + 1) ^ 2 < 4 * (2 * k + 1) ^ 2) : d * pCoeff k < pCoeff (k + 1) := by have hrec := pCoeff_recurrence k have hp := pCoeff_pos k have hmul : (k + 1) ^ 2 * (d * pCoeff k) < (k + 1) ^ 2 * pCoeff (k + 1) := by calc (k + 1) ^ 2 * (d * pCoeff k) = d * (k + 1) ^ 2 * pCoeff k := by ring _ < 4 * (2 * k + 1) ^ 2 * pCoeff k := Nat.mul_lt_mul_of_pos_right h hp _ = (k + 1) ^ 2 * pCoeff (k + 1) := hrec.symm exact Nat.lt_of_mul_lt_mul_left hmul lemma qCoeff_step_gt_of_quad {d k : ℕ} (h : d * ((k + 1) * (k + 2)) < 4 * (2 * k + 1) ^ 2) : d * qCoeff k < qCoeff (k + 1) := by have hrec := qCoeff_recurrence k have hq := qCoeff_pos k have hmul : (k + 1) * (k + 2) * (d * qCoeff k) < (k + 1) * (k + 2) * qCoeff (k + 1) := by calc (k + 1) * (k + 2) * (d * qCoeff k) = d * ((k + 1) * (k + 2)) * qCoeff k := by ring _ < 4 * (2 * k + 1) ^ 2 * qCoeff k := Nat.mul_lt_mul_of_pos_right h hq _ = (k + 1) * (k + 2) * qCoeff (k + 1) := hrec.symm exact Nat.lt_of_mul_lt_mul_left hmul /-! ### 5.2 Cleared Alternating Sum & Universal Rational-Root Reduction -/ /-- Cleared integer evaluation `d^n * ∑_{k=0}^n c(k) (-1/d)^k` when `c 0 = 1`. -/ def altSum (c : ℕ → ℕ) (d : ℕ) : ℕ → ℤ | 0 => 1 | n + 1 => (d : ℤ) * altSum c d n + (-1 : ℤ) ^ (n + 1) * (c (n + 1) : ℤ) lemma eval_neg_inv_eq_altSum (c : ℕ → ℕ) (hc0 : c 0 = 1) {d : ℕ} (hd : d ≠ 0) (n : ℕ) : (d : ℚ) ^ n * (∑ k ∈ Finset.range (n + 1), (c k : ℚ) * (-1 / (d : ℚ)) ^ k) = (altSum c d n : ℚ) := by have hdq : (d : ℚ) ≠ 0 := Nat.cast_ne_zero.mpr hd induction n with | zero => simp [altSum, hc0] | succ n ih => rw [Finset.sum_range_succ, mul_add, pow_succ', mul_assoc, ih] simp only [altSum, Int.cast_add, Int.cast_mul, Int.cast_pow, Int.cast_neg, Int.cast_one, Int.cast_natCast] congr 1 rw [← pow_succ', div_pow, mul_left_comm, mul_div_cancel₀ _ (pow_ne_zero _ hdq), mul_comm] /-- For `d` with strictly decreasing terms (`c(k+1) < d * c(k)` for all `k`), `altSum c d n > 0` for every `n ≥ 0`. -/ lemma altSum_pos_of_step_lt (c : ℕ → ℕ) (hc0 : c 0 = 1) {d : ℕ} (hd : 0 < d) (hstep : ∀ k, c (k + 1) < d * c k) : ∀ n, 0 < altSum c d n := by have hodd : ∀ j, 0 < altSum c d (2 * j + 1) := by intro j induction j with | zero => simp only [zero_add, altSum, pow_one, neg_mul, one_mul, mul_one] have h1 := hstep 0; rw [hc0, mul_one, zero_add] at h1 omega | succ j ih => have h2j3 : 2 * (j + 1) + 1 = (2 * j + 1) + 1 + 1 := by omega rw [h2j3, altSum, altSum] have heven_pow : (-1 : ℤ) ^ (2 * j + 1 + 1) = 1 := by rw [show 2 * j + 1 + 1 = 2 * (j + 1) by omega, pow_mul]; norm_num have hodd_pow : (-1 : ℤ) ^ (2 * j + 1 + 1 + 1) = -1 := by rw [pow_succ, heven_pow]; norm_num rw [heven_pow, hodd_pow, one_mul, neg_mul, one_mul] have hst : (c (2 * j + 2 + 1) : ℤ) < (d : ℤ) * (c (2 * j + 1 + 1) : ℤ) := by have h := hstep (2 * j + 2) rw [show 2 * j + 1 + 1 = 2 * j + 2 by omega] exact_mod_cast h have hdz : (0 : ℤ) < (d : ℤ) := by exact_mod_cast hd have hpos3 : (0 : ℤ) < (d : ℤ) * ((d : ℤ) * altSum c d (2 * j + 1)) := mul_pos hdz (mul_pos hdz ih) linarith intro n rcases Nat.even_or_odd n with ⟨j, hj⟩ | ⟨j, hj⟩ · rcases j with _ | j · simp [hj, altSum] · have h2 : n = (2 * j + 1) + 1 := by omega rw [h2, altSum] have heven_pow : (-1 : ℤ) ^ (2 * j + 1 + 1) = 1 := by rw [show 2 * j + 1 + 1 = 2 * (j + 1) by omega, pow_mul]; norm_num rw [heven_pow, one_mul] have hpos := hodd j have hdz : (0 : ℤ) < (d : ℤ) := by exact_mod_cast hd have hc_nn : (0 : ℤ) ≤ (c (2 * j + 1 + 1) : ℤ) := by positivity nlinarith · rw [hj]; exact hodd j /-- Inductive invariant for strictly increasing tails: once `0 < (-1)^M * altSum c d M < c M` and `d * c k < c (k + 1)` for all `k ≥ M`, the invariant holds for all `n ≥ M`, so `altSum c d n ≠ 0` for all `n ≥ M`. -/ lemma altSum_inv_of_ge (c : ℕ → ℕ) {d M : ℕ} (hd : 0 < d) (hbase : 0 < (-1 : ℤ) ^ M * altSum c d M ∧ (-1 : ℤ) ^ M * altSum c d M < (c M : ℤ)) (hstep : ∀ k, M ≤ k → d * c k < c (k + 1)) : ∀ n, M ≤ n → 0 < (-1 : ℤ) ^ n * altSum c d n ∧ (-1 : ℤ) ^ n * altSum c d n < (c n : ℤ) := by intro n hn induction n, hn using Nat.le_induction with | base => exact hbase | succ m hm ih => rw [altSum] have hpow2 : (-1 : ℤ) ^ (m + 1) * (-1 : ℤ) ^ (m + 1) = 1 := by rw [← pow_add, ← two_mul, pow_mul]; norm_num have hstep_z : (d : ℤ) * (c m : ℤ) < (c (m + 1) : ℤ) := by exact_mod_cast hstep m hm have hdz : (0 : ℤ) < (d : ℤ) := by exact_mod_cast hd have heq : (-1 : ℤ) ^ (m + 1) * ((d : ℤ) * altSum c d m + (-1 : ℤ) ^ (m + 1) * (c (m + 1) : ℤ)) = (c (m + 1) : ℤ) - (d : ℤ) * ((-1 : ℤ) ^ m * altSum c d m) := by calc (-1 : ℤ) ^ (m + 1) * ((d : ℤ) * altSum c d m + (-1 : ℤ) ^ (m + 1) * (c (m + 1) : ℤ)) = (d : ℤ) * ((-1 : ℤ) ^ (m + 1) * altSum c d m) + ((-1 : ℤ) ^ (m + 1) * (-1 : ℤ) ^ (m + 1)) * (c (m + 1) : ℤ) := by ring _ = (d : ℤ) * ((-1 : ℤ) ^ m * (-1) * altSum c d m) + 1 * (c (m + 1) : ℤ) := by rw [hpow2, pow_succ] _ = (c (m + 1) : ℤ) - (d : ℤ) * ((-1 : ℤ) ^ m * altSum c d m) := by ring rw [heq] constructor <;> nlinarith /-- Executable finite-prefix and base-invariant checker for `altSum`. -/ def checkAltSumLoop (step : ℕ → ℕ → ℕ) (d : ℕ) : ℕ → ℕ → ℕ → ℤ → ℤ → Bool | 0, _, c, I, s => decide (0 < s * I) && decide (s * I < (c : ℤ)) | rem + 1, k, c, I, s => (if 2 ≤ k then decide (I ≠ 0) else true) && let c' := step k c let s' := -s let I' := (d : ℤ) * I + s' * (c' : ℤ) checkAltSumLoop step d rem (k + 1) c' I' s' lemma checkAltSumLoop_spec (c : ℕ → ℕ) (step : ℕ → ℕ → ℕ) (hstep : ∀ k, c (k + 1) = step k (c k)) (d : ℕ) : ∀ rem k, checkAltSumLoop step d rem k (c k) (altSum c d k) ((-1 : ℤ) ^ k) = true → (∀ n, k ≤ n → n < k + rem → 2 ≤ n → altSum c d n ≠ 0) ∧ (0 < (-1 : ℤ) ^ (k + rem) * altSum c d (k + rem) ∧ (-1 : ℤ) ^ (k + rem) * altSum c d (k + rem) < (c (k + rem) : ℤ)) := by intro rem induction rem with | zero => intro k h simp only [checkAltSumLoop, Bool.and_eq_true, decide_eq_true_eq] at h refine ⟨fun n h1 h2 _ => by omega, ?_⟩ simpa only [add_zero] using h | succ rem ih => intro k h simp only [checkAltSumLoop, Bool.and_eq_true] at h rcases h with ⟨hcur, hnext⟩ have hc' : step k (c k) = c (k + 1) := (hstep k).symm have hs' : -((-1 : ℤ) ^ k) = (-1 : ℤ) ^ (k + 1) := by rw [pow_succ]; ring have hI' : (d : ℤ) * altSum c d k + -((-1 : ℤ) ^ k) * (step k (c k) : ℤ) = altSum c d (k + 1) := by rw [hc', hs', altSum] rw [hc', hs', show (d : ℤ) * altSum c d k + (-1 : ℤ) ^ (k + 1) * (c (k + 1) : ℤ) = altSum c d (k + 1) from by rw [altSum]] at hnext obtain ⟨hpref, hinv⟩ := ih (k + 1) hnext have hadd : k + 1 + rem = k + (rem + 1) := by omega rw [hadd] at hpref hinv refine ⟨?_, hinv⟩ intro n hkn hnlt hn2 by_cases hnk : n = k · subst hnk simp only [hn2, ↓reduceIte, decide_eq_true_eq] at hcur exact hcur · exact hpref n (by omega) hnlt hn2 lemma altSum_ne_zero_of_check (c : ℕ → ℕ) (hc0 : c 0 = 1) (step : ℕ → ℕ → ℕ) (hstep : ∀ k, c (k + 1) = step k (c k)) {d M : ℕ} (hd : 0 < d) (hchk : checkAltSumLoop step d M 0 1 1 1 = true) (htail : ∀ k, M ≤ k → d * c k < c (k + 1)) : ∀ n, 2 ≤ n → altSum c d n ≠ 0 := by have h0 : checkAltSumLoop step d M 0 (c 0) (altSum c d 0) ((-1 : ℤ) ^ 0) = true := by simpa [hc0, altSum] using hchk obtain ⟨hpref, hbase⟩ := checkAltSumLoop_spec c step hstep d M 0 h0 simp only [zero_add] at hpref hbase intro n hn2 by_cases hlt : n < M · exact hpref n (Nat.zero_le n) hlt hn2 · have hinv := altSum_inv_of_ge c hd hbase htail n (by omega) intro h0_n rw [h0_n, mul_zero] at hinv exact lt_irrefl 0 hinv.1 /-- Universal rational-root form: if `f ∈ ℤ[X]` has `deg f ≥ 1`, `f(0) = 1`, positive coefficients up to `deg f`, and even coefficients at all `k ≥ 1`, then any rational root `q` satisfies `q = -1 / d` for an even `d ≥ 2`. -/ lemma rat_root_eq_neg_inv_even {f : ℤ[X]} (hdeg : 1 ≤ f.natDegree) (h0 : f.coeff 0 = 1) (hpos : ∀ k ≤ f.natDegree, 0 < f.coeff k) (heven : ∀ k, 1 ≤ k → 2 ∣ f.coeff k) {q : ℚ} (hq : (f.map (Int.castRingHom ℚ)).eval q = 0) : ∃ d : ℕ, 2 ∣ d ∧ 2 ≤ d ∧ q = -1 / (d : ℚ) := by set a : ℤ := q.num set b : ℕ := q.den have hb_pos : 0 < b := q.pos have hb_ne : (b : ℚ) ≠ 0 := Nat.cast_ne_zero.mpr hb_pos.ne' have hcop : Nat.Coprime a.natAbs b := q.reduced have hq_eq : q = (a : ℚ) / (b : ℚ) := (Rat.num_div_den q).symm set N := f.natDegree set S : ℤ := ∑ k ∈ Finset.range (N + 1), f.coeff k * a ^ k * (b : ℤ) ^ (N - k) have hS_rat : (S : ℚ) = (b : ℚ) ^ N * (f.map (Int.castRingHom ℚ)).eval q := by have hdeg_map : (f.map (Int.castRingHom ℚ)).natDegree ≤ N := Polynomial.natDegree_map_le rw [Polynomial.eval_eq_sum_range' (Nat.lt_succ_of_le hdeg_map), Finset.mul_sum] dsimp [S] push_cast refine Finset.sum_congr rfl fun k hk => ?_ have hkN : k ≤ N := Nat.lt_succ_iff.mp (Finset.mem_range.mp hk) rw [Polynomial.coeff_map, eq_intCast, hq_eq, div_pow] have hpow : (b : ℚ) ^ N = (b : ℚ) ^ (N - k) * (b : ℚ) ^ k := by rw [← pow_add, Nat.sub_add_cancel hkN] rw [hpow] field_simp [hb_ne] have hS_zero : S = 0 := by have hq0 : (S : ℚ) = 0 := by rw [hS_rat, hq, mul_zero] exact Int.cast_eq_zero.mp hq0 have hsplit : (∑ k ∈ Finset.range N, f.coeff (k + 1) * a ^ (k + 1) * (b : ℤ) ^ (N - (k + 1))) + (b : ℤ) ^ N = 0 := by have hs := Finset.sum_range_succ' (fun k => f.coeff k * a ^ k * (b : ℤ) ^ (N - k)) N simp only [h0, pow_zero, mul_one, one_mul, Nat.sub_zero] at hs rw [← hs]; exact hS_zero -- Step 1: a ∣ b^N, hence a.natAbs = 1 have ha_dvd_sum : a ∣ ∑ k ∈ Finset.range N, f.coeff (k + 1) * a ^ (k + 1) * (b : ℤ) ^ (N - (k + 1)) := by refine Finset.dvd_sum fun k _ => ?_ rw [pow_succ] exact ⟨f.coeff (k + 1) * a ^ k * (b : ℤ) ^ (N - (k + 1)), by ring⟩ have ha_dvd_bN : a ∣ (b : ℤ) ^ N := by obtain ⟨t, ht⟩ := ha_dvd_sum exact ⟨-t, by linarith⟩ have ha_nat : a.natAbs ∣ b ^ N := by have h := Int.natAbs_dvd_natAbs.mpr ha_dvd_bN simpa [Int.natAbs_pow] using h have ha_abs_one : a.natAbs = 1 := Nat.dvd_one.mp ((hcop.pow_right N).dvd_of_dvd_mul_left (by simpa using ha_nat)) have ha_pm : a = 1 ∨ a = -1 := Int.natAbs_eq_iff.mp ha_abs_one -- Step 2: a ≠ 1 since all terms would be strictly positive have ha_eq : a = -1 := by rcases ha_pm with ha1 | ha1 · exfalso have hS_pos : 0 < S := by dsimp [S] refine Finset.sum_pos (fun k hk => ?_) (Finset.nonempty_range_iff.mpr (by omega)) have hkN : k ≤ N := Nat.lt_succ_iff.mp (Finset.mem_range.mp hk) have hfk := hpos k hkN have hbz : (0 : ℤ) < (b : ℤ) ^ (N - k) := pow_pos (by exact_mod_cast hb_pos) _ rw [ha1, one_pow, mul_one] exact mul_pos hfk hbz omega · exact ha1 -- Step 3: 2 ∣ b since 2 ∣ f.coeff (k + 1) for all k have h2_dvd_sum : (2 : ℤ) ∣ ∑ k ∈ Finset.range N, f.coeff (k + 1) * a ^ (k + 1) * (b : ℤ) ^ (N - (k + 1)) := by refine Finset.dvd_sum fun k _ => ?_ exact dvd_mul_of_dvd_left (dvd_mul_of_dvd_left (heven (k + 1) (by omega)) _) _ have h2_dvd_bN : (2 : ℤ) ∣ (b : ℤ) ^ N := by obtain ⟨t, ht⟩ := h2_dvd_sum exact ⟨-t, by linarith⟩ have h2_dvd_bN_nat : 2 ∣ b ^ N := by have h := Int.natAbs_dvd_natAbs.mpr h2_dvd_bN simpa [Int.natAbs_pow] using h have h2_dvd_b : 2 ∣ b := Nat.Prime.dvd_of_dvd_pow Nat.prime_two h2_dvd_bN_nat have hb_ge2 : 2 ≤ b := Nat.le_of_dvd hb_pos h2_dvd_b refine ⟨b, h2_dvd_b, hb_ge2, ?_⟩ rw [hq_eq, ha_eq]; simp /-! ### 5.3 Universal Rational-Root Nonexistence for $P_n$ and $Q_n$ ($n \ge 2$) -/ /-- **Theorem 7a (Universal Rational-Root Nonexistence for $P_n$)**: For every $n \ge 2$, $P_n(x)$ has no rational root. -/ theorem polyP_no_rat_root {n : ℕ} (hn : 2 ≤ n) (q : ℚ) : (polyP n).eval q ≠ 0 := by intro hq rw [← polyPInt_map_rat] at hq have hdeg : 1 ≤ (polyPInt n).natDegree := by rw [polyPInt_natDegree]; omega have h0 : (polyPInt n).coeff 0 = 1 := by rw [polyPInt_coeff, if_pos (Nat.zero_le n)]; norm_num [pCoeff] have hpos : ∀ k ≤ (polyPInt n).natDegree, 0 < (polyPInt n).coeff k := by intro k hk rw [polyPInt_natDegree] at hk rw [polyPInt_coeff, if_pos hk] exact_mod_cast pCoeff_pos k have heven : ∀ k, 1 ≤ k → 2 ∣ (polyPInt n).coeff k := by intro k hk rw [polyPInt_coeff] split_ifs · have h4 : 4 ∣ pCoeff k := four_dvd_pCoeff hk exact dvd_trans (by norm_num : (2 : ℤ) ∣ 4) (Int.natCast_dvd_natCast.mpr h4) · exact dvd_zero 2 obtain ⟨d, h2d, hd2, rfl⟩ := rat_root_eq_neg_inv_even hdeg h0 hpos heven hq have hd_pos : 0 < d := by omega have halt0 : altSum pCoeff d n = 0 := by have hsum : (polyPInt n).map (Int.castRingHom ℚ) = polyP n := polyPInt_map_rat n rw [hsum] at hq have heval : (polyP n).eval (-1 / (d : ℚ)) = ∑ k ∈ Finset.range (n + 1), (pCoeff k : ℚ) * (-1 / (d : ℚ)) ^ k := by unfold polyP pCoeff rw [Polynomial.eval_finsetSum] refine Finset.sum_congr rfl fun k _ => ?_ simp [Polynomial.eval_mul, Polynomial.eval_pow, Polynomial.eval_X] have hmul := eval_neg_inv_eq_altSum pCoeff (by norm_num [pCoeff]) hd_pos.ne' n rw [← heval, hq, mul_zero] at hmul exact Int.cast_eq_zero.mp hmul.symm by_cases hd16 : 16 ≤ d · exact (altSum_pos_of_step_lt pCoeff (by norm_num [pCoeff]) hd_pos (pCoeff_step_lt_of_ge_16 hd16) n).ne' halt0 · have hcases : d = 2 ∨ d = 4 ∨ d = 6 ∨ d = 8 ∨ d = 10 ∨ d = 12 ∨ d = 14 := by obtain ⟨t, rfl⟩ := h2d; omega rcases hcases with rfl | rfl | rfl | rfl | rfl | rfl | rfl · exact altSum_ne_zero_of_check pCoeff (by norm_num [pCoeff]) pCoeffStep pCoeff_succ_eq_step (M := 1) (by norm_num) (by decide) (fun k hk => pCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 · exact altSum_ne_zero_of_check pCoeff (by norm_num [pCoeff]) pCoeffStep pCoeff_succ_eq_step (M := 3) (by norm_num) (by decide) (fun k hk => pCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 · exact altSum_ne_zero_of_check pCoeff (by norm_num [pCoeff]) pCoeffStep pCoeff_succ_eq_step (M := 3) (by norm_num) (by decide) (fun k hk => pCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 · exact altSum_ne_zero_of_check pCoeff (by norm_num [pCoeff]) pCoeffStep pCoeff_succ_eq_step (M := 5) (by norm_num) (by decide) (fun k hk => pCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 · exact altSum_ne_zero_of_check pCoeff (by norm_num [pCoeff]) pCoeffStep pCoeff_succ_eq_step (M := 9) (by norm_num) (by decide) (fun k hk => pCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 · exact altSum_ne_zero_of_check pCoeff (by norm_num [pCoeff]) pCoeffStep pCoeff_succ_eq_step (M := 15) (by norm_num) (by decide) (fun k hk => pCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 · exact altSum_ne_zero_of_check pCoeff (by norm_num [pCoeff]) pCoeffStep pCoeff_succ_eq_step (M := 41) (by norm_num) (by decide) (fun k hk => pCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 /-- **Theorem 7b (Universal Rational-Root Nonexistence for $Q_n$)**: For every $n \ge 2$, $Q_n(x)$ has no rational root. -/ theorem polyQ_no_rat_root {n : ℕ} (hn : 2 ≤ n) (q : ℚ) : (polyQ n).eval q ≠ 0 := by intro hq rw [← polyQInt_map_rat] at hq have hdeg : 1 ≤ (polyQInt n).natDegree := by rw [polyQInt_natDegree]; omega have h0 : (polyQInt n).coeff 0 = 1 := by rw [polyQInt_coeff, if_pos (Nat.zero_le n)]; norm_num [qCoeff] have hpos : ∀ k ≤ (polyQInt n).natDegree, 0 < (polyQInt n).coeff k := by intro k hk rw [polyQInt_natDegree] at hk rw [polyQInt_coeff, if_pos hk] exact_mod_cast qCoeff_pos k have heven : ∀ k, 1 ≤ k → 2 ∣ (polyQInt n).coeff k := by intro k hk rw [polyQInt_coeff] split_ifs · have : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ have hv : 1 ≤ padicValNat 2 (qCoeff k) := by rcases k with _ | _ | k' · omega · have hq1 : qCoeff 1 = 2 := by decide rw [hq1, padicValNat.self (by norm_num)] · exact le_trans (by norm_num) (two_le_padicValNat_qCoeff (show 2 ≤ k' + 2 by omega)) have h2 : 2 ∣ qCoeff k := by have := (padicValNat_dvd_iff_le (qCoeff_pos k).ne').mpr hv simpa using this exact Int.natCast_dvd_natCast.mpr h2 · exact dvd_zero 2 obtain ⟨d, h2d, hd2, rfl⟩ := rat_root_eq_neg_inv_even hdeg h0 hpos heven hq have hd_pos : 0 < d := by omega have halt0 : altSum qCoeff d n = 0 := by have hsum : (polyQInt n).map (Int.castRingHom ℚ) = polyQ n := polyQInt_map_rat n rw [hsum] at hq have heval : (polyQ n).eval (-1 / (d : ℚ)) = ∑ k ∈ Finset.range (n + 1), (qCoeff k : ℚ) * (-1 / (d : ℚ)) ^ k := by rw [← polyQInt_map_rat] unfold polyQInt rw [Polynomial.map_sum, Polynomial.eval_finsetSum] refine Finset.sum_congr rfl fun k _ => ?_ simp [Polynomial.eval_mul, Polynomial.eval_pow, Polynomial.eval_X] have hmul := eval_neg_inv_eq_altSum qCoeff (by norm_num [qCoeff]) hd_pos.ne' n rw [← heval, hq, mul_zero] at hmul exact Int.cast_eq_zero.mp hmul.symm by_cases hd16 : 16 ≤ d · exact (altSum_pos_of_step_lt qCoeff (by norm_num [qCoeff]) hd_pos (qCoeff_step_lt_of_ge_16 hd16) n).ne' halt0 · have hcases : d = 2 ∨ d = 4 ∨ d = 6 ∨ d = 8 ∨ d = 10 ∨ d = 12 ∨ d = 14 := by obtain ⟨t, rfl⟩ := h2d; omega rcases hcases with rfl | rfl | rfl | rfl | rfl | rfl | rfl · exact altSum_ne_zero_of_check qCoeff (by norm_num [qCoeff]) qCoeffStep qCoeff_succ_eq_step (M := 3) (by norm_num) (by decide) (fun k hk => qCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 · exact altSum_ne_zero_of_check qCoeff (by norm_num [qCoeff]) qCoeffStep qCoeff_succ_eq_step (M := 3) (by norm_num) (by decide) (fun k hk => qCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 · exact altSum_ne_zero_of_check qCoeff (by norm_num [qCoeff]) qCoeffStep qCoeff_succ_eq_step (M := 5) (by norm_num) (by decide) (fun k hk => qCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 · exact altSum_ne_zero_of_check qCoeff (by norm_num [qCoeff]) qCoeffStep qCoeff_succ_eq_step (M := 9) (by norm_num) (by decide) (fun k hk => qCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 · exact altSum_ne_zero_of_check qCoeff (by norm_num [qCoeff]) qCoeffStep qCoeff_succ_eq_step (M := 15) (by norm_num) (by decide) (fun k hk => qCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 · exact altSum_ne_zero_of_check qCoeff (by norm_num [qCoeff]) qCoeffStep qCoeff_succ_eq_step (M := 31) (by norm_num) (by decide) (fun k hk => qCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 · exact altSum_ne_zero_of_check qCoeff (by norm_num [qCoeff]) qCoeffStep qCoeff_succ_eq_step (M := 79) (by norm_num) (by decide) (fun k hk => qCoeff_step_gt_of_quad (by nlinarith)) n hn halt0 /-! ### 5.4 Shifted 3-adic Newton Polygon + Rational-Root Exclusion: Irreducibility of $P_{13}$ -/ def pCoeffFast : ℕ → ℕ | 0 => 1 | k + 1 => pCoeffStep k (pCoeffFast k) lemma pCoeffFast_eq (k : ℕ) : pCoeffFast k = pCoeff k := by induction k with | zero => norm_num [pCoeffFast, pCoeff] | succ k ih => rw [pCoeffFast, ih, ← pCoeff_succ_eq_step] def f13CoeffFast (j : ℕ) : ℤ := ∑ k ∈ Finset.range 14, (pCoeffFast k : ℤ) * (if j ≤ k then (-1 : ℤ) ^ (k - j) * (Nat.choose k j : ℤ) else 0) lemma X_sub_one_pow_coeff (k j : ℕ) : ((Polynomial.X - 1 : ℤ[X]) ^ k).coeff j = if j ≤ k then (-1 : ℤ) ^ (k - j) * (Nat.choose k j : ℤ) else 0 := by rw [show (Polynomial.X - 1 : ℤ[X]) = Polynomial.X + Polynomial.C (-1 : ℤ) by simp [sub_eq_add_neg]] rw [add_pow, Polynomial.finsetSum_coeff] have hterm : ∀ m ∈ Finset.range (k + 1), (Polynomial.X ^ m * Polynomial.C (-1 : ℤ) ^ (k - m) * (Nat.choose k m : ℤ[X])).coeff j = if m = j then (-1 : ℤ) ^ (k - m) * (Nat.choose k m : ℤ) else 0 := by intro m _ rw [← map_pow, show (Nat.choose k m : ℤ[X]) = Polynomial.C (Nat.choose k m : ℤ) by simp, mul_assoc, ← map_mul, mul_comm (Polynomial.X ^ m), Polynomial.coeff_C_mul_X_pow] by_cases h : m = j · subst h; simp · have h' : j ≠ m := fun heq => h heq.symm simp [h, h'] rw [Finset.sum_congr rfl hterm, Finset.sum_ite_eq'] simp lemma polyPInt13_comp_coeff (j : ℕ) : ((polyPInt 13).comp (Polynomial.X - 1)).coeff j = f13CoeffFast j := by unfold polyPInt f13CoeffFast rw [Polynomial.sum_comp, Polynomial.finsetSum_coeff] refine Finset.sum_congr rfl fun k _ => ?_ rw [Polynomial.mul_comp, Polynomial.C_comp, Polynomial.X_pow_comp, Polynomial.coeff_C_mul, X_sub_one_pow_coeff, pCoeffFast_eq] /-- **Theorem 8 (Irreducibility of $P_{13}$ via Shifted 3-adic Newton Polygon + No Rational Root)**: $P_{13}(x)$ is irreducible over $\mathbb{Q}$. Neither 2-adic Dumas nor any unshifted prime Newton polygon settles $P_{13}$ alone; shifting to $P_{13}(x - 1)$ exposes a 3-adic segment of width 12, and `polyP_no_rat_root` rules out a linear factor. -/ theorem polyP_irreducible_thirteen : Irreducible (polyP 13) := by have : Fact (Nat.Prime 3) := ⟨Nat.prime_three⟩ set f13 : ℤ[X] := (polyPInt 13).comp (Polynomial.X - 1) have hf13_inv : f13.comp (Polynomial.X + 1) = polyPInt 13 := by dsimp [f13]; rw [Polynomial.comp_assoc]; simp have hf13_prim : f13.IsPrimitive := by rw [Polynomial.isPrimitive_iff_isUnit_of_C_dvd] intro r hr obtain ⟨u, hu⟩ := hr have hdiv : Polynomial.C r ∣ polyPInt 13 := by refine ⟨u.comp (Polynomial.X + 1), ?_⟩ rw [← hf13_inv, hu, Polynomial.mul_comp, Polynomial.C_comp] exact (Polynomial.isPrimitive_iff_isUnit_of_C_dvd.mp (polyPInt_isPrimitive 13)) r hdiv have hf13_deg : f13.natDegree = 13 := by dsimp [f13] rw [Polynomial.natDegree_comp, polyPInt_natDegree] have hX1 : (Polynomial.X - 1 : ℤ[X]).natDegree = 1 := Polynomial.natDegree_X_sub_C 1 rw [hX1, mul_one] -- Exact 3-adic divisibility facts checked in the kernel (pure decidability) have hc0 : f13CoeffFast 0 ≠ 0 ∧ (9 : ℤ) ∣ f13CoeffFast 0 := by decide have hc1 : f13CoeffFast 1 ≠ 0 ∧ (3 : ℤ) ∣ f13CoeffFast 1 ∧ ¬ (9 : ℤ) ∣ f13CoeffFast 1 := by decide have hcmid : ∀ j ∈ Finset.Icc 2 12, (3 : ℤ) ∣ f13CoeffFast j := by decide have hc13 : f13CoeffFast 13 ≠ 0 ∧ ¬ (3 : ℤ) ∣ f13CoeffFast 13 := by decide have hv_ge : ∀ z : ℤ, z ≠ 0 → ∀ e : ℕ, ((3 : ℤ) ^ e) ∣ z → e ≤ padicValInt 3 z := by intro z hz e hd rw [padicValInt, ← padicValNat_dvd_iff_le (Int.natAbs_ne_zero.mpr hz)] have h := Int.natAbs_dvd_natAbs.mpr hd simpa [Int.natAbs_pow] using h have hv_lt : ∀ z : ℤ, z ≠ 0 → ∀ e : ℕ, ¬ ((3 : ℤ) ^ e) ∣ z → padicValInt 3 z < e := by intro z hz e hnd by_contra hge have h1 : 3 ^ e ∣ z.natAbs := (padicValNat_dvd_iff_le (Int.natAbs_ne_zero.mpr hz)).mpr (by rw [← padicValInt]; omega) have h2 : ((3 : ℤ) ^ e) ∣ z := by have := Int.natCast_dvd.mpr h1 simpa using this exact hnd h2 have hv1 : padicValInt 3 (f13.coeff 1) = 1 := by rw [polyPInt13_comp_coeff] have h1 := hv_ge _ hc1.1 1 (by simpa using hc1.2.1) have h2 := hv_lt _ hc1.1 2 (by simpa using hc1.2.2) omega have hv13 : padicValInt 3 (f13.coeff 13) = 0 := by rw [polyPInt13_comp_coeff] have h2 := hv_lt _ hc13.1 1 (by simpa using hc13.2) omega -- Weight at (p=3, w=12, h=-1): npWeight 3 12 (-1) f13 k = 12 * v_3(c_k) + k have hwt1 : npWeight 3 12 (-1) f13 1 = 13 := by unfold npWeight; rw [hv1]; norm_num have hwt13 : npWeight 3 12 (-1) f13 13 = 13 := by unfold npWeight; rw [hv13]; norm_num have hge13 : ∀ k, f13.coeff k ≠ 0 → (13 : ℤ) ≤ npWeight 3 12 (-1) f13 k := by intro k hk have hk13 : k ≤ 13 := by have := Polynomial.le_natDegree_of_ne_zero hk; omega unfold npWeight rcases eq_or_ne k 0 with rfl | hk0 · have hv0 : 2 ≤ padicValInt 3 (f13.coeff 0) := by rw [polyPInt13_comp_coeff]; exact hv_ge _ hc0.1 2 (by simpa using hc0.2) omega · rcases eq_or_ne k 1 with rfl | hk1 · rw [hv1]; norm_num · rcases eq_or_ne k 13 with rfl | hk13' · rw [hv13]; norm_num · have hv_mid : 1 ≤ padicValInt 3 (f13.coeff k) := by rw [polyPInt13_comp_coeff] exact hv_ge _ (by rw [← polyPInt13_comp_coeff]; exact hk) 1 (by simpa using hcmid k (Finset.mem_Icc.mpr ⟨by omega, by omega⟩)) omega have hmin13 : npMinVal 3 12 (-1) f13 = 13 := by apply le_antisymm · rw [← hwt1] exact npMinVal_le (by rw [polyPInt13_comp_coeff]; exact hc1.1) · obtain ⟨k, hk⟩ := npAttain_nonempty (p := 3) (w := 12) (h := -1) hf13_prim.ne_zero have hk' := Finset.mem_filter.mp hk rw [← hk'.2]; exact hge13 k (Polynomial.mem_support_iff.mp hk'.1) have hleft1 : npLeft 3 12 (-1) f13 = 1 := by apply le_antisymm · exact npLeft_le_of_eq (by rw [polyPInt13_comp_coeff]; exact hc1.1) (hwt1.trans hmin13.symm) · by_contra hlt have h0eq : npLeft 3 12 (-1) f13 = 0 := by omega have hm := Finset.mem_filter.mp (npLeft_mem_attain (p := 3) (w := 12) (h := -1) hf13_prim.ne_zero) rw [h0eq, hmin13] at hm have hv0 : 2 ≤ padicValInt 3 (f13.coeff 0) := by rw [polyPInt13_comp_coeff]; exact hv_ge _ hc0.1 2 (by simpa using hc0.2) unfold npWeight at hm; omega have hright13 : npRight 3 12 (-1) f13 = 13 := by apply le_antisymm · have := npRight_le_natDegree (p := 3) (w := 12) (h := -1) hf13_prim.ne_zero omega · exact le_npRight_of_eq (by rw [polyPInt13_comp_coeff]; exact hc13.1) (hwt13.trans hmin13.symm) have hwidth12 : npWidth 3 12 (-1) f13 = 12 := by unfold npWidth; rw [hleft1, hright13] obtain ⟨g, hg_irred, hg_dvd, hg_deg⟩ := exists_irred_factor_natDegree_ge_of_npWidth (p := 3) (w := 12) (h := -1) (by norm_num) (by simp) f13.natDegree f13 le_rfl hf13_prim hwidth12 have hf13_map : f13.map (Int.castRingHom ℚ) = (polyP 13).comp (Polynomial.X - 1) := by dsimp [f13] rw [Polynomial.map_comp, polyPInt_map_rat] simp rw [hf13_map] at hg_dvd -- Shift g back by X + 1 set g' : ℚ[X] := g.comp (Polynomial.X + 1) have hg'_inv : g'.comp (Polynomial.X - 1) = g := by dsimp [g']; rw [Polynomial.comp_assoc]; simp have hg'_dvd : g' ∣ polyP 13 := by obtain ⟨q, hq⟩ := hg_dvd refine ⟨q.comp (Polynomial.X + 1), ?_⟩ have h := congrArg (fun p : ℚ[X] => p.comp (Polynomial.X + 1)) hq rw [Polynomial.comp_assoc] at h simpa [Polynomial.mul_comp, g'] using h have hg'_irred : Irreducible g' := by refine ⟨?_, ?_⟩ · intro hu obtain ⟨v, hv⟩ := hu.exists_right_inv have hv' : g * v.comp (Polynomial.X - 1) = 1 := by have h := congrArg (fun p : ℚ[X] => p.comp (Polynomial.X - 1)) hv simpa [Polynomial.mul_comp, hg'_inv] using h exact hg_irred.not_isUnit (isUnit_iff_exists_inv.mpr ⟨_, hv'⟩) · intro a b hab have hcomp : g = a.comp (Polynomial.X - 1) * b.comp (Polynomial.X - 1) := by rw [← hg'_inv, hab, Polynomial.mul_comp] rcases hg_irred.isUnit_or_isUnit hcomp with ha | hb · left obtain ⟨v, hv⟩ := ha.exists_right_inv refine isUnit_iff_exists_inv.mpr ⟨v.comp (Polynomial.X + 1), ?_⟩ have h := congrArg (fun p : ℚ[X] => p.comp (Polynomial.X + 1)) hv rw [Polynomial.mul_comp, Polynomial.comp_assoc] at h simpa using h · right obtain ⟨v, hv⟩ := hb.exists_right_inv refine isUnit_iff_exists_inv.mpr ⟨v.comp (Polynomial.X + 1), ?_⟩ have h := congrArg (fun p : ℚ[X] => p.comp (Polynomial.X + 1)) hv rw [Polynomial.mul_comp, Polynomial.comp_assoc] at h simpa using h have hg'_deg : 12 ≤ g'.natDegree := by dsimp [g'] rw [Polynomial.natDegree_comp, show (Polynomial.X + 1 : ℚ[X]) = Polynomial.X + Polynomial.C 1 by simp, Polynomial.natDegree_X_add_C, mul_one] exact hg_deg obtain ⟨h', hh'⟩ := hg'_dvd have hP13_ne : polyP 13 ≠ 0 := by rw [← polyPInt_map_rat] intro h0 exact (polyPInt_isPrimitive 13).ne_zero (Polynomial.map_injective (Int.castRingHom ℚ) Int.cast_injective (by simpa using h0)) have hg'_ne : g' ≠ 0 := hg'_irred.ne_zero have hh'_ne : h' ≠ 0 := fun h0 => hP13_ne (by rw [hh', h0, mul_zero]) have hP13_deg : (polyP 13).natDegree = 13 := by rw [← polyPInt_map_rat, Polynomial.natDegree_map_eq_of_injective Int.cast_injective, polyPInt_natDegree] have hdeg_sum : g'.natDegree + h'.natDegree = 13 := by rw [← Polynomial.natDegree_mul hg'_ne hh'_ne, ← hh', hP13_deg] have hh'_le1 : h'.natDegree ≤ 1 := by omega rcases Nat.le_one_iff_eq_zero_or_eq_one.mp hh'_le1 with hh0 | hh1 · -- Degree 0: h' is a nonzero constant, hence a unit have hu : IsUnit h' := by rw [Polynomial.eq_C_of_natDegree_eq_zero hh0] refine Polynomial.isUnit_C.mpr (IsUnit.mk0 _ ?_) intro hc0; apply hh'_ne; rw [Polynomial.eq_C_of_natDegree_eq_zero hh0, hc0, map_zero] rw [hh'] exact (associated_mul_unit_right g' h' hu).irreducible hg'_irred · -- Degree 1: h' has a rational root, contradicting polyP_no_rat_root exfalso have hl_ne : h'.coeff 1 ≠ 0 := by rw [← hh1]; exact Polynomial.leadingCoeff_ne_zero.mpr hh'_ne set r : ℚ := -(h'.coeff 0) / (h'.coeff 1) have hr_root : h'.eval r = 0 := by have hlin := Polynomial.eq_X_add_C_of_natDegree_le_one (le_of_eq hh1) rw [hlin, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_C] dsimp [r]; field_simp [hl_ne]; ring have hP_root : (polyP 13).eval r = 0 := by rw [hh', Polynomial.eval_mul, hr_root, mul_zero] exact polyP_no_rat_root (by omega : 2 ≤ 13) r hP_root end OeisA115257 /-! ## Section 6: Axiom Audit (`#print axioms`) Every headline theorem depends strictly on Lean's three standard foundational axioms: `[propext, Classical.choice, Quot.sound]`. -/ #print axioms OeisA115257.padicValNat_centralBinom_eq_sum_digits #print axioms OeisA115257.irreducible_of_mod16_two_pow #print axioms OeisA115257.np_mul_props #print axioms OeisA115257.dvd_npWidth #print axioms OeisA115257.dumas_single_segment_dvd_natDegree #print axioms OeisA115257.irreducible_of_dumas_single_segment #print axioms OeisA115257.exists_irred_factor_natDegree_ge_of_npWidth #print axioms OeisA115257.dvd_natDegree_of_slope_list #print axioms OeisA115257.polyP_irreducible_two_pow #print axioms OeisA115257.centralBinomPowPoly_irreducible_two_pow_odd #print axioms OeisA115257.polyQ_two_pow_factor_deg_dvd #print axioms OeisA115257.polyQ_irreducible_one #print axioms OeisA115257.polyQ_irreducible_three #print axioms OeisA115257.polyQ_irreducible_seven #print axioms OeisA115257.polyP_four_mul_even_factor_deg #print axioms OeisA115257.polyQ_four_mul_even_factor_deg #print axioms OeisA115257.polyQ_prime_sub_one_large_irred_factor #print axioms OeisA115257.polyP_prime_sub_one_large_irred_factor #print axioms OeisA115257.polyP_no_rat_root #print axioms OeisA115257.polyQ_no_rat_root #print axioms OeisA115257.polyP_irreducible_thirteen