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

feat: add Algebra.compHom and related lemma #18404

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
53 changes: 53 additions & 0 deletions Mathlib/Algebra/Algebra/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,18 @@ def RingHom.toAlgebra' {R S} [CommSemiring R] [Semiring S] (i : R →+* S)
smul_def' _ _ := rfl
toRingHom := i

/-- definition of smul of toAlgebra'-/
eric-wieser marked this conversation as resolved.
Show resolved Hide resolved
theorem RingHom.smul_toAlgebra' {R S} [CommSemiring R] [Semiring S] (i : R →+* S)
(h : ∀ c x, i c * x = x * i c) (r: R) (s: S) :
let _ := RingHom.toAlgebra' i h
r • s = i r * s := rfl

/--definition of algebraMap of toAlgebra'-/
theorem RingHom.algebraMap_toAlgebra' {R S} [CommSemiring R] [Semiring S] (i : R →+* S)
(h : ∀ c x, i c * x = x * i c) :
@algebraMap R S _ _ (i.toAlgebra' h) = i :=
rfl

/-- Creating an algebra from a morphism to a commutative semiring. -/
def RingHom.toAlgebra {R S} [CommSemiring R] [CommSemiring S] (i : R →+* S) : Algebra R S :=
i.toAlgebra' fun _ => mul_comm _
Expand Down Expand Up @@ -311,6 +323,47 @@ section

end

section compHom
variable {R : Type u} {S : Type v} (A : Type w)
[CommSemiring R] [Semiring A] [Algebra R A] [CommSemiring S]
(f : S →+* R)

/--
Compose a Algebra with a RingHom, with action f s • m.
-/
Comment on lines +332 to +334
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/--
Compose a Algebra with a RingHom, with action f s • m.
-/
/--
Compose an `Algebra` with a `RingHom`, with action `f s • m`.
This is the algebra version of `Module.compHom`.
-/

abbrev compHom: Algebra S A :=
{
(algebraMap R A).comp f with
smul := fun s x => f s • x
commutes' := fun _ _ => Algebra.commutes' _ _,
smul_def' := fun s x => smul_def (f s) x
}
yhtq marked this conversation as resolved.
Show resolved Hide resolved

theorem compHom_smul_def (s : S) (x : A):
letI := compHom A f
s • x = f s • x := by
letI := compHom A f
rw [Algebra.smul_def]
exact Eq.symm (smul_def (f s) x)

theorem compHom_algebraMap_eq :
letI := compHom A f
algebraMap S A = (algebraMap R A).comp f := rfl

theorem compHom_algebraMap_apply (s : S) :
letI := compHom A f
algebraMap S A s = (algebraMap R A) (f s) := rfl

theorem compHom_toRingHom_eq :
letI := compHom A f
(compHom A f).toRingHom = (algebraMap R A).comp f := rfl

theorem compHom_toRingHom_apply (s : S) :
letI := compHom A f
(compHom A f).toRingHom s = (algebraMap R A) (f s) := rfl
Comment on lines +341 to +362
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My inclination would be to drop these lemmas; I think since you're using abbrev above, lean will unfold them with dsimp only.


end compHom

variable (R A)

/-- The canonical ring homomorphism `algebraMap R A : R →+* A` for any `R`-algebra `A`,
Expand Down
33 changes: 33 additions & 0 deletions Mathlib/Algebra/Algebra/Equiv.lean
Original file line number Diff line number Diff line change
Expand Up @@ -812,3 +812,36 @@ def toAlgAut : G →* A ≃ₐ[R] A where
end

end MulSemiringAction

namespace AlgEquiv
section CompHom
/--
Define an equivalence of algebras in the following commutative diagram:
A₁ <------> A₂
/\ /\
| |
| |
S --------> R
Comment on lines +819 to +824
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the relation to Algebra.compHom here? Using non-canonical instances like compHom is quite unusual, so it's important to draw attention to it when it happens; especially since the docs wont show the letIs!

-/
@[simps apply symm_apply toEquiv]
def ofRingEquiv_compHom
{A₁: Type u} {A₂: Type v} {S: Type w} {R: Type u₁}
[Semiring A₁] [Semiring A₂]
[CommSemiring R] [CommSemiring S]
[Algebra R A₂] [Algebra S A₁]
(f: S →+* R) {equiv : A₁ ≃+* A₂}
(commute: ∀ x, (algebraMap R A₂) (f x) = equiv (algebraMap S A₁ x)) :
letI := Algebra.compHom A₂ f
A₁ ≃ₐ[S] A₂ :=
letI := Algebra.compHom A₂ f
{
equiv with
toFun := equiv,
invFun := equiv.symm,
commutes' := by
simp only [Algebra.compHom_algebraMap_eq, RingHom.coe_comp, Function.comp_apply]
exact (fun x => (commute x).symm)
}
Comment on lines +836 to +844
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit: This should be indented two spaces not six.


end CompHom
end AlgEquiv
Loading