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 #
-
normalization_monoidis defined by assigning to each element anorm_unitsuch that multiplying by that unit normalizes the monoid, andnormalizeis an idempotent monoid homomorphism. This definition as currently implemented does casework on0. -
gcd_monoidextendsnormalization_monoid, so thegcdandlcmare always normalized. This makesgcds of polynomials easier to work with, but excludes Euclidean domains, and monoids without zero. -
gcd_monoid_of_gcdnoncomputably constructs agcd_monoidstructure just from thegcdand its properties. -
gcd_monoid_of_exists_gcdnoncomputably constructs agcd_monoidstructure just from a proof that any two elements have a (not necessarily normalized)gcd. -
gcd_monoid_of_lcmnoncomputably constructs agcd_monoidstructure just from thelcmand its properties. -
gcd_monoid_of_exists_lcmnoncomputably constructs agcd_monoidstructure just from a proof that any two elements have a (not necessarily normalized)lcm.
TODO #
- Provide a GCD monoid instance for
ℕ, port GCD facts about nats, definition of coprime - Generalize normalization monoids to commutative (cancellative) monoids with or without zero
- Generalize GCD monoid to not require normalization in all cases
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
Equations
- comm_group_with_zero.normalization_monoid = {norm_unit := λ (x : α), dite (x = 0) (λ (h : x = 0), 1) (λ (h : ¬x = 0), (units.mk0 x h)⁻¹), norm_unit_zero := _, norm_unit_mul := _, norm_unit_coe_units := _}
Maps an element of associates back to the normalized element of its associate class
Equations
- associates.out = quotient.lift ⇑normalize associates.out._proof_1
- norm_unit : α → units α
- norm_unit_zero : gcd_monoid.norm_unit 0 = 1
- norm_unit_mul : ∀ {a b : α}, a ≠ 0 → b ≠ 0 → gcd_monoid.norm_unit (a * b) = (gcd_monoid.norm_unit a) * gcd_monoid.norm_unit b
- norm_unit_coe_units : ∀ (u : units α), gcd_monoid.norm_unit ↑u = u⁻¹
- 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_1 : α}, a ∣ c_1 → a ∣ b → a ∣ gcd c_1 b
- normalize_gcd : ∀ (a b : α), ⇑normalize (gcd a b) = gcd a b
- gcd_mul_lcm : ∀ (a b : α), (gcd a b) * lcm a b = ⇑normalize (a * b)
- lcm_zero_left : ∀ (a : α), lcm 0 a = 0
- lcm_zero_right : ∀ (a : α), lcm a 0 = 0
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.
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 := _}
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 normalize_gcd = {norm_unit := norm_unit infer_instance, norm_unit_zero := _, norm_unit_mul := _, norm_unit_coe_units := _, 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 := _, normalize_gcd := normalize_gcd, gcd_mul_lcm := _, lcm_zero_left := _, lcm_zero_right := _}
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 normalize_lcm = let exists_gcd : ∀ (a b : α), lcm a b ∣ ⇑normalize (a * b) := _ in {norm_unit := norm_unit infer_instance, norm_unit_zero := _, norm_unit_mul := _, norm_unit_coe_units := _, 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 := _, normalize_gcd := _, gcd_mul_lcm := _, lcm_zero_left := _, lcm_zero_right := _}
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 : α), ⇑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 : α), ⇑normalize (classical.some _)) _ _ _ _
ℕ is a gcd_monoid
Equations
- nat.gcd_monoid = {norm_unit := λ (_x : ℕ), 1, norm_unit_zero := nat.gcd_monoid._proof_1, norm_unit_mul := nat.gcd_monoid._proof_2, norm_unit_coe_units := nat.gcd_monoid._proof_3, gcd := nat.gcd, lcm := nat.lcm, gcd_dvd_left := nat.gcd_dvd_left, gcd_dvd_right := nat.gcd_dvd_right, dvd_gcd := nat.gcd_monoid._proof_4, normalize_gcd := nat.gcd_monoid._proof_5, gcd_mul_lcm := nat.gcd_monoid._proof_6, lcm_zero_left := nat.lcm_zero_left, lcm_zero_right := nat.lcm_zero_right}