Documentation

Std.Data.Int.DivMod

Lemmas about integer division #

/ #

theorem Int.ofNat_div (m : Nat) (n : Nat) :
(m / n) = Int.div m n
theorem Int.ofNat_fdiv (m : Nat) (n : Nat) :
(m / n) = Int.fdiv m n
@[simp]
theorem Int.ofNat_ediv (m : Nat) (n : Nat) :
(m / n) = m / n
theorem Int.negSucc_ediv (m : Nat) {b : Int} (H : 0 < b) :
Int.negSucc m / b = -(Int.div (m) b + 1)
@[simp]
theorem Int.zero_div (b : Int) :
Int.div 0 b = 0
@[simp]
theorem Int.zero_ediv (b : Int) :
0 / b = 0
@[simp]
theorem Int.zero_fdiv (b : Int) :
Int.fdiv 0 b = 0
@[simp]
theorem Int.div_zero (a : Int) :
Int.div a 0 = 0
@[simp]
theorem Int.ediv_zero (a : Int) :
a / 0 = 0
@[simp]
theorem Int.fdiv_zero (a : Int) :
Int.fdiv a 0 = 0
theorem Int.fdiv_eq_ediv (a : Int) {b : Int} :
0 bInt.fdiv a b = a / b
theorem Int.div_eq_ediv {a : Int} {b : Int} :
0 a0 bInt.div a b = a / b
theorem Int.fdiv_eq_div {a : Int} {b : Int} (Ha : 0 a) (Hb : 0 b) :
@[simp]
theorem Int.div_neg (a : Int) (b : Int) :
Int.div a (-b) = -Int.div a b
@[simp]
theorem Int.ediv_neg (a : Int) (b : Int) :
a / -b = -(a / b)
theorem Int.div_def (a : Int) (b : Int) :
a / b = Int.ediv a b
@[simp]
theorem Int.div_def' (a : Int) (b : Int) :
a / b = Int.div a b
@[simp]
theorem Int.neg_div (a : Int) (b : Int) :
Int.div (-a) b = -Int.div a b
theorem Int.neg_div_neg (a : Int) (b : Int) :
Int.div (-a) (-b) = Int.div a b
theorem Int.div_nonneg {a : Int} {b : Int} (Ha : 0 a) (Hb : 0 b) :
0 Int.div a b
theorem Int.fdiv_nonneg {a : Int} {b : Int} (Ha : 0 a) (Hb : 0 b) :
theorem Int.ediv_nonneg {a : Int} {b : Int} (Ha : 0 a) (Hb : 0 b) :
0 a / b
theorem Int.div_nonpos {a : Int} {b : Int} (Ha : 0 a) (Hb : b 0) :
Int.div a b 0
theorem Int.fdiv_nonpos {a : Int} {b : Int} :
0 ab 0Int.fdiv a b 0
theorem Int.ediv_nonpos {a : Int} {b : Int} (Ha : 0 a) (Hb : b 0) :
a / b 0
theorem Int.fdiv_neg' {a : Int} {b : Int} :
a < 00 < bInt.fdiv a b < 0
theorem Int.ediv_neg' {a : Int} {b : Int} (Ha : a < 0) (Hb : 0 < b) :
a / b < 0
@[simp]
theorem Int.div_one (a : Int) :
Int.div a 1 = a
@[simp]
theorem Int.fdiv_one (a : Int) :
Int.fdiv a 1 = a
@[simp]
theorem Int.ediv_one (a : Int) :
a / 1 = a
theorem Int.div_eq_zero_of_lt {a : Int} {b : Int} (H1 : 0 a) (H2 : a < b) :
Int.div a b = 0
theorem Int.ediv_eq_zero_of_lt {a : Int} {b : Int} (H1 : 0 a) (H2 : a < b) :
a / b = 0
theorem Int.add_mul_ediv_right (a : Int) (b : Int) {c : Int} (H : c 0) :
(a + b * c) / c = a / c + b
theorem Int.add_mul_ediv_left (a : Int) {b : Int} (c : Int) (H : b 0) :
(a + b * c) / b = a / b + c
theorem Int.add_ediv_of_dvd_right {a : Int} {b : Int} {c : Int} (H : c b) :
(a + b) / c = a / c + b / c
theorem Int.add_ediv_of_dvd_left {a : Int} {b : Int} {c : Int} (H : c a) :
(a + b) / c = a / c + b / c
@[simp]
theorem Int.mul_ediv_cancel (a : Int) {b : Int} (H : b 0) :
a * b / b = a
@[simp]
theorem Int.mul_fdiv_cancel (a : Int) {b : Int} (H : b 0) :
Int.fdiv (a * b) b = a
@[simp]
theorem Int.mul_div_cancel (a : Int) {b : Int} (H : b 0) :
Int.div (a * b) b = a
@[simp]
theorem Int.mul_div_cancel_left {a : Int} (b : Int) (H : a 0) :
Int.div (a * b) a = b
@[simp]
theorem Int.mul_fdiv_cancel_left {a : Int} (b : Int) (H : a 0) :
Int.fdiv (a * b) a = b
@[simp]
theorem Int.mul_ediv_cancel_left {a : Int} (b : Int) (H : a 0) :
a * b / a = b
@[simp]
theorem Int.div_self {a : Int} (H : a 0) :
Int.div a a = 1
@[simp]
theorem Int.fdiv_self {a : Int} (H : a 0) :
Int.fdiv a a = 1
@[simp]
theorem Int.ediv_self {a : Int} (H : a 0) :
a / a = 1
theorem Int.div_nonneg_iff_of_pos {a : Int} {b : Int} (h : 0 < b) :
a / b 0 a 0

