Skip to content

Commit

Permalink
feat: Add API for AlgEquiv. (#8639)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Yang <36414270+erdOne@users.noreply.github.com>
  • Loading branch information
erdOne and erdOne committed Dec 5, 2023
1 parent 55a024a commit bcd9607
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
35 changes: 35 additions & 0 deletions Mathlib/Algebra/Algebra/Equiv.lean
Expand Up @@ -276,6 +276,10 @@ theorem coe_algHom_injective : Function.Injective ((↑) : (A₁ ≃ₐ[R] A₂)
fun _ _ h => ext <| AlgHom.congr_fun h
#align alg_equiv.coe_alg_hom_injective AlgEquiv.coe_algHom_injective

@[simp, norm_cast]
lemma toAlgHom_toRingHom : ((e : A₁ →ₐ[R] A₂) : A₁ →+* A₂) = e :=
rfl

/-- The two paths coercion can take to a `RingHom` are equivalent -/
theorem coe_ringHom_commutes : ((e : A₁ →ₐ[R] A₂) : A₁ →+* A₂) = ((e : A₁ ≃+* A₂) : A₁ →+* A₂) :=
rfl
Expand Down Expand Up @@ -785,6 +789,37 @@ theorem algebraMap_eq_apply (e : A₁ ≃ₐ[R] A₂) {y : R} {x : A₁} :
e.toAlgHom.algebraMap_eq_apply h⟩
#align alg_equiv.algebra_map_eq_apply AlgEquiv.algebraMap_eq_apply

/-- `AlgEquiv.toLinearMap` as a `MonoidHom`. -/
@[simps]
def toLinearMapHom (R A) [CommSemiring R] [Semiring A] [Algebra R A] :
(A ≃ₐ[R] A) →* A →ₗ[R] A where
toFun := AlgEquiv.toLinearMap
map_one' := rfl
map_mul' := fun _ _ ↦ rfl

lemma pow_toLinearMap (σ : A₁ ≃ₐ[R] A₁) (n : ℕ) :
(σ ^ n).toLinearMap = σ.toLinearMap ^ n :=
(AlgEquiv.toLinearMapHom R A₁).map_pow σ n

@[simp]
lemma one_toLinearMap :
(1 : A₁ ≃ₐ[R] A₁).toLinearMap = 1 := rfl

/-- The units group of `S →ₐ[R] S` is `S ≃ₐ[R] S`.
See `LinearMap.GeneralLinearGroup.generalLinearEquiv` for the linear map version. -/
@[simps]
def algHomUnitsEquiv (R S : Type*) [CommSemiring R] [Semiring S] [Algebra R S] :
(S →ₐ[R] S)ˣ ≃* (S ≃ₐ[R] S) where
toFun := fun f ↦
{ (f : S →ₐ[R] S) with
invFun := ↑(f⁻¹)
left_inv := (fun x ↦ show (↑(f⁻¹ * f) : S →ₐ[R] S) x = x by rw [inv_mul_self]; rfl)
right_inv := (fun x ↦ show (↑(f * f⁻¹) : S →ₐ[R] S) x = x by rw [mul_inv_self]; rfl) }
invFun := fun f ↦ ⟨f, f.symm, f.comp_symm, f.symm_comp⟩
left_inv := fun _ ↦ rfl
right_inv := fun _ ↦ rfl
map_mul' := fun _ _ ↦ rfl

end Semiring

section CommSemiring
Expand Down
4 changes: 4 additions & 0 deletions Mathlib/Algebra/Algebra/Hom.lean
Expand Up @@ -509,6 +509,10 @@ def toIntAlgHom [Ring R] [Ring S] [Algebra ℤ R] [Algebra ℤ S] (f : R →+* S
{ f with commutes' := fun n => by simp }
#align ring_hom.to_int_alg_hom RingHom.toIntAlgHom

lemma toIntAlgHom_injective [Ring R] [Ring S] [Algebra ℤ R] [Algebra ℤ S] :
Function.Injective (RingHom.toIntAlgHom : (R →+* S) → _) :=
fun _ _ e ↦ FunLike.ext _ _ (fun x ↦ FunLike.congr_fun e x)

/-- Reinterpret a `RingHom` as a `ℚ`-algebra homomorphism. This actually yields an equivalence,
see `RingHom.equivRatAlgHom`. -/
def toRatAlgHom [Ring R] [Ring S] [Algebra ℚ R] [Algebra ℚ S] (f : R →+* S) : R →ₐ[ℚ] S :=
Expand Down
5 changes: 5 additions & 0 deletions Mathlib/Algebra/Group/Equiv/Basic.lean
Expand Up @@ -192,6 +192,11 @@ def MulEquivClass.toMulEquiv [Mul α] [Mul β] [MulEquivClass F α β] (f : F) :
instance [Mul α] [Mul β] [MulEquivClass F α β] : CoeTC F (α ≃* β) :=
⟨MulEquivClass.toMulEquiv⟩

@[to_additive]
theorem MulEquivClass.toMulEquiv_injective [Mul α] [Mul β] [MulEquivClass F α β] :
Function.Injective ((↑) : F → α ≃* β) :=
fun _ _ e ↦ FunLike.ext _ _ <| fun a ↦ congr_arg (fun e : α ≃* β ↦ e.toFun a) e

namespace MulEquiv

@[to_additive]
Expand Down
4 changes: 4 additions & 0 deletions Mathlib/Logic/Equiv/Defs.lean
Expand Up @@ -106,6 +106,10 @@ instance : EquivLike (α ≃ β) α β where
instance : FunLike (α ≃ β) α (fun _ => β) :=
EmbeddingLike.toFunLike

@[simp, norm_cast]
lemma _root_.EquivLike.coe_coe {F} [EquivLike F α β] (e : F) :
((e : α ≃ β) : α → β) = e := rfl

@[simp] theorem coe_fn_mk (f : α → β) (g l r) : (Equiv.mk f g l r : α → β) = f :=
rfl
#align equiv.coe_fn_mk Equiv.coe_fn_mk
Expand Down
4 changes: 2 additions & 2 deletions Mathlib/RepresentationTheory/Rep.lean
Expand Up @@ -686,7 +686,7 @@ def counitIso (M : ModuleCat.{u} (MonoidAlgebra k G)) :
map_smul' := fun r x => by
dsimp [counitIsoAddEquiv]
/- Porting note: rest of broken proof was `simp`. -/
rw [AddEquiv.coe_toEquiv, AddEquiv.trans_apply]
rw [AddEquiv.trans_apply]
rw [AddEquiv.trans_apply]
erw [@Representation.ofModule_asAlgebraHom_apply_apply k G _ _ _ _ (_)]
exact AddEquiv.symm_apply_apply _ _}
Expand Down Expand Up @@ -716,7 +716,7 @@ def unitIso (V : Rep k G) : V ≅ (toModuleMonoidAlgebra ⋙ ofModuleMonoidAlgeb
simp only [Representation.asModuleEquiv_symm_map_smul,
RestrictScalars.addEquiv_symm_map_algebraMap_smul] -/
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [AddEquiv.coe_toEquiv, AddEquiv.trans_apply,
erw [AddEquiv.trans_apply,
Representation.asModuleEquiv_symm_map_smul]
rfl })
fun g => by ext; apply unit_iso_comm
Expand Down

0 comments on commit bcd9607

Please sign in to comment.