How statement and proof provenance work
The first chip identifies the source of the statement or construction; the second identifies the source of its local proof or verification.
- Literature-sourced: the exact statement appears in a cited source; only wording and notation differ.
- AI-adapted: a semantically identical restatement of literature-sourced material, modulo indexing, notation, and boundary cases adopted by the library.
- AI-generated: a genuinely novel statement formulated by AI, with no source for the claim itself.
These labels describe origin, not correctness: citations and verification chips remain separate evidence.
Sums of Two Squares
1 · Prerequisites
- Binary Operations, Monoids, Groups and Subgroups
- Congruences, the Integers Modulo n and the Chinese Remainder Theorem
- Construction of the Natural Numbers
- Construction of the Real Numbers via Cauchy Sequences
- Construction of the Real Numbers via Dedekind Cuts
- Cosets, Index and Lagrange's Theorem
- Countability and Uncountability
- Cyclic Groups and Direct Products
- Divisibility, Greatest Common Divisors and Bézout's Identity
- Finite Counting, Factorials and Binomial Coefficients
- Foundations of the Real Numbers for Analysis
- Group Homomorphisms and the Isomorphism Theorems
- Inclusion–Exclusion, the Pigeonhole Principle and Double Counting
- Normal Subgroups and Quotient Groups
- Polynomial Rings, the Division Algorithm and Roots
- Primes, Euclid's Lemma and the Fundamental Theorem of Arithmetic
- Primitive Roots and Unit Groups Modulo N
- Quadratic Residues and the Legendre Symbol
- Relations, Functions, and Quotients
- Rings, Subrings, Integral Domains and Fields
- Roots, Rational Powers, and Classical Inequalities
- Suprema and Infima
- The Fundamental Theorem of Finite Abelian Groups
- The ZFC Axioms and the Basic Set Constructions
2 · Summary
The first supplement to quadratic reciprocity determines exactly when is a square modulo an odd prime. Canonical prime factorisation and -adic valuations record the multiplicity of every prime divisor, while finite counting and the strong pigeonhole principle produce small congruent representatives. The existence and order properties of real square roots turn their integer bounds into strict inequalities.
A two-square representation is defined together with its primitive form, and the Brahmagupta–Fibonacci identity controls products. Thue's lemma yields Fermat's theorem for primes, while a factorisation lemma gives uniqueness up to signs and order. Prime-power analysis and the local obstruction at primes congruent to three modulo four lead to the full characterisation. Separate primitive-product and primitive-prime-power lemmas then give the primitive criterion and its product, divisor, and squarefree consequences.
3 · Logical flowchart
4 · Definitions, theorems and proofs
Representations and primitive representations as sums of two squares
Definition
A representation of a nonnegative integer as a sum of two squares is an ordered pair such that .
It is primitive when (Common divisor, and the greatest common divisor , with the convention ). Two representations are equivalent up to signs and order when one is obtained from the other by independently changing coordinate signs and possibly interchanging the coordinates, and essentially different when they are not so equivalent.
For a positive odd integer, a representation is normalized when and are positive, is odd, and is even.
Remarks
The ordered-pair convention retains signs and order when a correspondence is being counted. Equivalence up to signs and order is invoked only when those symmetries are deliberately discarded.
The Brahmagupta–Fibonacci two-square identity
Statement
For all integers ,
Facts & Assumptions
Given: Integers .
Proof
Expanding gives .
Likewise .
Sums of two squares are closed under products
Statement
The product of two nonnegative integers representable as sums of two squares is again representable as a sum of two squares (Representations and primitive representations as sums of two squares).
Facts & Assumptions
Given: Nonnegative integers , each representable as a sum of two squares.
A representation of a nonnegative integer as a sum of two squares is an ordered pair such that (Representations and primitive representations as sums of two squares).
For all integers , (The Brahmagupta–Fibonacci two-square identity).
Proof
Choose integers with and .
Then by the two-square identity.
The displayed integer pair represents by [F1]. This also covers a zero factor, for which the pair represents zero and the same formula gives the zero product.
Representations of an odd integer correspond to representations of twice that integer
Statement
Let be a positive odd integer. The map
is a bijection from the ordered signed two-square representations of to those of , with inverse
The same maps restrict to a bijection between the primitive representations (Representations and primitive representations as sums of two squares).
Facts & Assumptions
Given: A positive odd integer .
A representation of a nonnegative integer as a sum of two squares is an ordered pair such that (Representations and primitive representations as sums of two squares).
An integer is a common divisor of and when and (Common divisor, and the greatest common divisor , with the convention ).
Every integer greater than has a prime divisor (Every integer has a prime divisor; indeed the least divisor of that exceeds is prime).
If a prime divides a product , then or (Euclid's lemma: if is prime and then or ).
Proof
If , oddness of makes have opposite parity, so and are odd; moreover , so sends representations of to representations of .
If , reduction modulo shows that and are both odd: their squares cannot both be even because , and they cannot have opposite parity because their square sum would be odd. Thus has integer coordinates, and their squared sum is .
Direct substitution gives and .
Suppose is primitive and a common divisor greater than divides both coordinates of . By [L1] it has a prime divisor . Since and are odd, is odd; because divides and , [L2] gives and , contradicting primitivity. Hence is primitive.
Suppose is primitive and a common divisor greater than divides both coordinates of . A prime divisor supplied by [L1] then divides their sum and difference , contradicting primitivity. Hence is primitive.
The mutually inverse maps of step 2.1 give the first bijection, and steps 2.2 and 2.3 show that they restrict to mutually inverse maps on primitive representations.
A prime congruent to modulo divides both coordinates of a divisible two-square sum
Statement
If is prime and , then and . Consequently .
Facts & Assumptions
Given: A prime and integers such that .
A representation of a nonnegative integer as a sum of two squares is an ordered pair such that (Representations and primitive representations as sums of two squares).
For an odd prime , if and only if , while if and only if (First supplement: ).
For an odd prime , the Legendre symbol is when divides the numerator, when its nonzero class is a square, and otherwise (The Legendre symbol, including its zero value).
For every prime , addition and multiplication make a field (For every prime , the two operations on make it a field).
If a prime divides , then or (Euclid's lemma: if is prime and then or ).
The congruence means that (Congruence modulo an integer: when , including the moduli and ).
Proof
The divisibility hypothesis is the congruence .
If , then step 1.1 gives , so [L3] gives ; the same argument with the coordinates interchanged handles .
If neither coordinate were divisible by , the nonzero class of would be invertible in the field , and step 1.1 would give . Thus would be a nonzero quadratic residue and .
Since , [L1] instead gives , contradicting step 2.2.
Hence at least one coordinate is divisible by , and step 2.1 makes both divisible by . Writing and gives .
Every nonzero residue modulo an odd prime is a sum of two squares
Statement
Let be an odd prime and let with . Then there are integers such that
Facts & Assumptions
Given: An odd prime and a nonzero class .
For an odd prime , exactly nonzero classes are quadratic residues modulo (An odd prime has nonzero quadratic residues and as many nonresidues).
The quotient has elements (For , every class in has one representative with , so ; while is in bijection with ).
If finite sets and are disjoint, then (The sum rule: a finite disjoint union is finite with and , and a sum over a finite index set splits along a partition).
A subset of a finite set is finite and has cardinality at most that of the ambient set (A subset of a finite set is finite, with , and equality holds if and only if ).
For every , is an abelian group, and multiplication distributes over addition on both sides (For every natural , is an abelian group, multiplication is a commutative monoid operation, and both distributive laws hold).
Proof
Let be the set of all square classes in , including zero. By [L1], .
Translation and negation are bijections of the additive group, so also has elements.
Suppose, for contradiction, that and are disjoint. Then [L3] gives .
But , so [L2] and [L4] give , contradicting step 3.1.
Choose . Write and for integers . Then by [L5], which is the required congruence.
Thue's lemma on small nonzero representatives
Statement
Let be a prime and let with . Then there are nonzero integers with and .
Facts & Assumptions
Given: A prime and an integer with .
Every nonempty finite subset of has a maximum and a minimum (Every nonempty finite set of reals has a maximum and a minimum).
Every nonnegative real has a unique nonnegative square root whose square is (Square roots exist: a unique with ; the positives are ).
If finite sets are given, then (The product rule: , and ).
The quotient has elements for positive (For , every class in has one representative with , so ; while is in bijection with ).
If a map from a finite set to a finite set has , then some fibre contains more than one element (If then every has a fibre with more than elements, and for nonempty some fibre has at least elements).
If a prime divides , then or (Euclid's lemma: if is prime and then or ).
The congruence means that (Congruence modulo an integer: when , including the moduli and ).
Proof
The set is finite and contains , so [L1] gives its largest element .
One has : a strict inequality in the other direction would put in , while equality would factor the prime as with . Also , so by nonnegativity and [L2].
Put . Then [L3] gives by step 2.1 and [L4].
Apply [L5] to . Distinct pairs have the same image. With and , this says .
The coordinate bounds give .
If , then [F1] gives ; the bound forces , contrary to distinctness. If , then ; [L6] and give , and the same bound forces , again a contradiction.
Thus the integers from step 4.1 are both nonzero, satisfy , and obey the required strict bounds.
Fermat's two-square theorem for primes
Statement
A prime is a sum of two integer squares if and only if or (Representations and primitive representations as sums of two squares).
Facts & Assumptions
Given: A prime .
A representation of a nonnegative integer as a sum of two squares is an ordered pair such that (Representations and primitive representations as sums of two squares).
If is prime, , then there are nonzero integers with and (Thue's lemma on small nonzero representatives).
For an odd prime , if and only if (First supplement: ).
For an odd prime , means that and is a quadratic residue modulo (The Legendre symbol, including its zero value).
The congruence means that (Congruence modulo an integer: when , including the moduli and ).
Proof
If an odd prime satisfies , the square residues modulo show that have opposite parity and hence .
The remaining even prime has the representation .
For the converse direction, suppose . Then is odd, and [L2] and [F2] provide an integer with and .
Apply [L1] to this to obtain nonzero integers with and .
Squaring the congruence in step 2.1 and using gives . Moreover . The only positive multiple of below is , so .
Step 1.1 proves necessity for odd primes, step 1.2 handles , and step 3.1 proves sufficiency when .
Two essentially different two-square representations factor an odd integer
Statement
Let be odd and suppose
where are positive odd integers, are positive even integers, and . Then , and two essentially different normalized representations force a factorisation with . More precisely, there are positive integers such that
and .
Facts & Assumptions
Given: The two normalized representations and inequalities in the Statement.
For all integers , (The Brahmagupta–Fibonacci two-square identity).
An integer is a common divisor of and when and (Common divisor, and the greatest common divisor , with the convention ).
If and , then (If and then ; and if , and then ).
Proof
Since , one has , and . All four factors are positive and even, so with , , , and one has .
Let and write , . Positivity gives , and , since a common divisor greater than one would make a common divisor of larger than .
The equality becomes . Since , [L2] gives and ; write and with .
From , , , and one obtains , , , and .
By [L1], . Each factor exceeds one because all four entries are positive.
A prime congruent to modulo has one two-square representation up to signs and order
Statement
Let be prime. There are unique positive integers with odd, even, and
Every ordered signed representation of is obtained from this pair by changing signs and interchanging coordinates (Representations and primitive representations as sums of two squares).
Facts & Assumptions
Given: A prime .
A representation of a nonnegative integer as a sum of two squares is an ordered pair such that (Representations and primitive representations as sums of two squares).
A prime is a sum of two integer squares if and only if or (Fermat's two-square theorem for primes).
For an odd integer, two essentially different normalized representations force a factorisation with (Two essentially different two-square representations factor an odd integer).
Proof
By [L1], choose integers with .
Neither coordinate is zero, since a prime cannot be a square of an integer greater than one. Since is odd, exactly one coordinate is odd: two odd squares sum to modulo , and two even squares give an even sum. Changing signs and interchanging coordinates therefore turns every representation into a positive normalized one.
If two normalized representations differed, their positive odd coordinates would differ; order them as and apply [L2]. This would write the prime as a product of two integers greater than one, a contradiction. Hence the normalized representation is unique.
Step 1.1 supplies the normalized pair, step 2.1 makes it unique, and undoing the sign changes and interchange in step 1.2 gives all ordered signed representations and no others.
Prime powers represented as sums of two squares
Statement
Every power of and every power of a prime is a sum of two squares; a power of a prime is representable exactly when its exponent is even. The exponent ranges over all of , including zero.
Facts & Assumptions
Given: A prime and a natural exponent.
A representation of a nonnegative integer as a sum of two squares is an ordered pair such that (Representations and primitive representations as sums of two squares).
The product of two nonnegative integers representable as sums of two squares is again representable as a sum of two squares (Sums of two squares are closed under products).
If is prime and , then and (A prime congruent to modulo divides both coordinates of a divisible two-square sum).
A prime is a sum of two integer squares if and only if or (Fermat's two-square theorem for primes).
If a property holds at and passes from to , it holds for every (The principle of mathematical induction).
Proof
For every prime , the exponent-zero power is .
If , every even power has the explicit representation .
If , then [L2] gives and , so when ; at , the same divisibility would make divide , which is impossible. Induction on repeatedly reduces any alleged odd-exponent representation to that impossible base case.
The prime and every prime are represented by [L3]. Multiplying an induction-stage representation by the prime representation and using [L1] gives one for the next power, so [L4] represents all their natural powers.
Steps 1.1 and 2.1 handle and primes congruent to one modulo four, while steps 1.2 and 1.3 prove both directions for primes congruent to three modulo four.
Characterisation of positive integers that are sums of two squares
Statement
A positive integer is a sum of two squares if and only if every prime occurs to an even exponent in its canonical prime factorisation.
Facts & Assumptions
Given: A positive integer .
A representation of a nonnegative integer as a sum of two squares is an ordered pair such that (Representations and primitive representations as sums of two squares).
The product of two nonnegative integers representable as sums of two squares is again representable as a sum of two squares (Sums of two squares are closed under products).
If is prime and , then and (A prime congruent to modulo divides both coordinates of a divisible two-square sum).
Every power of and every power of a prime is a sum of two squares; a power of is representable exactly when its exponent is even (Prime powers represented as sums of two squares).
A positive integer is the finite product of the powers of its prime divisors with their canonical valuations (For and any injective list of primes containing every prime divisor of , one has ; the exponents are determined by , and for every prime outside the list).
For a nonzero integer, divides it if and only if (For a prime and a nonzero integer : and ; holds exactly for ; exactly when ; ; and ).
For nonzero integers , ( for nonzero integers , and whenever , and are all nonzero).
If a property holds at and passes from to , it holds for every (The principle of mathematical induction).
Proof
For the reverse direction at , the canonical factorisation is empty and represents .
For the reverse direction at , assume every three-mod-four prime has even valuation. By [L3], every prime-power factor in [L4] is representable.
For the forward direction, suppose and let divide . By [L2], and , so with .
Repeatedly applying [L1] to the finite list of factors from step 1.2 gives a representation of their product ; step 1.1 supplies the empty-list case.
By [L5] and [L6], step 1.3 lowers the -adic valuation by exactly two: .
If were odd, induction on the number of two-step reductions in steps 1.3 and 2.2 would eventually give a represented integer of -valuation one. Applying step 1.3 once more would make its valuation at least two, a contradiction. Thus is even.
Steps 2.1 and 3.1 prove the reverse and forward directions, respectively.
Coprime primitively represented factors have a primitive product representation
Statement
If and are primitive representations with , then the Brahmagupta–Fibonacci construction gives a primitive representation of . In particular, is primitive.
Facts & Assumptions
Given: Primitive representations , , with .
A two-square representation is primitive when its coordinate gcd is (Representations and primitive representations as sums of two squares).
For all integers , (The Brahmagupta–Fibonacci two-square identity).
An integer is a common divisor of and when and (Common divisor, and the greatest common divisor , with the convention ).
Every integer greater than has a prime divisor (Every integer has a prime divisor; indeed the least divisor of that exceeds is prime).
If a prime divides , then or (Euclid's lemma: if is prime and then or ).
Proof
Put and . By [L1], .
Suppose, for contradiction, that is not primitive. Its positive gcd then exceeds one, so choose by [L2] a prime dividing both and .
The combinations and are divisible by . Since is primitive, cannot divide both; applying [L3] to the combination with coefficient not divisible by gives .
Similarly, and . Primitivity of and [L3] give .
Steps 2.1 and 2.2 contradict . Hence is primitive and, by step 1.1, primitively represents .
Powers of primes congruent to modulo have primitive two-square representations
Statement
Every natural power of a prime congruent to modulo has a primitive two-square representation.
Facts & Assumptions
Given: A prime and an exponent .
A two-square representation is primitive when its coordinate gcd is (Representations and primitive representations as sums of two squares).
For all integers , (The Brahmagupta–Fibonacci two-square identity).
A prime is a sum of two integer squares if and only if or (Fermat's two-square theorem for primes).
Every integer greater than has a prime divisor (Every integer has a prime divisor; indeed the least divisor of that exceeds is prime).
If a prime divides , then or (Euclid's lemma: if is prime and then or ).
If a property holds at and passes from to , it holds for every (The principle of mathematical induction).
If a positive integer is written as a finite product of powers of distinct primes, every exponent equals the corresponding canonical valuation (For and any injective list of primes containing every prime divisor of , one has ; the exponents are determined by , and for every prime outside the list).
Proof
The pair primitively represents .
By [L2], choose with . Neither coordinate is zero, and divisibility of either coordinate by would force divisibility of the other and then ; in particular divides neither coordinate. Any common prime divisor would have square dividing , so is primitive; the coordinates have opposite parity because is odd.
Assume primitively. The two sign variants in [L1] give representations of with coordinate pairs and .
If a prime divides both coordinates of either candidate, then by step 2.1. The uniqueness of prime exponents in [L6], or [L4] iterated through the power, forces .
If both candidates were coordinatewise divisible by , their sums and differences would show that divides . Since is odd and neither nor is divisible by , [L4] would give and , contradicting the induction hypothesis.
Thus at least one candidate has no common prime divisor; by [L3] its coordinate gcd cannot exceed one, so it is primitive. Step 1.1 and [L5] complete the induction.
Characterisation of primitive sums of two squares
Statement
A positive integer has a primitive two-square representation if and only if and no prime divides .
Facts & Assumptions
Given: A positive integer .
A two-square representation is primitive when its coordinate gcd is (Representations and primitive representations as sums of two squares).
If is prime and , then and (A prime congruent to modulo divides both coordinates of a divisible two-square sum).
If and are primitive representations with , then the Brahmagupta–Fibonacci construction gives a primitive representation of (Coprime primitively represented factors have a primitive product representation).
Every natural power of a prime congruent to modulo has a primitive two-square representation (Powers of primes congruent to modulo have primitive two-square representations).
A positive integer is the finite product of the powers of its prime divisors with their canonical valuations (For and any injective list of primes containing every prime divisor of , one has ; the exponents are determined by , and for every prime outside the list).
For a prime and a nonzero integer , and every : if and only if ; in particular if and only if (For a prime and a nonzero integer : and ; holds exactly for ; exactly when ; ; and ).
For a finite pairwise-coprime list with partial products , one has whenever (For a finite pairwise-coprime list of positive integers, the product divides every common multiple, and each initial product is coprime to every remaining modulus).
If a prime divides , then or (Euclid's lemma: if is prime and then or ).
If a property holds at and passes from to , it holds for every (The principle of mathematical induction).
Proof
For the forward direction, if primitively and a prime divided , [L1] would make divide both coordinates, contrary to [F1].
Squares modulo show that forces both and even. Thus a primitive representation has , and the divisibility clause of [L5] at , makes that equivalent to .
For the reverse direction, assume the two stated prime conditions. In [L4], no three-mod-four prime occurs, the factor occurs with exponent at most one, and all remaining nontrivial factors are powers of distinct primes congruent to one modulo four. The factors are pairwise coprime by uniqueness and [L7].
The possible factor has the primitive representation , and every one-mod-four prime power has a primitive representation by [L3].
Combine these pairwise-coprime primitive representations one at a time using [L2]. The partial product is coprime to the next factor by [L6], so [L8] completes the finite induction. If the factor list is empty, and is primitive.
Steps 1.1 and 1.2 prove necessity, while step 3.1 proves sufficiency.
Primitive sums of two squares are closed under products unless both factors are even
Statement
Let be positive integers that have primitive two-square representations. If and are not both even, then has a primitive two-square representation.
Facts & Assumptions
Given: Positive primitively represented integers .
A positive integer has a primitive two-square representation if and only if and no prime divides (Characterisation of primitive sums of two squares).
For nonzero integers , ( for nonzero integers , and whenever , and are all nonzero).
For a prime and a nonzero integer , if and only if (For a prime and a nonzero integer : and ; holds exactly for ; exactly when ; ; and ).
Proof
By [L1] and [L3], every prime congruent to three modulo four has valuation zero in each factor. By [L2], its valuation in the product is zero, so [L3] shows that it does not divide the product.
Again by [L1]–[L3], because at least one of is odd and therefore has -adic valuation zero.
The two conditions in [L1] hold for , so the product has a primitive two-square representation.
Divisors greater than one of primitively represented integers are primitively represented
Statement
If a positive integer has a primitive two-square representation and divides , then has a primitive two-square representation.
Facts & Assumptions
Given: A primitively represented positive integer and a divisor of .
A positive integer has a primitive two-square representation if and only if and no prime divides (Characterisation of primitive sums of two squares).
For a prime and a nonzero integer , if and only if (For a prime and a nonzero integer : and ; holds exactly for ; exactly when ; ; and ).
Proof
Since , the divisibility criterion in [L2] gives for every prime . Thus , and no three-mod-four prime can divide , because none divides by [L1].
The two inherited conditions in step 1.1 satisfy [L1], so has a primitive two-square representation.
Squarefree sums of two squares
Statement
A squarefree positive integer is a sum of two squares if and only if none of its odd prime factors is congruent to modulo ; every such representation is primitive.
Facts & Assumptions
Given: A squarefree positive integer .
A positive integer is squarefree if no square of a prime divides ; equivalently, every exponent in its canonical prime factorisation is or (Squarefree positive integers).
A positive integer is a sum of two squares if and only if every prime occurs to an even exponent in its canonical prime factorisation (Characterisation of positive integers that are sums of two squares).
A positive integer has a primitive two-square representation if and only if and no prime divides (Characterisation of primitive sums of two squares).
An integer is a common divisor of and when and (Common divisor, and the greatest common divisor , with the convention ).
Every integer greater than has a prime divisor (Every integer has a prime divisor; indeed the least divisor of that exceeds is prime).
If a prime divides , then or (Euclid's lemma: if is prime and then or ).
Proof
By [F1], every prime exponent of is zero or one. Consequently the even-exponent condition in [L1] for a prime congruent to three modulo four is equivalent to that prime not dividing .
To see that every representation is primitive, suppose and . By [L3] choose a prime dividing the gcd. Then and by [F2], so , contradicting [F1].
Squarefreeness also gives , so the same exclusion of three-mod-four primes satisfies [L2] and yields a primitive representation whenever is represented.
Step 1.1 proves the representation criterion, step 2.1 supplies primitivity under that criterion, and step 1.2 shows that every representation has it.
5 · Examples, counterexamples and false statements
None yet.
Sources
- P. Hackman, Elementary Number Theory, Chapter E
- W. Stein, Elementary Number Theory: Primes, Congruences, and Secrets, §5.7
- P. Hackman, Elementary Number Theory, Chapter E, §E.II.1
- P. Hackman, Elementary Number Theory, Chapter E, §E.II, Exercise 2
- P. Hackman, Elementary Number Theory, Chapter E, §E.II.2
- W. Stein, Elementary Number Theory: Primes, Congruences, and Secrets, Lemma 5.7.4
- P. Hackman, Elementary Number Theory, Chapter E, §E.II, Exercise 4
- P. Hackman, Elementary Number Theory, Chapter E, Theorem E.I.1
- P. Hackman, Elementary Number Theory, Chapter E, Theorem E.I.2
- W. Stein, Elementary Number Theory: Primes, Congruences, and Secrets, Theorem 5.7.1
- P. Hackman, Elementary Number Theory, Chapter E, Theorem E.I.3
- P. Hackman, Elementary Number Theory, Chapter E, Theorem E.II.2
- P. Hackman, Elementary Number Theory, Chapter E, Lemma E.II.5
- P. Hackman, Elementary Number Theory, Chapter E, Lemma E.II.6
- P. Hackman, Elementary Number Theory, Chapter E, Theorem E.II.4 and Lemmas E.II.5–E.II.6
- P. Hackman, Elementary Number Theory, Chapter E, Corollary E.II.8(a)
- P. Hackman, Elementary Number Theory, Chapter E, Corollary E.II.8(b)
- P. Hackman, Elementary Number Theory, Chapter E, Theorems E.II.2 and E.II.4