mod #

theorem Int.mod_def' (m : Int) (n : Int) :
m % n = Int.emod m n
theorem Int.ofNat_mod (m : Nat) (n : Nat) :
(m % n) = Int.mod m n
theorem Int.ofNat_mod_ofNat (m : Nat) (n : Nat) :
m % n = (m % n)
theorem Int.ofNat_fmod (m : Nat) (n : Nat) :
(m % n) = Int.fmod m n
@[simp]
theorem Int.ofNat_emod (m : Nat) (n : Nat) :
(m % n) = m % n
theorem Int.negSucc_emod (m : Nat) {b : Int} (bpos : 0 < b) :
Int.negSucc m % b = b - 1 - m % b
@[simp]
theorem Int.zero_mod (b : Int) :
Int.mod 0 b = 0
@[simp]
theorem Int.zero_fmod (b : Int) :
Int.fmod 0 b = 0
@[simp]
theorem Int.zero_emod (b : Int) :
0 % b = 0
@[simp]
theorem Int.mod_zero (a : Int) :
Int.mod a 0 = a
@[simp]
theorem Int.fmod_zero (a : Int) :
Int.fmod a 0 = a
@[simp]
theorem Int.emod_zero (a : Int) :
a % 0 = a
theorem Int.mod_add_div (a : Int) (b : Int) :
Int.mod a b + b * Int.div a b = a
theorem Int.fmod_add_fdiv (a : Int) (b : Int) :
Int.fmod a b + b * Int.fdiv a b = a
theorem Int.emod_add_ediv (a : Int) (b : Int) :
a % b + b * (a / b) = a
theorem Int.emod_add_ediv.aux (m : Nat) (n : Nat) :
n - (m % n + 1) - (n * (m / n) + n) = Int.negSucc m
theorem Int.div_add_mod (a : Int) (b : Int) :
b * Int.div a b + Int.mod a b = a
theorem Int.fdiv_add_fmod (a : Int) (b : Int) :
b * Int.fdiv a b + Int.fmod a b = a
theorem Int.ediv_add_emod (a : Int) (b : Int) :
b * (a / b) + a % b = a
theorem Int.mod_def (a : Int) (b : Int) :
Int.mod a b = a - b * Int.div a b
theorem Int.fmod_def (a : Int) (b : Int) :
Int.fmod a b = a - b * Int.fdiv a b
theorem Int.emod_def (a : Int) (b : Int) :
a % b = a - b * (a / b)
theorem Int.fmod_eq_emod (a : Int) {b : Int} (hb : 0 b) :
Int.fmod a b = a % b
theorem Int.mod_eq_emod {a : Int} {b : Int} (ha : 0 a) (hb : 0 b) :
Int.mod a b = a % b
theorem Int.fmod_eq_mod {a : Int} {b : Int} (Ha : 0 a) (Hb : 0 b) :
@[simp]
theorem Int.mod_neg (a : Int) (b : Int) :
Int.mod a (-b) = Int.mod a b
@[simp]
theorem Int.emod_neg (a : Int) (b : Int) :
a % -b = a % b
@[simp]
theorem Int.mod_one (a : Int) :
Int.mod a 1 = 0
theorem Int.emod_one (a : Int) :
a % 1 = 0
@[simp]
theorem Int.fmod_one (a : Int) :
Int.fmod a 1 = 0
theorem Int.emod_eq_of_lt {a : Int} {b : Int} (H1 : 0 a) (H2 : a < b) :
a % b = a
@[simp]
theorem Int.emod_self_add_one {x : Int} (h : 0 x) :
x % (x + 1) = x
theorem Int.mod_eq_of_lt {a : Int} {b : Int} (H1 : 0 a) (H2 : a < b) :
Int.mod a b = a
theorem Int.fmod_eq_of_lt {a : Int} {b : Int} (H1 : 0 a) (H2 : a < b) :
Int.fmod a b = a
theorem Int.mod_nonneg {a : Int} (b : Int) :
0 a0 Int.mod a b
theorem Int.emod_nonneg (a : Int) {b : Int} :
b 00 a % b
theorem Int.fmod_nonneg {a : Int} {b : Int} (ha : 0 a) (hb : 0 b) :
theorem Int.fmod_nonneg' (a : Int) {b : Int} (hb : 0 < b) :
theorem Int.mod_lt_of_pos (a : Int) {b : Int} (H : 0 < b) :
Int.mod a b < b
theorem Int.emod_lt_of_pos (a : Int) {b : Int} (H : 0 < b) :
a % b < b
theorem Int.fmod_lt_of_pos (a : Int) {b : Int} (H : 0 < b) :
Int.fmod a b < b
theorem Int.mul_ediv_self_le {x : Int} {k : Int} (h : k 0) :
k * (x / k) x
theorem Int.lt_mul_ediv_self_add {x : Int} {k : Int} (h : 0 < k) :
x < k * (x / k) + k
theorem Int.emod_two_eq (x : Int) :
x % 2 = 0 x % 2 = 1
theorem Int.mod_add_div' (m : Int) (k : Int) :
Int.mod m k + Int.div m k * k = m
theorem Int.div_add_mod' (m : Int) (k : Int) :
Int.div m k * k + Int.mod m k = m
theorem Int.emod_add_ediv' (m : Int) (k : Int) :
m % k + m / k * k = m
theorem Int.ediv_add_emod' (m : Int) (k : Int) :
m / k * k + m % k = m
@[simp]
theorem Int.add_mul_emod_self {a : Int} {b : Int} {c : Int} :
(a + b * c) % c = a % c
@[simp]
theorem Int.add_mul_emod_self_left (a : Int) (b : Int) (c : Int) :
(a + b * c) % b = a % b
@[simp]
theorem Int.add_emod_self {a : Int} {b : Int} :
(a + b) % b = a % b
@[simp]
theorem Int.add_emod_self_left {a : Int} {b : Int} :
(a + b) % a = b % a
theorem Int.neg_emod {a : Int} {b : Int} :
-a % b = (b - a) % b
@[simp]
theorem Int.emod_add_emod (m : Int) (n : Int) (k : Int) :
(m % n + k) % n = (m + k) % n
@[simp]
theorem Int.add_emod_emod (m : Int) (n : Int) (k : Int) :
(m + n % k) % k = (m + n) % k
theorem Int.add_emod (a : Int) (b : Int) (n : Int) :
(a + b) % n = (a % n + b % n) % n
theorem Int.add_emod_eq_add_emod_right {m : Int} {n : Int} {k : Int} (i : Int) (H : m % n = k % n) :
(m + i) % n = (k + i) % n
theorem Int.add_emod_eq_add_emod_left {m : Int} {n : Int} {k : Int} (i : Int) (H : m % n = k % n) :
(i + m) % n = (i + k) % n
theorem Int.emod_add_cancel_right {m : Int} {n : Int} {k : Int} (i : Int) :
(m + i) % n = (k + i) % n m % n = k % n
theorem Int.emod_add_cancel_left {m : Int} {n : Int} {k : Int} {i : Int} :
(i + m) % n = (i + k) % n m % n = k % n
theorem Int.emod_sub_cancel_right {m : Int} {n : Int} {k : Int} (i : Int) :
(m - i) % n = (k - i) % n m % n = k % n
theorem Int.emod_eq_emod_iff_emod_sub_eq_zero {m : Int} {n : Int} {k : Int} :
m % n = k % n (m - k) % n = 0
@[simp]
theorem Int.mul_mod_left (a : Int) (b : Int) :
Int.mod (a * b) b = 0
@[simp]
theorem Int.mul_fmod_left (a : Int) (b : Int) :
Int.fmod (a * b) b = 0
@[simp]
theorem Int.mul_emod_left (a : Int) (b : Int) :
a * b % b = 0
@[simp]
theorem Int.mul_mod_right (a : Int) (b : Int) :
Int.mod (a * b) a = 0
@[simp]
theorem Int.mul_fmod_right (a : Int) (b : Int) :
Int.fmod (a * b) a = 0
@[simp]
theorem Int.mul_emod_right (a : Int) (b : Int) :
a * b % a = 0
theorem Int.mul_emod (a : Int) (b : Int) (n : Int) :
a * b % n = a % n * (b % n) % n
@[simp]
theorem Int.mod_self {a : Int} :
Int.mod a a = 0
@[simp]
theorem Int.fmod_self {a : Int} :
Int.fmod a a = 0
theorem Int.emod_self {a : Int} :
a % a = 0
@[simp]
theorem Int.emod_emod_of_dvd (n : Int) {m : Int} {k : Int} (h : m k) :
n % k % m = n % m
@[simp]
theorem Int.emod_emod (a : Int) (b : Int) :
a % b % b = a % b
theorem Int.sub_emod (a : Int) (b : Int) (n : Int) :
(a - b) % n = (a % n - b % n) % n
theorem Int.ediv_emod_unique {a : Int} {b : Int} {r : Int} {q : Int} (h : 0 < b) :
a / b = q a % b = r r + b * q = a 0 r r < b

