mathlib documentation

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
@[simp]

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]
theorem normalize_apply {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [normalization_monoid α] {x : α} :

@[simp]

@[simp]

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

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

theorem normalize_eq_normalize {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [normalization_monoid α] {a b : α} (hab : a ∣ b) (hba : b ∣ a) :

theorem dvd_antisymm_of_normalize_eq {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [normalization_monoid α] {a b : α} (ha : ⇑normalize a = a) (hb : ⇑normalize b = b) (hab : a ∣ b) (hba : b ∣ a) :
a = 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 : α} :

def associates.out {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [normalization_monoid α] (a : associates α) :
α

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

@[simp]

@[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 : α) :
⇑normalize (gcd a b) = gcd a b

@[simp]
theorem gcd_mul_lcm {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :
(gcd a b) * lcm a b = ⇑normalize (a * b)

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

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

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

theorem gcd_eq_normalize {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {a b c : α} (habc : gcd a b ∣ c) (hcab : c ∣ gcd a b) :

@[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 a b = 0 ↔ a = 0 ∧ b = 0

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

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

theorem gcd_dvd_gcd {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {a b c d : α} (hab : a ∣ b) (hcd : c ∣ d) :
gcd a c ∣ 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 : α) :
gcd (a * b) (a * c) = (⇑normalize a) * gcd b c

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

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

theorem gcd_eq_right_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) (h : ⇑normalize b = b) :
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 : α) :
gcd m n ∣ gcd (k * m) n

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

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

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

theorem gcd_eq_of_associated_left {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {m n : α} (h : associated m n) (k : α) :
gcd m k = gcd n k

theorem gcd_eq_of_associated_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {m n : α} (h : associated m n) (k : α) :
gcd k m = gcd k n

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

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

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

theorem lcm_dvd {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {a b c : α} (hab : a ∣ b) (hcb : c ∣ b) :
lcm a c ∣ b

@[simp]
theorem lcm_eq_zero_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) :
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 : α) :
⇑normalize (lcm a b) = lcm a b

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

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

theorem lcm_eq_normalize {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {a b c : α} (habc : lcm a b ∣ c) (hcab : c ∣ lcm a b) :

theorem lcm_dvd_lcm {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {a b c d : α} (hab : a ∣ b) (hcd : c ∣ d) :
lcm a c ∣ 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 : α) :
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 : α) :
lcm (a * b) (a * c) = (⇑normalize a) * lcm b c

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

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

theorem lcm_eq_right_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (a b : α) (h : ⇑normalize b = b) :
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 : α) :
lcm m n ∣ lcm (k * m) n

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

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

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

theorem lcm_eq_of_associated_left {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {m n : α} (h : associated m n) (k : α) :
lcm m k = lcm n k

theorem lcm_eq_of_associated_right {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {m n : α} (h : associated m n) (k : α) :
lcm k m = lcm k n

theorem gcd_monoid.prime_of_irreducible {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {x : α} (hi : irreducible x) :

@[instance]

Equations
theorem int.normalize_of_nonneg {z : ℤ} (h : 0 ≤ z) :

theorem int.normalize_of_neg {z : ℤ} (h : z < 0) :

def int.lcm (i j : ℤ) :

ℤ 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 : ℤ} (h1 : k ∣ i) (h2 : k ∣ j) :
k ∣ ↑(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 : ℤ) :
↑(i.gcd j) = gcd i j

theorem int.coe_lcm (i j : ℤ) :
↑(i.lcm j) = lcm i j

theorem int.nat_abs_gcd (i j : ℤ) :
(gcd i j).nat_abs = i.gcd j

theorem int.nat_abs_lcm (i j : ℤ) :
(lcm i j).nat_abs = i.lcm 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_non_zero : i ≠ 0) :
0 < i.gcd j

theorem int.gcd_pos_of_non_zero_right (i : ℤ) {j : ℤ} (j_non_zero : j ≠ 0) :
0 < 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 : ℤ} (H1 : k ∣ i) (H2 : k ∣ j) :
(i / k).gcd (j / k) = i.gcd j / k.nat_abs

theorem int.gcd_div_gcd_div_gcd {i j : ℤ} (H : 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 : ℤ) (H : i ∣ k) :
i.gcd j ∣ k.gcd j

theorem int.gcd_dvd_gcd_of_dvd_right {i k : ℤ} (j : ℤ) (H : i ∣ k) :
j.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 : ℤ} (H : i ∣ j) :
i.gcd j = i.nat_abs

theorem int.gcd_eq_right {i j : ℤ} (H : j ∣ i) :
i.gcd j = j.nat_abs

theorem int.ne_zero_of_gcd {x y : ℤ} (hc : x.gcd y ≠ 0) :
x ≠ 0 ∨ y ≠ 0

theorem int.exists_gcd_one {m n : ℤ} (H : 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 : ℤ} (H : 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 : ℕ} (k0 : 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 : ℤ} (a : i ∣ k) (a_1 : j ∣ 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 : ℕ} (hp : nat.prime p) (h : ↑p ∣ m * n) :

theorem int.prime.dvd_mul' {m n : ℤ} {p : ℕ} (hp : nat.prime p) (h : ↑p ∣ m * n) :
↑p ∣ m ∨ ↑p ∣ n

theorem prime_two_or_dvd_of_dvd_two_mul_pow_self_two {m : ℤ} {p : ℕ} (hp : nat.prime p) (h : ↑p ∣ 2 * m ^ 2) :
p = 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 : α) :