Integers mod n
Definition of the integers mod n, and the field structure on the integers mod p.
Definitions
Ring structure on fin n
We define a commutative ring structure on fin n
, but we do not register it as instance.
Afterwords, when we define zmod n
in terms of fin n
, we use these definitions
to register the ring structure on zmod n
as type class instance.
Additive commutative semigroup structure on fin (n+1)
.
Equations
- fin.add_comm_semigroup n = {add := has_add.add fin.has_add, add_assoc := _, add_comm := _}
Multiplicative commutative semigroup structure on fin (n+1)
.
Equations
- fin.comm_semigroup n = {mul := has_mul.mul fin.has_mul, mul_assoc := _, mul_comm := _}
Commutative ring structure on fin (n+1)
.
Equations
- fin.comm_ring n = {add := add_comm_semigroup.add (fin.add_comm_semigroup n), add_assoc := _, zero := 0, zero_add := _, add_zero := _, neg := has_neg.neg (fin.has_neg (n + 1)), add_left_neg := _, add_comm := _, mul := comm_semigroup.mul (fin.comm_semigroup n), mul_assoc := _, one := 1, one_mul := _, mul_one := _, left_distrib := _, right_distrib := _, mul_comm := _}
Equations
- zmod.fintype (n + 1) = fin.fintype (n + 1)
- zmod.fintype 0 = _.elim
Equations
- zmod.decidable_eq (n + 1) = fin.decidable_eq (n.add 0 + 1)
- zmod.decidable_eq 0 = int.decidable_eq
Equations
- zmod.has_repr (n + 1) = fin.has_repr (n.add 0 + 1)
- zmod.has_repr 0 = int.has_repr
Equations
- zmod.comm_ring (n + 1) = fin.comm_ring n
- zmod.comm_ring 0 = int.comm_ring
Equations
- zmod.inhabited n = {default := 0}
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.val_min_abs
for a variant that takes values in the integers.
Cast an integer modulo n
to another semiring.
This function is a morphism if the characteristic of R
divides n
.
See zmod.cast_hom
for a bundled version.
If the characteristic of R
divides n
, then cast
is a homomorphism.
Some specialised simp lemmas which apply when R
has characteristic n
.
Equations
- _ = _
Equations
- zmod.has_inv n = {inv := zmod.inv n}
Equations
Field structure on zmod p
if p
is prime.
Equations
- zmod.field p = {add := comm_ring.add (zmod.comm_ring p), add_assoc := _, zero := comm_ring.zero (zmod.comm_ring p), zero_add := _, add_zero := _, neg := comm_ring.neg (zmod.comm_ring p), add_left_neg := _, add_comm := _, mul := comm_ring.mul (zmod.comm_ring p), mul_assoc := _, one := comm_ring.one (zmod.comm_ring p), one_mul := _, mul_one := _, left_distrib := _, right_distrib := _, mul_comm := _, inv := has_inv.inv (zmod.has_inv p), exists_pair_ne := _, mul_inv_cancel := _, inv_zero := _}