properties of / and % #

@[simp]
theorem Int.mul_ediv_mul_of_pos {a : Int} (b : Int) (c : Int) (H : 0 < a) :
a * b / (a * c) = b / c
@[simp]
theorem Int.mul_ediv_mul_of_pos_left (a : Int) {b : Int} (c : Int) (H : 0 < b) :
a * b / (c * b) = a / c
@[simp]
theorem Int.mul_emod_mul_of_pos {a : Int} (b : Int) (c : Int) (H : 0 < a) :
a * b % (a * c) = a * (b % c)
theorem Int.lt_div_add_one_mul_self (a : Int) {b : Int} (H : 0 < b) :
a < (Int.div a b + 1) * b
theorem Int.lt_ediv_add_one_mul_self (a : Int) {b : Int} (H : 0 < b) :
a < (a / b + 1) * b
theorem Int.lt_fdiv_add_one_mul_self (a : Int) {b : Int} (H : 0 < b) :
a < (Int.fdiv a b + 1) * b
@[simp]
theorem Int.ediv_le_self {a : Int} (b : Int) (Ha : 0 a) :
a / b a
theorem Int.mul_div_cancel_of_mod_eq_zero {a : Int} {b : Int} (H : Int.mod a b = 0) :
b * Int.div a b = a
theorem Int.div_mul_cancel_of_mod_eq_zero {a : Int} {b : Int} (H : Int.mod a b = 0) :
Int.div a b * b = a
theorem Int.mul_ediv_cancel_of_emod_eq_zero {a : Int} {b : Int} (H : a % b = 0) :
b * (a / b) = a
theorem Int.ediv_mul_cancel_of_emod_eq_zero {a : Int} {b : Int} (H : a % b = 0) :
a / b * b = a

