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 mnmodkm \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):00modk\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):(mnmodk)(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):mk0modk\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):0nkmodk\mathrm{indmodright}(m, n, k):0 \equiv n \cdot k \mod k

where mnm \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 (,mnmodk)(\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 (,mnmodk)(\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.