Mathlib theorem · Existing formal mathematics

Existing in Mathlib · Number theory

Fermat's Little Theorem

Choose a prime modulus p and a number n not divisible by p. Raising n to the power p−1 returns the unit residue 1 after reduction modulo p.

Exact theorem

Exact Mathlib statement

theorem Nat.ModEq.pow_card_sub_one_eq_one {p : ℕ} (hp : Nat.Prime p) {n : ℕ} (hpn : n.Coprime p) : n ^ (p - 1) ≡ 1 [MOD p]

The theorem at a glance

Fermat's Little Theorem — exact coprime exponent form

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

The selected Mathlib theorem states the coprime exponent form of Fermat's Little Theorem. Explanatory diagram.
Detailed visual description

The retained poster presents the exact prime-modulus hypotheses, exponent p−1 conclusion, reading sequence, and boundary excluding the alternate n^p form, converses, and primality tests.

Statement structure

From hypotheses to conclusion

Statement map for Fermat's Little TheoremIf p is prime and n is coprime to p, then n^(p-1) is congruent to 1 modulo p. The pinned upstream declaration is Nat.ModEq.pow_card_sub_one_eq_one. The exact checked statement is theorem Nat.ModEq.pow_card_sub_one_eq_one {p : ℕ} (hp : Nat.Prime p) {n : ℕ} (hpn : n.Coprime p) : n ^ (p - 1) ≡ 1 [MOD p].Mathematical readingIf p is prime and n iscoprime to p, thenn^(p-1) is congruent to1 modulo p.Pinned declarationmathlib ·Nat.ModEq.pow_card_sub_one_eq_oneExact checked formtheoremNat.ModEq.pow_card_sub_one_eq_one{p : ℕ} (hp : Nat.Primep) {n : ℕ} (hpn :n.Coprime p) : n ^ (p -1) ≡ 1 [MOD p]Statement map for Fermat's Little TheoremIf p is prime and n is coprime to p, then n^(p-1) is congruent to 1 modulo p. The pinned upstream declaration is Nat.ModEq.pow_card_sub_one_eq_one. The exact checked statement is theorem Nat.ModEq.pow_card_sub_one_eq_one {p : ℕ} (hp : Nat.Prime p) {n : ℕ} (hpn : n.Coprime p) : n ^ (p - 1) ≡ 1 [MOD p].Mathematical readingIf p is prime and n iscoprime to p, thenn^(p-1) is congruent to1 modulo p.Pinned declarationmathlib ·Nat.ModEq.pow_card_sub_one_eq_oneExact checked formtheoremNat.ModEq.pow_card_sub_one_eq_one{p : ℕ} (hp : Nat.Primep) {n : ℕ} (hpn :n.Coprime p) : n ^ (p -1) ≡ 1 [MOD p]

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

For prime p and n coprime to p, the exponent p−1 returns n to residue 1 modulo p. Explanatory scientific diagram.
Detailed visual description

The theorem begins with a prime modulus and a coprime natural number, then concludes a precise congruence after p−1 repeated multiplications.

Why it matters

A mathematical landmark

Fermat's Little Theorem is a basic structural fact about arithmetic modulo a prime and a starting point for modern primality tests, finite-field calculations, and public-key cryptography.

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 target indexes Mathlib's natural-number congruence form: if p is prime and n is coprime to p, then n^(p-1) is congruent to 1 modulo p. It does not state the alternate n^p congruent to n form, primality converses, or a new proof.

Source and local evidence

Where the theorem comes from

Existing declaration
Nat.ModEq.pow_card_sub_one_eq_one in mathlib
Relationship
The checked artifact is the upstream declaration itself
Local Lean evidence
artifact.library.mathlib.fermat-little-theorem.v001
Source
Open the pinned upstream reference