Monoids with normalization functions, gcd
, and lcm
#
This file defines extra structures on cancel_comm_monoid_with_zero
s, including is_domain
s.
Main Definitions #
normalization_monoid
gcd_monoid
normalized_gcd_monoid
gcd_monoid_of_gcd
,gcd_monoid_of_exists_gcd
,normalized_gcd_monoid_of_gcd
,normalized_gcd_monoid_of_exists_gcd
gcd_monoid_of_lcm
,gcd_monoid_of_exists_lcm
,normalized_gcd_monoid_of_lcm
,normalized_gcd_monoid_of_exists_lcm
For the normalized_gcd_monoid
instances on ℕ
and ℤ
, see ring_theory.int.basic
.
Implementation Notes #
-
normalization_monoid
is defined by assigning to each element anorm_unit
such that multiplying by that unit normalizes the monoid, andnormalize
is an idempotent monoid homomorphism. This definition as currently implemented does casework on0
. -
gcd_monoid
contains the definitions ofgcd
andlcm
with the usual properties. They are both determined up to a unit. -
normalized_gcd_monoid
extendsnormalization_monoid
, so thegcd
andlcm
are always normalized. This makesgcd
s of polynomials easier to work with, but excludes Euclidean domains, and monoids without zero. -
gcd_monoid_of_gcd
andnormalized_gcd_monoid_of_gcd
noncomputably construct agcd_monoid
(resp.normalized_gcd_monoid
) structure just from thegcd
and its properties. -
gcd_monoid_of_exists_gcd
andnormalized_gcd_monoid_of_exists_gcd
noncomputably construct agcd_monoid
(resp.normalized_gcd_monoid
) structure just from a proof that any two elements have a (not necessarily normalized)gcd
. -
gcd_monoid_of_lcm
andnormalized_gcd_monoid_of_lcm
noncomputably construct agcd_monoid
(resp.normalized_gcd_monoid
) structure just from thelcm
and its properties. -
gcd_monoid_of_exists_lcm
andnormalized_gcd_monoid_of_exists_lcm
noncomputably construct agcd_monoid
(resp.normalized_gcd_monoid
) structure just from a proof that any two elements have a (not necessarily normalized)lcm
.
TODO #
- Port GCD facts about nats, definition of coprime
- Generalize normalization monoids to commutative (cancellative) monoids with or without zero
Tags #
divisibility, gcd, lcm, normalize
- norm_unit : α → units α
- norm_unit_zero : norm_unit 0 = 1
- norm_unit_mul : ∀ {a b : α}, a ≠ 0 → b ≠ 0 → norm_unit (a * b) = (norm_unit a) * norm_unit b
- norm_unit_coe_units : ∀ (u : units α), norm_unit ↑u = u⁻¹
Normalization monoid: multiplying with norm_unit
gives a normal form for associated
elements.
Chooses an element of each associate class, by multiplying by norm_unit
Maps an element of associates
back to the normalized element of its associate class
Equations
- associates.out = quotient.lift ⇑normalize associates.out._proof_1
- gcd : α → α → α
- lcm : α → α → α
- gcd_dvd_left : ∀ (a b : α), gcd a b ∣ a
- gcd_dvd_right : ∀ (a b : α), gcd a b ∣ b
- dvd_gcd : ∀ {a b c : α}, a ∣ c → a ∣ b → a ∣ gcd c b
- gcd_mul_lcm : ∀ (a b : α), associated ((gcd a b) * lcm a b) (a * b)
- lcm_zero_left : ∀ (a : α), lcm 0 a = 0
- lcm_zero_right : ∀ (a : α), lcm a 0 = 0
GCD monoid: a cancel_comm_monoid_with_zero
with gcd
(greatest common divisor) and
lcm
(least common multiple) operations, determined up to a unit. The type class focuses on gcd
and we derive the corresponding lcm
facts from gcd
.
Instances
- to_normalization_monoid : normalization_monoid α
- to_gcd_monoid : gcd_monoid α
- normalize_gcd : ∀ (a b : α), ⇑normalize (gcd a b) = gcd a b
- normalize_lcm : ∀ (a b : α), ⇑normalize (lcm a b) = lcm a b
Normalized GCD monoid: a cancel_comm_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
.
Represent a divisor of m * n
as a product of a divisor of m
and a divisor of n
.
Note: In general, this representation is highly non-unique.
Equations
- normalization_monoid_of_unique_units = {norm_unit := λ (x : α), 1, norm_unit_zero := _, norm_unit_mul := _, norm_unit_coe_units := _}
If a monoid's only unit is 1
, then it is isomorphic to its associates.
Equations
Define normalization_monoid
on a structure from a monoid_hom
inverse to associates.mk
.
Equations
- normalization_monoid_of_monoid_hom_right_inverse f hinv = {norm_unit := λ (a : α), ite (a = 0) 1 (classical.some _), norm_unit_zero := _, norm_unit_mul := _, norm_unit_coe_units := _}
Define gcd_monoid
on a structure just from the gcd
and its properties.
Equations
- gcd_monoid_of_gcd gcd gcd_dvd_left gcd_dvd_right dvd_gcd = {gcd := gcd, lcm := λ (a b : α), ite (a = 0) 0 (classical.some _), gcd_dvd_left := gcd_dvd_left, gcd_dvd_right := gcd_dvd_right, dvd_gcd := _, gcd_mul_lcm := _, lcm_zero_left := _, lcm_zero_right := _}
Define normalized_gcd_monoid
on a structure just from the gcd
and its properties.
Equations
- normalized_gcd_monoid_of_gcd gcd gcd_dvd_left gcd_dvd_right dvd_gcd normalize_gcd = {to_normalization_monoid := {norm_unit := norm_unit infer_instance, norm_unit_zero := _, norm_unit_mul := _, norm_unit_coe_units := _}, to_gcd_monoid := {gcd := gcd, lcm := λ (a b : α), ite (a = 0) 0 (classical.some _), gcd_dvd_left := gcd_dvd_left, gcd_dvd_right := gcd_dvd_right, dvd_gcd := _, gcd_mul_lcm := _, lcm_zero_left := _, lcm_zero_right := _}, normalize_gcd := normalize_gcd, normalize_lcm := _}
Define gcd_monoid
on a structure just from the lcm
and its properties.
Equations
- gcd_monoid_of_lcm lcm dvd_lcm_left dvd_lcm_right lcm_dvd = let exists_gcd : ∀ (a b : α), lcm a b ∣ a * b := _ in {gcd := λ (a b : α), ite (a = 0) b (ite (b = 0) a (classical.some _)), lcm := lcm, gcd_dvd_left := _, gcd_dvd_right := _, dvd_gcd := _, gcd_mul_lcm := _, lcm_zero_left := _, lcm_zero_right := _}
Define normalized_gcd_monoid
on a structure just from the lcm
and its properties.
Equations
- normalized_gcd_monoid_of_lcm lcm dvd_lcm_left dvd_lcm_right lcm_dvd normalize_lcm = let exists_gcd : ∀ (a b : α), lcm a b ∣ ⇑normalize (a * b) := _ in {to_normalization_monoid := {norm_unit := norm_unit infer_instance, norm_unit_zero := _, norm_unit_mul := _, norm_unit_coe_units := _}, to_gcd_monoid := {gcd := λ (a b : α), ite (a = 0) (⇑normalize b) (ite (b = 0) (⇑normalize a) (classical.some _)), lcm := lcm, gcd_dvd_left := _, gcd_dvd_right := _, dvd_gcd := _, gcd_mul_lcm := _, lcm_zero_left := _, lcm_zero_right := _}, normalize_gcd := _, normalize_lcm := normalize_lcm}
Define a gcd_monoid
structure on a monoid just from the existence of a gcd
.
Equations
- gcd_monoid_of_exists_gcd h = gcd_monoid_of_gcd (λ (a b : α), classical.some _) _ _ _
Define a normalized_gcd_monoid
structure on a monoid just from the existence of a gcd
.
Equations
- normalized_gcd_monoid_of_exists_gcd h = normalized_gcd_monoid_of_gcd (λ (a b : α), ⇑normalize (classical.some _)) _ _ _ _
Define a gcd_monoid
structure on a monoid just from the existence of an lcm
.
Equations
- gcd_monoid_of_exists_lcm h = gcd_monoid_of_lcm (λ (a b : α), classical.some _) _ _ _
Define a normalized_gcd_monoid
structure on a monoid just from the existence of an lcm
.
Equations
- normalized_gcd_monoid_of_exists_lcm h = normalized_gcd_monoid_of_lcm (λ (a b : α), ⇑normalize (classical.some _)) _ _ _ _
Equations
- comm_group_with_zero.normalized_gcd_monoid G₀ = {to_normalization_monoid := {norm_unit := λ (x : G₀), dite (x = 0) (λ (h : x = 0), 1) (λ (h : ¬x = 0), (units.mk0 x h)⁻¹), norm_unit_zero := _, norm_unit_mul := _, norm_unit_coe_units := _}, to_gcd_monoid := {gcd := λ (a b : G₀), ite (a = 0 ∧ b = 0) 0 1, lcm := λ (a b : G₀), ite (a = 0 ∨ b = 0) 0 1, gcd_dvd_left := _, gcd_dvd_right := _, dvd_gcd := _, gcd_mul_lcm := _, lcm_zero_left := _, lcm_zero_right := _}, normalize_gcd := _, normalize_lcm := _}