mathlibdocumentation

algebra.euclidean_domain

Euclidean domains #

This file introduces Euclidean domains and provides the extended Euclidean algorithm. To be precise, a slightly more general version is provided which is sometimes called a transfinite Euclidean domain and differs in the fact that the degree function need not take values in ℕ but can take values in any well-ordered set. Transfinite Euclidean domains were introduced by Motzkin and examples which don't satisfy the classical notion were provided independently by Hiblot and Nagata.

Main definitions #

• euclidean_domain: Defines Euclidean domain with functions quotient and remainder. Instances of has_div and has_mod are provided, so that one can write a = b * (a / b) + a % b.
• gcd: defines the greatest common divisors of two elements of a Euclidean domain.
• xgcd: given two elements a b : R, xgcd a b defines the pair (x, y) such that x * a + y * b = gcd a b.
• lcm: defines the lowest common multiple of two elements a and b of a Euclidean domain as a * b / (gcd a b)

Main statements #

• gcd_eq_gcd_ab: states Bézout's lemma for Euclidean domains.
• int.euclidean_domain: shows that ℤ is a Euclidean domain.
• field.to_euclidean_domain: shows that any field is a Euclidean domain.

Notation #

≺ denotes the well founded relation on the Euclidean domain, e.g. in the example of the polynomial ring over a field, p ≺ q for polynomials p and q if and only if the degree of p is less than the degree of q.

Implementation details #

Instead of working with a valuation, euclidean_domain is implemented with the existence of a well founded relation r on the integral domain R, which in the example of ℤ would correspond to setting i ≺ j for integers i and j if the absolute value of i is smaller than the absolute value of j.

Tags #

Euclidean domain, transfinite Euclidean domain, Bézout's lemma

@[class]
structure euclidean_domain (R : Type u) :
Type u
• to_comm_ring :
• to_nontrivial :
• quotient : R → R → R
• quotient_zero : ∀ (a : R),
• remainder : R → R → R
• quotient_mul_add_remainder_eq : ∀ (a b : R), = a
• r : R → R → Prop
• r_well_founded :
• remainder_lt : ∀ (a : R) {b : R}, b 0
• mul_left_not_lt : ∀ (a : R) {b : R}, b 0¬euclidean_domain.r (a * b) a

A euclidean_domain is an non-trivial commutative ring with a division and a remainder, satisfying b * (a / b) + a % b = a. The definition of a euclidean domain usually includes a valuation function R → ℕ. This definition is slightly generalised to include a well founded relation r with the property that r (a % b) b, instead of a valuation.

