Formula for Pythagorean triples (Euclid's parametrization)
ProvedFamousTheorems.pythagorean_triple_classificationEuclid's parametrization of the Pythagorean triples.
An integer triple satisfies if and only if there are integers with
So every right triangle with integer sides is a scaled copy of one built from a pair , and the classification is exhaustive: the says nothing else occurs. The unordered pair appears as a disjunction because the two legs play asymmetric roles in the formula — one is a difference of squares, the other is twice a product — while the triple itself does not care which is which. The sign on is present because the statement is over , not .
The parametrization is in Book X of Euclid's Elements; Diophantus used it, and the Babylonian tablet Plimpton 322 (c. 1800 BC) appears to tabulate triples generated this way, over a thousand years earlier. It is the first nontrivial Diophantine equation to be completely solved, and the starting point for Fermat's descent — the case of Fermat's Last Theorem is proved by feeding this classification back into itself.
Formalization note. PythagoreanTriple x y z unfolds to x * x + y * y = z * z. The result is
Mathlib's PythagoreanTriple.classification.
import Mathlib
namespace FamousTheorems
theorem pythagorean_triple_classification : ∀ {x y z : ℤ}, PythagoreanTriple x y z ↔
∃ k m n, (x = k * (m ^ 2 - n ^ 2) ∧ y = k * (2 * m * n) ∨
x = k * (2 * m * n) ∧ y = k * (m ^ 2 - n ^ 2)) ∧
(z = k * (m ^ 2 + n ^ 2) ∨ z = -k * (m ^ 2 + n ^ 2)) := by sorry
end FamousTheorems