Sums of two squares #
Fermat's theorem on the sum of two squares. Every prime p congruent to 1 mod 4 is the
sum of two squares; see Nat.Prime.sq_add_sq (which has the weaker assumption p % 4 ≠ 3).
We also give the result that characterizes the (positive) natural numbers that are sums
of two squares as those numbers n such that for every prime q congruent to 3 mod 4, the
exponent of the largest power of q dividing n is even; see Nat.eq_sq_add_sq_iff.
There is an alternative characterization as the numbers of the form a^2 * b, where b is a
natural number such that -1 is a square modulo b; see Nat.eq_sq_add_sq_iff_eq_sq_mul.
Fermat's theorem on the sum of two squares. Every prime not congruent to 3 mod 4 is the sum of two squares. Also known as Fermat's Christmas theorem.
Generalities on sums of two squares #
The set of sums of two squares is closed under multiplication in any commutative ring.
See also sq_add_sq_mul_sq_add_sq.
The set of natural numbers that are sums of two squares is closed under multiplication.
Results on when -1 is a square modulo a natural number #
If -1 is a square modulo n and m divides n, then -1 is also a square modulo m.
If -1 is a square modulo coprime natural numbers m and n, then -1 is also
a square modulo m*n.
If p is a prime factor of n such that -1 is a square modulo n, then p % 4 ≠ 3.
Alias of Nat.mod_four_ne_three_of_mem_primeFactors_of_isSquare_neg_one.
If p is a prime factor of n such that -1 is a square modulo n, then p % 4 ≠ 3.
If n is a squarefree natural number, then -1 is a square modulo n if and only if
n does not have a prime factor q such that q % 4 = 3.
Alias of ZMod.isSquare_neg_one_iff_forall_mem_primeFactors_mod_four_ne_three.
If n is a squarefree natural number, then -1 is a square modulo n if and only if
n does not have a prime factor q such that q % 4 = 3.
If n is a squarefree natural number, then -1 is a square modulo n if and only if
n has no divisor q that is ≡ 3 mod 4.
Relation to sums of two squares #
If -1 is a square modulo the natural number n, then n is a sum of two squares.
If the integer n is a sum of two squares of coprime integers,
then -1 is a square modulo n.
If the natural number n is a sum of two squares of coprime natural numbers, then
-1 is a square modulo n.
A natural number n is a sum of two squares if and only if n = a^2 * b with natural
numbers a and b such that -1 is a square modulo b.
Characterization in terms of the prime factorization #
A (positive) natural number n is a sum of two squares if and only if the exponent of
every prime q such that q % 4 = 3 in the prime factorization of n is even.
(The assumption 0 < n is not present, since for n = 0, both sides are satisfied;
the right-hand side holds, since padicValNat q 0 = 0 by definition.)