Instances of this typeclass
Instances of other typeclasses for euclidean_domain
• euclidean_domain.has_sizeof_inst
@[protected, instance]
def euclidean_domain.has_div {R : Type u}  :
Equations
@[protected, instance]
def euclidean_domain.has_mod {R : Type u}  :
Equations
theorem euclidean_domain.div_add_mod {R : Type u} (a b : R) :
b * (a / b) + a % b = a
theorem euclidean_domain.mod_add_div {R : Type u} (a b : R) :
a % b + b * (a / b) = a
theorem euclidean_domain.mod_add_div' {R : Type u} (m k : R) :
m % k + m / k * k = m
theorem euclidean_domain.div_add_mod' {R : Type u} (m k : R) :
m / k * k + m % k = m
theorem euclidean_domain.mod_eq_sub_mul_div {R : Type u_1} (a b : R) :
a % b = a - b * (a / b)
theorem euclidean_domain.mod_lt {R : Type u} (a : R) {b : R} :
b 0euclidean_domain.r (a % b) b
theorem euclidean_domain.mul_right_not_lt {R : Type u} {a : R} (b : R) (h : a 0) :
theorem euclidean_domain.mul_div_cancel_left {R : Type u} {a : R} (b : R) (a0 : a 0) :
a * b / a = b
theorem euclidean_domain.mul_div_cancel {R : Type u} (a : R) {b : R} (b0 : b 0) :
a * b / b = a
@[simp]
theorem euclidean_domain.mod_zero {R : Type u} (a : R) :
a % 0 = a
@[simp]
theorem euclidean_domain.mod_eq_zero {R : Type u} {a b : R} :
a % b = 0 b a
@[simp]
theorem euclidean_domain.mod_self {R : Type u} (a : R) :
a % a = 0
theorem euclidean_domain.dvd_mod_iff {R : Type u} {a b c : R} (h : c b) :
c a % b c a
theorem euclidean_domain.lt_one {R : Type u} (a : R) :
a = 0
theorem euclidean_domain.val_dvd_le {R : Type u} (a b : R) :
b aa 0
@[simp]
theorem euclidean_domain.mod_one {R : Type u} (a : R) :
a % 1 = 0
@[simp]
theorem euclidean_domain.zero_mod {R : Type u} (b : R) :
0 % b = 0
@[simp]
theorem euclidean_domain.div_zero {R : Type u} (a : R) :
a / 0 = 0
@[simp]
theorem euclidean_domain.zero_div {R : Type u} {a : R} :
0 / a = 0
@[simp]
theorem euclidean_domain.div_self {R : Type u} {a : R} (a0 : a 0) :
a / a = 1
theorem euclidean_domain.eq_div_of_mul_eq_left {R : Type u} {a b c : R} (hb : b 0) (h : a * b = c) :
a = c / b
theorem euclidean_domain.eq_div_of_mul_eq_right {R : Type u} {a b c : R} (ha : a 0) (h : a * b = c) :
b = c / a
theorem euclidean_domain.mul_div_assoc {R : Type u} (x : R) {y z : R} (h : z y) :
x * y / z = x * (y / z)
@[simp]
theorem euclidean_domain.div_one {R : Type u} (p : R) :
p / 1 = p
theorem euclidean_domain.div_dvd_of_dvd {R : Type u} {p q : R} (hpq : q p) :
p / q p
theorem euclidean_domain.dvd_div_of_mul_dvd {R : Type u} {a b c : R} (h : a * b c) :
b c / a
theorem euclidean_domain.gcd.induction {R : Type u} {P : R → R → Prop} (a b : R) :
(∀ (x : R), P 0 x)(∀ (a b : R), a 0P (b % a) aP a b)P a b
def euclidean_domain.gcd {R : Type u} [decidable_eq R] :
R → R → R

gcd a b is a (non-unique) element such that gcd a b ∣ a gcd a b ∣ b, and for any element c such that c ∣ a and c ∣ b, then c ∣ gcd a b

Equations
@[simp]
theorem euclidean_domain.gcd_zero_left {R : Type u} [decidable_eq R] (a : R) :
@[simp]
theorem euclidean_domain.gcd_zero_right {R : Type u} [decidable_eq R] (a : R) :
theorem euclidean_domain.gcd_val {R : Type u} [decidable_eq R] (a b : R) :
theorem euclidean_domain.gcd_dvd {R : Type u} [decidable_eq R] (a b : R) :
theorem euclidean_domain.gcd_dvd_left {R : Type u} [decidable_eq R] (a b : R) :
theorem euclidean_domain.gcd_dvd_right {R : Type u} [decidable_eq R] (a b : R) :
@[protected]
theorem euclidean_domain.gcd_eq_zero_iff {R : Type u} [decidable_eq R] {a b : R} :
a = 0 b = 0
theorem euclidean_domain.dvd_gcd {R : Type u} [decidable_eq R] {a b c : R} :
c ac b
theorem euclidean_domain.gcd_eq_left {R : Type u} [decidable_eq R] {a b : R} :
a b
@[simp]
theorem euclidean_domain.gcd_one_left {R : Type u} [decidable_eq R] (a : R) :
@[simp]
theorem euclidean_domain.gcd_self {R : Type u} [decidable_eq R] (a : R) :
def euclidean_domain.xgcd_aux {R : Type u} [decidable_eq R] :
R → R → R → R → R → R → R × R × R

An implementation of the extended GCD algorithm. At each step we are computing a triple (r, s, t), where r is the next value of the GCD algorithm, to compute the greatest common divisor of the input (say x and y), and s and t are the coefficients in front of x and y to obtain r (i.e. r = s * x + t * y). The function xgcd_aux takes in two triples, and from these recursively computes the next triple:

