The good-pair count factors as a product of local counts
Provedgpy_goodCountAtL_eq_prod_localnumber-theory
For squarefree D, E with D at most R and E at most R, the good-pair count at modulus lcm D E equals the product over the prime divisors of lcm D E of the local choice counts. No admissibility hypothesis. Formalization Note: the count, support, goodness, and local choice finsets are written out in Mathlib terms, with no local definitions.
Preamble
import Mathlib open Classical
Formal statement
theorem gpy_goodCountAtL_eq_prod_local {k : ℕ} {h : Fin k → ℕ} {R : ℕ}
{i : Fin k} {D E : ℕ} (hsqD : Squarefree D) (hsqE : Squarefree E)
(hDR : D ≤ R) (hER : E ≤ R) :
((((Fintype.piFinset (fun _ : Fin k => Finset.Icc 1 R)).filter
(fun d => ∏ i, d i ≤ R) ×ˢ
(Fintype.piFinset (fun _ : Fin k => Finset.Icc 1 R)).filter
(fun d => ∏ i, d i ≤ R)).filter
(fun p => ∏ j, p.1 j = D ∧ ∏ j, p.2 j = E ∧
(∃ w, (∀ j, Nat.lcm (p.1 j) (p.2 j) ∣ w + h j) ∧
Nat.Coprime (w + h i)
(Finset.lcm Finset.univ (fun j => Nat.lcm (p.1 j) (p.2 j)))) ∧
Finset.lcm Finset.univ (fun j => Nat.lcm (p.1 j) (p.2 j)) = Nat.lcm D E))).card
= ∏ p ∈ (Nat.lcm D E).primeFactors,
((Finset.univ : Finset (Option (Fin k) × Option (Fin k))).filter
(fun ab => (ab.1.isSome ↔ p ∣ D) ∧ (ab.2.isSome ↔ p ∣ E) ∧
(∀ j j', (ab.1 = some j ∨ ab.2 = some j) →
(ab.1 = some j' ∨ ab.2 = some j') → h j ≡ h j' [MOD p]) ∧
(∀ j, (ab.1 = some j ∨ ab.2 = some j) → ¬ h i ≡ h j [MOD p]))).card := by sorrySource
GPY good-count product formula via the fiber bijection, formalized from Mathlib (no local definitions in statements)