Mathlib theorem · Existing formal mathematics

Existing in Mathlib · Number theory and algebra

Chinese Remainder Theorem

When two moduli are coprime, one residue modulo their product carries exactly the same information as one ordered pair of component residues, and the correspondence respects both addition and multiplication.

Exact definition

Exact Mathlib definition

def ZMod.chineseRemainder {m n : ℕ} (h : m.Coprime n) : ZMod (m * n) ≃+* ZMod m × ZMod n

The theorem at a glance

Chinese Remainder Theorem — exact two-modulus ring form

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

The two-modulus ZMod correspondence is bijective and preserves addition and multiplication. Explanatory diagram.
Detailed visual description

The retained poster presents coprimality, the three rings, the forward and reverse reading, ring-operation preservation, and the exact two-modulus boundary of ZMod.chineseRemainder.

Statement structure

Statement and scope

Statement map for Chinese Remainder TheoremFor coprime natural moduli m and n, residues modulo m*n form a ring equivalent to ordered pairs of residues modulo m and modulo n. Claim boundary: This target indexes Mathlib's ring equivalence between integers modulo mn and pairs modulo m and n when m and n are coprime. It is the two-modulus ZMod form, not a finite-family formulation, an integer representative algorithm, or a new proof. The pinned upstream declaration is ZMod.chineseRemainder. The complete formal statement is available in the Exact Mathlib statement section.Mathematical readingFor coprime naturalmoduli m and n, residuesmodulo m*n form a ringequivalent to orderedpairs of residues modulom and modulo n.Claim boundaryThis target indexesMathlib's ringequivalence betweenintegers modulo mn andpairs modulo m and nwhen m and n arecoprime. It is thetwo-modulus ZMod form,not a finite-familyformulation, an integerrepresentativealgorithm, or a newproof.Pinned declarationmathlib ·ZMod.chineseRemainderStatement map for Chinese Remainder TheoremFor coprime natural moduli m and n, residues modulo m*n form a ring equivalent to ordered pairs of residues modulo m and modulo n. Claim boundary: This target indexes Mathlib's ring equivalence between integers modulo mn and pairs modulo m and n when m and n are coprime. It is the two-modulus ZMod form, not a finite-family formulation, an integer representative algorithm, or a new proof. The pinned upstream declaration is ZMod.chineseRemainder. The complete formal statement is available in the Exact Mathlib statement section.Mathematical readingFor coprime naturalmoduli m and n, residuesmodulo m*n form a ringequivalent to orderedpairs of residues modulom and modulo n.Claim boundaryThis target indexesMathlib's ringequivalence betweenintegers modulo mn andpairs modulo m and nwhen m and n arecoprime. It is thetwo-modulus ZMod form,not a finite-familyformulation, an integerrepresentativealgorithm, or a newproof.Pinned declarationmathlib ·ZMod.chineseRemainder

Read the exact Mathlib declaration

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

Coprimality makes one residue modulo m*n equivalent to one ordered pair modulo m and n. Explanatory scientific diagram.
Detailed visual description

The construction reduces a product residue to both component moduli, reconstructs it from the pair, and preserves the two ring operations.

Why it matters

A mathematical landmark

The Chinese Remainder Theorem turns a modular problem into independent coprime components. It is foundational in number theory, algebra, algorithms, and cryptography.

Proof architecture

From one product residue to an ordered residue pair

4 curated stages

Mathlib constructs a ring equivalence between ZMod (m * n) and ZMod m × ZMod n for coprime natural moduli. The source builds the forward reduction map and a case-split inverse, proves both inverse laws, and packages the correspondence with its additive and multiplicative structure.

These source-anchored stages explain the retained Mathlib proof route. They are generated explanations, not proof evidence or an extracted Lean proof-term dependency graph.

  1. Reduce one product residue to a pair

    Reduction sends one product residue to its ordered pair of component residues.

    to_fun : ZMod (m * n) → ZMod m × ZMod n

    The forward map to_fun is ZMod.castHom into the product ring. Coprimality identifies the least common multiple with the product, so one residue modulo m*n determines both component residues while preserving addition and multiplication.

  2. Construct the inverse in both product cases

    The inverse reconstructs a product residue, with the zero-product edge cases kept separate from the nonzero CRT branch.

    inv_fun : ZMod m × ZMod n → ZMod (m * n)

    The inverse map branches on m*n=0. Coprimality reduces that edge case to a trivial factor, while the nonzero branch applies Nat.chineseRemainder to the canonical values of the two component residues.

  3. Prove the two maps are inverse

    Simultaneous congruences recover the original residue, and finite cardinality closes the reverse identity.

    LeftInverse inv_fun to_fun ∧ RightInverse inv_fun to_fun

    Nat.modEq_and_modEq_iff_modEq_mul turns agreement modulo both coprime factors into agreement modulo their product, proving the left inverse. rightInverse_of_card_le then uses the matching finite cardinalities to obtain the right inverse.

  4. Assemble the ring equivalence

    The reversible correspondence preserves addition and multiplication, completing the two-modulus ring equivalence.

    ZMod (m * n) ≃+* ZMod m × ZMod n

    The final structure packages to_fun, inv_fun, map_add, map_mul, and the two inverse laws. The endpoint is exactly a ring equivalence between the product modulus and the ordered pair of component moduli.

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 ring equivalence between integers modulo mn and pairs modulo m and n when m and n are coprime. It is the two-modulus ZMod form, not a finite-family formulation, an integer representative algorithm, or a new proof.

Source and local evidence

Where the theorem comes from

Existing declaration
ZMod.chineseRemainder in mathlib
Relationship
The checked artifact is the upstream declaration itself
Local Lean evidence
artifact.library.mathlib.chinese-remainder-theorem.v001
Source
Open the pinned upstream reference