import Mathlib.NumberTheory.FactorisationPropertiesimport Mathlib.NumberTheory.ArithmeticFunction.Misc/-!# Partial Machine-Checked Results for Erdős Problem #470Formalizes verified partial theorems supporting our investigation of Erdős #470(existence of odd weird numbers):1. `weird_of_abundance_lt_min_prime` & `weird_of_odd_abundance_two`:If `n` is abundant with `2 ≤ δ(n) < p_min(n)` (in particular, `n` odd and `δ(n) = 2`),then `n` is weird.2. `not_abundant_kravitz_base` & `not_weird_kravitz_base`:Kravitz-type `m * Q * R` obstruction: if `2 * m - σ(m) ≥ 2` and `R > Q > σ(m)` areprimes coprime to `m`, then `m * Q * R` is deficient (hence not weird).3. `not_abundant_odd_sqfree_omega_le_four` & `not_weird_odd_sqfree_omega_le_four`:Every odd squarefree `n` with `ω(n) ≤ 4` is not abundant (hence not weird).4. `abundant_945`, `pseudoperfect_945`, `not_weird_945`:The smallest odd abundant number `945` is pseudoperfect, hence not weird.-/open Finsetnamespace Erdos470Partial/-! ## 1. Sufficient condition for weirdness via small abundance -/lemma sum_properDivisors_sdiff {n : ℕ} {s : Finset ℕ} (hs : s ⊆ n.properDivisors)(hsum : ∑ i ∈ s, i = n) :∑ i ∈ (n.properDivisors \ s), i = (∑ i ∈ n.properDivisors, i) - n := byhave h := Finset.sum_sdiff (f := fun i : ℕ => i) hsomega/-- If `n > 0` has abundance `δ = σ(n) - 2n` with `1 < δ` and every prime factor `p ∣ n`satisfies `δ < p`, then `n` is weird. -/theorem weird_of_abundance_lt_min_prime {n δ : ℕ} (hn : 0 < n) (hδ : 1 < δ)(hmin : ∀ p, p.Prime → p ∣ n → δ < p)(hsum : ∑ i ∈ n.properDivisors, i = n + δ) : n.Weird := byrefine ⟨?_, ?_⟩· unfold Nat.Abundantomega· rintro ⟨_, s, hs, hsn⟩set t := n.properDivisors \ shave htsum : ∑ i ∈ t, i = δ := byhave h := sum_properDivisors_sdiff hs hsnchange ∑ i ∈ (n.properDivisors \ s), i = δomegahave ht_sub : t ⊆ ({1} : Finset ℕ) := byintro d hdrw [Finset.mem_singleton]have hd_prop : d ∈ n.properDivisors := (Finset.mem_sdiff.mp hd).1have hd_dvd : d ∣ n := (Nat.mem_properDivisors.mp hd_prop).1have hd_pos : 0 < d := Nat.pos_of_ne_zero fun h => bysubst hrw [zero_dvd_iff] at hd_dvdexact hn.ne' hd_dvdhave hd_le : d ≤ δ := bycalc d ≤ ∑ i ∈ t, i :=Finset.single_le_sum (f := fun i : ℕ => i) (fun _ _ => Nat.zero_le _) hd_ = δ := htsumby_contra hd_ne_onehave hp : d.minFac.Prime := Nat.minFac_prime hd_ne_onehave hp_dvd : d.minFac ∣ n := (Nat.minFac_dvd d).trans hd_dvdhave hδ_lt : δ < d.minFac := hmin d.minFac hp hp_dvdhave hmf_le : d.minFac ≤ d := Nat.minFac_le hd_posomegahave hle1 : ∑ i ∈ t, i ≤ 1 := bycalc ∑ i ∈ t, i ≤ ∑ i ∈ ({1} : Finset ℕ), i :=Finset.sum_le_sum_of_subset_of_nonneg ht_sub (fun _ _ _ => Nat.zero_le _)_ = 1 := by simpomega/-- Any odd `n` with `σ(n) = 2n + 2` (i.e., abundance `2`) is weird. -/theorem weird_of_odd_abundance_two {n : ℕ} (hodd : Odd n)(hsum : ∑ i ∈ n.properDivisors, i = n + 2) : n.Weird := byhave hn : 0 < n := Nat.pos_of_ne_zero (by rintro rfl; simp at hodd)refine weird_of_abundance_lt_min_prime hn (by decide) ?_ hsumintro p hp hpnhave hp2 : p ≠ 2 := byrintro rflexact (Nat.not_odd_iff_even.mpr (even_iff_two_dvd.mpr hpn)) hoddhave hp_ge2 : 2 ≤ p := hp.two_leomega/-! ## 2. Theorem 2: Obstruction to Kravitz-type `m * Q * R` constructions -//-- If `m ≥ 1` is deficient with `2 * m - σ(m) ≥ 2`, and `R > Q > σ(m)` are primescoprime to `m`, then `m * Q * R` is not abundant (in fact deficient). -/theorem not_abundant_kravitz_base {m Q R : ℕ} (hm : 0 < m)(hdef : ∑ d ∈ m.divisors, d + 2 ≤ 2 * m)(hQ : Q.Prime) (hR : R.Prime)(hmQ : m.Coprime Q) (hmR : m.Coprime R)(hσQ : ∑ d ∈ m.divisors, d < Q) (hQR : Q < R) :¬ (m * Q * R).Abundant := byhave hQR_ne : Q ≠ R := hQR.nehave hQR_cop : Q.Coprime R := (Nat.coprime_primes hQ hR).mpr hQR_nehave hmQ_R : (m * Q).Coprime R := hmR.mul_left hQR_cophave hσ_mul : ∑ d ∈ (m * Q * R).divisors, d =(∑ d ∈ m.divisors, d) * (Q + 1) * (R + 1) := byrw [hmQ_R.sum_divisors_mul, hmQ.sum_divisors_mul, hR.sum_divisors, hQ.sum_divisors]have hN_pos : 0 < m * Q * R := Nat.mul_pos (Nat.mul_pos hm hQ.pos) hR.posunfold Nat.Abundantrw [← Nat.add_lt_add_iff_right (k := m * Q * R), ← Nat.sum_divisors_eq_sum_properDivisors_add_self]rw [hσ_mul]set S := ∑ d ∈ m.divisors, dhave hm_ge1 : 1 ≤ S := byhave h1 : 1 ∈ m.divisors := Nat.one_mem_divisors.mpr hm.ne'exact Finset.single_le_sum (f := fun i : ℕ => i) (fun _ _ => Nat.zero_le _) h1have hm_ge2 : 2 ≤ m := by omegahave hm_le_S : m + 1 ≤ S := byhave hsub : ({1, m} : Finset ℕ) ⊆ m.divisors := byintro x hxsimp only [Finset.mem_insert, Finset.mem_singleton] at hxrcases hx with rfl | hxm· exact Nat.one_mem_divisors.mpr hm.ne'· rw [hxm]; exact Nat.mem_divisors.mpr ⟨dvd_refl m, hm.ne'⟩have hne : (1 : ℕ) ≠ m := by omegacalc m + 1 = ∑ x ∈ ({1, m} : Finset ℕ), x := by rw [Finset.sum_pair hne]; omega_ ≤ S := Finset.sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => Nat.zero_le _)have hQ_ne2 : Q ≠ 2 := by omegahave hR_ne2 : R ≠ 2 := by omegahave hQ_odd : Q % 2 = 1 := (Nat.Prime.eq_two_or_odd hQ).resolve_left hQ_ne2have hR_odd : R % 2 = 1 := (Nat.Prime.eq_two_or_odd hR).resolve_left hR_ne2have hR_ge : Q + 2 ≤ R := by omegahave h1 : S * (Q + 1) + Q < 2 * m * Q := by nlinarithhave h2 : S * (Q + 1) < Q * R := by nlinarithnlinarith/-- Under the hypotheses of `not_abundant_kravitz_base`, `m * Q * R` is not weird. -/theorem not_weird_kravitz_base {m Q R : ℕ} (hm : 0 < m)(hdef : ∑ d ∈ m.divisors, d + 2 ≤ 2 * m)(hQ : Q.Prime) (hR : R.Prime)(hmQ : m.Coprime Q) (hmR : m.Coprime R)(hσQ : ∑ d ∈ m.divisors, d < Q) (hQR : Q < R) :¬ (m * Q * R).Weird :=fun hw => not_abundant_kravitz_base hm hdef hQ hR hmQ hmR hσQ hQR hw.1/-! ## 3. Theorem 1 (r ≤ 4): No odd squarefree number with `ω(n) ≤ 4` is abundant -/private lemma sqfree_sum_divisors_eq_prod {n : ℕ} (hn : n ≠ 0) (hsq : Squarefree n) :∑ d ∈ n.divisors, d = ∏ p ∈ n.primeFactors, (p + 1) := byrw [Nat.sum_divisors hn]refine Finset.prod_congr rfl fun p hp => ?_have hfac : n.factorization p = 1 := byhave hle := hsq.natFactorization_le_one phave hpos : 0 < n.factorization p :=Nat.Prime.factorization_pos_of_dvd (Nat.prime_of_mem_primeFactors hp) hn(Nat.dvd_of_mem_primeFactors hp)omegarw [hfac]simp [Finset.sum_range_succ, add_comm]private lemma odd_prime_ge_13_of_not_mem {p : ℕ} (hp : p.Prime) (hodd : Odd p)(hnot : p ∉ ({3, 5, 7, 11} : Finset ℕ)) : 13 ≤ p := bysimp only [Finset.mem_insert, Finset.mem_singleton, not_or] at hnothave hp2 : p ≠ 2 := byrintro rflrevert hodddecidehave hp_ge2 : 2 ≤ p := hp.two_lehave hne4 : p ≠ 4 := fun h => by subst h; revert hp; decidehave hne6 : p ≠ 6 := fun h => by subst h; revert hp; decidehave hne8 : p ≠ 8 := fun h => by subst h; revert hp; decidehave hne9 : p ≠ 9 := fun h => by subst h; revert hp; decidehave hne10 : p ≠ 10 := fun h => by subst h; revert hp; decidehave hne12 : p ≠ 12 := fun h => by subst h; revert hp; decideomegaprivate lemma prod_abundancy_odd_le_four {S : Finset ℕ}(hS_prime : ∀ p ∈ S, p.Prime) (hS_odd : ∀ p ∈ S, Odd p) (hS_card : S.card ≤ 4) :∏ p ∈ S, ((p + 1 : ℚ) / p) < 2 := byset P₀ : Finset ℕ := {3, 5, 7, 11}have hP₀_card : P₀.card = 4 := by decidehave hcard_split : (S ∩ P₀).card + (S \ P₀).card = S.card :=Finset.card_inter_add_card_sdiff S P₀have hcard_split2 : (P₀ ∩ S).card + (P₀ \ S).card = P₀.card :=Finset.card_inter_add_card_sdiff P₀ Shave hcard_le : (S \ P₀).card ≤ (P₀ \ S).card := byrw [Finset.inter_comm] at hcard_split2omegahave h1 : ∏ p ∈ S \ P₀, ((p + 1 : ℚ) / p) ≤ (12 / 11 : ℚ) ^ (S \ P₀).card := bycalc ∏ p ∈ S \ P₀, ((p + 1 : ℚ) / p)≤ ∏ _p ∈ S \ P₀, (12 / 11 : ℚ) := byrefine Finset.prod_le_prod (fun p hp => by positivity) (fun p hp => ?_)have hp_mem : p ∈ S := (Finset.mem_sdiff.mp hp).1have hp_not : p ∉ P₀ := (Finset.mem_sdiff.mp hp).2have hp13 : 13 ≤ p :=odd_prime_ge_13_of_not_mem (hS_prime p hp_mem) (hS_odd p hp_mem) hp_nothave hpq : (13 : ℚ) ≤ (p : ℚ) := by exact_mod_cast hp13rw [div_le_div_iff₀ (by positivity) (by positivity)]linarith_ = (12 / 11 : ℚ) ^ (S \ P₀).card := by rw [Finset.prod_const]have h2 : (12 / 11 : ℚ) ^ (S \ P₀).card ≤ (12 / 11 : ℚ) ^ (P₀ \ S).card :=pow_le_pow_right₀ (by norm_num) hcard_lehave h3 : (12 / 11 : ℚ) ^ (P₀ \ S).card ≤ ∏ p ∈ P₀ \ S, ((p + 1 : ℚ) / p) := bycalc (12 / 11 : ℚ) ^ (P₀ \ S).card= ∏ _p ∈ P₀ \ S, (12 / 11 : ℚ) := by rw [Finset.prod_const]_ ≤ ∏ p ∈ P₀ \ S, ((p + 1 : ℚ) / p) := byrefine Finset.prod_le_prod (fun _ _ => by norm_num) (fun p hp => ?_)have hp_mem : p ∈ P₀ := (Finset.mem_sdiff.mp hp).1fin_cases hp_mem <;> norm_numhave h_main : ∏ p ∈ S, ((p + 1 : ℚ) / p) ≤ ∏ p ∈ P₀, ((p + 1 : ℚ) / p) := byrw [← Finset.prod_inter_mul_prod_sdiff S P₀, ← Finset.prod_inter_mul_prod_sdiff P₀ S,Finset.inter_comm P₀ S]refine mul_le_mul_of_nonneg_left (h1.trans (h2.trans h3)) ?_exact Finset.prod_nonneg (fun p _ => by positivity)have hP₀_val : ∏ p ∈ P₀, ((p + 1 : ℚ) / p) < 2 := bynorm_num [P₀]exact h_main.trans_lt hP₀_val/-- Every odd squarefree `n` with `ω(n) ≤ 4` is not abundant. -/theorem not_abundant_odd_sqfree_omega_le_four {n : ℕ} (hodd : Odd n) (hsq : Squarefree n)(hcard : n.primeFactors.card ≤ 4) : ¬ n.Abundant := byhave hn0 : n ≠ 0 := by rintro rfl; simp at hoddhave hσ : ∑ d ∈ n.divisors, d = ∏ p ∈ n.primeFactors, (p + 1) :=sqfree_sum_divisors_eq_prod hn0 hsqhave hn_prod : n = ∏ p ∈ n.primeFactors, p :=(Nat.prod_primeFactors_of_squarefree hsq).symmhave hS_prime : ∀ p ∈ n.primeFactors, p.Prime := fun _ hp => Nat.prime_of_mem_primeFactors hphave hS_odd : ∀ p ∈ n.primeFactors, Odd p := fun p hp =>hodd.of_dvd_nat (Nat.dvd_of_mem_primeFactors hp)have hlt : ∏ p ∈ n.primeFactors, ((p + 1 : ℚ) / p) < 2 :=prod_abundancy_odd_le_four hS_prime hS_odd hcardhave hprod_pos : (0 : ℚ) < ∏ p ∈ n.primeFactors, (p : ℚ) :=Finset.prod_pos fun p hp => by exact_mod_cast (hS_prime p hp).poshave hσ_rat : (∑ d ∈ n.divisors, (d : ℚ)) = ∏ p ∈ n.primeFactors, ((p : ℚ) + 1) := byhave h : ((∑ d ∈ n.divisors, d : ℕ) : ℚ) = ((∏ p ∈ n.primeFactors, (p + 1) : ℕ) : ℚ) := byexact_mod_cast hσsimpa only [Nat.cast_sum, Nat.cast_prod, Nat.cast_add, Nat.cast_one] using hhave hn_rat : (n : ℚ) = ∏ p ∈ n.primeFactors, (p : ℚ) := byhave h : (n : ℚ) = ((∏ p ∈ n.primeFactors, p : ℕ) : ℚ) := by exact_mod_cast hn_prodsimpa only [Nat.cast_prod] using hhave hlt_mul : (∑ d ∈ n.divisors, (d : ℚ)) < 2 * (n : ℚ) := bycalc (∑ d ∈ n.divisors, (d : ℚ))= ∏ p ∈ n.primeFactors, ((p : ℚ) + 1) := hσ_rat_ = (∏ p ∈ n.primeFactors, ((p + 1 : ℚ) / p)) * (∏ p ∈ n.primeFactors, (p : ℚ)) := byrw [← Finset.prod_mul_distrib]refine Finset.prod_congr rfl fun p hp => ?_have hp0 : (p : ℚ) ≠ 0 := by exact_mod_cast (hS_prime p hp).ne_zerorw [div_mul_cancel₀ _ hp0]_ < 2 * (∏ p ∈ n.primeFactors, (p : ℚ)) := mul_lt_mul_of_pos_right hlt hprod_pos_ = 2 * (n : ℚ) := by rw [← hn_rat]have hlt_nat : ∑ d ∈ n.divisors, d < 2 * n := byhave h : ((∑ d ∈ n.divisors, d : ℕ) : ℚ) < ((2 * n : ℕ) : ℚ) := bysimpa only [Nat.cast_sum, Nat.cast_mul, Nat.cast_ofNat] using hlt_mulexact_mod_cast hunfold Nat.Abundantrw [← Nat.add_lt_add_iff_right (k := n), ← Nat.sum_divisors_eq_sum_properDivisors_add_self]omega/-- Every odd squarefree `n` with `ω(n) ≤ 4` is not weird. -/theorem not_weird_odd_sqfree_omega_le_four {n : ℕ} (hodd : Odd n) (hsq : Squarefree n)(hcard : n.primeFactors.card ≤ 4) : ¬ n.Weird :=fun hw => not_abundant_odd_sqfree_omega_le_four hodd hsq hcard hw.1/-! ## 4. Smallest odd abundant number 945 is pseudoperfect, hence not weird -/theorem abundant_945 : Nat.Abundant 945 := by decide +kerneltheorem pseudoperfect_945 : Nat.Pseudoperfect 945 := byrefine ⟨by decide, ({1, 5, 7, 9, 15, 21, 35, 45, 63, 105, 135, 189, 315} : Finset ℕ),by decide, by decide⟩theorem not_weird_945 : ¬ Nat.Weird 945 :=fun hw => hw.2 pseudoperfect_945/-! ## 5. Lemma 3: Odd Divisor Gap-Free Coverage -//-- Inductive gap-free coverage: if `d 0 = 1`, `d 1 = 3`, `d 2 = 5`, `d` is strictlyincreasing on `range m` (with `3 ≤ m`), and for every `3 ≤ k < m`,`d k ≤ S k - 2` and `d k ≠ S k - 4` (where `S k = ∑ i ∈ range k, d i`), thenevery `x ≤ S m` with `x ≠ 2` and `x ≠ S m - 2` is a subset sum of `(range m).image d`. -/theorem odd_divisor_gap_free_coverage {d : ℕ → ℕ} {m : ℕ} (hm : 3 ≤ m)(hd0 : d 0 = 1) (hd1 : d 1 = 3) (hd2 : d 2 = 5)(hmono : ∀ i j, i < j → j < m → d i < d j)(hstep : ∀ k, 3 ≤ k → k < m →d k ≤ (∑ i ∈ Finset.range k, d i) - 2 ∧ d k ≠ (∑ i ∈ Finset.range k, d i) - 4) :∀ x ≤ ∑ i ∈ Finset.range m, d i, x ≠ 2 → x ≠ (∑ i ∈ Finset.range m, d i) - 2 →∃ s ⊆ (Finset.range m).image d, ∑ i ∈ s, i = x := bysuffices h : ∀ k, 3 ≤ k → k ≤ m →9 ≤ ∑ i ∈ Finset.range k, d i ∧∀ x ≤ ∑ i ∈ Finset.range k, d i, x ≠ 2 → x ≠ (∑ i ∈ Finset.range k, d i) - 2 →∃ s ⊆ (Finset.range k).image d, ∑ i ∈ s, i = x from(h m hm le_rfl).2intro k hk3 hkminduction k, hk3 using Nat.le_induction with| base =>have hS3 : ∑ i ∈ Finset.range 3, d i = 9 := bysimp [Finset.sum_range_succ, hd0, hd1, hd2]rw [hS3]refine ⟨le_rfl, fun x hx hne2 hne7 => ?_⟩have hD3 : ({1, 3, 5} : Finset ℕ) ⊆ (Finset.range 3).image d := byintro y hysimp only [Finset.mem_insert, Finset.mem_singleton] at hyrcases hy with rfl | rfl | rfl· exact Finset.mem_image.mpr ⟨0, by decide, hd0⟩· exact Finset.mem_image.mpr ⟨1, by decide, hd1⟩· exact Finset.mem_image.mpr ⟨2, by decide, hd2⟩rcases (by omega : x = 0 ∨ x = 1 ∨ x = 3 ∨ x = 4 ∨ x = 5 ∨ x = 6 ∨ x = 8 ∨ x = 9) withrfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl· exact ⟨∅, Finset.empty_subset _, by decide⟩· exact ⟨{1}, Finset.Subset.trans (by decide) hD3, by decide⟩· exact ⟨{3}, Finset.Subset.trans (by decide) hD3, by decide⟩· exact ⟨{1, 3}, Finset.Subset.trans (by decide) hD3, by decide⟩· exact ⟨{5}, Finset.Subset.trans (by decide) hD3, by decide⟩· exact ⟨{1, 5}, Finset.Subset.trans (by decide) hD3, by decide⟩· exact ⟨{3, 5}, Finset.Subset.trans (by decide) hD3, by decide⟩· exact ⟨{1, 3, 5}, hD3, by decide⟩| succ k hk3 ih =>obtain ⟨hSk9, hIH⟩ := ih (Nat.le_of_succ_le hkm)have hkm_lt : k < m := hkmobtain ⟨hle, hne4⟩ := hstep k hk3 hkm_lthave hdk_ge5 : 5 ≤ d k := byhave h2k : d 2 < d k := hmono 2 k (by omega) hkm_ltomegahave hSk1 : ∑ i ∈ Finset.range (k + 1), d i = (∑ i ∈ Finset.range k, d i) + d k :=Finset.sum_range_succ d khave hdk_not_mem : d k ∉ (Finset.range k).image d := byintro hmemrw [Finset.mem_image] at hmemobtain ⟨j, hj, hjd⟩ := hmemrw [Finset.mem_range] at hjhave := hmono j k hj hkm_ltomegarefine ⟨by omega, fun x hx hne2 hne_top => ?_⟩rw [hSk1] at hx hne_tophave hD_sub : (Finset.range k).image d ⊆ (Finset.range (k + 1)).image d :=Finset.image_subset_image (Finset.range_mono (Nat.le_succ k))have hdk_mem : d k ∈ (Finset.range (k + 1)).image d :=Finset.mem_image.mpr ⟨k, Finset.mem_range.mpr (Nat.lt_succ_self k), rfl⟩by_cases hx_le : x ≤ ∑ i ∈ Finset.range k, d i· by_cases hx_sub2 : x = (∑ i ∈ Finset.range k, d i) - 2· set y := (∑ i ∈ Finset.range k, d i) - 2 - d khave hy_le : y ≤ ∑ i ∈ Finset.range k, d i := by omegahave hy_ne2 : y ≠ 2 := by omegahave hy_ne_top : y ≠ (∑ i ∈ Finset.range k, d i) - 2 := by omegaobtain ⟨s, hs, hsum⟩ := hIH y hy_le hy_ne2 hy_ne_tophave hdk_notin_s : d k ∉ s := fun h => hdk_not_mem (hs h)refine ⟨insert (d k) s, Finset.insert_subset_iff.mpr ⟨hdk_mem, hs.trans hD_sub⟩, ?_⟩rw [Finset.sum_insert hdk_notin_s, hsum]omega· obtain ⟨s, hs, hsum⟩ := hIH x hx_le hne2 hx_sub2exact ⟨s, hs.trans hD_sub, hsum⟩· set y := x - d khave hy_le : y ≤ ∑ i ∈ Finset.range k, d i := by omegahave hy_ne2 : y ≠ 2 := by omegahave hy_ne_top : y ≠ (∑ i ∈ Finset.range k, d i) - 2 := by omegaobtain ⟨s, hs, hsum⟩ := hIH y hy_le hy_ne2 hy_ne_tophave hdk_notin_s : d k ∉ s := fun h => hdk_not_mem (hs h)refine ⟨insert (d k) s, Finset.insert_subset_iff.mpr ⟨hdk_mem, hs.trans hD_sub⟩, ?_⟩rw [Finset.sum_insert hdk_notin_s, hsum]omega/-- Consequently, if `n` is abundant with `A(n) = (∑ i ∈ n.properDivisors, i) - n`covered by `(range m).image d ⊆ n.properDivisors` (with `A(n) ≤ S_m`, `A(n) ∉ {2, S_m - 2}`),then `n` is pseudoperfect, hence not weird. -/theorem not_weird_of_gap_free_coverage {n : ℕ} {d : ℕ → ℕ} {m : ℕ} (hm : 3 ≤ m)(hsub : (Finset.range m).image d ⊆ n.properDivisors)(hd0 : d 0 = 1) (hd1 : d 1 = 3) (hd2 : d 2 = 5)(hmono : ∀ i j, i < j → j < m → d i < d j)(hstep : ∀ k, 3 ≤ k → k < m →d k ≤ (∑ i ∈ Finset.range k, d i) - 2 ∧ d k ≠ (∑ i ∈ Finset.range k, d i) - 4)(hab : n.Abundant)(hle : (∑ i ∈ n.properDivisors, i) - n ≤ ∑ i ∈ Finset.range m, d i)(hne2 : (∑ i ∈ n.properDivisors, i) - n ≠ 2)(hnetop : (∑ i ∈ n.properDivisors, i) - n ≠ (∑ i ∈ Finset.range m, d i) - 2) :¬ n.Weird := byobtain ⟨s, hs, hsum⟩ := odd_divisor_gap_free_coverage hm hd0 hd1 hd2 hmono hstep((∑ i ∈ n.properDivisors, i) - n) hle hne2 hnetophave hs_prop : s ⊆ n.properDivisors := hs.trans hsubhave hcomp_sum : ∑ i ∈ (n.properDivisors \ s), i = n := byhave h := Finset.sum_sdiff (f := fun i : ℕ => i) hs_propunfold Nat.Abundant at habomegahave hpseudo : n.Pseudoperfect :=⟨hab.pos, n.properDivisors \ s, Finset.sdiff_subset, hcomp_sum⟩exact fun hw => hw.2 hpseudoend Erdos470Partial