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] - feat(RingTheory/PiTensorProduct): extensionality and isomorphisms #11196

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Mathlib/Algebra/Algebra/Equiv.lean
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ theorem equivCongr_trans (e₁₂ : A₁ ≃ₐ[R] A₂) (e₁₂' : A₁' ≃
rfl

/-- If an algebra morphism has an inverse, it is an algebra isomorphism. -/
@[simps]
def ofAlgHom (f : A₁ →ₐ[R] A₂) (g : A₂ →ₐ[R] A₁) (h₁ : f.comp g = AlgHom.id R A₂)
(h₂ : g.comp f = AlgHom.id R A₁) : A₁ ≃ₐ[R] A₂ :=
{ f with
Expand Down
81 changes: 81 additions & 0 deletions Mathlib/RingTheory/PiTensorProduct.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Authors: Jujian Zhang

import Mathlib.LinearAlgebra.PiTensorProduct
import Mathlib.Algebra.Algebra.Bilinear
import Mathlib.Algebra.Algebra.Equiv
import Mathlib.Data.Finset.NoncommProd

/-!
# Tensor product of `R`-algebras and rings
Expand Down Expand Up @@ -63,6 +65,15 @@ lemma mul_def (x y : ⨂[R] i, A i) : x * y = mul x y := rfl
tprod R x * tprod R y = tprod R (x * y) :=
mul_tprod_tprod x y

theorem _root_.SemiconjBy.tprod {a₁ a₂ a₃ : Π i, A i}
(ha : SemiconjBy a₁ a₂ a₃) :
SemiconjBy (tprod R a₁) (tprod R a₂) (tprod R a₃) := by
rw [SemiconjBy, tprod_mul_tprod, tprod_mul_tprod, ha]

nonrec theorem _root_.Commute.tprod {a₁ a₂ : Π i, A i} (ha : Commute a₁ a₂) :
Commute (tprod R a₁) (tprod R a₂) :=
ha.tprod

lemma smul_tprod_mul_smul_tprod (r s : R) (x y : Π i, A i) :
(r • tprod R x) * (s • tprod R y) = (r * s) • tprod R (x * y) := by
change mul _ _ = _
Expand Down Expand Up @@ -99,6 +110,14 @@ instance instNonAssocSemiring : NonAssocSemiring (⨂[R] i, A i) where
one_mul := PiTensorProduct.one_mul
mul_one := PiTensorProduct.mul_one

variable (R) in
/-- `PiTensorProduct.tprod` as a `MonoidHom`. -/
@[simps]
def tprodMonoidHom : (Π i, A i) →* ⨂[R] i, A i where
toFun := tprod R
map_one' := rfl
map_mul' x y := (tprod_mul_tprod x y).symm

end NonAssocSemiring

noncomputable section NonUnitalSemiring
Expand Down Expand Up @@ -189,6 +208,22 @@ def liftAlgHom {S : Type*} [Semiring S] [Algebra R S]
AlgHom.ofLinearMap (lift f) (show lift f (tprod R 1) = 1 by simp [one]) <|
LinearMap.map_mul_iff _ |>.mpr <| by aesop

@[simp] lemma tprod_noncommProd {κ : Type*} (s : Finset κ) (x : κ → Π i, A i) (hx) :
tprod R (s.noncommProd x hx) = s.noncommProd (fun k => tprod R (x k))
(hx.imp fun _ _ => Commute.tprod) :=
Finset.noncommProd_map s x _ (tprodMonoidHom R)

/-- To show two algebra morphisms from finite tensor products are equal, it suffices to show that
they agree on elements of the form $1 ⊗ ⋯ ⊗ a ⊗ 1 ⊗ ⋯$. -/
@[ext high]
theorem algHom_ext {S : Type*} [Finite ι] [DecidableEq ι] [Semiring S] [Algebra R S]
⦃f g : (⨂[R] i, A i) →ₐ[R] S⦄ (h : ∀ i, f.comp (singleAlgHom i) = g.comp (singleAlgHom i)) :
f = g :=
AlgHom.toLinearMap_injective <| PiTensorProduct.ext <| MultilinearMap.ext fun x =>
suffices f.toMonoidHom.comp (tprodMonoidHom R) = g.toMonoidHom.comp (tprodMonoidHom R) from
DFunLike.congr_fun this x
MonoidHom.pi_ext fun i xi => DFunLike.congr_fun (h i) xi

end Semiring

noncomputable section Ring
Expand Down Expand Up @@ -217,6 +252,52 @@ instance instCommSemiring : CommSemiring (⨂[R] i, A i) where
__ := inferInstanceAs <| AddCommMonoid (⨂[R] i, A i)
mul_comm := PiTensorProduct.mul_comm

open scoped BigOperators in
@[simp] lemma tprod_prod {κ : Type*} (s : Finset κ) (x : κ → Π i, A i) :
tprod R (∏ k in s, x k) = ∏ k in s, tprod R (x k) :=
map_prod (tprodMonoidHom R) x s

section

open BigOperators Function

variable [Fintype ι]

variable (R ι)

/--
The algebra equivalence from the tensor product of the constant family with
value `R` to `R`, given by multiplication of the entries.
-/
noncomputable def constantBaseRingEquiv : (⨂[R] _ : ι, R) ≃ₐ[R] R :=
letI toFun := lift (MultilinearMap.mkPiAlgebra R ι R)
AlgEquiv.ofAlgHom
(AlgHom.ofLinearMap
toFun
((lift.tprod _).trans Finset.prod_const_one)
(by
rw [LinearMap.map_mul_iff]
ext x y
show toFun (tprod R x * tprod R y) = toFun (tprod R x) * toFun (tprod R y)
simp_rw [tprod_mul_tprod, toFun, lift.tprod, MultilinearMap.mkPiAlgebra_apply,
Pi.mul_apply, Finset.prod_mul_distrib]))
(Algebra.ofId _ _)
(by ext)
(by classical ext)

variable {R ι}

@[simp]
theorem constantBaseRingEquiv_tprod (x : ι → R) :
constantBaseRingEquiv ι R (tprod R x) = ∏ i, x i := by
simp [constantBaseRingEquiv]

@[simp]
theorem constantBaseRingEquiv_symm (r : R) :
(constantBaseRingEquiv ι R).symm r = algebraMap _ _ r := rfl

end

end CommSemiring

noncomputable section CommRing
Expand Down
Loading