Documentation

Mathlib.Data.ZMod.Basic

Integers mod n #

Definition of the integers mod n, and the field structure on the integers mod p.

Definitions #

def ZMod.finEquiv (n : โ„•) [NeZero n] :
Fin n โ‰ƒ+* ZMod n

For non-zero n : โ„•, the ring Fin n is equivalent to ZMod n.

Instances For
    def ZMod.val {n : โ„•} :
    ZMod n โ†’ โ„•

    val a is a natural number defined as:

    • for a : ZMod 0 it is the absolute value of a
    • for a : ZMod n with 0 < n it is the least natural number in the equivalence class

    See ZMod.valMinAbs for a variant that takes values in the integers.

    Instances For
      theorem ZMod.val_lt {n : โ„•} [NeZero n] (a : ZMod n) :
      a.val < n
      theorem ZMod.val_le {n : โ„•} [NeZero n] (a : ZMod n) :
      @[simp]
      theorem ZMod.val_zero {n : โ„•} :
      val 0 = 0
      @[simp]
      theorem ZMod.val_neg' {n : ZMod 0} :
      (-n).val = n.val
      @[simp]
      theorem ZMod.val_mul' {m n : ZMod 0} :
      (m * n).val = m.val * n.val
      @[simp]
      theorem ZMod.val_natCast (n a : โ„•) :
      (โ†‘a).val = a % n
      theorem ZMod.val_natCast_of_lt {n a : โ„•} (h : a < n) :
      (โ†‘a).val = a
      theorem ZMod.val_ofNat (n a : โ„•) [a.AtLeastTwo] :
      (OfNat.ofNat a).val = OfNat.ofNat a % n
      theorem ZMod.val_ofNat_of_lt {n a : โ„•} [a.AtLeastTwo] (han : a < n) :
      (OfNat.ofNat a).val = OfNat.ofNat a
      theorem ZMod.val_unit' {n : ZMod 0} :
      IsUnit n โ†” n.val = 1
      theorem ZMod.eq_one_of_isUnit_natCast {n : โ„•} (h : IsUnit โ†‘n) :
      n = 1
      instance ZMod.charP (n : โ„•) :
      CharP (ZMod n) n
      @[simp]
      theorem ZMod.addOrderOf_one (n : โ„•) :
      @[simp]
      theorem ZMod.addOrderOf_coe (a : โ„•) {n : โ„•} (n0 : n โ‰  0) :
      addOrderOf โ†‘a = n / n.gcd a

      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'.

      @[simp]
      theorem ZMod.addOrderOf_coe' {a : โ„•} (n : โ„•) (a0 : a โ‰  0) :
      addOrderOf โ†‘a = n / n.gcd a

      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.

      theorem ZMod.ringChar_zmod_n (n : โ„•) :
      ringChar (ZMod n) = n

      We have that ringChar (ZMod n) = n.

      theorem ZMod.natCast_self (n : โ„•) :
      โ†‘n = 0
      @[simp]
      theorem ZMod.natCast_self' (n : โ„•) :
      โ†‘n + 1 = 0
      theorem ZMod.natCast_pow_eq_zero_of_le (p : โ„•) {m n : โ„•} (h : n โ‰ค m) :
      โ†‘p ^ m = 0
      def ZMod.cast {R : Type u_1} [AddGroupWithOne R] {n : โ„•} :
      ZMod n โ†’ R

      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.

      Instances For
        @[simp]
        theorem ZMod.cast_zero {n : โ„•} {R : Type u_1} [AddGroupWithOne R] :
        cast 0 = 0
        theorem ZMod.cast_eq_val {n : โ„•} {R : Type u_1} [AddGroupWithOne R] [NeZero n] (a : ZMod n) :
        a.cast = โ†‘a.val
        @[simp]
        theorem Prod.fst_zmod_cast {n : โ„•} {R : Type u_1} [AddGroupWithOne R] {S : Type u_2} [AddGroupWithOne S] (a : ZMod n) :
        a.cast.1 = a.cast
        @[simp]
        theorem Prod.snd_zmod_cast {n : โ„•} {R : Type u_1} [AddGroupWithOne R] {S : Type u_2} [AddGroupWithOne S] (a : ZMod n) :
        a.cast.2 = a.cast
        theorem ZMod.natCast_zmod_val {n : โ„•} [NeZero n] (a : ZMod n) :
        โ†‘a.val = a

        So-named because the coercion is Nat.cast into ZMod. For Nat.cast into an arbitrary ring, see ZMod.natCast_val.

        theorem ZMod.natCast_rightInverse {n : โ„•} [NeZero n] :
        Function.RightInverse val Nat.cast
        theorem ZMod.natCast_zmod_surjective {n : โ„•} [NeZero n] :
        Function.Surjective Nat.cast
        theorem ZMod.intCast_zmod_cast {n : โ„•} (a : ZMod n) :
        โ†‘a.cast = a

        So-named because the outer coercion is Int.cast into ZMod. For Int.cast into an arbitrary ring, see ZMod.intCast_cast.

        theorem ZMod.intCast_rightInverse {n : โ„•} :
        Function.RightInverse cast Int.cast
        theorem ZMod.intCast_surjective {n : โ„•} :
        Function.Surjective Int.cast
        theorem ZMod.forall {n : โ„•} {P : ZMod n โ†’ Prop} :
        (โˆ€ (x : ZMod n), P x) โ†” โˆ€ (x : โ„ค), P โ†‘x
        theorem ZMod.exists {n : โ„•} {P : ZMod n โ†’ Prop} :
        (โˆƒ (x : ZMod n), P x) โ†” โˆƒ (x : โ„ค), P โ†‘x
        theorem ZMod.cast_id (n : โ„•) (i : ZMod n) :
        i.cast = i
        @[simp]
        theorem ZMod.cast_id' {n : โ„•} :
        cast = id
        @[simp]
        theorem ZMod.natCast_comp_val {n : โ„•} (R : Type u_1) [Ring R] [NeZero n] :
        Nat.cast โˆ˜ val = cast

        The coercions are respectively Nat.cast and ZMod.cast.

        @[simp]
        theorem ZMod.intCast_comp_cast {n : โ„•} (R : Type u_1) [Ring R] :
        Int.cast โˆ˜ cast = cast

        The coercions are respectively Int.cast, ZMod.cast, and ZMod.cast.

        @[simp]
        theorem ZMod.natCast_val {n : โ„•} {R : Type u_1} [Ring R] [NeZero n] (i : ZMod n) :
        โ†‘i.val = i.cast
        @[simp]
        theorem ZMod.intCast_cast {n : โ„•} {R : Type u_1} [Ring R] (i : ZMod n) :
        โ†‘i.cast = i.cast
        theorem ZMod.cast_add_eq_ite {n : โ„•} (a b : ZMod n) :
        (a + b).cast = if โ†‘n โ‰ค a.cast + b.cast then a.cast + b.cast - โ†‘n else a.cast + b.cast

        If the characteristic of R divides n, then cast is a homomorphism.

        @[simp]
        theorem ZMod.cast_one {n : โ„•} {R : Type u_1} [Ring R] {m : โ„•} [CharP R m] (h : m โˆฃ n) :
        cast 1 = 1
        @[simp]
        theorem ZMod.cast_add {n : โ„•} {R : Type u_1} [Ring R] {m : โ„•} [CharP R m] (h : m โˆฃ n) (a b : ZMod n) :
        (a + b).cast = a.cast + b.cast
        @[simp]
        theorem ZMod.cast_mul {n : โ„•} {R : Type u_1} [Ring R] {m : โ„•} [CharP R m] (h : m โˆฃ n) (a b : ZMod n) :
        (a * b).cast = a.cast * b.cast
        def ZMod.castHom {n m : โ„•} (h : m โˆฃ n) (R : Type u_2) [Ring R] [CharP R m] :

        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.

        Instances For
          @[simp]
          theorem ZMod.castHom_apply {n : โ„•} {R : Type u_1} [Ring R] {m : โ„•} [CharP R m] {h : m โˆฃ n} (i : ZMod n) :
          (castHom h R) i = i.cast
          @[simp]
          theorem ZMod.cast_sub {n : โ„•} {R : Type u_1} [Ring R] {m : โ„•} [CharP R m] (h : m โˆฃ n) (a b : ZMod n) :
          (a - b).cast = a.cast - b.cast
          @[simp]
          theorem ZMod.cast_neg {n : โ„•} {R : Type u_1} [Ring R] {m : โ„•} [CharP R m] (h : m โˆฃ n) (a : ZMod n) :
          (-a).cast = -a.cast
          @[simp]
          theorem ZMod.cast_pow {n : โ„•} {R : Type u_1} [Ring R] {m : โ„•} [CharP R m] (h : m โˆฃ n) (a : ZMod n) (k : โ„•) :
          (a ^ k).cast = a.cast ^ k
          @[simp]
          theorem ZMod.cast_natCast {n : โ„•} {R : Type u_1} [Ring R] {m : โ„•} [CharP R m] (h : m โˆฃ n) (k : โ„•) :
          (โ†‘k).cast = โ†‘k
          @[simp]
          theorem ZMod.cast_intCast {n : โ„•} {R : Type u_1} [Ring R] {m : โ„•} [CharP R m] (h : m โˆฃ n) (k : โ„ค) :
          (โ†‘k).cast = โ†‘k
          theorem ZMod.castHom_surjective {n m : โ„•} (h : m โˆฃ n) :
          Function.Surjective โ‡‘(castHom h (ZMod m))

          Some specialised simp lemmas which apply when R has characteristic n.

          theorem ZMod.cast_one' {n : โ„•} {R : Type u_1} [Ring R] [CharP R n] :
          cast 1 = 1
          theorem ZMod.cast_add' {n : โ„•} {R : Type u_1} [Ring R] [CharP R n] (a b : ZMod n) :
          (a + b).cast = a.cast + b.cast
          theorem ZMod.cast_mul' {n : โ„•} {R : Type u_1} [Ring R] [CharP R n] (a b : ZMod n) :
          (a * b).cast = a.cast * b.cast
          theorem ZMod.cast_sub' {n : โ„•} {R : Type u_1} [Ring R] [CharP R n] (a b : ZMod n) :
          (a - b).cast = a.cast - b.cast
          theorem ZMod.cast_pow' {n : โ„•} {R : Type u_1} [Ring R] [CharP R n] (a : ZMod n) (k : โ„•) :
          (a ^ k).cast = a.cast ^ k
          theorem ZMod.cast_natCast' {n : โ„•} {R : Type u_1} [Ring R] [CharP R n] (k : โ„•) :
          (โ†‘k).cast = โ†‘k
          theorem ZMod.cast_intCast' {n : โ„•} {R : Type u_1} [Ring R] [CharP R n] (k : โ„ค) :
          (โ†‘k).cast = โ†‘k
          theorem ZMod.castHom_injective {n : โ„•} (R : Type u_1) [Ring R] [CharP R n] :
          Function.Injective โ‡‘(castHom โ‹ฏ R)
          theorem ZMod.castHom_bijective {n : โ„•} (R : Type u_1) [Ring R] [CharP R n] [Fintype R] (h : Fintype.card R = n) :
          Function.Bijective โ‡‘(castHom โ‹ฏ R)
          noncomputable def ZMod.ringEquiv {n : โ„•} (R : Type u_1) [Ring R] [CharP R n] [Fintype R] (h : Fintype.card R = n) :

          The unique ring isomorphism between ZMod n and a ring R of characteristic n and cardinality n.

          Instances For
            noncomputable def ZMod.ringEquivOfPrime (R : Type u_1) [Ring R] [Fintype R] {p : โ„•} (hp : Nat.Prime p) (hR : Fintype.card R = p) :

            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.

            Instances For
              @[simp]
              theorem ZMod.ringEquivOfPrime_eq_ringEquiv (R : Type u_1) [Ring R] [Fintype R] {p : โ„•} [CharP R p] (hp : Nat.Prime p) (hR : Fintype.card R = p) :
              def ZMod.ringEquivCongr {m n : โ„•} (h : m = n) :

              The identity between ZMod m and ZMod n when m = n, as a ring isomorphism.

              Instances For
                theorem ZMod.ringEquivCongr_refl_apply {a : โ„•} (x : ZMod a) :
                (ringEquivCongr โ‹ฏ) x = x
                theorem ZMod.ringEquivCongr_symm {a b : โ„•} (hab : a = b) :
                theorem ZMod.ringEquivCongr_trans {a b c : โ„•} (hab : a = b) (hbc : b = c) :
                theorem ZMod.ringEquivCongr_ringEquivCongr_apply {a b c : โ„•} (hab : a = b) (hbc : b = c) (x : ZMod a) :
                (ringEquivCongr hbc) ((ringEquivCongr hab) x) = (ringEquivCongr โ‹ฏ) x
                theorem ZMod.ringEquivCongr_val {a b : โ„•} (h : a = b) (x : ZMod a) :
                ((ringEquivCongr h) x).val = x.val
                theorem ZMod.ringEquivCongr_intCast {a b : โ„•} (h : a = b) (z : โ„ค) :
                (ringEquivCongr h) โ†‘z = โ†‘z
                @[simp]
                theorem ZMod.val_eq_zero {n : โ„•} (a : ZMod n) :
                a.val = 0 โ†” a = 0
                theorem ZMod.intCast_eq_intCast_iff (a b : โ„ค) (c : โ„•) :
                โ†‘a = โ†‘b โ†” a โ‰ก b [ZMOD โ†‘c]
                theorem ZMod.intCast_eq_intCast_iff' (a b : โ„ค) (c : โ„•) :
                โ†‘a = โ†‘b โ†” a % โ†‘c = b % โ†‘c
                theorem ZMod.val_intCast {n : โ„•} (a : โ„ค) [NeZero n] :
                โ†‘(โ†‘a).val = a % โ†‘n
                theorem ZMod.natCast_eq_natCast_iff (a b c : โ„•) :
                โ†‘a = โ†‘b โ†” a โ‰ก b [MOD c]
                theorem ZMod.natCast_eq_natCast_iff' (a b c : โ„•) :
                โ†‘a = โ†‘b โ†” a % c = b % c
                theorem ZMod.intCast_zmod_eq_zero_iff_dvd (a : โ„ค) (b : โ„•) :
                โ†‘a = 0 โ†” โ†‘b โˆฃ a
                theorem ZMod.intCast_eq_intCast_iff_dvd_sub (a b : โ„ค) (c : โ„•) :
                โ†‘a = โ†‘b โ†” โ†‘c โˆฃ b - a
                theorem ZMod.natCast_eq_zero_iff (a b : โ„•) :
                โ†‘a = 0 โ†” b โˆฃ a
                theorem ZMod.coe_intCast {n : โ„•} (a : โ„ค) :
                (โ†‘a).cast = a % โ†‘n
                theorem ZMod.intCast_cast_add {n : โ„•} (x y : ZMod n) :
                (x + y).cast = (x.cast + y.cast) % โ†‘n
                theorem ZMod.intCast_cast_mul {n : โ„•} (x y : ZMod n) :
                (x * y).cast = x.cast * y.cast % โ†‘n
                theorem ZMod.intCast_cast_sub {n : โ„•} (x y : ZMod n) :
                (x - y).cast = (x.cast - y.cast) % โ†‘n
                theorem ZMod.intCast_cast_neg {n : โ„•} (x : ZMod n) :
                (-x).cast = -x.cast % โ†‘n
                @[simp]
                theorem ZMod.val_neg_one (n : โ„•) :
                (-1).val = n
                theorem ZMod.cast_neg_one {R : Type u_1} [Ring R] (n : โ„•) :
                (-1).cast = โ†‘n - 1

                -1 : ZMod n lifts to n - 1 : R. This avoids the characteristic assumption in cast_neg.

                theorem ZMod.cast_sub_one {R : Type u_1} [Ring R] {n : โ„•} (k : ZMod n) :
                (k - 1).cast = (if k = 0 then โ†‘n else k.cast) - 1
                theorem ZMod.natCast_eq_iff (p n : โ„•) (z : ZMod p) [NeZero p] :
                โ†‘n = z โ†” โˆƒ (k : โ„•), n = z.val + p * k
                theorem ZMod.intCast_eq_iff (p : โ„•) (n : โ„ค) (z : ZMod p) [NeZero p] :
                โ†‘n = z โ†” โˆƒ (k : โ„ค), n = โ†‘z.val + โ†‘p * k
                @[simp]
                theorem ZMod.intCast_mod (a : โ„ค) (b : โ„•) :
                โ†‘(a % โ†‘b) = โ†‘a
                theorem ZMod.cast_injective_of_le {m n : โ„•} [nzm : NeZero m] (h : m โ‰ค n) :
                Function.Injective cast
                theorem ZMod.cast_zmod_eq_zero_iff_of_le {m n : โ„•} [NeZero m] (h : m โ‰ค n) (a : ZMod m) :
                a.cast = 0 โ†” a = 0
                @[simp]
                theorem ZMod.natCast_toNat (p : โ„•) {z : โ„ค} (_h : 0 โ‰ค z) :
                โ†‘z.toNat = โ†‘z
                theorem ZMod.val_injective (n : โ„•) [NeZero n] :
                Function.Injective val
                theorem ZMod.val_one_eq_one_mod (n : โ„•) :
                val 1 = 1 % n
                theorem ZMod.val_two_eq_two_mod (n : โ„•) :
                val 2 = 2 % n
                theorem ZMod.val_one (n : โ„•) [Fact (1 < n)] :
                val 1 = 1
                theorem ZMod.val_one'' {n : โ„•} :
                n โ‰  1 โ†’ val 1 = 1
                theorem ZMod.val_add {n : โ„•} [NeZero n] (a b : ZMod n) :
                (a + b).val = (a.val + b.val) % n
                theorem ZMod.val_add_of_lt {n : โ„•} {a b : ZMod n} (h : a.val + b.val < n) :
                (a + b).val = a.val + b.val
                theorem ZMod.val_add_val_of_le {n : โ„•} [NeZero n] {a b : ZMod n} (h : n โ‰ค a.val + b.val) :
                a.val + b.val = (a + b).val + n
                theorem ZMod.val_add_of_le {n : โ„•} [NeZero n] {a b : ZMod n} (h : n โ‰ค a.val + b.val) :
                (a + b).val = a.val + b.val - n
                theorem ZMod.val_add_le {n : โ„•} (a b : ZMod n) :
                (a + b).val โ‰ค a.val + b.val
                theorem ZMod.val_mul {n : โ„•} (a b : ZMod n) :
                (a * b).val = a.val * b.val % n
                theorem ZMod.val_mul_le {n : โ„•} (a b : ZMod n) :
                (a * b).val โ‰ค a.val * b.val
                theorem ZMod.val_mul_of_lt {n : โ„•} {a b : ZMod n} (h : a.val * b.val < n) :
                (a * b).val = a.val * b.val
                theorem ZMod.val_mul_iff_lt {n : โ„•} [NeZero n] (a b : ZMod n) :
                (a * b).val = a.val * b.val โ†” a.val * b.val < n
                instance ZMod.nontrivial (n : โ„•) [Fact (1 < n)] :
                theorem ZMod.one_eq_zero_iff {n : โ„•} :
                1 = 0 โ†” n = 1
                def ZMod.inv (n : โ„•) :
                ZMod n โ†’ ZMod n

                The inversion on ZMod n. It is setup in such a way that a * aโปยน is equal to gcd a.val n. In particular, if a is coprime to n, and hence a unit, a * aโปยน = 1.

                Instances For
                  @[implicit_reducible]
                  instance ZMod.instInv (n : โ„•) :
                  Inv (ZMod n)
                  theorem ZMod.mul_inv_eq_gcd {n : โ„•} (a : ZMod n) :
                  a * aโปยน = โ†‘(a.val.gcd n)
                  @[simp]
                  theorem ZMod.inv_one (n : โ„•) :
                  @[simp]
                  theorem ZMod.natCast_mod (a n : โ„•) :
                  โ†‘(a % n) = โ†‘a
                  theorem ZMod.intCast_eq_zero_iff_even {n : โ„ค} :
                  โ†‘n = 0 โ†” Even n
                  theorem Even.intCast_zmod_two {n : โ„ค} :
                  Even n โ†’ โ†‘n = 0

                  Alias of the reverse direction of ZMod.intCast_eq_zero_iff_even.

                  theorem ZMod.natCast_eq_zero_iff_even {n : โ„•} :
                  โ†‘n = 0 โ†” Even n
                  theorem Even.natCast_zmod_two {n : โ„•} :
                  Even n โ†’ โ†‘n = 0

                  Alias of the reverse direction of ZMod.natCast_eq_zero_iff_even.

                  theorem ZMod.intCast_eq_one_iff_odd {n : โ„ค} :
                  โ†‘n = 1 โ†” Odd n
                  theorem Odd.intCast_zmod_two {n : โ„ค} :
                  Odd n โ†’ โ†‘n = 1

                  Alias of the reverse direction of ZMod.intCast_eq_one_iff_odd.

                  theorem ZMod.natCast_eq_one_iff_odd {n : โ„•} :
                  โ†‘n = 1 โ†” Odd n
                  theorem Odd.natCast_zmod_two {n : โ„•} :
                  Odd n โ†’ โ†‘n = 1

                  Alias of the reverse direction of ZMod.natCast_eq_one_iff_odd.

                  theorem ZMod.natCast_ne_zero_iff_odd {n : โ„•} :
                  โ†‘n โ‰  0 โ†” Odd n
                  theorem ZMod.coe_mul_inv_eq_one {n : โ„•} (x : โ„•) (h : x.Coprime n) :
                  โ†‘x * (โ†‘x)โปยน = 1
                  theorem ZMod.mul_val_inv {m n : โ„•} (hmn : m.Coprime n) :
                  โ†‘m * โ†‘(โ†‘m)โปยน.val = 1
                  theorem ZMod.val_inv_mul {m n : โ„•} (hmn : m.Coprime n) :
                  โ†‘(โ†‘m)โปยน.val * โ†‘m = 1
                  def ZMod.unitOfCoprime {n : โ„•} (x : โ„•) (h : x.Coprime n) :

                  unitOfCoprime makes an element of (ZMod n)หฃ given a natural number x and a proof that x is coprime to n

                  Instances For
                    @[simp]
                    theorem ZMod.coe_unitOfCoprime {n : โ„•} (x : โ„•) (h : x.Coprime n) :
                    โ†‘(unitOfCoprime x h) = โ†‘x
                    theorem ZMod.val_coe_unit_coprime {n : โ„•} (u : (ZMod n)หฃ) :
                    (โ†‘u).val.Coprime n
                    theorem ZMod.isUnit_iff_coprime (m n : โ„•) :
                    IsUnit โ†‘m โ†” m.Coprime n
                    @[simp]
                    theorem ZMod.coprime_mod_iff_coprime (m n : โ„•) :
                    (m % n).Coprime n โ†” m.Coprime n
                    theorem ZMod.isUnit_prime_iff_not_dvd {n p : โ„•} (hp : Nat.Prime p) :
                    IsUnit โ†‘p โ†” ยฌp โˆฃ n
                    theorem ZMod.isUnit_prime_of_not_dvd {n p : โ„•} (hp : Nat.Prime p) (h : ยฌp โˆฃ n) :
                    IsUnit โ†‘p
                    @[simp]
                    theorem ZMod.inv_coe_unit {n : โ„•} (u : (ZMod n)หฃ) :
                    (โ†‘u)โปยน = โ†‘uโปยน
                    theorem ZMod.mul_inv_of_unit {n : โ„•} (a : ZMod n) (h : IsUnit a) :
                    theorem ZMod.inv_mul_of_unit {n : โ„•} (a : ZMod n) (h : IsUnit a) :
                    theorem ZMod.inv_eq_of_mul_eq_one (n : โ„•) (a b : ZMod n) (h : a * b = 1) :
                    @[simp]
                    theorem ZMod.inv_neg_one (n : โ„•) :
                    theorem ZMod.inv_mul_eq_one_of_isUnit {n : โ„•} {a : ZMod n} (ha : IsUnit a) (b : ZMod n) :
                    aโปยน * b = 1 โ†” a = b
                    def ZMod.unitsEquivCoprime {n : โ„•} [NeZero n] :
                    (ZMod n)หฃ โ‰ƒ { x : ZMod n // x.val.Coprime n }

                    Equivalence between the units of ZMod n and the subtype of terms x : ZMod n for which x.val is coprime to n

                    Instances For
                      def ZMod.chineseRemainder {m n : โ„•} (h : m.Coprime n) :
                      ZMod (m * n) โ‰ƒ+* ZMod m ร— ZMod n

                      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.

                      Instances For
                        theorem ZMod.subsingleton_iff {n : โ„•} :
                        Subsingleton (ZMod n) โ†” n = 1
                        theorem ZMod.nontrivial_iff {n : โ„•} :
                        Nontrivial (ZMod n) โ†” n โ‰  1
                        @[simp]
                        theorem ZMod.add_self_eq_zero_iff_eq_zero {n : โ„•} (hn : Odd n) {a : ZMod n} :
                        a + a = 0 โ†” a = 0
                        theorem ZMod.ne_neg_self {n : โ„•} (hn : Odd n) {a : ZMod n} (ha : a โ‰  0) :
                        a โ‰  -a
                        theorem ZMod.neg_one_ne_one {n : โ„•} [Fact (2 < n)] :
                        -1 โ‰  1
                        @[simp]
                        theorem ZMod.intCast_abs_mod_two (a : โ„ค) :
                        โ†‘|a| = โ†‘a
                        theorem ZMod.natAbs_mod_two (a : โ„ค) :
                        โ†‘a.natAbs = โ†‘a
                        theorem ZMod.val_ne_zero {n : โ„•} (a : ZMod n) :
                        a.val โ‰  0 โ†” a โ‰  0
                        @[simp]
                        theorem ZMod.val_pos {n : โ„•} {a : ZMod n} :
                        0 < a.val โ†” a โ‰  0
                        theorem ZMod.val_eq_one {n : โ„•} :
                        1 < n โ†’ โˆ€ (a : ZMod n), a.val = 1 โ†” a = 1
                        theorem ZMod.neg_eq_self_iff {n : โ„•} (a : ZMod n) :
                        -a = a โ†” a = 0 โˆจ 2 * a.val = n
                        theorem ZMod.val_cast_of_lt {n a : โ„•} (h : a < n) :
                        (โ†‘a).val = a
                        theorem ZMod.val_cast_zmod_lt {m : โ„•} [NeZero m] (n : โ„•) [NeZero n] (a : ZMod m) :
                        a.cast.val < m
                        theorem ZMod.neg_val' {n : โ„•} [NeZero n] (a : ZMod n) :
                        (-a).val = (n - a.val) % n
                        theorem ZMod.neg_val {n : โ„•} [NeZero n] (a : ZMod n) :
                        (-a).val = if a = 0 then 0 else n - a.val
                        theorem ZMod.val_neg_of_ne_zero {n : โ„•} [nz : NeZero n] (a : ZMod n) [na : NeZero a] :
                        (-a).val = n - a.val
                        theorem ZMod.val_sub {n : โ„•} [NeZero n] {a b : ZMod n} (h : b.val โ‰ค a.val) :
                        (a - b).val = a.val - b.val
                        theorem ZMod.val_cast_eq_val_of_lt {m n : โ„•} [nzm : NeZero m] {a : ZMod m} (h : a.val < n) :
                        a.cast.val = a.val
                        theorem ZMod.cast_cast_zmod_of_le {m n : โ„•} [hm : NeZero m] (h : m โ‰ค n) (a : ZMod m) :
                        a.cast.cast = a
                        theorem ZMod.val_pow {m n : โ„•} {a : ZMod n} [ilt : Fact (1 < n)] (h : a.val ^ m < n) :
                        (a ^ m).val = a.val ^ m
                        theorem ZMod.val_pow_le {m n : โ„•} [Fact (1 < n)] {a : ZMod n} :
                        (a ^ m).val โ‰ค a.val ^ m
                        theorem ZMod.natAbs_min_of_le_div_two (n : โ„•) (x y : โ„ค) (he : โ†‘x = โ†‘y) (hl : x.natAbs โ‰ค n / 2) :
                        x.natAbs โ‰ค y.natAbs
                        theorem RingHom.ext_zmod {n : โ„•} {R : Type u_1} [NonAssocSemiring R] (f g : ZMod n โ†’+* R) :
                        f = g
                        instance ZMod.subsingleton_ringHom {n : โ„•} {R : Type u_1} [Semiring R] :
                        Subsingleton (ZMod n โ†’+* R)
                        instance ZMod.subsingleton_ringEquiv {n : โ„•} {R : Type u_1} [Semiring R] :
                        Subsingleton (ZMod n โ‰ƒ+* R)
                        @[simp]
                        theorem ZMod.ringHom_map_cast {n : โ„•} {R : Type u_1} [NonAssocRing R] (f : R โ†’+* ZMod n) (k : ZMod n) :
                        f k.cast = k
                        theorem ZMod.ringHom_rightInverse {n : โ„•} {R : Type u_1} [NonAssocRing R] (f : R โ†’+* ZMod n) :
                        Function.RightInverse cast โ‡‘f

                        Any ring homomorphism into ZMod n has a right inverse.

                        theorem ZMod.ringHom_surjective {n : โ„•} {R : Type u_1} [NonAssocRing R] (f : R โ†’+* ZMod n) :
                        Function.Surjective โ‡‘f

                        Any ring homomorphism into ZMod n is surjective.

                        @[simp]
                        theorem ZMod.castHom_self {n : โ„•} :
                        castHom โ‹ฏ (ZMod n) = RingHom.id (ZMod n)
                        @[simp]
                        theorem ZMod.castHom_comp {n m d : โ„•} (hm : n โˆฃ m) (hd : m โˆฃ d) :
                        (castHom hm (ZMod n)).comp (castHom hd (ZMod m)) = castHom โ‹ฏ (ZMod n)
                        def ZMod.lift (n : โ„•) {A : Type u_2} [AddGroup A] :
                        { f : โ„ค โ†’+ A // f โ†‘n = 0 } โ‰ƒ (ZMod n โ†’+ A)

                        The map from ZMod n induced by f : โ„ค โ†’+ A that maps n to 0.

                        Instances For
                          @[simp]
                          theorem ZMod.lift_coe (n : โ„•) {A : Type u_2} [AddGroup A] (f : { f : โ„ค โ†’+ A // f โ†‘n = 0 }) (x : โ„ค) :
                          ((lift n) f) โ†‘x = โ†‘f x
                          theorem ZMod.lift_castAddHom (n : โ„•) {A : Type u_2} [AddGroup A] (f : { f : โ„ค โ†’+ A // f โ†‘n = 0 }) (x : โ„ค) :
                          ((lift n) f) ((Int.castAddHom (ZMod n)) x) = โ†‘f x
                          @[simp]
                          theorem ZMod.lift_comp_coe (n : โ„•) {A : Type u_2} [AddGroup A] (f : { f : โ„ค โ†’+ A // f โ†‘n = 0 }) :
                          โ‡‘((lift n) f) โˆ˜ Int.cast = โ‡‘โ†‘f
                          @[simp]
                          theorem ZMod.lift_comp_castAddHom (n : โ„•) {A : Type u_2} [AddGroup A] (f : { f : โ„ค โ†’+ A // f โ†‘n = 0 }) :
                          ((lift n) f).comp (Int.castAddHom (ZMod n)) = โ†‘f
                          theorem ZMod.lift_injective (n : โ„•) {A : Type u_2} [AddGroup A] {f : { f : โ„ค โ†’+ A // f โ†‘n = 0 }} :
                          Function.Injective โ‡‘((lift n) f) โ†” โˆ€ (m : โ„ค), โ†‘f m = 0 โ†’ โ†‘m = 0

                          Groups of bounded torsion #

                          For G a group and n a natural number, G having torsion dividing n (โˆ€ x : G, n โ€ข x = 0) can be derived from Module R G where R has characteristic dividing n.

                          It is however painful to have the API for such groups G stated in this generality, as R does not appear anywhere in the lemmas' return type. Instead of writing the API in terms of a general R, we therefore specialise to the canonical ring of order n, namely ZMod n.

                          This spelling Module (ZMod n) G has the extra advantage of providing the canonical action by ZMod n. It is however Type-valued, so we might want to acquire a Prop-valued version in the future.

                          theorem zmod_smul_mem {n : โ„•} {S : Type u_1} {G : Type u_2} [AddCommGroup G] [SetLike S G] [AddSubgroupClass S G] {K : S} [Module (ZMod n) G] {x : G} (hx : x โˆˆ K) (a : ZMod n) :
                          a โ€ข x โˆˆ K
                          theorem smulMemClass {n : โ„•} {S : Type u_1} {G : Type u_2} [AddCommGroup G] [SetLike S G] [AddSubgroupClass S G] [Module (ZMod n) G] :

                          This cannot be made an instance because of the [Module (ZMod n) G] argument and the fact that n only appears in the second argument of SMulMemClass, which is an OutParam.

                          @[implicit_reducible]
                          instance AddSubgroupClass.instZModSMul {n : โ„•} {S : Type u_1} {G : Type u_2} [AddCommGroup G] [SetLike S G] [AddSubgroupClass S G] {K : S} [Module (ZMod n) G] :
                          SMul (ZMod n) โ†ฅK
                          @[simp]
                          theorem AddSubgroupClass.coe_zmod_smul {n : โ„•} {S : Type u_1} {G : Type u_2} [AddCommGroup G] [SetLike S G] [AddSubgroupClass S G] {K : S} [Module (ZMod n) G] (a : ZMod n) (x : โ†ฅK) :
                          โ†‘(a โ€ข x) = a โ€ข โ†‘x
                          @[implicit_reducible]
                          instance AddSubgroupClass.instZModModule {n : โ„•} {S : Type u_1} {G : Type u_2} [AddCommGroup G] [SetLike S G] [AddSubgroupClass S G] {K : S} [Module (ZMod n) G] :
                          Module (ZMod n) โ†ฅK
                          theorem ZModModule.char_nsmul_eq_zero (n : โ„•) {G : Type u_2} [AddCommGroup G] [Module (ZMod n) G] (x : G) :
                          n โ€ข x = 0
                          theorem ZModModule.char_ne_one (n : โ„•) (G : Type u_2) [AddCommGroup G] [Module (ZMod n) G] [Nontrivial G] :
                          n โ‰  1
                          theorem ZModModule.two_le_char (n : โ„•) (G : Type u_2) [AddCommGroup G] [Module (ZMod n) G] [NeZero n] [Nontrivial G] :
                          theorem ZModModule.periodicPts_add_left (n : โ„•) {G : Type u_2} [AddCommGroup G] [Module (ZMod n) G] [NeZero n] (x : G) :
                          (Function.periodicPts fun (x_1 : G) => x + x_1) = Set.univ
                          theorem ZModModule.add_self {G : Type u_2} [AddCommGroup G] [Module (ZMod 2) G] (x : G) :
                          x + x = 0
                          theorem ZModModule.neg_eq_self {G : Type u_2} [AddCommGroup G] [Module (ZMod 2) G] (x : G) :
                          -x = x
                          theorem ZModModule.sub_eq_add {G : Type u_2} [AddCommGroup G] [Module (ZMod 2) G] (x y : G) :
                          x - y = x + y
                          theorem ZModModule.add_add_add_cancel {G : Type u_2} [AddCommGroup G] [Module (ZMod 2) G] (x y z : G) :
                          x + y + (y + z) = x + z
                          @[simp]
                          theorem pow_zmod_val_inv_pow {ฮฑ : Type u_1} [Group ฮฑ] {n : โ„•} (hn : (Nat.card ฮฑ).gcd n = 1) (a : ฮฑ) :
                          (a ^ (โ†‘n)โปยน.val) ^ n = a
                          @[simp]
                          theorem nsmul_zmod_val_inv_nsmul {ฮฑ : Type u_1} [AddGroup ฮฑ] {n : โ„•} (hn : (Nat.card ฮฑ).gcd n = 1) (a : ฮฑ) :
                          n โ€ข (โ†‘n)โปยน.val โ€ข a = a
                          @[simp]
                          theorem pow_pow_zmod_val_inv {ฮฑ : Type u_1} [Group ฮฑ] {n : โ„•} (hn : (Nat.card ฮฑ).gcd n = 1) (a : ฮฑ) :
                          (a ^ n) ^ (โ†‘n)โปยน.val = a
                          @[simp]
                          theorem zmod_val_inv_nsmul_nsmul {ฮฑ : Type u_1} [AddGroup ฮฑ] {n : โ„•} (hn : (Nat.card ฮฑ).gcd n = 1) (a : ฮฑ) :
                          (โ†‘n)โปยน.val โ€ข n โ€ข a = a
                          theorem Nat.range_mul_add (m k : โ„•) :
                          (Set.range fun (n : โ„•) => m * n + k) = {n : โ„• | โ†‘n = โ†‘k โˆง k โ‰ค n}

                          The range of (m * ยท + k) on natural numbers is the set of elements โ‰ฅ k in the residue class of k mod m.

                          def Nat.residueClassesEquiv (N : โ„•) [NeZero N] :
                          โ„• โ‰ƒ ZMod N ร— โ„•

                          Equivalence between โ„• and ZMod N ร— โ„•, sending n to (n mod N, n / N).

                          Instances For
                            instance ZMod.instSubsingletonModule (n : โ„•) (M : Type u_1) [AddCommMonoid M] :
                            Subsingleton (Module (ZMod n) M)