Every integer solution of a^2+b^2=c^2+d^2 comes from four parameters
ProvedEqualTwoSquares.complete_parametrizationLet a, b, c and d be integers with a^2 + b^2 = c^2 + d^2. Then there are integers p, q, r and s with a = pr + qs, b = ps - qr, c = pr - qs and d = ps + qr; alternatively, there are integers p, q, r and s with a = pr + qs, b = ps - qr, d = pr - qs and c = ps + qr, i.e. the same conclusion holds after the two entries on the right-hand side are interchanged.
import Mathlib
namespace EqualTwoSquares
/-- Objective 6, the goal: the four-parameter parametrisation is complete. -/
theorem complete_parametrization {a b c d : ℤ} (h : a^2 + b^2 = c^2 + d^2) :
(∃ p q r s : ℤ,
a = p * r + q * s ∧ b = p * s - q * r ∧
c = p * r - q * s ∧ d = p * s + q * r) ∨
(∃ p q r s : ℤ,
a = p * r + q * s ∧ b = p * s - q * r ∧
d = p * r - q * s ∧ c = p * s + q * r) := by sorry
end EqualTwoSquaresRead-back
What the Lean code literally says, in plain math · independent-agent
Read-back: complete_parametrization
Declared in namespace EqualTwoSquares (file items/complete_parametrization.lean); the name agrees with the file name. Its own doc line reads "Objective 6, the goal: the four-parameter parametrisation is complete."
What the declaration literally says
Let satisfy the single hypothesis
Then at least one of the following two alternatives holds:
- Branch 1: there exist integers with
- Branch 2: there exist integers with
That is, every integer solution of the equal-sums-of-two-squares equation is produced by the four parameters in the pattern of the Brahmagupta–Fibonacci / four-parameter identity, up to possibly interchanging the roles of the two entries and on the right-hand side (branch 2 is branch 1 with and swapped; note keeps its form in both branches, and the two branches share the witnesses' formula for ).
No size bound, coprimality, positivity or normality is imposed on or on ; the witnesses are asserted only to exist, never uniquely. Degenerate solutions are expressly covered by the quantifiers: (take in either branch), solutions with zero entries, negative entries, coincident entries, and solutions where one side is empty of squares (, forcing ). Note that the bound alone is not always realisable in branch 1 — e.g. has odd, which makes impossible over the integers; for such quadruples only branch 2 can (and, by the theorem, does) succeed — with giving , , , . Both branches are therefore needed, and neither is vacuous.
Audit notes
-
Truth. TRUE, and this is the delicate item; it was checked in two independent ways.
Mathematical proof. Suppose . Counting odd entries modulo (every odd square is and every even square ) shows that the number of odd entries among equals the number of odd entries among , whence either (i) and are both even, or (ii) and are both even.
Case (i). Set , , , ; these are integers, they satisfy , , , , and . Applying the four-factor parametrisation (valid for all integer solutions of , including all zero patterns) gives with , , , ; substituting back yields exactly branch 1: , , , .
Case (ii). Same construction with and interchanged: , , , , giving , , , , i.e. branch 2.
Machine verification. For every quadruple with satisfying (40 001 quadruples), explicit integer witnesses were constructed by the above route and then re-verified against the four claimed equalities: zero unresolved quadruples. Concrete checked examples: branch 2 with ; () branch 1; either branch with all parameters .
-
Faithfulness. Name matches file name. The doc line's claim that "the four-parameter parametrisation is complete" is rendered as: every solution arises from some , up to swapping and — and the second branch is present precisely for that swap, so no case is dropped. All variables are bound: are implicit universal arguments, are existentially bound inside each branch, and every one appears in the branch's equations; nothing is free and nothing is quantified over vacuously. The statement is one-directional (every solution comes from parameters) and deliberately does not include the converse direction (that every choice of parameters yields a solution) — that direction is the content of the separate item
four_param_identity; if the author's notion of "completeness" was intended to bundle both directions, this item alone supplies only the completeness half. -
Trivializing premise. None: the single hypothesis is the equation under study, not a restatement of the parametrisation; it is not contradictory and does not restrict to degenerate solutions. The two-branch disjunction is genuinely required (see the example, where branch 1 is impossible), so the disjunction is not padding.
-
Satisfiability. The hypothesis is satisfiable with abundant non-trivial witnesses — every member of the explicit family , plus , , etc. — so the theorem is emphatically non-vacuous.
-
Elaboration. Included in
statements/All.lean; elaborates with only the expecteddeclaration uses 'sorry'warning.
FAITHFUL
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.