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 0
it is the absolute value ofa
- for
a : ZMod n
with0 < n
it is the least natural number in the equivalence class
See ZMod.valMinAbs
for a variant that takes values in the integers.
Equations
Instances For
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
.
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
Equations
- ZMod.instCoeTCZMod n = { coe := ZMod.cast }
So-named because the outer coercion is Int.cast
into ZMod
. For Int.cast
into an arbitrary
ring, see ZMod.int_cast_cast
.
If the characteristic of R
divides n
, then cast
is a homomorphism.
Some specialised simp lemmas which apply when R
has characteristic n
.
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 (_ : n ∣ n) R) (_ : Function.Bijective ↑(ZMod.castHom (_ : n ∣ n) R))
Instances For
Equations
Equations
Equations
- ZMod.instInvZMod n = { inv := ZMod.inv n }
unitOfCoprime
makes an element of (ZMod n)ˣ
given
a natural number x
and a proof that x
is coprime to n
Equations
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
ZMod p
is an integral domain when p
is prime.