Documentation

Mathlib.Data.Int.ModEq

Congruences modulo an integer #

This file defines the equivalence relation a ≡ b [ZMOD n] on the integers, similarly to how Data.Nat.ModEq defines them for the natural numbers. The notation is short for n.ModEq a b, which is defined to be a % n = b % n for integers a b n.

Tags #

modeq, congruence, mod, MOD, modulo, integers

def Int.ModEq (n : ) (a : ) (b : ) :

a ≡ b [ZMOD n] when a % n = b % n.

Equations
  • n.ModEq a b = (a % n = b % n)
Instances For

    a ≡ b [ZMOD n] when a % n = b % n.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      instance Int.instDecidableModEq {n : } {a : } {b : } :
      Decidable (n.ModEq a b)
      Equations
      • Int.instDecidableModEq = decEq (a % n) (b % n)
      @[simp]
      theorem Int.ModEq.refl {n : } (a : ) :
      n.ModEq a a
      theorem Int.ModEq.rfl {n : } {a : } :
      n.ModEq a a
      instance Int.ModEq.instIsRefl {n : } :
      IsRefl n.ModEq
      Equations
      • =
      theorem Int.ModEq.symm {n : } {a : } {b : } :
      n.ModEq a bn.ModEq b a
      theorem Int.ModEq.trans {n : } {a : } {b : } {c : } :
      n.ModEq a bn.ModEq b cn.ModEq a c
      instance Int.ModEq.instIsTrans {n : } :
      IsTrans n.ModEq
      Equations
      • =
      theorem Int.ModEq.eq {n : } {a : } {b : } :
      n.ModEq a ba % n = b % n
      theorem Int.modEq_comm {n : } {a : } {b : } :
      n.ModEq a b n.ModEq b a
      theorem Int.natCast_modEq_iff {a : } {b : } {n : } :
      (n).ModEq a b n.ModEq a b
      theorem Int.modEq_zero_iff_dvd {n : } {a : } :
      n.ModEq a 0 n a
      theorem Dvd.dvd.modEq_zero_int {n : } {a : } (h : n a) :
      n.ModEq a 0
      theorem Dvd.dvd.zero_modEq_int {n : } {a : } (h : n a) :
      n.ModEq 0 a
      theorem Int.modEq_iff_dvd {n : } {a : } {b : } :
      n.ModEq a b n b - a
      theorem Int.modEq_iff_add_fac {a : } {b : } {n : } :
      n.ModEq a b ∃ (t : ), b = a + n * t
      theorem Int.modEq_of_dvd {n : } {a : } {b : } :
      n b - an.ModEq a b

      Alias of the reverse direction of Int.modEq_iff_dvd.

      theorem Int.ModEq.dvd {n : } {a : } {b : } :
      n.ModEq a bn b - a

      Alias of the forward direction of Int.modEq_iff_dvd.

      theorem Int.mod_modEq (a : ) (n : ) :
      n.ModEq (a % n) a
      @[simp]
      theorem Int.neg_modEq_neg {n : } {a : } {b : } :
      n.ModEq (-a) (-b) n.ModEq a b
      @[simp]
      theorem Int.modEq_neg {n : } {a : } {b : } :
      (-n).ModEq a b n.ModEq a b
      theorem Int.ModEq.of_dvd {m : } {n : } {a : } {b : } (d : m n) (h : n.ModEq a b) :
      m.ModEq a b
      theorem Int.ModEq.mul_left' {n : } {a : } {b : } {c : } (h : n.ModEq a b) :
      (c * n).ModEq (c * a) (c * b)
      theorem Int.ModEq.mul_right' {n : } {a : } {b : } {c : } (h : n.ModEq a b) :
      (n * c).ModEq (a * c) (b * c)
      theorem Int.ModEq.add {n : } {a : } {b : } {c : } {d : } (h₁ : n.ModEq a b) (h₂ : n.ModEq c d) :
      n.ModEq (a + c) (b + d)
      theorem Int.ModEq.add_left {n : } {a : } {b : } (c : ) (h : n.ModEq a b) :
      n.ModEq (c + a) (c + b)
      theorem Int.ModEq.add_right {n : } {a : } {b : } (c : ) (h : n.ModEq a b) :
      n.ModEq (a + c) (b + c)
      theorem Int.ModEq.add_left_cancel {n : } {a : } {b : } {c : } {d : } (h₁ : n.ModEq a b) (h₂ : n.ModEq (a + c) (b + d)) :
      n.ModEq c d
      theorem Int.ModEq.add_left_cancel' {n : } {a : } {b : } (c : ) (h : n.ModEq (c + a) (c + b)) :
      n.ModEq a b
      theorem Int.ModEq.add_right_cancel {n : } {a : } {b : } {c : } {d : } (h₁ : n.ModEq c d) (h₂ : n.ModEq (a + c) (b + d)) :
      n.ModEq a b
      theorem Int.ModEq.add_right_cancel' {n : } {a : } {b : } (c : ) (h : n.ModEq (a + c) (b + c)) :
      n.ModEq a b
      theorem Int.ModEq.neg {n : } {a : } {b : } (h : n.ModEq a b) :
      n.ModEq (-a) (-b)
      theorem Int.ModEq.sub {n : } {a : } {b : } {c : } {d : } (h₁ : n.ModEq a b) (h₂ : n.ModEq c d) :
      n.ModEq (a - c) (b - d)
      theorem Int.ModEq.sub_left {n : } {a : } {b : } (c : ) (h : n.ModEq a b) :
      n.ModEq (c - a) (c - b)
      theorem Int.ModEq.sub_right {n : } {a : } {b : } (c : ) (h : n.ModEq a b) :
      n.ModEq (a - c) (b - c)
      theorem Int.ModEq.mul_left {n : } {a : } {b : } (c : ) (h : n.ModEq a b) :
      n.ModEq (c * a) (c * b)
      theorem Int.ModEq.mul_right {n : } {a : } {b : } (c : ) (h : n.ModEq a b) :
      n.ModEq (a * c) (b * c)
      theorem Int.ModEq.mul {n : } {a : } {b : } {c : } {d : } (h₁ : n.ModEq a b) (h₂ : n.ModEq c d) :
      n.ModEq (a * c) (b * d)
      theorem Int.ModEq.pow {n : } {a : } {b : } (m : ) (h : n.ModEq a b) :
      n.ModEq (a ^ m) (b ^ m)
      theorem Int.ModEq.of_mul_left {n : } {a : } {b : } (m : ) (h : (m * n).ModEq a b) :
      n.ModEq a b
      theorem Int.ModEq.of_mul_right {n : } {a : } {b : } (m : ) :
      (n * m).ModEq a bn.ModEq a b
      theorem Int.ModEq.cancel_right_div_gcd {m : } {a : } {b : } {c : } (hm : 0 < m) (h : m.ModEq (a * c) (b * c)) :
      (m / (m.gcd c)).ModEq a b

      To cancel a common factor c from a ModEq we must divide the modulus m by gcd m c.

      theorem Int.ModEq.cancel_left_div_gcd {m : } {a : } {b : } {c : } (hm : 0 < m) (h : m.ModEq (c * a) (c * b)) :
      (m / (m.gcd c)).ModEq a b

      To cancel a common factor c from a ModEq we must divide the modulus m by gcd m c.

      theorem Int.ModEq.of_div {m : } {a : } {b : } {c : } (h : (m / c).ModEq (a / c) (b / c)) (ha : c a) (ha : c b) (ha : c m) :
      m.ModEq a b
      theorem Int.modEq_one {a : } {b : } :
      a b [ZMOD 1]
      theorem Int.modEq_sub (a : ) (b : ) :
      (a - b).ModEq a b
      @[simp]
      theorem Int.modEq_zero_iff {a : } {b : } :
      a b [ZMOD 0] a = b
      @[simp]
      theorem Int.add_modEq_left {n : } {a : } :
      n.ModEq (n + a) a
      @[simp]
      theorem Int.add_modEq_right {n : } {a : } :
      n.ModEq (a + n) a
      theorem Int.modEq_and_modEq_iff_modEq_mul {a : } {b : } {m : } {n : } (hmn : m.natAbs.Coprime n.natAbs) :
      m.ModEq a b n.ModEq a b (m * n).ModEq a b
      theorem Int.gcd_a_modEq (a : ) (b : ) :
      (b).ModEq (a * a.gcdA b) (a.gcd b)
      theorem Int.modEq_add_fac {a : } {b : } {n : } (c : ) (ha : n.ModEq a b) :
      n.ModEq (a + n * c) b
      theorem Int.modEq_sub_fac {a : } {b : } {n : } (c : ) (ha : n.ModEq a b) :
      n.ModEq (a - n * c) b
      theorem Int.modEq_add_fac_self {a : } {t : } {n : } :
      n.ModEq (a + n * t) a
      theorem Int.mod_coprime {a : } {b : } (hab : a.Coprime b) :
      ∃ (y : ), (b).ModEq (a * y) 1
      theorem Int.exists_unique_equiv (a : ) {b : } (hb : 0 < b) :
      ∃ (z : ), 0 z z < b b.ModEq z a
      theorem Int.exists_unique_equiv_nat (a : ) {b : } (hb : 0 < b) :
      ∃ (z : ), z < b b.ModEq (z) a
      theorem Int.mod_mul_right_mod (a : ) (b : ) (c : ) :
      a % (b * c) % b = a % b
      theorem Int.mod_mul_left_mod (a : ) (b : ) (c : ) :
      a % (b * c) % c = a % c
      @[deprecated Int.natCast_modEq_iff]
      theorem Int.coe_nat_modEq_iff {a : } {b : } {n : } :
      (n).ModEq a b n.ModEq a b

      Alias of Int.natCast_modEq_iff.