Mathlib theorem · Existing formal mathematics

Existing in Mathlib · Number theory

Classification of Pythagorean Triples

An integer triple satisfies x² + y² = z² exactly when, for some integers k, m, and n, its two leg coordinates are k(m² − n²) and k(2mn) in either order, while z is either k(m² + n²) or its negative.

Exact theorem

Exact Mathlib statement

theorem PythagoreanTriple.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))

The theorem at a glance

Classification of Pythagorean triples at a glance

A visual guide to the theorem's hypotheses, structure, and conclusion; the exact statement gives the formal detail.

Every integer Pythagorean triple, including scaled and signed cases, has the displayed parameter form—and every displayed parameter choice gives a Pythagorean triple. Explanatory diagram.
Detailed visual description

The poster states the biconditional over integers, gives both possible orders of the two leg coordinates, and gives both possible signs of the third coordinate. A central square-and-ribbon construction keeps the common scale k visible across all three coordinates. The scope footer explicitly excludes positivity, primitivity, coprimality, parity, and uniqueness claims.

Statement structure

From hypotheses to conclusion

Statement map for Classification of Pythagorean TriplesAll integer solutions of x² + y² = z² are exactly the scaled Euclidean parameter forms, with the legs interchangeable and either sign allowed for z. The pinned upstream declaration is PythagoreanTriple.classification. The exact checked statement is theorem PythagoreanTriple.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)).Mathematical readingAll integer solutions ofx² + y² = z² are exactlythe scaled Euclideanparameter forms, withthe legs interchangeableand either sign allowedfor z.Pinned declarationmathlib ·PythagoreanTriple.classificationExact checked formtheoremPythagoreanTriple.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))Statement map for Classification of Pythagorean TriplesAll integer solutions of x² + y² = z² are exactly the scaled Euclidean parameter forms, with the legs interchangeable and either sign allowed for z. The pinned upstream declaration is PythagoreanTriple.classification. The exact checked statement is theorem PythagoreanTriple.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)).Mathematical readingAll integer solutions ofx² + y² = z² are exactlythe scaled Euclideanparameter forms, withthe legs interchangeableand either sign allowedfor z.Pinned declarationmathlib ·PythagoreanTriple.classificationExact checked formtheoremPythagoreanTriple.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))

This map summarizes the statement's structure; the exact Mathlib declaration remains authoritative.

One common integer construction permits the two leg forms in either order and an independent choice between two signs for the third coordinate. Explanatory scientific diagram.
Detailed visual description

A cobalt cut-square motif and an emerald doubled-rectangle motif occupy the left side. Two wide antique-gold bands cross before meeting the two legs of one central right triangle. A single unornamented charcoal-and-gold band encloses the construction. The hypotenuse feeds a four-square hub at right, which splits into exactly two identical concentric endpoint motifs, one above and one below. No third branch or sign glyph appears.

Why it matters

A mathematical landmark

The classification turns the elementary-looking equation x² + y² = z² into a complete parameterization of every integer solution. Mathlib's endpoint is unusually instructive because it exposes the full generality often suppressed in textbook shorthand: an arbitrary integer scale, either order of the legs, and either sign of z, with no primitive, positivity, parity, coprimality, or uniqueness condition in the final statement.

ProofAtlas record

What has been checked

Upstream indexedPinned source bytes verified locally
Locally reproducedExact upstream declaration replayed
Reviewed pageCurrent public presentation reviewed
Accepted Atlas resultNot recorded for the preferred artifact

Mathlib is the source of the theorem; the local Lean replay and page review are separate.

Claim boundary

No new theorem is claimed

This page indexes Mathlib's integer if-and-only-if classification of Pythagorean triples. Here PythagoreanTriple x y z is exactly x * x + y * y = z * z. The parameters k, m, and n are integers; the two leg formulas may be swapped, and z may be either k * (m ^ 2 + n ^ 2) or -k * (m ^ 2 + n ^ 2). The endpoint does not require a primitive or positive triple, does not require the parameters to be coprime or of opposite parity, and does not claim unique or canonical parameters. It is not the rational-unit-circle formulation.

Source and local evidence

Where the theorem comes from

Existing declaration
PythagoreanTriple.classification in mathlib
Relationship
The checked artifact is the upstream declaration itself
Local Lean evidence
artifact.library.mathlib.pythagorean-triples-classification.v001
Source
Open the pinned upstream reference