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(Mathlib.RingTheory.TensorProduct.MvPolynomial) : tensor product of a (multivariate) polynomial ring #12293

Closed
wants to merge 83 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
d8e50fc
generalize to CommSemiring / AddCommMonoid
Feb 21, 2024
fa4cb7e
generalize to CommSemiring / AddCommMonoid
Feb 21, 2024
53ee15d
add finsupp_sum_tmul and 3 variants
Feb 21, 2024
d55ac1e
revert
Feb 21, 2024
2f1ebe7
rename (temp)
Feb 21, 2024
c28b2e6
something working
Feb 21, 2024
2320a61
lint 100
Feb 21, 2024
1fdd0aa
revert the generalization (-> AddCommGroup/CommSemiring in the initia…
Feb 21, 2024
d76a5a9
rename following EW's suggestion
Feb 21, 2024
423a61d
namespace TensorProduct
Feb 21, 2024
2efdc69
add docstring
Feb 21, 2024
98b197b
update Mathlib.lean
Feb 21, 2024
7f13321
update Mathlib.lean
Feb 21, 2024
aa3eaf6
better inferface for polynomial (via finsuppScalarLeft)
Feb 22, 2024
3e12239
add letI in RingTheory/Flat/Basic
Feb 22, 2024
8458d4e
adjust `simp` to make Lie/TensorProduct compile
Feb 22, 2024
e259731
remove useless import
Feb 22, 2024
2e74096
Merge branch 'master' into ACL/FinsuppTensorProd
eric-wieser Feb 23, 2024
19af3b0
re-add variable
Feb 23, 2024
d26f775
remove multiplicativity (doesn't work yet)
Feb 23, 2024
660e471
Update Mathlib/LinearAlgebra/DirectSum/Finsupp.lean
AntoineChambert-Loir Feb 23, 2024
65e6c20
add finsuppScalarRight
Feb 23, 2024
a7b0441
add TensorProduct of MonoidAlgebra
Feb 23, 2024
8af8487
add docstring
Feb 23, 2024
4f65f96
add docstrings for definitions
Feb 23, 2024
b1742d9
lint100
Feb 23, 2024
85b2839
update Mathlib.lean
Feb 23, 2024
3fb1a0a
add "todo" note
Feb 23, 2024
c375537
do the construction in the other directions (using AlgebraTensorProduct)
Feb 24, 2024
e296050
small progress
Feb 24, 2024
ef9a571
delete garbage
Feb 24, 2024
6c74740
remove bad "end"
Feb 24, 2024
d9ce8e2
Algebra for MvPolynomial
Feb 24, 2024
ec42703
cleanup
Feb 25, 2024
d7c43b0
cleanup
Feb 25, 2024
32d9c2e
move files
Feb 25, 2024
417d963
adjust Mathlib.lean
Feb 25, 2024
337b52a
equiv for polynomial
Feb 25, 2024
5a5f1a9
shorten some lines; review-dog
Feb 25, 2024
cdc4ef9
linter 100
Feb 25, 2024
5112ca4
dedup namespace
Feb 25, 2024
47a6c00
Merge branch 'master' into ACL/FinsuppTensorProd
Feb 29, 2024
746bb43
Do what review dog suggests
AntoineChambert-Loir Feb 29, 2024
20c8b2d
generalize Monoid to MulOneClass
Feb 29, 2024
1665702
add docstrings
Feb 29, 2024
f0a5d8b
add docstrings
Feb 29, 2024
fc8f0d1
one more doctring
Feb 29, 2024
0e751b9
yet another docstring
Feb 29, 2024
d3ade35
docstring : change i to iota (3 lines)
Feb 29, 2024
87d6d87
lint 100
Feb 29, 2024
cdfd7b1
remove unused equiv
Feb 29, 2024
91c0278
Merge branch 'master' into ACL/FinsuppTensorProd
Mar 13, 2024
c2496b2
Update Mathlib/Algebra/Lie/TensorProduct.lean
AntoineChambert-Loir Mar 13, 2024
02e19a6
change import in 3 files
Mar 13, 2024
073c214
correct badly formed import line
Mar 13, 2024
47be110
import lines were still wrong…
Mar 13, 2024
119763f
that should be good…
Mar 13, 2024
c16067f
generalize one universe
AntoineChambert-Loir Mar 21, 2024
845bb95
add MvPolynomial.lcoeff
AntoineChambert-Loir Mar 21, 2024
8004cfc
add lemmas
AntoineChambert-Loir Mar 21, 2024
de94570
indent correctly
AntoineChambert-Loir Mar 21, 2024
cfa238f
correct the unfinished proof
AntoineChambert-Loir Mar 21, 2024
aa4b9a4
Merge branch 'master' into ACL/FinsuppTensorProd
AntoineChambert-Loir Apr 9, 2024
f3d3ee2
adjust MvPolynomial to merged version of finsupptensorprod
AntoineChambert-Loir Apr 9, 2024
df63d70
mv two lemmas to Data/Finsupp
AntoineChambert-Loir Apr 9, 2024
8d31f5d
add explicit arguments
AntoineChambert-Loir Apr 9, 2024
f1719b8
Replace noisy `simp?`
ocfnash Apr 10, 2024
c724436
Merge branch 'master' into ACL/FinsuppTensorProd
AntoineChambert-Loir Apr 11, 2024
31e2899
Merge branch 'ACL/FinsuppTensorProd' into ACL/FinsuppTensorProdMvPoly…
AntoineChambert-Loir Apr 20, 2024
394b285
initial commit
AntoineChambert-Loir Apr 20, 2024
95f1ad3
follow suggestions
AntoineChambert-Loir Apr 21, 2024
ed28368
make one lemma simps and delete the one that is now generated
AntoineChambert-Loir Apr 21, 2024
12426ac
delete one lemma that is obtained by two existing simp lemmas
AntoineChambert-Loir Apr 21, 2024
be85260
use monoidhomclass
AntoineChambert-Loir Apr 21, 2024
0c364ae
Merge branch 'master' into ACL/FinsuppTensorProdMvPolynomial
AntoineChambert-Loir May 4, 2024
118c80a
minor generalizations
AntoineChambert-Loir May 4, 2024
c9ac993
Revert "minor generalizations"
AntoineChambert-Loir May 4, 2024
7abb26e
update
AntoineChambert-Loir May 4, 2024
3f4b748
revert modif in Lie
AntoineChambert-Loir May 4, 2024
554fdf4
use "variable (R) in"…
AntoineChambert-Loir May 4, 2024
b583540
udpate docstring
AntoineChambert-Loir May 4, 2024
42a2dab
de-simp lemmas that make the simpNF linter complain
AntoineChambert-Loir May 4, 2024
e729f94
Update Mathlib/RingTheory/TensorProduct/MvPolynomial.lean
AntoineChambert-Loir Jun 4, 2024
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.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3534,6 +3534,7 @@ import Mathlib.RingTheory.RootsOfUnity.Minpoly
import Mathlib.RingTheory.SimpleModule
import Mathlib.RingTheory.Smooth.Basic
import Mathlib.RingTheory.TensorProduct.Basic
import Mathlib.RingTheory.TensorProduct.MvPolynomial
import Mathlib.RingTheory.Trace
import Mathlib.RingTheory.UniqueFactorizationDomain
import Mathlib.RingTheory.Unramified.Basic
Expand Down
8 changes: 8 additions & 0 deletions Mathlib/Algebra/MvPolynomial/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,14 @@ def coeffAddMonoidHom (m : σ →₀ ℕ) : MvPolynomial σ R →+ R
map_add' := coeff_add m
#align mv_polynomial.coeff_add_monoid_hom MvPolynomial.coeffAddMonoidHom

variable (R) in
/-- `MvPolynomial.coeff m` but promoted to a `LinearMap`. -/
@[simps]
def lcoeff (m : σ →₀ ℕ) : MvPolynomial σ R →ₗ[R] R where
AntoineChambert-Loir marked this conversation as resolved.
Show resolved Hide resolved
toFun := coeff m
map_add' := coeff_add m
map_smul' := coeff_smul m

theorem coeff_sum {X : Type*} (s : Finset X) (f : X → MvPolynomial σ R) (m : σ →₀ ℕ) :
coeff m (∑ x in s, f x) = ∑ x in s, coeff m (f x) :=
map_sum (@coeffAddMonoidHom R σ _ _) _ s
Expand Down
8 changes: 8 additions & 0 deletions Mathlib/Data/Finsupp/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,14 @@ theorem unique_single_eq_iff [Unique α] {b' : M} : single a b = single a' b'
rw [unique_ext_iff, Unique.eq_default a, Unique.eq_default a', single_eq_same, single_eq_same]
#align finsupp.unique_single_eq_iff Finsupp.unique_single_eq_iff

lemma apply_single [AddCommMonoid N] [AddCommMonoid P]
{F : Type*} [FunLike F N P] [AddMonoidHomClass F N P] (e : F)
(a : α) (n : N) (b : α) :
e ((single a n) b) = single a (e n) b := by
classical
simp only [single_apply]
split_ifs; rfl; exact map_zero e

theorem support_eq_singleton {f : α →₀ M} {a : α} :
f.support = {a} ↔ f a ≠ 0 ∧ f = single a (f a) :=
⟨fun h =>
Expand Down
193 changes: 193 additions & 0 deletions Mathlib/RingTheory/TensorProduct/MvPolynomial.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
/-
Copyright (c) 2024 Antoine Chambert-Loir. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Antoine Chambert-Loir
-/

import Mathlib.LinearAlgebra.DirectSum.Finsupp
import Mathlib.Algebra.MvPolynomial.Basic
import Mathlib.RingTheory.TensorProduct.Basic
import Mathlib.Algebra.MvPolynomial.Equiv
/-!

# Tensor Product of (multivariate) polynomial rings

Let `Semiring R`, `Algebra R S` and `Module R N`.

* `MvPolynomial.rTensor` gives the linear equivalence
`MvPolynomial σ S ⊗[R] N ≃ₗ[R] (σ →₀ ℕ) →₀ (S ⊗[R] N)` characterized,
for `p : MvPolynomial σ S`, `n : N` and `d : σ →₀ ℕ`, by
`rTensor (p ⊗ₜ[R] n) d = (coeff d p) ⊗ₜ[R] n`
* `MvPolynomial.scalarRTensor` gives the linear equivalence
`MvPolynomial σ R ⊗[R] N ≃ₗ[R] (σ →₀ ℕ) →₀ N`
such that `MvPolynomial.scalarRTensor (p ⊗ₜ[R] n) d = coeff d p • n`
for `p : MvPolynomial σ R`, `n : N` and `d : σ →₀ ℕ`, by

* `MvPolynomial.rTensorAlgHom`, the algebra morphism from the tensor product
of a polynomial algebra by an algebra to a polynomial algebra
* `MvPolynomial.rTensorAlgEquiv`, `MvPolynomial.scalarRTensorAlgEquiv`,
the tensor product of a polynomial algebra by an algebra
is algebraically equivalent to a polynomial algebra

## TODO :
* `MvPolynomial.rTensor` could be phrased in terms of `AddMonoidAlgebra`, and
`MvPolynomial.rTensor` then has `smul` by the polynomial algebra.
* `MvPolynomial.rTensorAlgHom` and `MvPolynomial.scalarRTensorAlgEquiv`
are morphisms for the algebra structure by `MvPolynomial σ R`.
-/


universe u v w

noncomputable section

namespace MvPolynomial

open DirectSum TensorProduct

open Set LinearMap Submodule

variable {R : Type u} {M : Type v} {N : Type w}
[CommSemiring R] [AddCommMonoid M] [Module R M]

variable {σ : Type*} [DecidableEq σ]

variable {S : Type*} [CommSemiring S] [Algebra R S]

section Module

variable [AddCommMonoid N] [Module R N]

/-- The tensor product of a polynomial ring by a module is
linearly equivalent to a Finsupp of a tensor product -/
noncomputable def rTensor :
MvPolynomial σ S ⊗[R] N ≃ₗ[S] (σ →₀ ℕ) →₀ (S ⊗[R] N) :=
TensorProduct.finsuppLeft' _ _ _ _ _

lemma rTensor_apply_tmul (p : MvPolynomial σ S) (n : N) :
rTensor (p ⊗ₜ[R] n) = p.sum (fun i m ↦ Finsupp.single i (m ⊗ₜ[R] n)) :=
TensorProduct.finsuppLeft_apply_tmul p n

lemma rTensor_apply_tmul_apply (p : MvPolynomial σ S) (n : N) (d : σ →₀ ℕ) :
rTensor (p ⊗ₜ[R] n) d = (coeff d p) ⊗ₜ[R] n :=
TensorProduct.finsuppLeft_apply_tmul_apply p n d
AntoineChambert-Loir marked this conversation as resolved.
Show resolved Hide resolved

lemma rTensor_apply_monomial_tmul (e : σ →₀ ℕ) (s : S) (n : N) (d : σ →₀ ℕ) :
rTensor (monomial e s ⊗ₜ[R] n) d = if e = d then s ⊗ₜ[R] n else 0 := by
simp only [rTensor_apply_tmul_apply, coeff_monomial, ite_tmul]

lemma rTensor_apply_X_tmul (s : σ) (n : N) (d : σ →₀ ℕ) :
rTensor (X s ⊗ₜ[R] n) d = if Finsupp.single s 1 = d then (1 : S) ⊗ₜ[R] n else 0 := by
rw [rTensor_apply_tmul_apply, coeff_X', ite_tmul]

lemma rTensor_apply (t : MvPolynomial σ S ⊗[R] N) (d : σ →₀ ℕ) :
rTensor t d = ((lcoeff S d).restrictScalars R).rTensor N t :=
TensorProduct.finsuppLeft_apply t d

@[simp]
lemma rTensor_symm_apply_single (d : σ →₀ ℕ) (s : S) (n : N) :
rTensor.symm (Finsupp.single d (s ⊗ₜ n)) =
(monomial d s) ⊗ₜ[R] n :=
TensorProduct.finsuppLeft_symm_apply_single (R := R) d s n

/-- The tensor product of the polynomial algebra by a module
is linearly equivalent to a Finsupp of that module -/
noncomputable def scalarRTensor :
MvPolynomial σ R ⊗[R] N ≃ₗ[R] (σ →₀ ℕ) →₀ N :=
TensorProduct.finsuppScalarLeft _ _ _

lemma scalarRTensor_apply_tmul (p : MvPolynomial σ R) (n : N) :
scalarRTensor (p ⊗ₜ[R] n) = p.sum (fun i m ↦ Finsupp.single i (m • n)) :=
TensorProduct.finsuppScalarLeft_apply_tmul p n

lemma scalarRTensor_apply_tmul_apply (p : MvPolynomial σ R) (n : N) (d : σ →₀ ℕ):
scalarRTensor (p ⊗ₜ[R] n) d = coeff d p • n :=
TensorProduct.finsuppScalarLeft_apply_tmul_apply p n d

lemma scalarRTensor_apply_monomial_tmul (e : σ →₀ ℕ) (r : R) (n : N) (d : σ →₀ ℕ):
scalarRTensor (monomial e r ⊗ₜ[R] n) d = if e = d then r • n else 0 := by
rw [scalarRTensor_apply_tmul_apply, coeff_monomial, ite_smul, zero_smul]

lemma scalarRTensor_apply_X_tmul_apply (s : σ) (n : N) (d : σ →₀ ℕ):
scalarRTensor (X s ⊗ₜ[R] n) d = if Finsupp.single s 1 = d then n else 0 := by
rw [scalarRTensor_apply_tmul_apply, coeff_X', ite_smul, one_smul, zero_smul]

lemma scalarRTensor_symm_apply_single (d : σ →₀ ℕ) (n : N) :
scalarRTensor.symm (Finsupp.single d n) = (monomial d 1) ⊗ₜ[R] n :=
TensorProduct.finsuppScalarLeft_symm_apply_single d n

end Module

section Algebra

variable [CommSemiring N] [Algebra R N]

/-- The algebra morphism from a tensor product of a polynomial algebra
by an algebra to a polynomial algebra -/
noncomputable def rTensorAlgHom :
(MvPolynomial σ S) ⊗[R] N →ₐ[S] MvPolynomial σ (S ⊗[R] N) :=
Algebra.TensorProduct.lift
(mapAlgHom Algebra.TensorProduct.includeLeft)
((IsScalarTower.toAlgHom R (S ⊗[R] N) _).comp Algebra.TensorProduct.includeRight)
(fun p n => by simp [commute_iff_eq, algebraMap_eq, mul_comm])

@[simp]
lemma coeff_rTensorAlgHom_tmul
(p : MvPolynomial σ S) (n : N) (d : σ →₀ ℕ) :
coeff d (rTensorAlgHom (p ⊗ₜ[R] n)) = (coeff d p) ⊗ₜ[R] n := by
rw [rTensorAlgHom, Algebra.TensorProduct.lift_tmul]
rw [AlgHom.coe_comp, IsScalarTower.coe_toAlgHom', Function.comp_apply,
Algebra.TensorProduct.includeRight_apply]
rw [algebraMap_eq, mul_comm, coeff_C_mul]
simp [mapAlgHom, coeff_map]

lemma coeff_rTensorAlgHom_monomial_tmul
(e : σ →₀ ℕ) (s : S) (n : N) (d : σ →₀ ℕ) :
coeff d (rTensorAlgHom (monomial e s ⊗ₜ[R] n)) =
if e = d then s ⊗ₜ[R] n else 0 := by
simp [ite_tmul]

lemma rTensorAlgHom_toLinearMap :
(rTensorAlgHom :
MvPolynomial σ S ⊗[R] N →ₐ[S] MvPolynomial σ (S ⊗[R] N)).toLinearMap =
rTensor.toLinearMap := by
ext d n e
dsimp only [AlgebraTensorModule.curry_apply, TensorProduct.curry_apply,
LinearMap.coe_restrictScalars, AlgHom.toLinearMap_apply]
simp only [coe_comp, Function.comp_apply, AlgebraTensorModule.curry_apply, curry_apply,
LinearMap.coe_restrictScalars, AlgHom.toLinearMap_apply]
rw [coeff_rTensorAlgHom_tmul]
simp only [coeff]
erw [finsuppLeft_apply_tmul_apply]

lemma rTensorAlgHom_apply_eq (p : MvPolynomial σ S ⊗[R] N) :
rTensorAlgHom (S := S) p = rTensor p := by
rw [← AlgHom.toLinearMap_apply, rTensorAlgHom_toLinearMap]
rfl

/-- The tensor product of a polynomial algebra by an algebra
is algebraically equivalent to a polynomial algebra -/
noncomputable def rTensorAlgEquiv :
(MvPolynomial σ S) ⊗[R] N ≃ₐ[S] MvPolynomial σ (S ⊗[R] N) := by
apply AlgEquiv.ofLinearEquiv rTensor
· simp only [Algebra.TensorProduct.one_def]
apply symm
rw [← LinearEquiv.symm_apply_eq]
exact finsuppLeft_symm_apply_single (R := R) (0 : σ →₀ ℕ) (1 : S) (1 : N)
· intro x y
erw [← rTensorAlgHom_apply_eq (S := S)]
simp only [_root_.map_mul, rTensorAlgHom_apply_eq]
rfl

/-- The tensor product of the polynomial algebra by an algebra
is algebraically equivalent to a polynomial algebra with
coefficients in that algegra -/
noncomputable def scalarRTensorAlgEquiv :
MvPolynomial σ R ⊗[R] N ≃ₐ[R] MvPolynomial σ N :=
rTensorAlgEquiv.trans (mapAlgEquiv σ (Algebra.TensorProduct.lid R N))

end Algebra

end MvPolynomial

end
Loading