nLab modular arithmetic

Contents

The modulus relation

The basic relation in modular arithmetic is the modulus relation. In dependent type theory with a natural numbers type and function types, one could define the modulus relation on the natural numbers as a ternary inductive type family m≡nmodkm \equiv n \mod k indexed by natural numbers m:ℕm:\mathbb{N}, n:ℕn:\mathbb{N}, and k:ℕk:\mathbb{N}, inductively defined by the following constructors:

  • for each k:ℕk:\mathbb{N}, a term
    indzero(k):0≡0modk\mathrm{indzero}(k):0 \equiv 0 \mod k
  • for each k:ℕk:\mathbb{N}, m:ℕm:\mathbb{N} and n:ℕn:\mathbb{N}, a function
    indsucc(m,n,k):(m≡nmodk)→(s(m)≡s(n)modk)\mathrm{indsucc}(m, n, k):(m \equiv n \mod k) \to (s(m) \equiv s(n) \mod k)
  • for each k:ℕk:\mathbb{N}, m:ℕm:\mathbb{N} and n:ℕn:\mathbb{N}, a term
    indmodleft(m,n,k):m⋅k≡0modk\mathrm{indmodleft}(m, n, k):m \cdot k \equiv 0 \mod k
  • for each k:ℕk:\mathbb{N}, m:ℕm:\mathbb{N} and n:ℕn:\mathbb{N}, a term
    indmodright(m,n,k):0≡n⋅kmodk\mathrm{indmodright}(m, n, k):0 \equiv n \cdot k \mod k

where m⋅nm \cdot n is multiplication of two natural numbers m:ℕm:\mathbb{N} and n:ℕn:\mathbb{N}.

For each nonzero natural number kk, the type (ℕ,m≡nmodk)(\mathbb{N}, m \equiv n \mod k) is equivalent to the finite type Fin(k)\mathrm{Fin}(k) equipped with its canonical identity type. When kk is zero the type (ℕ,m≡nmodk)(\mathbb{N}, m \equiv n \mod k) is equivalent to the type of natural numbers with its canonical identity type.

This implies that the modulus relation is valued in h-propositions and is a family of decidable equivalence relations indexed by kk.

References

Last revised on October 11, 2022 at 22:52:33. See the history of this page for a list of all contributions to it.