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 has_scalar
and has_vadd
for multiplicative and additive
actions and register the following instances:
has_pow M ℕ
, for monoidsM
, andhas_pow G ℤ
for groupsG
;has_scalar ℕ M
for additive monoidsM
, andhas_scalar ℤ G
for additive groupsG
.
Notation #
+
,-
,*
,/
,^
: the usual arithmetic operations; the underlying functions arehas_add.add
,has_neg.neg
/has_sub.sub
,has_mul.mul
,has_div.div
, andhas_pow.pow
.a • b
is used as notation forhas_scalar.smul a b
.a +ᵥ b
is used as notation forhas_vadd.vadd a b
.
- vadd : G → P → P
Type class for the +ᵥ
notation.
Instances
- add_action.to_has_vadd
- has_add.to_has_scalar
- add_opposite.has_scalar
- has_add.to_has_opposite_scalar
- prod.has_vadd
- add_units.has_scalar
- add_submonoid.has_scalar
- pi.has_vadd
- pi.has_vadd'
- function.has_vadd
- filter.has_vadd
- filter.has_vadd_filter
- finset.has_vadd_finset
- finset.has_vadd
- set.has_vadd_set
- set.has_vadd
- vsub : P → P → G
Type class for the -ᵥ
notation.
Instances
- smul : M → α → α
Typeclass for types with a scalar multiplication operation, denoted •
(\bu
)
Instances
- algebra.to_has_scalar
- mul_action.to_has_scalar
- smul_with_zero.to_has_scalar
- has_mul.to_has_scalar
- add_monoid.has_scalar_nat
- sub_neg_monoid.has_scalar_int
- mul_opposite.has_scalar
- has_mul.to_has_opposite_scalar
- prod.has_scalar
- units.has_scalar
- add_submonoid_class.has_nsmul
- submonoid.has_scalar
- add_subgroup_class.has_zsmul
- add_subgroup.has_nsmul
- add_subgroup.has_zsmul
- subsemiring.has_scalar
- subring.has_scalar
- punit.has_scalar
- pi.has_scalar
- pi.has_scalar'
- finsupp.has_nat_scalar
- finsupp.has_int_scalar
- finsupp.has_scalar
- linear_map.has_scalar
- add_con.quotient.has_nsmul
- add_con.quotient.has_zsmul
- sub_mul_action.has_scalar
- sub_mul_action.has_scalar'
- submodule.has_scalar
- dfinsupp.has_nat_scalar
- dfinsupp.has_int_scalar
- dfinsupp.has_scalar
- function.has_scalar
- submodule.quotient.has_scalar'
- submodule.quotient.has_scalar
- tensor_product.left_has_scalar
- tensor_product.has_scalar
- submodule.has_scalar'
- localization.has_scalar
- subalgebra.has_scalar
- monoid_algebra.has_scalar
- add_monoid_algebra.has_scalar
- polynomial.has_scalar
- matrix.has_scalar
- multilinear_map.has_scalar
- alternating_map.has_scalar
- fractional_ideal.has_scalar
- conj_act.has_scalar
- conj_act.has_units_scalar
- conj_act.subgroup.conj_action
- filter.has_scalar
- filter.has_scalar_filter
- hahn_series.has_scalar
- hahn_series.summable_family.has_scalar
- ratfunc.has_scalar
- nonneg.has_nsmul
- finset.has_scalar_finset
- finset.has_scalar
- finset.has_nsmul
- finset.has_zsmul
- set.has_scalar_set
- set.has_scalar
- set.has_nsmul
- set.has_zsmul
A semigroup is a type with an associative (*)
.
Instances
- comm_semigroup.to_semigroup
- left_cancel_semigroup.to_semigroup
- right_cancel_semigroup.to_semigroup
- monoid.to_semigroup
- semigroup_with_zero.to_semigroup
- multiplicative.semigroup
- mul_opposite.semigroup
- add_opposite.semigroup
- prod.semigroup
- order_dual.semigroup
- nat.semigroup
- pi.semigroup
- int.semigroup
- rat.semigroup
- con.semigroup
- filter.semigroup
- real.semigroup
- free_abelian_group.semigroup
- zsqrtd.semigroup
- finset.semigroup
- set.semigroup
An additive semigroup is a type with an associative (+)
.
Instances
- add_comm_semigroup.to_add_semigroup
- add_left_cancel_semigroup.to_add_semigroup
- add_right_cancel_semigroup.to_add_semigroup
- add_monoid.to_add_semigroup
- additive.add_semigroup
- mul_opposite.add_semigroup
- add_opposite.add_semigroup
- prod.add_semigroup
- order_dual.add_semigroup
- with_top.add_semigroup
- with_bot.add_semigroup
- nat.add_semigroup
- pi.add_semigroup
- int.add_semigroup
- rat.add_semigroup
- add_con.add_semigroup
- matrix.add_semigroup
- filter.add_semigroup
- real.add_semigroup
- dmatrix.add_semigroup
- zsqrtd.add_semigroup
- finset.add_semigroup
- set.add_semigroup
- mul : G → G → G
- mul_assoc : ∀ (a b c : G), (a * b) * c = a * b * c
- mul_comm : ∀ (a b : G), a * b = b * a
A commutative semigroup is a type with an associative commutative (*)
.
Instances
- comm_monoid.to_comm_semigroup
- multiplicative.comm_semigroup
- with_zero.comm_semigroup
- mul_opposite.comm_semigroup
- add_opposite.comm_semigroup
- prod.comm_semigroup
- order_dual.comm_semigroup
- nat.comm_semigroup
- pi.comm_semigroup
- int.comm_semigroup
- rat.comm_semigroup
- con.comm_semigroup
- filter.comm_semigroup
- real.comm_semigroup
- fin.comm_semigroup
- zsqrtd.comm_semigroup
- set.comm_semigroup
- add : G → G → G
- add_assoc : ∀ (a b c : G), a + b + c = a + (b + c)
- add_comm : ∀ (a b : G), a + b = b + a
A commutative additive semigroup is a type with an associative commutative (+)
.
Instances
- add_comm_monoid.to_add_comm_semigroup
- additive.add_comm_semigroup
- mul_opposite.add_comm_semigroup
- add_opposite.add_comm_semigroup
- prod.add_comm_semigroup
- order_dual.add_comm_semigroup
- with_top.add_comm_semigroup
- with_bot.add_comm_semigroup
- nat.add_comm_semigroup
- pi.add_comm_semigroup
- int.add_comm_semigroup
- pnat.add_comm_semigroup
- rat.add_comm_semigroup
- add_con.add_comm_semigroup
- tensor_product.add_comm_semigroup
- matrix.add_comm_semigroup
- filter.add_comm_semigroup
- real.add_comm_semigroup
- dmatrix.add_comm_semigroup
- zsqrtd.add_comm_semigroup
- set.add_comm_semigroup
- add : G → G → G
- add_assoc : ∀ (a b c : G), a + b + c = a + (b + c)
- add_left_cancel : ∀ (a b c : G), a + b = a + c → b = c
An add_left_cancel_semigroup
is an additive semigroup such that
a + b = a + c
implies b = c
.
Instances
- add_left_cancel_monoid.to_add_left_cancel_semigroup
- additive.add_left_cancel_semigroup
- mul_opposite.add_left_cancel_semigroup
- add_opposite.left_cancel_add_semigroup
- prod.left_cancel_add_semigroup
- pi.add_left_cancel_semigroup
- pnat.add_left_cancel_semigroup
- rat.add_left_cancel_semigroup
- real.add_left_cancel_semigroup
- add : G → G → G
- add_assoc : ∀ (a b c : G), a + b + c = a + (b + c)
- add_right_cancel : ∀ (a b c : G), a + b = c + b → a = c
An add_right_cancel_semigroup
is an additive semigroup such that
a + b = c + b
implies a = c
.
Instances
- add_right_cancel_monoid.to_add_right_cancel_semigroup
- additive.add_right_cancel_semigroup
- mul_opposite.add_right_cancel_semigroup
- add_opposite.right_cancel_add_semigroup
- prod.right_cancel_add_semigroup
- pi.add_right_cancel_semigroup
- pnat.add_right_cancel_semigroup
- rat.add_right_cancel_semigroup
- real.add_right_cancel_semigroup
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
- submonoid_class.to_mul_one_class
- monoid.to_mul_one_class
- mul_zero_one_class.to_mul_one_class
- multiplicative.mul_one_class
- with_one.mul_one_class
- mul_opposite.mul_one_class
- add_opposite.mul_one_class
- prod.mul_one_class
- order_dual.mul_one_class
- pi.mul_one_class
- submonoid.to_mul_one_class
- con.mul_one_class
- filter.mul_one_class
- finset.mul_one_class
- set.mul_one_class
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
- add_submonoid_class.to_add_zero_class
- add_monoid.to_add_zero_class
- additive.add_zero_class
- with_zero.add_zero_class
- mul_opposite.add_zero_class
- add_opposite.add_zero_class
- prod.add_zero_class
- order_dual.add_zero_class
- with_top.add_zero_class
- with_bot.add_zero_class
- pi.add_zero_class
- add_submonoid.to_add_zero_class
- finsupp.add_zero_class
- add_con.add_zero_class
- dfinsupp.add_zero_class
- dfinsupp.add_zero_class₂
- tensor_product.add_zero_class
- matrix.add_zero_class
- filter.add_zero_class
- finset.add_zero_class
- set.add_zero_class
Design note on add_monoid
and monoid
#
An add_monoid
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 add_monoid
(which is by
default equal to the naive action a + ... + a
, but can be adjusted when needed), and declare
a has_scalar ℕ α
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 add_monoid
). In this way, the two natural has_scalar ℕ (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.group_power.basic
. For now, we only register the most basic properties that we
need right away.
In the definition, we use n.succ
instead of n + 1
in the nsmul_succ'
and npow_succ'
fields
to make sure that to_additive
is not confused (otherwise, it would try to convert 1 : ℕ
to 0 : ℕ
).
- add : M → M → M
- add_assoc : ∀ (a b c : M), a + b + c = a + (b + c)
- zero : M
- zero_add : ∀ (a : M), 0 + a = a
- add_zero : ∀ (a : M), a + 0 = a
- nsmul : ℕ → M → M
- nsmul_zero' : (∀ (x : M), add_monoid.nsmul 0 x = 0) . "try_refl_tac"
- nsmul_succ' : (∀ (n : ℕ) (x : M), add_monoid.nsmul n.succ x = x + add_monoid.nsmul n x) . "try_refl_tac"
An add_monoid
is an add_semigroup
with an element 0
such that 0 + a = a + 0 = a
.
Instances
- add_submonoid_class.to_add_monoid
- add_comm_monoid.to_add_monoid
- add_left_cancel_monoid.to_add_monoid
- add_right_cancel_monoid.to_add_monoid
- sub_neg_monoid.to_add_monoid
- additive.add_monoid
- with_zero.add_monoid
- mul_opposite.add_monoid
- add_opposite.add_monoid
- prod.add_monoid
- order_dual.add_monoid
- with_top.add_monoid
- with_bot.add_monoid
- nat.add_monoid
- pi.add_monoid
- int.add_monoid
- rat.add_monoid
- add_submonoid.to_add_monoid
- free_add_monoid.add_monoid
- finsupp.add_monoid
- add_con.add_monoid
- dfinsupp.add_monoid
- dfinsupp.add_monoid₂
- matrix.add_monoid
- ordinal.add_monoid
- AddMon.add_monoid
- filter.add_monoid
- uniform_space.completion.add_monoid
- real.add_monoid
- mv_power_series.add_monoid
- power_series.add_monoid
- hahn_series.add_monoid
- dmatrix.add_monoid
- zsqrtd.add_monoid
- finset.add_monoid
- set.add_monoid
- mul : M → M → M
- mul_assoc : ∀ (a b c : M), (a * b) * c = a * b * c
- one : M
- one_mul : ∀ (a : M), 1 * a = a
- mul_one : ∀ (a : M), a * 1 = a
- npow : ℕ → M → M
- npow_zero' : (∀ (x : M), monoid.npow 0 x = 1) . "try_refl_tac"
- npow_succ' : (∀ (n : ℕ) (x : M), monoid.npow n.succ x = x * monoid.npow n x) . "try_refl_tac"
A monoid
is a semigroup
with an element 1
such that 1 * a = a * 1 = a
.
Instances
- submonoid_class.to_monoid
- comm_monoid.to_monoid
- left_cancel_monoid.to_monoid
- right_cancel_monoid.to_monoid
- div_inv_monoid.to_monoid
- monoid_with_zero.to_monoid
- ring.to_monoid
- monoid.End.monoid
- add_monoid.End.monoid
- multiplicative.monoid
- ring_hom.monoid
- with_one.monoid
- mul_opposite.monoid
- add_opposite.monoid
- prod.monoid
- order_dual.monoid
- nat.monoid
- function.End.monoid
- pi.monoid
- int.monoid
- rat.monoid
- submonoid.to_monoid
- free_monoid.monoid
- module.End.monoid
- con.monoid
- ordinal.monoid
- Mon.monoid
- category_theory.End.monoid
- filter.monoid
- real.monoid
- zsqrtd.monoid
- finset.monoid
- set.monoid
Equations
- monoid.has_pow = {pow := λ (x : M) (n : ℕ), monoid.npow n x}
Equations
- add_monoid.has_scalar_nat = {smul := add_monoid.nsmul _inst_1}
- add : M → M → M
- add_assoc : ∀ (a b c : M), a + b + c = a + (b + c)
- zero : M
- zero_add : ∀ (a : M), 0 + a = a
- add_zero : ∀ (a : M), a + 0 = a
- nsmul : ℕ → M → M
- nsmul_zero' : (∀ (x : M), add_comm_monoid.nsmul 0 x = 0) . "try_refl_tac"
- nsmul_succ' : (∀ (n : ℕ) (x : M), add_comm_monoid.nsmul n.succ x = x + add_comm_monoid.nsmul n x) . "try_refl_tac"
- add_comm : ∀ (a b : M), a + b = b + a
An additive commutative monoid is an additive monoid with commutative (+)
.
Instances
- add_submonoid_class.to_add_comm_monoid
- add_cancel_comm_monoid.to_add_comm_monoid
- non_unital_non_assoc_semiring.to_add_comm_monoid
- ordered_add_comm_monoid.to_add_comm_monoid
- add_comm_group.to_add_comm_monoid
- additive.add_comm_monoid
- with_zero.add_comm_monoid
- mul_opposite.add_comm_monoid
- add_opposite.add_comm_monoid
- prod.add_comm_monoid
- order_dual.add_comm_monoid
- with_top.add_comm_monoid
- with_bot.add_comm_monoid
- nat.add_comm_monoid
- add_monoid_hom.add_comm_monoid
- pi.add_comm_monoid
- int.add_comm_monoid
- fin.add_comm_monoid
- rat.add_comm_monoid
- set.set_semiring.add_comm_monoid
- add_submonoid.to_add_comm_monoid
- finsupp.add_comm_monoid
- linear_map.add_comm_monoid
- add_con.add_comm_monoid
- submodule.add_comm_monoid
- dfinsupp.add_comm_monoid
- enat.add_comm_monoid
- tensor_product.add_comm_monoid
- submodule.pointwise_add_comm_monoid
- add_localization.add_comm_monoid
- monoid_algebra.add_comm_monoid
- add_monoid_algebra.add_comm_monoid
- restrict_scalars.add_comm_monoid
- dfinsupp.add_comm_monoid_of_linear_map
- matrix.add_comm_monoid
- multilinear_map.add_comm_monoid
- alternating_map.add_comm_monoid
- AddCommMon.add_comm_monoid
- filter.add_comm_monoid
- continuous_linear_map.add_comm_monoid
- real.add_comm_monoid
- mv_power_series.add_comm_monoid
- power_series.add_comm_monoid
- hahn_series.add_comm_monoid
- hahn_series.summable_family.add_comm_monoid
- module.dual.add_comm_monoid
- bilin_form.add_comm_monoid
- direct_sum.add_comm_monoid
- dmatrix.add_comm_monoid
- ennreal.add_comm_monoid
- zsqrtd.add_comm_monoid
- finset.add_comm_monoid
- set.add_comm_monoid
- mul : M → M → M
- mul_assoc : ∀ (a b c : M), (a * b) * c = a * b * c
- one : M
- one_mul : ∀ (a : M), 1 * a = a
- mul_one : ∀ (a : M), a * 1 = a
- npow : ℕ → M → M
- npow_zero' : (∀ (x : M), comm_monoid.npow 0 x = 1) . "try_refl_tac"
- npow_succ' : (∀ (n : ℕ) (x : M), comm_monoid.npow n.succ x = x * comm_monoid.npow n x) . "try_refl_tac"
- mul_comm : ∀ (a b : M), a * b = b * a
A commutative monoid is a monoid with commutative (*)
.
Instances
- submonoid_class.to_comm_monoid
- cancel_comm_monoid.to_comm_monoid
- comm_group.to_comm_monoid
- comm_monoid_with_zero.to_comm_monoid
- comm_semiring.to_comm_monoid
- comm_ring.to_comm_monoid
- ordered_comm_monoid.to_comm_monoid
- linear_ordered_comm_ring.to_comm_monoid
- multiplicative.comm_monoid
- with_one.comm_monoid
- mul_opposite.comm_monoid
- add_opposite.comm_monoid
- prod.comm_monoid
- order_dual.comm_monoid
- nat.comm_monoid
- monoid_hom.comm_monoid
- pi.comm_monoid
- int.comm_monoid
- pnat.comm_monoid
- rat.comm_monoid
- associates.comm_monoid
- submonoid.to_comm_monoid
- submonoid.center.comm_monoid
- con.comm_monoid
- localization.comm_monoid
- CommMon.comm_monoid
- filter.comm_monoid
- real.comm_monoid
- perfect_closure.comm_monoid
- zsqrtd.comm_monoid
- finset.comm_monoid
- set.comm_monoid
- add : M → M → M
- add_assoc : ∀ (a b c : M), a + b + c = a + (b + c)
- add_left_cancel : ∀ (a b c : M), a + b = a + c → b = c
- zero : M
- zero_add : ∀ (a : M), 0 + a = a
- add_zero : ∀ (a : M), a + 0 = a
- nsmul : ℕ → M → M
- nsmul_zero' : (∀ (x : M), add_left_cancel_monoid.nsmul 0 x = 0) . "try_refl_tac"
- nsmul_succ' : (∀ (n : ℕ) (x : M), add_left_cancel_monoid.nsmul n.succ x = x + add_left_cancel_monoid.nsmul n x) . "try_refl_tac"
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 add_left_cancel_semigroup
is not enough.
- mul : M → M → M
- mul_assoc : ∀ (a b c : M), (a * b) * c = a * b * c
- mul_left_cancel : ∀ (a b c : M), a * b = a * c → b = c
- one : M
- one_mul : ∀ (a : M), 1 * a = a
- mul_one : ∀ (a : M), a * 1 = a
- npow : ℕ → M → M
- npow_zero' : (∀ (x : M), left_cancel_monoid.npow 0 x = 1) . "try_refl_tac"
- npow_succ' : (∀ (n : ℕ) (x : M), left_cancel_monoid.npow n.succ x = x * left_cancel_monoid.npow n x) . "try_refl_tac"
A monoid in which multiplication is left-cancellative.
- add : M → M → M
- add_assoc : ∀ (a b c : M), a + b + c = a + (b + c)
- add_right_cancel : ∀ (a b c : M), a + b = c + b → a = c
- zero : M
- zero_add : ∀ (a : M), 0 + a = a
- add_zero : ∀ (a : M), a + 0 = a
- nsmul : ℕ → M → M
- nsmul_zero' : (∀ (x : M), add_right_cancel_monoid.nsmul 0 x = 0) . "try_refl_tac"
- nsmul_succ' : (∀ (n : ℕ) (x : M), add_right_cancel_monoid.nsmul n.succ x = x + add_right_cancel_monoid.nsmul n x) . "try_refl_tac"
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 add_right_cancel_semigroup
is not enough.
- mul : M → M → M
- mul_assoc : ∀ (a b c : M), (a * b) * c = a * b * c
- mul_right_cancel : ∀ (a b c : M), a * b = c * b → a = c
- one : M
- one_mul : ∀ (a : M), 1 * a = a
- mul_one : ∀ (a : M), a * 1 = a
- npow : ℕ → M → M
- npow_zero' : (∀ (x : M), right_cancel_monoid.npow 0 x = 1) . "try_refl_tac"
- npow_succ' : (∀ (n : ℕ) (x : M), right_cancel_monoid.npow n.succ x = x * right_cancel_monoid.npow n x) . "try_refl_tac"
A monoid in which multiplication is right-cancellative.
- add : M → M → M
- add_assoc : ∀ (a b c : M), a + b + c = a + (b + c)
- add_left_cancel : ∀ (a b c : M), a + b = a + c → b = c
- zero : M
- zero_add : ∀ (a : M), 0 + a = a
- add_zero : ∀ (a : M), a + 0 = a
- nsmul : ℕ → M → M
- nsmul_zero' : (∀ (x : M), add_cancel_monoid.nsmul 0 x = 0) . "try_refl_tac"
- nsmul_succ' : (∀ (n : ℕ) (x : M), add_cancel_monoid.nsmul n.succ x = x + add_cancel_monoid.nsmul n x) . "try_refl_tac"
- add_right_cancel : ∀ (a b c : M), a + b = c + b → a = c
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 add_right_cancel_semigroup
is not enough.
- mul : M → M → M
- mul_assoc : ∀ (a b c : M), (a * b) * c = a * b * c
- mul_left_cancel : ∀ (a b c : M), a * b = a * c → b = c
- one : M
- one_mul : ∀ (a : M), 1 * a = a
- mul_one : ∀ (a : M), a * 1 = a
- npow : ℕ → M → M
- npow_zero' : (∀ (x : M), cancel_monoid.npow 0 x = 1) . "try_refl_tac"
- npow_succ' : (∀ (n : ℕ) (x : M), cancel_monoid.npow n.succ x = x * cancel_monoid.npow n x) . "try_refl_tac"
- mul_right_cancel : ∀ (a b c : M), a * b = c * b → a = c
A monoid in which multiplication is cancellative.
- add : M → M → M
- add_assoc : ∀ (a b c : M), a + b + c = a + (b + c)
- add_left_cancel : ∀ (a b c : M), a + b = a + c → b = c
- zero : M
- zero_add : ∀ (a : M), 0 + a = a
- add_zero : ∀ (a : M), a + 0 = a
- nsmul : ℕ → M → M
- nsmul_zero' : (∀ (x : M), add_cancel_comm_monoid.nsmul 0 x = 0) . "try_refl_tac"
- nsmul_succ' : (∀ (n : ℕ) (x : M), add_cancel_comm_monoid.nsmul n.succ x = x + add_cancel_comm_monoid.nsmul n x) . "try_refl_tac"
- add_comm : ∀ (a b : M), a + b = b + a
Commutative version of add_cancel_monoid.
- mul : M → M → M
- mul_assoc : ∀ (a b c : M), (a * b) * c = a * b * c
- mul_left_cancel : ∀ (a b c : M), a * b = a * c → b = c
- one : M
- one_mul : ∀ (a : M), 1 * a = a
- mul_one : ∀ (a : M), a * 1 = a
- npow : ℕ → M → M
- npow_zero' : (∀ (x : M), cancel_comm_monoid.npow 0 x = 1) . "try_refl_tac"
- npow_succ' : (∀ (n : ℕ) (x : M), cancel_comm_monoid.npow n.succ x = x * cancel_comm_monoid.npow n x) . "try_refl_tac"
- mul_comm : ∀ (a b : M), a * b = b * a
Commutative version of cancel_monoid.
Equations
- cancel_comm_monoid.to_cancel_monoid M = {mul := cancel_comm_monoid.mul _inst_1, mul_assoc := _, mul_left_cancel := _, one := cancel_comm_monoid.one _inst_1, one_mul := _, mul_one := _, npow := cancel_comm_monoid.npow _inst_1, npow_zero' := _, npow_succ' := _, mul_right_cancel := _}
Equations
- add_cancel_comm_monoid.to_cancel_add_monoid M = {add := add_cancel_comm_monoid.add _inst_1, add_assoc := _, add_left_cancel := _, zero := add_cancel_comm_monoid.zero _inst_1, zero_add := _, add_zero := _, nsmul := add_cancel_comm_monoid.nsmul _inst_1, nsmul_zero' := _, nsmul_succ' := _, add_right_cancel := _}
The fundamental power operation in a group. zpow_rec n a = a*a*...*a
n times, for integer n
.
Use instead a ^ n
, which has better definitional behavior.
The fundamental scalar multiplication in an additive group. zsmul_rec n a = a+a+...+a
n
times, for integer n
. Use instead n • a
, which has better definitional behavior.
- mul : G → G → G
- mul_assoc : ∀ (a b c : G), (a * b) * c = a * b * c
- one : G
- one_mul : ∀ (a : G), 1 * a = a
- mul_one : ∀ (a : G), a * 1 = a
- npow : ℕ → G → G
- npow_zero' : (∀ (x : G), div_inv_monoid.npow 0 x = 1) . "try_refl_tac"
- npow_succ' : (∀ (n : ℕ) (x : G), div_inv_monoid.npow n.succ x = x * div_inv_monoid.npow n x) . "try_refl_tac"
- inv : G → G
- div : G → G → G
- div_eq_mul_inv : (∀ (a b : G), a / b = a * b⁻¹) . "try_refl_tac"
- zpow : ℤ → G → G
- zpow_zero' : (∀ (a : G), div_inv_monoid.zpow 0 a = 1) . "try_refl_tac"
- zpow_succ' : (∀ (n : ℕ) (a : G), div_inv_monoid.zpow (int.of_nat n.succ) a = a * div_inv_monoid.zpow (int.of_nat n) a) . "try_refl_tac"
- zpow_neg' : (∀ (n : ℕ) (a : G), div_inv_monoid.zpow -[1+ n] a = (div_inv_monoid.zpow ↑(n.succ) a)⁻¹) . "try_refl_tac"
A div_inv_monoid
is a monoid
with operations /
and ⁻¹
satisfying
div_eq_mul_inv : ∀ a b, a / b = a * b⁻¹
.
This is the immediate common ancestor of group
and group_with_zero
,
in order to deduplicate 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, has_div (foo X)
instance but no
∀ X, has_inv (foo X)
, e.g. when foo X
is a euclidean_domain
. Suppose we
also have an instance ∀ X [cromulent X], group_with_zero (foo X)
. Then the
(/)
coming from group_with_zero_has_div
cannot be definitionally equal to
the (/)
coming from foo.has_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
- group.to_div_inv_monoid
- group_with_zero.to_div_inv_monoid
- division_ring.to_div_inv_monoid
- field.to_div_inv_monoid
- multiplicative.div_inv_monoid
- with_zero.div_inv_monoid
- mul_opposite.div_inv_monoid
- add_opposite.div_inv_monoid
- prod.div_inv_monoid
- order_dual.div_inv_monoid
- pi.div_inv_monoid
- conj_act.div_inv_monoid
- filter.div_inv_monoid
- filter.div_inv_monoid'
- ennreal.div_inv_monoid
- finset.div_inv_monoid
- finset.div_inv_monoid'
- set.div_inv_monoid
- set.div_inv_monoid'
- add : G → G → G
- add_assoc : ∀ (a b c : G), a + b + c = a + (b + c)
- zero : G
- zero_add : ∀ (a : G), 0 + a = a
- add_zero : ∀ (a : G), a + 0 = a
- nsmul : ℕ → G → G
- nsmul_zero' : (∀ (x : G), sub_neg_monoid.nsmul 0 x = 0) . "try_refl_tac"
- nsmul_succ' : (∀ (n : ℕ) (x : G), sub_neg_monoid.nsmul n.succ x = x + sub_neg_monoid.nsmul n x) . "try_refl_tac"
- neg : G → G
- sub : G → G → G
- sub_eq_add_neg : (∀ (a b : G), a - b = a + -b) . "try_refl_tac"
- zsmul : ℤ → G → G
- zsmul_zero' : (∀ (a : G), sub_neg_monoid.zsmul 0 a = 0) . "try_refl_tac"
- zsmul_succ' : (∀ (n : ℕ) (a : G), sub_neg_monoid.zsmul (int.of_nat n.succ) a = a + sub_neg_monoid.zsmul (int.of_nat n) a) . "try_refl_tac"
- zsmul_neg' : (∀ (n : ℕ) (a : G), sub_neg_monoid.zsmul -[1+ n] a = -sub_neg_monoid.zsmul ↑(n.succ) a) . "try_refl_tac"
A sub_neg_monoid
is an add_monoid
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, has_sub (foo X)
instance but no
∀ X, has_neg (foo X)
. Suppose we also have an instance
∀ X [cromulent X], add_group (foo X)
. Then the (-)
coming from
add_group.has_sub
cannot be definitionally equal to the (-)
coming from
foo.has_sub
.
In the same way, adding a zsmul
field makes it possible to avoid definitional failures
in diamonds. See the definition of add_monoid
and Note [forgetful inheritance] for more
explanations on this.
Instances
- add_group.to_sub_neg_monoid
- linear_ordered_add_comm_group_with_top.to_sub_neg_monoid
- additive.sub_neg_monoid
- mul_opposite.sub_neg_monoid
- add_opposite.sub_neg_add_monoid
- prod.sub_neg_add_monoid
- order_dual.sub_neg_add_monoid
- pi.sub_neg_add_monoid
- filter.sub_neg_add_monoid
- uniform_space.completion.sub_neg_monoid
- finset.sub_neg_add_monoid
- set.sub_neg_add_monoid
Equations
- div_inv_monoid.has_pow = {pow := λ (x : M) (n : ℤ), div_inv_monoid.zpow n x}
Equations
- sub_neg_monoid.has_scalar_int = {smul := sub_neg_monoid.zsmul _inst_1}
Auxiliary typeclass for types with an involutive has_inv
.
Auxiliary typeclass for types with an involutive has_neg
.
- mul : G → G → G
- mul_assoc : ∀ (a b c : G), (a * b) * c = a * b * c
- one : G
- one_mul : ∀ (a : G), 1 * a = a
- mul_one : ∀ (a : G), a * 1 = a
- npow : ℕ → G → G
- npow_zero' : (∀ (x : G), group.npow 0 x = 1) . "try_refl_tac"
- npow_succ' : (∀ (n : ℕ) (x : G), group.npow n.succ x = x * group.npow n x) . "try_refl_tac"
- inv : G → G
- div : G → G → G
- div_eq_mul_inv : (∀ (a b : G), a / b = a * b⁻¹) . "try_refl_tac"
- zpow : ℤ → G → G
- zpow_zero' : (∀ (a : G), group.zpow 0 a = 1) . "try_refl_tac"
- zpow_succ' : (∀ (n : ℕ) (a : G), group.zpow (int.of_nat n.succ) a = a * group.zpow (int.of_nat n) a) . "try_refl_tac"
- zpow_neg' : (∀ (n : ℕ) (a : G), group.zpow -[1+ n] a = (group.zpow ↑(n.succ) a)⁻¹) . "try_refl_tac"
- mul_left_inv : ∀ (a : G), a⁻¹ * a = 1
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.
Instances
- subgroup_class.to_group
- comm_group.to_group
- units.group
- multiplicative.group
- mul_opposite.group
- add_opposite.group
- prod.group
- rel_iso.group
- order_dual.group
- pi.group
- equiv.perm.perm_group
- mul_aut.group
- add_aut.group
- subgroup.to_group
- ring_aut.group
- linear_equiv.automorphism_group
- con.group
- quotient_group.quotient.group
- alg_equiv.aut
- category_theory.End.group
- category_theory.Aut.group
- Group.group
- submonoid.is_unit.submonoid.group
- conj_act.group
- continuous_linear_equiv.automorphism_group
- free_group.group
- G_K.group
- G_K_ab.group
- add : A → A → A
- add_assoc : ∀ (a b c : A), a + b + c = a + (b + c)
- zero : A
- zero_add : ∀ (a : A), 0 + a = a
- add_zero : ∀ (a : A), a + 0 = a
- nsmul : ℕ → A → A
- nsmul_zero' : (∀ (x : A), add_group.nsmul 0 x = 0) . "try_refl_tac"
- nsmul_succ' : (∀ (n : ℕ) (x : A), add_group.nsmul n.succ x = x + add_group.nsmul n x) . "try_refl_tac"
- neg : A → A
- sub : A → A → A
- sub_eq_add_neg : (∀ (a b : A), a - b = a + -b) . "try_refl_tac"
- zsmul : ℤ → A → A
- zsmul_zero' : (∀ (a : A), add_group.zsmul 0 a = 0) . "try_refl_tac"
- zsmul_succ' : (∀ (n : ℕ) (a : A), add_group.zsmul (int.of_nat n.succ) a = a + add_group.zsmul (int.of_nat n) a) . "try_refl_tac"
- zsmul_neg' : (∀ (n : ℕ) (a : A), add_group.zsmul -[1+ n] a = -add_group.zsmul ↑(n.succ) a) . "try_refl_tac"
- add_left_neg : ∀ (a : A), -a + a = 0
An add_group
is an add_monoid
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.
Instances
- add_subgroup_class.to_add_group
- add_comm_group.to_add_group
- add_units.add_group
- additive.add_group
- mul_opposite.add_group
- add_opposite.add_group
- prod.add_group
- order_dual.add_group
- pi.add_group
- int.add_group
- rat.add_group
- add_subgroup.to_add_group
- finsupp.add_group
- add_con.add_group
- quotient_add_group.add_group
- dfinsupp.add_group
- matrix.add_group
- AddGroup.add_group
- add_submonoid.is_unit.submonoid.add_group
- uniform_space.completion.add_group
- real.add_group
- mv_power_series.add_group
- power_series.add_group
- hahn_series.add_group
- dmatrix.add_group
Abbreviation for @div_inv_monoid.to_monoid _ (@group.to_div_inv_monoid _ _)
.
Useful because it corresponds to the fact that Grp
is a subcategory of Mon
.
Not an instance since it duplicates @div_inv_monoid.to_monoid _ (@group.to_div_inv_monoid _ _)
.
See note [reducible non-instances].
Equations
Equations
Equations
- group.to_has_involutive_inv = {inv := has_inv.inv (div_inv_monoid.to_has_inv G), inv_inv := _}
Equations
- group.to_cancel_monoid = {mul := group.mul _inst_1, mul_assoc := _, mul_left_cancel := _, one := group.one _inst_1, one_mul := _, mul_one := _, npow := group.npow _inst_1, npow_zero' := _, npow_succ' := _, mul_right_cancel := _}
Equations
- add_group.to_cancel_add_monoid = {add := add_group.add _inst_1, add_assoc := _, add_left_cancel := _, zero := add_group.zero _inst_1, zero_add := _, add_zero := _, nsmul := add_group.nsmul _inst_1, nsmul_zero' := _, nsmul_succ' := _, add_right_cancel := _}
- mul : G → G → G
- mul_assoc : ∀ (a b c : G), (a * b) * c = a * b * c
- one : G
- one_mul : ∀ (a : G), 1 * a = a
- mul_one : ∀ (a : G), a * 1 = a
- npow : ℕ → G → G
- npow_zero' : (∀ (x : G), comm_group.npow 0 x = 1) . "try_refl_tac"
- npow_succ' : (∀ (n : ℕ) (x : G), comm_group.npow n.succ x = x * comm_group.npow n x) . "try_refl_tac"
- inv : G → G
- div : G → G → G
- div_eq_mul_inv : (∀ (a b : G), a / b = a * b⁻¹) . "try_refl_tac"
- zpow : ℤ → G → G
- zpow_zero' : (∀ (a : G), comm_group.zpow 0 a = 1) . "try_refl_tac"
- zpow_succ' : (∀ (n : ℕ) (a : G), comm_group.zpow (int.of_nat n.succ) a = a * comm_group.zpow (int.of_nat n) a) . "try_refl_tac"
- zpow_neg' : (∀ (n : ℕ) (a : G), comm_group.zpow -[1+ n] a = (comm_group.zpow ↑(n.succ) a)⁻¹) . "try_refl_tac"
- mul_left_inv : ∀ (a : G), a⁻¹ * a = 1
- mul_comm : ∀ (a b : G), a * b = b * a
A commutative group is a group with commutative (*)
.
Instances
- subgroup_class.to_comm_group
- ordered_comm_group.to_comm_group
- units.comm_group
- multiplicative.comm_group
- mul_opposite.comm_group
- add_opposite.comm_group
- prod.comm_group
- order_dual.comm_group
- monoid_hom.comm_group
- pi.comm_group
- subgroup.to_comm_group
- subgroup.is_commutative.comm_group
- punit.comm_group
- quotient_group.has_quotient.quotient.comm_group
- CommGroup.comm_group_instance
- submonoid.is_unit.submonoid.comm_group
- abelianization.comm_group
- class_group.comm_group
- finite_idele_group'.comm_group
- number_field.I_K_f.comm_group
- number_field.I_K.comm_group
- number_field.C_K.comm_group
- function_field.I_F_f.comm_group
- function_field.I_F.comm_group
- function_field.C_F.comm_group
- add : G → G → G
- add_assoc : ∀ (a b c : G), a + b + c = a + (b + c)
- zero : G
- zero_add : ∀ (a : G), 0 + a = a
- add_zero : ∀ (a : G), a + 0 = a
- nsmul : ℕ → G → G
- nsmul_zero' : (∀ (x : G), add_comm_group.nsmul 0 x = 0) . "try_refl_tac"
- nsmul_succ' : (∀ (n : ℕ) (x : G), add_comm_group.nsmul n.succ x = x + add_comm_group.nsmul n x) . "try_refl_tac"
- neg : G → G
- sub : G → G → G
- sub_eq_add_neg : (∀ (a b : G), a - b = a + -b) . "try_refl_tac"
- zsmul : ℤ → G → G
- zsmul_zero' : (∀ (a : G), add_comm_group.zsmul 0 a = 0) . "try_refl_tac"
- zsmul_succ' : (∀ (n : ℕ) (a : G), add_comm_group.zsmul (int.of_nat n.succ) a = a + add_comm_group.zsmul (int.of_nat n) a) . "try_refl_tac"
- zsmul_neg' : (∀ (n : ℕ) (a : G), add_comm_group.zsmul -[1+ n] a = -add_comm_group.zsmul ↑(n.succ) a) . "try_refl_tac"
- add_left_neg : ∀ (a : G), -a + a = 0
- add_comm : ∀ (a b : G), a + b = b + a
An additive commutative group is an additive group with commutative (+)
.
Instances
- add_subgroup_class.to_add_comm_group
- non_unital_non_assoc_ring.to_add_comm_group
- ring.to_add_comm_group
- ordered_add_comm_group.to_add_comm_group
- add_group_with_zero_nhd.to_add_comm_group
- add_units.add_comm_group
- additive.add_comm_group
- mul_opposite.add_comm_group
- add_opposite.add_comm_group
- prod.add_comm_group
- order_dual.add_comm_group
- add_monoid_hom.add_comm_group
- pi.add_comm_group
- int.add_comm_group
- fin.add_comm_group
- rat.add_comm_group
- add_subgroup.to_add_comm_group
- add_subgroup.is_commutative.add_comm_group
- punit.add_comm_group
- finsupp.add_comm_group
- linear_map.add_comm_group
- quotient_add_group.add_comm_group
- submodule.add_comm_group
- dfinsupp.add_comm_group
- submodule.quotient.add_comm_group
- tensor_product.add_comm_group
- monoid_algebra.add_comm_group
- add_monoid_algebra.add_comm_group
- restrict_scalars.add_comm_group
- matrix.add_comm_group
- multilinear_map.add_comm_group
- alternating_map.add_comm_group
- AddCommGroup.add_comm_group_instance
- add_submonoid.is_unit.submonoid.add_comm_group
- continuous_linear_map.add_comm_group
- uniform_space.completion.add_comm_group
- finite_adele_ring'.add_comm_group
- real.add_comm_group
- mv_power_series.add_comm_group
- power_series.add_comm_group
- hahn_series.add_comm_group
- hahn_series.summable_family.add_comm_group
- module.dual.add_comm_group
- bilin_form.add_comm_group
- direct_sum.add_comm_group
- dmatrix.add_comm_group
- free_abelian_group.add_comm_group
- module.direct_limit.add_comm_group
- add_comm_group.direct_limit.add_comm_group
Equations
- comm_group.to_cancel_comm_monoid = {mul := comm_group.mul _inst_1, mul_assoc := _, mul_left_cancel := _, one := comm_group.one _inst_1, one_mul := _, mul_one := _, npow := comm_group.npow _inst_1, npow_zero' := _, npow_succ' := _, mul_comm := _}
Equations
- add_comm_group.to_cancel_add_comm_monoid = {add := add_comm_group.add _inst_1, add_assoc := _, add_left_cancel := _, zero := add_comm_group.zero _inst_1, zero_add := _, add_zero := _, nsmul := add_comm_group.nsmul _inst_1, nsmul_zero' := _, nsmul_succ' := _, add_comm := _}