Integers mod n #
Definition of the integers mod n, and the field structure on the integers mod p.
Definitions #
val a is a natural number defined as:
- for
a : ZMod 0it is the absolute value ofa - for
a : ZMod nwith0 < nit is the least natural number in the equivalence class
See ZMod.valMinAbs for a variant that takes values in the integers.
Equations
- ZMod.val = match (motive := (x : ℕ) → ZMod x → ℕ) x with | 0 => Int.natAbs | n.succ => Fin.val
Instances For
Alias of ZMod.val_natCast.
Alias of ZMod.val_natCast_of_lt.
This lemma works in the case in which ZMod n is not infinite, i.e. n ≠ 0. The version
where a ≠ 0 is addOrderOf_coe'.
This lemma works in the case in which a ≠ 0. The version where
ZMod n is not infinite, i.e. n ≠ 0, is addOrderOf_coe.
Alias of ZMod.natCast_self.
Alias of ZMod.natCast_self'.
Cast an integer modulo n to another semiring.
This function is a morphism if the characteristic of R divides n.
See ZMod.castHom for a bundled version.
Equations
Instances For
So-named because the coercion is Nat.cast into ZMod. For Nat.cast into an arbitrary ring,
see ZMod.natCast_val.
Alias of ZMod.natCast_zmod_val.
So-named because the coercion is Nat.cast into ZMod. For Nat.cast into an arbitrary ring,
see ZMod.natCast_val.
Alias of ZMod.natCast_rightInverse.
Alias of ZMod.natCast_zmod_surjective.
So-named because the outer coercion is Int.cast into ZMod. For Int.cast into an arbitrary
ring, see ZMod.intCast_cast.
Alias of ZMod.intCast_zmod_cast.
So-named because the outer coercion is Int.cast into ZMod. For Int.cast into an arbitrary
ring, see ZMod.intCast_cast.
Alias of ZMod.intCast_rightInverse.
Alias of ZMod.intCast_surjective.
Alias of ZMod.natCast_val.
Alias of ZMod.intCast_cast.
If the characteristic of R divides n, then cast is a homomorphism.
The canonical ring homomorphism from ZMod n to a ring of characteristic dividing n.
See also ZMod.lift for a generalized version working in AddGroups.
Equations
- ZMod.castHom h R = { toFun := ZMod.cast, map_one' := ⋯, map_mul' := ⋯, map_zero' := ⋯, map_add' := ⋯ }
Instances For
Some specialised simp lemmas which apply when R has characteristic n.
Alias of ZMod.cast_natCast'.
Alias of ZMod.cast_intCast'.
The unique ring isomorphism between ZMod n and a ring R
of characteristic n and cardinality n.
Equations
- ZMod.ringEquiv R h = RingEquiv.ofBijective (ZMod.castHom ⋯ R) ⋯
Instances For
The unique ring isomorphism between ZMod p and a ring R of cardinality a prime p.
If you need any property of this isomorphism, first of all use ringEquivOfPrime_eq_ringEquiv
below (after have : CharP R p := ...) and deduce it by the results about ZMod.ringEquiv.
Equations
- ZMod.ringEquivOfPrime R hp hR = let_fun this := ⋯; let_fun this := ⋯; ZMod.ringEquiv R hR
Instances For
Alias of ZMod.ringEquivCongr_intCast.
Alias of ZMod.intCast_zmod_eq_zero_iff_dvd.
Alias of ZMod.intCast_eq_intCast_iff_dvd_sub.
Alias of ZMod.natCast_zmod_eq_zero_iff_dvd.
Alias of ZMod.val_intCast.
Alias of ZMod.coe_intCast.
Alias of ZMod.intCast_mod.
Alias of ZMod.ker_intCastAddHom.
Alias of ZMod.natCast_toNat.
Alias of ZMod.natCast_mod.
unitOfCoprime makes an element of (ZMod n)ˣ given
a natural number x and a proof that x is coprime to n
Equations
- ZMod.unitOfCoprime x h = { val := ↑x, inv := (↑x)⁻¹, val_inv := ⋯, inv_val := ⋯ }
Instances For
Equivalence between the units of ZMod n and
the subtype of terms x : ZMod n for which x.val is coprime to n
Equations
- ZMod.unitsEquivCoprime = { toFun := fun (x : (ZMod n)ˣ) => ⟨↑x, ⋯⟩, invFun := fun (x : { x : ZMod n // x.val.Coprime n }) => ZMod.unitOfCoprime (↑x).val ⋯, left_inv := ⋯, right_inv := ⋯ }
Instances For
The Chinese remainder theorem. For a pair of coprime natural numbers, m and n,
the rings ZMod (m * n) and ZMod m × ZMod n are isomorphic.
See Ideal.quotientInfRingEquivPiQuotient for the Chinese remainder theorem for ideals in any
ring.
Equations
- One or more equations did not get rendered due to their size.
Instances For
valMinAbs x returns the integer in the same equivalence class as x that is closest to 0,
The result will be in the interval (-n/2, n/2].
Equations
Instances For
Alias of ZMod.natCast_natAbs_valMinAbs.
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Any ring homomorphism into ZMod n has a right inverse.