Module docstring
{"# Algebras over commutative semirings
In this file we define associative unital Algebras over commutative (semi)rings.
algebra homomorphisms
AlgHomare defined inMathlib.Algebra.Algebra.Hom;algebra equivalences
AlgEquivare defined inMathlib.Algebra.Algebra.Equiv;Subalgebras are defined inMathlib.Algebra.Algebra.Subalgebra;The category
AlgebraCat RofR-algebras is defined in the fileMathlib.Algebra.Category.Algebra.Basic.
See the implementation notes for remarks about non-associative and non-unital algebras.
Main definitions:
Algebra R A: the algebra typeclass.algebraMap R A : R →+* A: the canonical map fromRtoA, as aRingHom. This is the preferred spelling of this map, it is also available as:Algebra.linearMap R A : R →ₗ[R] A, aLinearMap.Algebra.ofId R A : R →ₐ[R] A, anAlgHom(defined in a later file).
Implementation notes
Given a commutative (semi)ring R, there are two ways to define an R-algebra structure on a
(possibly noncommutative) (semi)ring A:
* By endowing A with a morphism of rings R →+* A denoted algebraMap R A which lands in the
center of A.
* By requiring A be an R-module such that the action associates and commutes with multiplication
as r • (a₁ * a₂) = (r • a₁) * a₂ = a₁ * (r • a₂).
We define Algebra R A in a way that subsumes both definitions, by extending SMul R A and
requiring that this scalar action r • x must agree with left multiplication by the image of the
structure morphism algebraMap R A r * x.
As a result, there are two ways to talk about an R-algebra A when A is a semiring:
1. lean
variable [CommSemiring R] [Semiring A]
variable [Algebra R A]
2. lean
variable [CommSemiring R] [Semiring A]
variable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]
The first approach implies the second via typeclass search; so any lemma stated with the second set
of arguments will automatically apply to the first set. Typeclass search does not know that the
second approach implies the first, but this can be shown with:
lean
example {R A : Type*} [CommSemiring R] [Semiring A]
[Module R A] [SMulCommClass R A A] [IsScalarTower R A A] : Algebra R A :=
Algebra.ofModule smul_mul_assoc mul_smul_comm
The advantage of the first approach is that algebraMap R A is available, and AlgHom R A B and
Subalgebra R A can be used. For concrete R and A, algebraMap R A is often definitionally
convenient.
The advantage of the second approach is that CommSemiring R, Semiring A, and Module R A can
all be relaxed independently; for instance, this allows us to:
* Replace Semiring A with NonUnitalNonAssocSemiring A in order to describe non-unital and/or
non-associative algebras.
* Replace CommSemiring R and Module R A with CommGroup R' and DistribMulAction R' A,
which when R' = Rˣ lets us talk about the \"algebra-like\" action of Rˣ on an
R-algebra A.
While AlgHom R A B cannot be used in the second approach, NonUnitalAlgHom R A B still can.
You should always use the first approach when working with associative unital algebras, and mimic
the second approach only when you need to weaken a condition on either R or A.
"}