dvd #

theorem Int.dvd_zero (n : Int) :
n 0
theorem Int.dvd_refl (n : Int) :
n n
theorem Int.one_dvd (n : Int) :
1 n
theorem Int.dvd_trans {a : Int} {b : Int} {c : Int} :
a bb ca c
@[simp]
theorem Int.zero_dvd {n : Int} :
0 n n = 0
theorem Int.neg_dvd {a : Int} {b : Int} :
-a b a b
theorem Int.dvd_neg {a : Int} {b : Int} :
a -b a b
theorem Int.dvd_mul_right (a : Int) (b : Int) :
a a * b
theorem Int.dvd_mul_left (a : Int) (b : Int) :
b a * b
theorem Int.dvd_add {a : Int} {b : Int} {c : Int} :
a ba ca b + c
theorem Int.dvd_sub {a : Int} {b : Int} {c : Int} :
a ba ca b - c
theorem Int.dvd_add_left {a : Int} {b : Int} {c : Int} (H : a c) :
a b + c a b
theorem Int.dvd_add_right {a : Int} {b : Int} {c : Int} (H : a b) :
a b + c a c
theorem Int.dvd_iff_dvd_of_dvd_sub {a : Int} {b : Int} {c : Int} (H : a b - c) :
a b a c
theorem Int.dvd_iff_dvd_of_dvd_add {a : Int} {b : Int} {c : Int} (H : a b + c) :
a b a c
theorem Int.ofNat_dvd {m : Nat} {n : Nat} :
m n m n
@[simp]
theorem Int.natAbs_dvd {a : Int} {b : Int} :
(Int.natAbs a) b a b
theorem Int.dvd_natAbs {a : Int} {b : Int} :
a (Int.natAbs b) a b
theorem Int.ofNat_dvd_left {n : Nat} {z : Int} :
n z n Int.natAbs z
theorem Int.ofNat_dvd_right {n : Nat} {z : Int} :
z n Int.natAbs z n
theorem Int.dvd_antisymm {a : Int} {b : Int} (H1 : 0 a) (H2 : 0 b) :
a bb aa = b
theorem Int.dvd_of_mod_eq_zero {a : Int} {b : Int} (H : Int.mod b a = 0) :
a b
theorem Int.dvd_of_emod_eq_zero {a : Int} {b : Int} (H : b % a = 0) :
a b
theorem Int.dvd_emod_sub_self {x : Int} {m : Nat} :
m x % m - x
theorem Int.mod_eq_zero_of_dvd {a : Int} {b : Int} :
a bInt.mod b a = 0
theorem Int.emod_eq_zero_of_dvd {a : Int} {b : Int} :
a bb % a = 0
theorem Int.dvd_iff_mod_eq_zero (a : Int) (b : Int) :
a b Int.mod b a = 0
theorem Int.dvd_iff_emod_eq_zero (a : Int) (b : Int) :
a b b % a = 0
theorem Int.emod_pos_of_not_dvd {a : Int} {b : Int} (h : ¬a b) :
a = 0 0 < b % a
instance Int.decidableDvd :
DecidableRel fun (x x_1 : Int) => x x_1
Equations
theorem Int.dvd_sub_of_emod_eq {a : Int} {b : Int} {c : Int} (h : a % b = c) :
b a - c

