{
  "slug": "erdos647-erdos-647",
  "status": "partial",
  "mode": null,
  "main_lean": "import Mathlib\nimport FormalConjectures.ErdosProblems.«647»\n\n/-!\n# Partial results for Erdős problem 647\n\nThe challenge is equivalent to a divisor budget at every positive shift.\nThis file gives a finite-window check, exclusion criteria, and a limitation\nof congruence covers based on a fixed divisor and one cofactor doubling.\n-/\n\nnamespace Bounty\n\nopen ArithmeticFunction\n\ntheorem sigma_zero_eq_card (m : ℕ) : sigma 0 m = m.divisors.card := by\n  simp [sigma_apply]\n\ntheorem sigma_zero_le_self (m : ℕ) : sigma 0 m ≤ m := by\n  rw [sigma_zero_eq_card]\n  exact Nat.card_divisors_le_self m\n\ntheorem window_iff (n : ℕ) :\n    ((⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) ≤ n + 2) ↔\n      ∀ k : ℕ, 0 < k → k < n → sigma 0 (n - k) ≤ k + 2 := by\n  constructor\n  · intro h k hk hkn\n    have hb : BddAbove (Set.range (fun m : Fin n => (m : ℕ) + sigma 0 (m : ℕ))) := by\n      refine ⟨n + n, ?_⟩\n      rintro _ ⟨m, rfl⟩\n      change (m : ℕ) + sigma 0 (m : ℕ) ≤ n + n\n      have hm := m.isLt\n      have hd := sigma_zero_le_self (m : ℕ)\n      omega\n    have hle := (le_ciSup hb ⟨n - k, by omega⟩).trans h\n    change n - k + sigma 0 (n - k) ≤ n + 2 at hle\n    omega\n  · intro h\n    apply ciSup_le'\n    intro m\n    have hm := m.isLt\n    by_cases hz : (m : ℕ) = 0\n    · simp [hz]\n    · have hd := h (n - (m : ℕ)) (by omega) (by omega)\n      have he : n - (n - (m : ℕ)) = (m : ℕ) := by omega\n      rw [he] at hd\n      omega\n\ntheorem challenge_reduction :\n    (type_of% @Erdos647.erdos_647) ↔\n      ∃ n > 24, ∀ k : ℕ, 0 < k → k < n → sigma 0 (n - k) ≤ k + 2 := by\n  constructor\n  · intro h\n    obtain ⟨n, hn, hsup⟩ := h.mp True.intro\n    exact ⟨n, hn, (window_iff n).mp hsup⟩\n  · rintro ⟨n, hn, hwin⟩\n    exact ⟨fun _ => ⟨n, hn, (window_iff n).mpr hwin⟩, fun _ => True.intro⟩\n\ntheorem window_of_cap {n B : ℕ}\n    (cap : ∀ m < n, sigma 0 m ≤ B)\n    (checked : ∀ k : ℕ, 0 < k → k < n → k + 2 < B → sigma 0 (n - k) ≤ k + 2) :\n    (⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) ≤ n + 2 := by\n  apply (window_iff n).mpr\n  intro k hk hkn\n  by_cases hs : k + 2 < B\n  · exact checked k hk hkn hs\n  · exact (cap (n - k) (by omega)).trans (by omega)\n\ntheorem sigma_zero_le_twice_sqrt (m : ℕ) : sigma 0 m ≤ 2 * m.sqrt := by\n  classical\n  let pairs := m.divisorsAntidiagonal\n  let left := pairs.filter (fun p => p.1 ≤ m.sqrt)\n  let right := pairs.filter (fun p => p.2 ≤ m.sqrt)\n  let small := Finset.Icc 1 m.sqrt\n  have hleft : left.card ≤ small.card := by\n    apply Finset.card_le_card_of_injOn Prod.fst\n    · intro p hp\n      have hp' := Finset.mem_filter.mp hp\n      exact Finset.mem_Icc.mpr\n        ⟨Nat.pos_of_ne_zero (Nat.left_ne_zero_of_mem_divisorsAntidiagonal hp'.1), hp'.2⟩\n    · intro p hp q hq he\n      have hp' := (Finset.mem_filter.mp hp).1\n      have hq' := (Finset.mem_filter.mp hq).1\n      have hprod := (Nat.mem_divisorsAntidiagonal.mp hp').1.trans\n        (Nat.mem_divisorsAntidiagonal.mp hq').1.symm\n      rw [← he] at hprod\n      exact Prod.ext he (Nat.eq_of_mul_eq_mul_left\n        (Nat.pos_of_ne_zero (Nat.left_ne_zero_of_mem_divisorsAntidiagonal hp')) hprod)\n  have hright : right.card ≤ small.card := by\n    apply Finset.card_le_card_of_injOn Prod.snd\n    · intro p hp\n      have hp' := Finset.mem_filter.mp hp\n      exact Finset.mem_Icc.mpr\n        ⟨Nat.pos_of_ne_zero (Nat.right_ne_zero_of_mem_divisorsAntidiagonal hp'.1), hp'.2⟩\n    · intro p hp q hq he\n      have hp' := (Finset.mem_filter.mp hp).1\n      have hq' := (Finset.mem_filter.mp hq).1\n      have hprod := (Nat.mem_divisorsAntidiagonal.mp hp').1.trans\n        (Nat.mem_divisorsAntidiagonal.mp hq').1.symm\n      rw [← he] at hprod\n      exact Prod.ext (Nat.eq_of_mul_eq_mul_right\n        (Nat.pos_of_ne_zero (Nat.right_ne_zero_of_mem_divisorsAntidiagonal hp')) hprod) he\n  have hcover : pairs ⊆ left ∪ right := by\n    intro p hp\n    apply Finset.mem_union.mpr\n    rcases Nat.le_sqrt_of_eq_mul (Nat.mem_divisorsAntidiagonal.mp hp).1.symm with hl | hr\n    · exact Or.inl (Finset.mem_filter.mpr ⟨hp, hl⟩)\n    · exact Or.inr (Finset.mem_filter.mpr ⟨hp, hr⟩)\n  have hsmall : small.card = m.sqrt := by\n    simp [small, Nat.card_Icc]\n  have he : pairs.card = m.divisors.card := by\n    simp [pairs, ← Nat.map_div_right_divisors]\n  calc\n    sigma 0 m = pairs.card := (sigma_zero_eq_card m).trans he.symm\n    _ ≤ (left ∪ right).card := Finset.card_le_card hcover\n    _ ≤ left.card + right.card := Finset.card_union_le _ _\n    _ ≤ 2 * m.sqrt := by omega\n\ntheorem window_of_sqrt_check {n : ℕ}\n    (checked : ∀ k : ℕ, 0 < k → k < n → k + 2 < 2 * n.sqrt →\n      sigma 0 (n - k) ≤ k + 2) :\n    (⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) ≤ n + 2 := by\n  apply window_of_cap (B := 2 * n.sqrt) _ checked\n  intro m hm\n  exact (sigma_zero_le_twice_sqrt m).trans\n    (Nat.mul_le_mul_left 2 (Nat.sqrt_le_sqrt hm.le))\n\ntheorem factor_pair_count {a b : ℕ} (h : Nat.Coprime a b) :\n    sigma 0 (a * b) = sigma 0 a * sigma 0 b := by\n  simp only [sigma_zero_eq_card]\n  exact h.card_divisors_mul\n\ntheorem excludes_of_dvd {n k d : ℕ} (hk : 0 < k) (hkn : k < n)\n    (hd : d ∣ n - k) (hexcess : k + 2 < sigma 0 d) :\n    n + 2 < (⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) := by\n  apply lt_of_not_ge\n  intro h\n  have hm : n - k ≠ 0 := by omega\n  have hcount : sigma 0 d ≤ sigma 0 (n - k) := by\n    simp only [sigma_zero_eq_card]\n    exact Finset.card_le_card (Nat.divisors_subset_of_dvd hm hd)\n  exact (not_lt_of_ge ((window_iff n).mp h k hk hkn)) (hexcess.trans_le hcount)\n\ntheorem excludes_of_congruence {n M r k d : ℕ} (hk : 0 < k) (hkn : k < n)\n    (hdM : d ∣ M) (hnr : n ≡ r [MOD M]) (hrk : r ≡ k [MOD d])\n    (hexcess : k + 2 < sigma 0 d) :\n    n + 2 < (⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) := by\n  have hkn' : k ≡ n [MOD d] := ((hnr.of_dvd hdM).trans hrk).symm\n  exact excludes_of_dvd hk hkn ((Nat.modEq_iff_dvd' hkn.le).mp hkn') hexcess\n\ntheorem excludes_of_coprime_cofactor {n k d c : ℕ} (hk : 0 < k) (hkn : k < n)\n    (he : n - k = d * c) (hc : Nat.Coprime d c) (hcgt : 1 < c)\n    (hexcess : k + 2 < 2 * sigma 0 d) :\n    n + 2 < (⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) := by\n  have hcount : 2 ≤ sigma 0 c := by\n    rw [sigma_zero_eq_card]\n    exact Finset.one_lt_card.mpr\n      ⟨1, Nat.one_mem_divisors.mpr (by omega), c, Nat.mem_divisors_self c (by omega), by omega⟩\n  apply lt_of_not_ge\n  intro h\n  have hbudget := (window_iff n).mp h k hk hkn\n  rw [he, factor_pair_count hc] at hbudget\n  have := Nat.mul_le_mul_left (sigma 0 d) hcount\n  omega\n\ntheorem twice_sigma_le_of_large_cofactor {d c : ℕ} (hlt : d < c) :\n    2 * sigma 0 d ≤ sigma 0 (d * c) := by\n  by_cases hd : d = 0\n  · simp [hd]\n  have hc : 0 < c := Nat.zero_le d |>.trans_lt hlt\n  have hdc : d * c ≠ 0 := Nat.mul_ne_zero hd hc.ne'\n  let scaled := d.divisors.map\n    ⟨fun e => e * c, fun _ _ he => Nat.eq_of_mul_eq_mul_right hc he⟩\n  have hscaled : scaled.card = d.divisors.card := by simp [scaled]\n  have hdisjoint : Disjoint d.divisors scaled := by\n    refine Finset.disjoint_left.mpr ?_\n    intro x hx hy\n    obtain ⟨e, he, rfl⟩ := Finset.mem_map.mp hy\n    have hlow : c ≤ e * c := by\n      simpa only [Nat.one_mul] using Nat.mul_le_mul_right c (Nat.pos_of_mem_divisors he)\n    exact (not_le_of_gt hlt) (hlow.trans (Nat.divisor_le hx))\n  have hcover : d.divisors ∪ scaled ⊆ (d * c).divisors := by\n    intro x hx\n    rcases Finset.mem_union.mp hx with hs | hs\n    · exact Nat.divisors_subset_of_dvd hdc (dvd_mul_right d c) hs\n    · obtain ⟨e, he, rfl⟩ := Finset.mem_map.mp hs\n      exact Nat.mem_divisors.mpr ⟨Nat.mul_dvd_mul (Nat.mem_divisors.mp he).1 (dvd_refl c), hdc⟩\n  have hcard := Finset.card_le_card hcover\n  rw [Finset.card_union_of_disjoint hdisjoint, hscaled] at hcard\n  simp only [sigma_zero_eq_card]\n  omega\n\ntheorem excludes_of_large_cofactor {n k d c : ℕ} (hk : 0 < k) (hkn : k < n)\n    (he : n - k = d * c) (hlt : d < c) (hexcess : k + 2 < 2 * sigma 0 d) :\n    n + 2 < (⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) := by\n  apply lt_of_not_ge\n  intro h\n  have hbudget := (window_iff n).mp h k hk hkn\n  rw [he] at hbudget\n  exact (not_lt_of_ge ((twice_sigma_le_of_large_cofactor hlt).trans hbudget)) hexcess\n\ntheorem twice_sigma_zero_le (m : ℕ) : 2 * sigma 0 m ≤ m + 2 := by\n  by_cases hz : m = 0\n  · simp [hz]\n  have hsub : m.properDivisors ⊆ Finset.Icc 1 (m / 2) := by\n    intro d hd\n    have hp := Nat.pos_of_mem_properDivisors hd\n    obtain ⟨q, hq, he⟩ := (Nat.mem_properDivisors_iff_exists hz).mp hd\n    have hmul : d * 2 ≤ d * q := Nat.mul_le_mul_left d (by omega)\n    have hle : d ≤ m / 2 := by omega\n    exact Finset.mem_Icc.mpr ⟨hp, hle⟩\n  have hc := Finset.card_le_card hsub\n  rw [Nat.card_Icc] at hc\n  rw [sigma_zero_eq_card, ← Nat.cons_self_properDivisors hz, Finset.card_cons]\n  omega\n\ntheorem fixed_rows_miss_multiples {M n k d : ℕ}\n    (hMn : M ∣ n) (hdM : d ∣ M) (hk : 0 < k) (hkn : k ≤ n) (hd : d ∣ n - k) :\n    2 * sigma 0 d ≤ k + 2 := by\n  have hdk := (Nat.dvd_sub_iff_right hkn (hdM.trans hMn)).mp hd\n  have hle := Nat.le_of_dvd hk hdk\n  exact (twice_sigma_zero_le d).trans (by omega)\n\ntheorem finite_fixed_rows_incomplete (moduli : Finset ℕ)\n    (hpositive : ∀ M ∈ moduli, 0 < M) (threshold : ℕ) :\n    ∃ n > threshold, ∀ M ∈ moduli, ∀ k d : ℕ,\n      0 < k → k < n → d ∣ M → d ∣ n - k → 2 * sigma 0 d ≤ k + 2 := by\n  let P : ℕ := ∏ M ∈ moduli, M\n  have hP : 0 < P := Finset.prod_pos hpositive\n  refine ⟨(threshold + 1) * P, ?_, ?_⟩\n  · have hle : (threshold + 1) * 1 ≤ (threshold + 1) * P :=\n      Nat.mul_le_mul_left _ hP\n    omega\n  · intro M hM k d hk hkn hdM hd\n    have hMP : M ∣ P := Finset.dvd_prod_of_mem id hM\n    exact fixed_rows_miss_multiples\n      (hMP.trans (dvd_mul_left P (threshold + 1))) hdM hk hkn.le hd\n\ntheorem first_frontier_interval {k : ℕ} (hk : 0 < k) (hmax : k ≤ 526) :\n    10 ^ 22 + k + 2 <\n      (⨆ m : Fin (10 ^ 22 + k), (m : ℕ) + sigma 0 (m : ℕ)) := by\n  have hpow : (10 : ℕ) ^ 22 = 2 ^ 22 * 5 ^ 22 := by\n    rw [← mul_pow, show (2 : ℕ) * 5 = 10 by decide]\n  have hc : Nat.Coprime (2 ^ 22) (5 ^ 22) := by decide\n  have hcount : sigma 0 (10 ^ 22) = 529 := by\n    rw [hpow, factor_pair_count hc,\n      sigma_zero_apply_prime_pow Nat.prime_two, sigma_zero_apply_prime_pow Nat.prime_five]\n  have hpos : 0 < (10 : ℕ) ^ 22 := by decide\n  apply excludes_of_dvd (d := 10 ^ 22) hk (by omega)\n  · simp\n  · rw [hcount]\n    omega\n\ntheorem twenty_four_certificate :\n    (⨆ m : Fin 24, (m : ℕ) + sigma 0 (m : ℕ)) ≤ 26 := by\n  apply window_of_sqrt_check\n  intro k hk _ hcap\n  have hs : (24 : ℕ).sqrt = 4 := (Nat.eq_sqrt.mpr (by decide)).symm\n  have hsmall : k < 6 := by rw [hs] at hcap; omega\n  have hcheck : ∀ i : Fin 6, 0 < (i : ℕ) → sigma 0 (24 - (i : ℕ)) ≤ (i : ℕ) + 2 := by\n    decide\n  exact hcheck ⟨k, hsmall⟩ hk\n\nend Bounty\n\n#print axioms Bounty.sigma_zero_eq_card\n#print axioms Bounty.sigma_zero_le_self\n#print axioms Bounty.window_iff\n#print axioms Bounty.challenge_reduction\n#print axioms Bounty.window_of_cap\n#print axioms Bounty.sigma_zero_le_twice_sqrt\n#print axioms Bounty.window_of_sqrt_check\n#print axioms Bounty.factor_pair_count\n#print axioms Bounty.excludes_of_dvd\n#print axioms Bounty.excludes_of_congruence\n#print axioms Bounty.excludes_of_coprime_cofactor\n#print axioms Bounty.twice_sigma_le_of_large_cofactor\n#print axioms Bounty.excludes_of_large_cofactor\n#print axioms Bounty.twice_sigma_zero_le\n#print axioms Bounty.fixed_rows_miss_multiples\n#print axioms Bounty.finite_fixed_rows_incomplete\n#print axioms Bounty.first_frontier_interval\n#print axioms Bounty.twenty_four_certificate\n",
  "build_commands": [
    "In a fresh scratch directory, set ELAN_HOME to its absolute elan subdirectory and XDG_CACHE_HOME to its absolute cache subdirectory. Use the Linux x86-64 elan 4.2.3 archive and add the local shims to PATH.",
    "curl -fLsS https://github.com/leanprover/elan/releases/download/v4.2.3/elan-x86_64-unknown-linux-gnu.tar.gz -o elan.tar.gz && tar xzf elan.tar.gz && ./elan-init --default-toolchain none --no-modify-path -y",
    "mkdir fc && cd fc && git init -q && git fetch --depth 1 https://github.com/google-deepmind/formal-conjectures 7d1a8c9912747679d0093f6d1216420c33ee5ffa && git checkout --detach FETCH_HEAD",
    "curl -fLsS https://raw.githubusercontent.com/conjectures-io/conjectures-tasks/f5dab9b843c460bf946e0ec7b0e6ad2f2f739eb8/tiers/tier-1/formal-conjectures-audit-fixes.patch -o ../audit.patch",
    "printf '%s\\n' '352280407fbbe83e636aa07a5c090aab15c6353c7cd77c0491284cd40df51275  ../audit.patch' | sha256sum -c - && git apply ../audit.patch",
    "lake exe cache get",
    "lake build 'FormalConjectures.ErdosProblems.«647»'",
    "Save the main_lean string from this JSON as Main.lean at the patched Lake project root.",
    "lake env lean Main.lean"
  ],
  "build_log_tail": "Lean (version 4.35.0-rc2, x86_64-unknown-linux-gnu, commit 11acb17ec6b07a8f9e9173e6845197929540936b, Release)\n7d1a8c9912747679d0093f6d1216420c33ee5ffa\n065356127b1dc0016f66b7283ce0ce2c4055aa55\n352280407fbbe83e636aa07a5c090aab15c6353c7cd77c0491284cd40df51275  ../audit.patch\nBuild completed successfully (9198 jobs).\n'Bounty.sigma_zero_eq_card' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.sigma_zero_le_self' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.window_iff' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.challenge_reduction' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.window_of_cap' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.sigma_zero_le_twice_sqrt' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.window_of_sqrt_check' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.factor_pair_count' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.excludes_of_dvd' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.excludes_of_congruence' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.excludes_of_coprime_cofactor' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.twice_sigma_le_of_large_cofactor' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.excludes_of_large_cofactor' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.twice_sigma_zero_le' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.fixed_rows_miss_multiples' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.finite_fixed_rows_incomplete' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.first_frontier_interval' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.twenty_four_certificate' depends on axioms: [propext, Classical.choice, Quot.sound]\n",
  "axioms_output": "'Bounty.sigma_zero_eq_card' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.sigma_zero_le_self' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.window_iff' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.challenge_reduction' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.window_of_cap' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.sigma_zero_le_twice_sqrt' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.window_of_sqrt_check' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.factor_pair_count' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.excludes_of_dvd' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.excludes_of_congruence' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.excludes_of_coprime_cofactor' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.twice_sigma_le_of_large_cofactor' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.excludes_of_large_cofactor' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.twice_sigma_zero_le' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.fixed_rows_miss_multiples' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.finite_fixed_rows_incomplete' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.first_frontier_interval' depends on axioms: [propext, Classical.choice, Quot.sound]\n'Bounty.twenty_four_certificate' depends on axioms: [propext, Classical.choice, Quot.sound]\n",
  "compiled_lemmas": "import Mathlib\nimport FormalConjectures.ErdosProblems.«647»\n\n/-!\n# Partial results for Erdős problem 647\n\nThe challenge is equivalent to a divisor budget at every positive shift.\nThis file gives a finite-window check, exclusion criteria, and a limitation\nof congruence covers based on a fixed divisor and one cofactor doubling.\n-/\n\nnamespace Bounty\n\nopen ArithmeticFunction\n\ntheorem sigma_zero_eq_card (m : ℕ) : sigma 0 m = m.divisors.card := by\n  simp [sigma_apply]\n\ntheorem sigma_zero_le_self (m : ℕ) : sigma 0 m ≤ m := by\n  rw [sigma_zero_eq_card]\n  exact Nat.card_divisors_le_self m\n\ntheorem window_iff (n : ℕ) :\n    ((⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) ≤ n + 2) ↔\n      ∀ k : ℕ, 0 < k → k < n → sigma 0 (n - k) ≤ k + 2 := by\n  constructor\n  · intro h k hk hkn\n    have hb : BddAbove (Set.range (fun m : Fin n => (m : ℕ) + sigma 0 (m : ℕ))) := by\n      refine ⟨n + n, ?_⟩\n      rintro _ ⟨m, rfl⟩\n      change (m : ℕ) + sigma 0 (m : ℕ) ≤ n + n\n      have hm := m.isLt\n      have hd := sigma_zero_le_self (m : ℕ)\n      omega\n    have hle := (le_ciSup hb ⟨n - k, by omega⟩).trans h\n    change n - k + sigma 0 (n - k) ≤ n + 2 at hle\n    omega\n  · intro h\n    apply ciSup_le'\n    intro m\n    have hm := m.isLt\n    by_cases hz : (m : ℕ) = 0\n    · simp [hz]\n    · have hd := h (n - (m : ℕ)) (by omega) (by omega)\n      have he : n - (n - (m : ℕ)) = (m : ℕ) := by omega\n      rw [he] at hd\n      omega\n\ntheorem challenge_reduction :\n    (type_of% @Erdos647.erdos_647) ↔\n      ∃ n > 24, ∀ k : ℕ, 0 < k → k < n → sigma 0 (n - k) ≤ k + 2 := by\n  constructor\n  · intro h\n    obtain ⟨n, hn, hsup⟩ := h.mp True.intro\n    exact ⟨n, hn, (window_iff n).mp hsup⟩\n  · rintro ⟨n, hn, hwin⟩\n    exact ⟨fun _ => ⟨n, hn, (window_iff n).mpr hwin⟩, fun _ => True.intro⟩\n\ntheorem window_of_cap {n B : ℕ}\n    (cap : ∀ m < n, sigma 0 m ≤ B)\n    (checked : ∀ k : ℕ, 0 < k → k < n → k + 2 < B → sigma 0 (n - k) ≤ k + 2) :\n    (⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) ≤ n + 2 := by\n  apply (window_iff n).mpr\n  intro k hk hkn\n  by_cases hs : k + 2 < B\n  · exact checked k hk hkn hs\n  · exact (cap (n - k) (by omega)).trans (by omega)\n\ntheorem sigma_zero_le_twice_sqrt (m : ℕ) : sigma 0 m ≤ 2 * m.sqrt := by\n  classical\n  let pairs := m.divisorsAntidiagonal\n  let left := pairs.filter (fun p => p.1 ≤ m.sqrt)\n  let right := pairs.filter (fun p => p.2 ≤ m.sqrt)\n  let small := Finset.Icc 1 m.sqrt\n  have hleft : left.card ≤ small.card := by\n    apply Finset.card_le_card_of_injOn Prod.fst\n    · intro p hp\n      have hp' := Finset.mem_filter.mp hp\n      exact Finset.mem_Icc.mpr\n        ⟨Nat.pos_of_ne_zero (Nat.left_ne_zero_of_mem_divisorsAntidiagonal hp'.1), hp'.2⟩\n    · intro p hp q hq he\n      have hp' := (Finset.mem_filter.mp hp).1\n      have hq' := (Finset.mem_filter.mp hq).1\n      have hprod := (Nat.mem_divisorsAntidiagonal.mp hp').1.trans\n        (Nat.mem_divisorsAntidiagonal.mp hq').1.symm\n      rw [← he] at hprod\n      exact Prod.ext he (Nat.eq_of_mul_eq_mul_left\n        (Nat.pos_of_ne_zero (Nat.left_ne_zero_of_mem_divisorsAntidiagonal hp')) hprod)\n  have hright : right.card ≤ small.card := by\n    apply Finset.card_le_card_of_injOn Prod.snd\n    · intro p hp\n      have hp' := Finset.mem_filter.mp hp\n      exact Finset.mem_Icc.mpr\n        ⟨Nat.pos_of_ne_zero (Nat.right_ne_zero_of_mem_divisorsAntidiagonal hp'.1), hp'.2⟩\n    · intro p hp q hq he\n      have hp' := (Finset.mem_filter.mp hp).1\n      have hq' := (Finset.mem_filter.mp hq).1\n      have hprod := (Nat.mem_divisorsAntidiagonal.mp hp').1.trans\n        (Nat.mem_divisorsAntidiagonal.mp hq').1.symm\n      rw [← he] at hprod\n      exact Prod.ext (Nat.eq_of_mul_eq_mul_right\n        (Nat.pos_of_ne_zero (Nat.right_ne_zero_of_mem_divisorsAntidiagonal hp')) hprod) he\n  have hcover : pairs ⊆ left ∪ right := by\n    intro p hp\n    apply Finset.mem_union.mpr\n    rcases Nat.le_sqrt_of_eq_mul (Nat.mem_divisorsAntidiagonal.mp hp).1.symm with hl | hr\n    · exact Or.inl (Finset.mem_filter.mpr ⟨hp, hl⟩)\n    · exact Or.inr (Finset.mem_filter.mpr ⟨hp, hr⟩)\n  have hsmall : small.card = m.sqrt := by\n    simp [small, Nat.card_Icc]\n  have he : pairs.card = m.divisors.card := by\n    simp [pairs, ← Nat.map_div_right_divisors]\n  calc\n    sigma 0 m = pairs.card := (sigma_zero_eq_card m).trans he.symm\n    _ ≤ (left ∪ right).card := Finset.card_le_card hcover\n    _ ≤ left.card + right.card := Finset.card_union_le _ _\n    _ ≤ 2 * m.sqrt := by omega\n\ntheorem window_of_sqrt_check {n : ℕ}\n    (checked : ∀ k : ℕ, 0 < k → k < n → k + 2 < 2 * n.sqrt →\n      sigma 0 (n - k) ≤ k + 2) :\n    (⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) ≤ n + 2 := by\n  apply window_of_cap (B := 2 * n.sqrt) _ checked\n  intro m hm\n  exact (sigma_zero_le_twice_sqrt m).trans\n    (Nat.mul_le_mul_left 2 (Nat.sqrt_le_sqrt hm.le))\n\ntheorem factor_pair_count {a b : ℕ} (h : Nat.Coprime a b) :\n    sigma 0 (a * b) = sigma 0 a * sigma 0 b := by\n  simp only [sigma_zero_eq_card]\n  exact h.card_divisors_mul\n\ntheorem excludes_of_dvd {n k d : ℕ} (hk : 0 < k) (hkn : k < n)\n    (hd : d ∣ n - k) (hexcess : k + 2 < sigma 0 d) :\n    n + 2 < (⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) := by\n  apply lt_of_not_ge\n  intro h\n  have hm : n - k ≠ 0 := by omega\n  have hcount : sigma 0 d ≤ sigma 0 (n - k) := by\n    simp only [sigma_zero_eq_card]\n    exact Finset.card_le_card (Nat.divisors_subset_of_dvd hm hd)\n  exact (not_lt_of_ge ((window_iff n).mp h k hk hkn)) (hexcess.trans_le hcount)\n\ntheorem excludes_of_congruence {n M r k d : ℕ} (hk : 0 < k) (hkn : k < n)\n    (hdM : d ∣ M) (hnr : n ≡ r [MOD M]) (hrk : r ≡ k [MOD d])\n    (hexcess : k + 2 < sigma 0 d) :\n    n + 2 < (⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) := by\n  have hkn' : k ≡ n [MOD d] := ((hnr.of_dvd hdM).trans hrk).symm\n  exact excludes_of_dvd hk hkn ((Nat.modEq_iff_dvd' hkn.le).mp hkn') hexcess\n\ntheorem excludes_of_coprime_cofactor {n k d c : ℕ} (hk : 0 < k) (hkn : k < n)\n    (he : n - k = d * c) (hc : Nat.Coprime d c) (hcgt : 1 < c)\n    (hexcess : k + 2 < 2 * sigma 0 d) :\n    n + 2 < (⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) := by\n  have hcount : 2 ≤ sigma 0 c := by\n    rw [sigma_zero_eq_card]\n    exact Finset.one_lt_card.mpr\n      ⟨1, Nat.one_mem_divisors.mpr (by omega), c, Nat.mem_divisors_self c (by omega), by omega⟩\n  apply lt_of_not_ge\n  intro h\n  have hbudget := (window_iff n).mp h k hk hkn\n  rw [he, factor_pair_count hc] at hbudget\n  have := Nat.mul_le_mul_left (sigma 0 d) hcount\n  omega\n\ntheorem twice_sigma_le_of_large_cofactor {d c : ℕ} (hlt : d < c) :\n    2 * sigma 0 d ≤ sigma 0 (d * c) := by\n  by_cases hd : d = 0\n  · simp [hd]\n  have hc : 0 < c := Nat.zero_le d |>.trans_lt hlt\n  have hdc : d * c ≠ 0 := Nat.mul_ne_zero hd hc.ne'\n  let scaled := d.divisors.map\n    ⟨fun e => e * c, fun _ _ he => Nat.eq_of_mul_eq_mul_right hc he⟩\n  have hscaled : scaled.card = d.divisors.card := by simp [scaled]\n  have hdisjoint : Disjoint d.divisors scaled := by\n    refine Finset.disjoint_left.mpr ?_\n    intro x hx hy\n    obtain ⟨e, he, rfl⟩ := Finset.mem_map.mp hy\n    have hlow : c ≤ e * c := by\n      simpa only [Nat.one_mul] using Nat.mul_le_mul_right c (Nat.pos_of_mem_divisors he)\n    exact (not_le_of_gt hlt) (hlow.trans (Nat.divisor_le hx))\n  have hcover : d.divisors ∪ scaled ⊆ (d * c).divisors := by\n    intro x hx\n    rcases Finset.mem_union.mp hx with hs | hs\n    · exact Nat.divisors_subset_of_dvd hdc (dvd_mul_right d c) hs\n    · obtain ⟨e, he, rfl⟩ := Finset.mem_map.mp hs\n      exact Nat.mem_divisors.mpr ⟨Nat.mul_dvd_mul (Nat.mem_divisors.mp he).1 (dvd_refl c), hdc⟩\n  have hcard := Finset.card_le_card hcover\n  rw [Finset.card_union_of_disjoint hdisjoint, hscaled] at hcard\n  simp only [sigma_zero_eq_card]\n  omega\n\ntheorem excludes_of_large_cofactor {n k d c : ℕ} (hk : 0 < k) (hkn : k < n)\n    (he : n - k = d * c) (hlt : d < c) (hexcess : k + 2 < 2 * sigma 0 d) :\n    n + 2 < (⨆ m : Fin n, (m : ℕ) + sigma 0 (m : ℕ)) := by\n  apply lt_of_not_ge\n  intro h\n  have hbudget := (window_iff n).mp h k hk hkn\n  rw [he] at hbudget\n  exact (not_lt_of_ge ((twice_sigma_le_of_large_cofactor hlt).trans hbudget)) hexcess\n\ntheorem twice_sigma_zero_le (m : ℕ) : 2 * sigma 0 m ≤ m + 2 := by\n  by_cases hz : m = 0\n  · simp [hz]\n  have hsub : m.properDivisors ⊆ Finset.Icc 1 (m / 2) := by\n    intro d hd\n    have hp := Nat.pos_of_mem_properDivisors hd\n    obtain ⟨q, hq, he⟩ := (Nat.mem_properDivisors_iff_exists hz).mp hd\n    have hmul : d * 2 ≤ d * q := Nat.mul_le_mul_left d (by omega)\n    have hle : d ≤ m / 2 := by omega\n    exact Finset.mem_Icc.mpr ⟨hp, hle⟩\n  have hc := Finset.card_le_card hsub\n  rw [Nat.card_Icc] at hc\n  rw [sigma_zero_eq_card, ← Nat.cons_self_properDivisors hz, Finset.card_cons]\n  omega\n\ntheorem fixed_rows_miss_multiples {M n k d : ℕ}\n    (hMn : M ∣ n) (hdM : d ∣ M) (hk : 0 < k) (hkn : k ≤ n) (hd : d ∣ n - k) :\n    2 * sigma 0 d ≤ k + 2 := by\n  have hdk := (Nat.dvd_sub_iff_right hkn (hdM.trans hMn)).mp hd\n  have hle := Nat.le_of_dvd hk hdk\n  exact (twice_sigma_zero_le d).trans (by omega)\n\ntheorem finite_fixed_rows_incomplete (moduli : Finset ℕ)\n    (hpositive : ∀ M ∈ moduli, 0 < M) (threshold : ℕ) :\n    ∃ n > threshold, ∀ M ∈ moduli, ∀ k d : ℕ,\n      0 < k → k < n → d ∣ M → d ∣ n - k → 2 * sigma 0 d ≤ k + 2 := by\n  let P : ℕ := ∏ M ∈ moduli, M\n  have hP : 0 < P := Finset.prod_pos hpositive\n  refine ⟨(threshold + 1) * P, ?_, ?_⟩\n  · have hle : (threshold + 1) * 1 ≤ (threshold + 1) * P :=\n      Nat.mul_le_mul_left _ hP\n    omega\n  · intro M hM k d hk hkn hdM hd\n    have hMP : M ∣ P := Finset.dvd_prod_of_mem id hM\n    exact fixed_rows_miss_multiples\n      (hMP.trans (dvd_mul_left P (threshold + 1))) hdM hk hkn.le hd\n\ntheorem first_frontier_interval {k : ℕ} (hk : 0 < k) (hmax : k ≤ 526) :\n    10 ^ 22 + k + 2 <\n      (⨆ m : Fin (10 ^ 22 + k), (m : ℕ) + sigma 0 (m : ℕ)) := by\n  have hpow : (10 : ℕ) ^ 22 = 2 ^ 22 * 5 ^ 22 := by\n    rw [← mul_pow, show (2 : ℕ) * 5 = 10 by decide]\n  have hc : Nat.Coprime (2 ^ 22) (5 ^ 22) := by decide\n  have hcount : sigma 0 (10 ^ 22) = 529 := by\n    rw [hpow, factor_pair_count hc,\n      sigma_zero_apply_prime_pow Nat.prime_two, sigma_zero_apply_prime_pow Nat.prime_five]\n  have hpos : 0 < (10 : ℕ) ^ 22 := by decide\n  apply excludes_of_dvd (d := 10 ^ 22) hk (by omega)\n  · simp\n  · rw [hcount]\n    omega\n\ntheorem twenty_four_certificate :\n    (⨆ m : Fin 24, (m : ℕ) + sigma 0 (m : ℕ)) ≤ 26 := by\n  apply window_of_sqrt_check\n  intro k hk _ hcap\n  have hs : (24 : ℕ).sqrt = 4 := (Nat.eq_sqrt.mpr (by decide)).symm\n  have hsmall : k < 6 := by rw [hs] at hcap; omega\n  have hcheck : ∀ i : Fin 6, 0 < (i : ℕ) → sigma 0 (24 - (i : ℕ)) ≤ (i : ℕ) + 2 := by\n    decide\n  exact hcheck ⟨k, hsmall⟩ hk\n\nend Bounty\n\n",
  "explanation": "This attempt did not prove or refute Erdős problem 647. Lean checks that the exact pinned type is equivalent to finding an n greater than 24 whose positive shifts k<n each satisfy τ(n−k)≤k+2. A divisor pair of any m has at least one coordinate at most floor(sqrt(m)). Projecting onto that coordinate bounds each of the two families of pairs by floor(sqrt(m)), so the witness checker only needs shifts with k+2<2 floor(sqrt(n)). This verifies the historical n=24 example by checking shifts 1 through 5. At the far frontier, the factorization 10^22=2^22·5^22 gives 529 divisors, excluding 10^22+k for 1≤k≤526 in Lean. For the refutation approach, divisibility of n−k by d gives τ(n−k)≥τ(d), and a coprime cofactor greater than 1 gives τ(n−k)≥2τ(d). The same lower bound holds when the cofactor exceeds d, because the divisors of d and their cofactor multiples are disjoint. If n is a common multiple of the finitely many moduli, every applicable fixed d also divides k. All proper divisors of d are at most d/2, hence 2τ(d)≤d+2≤k+2. Thus even the doubled fixed-divisor bounds cannot exclude arbitrarily large common multiples.",
  "tried": [
    {
      "approach": "a",
      "finding": "Searched a contiguous block immediately above the reported 10^22 frontier. The segmented lower-bound sieve tested all integers in the block, so it required no assumptions about the published residue restrictions. All candidates failed within 128 shifts. With no surviving n to factor, I used the divisor-pair bound from the triage to implement and test the compressed check on n=24."
    },
    {
      "approach": "b",
      "finding": "Enumerated residue classes modulo 2520 and shifts 1 through 128, first with all fixed divisors of 2520 and then with a doubled coprime part. The screens left 212 and 78 residues respectively. A stronger large-cofactor screen left only residue zero. Formalized the exclusion rules and the common-multiple obstruction previously described by Tölö. Checked one finite exclusion interval with a symbolic prime-power count."
    }
  ],
  "stuck": "Approach a needs a concrete n>24 meeting every divisor budget. The searched interval supplied none, and no upper bound on the first witness is known if one exists. Approach b needs a lower-bound rule beyond a fixed divisor of the modulus with at most one guaranteed cofactor doubling, or a variable-shift argument that covers the surviving residue classes for unbounded n.",
  "computation": {
    "frontier_scan": {
      "inclusive_min": "10000000000000000000001",
      "inclusive_max": "10000000000000005000000",
      "shifts": [
        1,
        128
      ],
      "prime_cutoff": 100000,
      "survivors": 0,
      "kernel_checked": false,
      "output": "width=5000000 window=128 prime cutoff=100000 survivors=0\n",
      "reproducer_cpp17": "#include <algorithm>\n#include <cstdint>\n#include <iostream>\n#include <vector>\n\nusing Wide = __uint128_t;\n\nint main() {\n    const Wide frontier = Wide(1000000000000000000ULL) * 10000;\n    constexpr int width = 5000000;\n    constexpr int window = 128;\n    constexpr int sieve_limit = 100000;\n    const Wide first = frontier + 1 - window;\n    const int length = width + window;\n    std::vector<Wide> residual(length);\n    std::vector<std::uint64_t> divisor_lower(length, 1);\n    std::vector<int> coverage(length + 1);\n    for (int i = 0; i < length; ++i) residual[i] = first + i;\n    std::vector<bool> composite(sieve_limit + 1);\n    for (int p = 2; p <= sieve_limit; ++p) {\n        if (composite[p]) continue;\n        for (int j = 2 * p; j <= sieve_limit; j += p) composite[j] = true;\n        for (int i = (p - int(first % p)) % p; i < length; i += p) {\n            int power = 0;\n            do {\n                residual[i] /= p;\n                ++power;\n            } while (residual[i] % p == 0);\n            divisor_lower[i] *= power + 1;\n        }\n    }\n    for (int i = 0; i < length - 1; ++i) {\n        if (residual[i] > 1) divisor_lower[i] *= 2;\n        if (divisor_lower[i] < 4) continue;\n        const int last_shift = int(std::min<std::uint64_t>(window, divisor_lower[i] - 3));\n        ++coverage[i + 1];\n        --coverage[std::min(length, i + last_shift + 1)];\n    }\n    int active = 0, survivors = 0;\n    for (int i = 0; i < length; ++i) {\n        active += coverage[i];\n        if (i >= window && active == 0) {\n            ++survivors;\n            std::cout << \"survivor offset \" << i - window + 1 << '\\n';\n        }\n    }\n    std::cout << \"width=\" << width << \" window=\" << window\n              << \" prime cutoff=\" << sieve_limit << \" survivors=\" << survivors << '\\n';\n}\n",
      "command": "g++ -std=c++17 -O2 -Wall -Wextra search.cpp -o search && ./search"
    },
    "residue_screen": {
      "modulus": 2520,
      "shifts": [
        1,
        128
      ],
      "coprime_doubling_applies_for": "n>2648, so n−k>2520 and exceeds the entire fixed part",
      "large_cofactor_doubling_applies_for": "n>6350528, so n−k>2520² and (n−k)/d>d for every d dividing 2520 and n−k",
      "kernel_checked": false,
      "output": "doubling=False survivors=212 includes_zero=True\ndoubling=True survivors=78 includes_zero=True\nlarge_cofactor survivors=1 residues=[0]\n",
      "reproducer_python3": "from math import gcd\n\nmodulus = 2520\nmax_shift = 128\ntau = [sum(n % i == 0 for i in range(1, n + 1)) for n in range(modulus + 1)]\n\ndef exact_part(r, k):\n    d = 1\n    for p in (2, 3, 5, 7):\n        power = 1\n        while (r - k) % (power * p) == 0 and modulus % (power * p) == 0:\n            power *= p\n        if modulus % (power * p) == 0:\n            d *= power\n    return d\n\nfor doubling in (False, True):\n    survivors = []\n    for r in range(modulus):\n        for k in range(1, max_shift + 1):\n            lower = tau[gcd(modulus, r - k)]\n            if doubling:\n                lower = max(lower, 2 * tau[exact_part(r, k)])\n            if lower > k + 2:\n                break\n        else:\n            survivors.append(r)\n    print(f\"doubling={doubling} survivors={len(survivors)} includes_zero={0 in survivors}\")\n\nsurvivors = [\n    r for r in range(modulus)\n    if all(2 * tau[gcd(modulus, r - k)] <= k + 2\n           for k in range(1, max_shift + 1))\n]\nprint(f\"large_cofactor survivors={len(survivors)} residues={survivors}\")\n"
    },
    "lean_checked_exclusion": "n=10^22+k for 1≤k≤526",
    "lean_checked_historical_example": "n=24"
  },
  "triage": {
    "class": "a",
    "chance_pct": 0,
    "solved_in_literature": false
  },
  "literature_recheck": [
    {
      "url": "https://api.imd.fun/artifacts/92d87d986c191a73ce49fd46d693fe0bb2509ea38050cf8d508ca32546ddc14f",
      "finding": "Pinned triage input verified by SHA-256. Class, chance estimate and solved_in_literature copied as given."
    },
    {
      "url": "https://conjectures.io/problems/erdos647-erdos-647",
      "finding": "The public listing showed a $2,983 bounty estimate and said nobody had attempted this at the time of the check."
    },
    {
      "url": "https://conjectures.io/problems/erdos647-erdos-647/challenge?mode=formalized",
      "finding": "Challenge extracts the type of Erdos647.erdos_647. The Lean reduction uses only its type and the pinned source module was unmodified by the audit patch."
    },
    {
      "url": "https://conjectures.io/submission-terms",
      "finding": "Version 13 requires the exact target and excludes prior complete established proofs of the same problem."
    },
    {
      "url": "https://www.erdosproblems.com/647",
      "finding": "The source attributes the question to Erdős and Selfridge and records n=24. It distinguishes the all-predecessors problem from the fixed-window and limit variants."
    },
    {
      "url": "https://www.erdosproblems.com/forum/thread/647",
      "finding": "The discussion reports finite scans, modular restrictions and Tölö’s exclusion to 10^13. No complete argument deciding the exact problem was established by the material reviewed."
    },
    {
      "url": "https://raw.githubusercontent.com/fjordmindlabs/math/main/erdos647-sparse/README.md",
      "finding": "Tölö gives the statement and reported axiom closure of the 10^13 exclusion. The same writeup identifies the zero-residue obstruction even with the stronger cofactor-doubling rule. I formalized that obstruction here for arbitrary finite families of moduli."
    },
    {
      "url": "https://arxiv.org/html/2608.17880",
      "finding": "Mian–Siddique report kernel exclusion only to 10^9. The previously claimed unbounded domination-interval argument was withdrawn and lacked a proof of perpetual overlap."
    },
    {
      "url": "https://raw.githubusercontent.com/veljjanoski/erdos647/main/README.md",
      "finding": "Author reports a GPU exclusion with no solution for 24<n≤10^22. This supplied the starting point of the new contiguous scan."
    },
    {
      "url": "https://arxiv.org/html/2512.01739",
      "finding": "Tao–Teräväinen obtain prime-factor-count bounds on consecutive shifts and results on equal divisor counts. Neither supplies the exact one-sided budgets needed here."
    },
    {
      "url": "https://arxiv.org/abs/2604.15042",
      "finding": "Lau improves bounds on the number of distinct prime factors at shifts. This leaves the exact divisor-count inequalities undecided."
    }
  ],
  "chat_log": "missing_original_chat_export",
  "unverified": [
    "The exact target in either direction and global closure of the surviving progressions remain UNVERIFIED.",
    "The full five-million-integer C++ scan and the Python residue counts are UNVERIFIED by Lean. The separate Lean frontier interval covers only the first 526 integers.",
    "The external GPU and Lean certificates were reviewed as reports and remain UNVERIFIED independently here.",
    "An independent clean rebuild by a different agent remains UNVERIFIED."
  ]
}
