Typeclasses for (semi)groups and monoids #
In this file we define typeclasses for algebraic structures with one binary operation.
The classes are named (Add)?(Comm)?(Semigroup|Monoid|Group), where Add means that
the class uses additive notation and Comm means that the class assumes that the binary
operation is commutative.
The file does not contain any lemmas except for
- axioms of typeclasses restated in the root namespace;
- lemmas required for instances.
For basic lemmas about these classes see Algebra.Group.Basic.
We also introduce notation classes SMul and VAdd for multiplicative and additive
actions and register the following instances:
Pow M ℕ, for monoidsM, andPow G ℤfor groupsG;SMul ℕ Mfor additive monoidsM, andSMul ℤ Gfor additive groupsG.
Notation #
+,-,*,/,^: the usual arithmetic operations; the underlying functions areAdd.add,Neg.neg/Sub.sub,Mul.mul,Div.div, andHPow.hPow.a • bis used as notation forHSMul.hSMul a b.a +ᵥ bis used as notation forHVAdd.hVAdd a b.
- hVAdd : α → β → γ
a +ᵥ bcomputes the sum ofaandb. The meaning of this notation is type-dependent.
The notation typeclass for heterogeneous additive actions.
This enables the notation a +ᵥ b : γ where a : α, b : β.
Instances
- hSMul : α → β → γ
a • bcomputes the product ofaandb. The meaning of this notation is type-dependent.
The notation typeclass for heterogeneous scalar multiplication.
This enables the notation a • b : γ where a : α, b : β.
Instances
Equations
- «term_+ᵥ_» = Lean.ParserDescr.trailingNode `term_+ᵥ_ 65 65 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " +ᵥ ") (Lean.ParserDescr.cat `term 66))
Instances For
Equations
- «term_-ᵥ_» = Lean.ParserDescr.trailingNode `term_-ᵥ_ 65 65 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " -ᵥ ") (Lean.ParserDescr.cat `term 66))
Instances For
Equations
- «term_•_» = Lean.ParserDescr.trailingNode `term_•_ 73 74 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " • ") (Lean.ParserDescr.cat `term 73))
Instances For
Invert an element of α.
Equations
- «term_⁻¹» = Lean.ParserDescr.trailingNode `term_⁻¹ 1024 1024 (Lean.ParserDescr.symbol "⁻¹")
Instances For
A mixin for cancellative multiplication.
Instances
A mixin for cancellative addition.
Instances
- mul : G → G → G
Multiplication is commutative in a commutative semigroup.
A commutative semigroup is a type with an associative commutative (*).
Instances
- add : G → G → G
Addition is commutative in an additive commutative semigroup.
A commutative additive semigroup is a type with an associative commutative (+).
Instances
Any
AddCommSemigroup G that satisfies IsRightCancelAdd G also satisfies
IsLeftCancelAdd G.
Any CommSemigroup G that satisfies IsRightCancelMul G also satisfies
IsLeftCancelMul G.
Any
AddCommSemigroup G that satisfies IsLeftCancelAdd G also satisfies
IsRightCancelAdd G.
Any CommSemigroup G that satisfies IsLeftCancelMul G also satisfies
IsRightCancelMul G.
Any
AddCommSemigroup G that satisfies IsLeftCancelAdd G also satisfies
IsCancelAdd G.
Any CommSemigroup G that satisfies IsLeftCancelMul G also satisfies
IsCancelMul G.
Any
AddCommSemigroup G that satisfies IsRightCancelAdd G also satisfies
IsCancelAdd G.
Any CommSemigroup G that satisfies IsRightCancelMul G also satisfies
IsCancelMul G.
- add : G → G → G
An AddLeftCancelSemigroup is an additive semigroup such that
a + b = a + c implies b = c.
Instances
Any AddLeftCancelSemigroup satisfies
IsLeftCancelAdd.
Any LeftCancelSemigroup satisfies IsLeftCancelMul.
- add : G → G → G
An AddRightCancelSemigroup is an additive semigroup such that
a + b = c + b implies a = c.
Instances
Any RightCancelSemigroup satisfies IsRightCancelMul.
- one : M
- mul : M → M → M
One is a left neutral element for multiplication
One is a right neutral element for multiplication
Typeclass for expressing that a type M with multiplication and a one satisfies
1 * a = a and a * 1 = a for all a : M.
Instances
- zero : M
- add : M → M → M
Zero is a left neutral element for addition
Zero is a right neutral element for addition
Typeclass for expressing that a type M with addition and a zero satisfies
0 + a = a and a + 0 = a for all a : M.
Instances
Design note on AddMonoid and Monoid #
An AddMonoid has a natural ℕ-action, defined by n • a = a + ... + a, that we want to declare
as an instance as it makes it possible to use the language of linear algebra. However, there are
often other natural ℕ-actions. For instance, for any semiring R, the space of polynomials
Polynomial R has a natural R-action defined by multiplication on the coefficients. This means
that Polynomial ℕ would have two natural ℕ-actions, which are equal but not defeq. The same
goes for linear maps, tensor products, and so on (and even for ℕ itself).
To solve this issue, we embed an ℕ-action in the definition of an AddMonoid (which is by
default equal to the naive action a + ... + a, but can be adjusted when needed), and declare
a SMul ℕ α instance using this action. See Note [forgetful inheritance] for more
explanations on this pattern.
For example, when we define Polynomial R, then we declare the ℕ-action to be by multiplication
on each coefficient (using the ℕ-action on R that comes from the fact that R is
an AddMonoid). In this way, the two natural SMul ℕ (Polynomial ℕ) instances are defeq.
The tactic to_additive transfers definitions and results from multiplicative monoids to additive
monoids. To work, it has to map fields to fields. This means that we should also add corresponding
fields to the multiplicative structure Monoid, which could solve defeq problems for powers if
needed. These problems do not come up in practice, so most of the time we will not need to adjust
the npow field when defining multiplicative objects.
A basic theory for the power function on monoids and the ℕ-action on additive monoids is built in
the file Algebra.GroupPower.Basic. For now, we only register the most basic properties that we
need right away.
- add : M → M → M
- zero : M
Zero is a left neutral element for addition
Zero is a right neutral element for addition
- nsmul : ℕ → M → M
Multiplication by a natural number.
- nsmul_zero : ∀ (x : M), AddMonoid.nsmul 0 x = 0
Multiplication by
(0 : ℕ)gives0. - nsmul_succ : ∀ (n : ℕ) (x : M), AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
Multiplication by
(n + 1 : ℕ)behaves as expected.
An AddMonoid is an AddSemigroup with an element 0 such that 0 + a = a + 0 = a.
Instances
- mul : M → M → M
- one : M
One is a left neutral element for multiplication
One is a right neutral element for multiplication
- npow : ℕ → M → M
Raising to the power of a natural number.
- npow_zero : ∀ (x : M), Monoid.npow 0 x = 1
Raising to the power
(0 : ℕ)gives1. - npow_succ : ∀ (n : ℕ) (x : M), Monoid.npow (n + 1) x = x * Monoid.npow n x
Raising to the power
(n + 1 : ℕ)behaves as expected.
A Monoid is a Semigroup with an element 1 such that 1 * a = a * 1 = a.
Instances
Equations
- Monoid.Pow = { pow := fun x n => Monoid.npow n x }
- add : M → M → M
- zero : M
- nsmul : ℕ → M → M
- nsmul_zero : ∀ (x : M), AddMonoid.nsmul 0 x = 0
- nsmul_succ : ∀ (n : ℕ) (x : M), AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
Addition is commutative in an additive commutative semigroup.
An additive commutative monoid is an additive monoid with commutative (+).
Instances
- mul : M → M → M
- one : M
- npow : ℕ → M → M
- npow_zero : ∀ (x : M), Monoid.npow 0 x = 1
- npow_succ : ∀ (n : ℕ) (x : M), Monoid.npow (n + 1) x = x * Monoid.npow n x
Multiplication is commutative in a commutative semigroup.
A commutative monoid is a monoid with commutative (*).
Instances
- add : M → M → M
- zero : M
Zero is a left neutral element for addition
Zero is a right neutral element for addition
- nsmul : ℕ → M → M
Multiplication by a natural number.
- nsmul_zero : ∀ (x : M), AddLeftCancelMonoid.nsmul 0 x = 0
Multiplication by
(0 : ℕ)gives0. - nsmul_succ : ∀ (n : ℕ) (x : M), AddLeftCancelMonoid.nsmul (n + 1) x = x + AddLeftCancelMonoid.nsmul n x
Multiplication by
(n + 1 : ℕ)behaves as expected.
An additive monoid in which addition is left-cancellative.
Main examples are ℕ and groups. This is the right typeclass for many sum lemmas, as having a zero
is useful to define the sum over the empty set, so AddLeftCancelSemigroup is not enough.
Instances
- mul : M → M → M
- one : M
One is a left neutral element for multiplication
One is a right neutral element for multiplication
- npow : ℕ → M → M
Raising to the power of a natural number.
- npow_zero : ∀ (x : M), LeftCancelMonoid.npow 0 x = 1
Raising to the power
(0 : ℕ)gives1. - npow_succ : ∀ (n : ℕ) (x : M), LeftCancelMonoid.npow (n + 1) x = x * LeftCancelMonoid.npow n x
Raising to the power
(n + 1 : ℕ)behaves as expected.
A monoid in which multiplication is left-cancellative.
Instances
- add : M → M → M
- zero : M
Zero is a left neutral element for addition
Zero is a right neutral element for addition
- nsmul : ℕ → M → M
Multiplication by a natural number.
- nsmul_zero : ∀ (x : M), AddRightCancelMonoid.nsmul 0 x = 0
Multiplication by
(0 : ℕ)gives0. - nsmul_succ : ∀ (n : ℕ) (x : M), AddRightCancelMonoid.nsmul (n + 1) x = x + AddRightCancelMonoid.nsmul n x
Multiplication by
(n + 1 : ℕ)behaves as expected.
An additive monoid in which addition is right-cancellative.
Main examples are ℕ and groups. This is the right typeclass for many sum lemmas, as having a zero
is useful to define the sum over the empty set, so AddRightCancelSemigroup is not enough.
Instances
- mul : M → M → M
- one : M
One is a left neutral element for multiplication
One is a right neutral element for multiplication
- npow : ℕ → M → M
Raising to the power of a natural number.
- npow_zero : ∀ (x : M), RightCancelMonoid.npow 0 x = 1
Raising to the power
(0 : ℕ)gives1. - npow_succ : ∀ (n : ℕ) (x : M), RightCancelMonoid.npow (n + 1) x = x * RightCancelMonoid.npow n x
Raising to the power
(n + 1 : ℕ)behaves as expected.
A monoid in which multiplication is right-cancellative.
Instances
- add : M → M → M
- zero : M
- nsmul : ℕ → M → M
- nsmul_zero : ∀ (x : M), AddLeftCancelMonoid.nsmul 0 x = 0
- nsmul_succ : ∀ (n : ℕ) (x : M), AddLeftCancelMonoid.nsmul (n + 1) x = x + AddLeftCancelMonoid.nsmul n x
An additive monoid in which addition is cancellative on both sides.
Main examples are ℕ and groups. This is the right typeclass for many sum lemmas, as having a zero
is useful to define the sum over the empty set, so AddRightCancelMonoid is not enough.
Instances
- mul : M → M → M
- one : M
- npow : ℕ → M → M
- npow_zero : ∀ (x : M), LeftCancelMonoid.npow 0 x = 1
- npow_succ : ∀ (n : ℕ) (x : M), LeftCancelMonoid.npow (n + 1) x = x * LeftCancelMonoid.npow n x
A monoid in which multiplication is cancellative.
Instances
- add : M → M → M
- zero : M
- nsmul : ℕ → M → M
- nsmul_zero : ∀ (x : M), AddLeftCancelMonoid.nsmul 0 x = 0
- nsmul_succ : ∀ (n : ℕ) (x : M), AddLeftCancelMonoid.nsmul (n + 1) x = x + AddLeftCancelMonoid.nsmul n x
Addition is commutative in an additive commutative semigroup.
Commutative version of AddCancelMonoid.
Instances
- mul : M → M → M
- one : M
- npow : ℕ → M → M
- npow_zero : ∀ (x : M), LeftCancelMonoid.npow 0 x = 1
- npow_succ : ∀ (n : ℕ) (x : M), LeftCancelMonoid.npow (n + 1) x = x * LeftCancelMonoid.npow n x
Multiplication is commutative in a commutative semigroup.
Commutative version of CancelMonoid.
Instances
Equations
- AddCancelCommMonoid.toAddCancelMonoid M = let src := (_ : IsRightCancelAdd M); AddCancelMonoid.mk (_ : ∀ (a b c : M), a + b = c + b → a = c)
Equations
- CancelCommMonoid.toCancelMonoid M = let src := (_ : IsRightCancelMul M); CancelMonoid.mk (_ : ∀ (a b c : M), a * b = c * b → a = c)
Any AddCancelMonoid G satisfies IsCancelAdd G.
Any CancelMonoid G satisfies IsCancelMul G.
The fundamental power operation in a group. zpowRec n a = a*a*...*a n times, for integer n.
Use instead a ^ n, which has better definitional behavior.
Equations
Instances For
The fundamental scalar multiplication in an additive group. zpowRec n a = a+a+...+a n
times, for integer n. Use instead n • a, which has better definitional behavior.
Equations
Instances For
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:
- Groups
- Groups with zero
- The pointwise monoids
Set α,Finset α,Filter α
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αnon commutative. - 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.
Equations
- DivInvMonoid.div' a b = a * b⁻¹
Instances For
- mul : G → G → G
- one : G
- npow : ℕ → G → G
- npow_zero : ∀ (x : G), Monoid.npow 0 x = 1
- npow_succ : ∀ (n : ℕ) (x : G), Monoid.npow (n + 1) x = x * Monoid.npow n x
- inv : G → G
- div : G → G → G
a / b := a * b⁻¹- zpow : ℤ → G → G
The power operation:
a ^ n = a * ··· * a;a ^ (-n) = a⁻¹ * ··· a⁻¹(ntimes) - zpow_zero' : ∀ (a : G), DivInvMonoid.zpow 0 a = 1
a ^ 0 = 1 - zpow_succ' : ∀ (n : ℕ) (a : G), DivInvMonoid.zpow (Int.ofNat (Nat.succ n)) a = a * DivInvMonoid.zpow (Int.ofNat n) a
a ^ (n + 1) = a * a ^ n - zpow_neg' : ∀ (n : ℕ) (a : G), DivInvMonoid.zpow (Int.negSucc n) a = (DivInvMonoid.zpow (↑(Nat.succ n)) a)⁻¹
a ^ -(n + 1) = (a ^ (n + 1))⁻¹
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.
Instances
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.
Equations
- SubNegMonoid.sub' a b = a + -b
Instances For
- add : G → G → G
- zero : G
- nsmul : ℕ → G → G
- nsmul_zero : ∀ (x : G), AddMonoid.nsmul 0 x = 0
- nsmul_succ : ∀ (n : ℕ) (x : G), AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
- neg : G → G
- sub : G → G → G
- zsmul : ℤ → G → G
- zsmul_zero' : ∀ (a : G), SubNegMonoid.zsmul 0 a = 0
- zsmul_succ' : ∀ (n : ℕ) (a : G), SubNegMonoid.zsmul (Int.ofNat (Nat.succ n)) a = a + SubNegMonoid.zsmul (Int.ofNat n) a
- zsmul_neg' : ∀ (n : ℕ) (a : G), SubNegMonoid.zsmul (Int.negSucc n) a = -SubNegMonoid.zsmul (↑(Nat.succ n)) a
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
Equations
- DivInvMonoid.Pow = { pow := fun x n => DivInvMonoid.zpow n x }
Equations
- SubNegMonoid.SMulInt = { smul := SubNegMonoid.zsmul }
Equations
- ofNat_zsmul.match_1 motive x h_1 h_2 = Nat.casesOn x (h_1 ()) fun n => h_2 n
Instances For
Subtracting an element is the same as adding by its negative.
This is a duplicate of SubNegMonoid.sub_eq_mul_neg ensuring that the types unfold better.
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.
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.
- add : G → G → G
- zero : G
- nsmul : ℕ → G → G
- nsmul_zero : ∀ (x : G), AddMonoid.nsmul 0 x = 0
- nsmul_succ : ∀ (n : ℕ) (x : G), AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
- neg : G → G
- sub : G → G → G
- zsmul : ℤ → G → G
- zsmul_zero' : ∀ (a : G), SubNegMonoid.zsmul 0 a = 0
- zsmul_succ' : ∀ (n : ℕ) (a : G), SubNegMonoid.zsmul (Int.ofNat (Nat.succ n)) a = a + SubNegMonoid.zsmul (Int.ofNat n) a
- zsmul_neg' : ∀ (n : ℕ) (a : G), SubNegMonoid.zsmul (Int.negSucc n) a = -SubNegMonoid.zsmul (↑(Nat.succ n)) a
A SubNegMonoid where -0 = 0.
Instances
- mul : G → G → G
- one : G
- npow : ℕ → G → G
- npow_zero : ∀ (x : G), Monoid.npow 0 x = 1
- npow_succ : ∀ (n : ℕ) (x : G), Monoid.npow (n + 1) x = x * Monoid.npow n x
- inv : G → G
- div : G → G → G
- zpow : ℤ → G → G
- zpow_zero' : ∀ (a : G), DivInvMonoid.zpow 0 a = 1
- zpow_succ' : ∀ (n : ℕ) (a : G), DivInvMonoid.zpow (Int.ofNat (Nat.succ n)) a = a * DivInvMonoid.zpow (Int.ofNat n) a
- zpow_neg' : ∀ (n : ℕ) (a : G), DivInvMonoid.zpow (Int.negSucc n) a = (DivInvMonoid.zpow (↑(Nat.succ n)) a)⁻¹
A DivInvMonoid where 1⁻¹ = 1.
Instances
- add : G → G → G
- zero : G
- nsmul : ℕ → G → G
- nsmul_zero : ∀ (x : G), AddMonoid.nsmul 0 x = 0
- nsmul_succ : ∀ (n : ℕ) (x : G), AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
- neg : G → G
- sub : G → G → G
- zsmul : ℤ → G → G
- zsmul_zero' : ∀ (a : G), SubNegMonoid.zsmul 0 a = 0
- zsmul_succ' : ∀ (n : ℕ) (a : G), SubNegMonoid.zsmul (Int.ofNat (Nat.succ n)) a = a + SubNegMonoid.zsmul (Int.ofNat n) a
- zsmul_neg' : ∀ (n : ℕ) (a : G), SubNegMonoid.zsmul (Int.negSucc n) a = -SubNegMonoid.zsmul (↑(Nat.succ n)) a
A SubtractionMonoid is a SubNegMonoid with involutive negation and such that
-(a + b) = -b + -a and a + b = 0 → -a = b.
Instances
- mul : G → G → G
- one : G
- npow : ℕ → G → G
- npow_zero : ∀ (x : G), Monoid.npow 0 x = 1
- npow_succ : ∀ (n : ℕ) (x : G), Monoid.npow (n + 1) x = x * Monoid.npow n x
- inv : G → G
- div : G → G → G
- zpow : ℤ → G → G
- zpow_zero' : ∀ (a : G), DivInvMonoid.zpow 0 a = 1
- zpow_succ' : ∀ (n : ℕ) (a : G), DivInvMonoid.zpow (Int.ofNat (Nat.succ n)) a = a * DivInvMonoid.zpow (Int.ofNat n) a
- zpow_neg' : ∀ (n : ℕ) (a : G), DivInvMonoid.zpow (Int.negSucc n) a = (DivInvMonoid.zpow (↑(Nat.succ n)) a)⁻¹
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.
Instances
- add : G → G → G
- zero : G
- nsmul : ℕ → G → G
- nsmul_zero : ∀ (x : G), AddMonoid.nsmul 0 x = 0
- nsmul_succ : ∀ (n : ℕ) (x : G), AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
- neg : G → G
- sub : G → G → G
- zsmul : ℤ → G → G
- zsmul_zero' : ∀ (a : G), SubNegMonoid.zsmul 0 a = 0
- zsmul_succ' : ∀ (n : ℕ) (a : G), SubNegMonoid.zsmul (Int.ofNat (Nat.succ n)) a = a + SubNegMonoid.zsmul (Int.ofNat n) a
- zsmul_neg' : ∀ (n : ℕ) (a : G), SubNegMonoid.zsmul (Int.negSucc n) a = -SubNegMonoid.zsmul (↑(Nat.succ n)) a
Addition is commutative in an additive commutative semigroup.
Commutative SubtractionMonoid.
Instances
- mul : G → G → G
- one : G
- npow : ℕ → G → G
- npow_zero : ∀ (x : G), Monoid.npow 0 x = 1
- npow_succ : ∀ (n : ℕ) (x : G), Monoid.npow (n + 1) x = x * Monoid.npow n x
- inv : G → G
- div : G → G → G
- zpow : ℤ → G → G
- zpow_zero' : ∀ (a : G), DivInvMonoid.zpow 0 a = 1
- zpow_succ' : ∀ (n : ℕ) (a : G), DivInvMonoid.zpow (Int.ofNat (Nat.succ n)) a = a * DivInvMonoid.zpow (Int.ofNat n) a
- zpow_neg' : ∀ (n : ℕ) (a : G), DivInvMonoid.zpow (Int.negSucc n) a = (DivInvMonoid.zpow (↑(Nat.succ n)) a)⁻¹
Multiplication is commutative in a commutative semigroup.
Commutative DivisionMonoid.
This is the immediate common ancestor of CommGroup and CommGroupWithZero.
Instances
- mul : G → G → G
- one : G
- npow : ℕ → G → G
- npow_zero : ∀ (x : G), Monoid.npow 0 x = 1
- npow_succ : ∀ (n : ℕ) (x : G), Monoid.npow (n + 1) x = x * Monoid.npow n x
- inv : G → G
- div : G → G → G
- zpow : ℤ → G → G
- zpow_zero' : ∀ (a : G), DivInvMonoid.zpow 0 a = 1
- zpow_succ' : ∀ (n : ℕ) (a : G), DivInvMonoid.zpow (Int.ofNat (Nat.succ n)) a = a * DivInvMonoid.zpow (Int.ofNat n) a
- zpow_neg' : ∀ (n : ℕ) (a : G), DivInvMonoid.zpow (Int.negSucc n) a = (DivInvMonoid.zpow (↑(Nat.succ n)) a)⁻¹
A Group is a Monoid with an operation ⁻¹ satisfying a⁻¹ * a = 1.
There is also a division operation / such that a / b = a * b⁻¹,
with a default so that a / b = a * b⁻¹ holds by definition.
Use Group.ofLeftAxioms or Group.ofRightAxioms to define a group structure
on a type with the minumum proof obligations.
Instances
- add : A → A → A
- zero : A
- nsmul : ℕ → A → A
- nsmul_zero : ∀ (x : A), AddMonoid.nsmul 0 x = 0
- nsmul_succ : ∀ (n : ℕ) (x : A), AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
- neg : A → A
- sub : A → A → A
- zsmul : ℤ → A → A
- zsmul_zero' : ∀ (a : A), SubNegMonoid.zsmul 0 a = 0
- zsmul_succ' : ∀ (n : ℕ) (a : A), SubNegMonoid.zsmul (Int.ofNat (Nat.succ n)) a = a + SubNegMonoid.zsmul (Int.ofNat n) a
- zsmul_neg' : ∀ (n : ℕ) (a : A), SubNegMonoid.zsmul (Int.negSucc n) a = -SubNegMonoid.zsmul (↑(Nat.succ n)) a
An AddGroup is an AddMonoid with a unary - satisfying -a + a = 0.
There is also a binary operation - such that a - b = a + -b,
with a default so that a - b = a + -b holds by definition.
Use AddGroup.ofLeftAxioms or AddGroup.ofRightAxioms to define an
additive group structure on a type with the minumum proof obligations.
Instances
- add : G → G → G
- zero : G
- nsmul : ℕ → G → G
- nsmul_zero : ∀ (x : G), AddMonoid.nsmul 0 x = 0
- nsmul_succ : ∀ (n : ℕ) (x : G), AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
- neg : G → G
- sub : G → G → G
- zsmul : ℤ → G → G
- zsmul_zero' : ∀ (a : G), SubNegMonoid.zsmul 0 a = 0
- zsmul_succ' : ∀ (n : ℕ) (a : G), SubNegMonoid.zsmul (Int.ofNat (Nat.succ n)) a = a + SubNegMonoid.zsmul (Int.ofNat n) a
- zsmul_neg' : ∀ (n : ℕ) (a : G), SubNegMonoid.zsmul (Int.negSucc n) a = -SubNegMonoid.zsmul (↑(Nat.succ n)) a
Addition is commutative in an additive commutative semigroup.
An additive commutative group is an additive group with commutative (+).
Instances
- mul : G → G → G
- one : G
- npow : ℕ → G → G
- npow_zero : ∀ (x : G), Monoid.npow 0 x = 1
- npow_succ : ∀ (n : ℕ) (x : G), Monoid.npow (n + 1) x = x * Monoid.npow n x
- inv : G → G
- div : G → G → G
- zpow : ℤ → G → G
- zpow_zero' : ∀ (a : G), DivInvMonoid.zpow 0 a = 1
- zpow_succ' : ∀ (n : ℕ) (a : G), DivInvMonoid.zpow (Int.ofNat (Nat.succ n)) a = a * DivInvMonoid.zpow (Int.ofNat n) a
- zpow_neg' : ∀ (n : ℕ) (a : G), DivInvMonoid.zpow (Int.negSucc n) a = (DivInvMonoid.zpow (↑(Nat.succ n)) a)⁻¹
Multiplication is commutative in a commutative semigroup.
A commutative group is a group with commutative (*).
Instances
Equations
- AddCommGroup.toAddCancelCommMonoid = let src := inst; let src_1 := AddGroup.toAddCancelMonoid; AddCancelCommMonoid.mk (_ : ∀ (a b : G), a + b = b + a)
Equations
- CommGroup.toCancelCommMonoid = let src := inst; let src_1 := Group.toCancelMonoid; CancelCommMonoid.mk (_ : ∀ (a b : G), a * b = b * a)
Equations
- AddCommGroup.toDivisionAddCommMonoid = let src := inst; let src_1 := AddGroup.toSubtractionMonoid; SubtractionCommMonoid.mk (_ : ∀ (a b : G), a + b = b + a)
Equations
- CommGroup.toDivisionCommMonoid = let src := inst; let src_1 := Group.toDivisionMonoid; DivisionCommMonoid.mk (_ : ∀ (a b : G), a * b = b * a)
We initialize all projections for @[simps] here, so that we don't have to do it in later
files.
Note: the lemmas generated for the npow/zpow projections will not apply to x ^ y, since the
argument order of these projections doesn't match the argument order of ^.
The nsmul/zsmul lemmas will be correct.