If a % b = c then b divides a - c.

theorem Int.div_mul_cancel {a : Int} {b : Int} (H : b a) :
Int.div a b * b = a
theorem Int.ediv_mul_cancel {a : Int} {b : Int} (H : b a) :
a / b * b = a
theorem Int.mul_div_cancel' {a : Int} {b : Int} (H : a b) :
a * Int.div b a = b
theorem Int.mul_ediv_cancel' {a : Int} {b : Int} (H : a b) :
a * (b / a) = b
theorem Int.mul_div_assoc (a : Int) {b : Int} {c : Int} :
c bInt.div (a * b) c = a * Int.div b c
theorem Int.mul_ediv_assoc (a : Int) {b : Int} {c : Int} :
c ba * b / c = a * (b / c)
theorem Int.mul_div_assoc' (b : Int) {a : Int} {c : Int} (h : c a) :
Int.div (a * b) c = Int.div a c * b
theorem Int.mul_ediv_assoc' (b : Int) {a : Int} {c : Int} (h : c a) :
a * b / c = a / c * b
theorem Int.div_dvd_div {a : Int} {b : Int} {c : Int} :
a bb cInt.div b a Int.div c a
theorem Int.eq_mul_of_div_eq_right {a : Int} {b : Int} {c : Int} (H1 : b a) (H2 : Int.div a b = c) :
a = b * c
theorem Int.eq_mul_of_ediv_eq_right {a : Int} {b : Int} {c : Int} (H1 : b a) (H2 : a / b = c) :
a = b * c
theorem Int.div_eq_of_eq_mul_right {a : Int} {b : Int} {c : Int} (H1 : b 0) (H2 : a = b * c) :
Int.div a b = c
theorem Int.ediv_eq_of_eq_mul_right {a : Int} {b : Int} {c : Int} (H1 : b 0) (H2 : a = b * c) :
a / b = c
theorem Int.eq_div_of_mul_eq_right {a : Int} {b : Int} {c : Int} (H1 : a 0) (H2 : a * b = c) :
b = Int.div c a
theorem Int.eq_ediv_of_mul_eq_right {a : Int} {b : Int} {c : Int} (H1 : a 0) (H2 : a * b = c) :
b = c / a
theorem Int.div_eq_iff_eq_mul_right {a : Int} {b : Int} {c : Int} (H : b 0) (H' : b a) :
Int.div a b = c a = b * c
theorem Int.ediv_eq_iff_eq_mul_right {a : Int} {b : Int} {c : Int} (H : b 0) (H' : b a) :
a / b = c a = b * c
theorem Int.div_eq_iff_eq_mul_left {a : Int} {b : Int} {c : Int} (H : b 0) (H' : b a) :
Int.div a b = c a = c * b
theorem Int.ediv_eq_iff_eq_mul_left {a : Int} {b : Int} {c : Int} (H : b 0) (H' : b a) :
a / b = c a = c * b
theorem Int.eq_mul_of_div_eq_left {a : Int} {b : Int} {c : Int} (H1 : b a) (H2 : Int.div a b = c) :
a = c * b
theorem Int.eq_mul_of_ediv_eq_left {a : Int} {b : Int} {c : Int} (H1 : b a) (H2 : a / b = c) :
a = c * b
theorem Int.div_eq_of_eq_mul_left {a : Int} {b : Int} {c : Int} (H1 : b 0) (H2 : a = c * b) :
Int.div a b = c
theorem Int.ediv_eq_of_eq_mul_left {a : Int} {b : Int} {c : Int} (H1 : b 0) (H2 : a = c * b) :
a / b = c
theorem Int.eq_zero_of_div_eq_zero {d : Int} {n : Int} (h : d n) (H : Int.div n d = 0) :
n = 0
theorem Int.eq_zero_of_ediv_eq_zero {d : Int} {n : Int} (h : d n) (H : n / d = 0) :
n = 0
theorem Int.div_eq_ediv_of_dvd {a : Int} {b : Int} (h : b a) :
Int.div a b = a / b
theorem Int.fdiv_eq_ediv_of_dvd {a : Int} {b : Int} :
b aInt.fdiv a b = a / b
theorem Int.neg_ediv_of_dvd {a : Int} {b : Int} :
b a-a / b = -(a / b)
theorem Int.sub_ediv_of_dvd (a : Int) {b : Int} {c : Int} (hcb : c b) :
(a - b) / c = a / c - b / c
theorem Int.sub_ediv_of_dvd_sub {a : Int} {b : Int} {c : Int} (hcab : c a - b) :
(a - b) / c = a / c - b / c
@[simp]
theorem Int.div_left_inj {a : Int} {b : Int} {d : Int} (hda : d a) (hdb : d b) :
Int.div a d = Int.div b d a = b
@[simp]
theorem Int.ediv_left_inj {a : Int} {b : Int} {d : Int} (hda : d a) (hdb : d b) :
a / d = b / d a = b
theorem Int.div_sign (a : Int) (b : Int) :
theorem Int.ediv_sign (a : Int) (b : Int) :
theorem Int.mul_sign (i : Int) :
i * Int.sign i = (Int.natAbs i)
theorem Int.le_of_dvd {a : Int} {b : Int} (bpos : 0 < b) (H : a b) :
a b
theorem Int.eq_one_of_dvd_one {a : Int} (H : 0 a) (H' : a 1) :
a = 1
theorem Int.eq_one_of_mul_eq_one_right {a : Int} {b : Int} (H : 0 a) (H' : a * b = 1) :
a = 1
theorem Int.eq_one_of_mul_eq_one_left {a : Int} {b : Int} (H : 0 b) (H' : a * b = 1) :
b = 1

bmod ("balanced" mod) #

We use balanced mod in the omega algorithm, to make ±1 coefficients appear in equations without them.

def Int.bmod (x : Int) (m : Nat) :

Balanced mod, taking values in the range [- m/2, (m - 1)/2].

Equations
  • Int.bmod x m = let r := x % m; if r < (m + 1) / 2 then r else r - m
Instances For
    @[simp]
    theorem Int.bmod_emod {x : Int} {m : Nat} :
    Int.bmod x m % m = x % m
    @[simp]
    theorem Int.emod_bmod {x : Int} {m : Nat} :
    Int.bmod (x % m) m = Int.bmod x m
    @[simp]
    theorem Int.bmod_bmod {x : Int} {m : Nat} :
    @[simp]
    theorem Int.bmod_zero {m : Nat} :
    Int.bmod 0 m = 0
    theorem Int.dvd_bmod_sub_self {x : Int} {m : Nat} :
    m Int.bmod x m - x
    theorem Int.le_bmod {x : Int} {m : Nat} (h : 0 < m) :
    -(m / 2) Int.bmod x m
    theorem Int.bmod_lt {x : Int} {m : Nat} (h : 0 < m) :
    Int.bmod x m < (m + 1) / 2
    theorem Int.bmod_le {x : Int} {m : Nat} (h : 0 < m) :
    Int.bmod x m (m - 1) / 2