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 ∣ b → b ∣ a → ⇑normalize a = ⇑normalize b

theorem dvd_antisymm_of_normalize_eq {α : Type u_1} [comm_cancel_monoid_with_zero α] [nontrivial α] [normalization_monoid α] {a b : α} :
⇑normalize a = a → ⇑normalize b = b → a ∣ b → 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 : α} :

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 ∣ b → c ∣ d → gcd_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 ∣ b → c ∣ b → gcd_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 ∣ b → c ∣ d → gcd_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 ≤ z → ⇑normalize z = z

theorem int.​normalize_of_neg {z : ℤ} :
z < 0 → ⇑normalize 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 ∣ i → 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 : ℤ) :

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 ≠ 0 → 0 < i.gcd j

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

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

theorem int.​gcd_eq_right {i j : ℤ} :
j ∣ i → i.gcd j = j.nat_abs

theorem int.​ne_zero_of_gcd {x y : ℤ} :
x.gcd y ≠ 0 → x ≠ 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 ∣ k → 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 : ℕ} :
nat.prime p → ↑p ∣ m * n → p ∣ m.nat_abs ∨ p ∣ n.nat_abs

theorem int.​prime.​dvd_mul' {m n : ℤ} {p : ℕ} :
nat.prime p → ↑p ∣ m * n → ↑p ∣ m ∨ ↑p ∣ n

theorem prime_two_or_dvd_of_dvd_two_mul_pow_self_two {m : ℤ} {p : ℕ} :
nat.prime p → ↑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 : α) :