Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - refactor(Algebra/Star/*): Allow for star operation on non-associative algebras #6562

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions Mathlib/Algebra/Star/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ We introduce the basic algebraic notions of star monoids, star rings, and star m
A star algebra is simply a star ring that is also a star module.

These are implemented as "mixin" typeclasses, so to summon a star ring (for example)
one needs to write `(R : Type*) [Ring R] [StarRing R]`.
one needs to write `(R : Type*) [NonUnitalNonAssocSemiring R] [StarRing R]`.
mans0954 marked this conversation as resolved.
Show resolved Hide resolved
This avoids difficulties with diamond inheritance.

For now we simply do not introduce notations,
as different users are expected to feel strongly about the relative merits of
`r^*`, `r†`, `rᘁ`, and so on.

Our star rings are actually star semirings, but of course we can prove
Our star rings are actually star non-unital, non-associative, semirings, but of course we can prove
`star_neg : star (-r) = - star r` when the underlying semiring is a ring.
-/

Expand Down Expand Up @@ -121,8 +121,8 @@ export TrivialStar (star_trivial)

attribute [simp] star_trivial

/-- A `*`-semigroup is a semigroup `R` with an involutive operation `star`
such that `star (r * s) = star s * star r`.
/-- A `StarMul` is a type `R` with a multiplication and an involutive operation `star` such that
`star (r * s) = star s * star r`.
mans0954 marked this conversation as resolved.
Show resolved Hide resolved
-/
class StarMul (R : Type u) [Mul R] extends InvolutiveStar R where
/-- `star` skew-distributes over multiplication. -/
Expand Down Expand Up @@ -227,17 +227,17 @@ theorem star_div [CommGroup R] [StarMul R] (x y : R) : star (x / y) = star x / s
See note [reducible non-instances].
-/
@[reducible]
def starSemigroupOfComm {R : Type*} [CommMonoid R] : StarMul R where
def starMulOfComm {R : Type*} [CommMonoid R] : StarMul R where
star := id
star_involutive _ := rfl
star_mul := mul_comm
#align star_semigroup_of_comm starSemigroupOfComm
#align star_semigroup_of_comm starMulOfComm

section

attribute [local instance] starSemigroupOfComm
attribute [local instance] starMulOfComm

/-- Note that since `starSemigroupOfComm` is reducible, `simp` can already prove this. -/
/-- Note that since `starMulOfComm` is reducible, `simp` can already prove this. -/
theorem star_id_of_comm {R : Type*} [CommSemiring R] {x : R} : star x = x :=
rfl
#align star_id_of_comm star_id_of_comm
Expand Down Expand Up @@ -302,8 +302,8 @@ theorem star_zsmul [AddGroup R] [StarAddMonoid R] (x : R) (n : ℤ) : star (n
(starAddEquiv : R ≃+ R).toAddMonoidHom.map_zsmul _ _
#align star_zsmul star_zsmul

/-- A `*`-ring `R` is a (semi)ring with an involutive `star` operation which is additive
which makes `R` with its multiplicative structure into a `*`-semigroup
/-- A `*`-ring `R` is a non-unital, non-associative (semi)ring with an involutive `star` operation
which is additive which makes `R` with its multiplicative structure into a `*`-multiplication
mans0954 marked this conversation as resolved.
Show resolved Hide resolved
(i.e. `star (r * s) = star s * star r`). -/
class StarRing (R : Type u) [NonUnitalNonAssocSemiring R] extends StarMul R where
/-- `star` commutes with addition -/
Expand Down Expand Up @@ -459,7 +459,7 @@ See note [reducible non-instances].
-/
@[reducible]
def starRingOfComm {R : Type*} [CommSemiring R] : StarRing R :=
{ starSemigroupOfComm with
{ starMulOfComm with
star := id
star_add := fun _ _ => rfl }
#align star_ring_of_comm starRingOfComm
Expand Down
10 changes: 6 additions & 4 deletions Mathlib/Algebra/Star/NonUnitalSubalgebra.lean
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ instance instInvolutiveStar {S R : Type*} [InvolutiveStar R] [SetLike S R] [Star
(s : S) : InvolutiveStar s where
star_involutive r := Subtype.ext <| star_star (r : R)

/-- In a star semigroup (i.e., a semigroup with an antimultiplicative involutive star operation),
any star-closed subset which is also closed under multiplication is itself a star semigroup. -/
/-- In a star multiplication (i.e., a multiplication with an antimultiplicative involutive star
operation), any star-closed subset which is also closed under multiplication is itself a star
multiplication. -/
mans0954 marked this conversation as resolved.
Show resolved Hide resolved
instance instStarMul {S R : Type*} [Mul R] [StarMul R] [SetLike S R]
[MulMemClass S R] [StarMemClass S R] (s : S) : StarMul s where
star_mul _ _ := Subtype.ext <| star_mul _ _
Expand All @@ -39,8 +40,9 @@ instance instStarAddMonoid {S R : Type*} [AddMonoid R] [StarAddMonoid R] [SetLik
[AddSubmonoidClass S R] [StarMemClass S R] (s : S) : StarAddMonoid s where
star_add _ _ := Subtype.ext <| star_add _ _

/-- In a star ring (i.e., a non-unital semiring with an additive, antimultiplicative, involutive
star operation), an star-closed non-unital subsemiring is itself a star ring. -/
/-- In a star ring (i.e., a non-unital, non-associative, semiring with an additive,
antimultiplicative, involutive star operation), a star-closed non-unital subsemiring is itself a
star ring. -/
instance instStarRing {S R : Type*} [NonUnitalNonAssocSemiring R] [StarRing R] [SetLike S R]
[NonUnitalSubsemiringClass S R] [StarMemClass S R] (s : S) : StarRing s :=
{ StarMemClass.instStarMul s, StarMemClass.instStarAddMonoid s with }
Expand Down