Division monoids #
This file defines additive and multiplicative structures with division, inversion, subtraction,
or negation, up to DivisionCommMonoid and SubtractionCommMonoid. Group structures are defined in
Mathlib.Algebra.Group.Defs.
Design note on DivInvMonoid/SubNegMonoid and DivisionMonoid/SubtractionMonoid #
Those two pairs of made-up classes fulfill slightly different roles.
DivInvMonoid/SubNegMonoid provides the minimum amount of information to define the
ℤ action (zpow or zsmul). Further, it provides a div field, matching the forgetful
inheritance pattern. This is useful to shorten extension clauses of stronger structures (Group,
GroupWithZero, DivisionRing, Field) and for a few structures with a rather weak
pseudo-inverse (Matrix).
DivisionMonoid/SubtractionMonoid is targeted at structures with stronger pseudo-inverses. It
is an ad hoc collection of axioms that are mainly respected by three things:
It acts as a middle ground for structures with an inversion operator that plays well with
multiplication, except for the fact that it might not be a true inverse (a / a ≠ 1 in general).
The axioms are pretty arbitrary (many other combinations are equivalent to it), but they are
independent:
- Without
DivisionMonoid.div_eq_mul_inv, you can define/arbitrarily. - Without
DivisionMonoid.inv_inv, you can considerWithTop Unitwitha⁻¹ = ⊤for alla. - Without
DivisionMonoid.mul_inv_rev, you can considerWithTop αwitha⁻¹ = afor allawhereαnoncommutative. - Without
DivisionMonoid.inv_eq_of_mul, you can consider anyCommMonoidwitha⁻¹ = afor alla.
As a consequence, a few natural structures do not fit in this framework. For example, ENNReal
respects everything except for the fact that (0 * ∞)⁻¹ = 0⁻¹ = ∞ while ∞⁻¹ * 0⁻¹ = 0 * ∞ = 0.
In a class equipped with instances of both Monoid and Inv, this definition records what the
default definition for Div would be: a * b⁻¹. This is later provided as the default value for
the Div instance in DivInvMonoid.
We keep it as a separate definition rather than inlining it in DivInvMonoid so that the Div
field of individual DivInvMonoids constructed using that default value will not be unfolded at
.instance transparency.
Instances For
In a class equipped with instances of both AddMonoid and Neg, this definition records what
the default definition for Sub would be: a + -b. This is later provided as the default value
for the Sub instance in SubNegMonoid.
We keep it as a separate definition rather than inlining it in SubNegMonoid so that the Sub
field of individual SubNegMonoids constructed using that default value will not be unfolded at
.instance transparency.
Instances For
A DivInvMonoid is a Monoid with operations / and ⁻¹ satisfying
div_eq_mul_inv : ∀ a b, a / b = a * b⁻¹.
This deduplicates the name div_eq_mul_inv.
The default for div is such that a / b = a * b⁻¹ holds by definition.
Adding div as a field rather than defining a / b := a * b⁻¹ allows us to
avoid certain classes of unification failures, for example:
Let Foo X be a type with a ∀ X, Div (Foo X) instance but no
∀ X, Inv (Foo X), e.g. when Foo X is a EuclideanDomain. Suppose we
also have an instance ∀ X [Cromulent X], GroupWithZero (Foo X). Then the
(/) coming from GroupWithZero.div cannot be definitionally equal to
the (/) coming from Foo.Div.
In the same way, adding a zpow field makes it possible to avoid definitional failures
in diamonds. See the definition of Monoid and Note [forgetful inheritance] for more
explanations on this.
- one : G
- mul : G → G → G
- inv : G → G
- div : G → G → G
a / b := a * b⁻¹a ^ 0 = 1a ^ (n + 1) = a ^ n * aa ^ -(n + 1) = (a ^ (n + 1))⁻¹
Instances
A SubNegMonoid is an AddMonoid with unary - and binary - operations
satisfying sub_eq_add_neg : ∀ a b, a - b = a + -b.
The default for sub is such that a - b = a + -b holds by definition.
Adding sub as a field rather than defining a - b := a + -b allows us to
avoid certain classes of unification failures, for example:
Let foo X be a type with a ∀ X, Sub (Foo X) instance but no
∀ X, Neg (Foo X). Suppose we also have an instance
∀ X [Cromulent X], AddGroup (Foo X). Then the (-) coming from
AddGroup.sub cannot be definitionally equal to the (-) coming from
Foo.Sub.
In the same way, adding a zsmul field makes it possible to avoid definitional failures
in diamonds. See the definition of AddMonoid and Note [forgetful inheritance] for more
explanations on this.
Instances
A group is called cyclic if it is generated by a single element.
Instances
Dividing by an element is the same as multiplying by its inverse.
This is a duplicate of DivInvMonoid.div_eq_mul_inv ensuring that the types unfold better.
Subtracting an element is the same as adding by its negative.
This is a duplicate of SubNegMonoid.sub_eq_add_neg ensuring that the types unfold better.
Alias of div_eq_mul_inv.
Dividing by an element is the same as multiplying by its inverse.
This is a duplicate of DivInvMonoid.div_eq_mul_inv ensuring that the types unfold better.
A SubNegMonoid where -0 = 0.
Instances
A DivInvMonoid where 1⁻¹ = 1.
Instances
A SubtractionMonoid is a SubNegMonoid with involutive negation and such that
-(a + b) = -b + -a and a + b = 0 → -a = b.
- zero : G
- add : G → G → G
- neg : G → G
- sub : G → G → G
Despite the asymmetry of
neg_eq_of_add, the symmetric version is true thanks to the involutivity of negation.
Instances
A DivisionMonoid is a DivInvMonoid with involutive inversion and such that
(a * b)⁻¹ = b⁻¹ * a⁻¹ and a * b = 1 → a⁻¹ = b.
This is the immediate common ancestor of Group and GroupWithZero.
- one : G
- mul : G → G → G
- inv : G → G
- div : G → G → G
Despite the asymmetry of
inv_eq_of_mul, the symmetric version is true thanks to the involutivity of inversion.
Instances
Commutative SubtractionMonoid.
Instances
Commutative DivisionMonoid.
This is the immediate common ancestor of CommGroup and CommGroupWithZero.