xgcd_aux (r, s, t) (r', s', t') = xgcd_aux (r' % r, s' - (r' / r) * s, t' - (r' / r) * t) (r, s, t)

Equations
@[simp]
theorem euclidean_domain.xgcd_zero_left {R : Type u} [decidable_eq R] {s t r' s' t' : R} :
r' s' t' = (r', s', t')
theorem euclidean_domain.xgcd_aux_rec {R : Type u} [decidable_eq R] {r s t r' s' t' : R} (h : r 0) :
r' s' t' = euclidean_domain.xgcd_aux (r' % r) (s' - r' / r * s) (t' - r' / r * t) r s t
def euclidean_domain.xgcd {R : Type u} [decidable_eq R] (x y : R) :
R × R

Use the extended GCD algorithm to generate the a and b values satisfying gcd x y = x * a + y * b.

Equations
def euclidean_domain.gcd_a {R : Type u} [decidable_eq R] (x y : R) :
R

The extended GCD a value in the equation gcd x y = x * a + y * b.

Equations
def euclidean_domain.gcd_b {R : Type u} [decidable_eq R] (x y : R) :
R

The extended GCD b value in the equation gcd x y = x * a + y * b.

Equations
@[simp]
theorem euclidean_domain.gcd_a_zero_left {R : Type u} [decidable_eq R] {s : R} :
@[simp]
theorem euclidean_domain.gcd_b_zero_left {R : Type u} [decidable_eq R] {s : R} :
@[simp]
theorem euclidean_domain.xgcd_aux_fst {R : Type u} [decidable_eq R] (x y s t s' t' : R) :
y s' t').fst =
theorem euclidean_domain.xgcd_aux_val {R : Type u} [decidable_eq R] (x y : R) :
y 0 1 = ,
theorem euclidean_domain.xgcd_val {R : Type u} [decidable_eq R] (x y : R) :
theorem euclidean_domain.xgcd_aux_P {R : Type u} [decidable_eq R] (a b : R) {r r' s t s' t' : R} :
P a b (r, s, t)P a b (r', s', t')P a b r' s' t')
theorem euclidean_domain.gcd_eq_gcd_ab {R : Type u} [decidable_eq R] (a b : R) :
= +

An explicit version of Bézout's lemma for Euclidean domains.

@[protected, instance]
def euclidean_domain.is_domain (R : Type u_1) [e : euclidean_domain R] :
def euclidean_domain.lcm {R : Type u} [decidable_eq R] (x y : R) :
R

lcm a b is a (non-unique) element such that a ∣ lcm a b b ∣ lcm a b, and for any element c such that a ∣ c and b ∣ c, then lcm a b ∣ c

Equations
theorem euclidean_domain.dvd_lcm_left {R : Type u} [decidable_eq R] (x y : R) :
theorem euclidean_domain.dvd_lcm_right {R : Type u} [decidable_eq R] (x y : R) :
theorem euclidean_domain.lcm_dvd {R : Type u} [decidable_eq R] {x y z : R} (hxz : x z) (hyz : y z) :
@[simp]
theorem euclidean_domain.lcm_dvd_iff {R : Type u} [decidable_eq R] {x y z : R} :
x z y z
@[simp]
theorem euclidean_domain.lcm_zero_left {R : Type u} [decidable_eq R] (x : R) :
@[simp]
theorem euclidean_domain.lcm_zero_right {R : Type u} [decidable_eq R] (x : R) :
@[simp]
theorem euclidean_domain.lcm_eq_zero_iff {R : Type u} [decidable_eq R] {x y : R} :
x = 0 y = 0
@[simp]
theorem euclidean_domain.gcd_mul_lcm {R : Type u} [decidable_eq R] (x y : R) :
= x * y
theorem euclidean_domain.mul_div_mul_cancel {R : Type u} {a b c : R} (ha : a 0) (hcb : c b) :
a * b / (a * c) = b / c
theorem euclidean_domain.mul_div_mul_comm_of_dvd_dvd {R : Type u} {a b c d : R} (hac : c a) (hbd : d b) :
a * b / (c * d) = a / c * (b / d)
@[protected, instance]
Equations
@[protected, instance]
def field.to_euclidean_domain {K : Type u} [field K] :
Equations