The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V09. Commutative algebra I: ideals, polynomials, factorization

Mathlib.Algebra.EuclideanDomain.Defs

38 declarations. Mathlib docs · Source

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

  • EuclideanDomain: Defines Euclidean domain with functions quotient and remainder. Instances of Div and 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

See Algebra.EuclideanDomain.Basic for most of the theorems about Euclidean domains, including Bézout's lemma.

See Algebra.EuclideanDomain.Instances for the fact that ℤ is a Euclidean domain, as is any field.

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 notes

Instead of working with a valuation, EuclideanDomain 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.

References

  • [Th. Motzkin, The Euclidean algorithm][MR32592]
  • [J.-J. Hiblot, Des anneaux euclidiens dont le plus petit algorithme n'est pas à valeurs finies][MR399081]
  • [M. Nagata, On Euclid algorithm][MR541021]

Tags

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

def EuclideanDomain.ctorIdx E1 #

{R : Type u} → EuclideanDomain R → ℕ

class EuclideanDomain E3 #

Type u → Type u

A EuclideanDomain is a 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.

ctor EuclideanDomain.mk E0 #

{R : Type u} →
  [toCommRing : CommRing R] →
    [toNontrivial : Nontrivial R] →
      (quotient : R → R → R) →
        (∀ (a : R), quotient a 0 = 0) →
          (remainder : R → R → R) →
            (∀ (a b : R), b * quotient a b + remainder a b = a) →
              (r : R → R → Prop) →
                [r_wellFounded : WellFounded r] →
                  (∀ (a : R) {b : R}, b ≠ 0 → r (remainder a b) b) →
                    (∀ (a : R) {b : R}, b ≠ 0 → ¬r (a * b) a) → EuclideanDomain R

instance EuclideanDomain.toNontrivial E0 #

∀ {R : Type u} [self : EuclideanDomain R], Nontrivial R

instance EuclideanDomain.toCommRing E0 #

{R : Type u} → [self : EuclideanDomain R] → CommRing R

abbrev EuclideanDomain.quotient E3 #

{R : Type u} → [self : EuclideanDomain R] → R → R → R

A division function (denoted /) on R. This satisfies the property b * (a / b) + a % b = a, where % denotes remainder.

theorem EuclideanDomain.quotient_zero E1 #

∀ {R : Type u} [self : EuclideanDomain R] (a : R), EuclideanDomain.quotient a 0 = 0

Division by zero should always give zero by convention.

abbrev EuclideanDomain.remainder E3 #

{R : Type u} → [self : EuclideanDomain R] → R → R → R

A remainder function (denoted %) on R. This satisfies the property b * (a / b) + a % b = a, where / denotes quotient.

theorem EuclideanDomain.quotient_mul_add_remainder_eq E0 #

∀ {R : Type u} [self : EuclideanDomain R] (a b : R),
  b * EuclideanDomain.quotient a b + EuclideanDomain.remainder a b = a

The property that links the quotient and remainder functions. This allows us to compute GCDs and LCMs.

abbrev EuclideanDomain.r E1 #

{R : Type u} → [self : EuclideanDomain R] → R → R → Prop

A well-founded relation on R, satisfying r (a % b) b. This ensures that the GCD algorithm always terminates.

theorem EuclideanDomain.r_wellFounded E1 #

∀ {R : Type u} [self : EuclideanDomain R], WellFounded EuclideanDomain.r

The relation r must be well-founded. This ensures that the GCD algorithm always terminates.

theorem EuclideanDomain.remainder_lt E1 #

∀ {R : Type u} [self : EuclideanDomain R] (a : R) {b : R}, b ≠ 0 → EuclideanDomain.r (EuclideanDomain.remainder a b) b

The relation r satisfies r (a % b) b.

theorem EuclideanDomain.mul_left_not_lt E1 #

∀ {R : Type u} [self : EuclideanDomain R] (a : R) {b : R}, b ≠ 0 → ¬EuclideanDomain.r (a * b) a

An additional constraint on r.

def EuclideanDomain.wellFoundedRelation E1 #

{R : Type u} → [EuclideanDomain R] → WellFoundedRelation R

instance EuclideanDomain.instDiv E0 #

{R : Type u} → [EuclideanDomain R] → Div R

instance EuclideanDomain.instMod E0 #

{R : Type u} → [EuclideanDomain R] → Mod R

theorem EuclideanDomain.div_add_mod E1 #

∀ {R : Type u} [inst : EuclideanDomain R] (a b : R), b * (a / b) + a % b = a

theorem EuclideanDomain.mod_add_div E1 #

∀ {R : Type u} [inst : EuclideanDomain R] (a b : R), a % b + b * (a / b) = a

theorem EuclideanDomain.mod_add_div' E1 #

∀ {R : Type u} [inst : EuclideanDomain R] (m k : R), m % k + m / k * k = m

theorem EuclideanDomain.div_add_mod' E1 #

∀ {R : Type u} [inst : EuclideanDomain R] (m k : R), m / k * k + m % k = m

theorem EuclideanDomain.mod_lt E1 #

∀ {R : Type u} [inst : EuclideanDomain R] (a : R) {b : R}, b ≠ 0 → EuclideanDomain.r (a % b) b

theorem EuclideanDomain.mul_right_not_lt E1 #

∀ {R : Type u} [inst : EuclideanDomain R] {a : R} (b : R), a ≠ 0 → ¬EuclideanDomain.r (a * b) b

theorem EuclideanDomain.mod_zero E0 #

∀ {R : Type u} [inst : EuclideanDomain R] (a : R), a % 0 = a

theorem EuclideanDomain.lt_one E1 #

∀ {R : Type u} [inst : EuclideanDomain R] (a : R), EuclideanDomain.r a 1 → a = 0

theorem EuclideanDomain.div_zero E0 #

∀ {R : Type u} [inst : EuclideanDomain R] (a : R), a / 0 = 0

theorem EuclideanDomain.GCD.induction E1 #

∀ {R : Type u} [inst : EuclideanDomain R] {P : R → R → Prop} (a b : R),
  (∀ (x : R), P 0 x) → (∀ (a b : R), a ≠ 0 → P (b % a) a → P a b) → P a b

def EuclideanDomain.gcd E3 #

{R : Type u} → [EuclideanDomain R] → [DecidableEq 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

theorem EuclideanDomain.gcd_zero_left E0 #

∀ {R : Type u} [inst : EuclideanDomain R] [inst_1 : DecidableEq R] (a : R), EuclideanDomain.gcd 0 a = a

def EuclideanDomain.xgcdAux E0 #

{R : Type u} → [EuclideanDomain R] → [DecidableEq 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 xgcdAux takes in two triples, and from these recursively computes the next triple:

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

theorem EuclideanDomain.xgcd_zero_left E0 #

∀ {R : Type u} [inst : EuclideanDomain R] [inst_1 : DecidableEq R] {s t r' s' t' : R},
  EuclideanDomain.xgcdAux 0 s t r' s' t' = (r', s', t')

theorem EuclideanDomain.xgcdAux_rec E1 #

∀ {R : Type u} [inst : EuclideanDomain R] [inst_1 : DecidableEq R] {r s t r' s' t' : R},
  r ≠ 0 →
    EuclideanDomain.xgcdAux r s t r' s' t' = EuclideanDomain.xgcdAux (r' % r) (s' - r' / r * s) (t' - r' / r * t) r s t

def EuclideanDomain.xgcd E3 #

{R : Type u} → [EuclideanDomain R] → [DecidableEq R] → R → R → R × R

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

def EuclideanDomain.gcdA E1 #

{R : Type u} → [EuclideanDomain R] → [DecidableEq R] → R → R → R

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

def EuclideanDomain.gcdB E1 #

{R : Type u} → [EuclideanDomain R] → [DecidableEq R] → R → R → R

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

theorem EuclideanDomain.gcdA_zero_left E0 #

∀ {R : Type u} [inst : EuclideanDomain R] [inst_1 : DecidableEq R] {s : R}, EuclideanDomain.gcdA 0 s = 0

theorem EuclideanDomain.gcdB_zero_left E0 #

∀ {R : Type u} [inst : EuclideanDomain R] [inst_1 : DecidableEq R] {s : R}, EuclideanDomain.gcdB 0 s = 1

theorem EuclideanDomain.xgcd_val E0 #

∀ {R : Type u} [inst : EuclideanDomain R] [inst_1 : DecidableEq R] (x y : R),
  EuclideanDomain.xgcd x y = (EuclideanDomain.gcdA x y, EuclideanDomain.gcdB x y)

def EuclideanDomain.lcm E1 #

{R : Type u} → [EuclideanDomain R] → [DecidableEq R] → R → 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