Theorem 5.7.1 — The prime-factor criterion for two integer squares
ProvedSteinENT.two_squares_criterionLet be a positive integer. For a prime , let denote its exponent in the prime factorization of . Then
This gives a complete arithmetic criterion for representability, including composite integers.
Formalization Note The input and primes are natural numbers, with positivity explicit. Square coordinates are integers, and Nat.factorization records the prime exponent.
import Mathlib.NumberTheory.SumTwoSquares import Mathlib.NumberTheory.DiophantineApproximation.Basic import Mathlib.Tactic
namespace SteinENT
theorem two_squares_criterion (n : ℕ) (hn : 0 < n) :
(∃ x y : ℤ, (n : ℤ) = x ^ 2 + y ^ 2) ↔
∀ p : ℕ, p.Prime → p ∣ n → p % 4 = 3 → Even (n.factorization p) := by sorry
end SteinENTRead-back
What the Lean code literally says, in plain math · Codex (exact model identifier unavailable in auditor runtime)
Read-back model: unavailable (the exact runtime model identifier is not exposed).
For every natural number with , there exist integers and such that , with interpreted as an integer in this equality, if and only if the following holds: for every natural number , if is prime, divides in the natural numbers, and the remainder of on division by is , then the natural number is even. Here means that for some ; a prime natural number is at least and has only and itself as natural divisors. The function is the finitely supported function from natural numbers to natural numbers whose value at a prime , for positive , is the exponent of in the prime factorization of , equivalently the largest for which ; it is at nonprimes and primes not dividing , and the library defines the entire factorization function of and of to be . Evenness means that this exponent equals for some . The hypothesis excludes but includes , for which the condition on prime divisors is vacuous; more generally that condition is vacuous whenever no prime divisor of has remainder modulo . The integers may be zero or negative, and there are no coprimality, distinctness, nonzero, or uniqueness conditions and no further assumptions.
Confirmed by the mission captain (proposal self-audit).