mathlib documentation

algebra.​gcd_monoid

algebra.​gcd_monoid

Monoids with normalization functions, gcd, and lcm

This file defines extra structures on comm_cancel_monoid_with_zeros, including integral_domains.

Main Definitions

Implementation Notes

TODO

Tags

divisibility, gcd, lcm, normalize

@[class]
structure normalization_monoid (α : Type u_2) [nontrivial α] [comm_cancel_monoid_with_zero α] :
Type u_2

Normalization monoid: multiplying with norm_unit gives a normal form for associated elements.

Instances
def normalize {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [normalization_monoid α] :
α →* α

Chooses an element of each associate class, by multiplying by norm_unit

Equations
@[simp]

@[simp]

theorem normalize_eq_zero {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [normalization_monoid α] {x : α} :

theorem normalize_eq_normalize {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [normalization_monoid α] {a b : α} :
a bb anormalize a = normalize b

theorem dvd_antisymm_of_normalize_eq {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [normalization_monoid α] {a b : α} :
normalize a = anormalize b = ba bb aa = b

theorem dvd_normalize_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [normalization_monoid α] {a b : α} :

theorem normalize_dvd_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [normalization_monoid α] {a b : α} :

Maps an element of associates back to the normalized element of its associate class

Equations
@[simp]

theorem associates.​out_mul {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [normalization_monoid α] (a b : associates α) :
(a * b).out = a.out * b.out

@[class]
structure gcd_monoid (α : Type u_2) [comm_cancel_monoid_with_zero α] [nontrivial α] :
Type u_2

GCD monoid: a comm_cancel_monoid_with_zero with normalization and gcd (greatest common divisor) and lcm (least common multiple) operations. In this setting gcd and lcm form a bounded lattice on the associated elements where gcd is the infimum, lcm is the supremum, 1 is bottom, and 0 is top. The type class focuses on gcd and we derive the corresponding lcm facts from gcd.

Instances
@[simp]
theorem normalize_gcd {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :

@[simp]
theorem gcd_mul_lcm {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :

theorem dvd_gcd_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b c : α) :

theorem gcd_comm {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :

theorem gcd_assoc {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (m n k : α) :

theorem gcd_eq_normalize {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {a b c : α} :

@[simp]
theorem gcd_zero_left {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a : α) :

@[simp]
theorem gcd_zero_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a : α) :

@[simp]
theorem gcd_eq_zero_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :
gcd_monoid.gcd a b = 0 a = 0 b = 0

@[simp]
theorem gcd_one_left {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a : α) :

@[simp]
theorem gcd_one_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a : α) :

theorem gcd_dvd_gcd {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {a b c d : α} :
a bc dgcd_monoid.gcd a c gcd_monoid.gcd b d

@[simp]
theorem gcd_same {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a : α) :

@[simp]
theorem gcd_mul_left {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b c : α) :

@[simp]
theorem gcd_mul_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b c : α) :

theorem gcd_eq_left_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :
normalize a = a(gcd_monoid.gcd a b = a a b)

theorem gcd_eq_right_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :
normalize b = b(gcd_monoid.gcd a b = b b a)

theorem gcd_dvd_gcd_mul_left {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (m n k : α) :

theorem gcd_dvd_gcd_mul_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (m n k : α) :

theorem gcd_dvd_gcd_mul_left_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (m n k : α) :

theorem gcd_dvd_gcd_mul_right_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (m n k : α) :

theorem lcm_dvd_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {a b c : α} :

theorem dvd_lcm_left {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :

theorem dvd_lcm_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :

theorem lcm_dvd {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {a b c : α} :
a bc bgcd_monoid.lcm a c b

@[simp]
theorem lcm_eq_zero_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :
gcd_monoid.lcm a b = 0 a = 0 b = 0

@[simp]
theorem normalize_lcm {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :

theorem lcm_comm {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :

theorem lcm_assoc {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (m n k : α) :

theorem lcm_eq_normalize {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {a b c : α} :

theorem lcm_dvd_lcm {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {a b c d : α} :
a bc dgcd_monoid.lcm a c gcd_monoid.lcm b d

@[simp]
theorem lcm_units_coe_left {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (u : units α) (a : α) :

@[simp]
theorem lcm_units_coe_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a : α) (u : units α) :

@[simp]
theorem lcm_one_left {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a : α) :

@[simp]
theorem lcm_one_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a : α) :

@[simp]
theorem lcm_same {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a : α) :

@[simp]
theorem lcm_eq_one_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :
gcd_monoid.lcm a b = 1 a 1 b 1

@[simp]
theorem lcm_mul_left {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b c : α) :

@[simp]
theorem lcm_mul_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b c : α) :

theorem lcm_eq_left_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :
normalize a = a(gcd_monoid.lcm a b = a b a)

theorem lcm_eq_right_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :
normalize b = b(gcd_monoid.lcm a b = b a b)

theorem lcm_dvd_lcm_mul_left {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (m n k : α) :

theorem lcm_dvd_lcm_mul_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (m n k : α) :

theorem lcm_dvd_lcm_mul_left_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (m n k : α) :

theorem lcm_dvd_lcm_mul_right_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (m n k : α) :

@[instance]

Equations
theorem int.​normalize_of_nonneg {z : } :
0 znormalize z = z

theorem int.​normalize_of_neg {z : } :
z < 0normalize z = -z

def int.​lcm  :

ℤ specific version of least common multiple.

Equations
theorem int.​lcm_def (i j : ) :

theorem int.​gcd_dvd_left (i j : ) :
(i.gcd j) i

theorem int.​gcd_dvd_right (i j : ) :
(i.gcd j) j

theorem int.​dvd_gcd {i j k : } :
k ik jk (i.gcd j)

theorem int.​gcd_mul_lcm (i j : ) :
i.gcd j * i.lcm j = (i * j).nat_abs

@[instance]

Equations
theorem int.​coe_gcd (i j : ) :

theorem int.​coe_lcm (i j : ) :

theorem int.​nat_abs_gcd (i j : ) :

theorem int.​nat_abs_lcm (i j : ) :

theorem int.​gcd_comm (i j : ) :
i.gcd j = j.gcd i

theorem int.​gcd_assoc (i j k : ) :
(i.gcd j).gcd k = i.gcd (j.gcd k)

@[simp]
theorem int.​gcd_self (i : ) :
i.gcd i = i.nat_abs

@[simp]
theorem int.​gcd_zero_left (i : ) :
0.gcd i = i.nat_abs

@[simp]
theorem int.​gcd_zero_right (i : ) :
i.gcd 0 = i.nat_abs

@[simp]
theorem int.​gcd_one_left (i : ) :
1.gcd i = 1

@[simp]
theorem int.​gcd_one_right (i : ) :
i.gcd 1 = 1

theorem int.​gcd_mul_left (i j k : ) :
(i * j).gcd (i * k) = i.nat_abs * j.gcd k

theorem int.​gcd_mul_right (i j k : ) :
(i * j).gcd (k * j) = i.gcd k * j.nat_abs

theorem int.​gcd_pos_of_non_zero_left {i : } (j : ) :
i 00 < i.gcd j

theorem int.​gcd_pos_of_non_zero_right (i : ) {j : } :
j 00 < i.gcd j

theorem int.​gcd_eq_zero_iff {i j : } :
i.gcd j = 0 i = 0 j = 0

theorem int.​gcd_div {i j k : } :
k ik j(i / k).gcd (j / k) = i.gcd j / k.nat_abs

theorem int.​gcd_div_gcd_div_gcd {i j : } :
0 < i.gcd j(i / (i.gcd j)).gcd (j / (i.gcd j)) = 1

theorem int.​gcd_dvd_gcd_of_dvd_left {i k : } (j : ) :
i ki.gcd j k.gcd j

theorem int.​gcd_dvd_gcd_of_dvd_right {i k : } (j : ) :
i kj.gcd i j.gcd k

theorem int.​gcd_dvd_gcd_mul_left (i j k : ) :
i.gcd j (k * i).gcd j

theorem int.​gcd_dvd_gcd_mul_right (i j k : ) :
i.gcd j (i * k).gcd j

theorem int.​gcd_dvd_gcd_mul_left_right (i j k : ) :
i.gcd j i.gcd (k * j)

theorem int.​gcd_dvd_gcd_mul_right_right (i j k : ) :
i.gcd j i.gcd (j * k)

theorem int.​gcd_eq_left {i j : } :
i ji.gcd j = i.nat_abs

theorem int.​gcd_eq_right {i j : } :
j ii.gcd j = j.nat_abs

theorem int.​ne_zero_of_gcd {x y : } :
x.gcd y 0x 0 y 0

theorem int.​exists_gcd_one {m n : } :
0 < m.gcd n(∃ (m' n' : ), m'.gcd n' = 1 m = m' * (m.gcd n) n = n' * (m.gcd n))

theorem int.​exists_gcd_one' {m n : } :
0 < m.gcd n(∃ (g : ) (m' n' : ), 0 < g m'.gcd n' = 1 m = m' * g n = n' * g)

theorem int.​pow_dvd_pow_iff {m n : } {k : } :
0 < k(m ^ k n ^ k m n)

theorem int.​lcm_comm (i j : ) :
i.lcm j = j.lcm i

theorem int.​lcm_assoc (i j k : ) :
(i.lcm j).lcm k = i.lcm (j.lcm k)

@[simp]
theorem int.​lcm_zero_left (i : ) :
0.lcm i = 0

@[simp]
theorem int.​lcm_zero_right (i : ) :
i.lcm 0 = 0

@[simp]
theorem int.​lcm_one_left (i : ) :
1.lcm i = i.nat_abs

@[simp]
theorem int.​lcm_one_right (i : ) :
i.lcm 1 = i.nat_abs

@[simp]
theorem int.​lcm_self (i : ) :
i.lcm i = i.nat_abs

theorem int.​dvd_lcm_left (i j : ) :
i (i.lcm j)

theorem int.​dvd_lcm_right (i j : ) :
j (i.lcm j)

theorem int.​lcm_dvd {i j k : } :
i kj k(i.lcm j) k

Maps an associate class of integers consisting of -n, n to n : ℕ

Equations
theorem int.​prime.​dvd_mul {m n : } {p : } :
nat.prime pp m * np m.nat_abs p n.nat_abs

theorem int.​prime.​dvd_mul' {m n : } {p : } :
nat.prime pp m * np m p n

theorem prime_two_or_dvd_of_dvd_two_mul_pow_self_two {m : } {p : } :
nat.prime pp 2 * m ^ 2p = 2 p m.nat_abs

theorem units_eq_one {α : Type u_1} [comm_cancel_monoid_with_zero α] [unique (units α)] (u : units α) :
u = 1

@[simp]
theorem norm_unit_eq_one {α : Type u_1} [comm_cancel_monoid_with_zero α] [unique (units α)] [nontrivial α] (x : α) :

@[simp]
theorem normalize_eq {α : Type u_1} [comm_cancel_monoid_with_zero α] [unique (units α)] [nontrivial α] (x : α) :