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(linear_algebra/tensor_power): the tensor powers form a graded algebra #10255

Closed
wants to merge 84 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
3482a3a
wip
eric-wieser Jan 24, 2021
68f90bf
Merge remote-tracking branch 'origin/master' into eric-wieser/tensor_…
eric-wieser Feb 5, 2021
e912ffa
Working definition of mul
eric-wieser Feb 6, 2021
f5e2f45
mul_equiv mostly proved
eric-wieser Feb 6, 2021
01801aa
add reindexing
eric-wieser Feb 6, 2021
e856f0d
wip
eric-wieser Feb 6, 2021
27dfd0f
Merge branch 'master' of github.com:leanprover-community/mathlib into…
eric-wieser Feb 8, 2021
d05bb1d
Get it working
eric-wieser Feb 8, 2021
7576243
Tidy
eric-wieser Feb 8, 2021
5a25d1d
Merge branch 'master' of github.com:leanprover-community/mathlib into…
eric-wieser Feb 15, 2021
21c472a
Move to a new file
eric-wieser Feb 15, 2021
5953273
wip
eric-wieser Feb 15, 2021
0db761e
wip
eric-wieser Feb 15, 2021
970afbd
Merge branch 'master' of github.com:leanprover-community/mathlib into…
eric-wieser Feb 16, 2021
bf21b53
more wip
eric-wieser Feb 16, 2021
86632a7
Merge remote-tracking branch 'origin/master' into eric-wieser/tensor_…
eric-wieser Nov 9, 2021
52c2c74
remove junk
eric-wieser Nov 10, 2021
48b9a49
Fix for latest mathlib
eric-wieser Nov 10, 2021
ea3e579
Add all the sorries
eric-wieser Nov 10, 2021
6b7cd9f
feat(linear_algebra/pi_tensor_prod): generalize actions and provide m…
eric-wieser Nov 10, 2021
c41362f
squeeze simps
eric-wieser Nov 10, 2021
5426586
shortcut instances
eric-wieser Nov 10, 2021
f7b7fcf
Getting close!
eric-wieser Nov 10, 2021
5f8b45e
Sorrys pushed further away
eric-wieser Nov 10, 2021
b1ca876
remove a duplicate lemma
eric-wieser Nov 10, 2021
d7a0f1e
Fix universe variables
eric-wieser Nov 10, 2021
a5aa816
rename concat to append, add repeat
eric-wieser Nov 10, 2021
1204301
Remove incomplete stuff
eric-wieser Nov 11, 2021
64d18f7
Merge remote-tracking branch 'origin/master' into eric-wieser/tensor_…
eric-wieser Nov 11, 2021
1fe183c
State the equivalence. Untested due to orange bars.
eric-wieser Nov 11, 2021
5a850b4
Merge remote-tracking branch 'origin/master' into eric-wieser/tensor_…
eric-wieser Nov 11, 2021
4a09e21
fix slightly
eric-wieser Nov 12, 2021
eb0f0a5
wip
eric-wieser Nov 12, 2021
4532666
Tidy up
eric-wieser Nov 12, 2021
b3c44ab
Fix typos in graded_monoid
eric-wieser Nov 12, 2021
0290f12
remove three sorries
eric-wieser Nov 12, 2021
2e247cf
Most of the iso sorrys gone
eric-wieser Nov 12, 2021
1fa857d
Merge remote-tracking branch 'origin/master' into eric-wieser/tensor_…
eric-wieser Nov 15, 2021
7f1a1f3
Clean up a sorry, golf
eric-wieser Nov 15, 2021
8ddce01
Sorry-free!
eric-wieser Nov 15, 2021
088aa65
Split the file
eric-wieser Nov 15, 2021
70daf96
wip
eric-wieser Nov 15, 2021
09e0f5a
Merge remote-tracking branch 'origin/master' into eric-wieser/tensor_…
eric-wieser Dec 6, 2021
bb8d310
Fill the hard sorry
eric-wieser Dec 7, 2021
884bdcb
fix
eric-wieser Dec 7, 2021
b976668
move lemmas
eric-wieser Dec 7, 2021
452b42a
feat(algebra/graded_monoid): dependent products
eric-wieser Dec 8, 2021
e0ae1d6
docstring, better name
eric-wieser Dec 8, 2021
4b4b1e9
tweaks
eric-wieser Dec 8, 2021
4d72e5c
Merge remote-tracking branch 'origin/master' into eric-wieser/list.dprod
eric-wieser Dec 8, 2021
a805153
Merge branch 'master' into eric-wieser/list.dprod
eric-wieser Dec 9, 2021
e1794bb
Add lemmas about subtypes
eric-wieser Dec 9, 2021
77058d5
reorder
eric-wieser Dec 9, 2021
bee5300
Merge branch 'eric-wieser/list.dprod' into eric-wieser/tensor_algebra…
eric-wieser Dec 9, 2021
e1beed8
fix bad merge
eric-wieser Dec 9, 2021
bc8a7f3
Merge remote-tracking branch 'origin/master' into eric-wieser/tensor_…
eric-wieser Dec 14, 2021
df8e6f9
Merge remote-tracking branch 'origin/master' into eric-wieser/tensor_…
eric-wieser May 17, 2022
f7c011a
fix import
eric-wieser May 17, 2022
489fe70
fix
eric-wieser May 17, 2022
86e9d63
Merge remote-tracking branch 'origin/master' into eric-wieser/tensor_…
eric-wieser May 24, 2022
926be50
Merge remote-tracking branch 'origin/master' into eric-wieser/tensor_…
eric-wieser May 24, 2022
ef40618
get building again
eric-wieser May 24, 2022
edd4bf8
add a cast lemma
eric-wieser May 24, 2022
03a8df1
squeeze the sorry
eric-wieser May 24, 2022
9051b0d
wip
eric-wieser May 24, 2022
ca4a585
fix
eric-wieser May 24, 2022
e99c879
Merge remote-tracking branch 'origin/master' into eric-wieser/tensor_…
eric-wieser Jul 20, 2022
a33c5c3
fix formatting
eric-wieser Jul 20, 2022
18fca3f
fix build errors
eric-wieser Jul 20, 2022
aaec256
Merge remote-tracking branch 'origin/master' into eric-wieser/tensor_…
eric-wieser Jan 17, 2023
35736f5
remove redundant defs
eric-wieser Jan 17, 2023
6852bb1
fixes after merging
eric-wieser Jan 17, 2023
fbcd743
remove unused file
eric-wieser Jan 17, 2023
11d1e40
remove unused line
eric-wieser Jan 17, 2023
00b0663
Merge remote-tracking branch 'origin/master' into eric-wieser/tensor_…
eric-wieser Jan 18, 2023
aa4a064
remove duplicate lemma
eric-wieser Jan 18, 2023
56ee3ee
move lemma to a different file
eric-wieser Feb 8, 2023
9d92edb
golf
eric-wieser Feb 8, 2023
5baa898
remove some dead code, golf a proof
eric-wieser Feb 8, 2023
76452dd
adjust a lemma statement
eric-wieser Feb 8, 2023
d3fd71a
rename algebra_map to algebra_map₀
eric-wieser Mar 1, 2023
f5b7f79
tidy parens
eric-wieser Mar 20, 2023
2ff50fc
golf and comment
eric-wieser Mar 20, 2023
9362a5a
move to appropriate file
eric-wieser Mar 28, 2023
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
28 changes: 28 additions & 0 deletions src/data/fin/tuple/basic.lean
@@ -1,4 +1,4 @@
/-

Check warning on line 1 in src/data/fin/tuple/basic.lean

View workflow job for this annotation

GitHub Actions / Check for modifications to ported files

Changes to this file will need to be ported to mathlib 4! Please consider retracting the changes to this file unless you are willing to immediately forward-port them.
Copyright (c) 2019 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn, Yury Kudryashov, Sébastien Gouëzel, Chris Hughes
Expand Down Expand Up @@ -307,6 +307,20 @@
simp [←nat_add_nat_add] },
end

/-- Appending a one-tuple to the left is the same as `fin.cons`. -/
lemma append_left_eq_cons {α : Type*} {n : ℕ} (x₀ : fin 1 → α) (x : fin n → α):
fin.append x₀ x = fin.cons (x₀ 0) x ∘ fin.cast (add_comm _ _) :=
begin
ext i,
refine fin.add_cases _ _ i; clear i,
{ intro i,
rw [subsingleton.elim i 0, fin.append_left, function.comp_apply, eq_comm],
exact fin.cons_zero _ _, },
{ intro i,
rw [fin.append_right, function.comp_apply, fin.cast_nat_add, eq_comm, fin.add_nat_one],
exact fin.cons_succ _ _ _ },
end

end append

section repeat
Expand Down Expand Up @@ -531,6 +545,20 @@
simp }
end

/-- Appending a one-tuple to the right is the same as `fin.snoc`. -/
lemma append_right_eq_snoc {α : Type*} {n : ℕ} (x : fin n → α) (x₀ : fin 1 → α) :
fin.append x x₀ = fin.snoc x (x₀ 0) :=
begin
ext i,
refine fin.add_cases _ _ i; clear i,
{ intro i,
rw [fin.append_left],
exact (@snoc_cast_succ _ (λ _, α) _ _ i).symm, },
{ intro i,
rw [subsingleton.elim i 0, fin.append_right],
exact (@snoc_last _ (λ _, α) _ _).symm, },
end

lemma comp_init {α : Type*} {β : Type*} (g : α → β) (q : fin n.succ → α) :
g ∘ (init q) = init (g ∘ q) :=
by { ext j, simp [init] }
Expand Down
163 changes: 163 additions & 0 deletions src/linear_algebra/tensor_algebra/to_tensor_power.lean
@@ -0,0 +1,163 @@
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import linear_algebra.tensor_algebra.basic
import linear_algebra.tensor_power
/-!
# Tensor algebras as direct sums of tensor powers

In this file we show that `tensor_algebra R M` is isomorphic to a direct sum of tensor powers, as
`tensor_algebra.equiv_direct_sum`.
-/
open_locale direct_sum tensor_product

variables {R M : Type*} [comm_semiring R] [add_comm_monoid M] [module R M]

namespace tensor_power

/-- The canonical embedding from a tensor power to the tensor algebra -/
def to_tensor_algebra {n} : ⨂[R]^n M →ₗ[R] tensor_algebra R M :=
pi_tensor_product.lift (tensor_algebra.tprod R M n)

@[simp]
lemma to_tensor_algebra_tprod {n} (x : fin n → M) :
tensor_power.to_tensor_algebra (pi_tensor_product.tprod R x) = tensor_algebra.tprod R M n x :=
pi_tensor_product.lift.tprod _

@[simp]
lemma to_tensor_algebra_ghas_one :
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mentioning the name of the instance in the lemma is surprising to me. Why so?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is about ghas_one.one : A 0, not has_one.one : A; we don't have a convention in place for lemmas about the former.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would have suggested gone 💨

(@graded_monoid.ghas_one.one _ (λ n, ⨂[R]^n M) _ _).to_tensor_algebra = 1 :=
tensor_power.to_tensor_algebra_tprod _

@[simp]
lemma to_tensor_algebra_ghas_mul {i j} (a : ⨂[R]^i M) (b : ⨂[R]^j M) :
(@graded_monoid.ghas_mul.mul _ (λ n, ⨂[R]^n M) _ _ _ _ a b).to_tensor_algebra
= a.to_tensor_algebra * b.to_tensor_algebra :=
begin
-- change `a` and `b` to `tprod R a` and `tprod R b`
rw [tensor_power.ghas_mul_eq_coe_linear_map, ←linear_map.compr₂_apply,
←@linear_map.mul_apply' R, ←linear_map.compl₂_apply, ←linear_map.comp_apply],
refine linear_map.congr_fun (linear_map.congr_fun _ a) b,
clear a b,
ext a b,
simp only [linear_map.compr₂_apply, linear_map.mul_apply',
linear_map.compl₂_apply, linear_map.comp_apply, linear_map.comp_multilinear_map_apply,
pi_tensor_product.lift.tprod, tensor_power.tprod_mul_tprod,
tensor_power.to_tensor_algebra_tprod, tensor_algebra.tprod_apply, ←ghas_mul_eq_coe_linear_map],
refine eq.trans _ list.prod_append,
congr',
rw [←list.map_of_fn _ (tensor_algebra.ι R), ←list.map_of_fn _ (tensor_algebra.ι R),
←list.map_of_fn _ (tensor_algebra.ι R), ←list.map_append, list.of_fn_fin_append],
end

@[simp]
lemma to_tensor_algebra_galgebra_to_fun (r : R) :
(@direct_sum.galgebra.to_fun _ R (λ n, ⨂[R]^n M) _ _ _ _ _ _ _ r).to_tensor_algebra
= algebra_map _ _ r :=
by rw [tensor_power.galgebra_to_fun_def, tensor_power.algebra_map₀_eq_smul_one, linear_map.map_smul,
tensor_power.to_tensor_algebra_ghas_one, algebra.algebra_map_eq_smul_one]

end tensor_power

namespace tensor_algebra

/-- The canonical map from a direct sum of tensor powers to the tensor algebra. -/
def of_direct_sum : (⨁ n, ⨂[R]^n M) →ₐ[R] tensor_algebra R M :=
Vierkantor marked this conversation as resolved.
Show resolved Hide resolved
direct_sum.to_algebra _ _ (λ n, tensor_power.to_tensor_algebra)
tensor_power.to_tensor_algebra_ghas_one
(λ i j, tensor_power.to_tensor_algebra_ghas_mul)
(tensor_power.to_tensor_algebra_galgebra_to_fun)

@[simp] lemma of_direct_sum_of_tprod {n} (x : fin n → M) :
of_direct_sum (direct_sum.of _ n (pi_tensor_product.tprod R x)) = tprod R M n x :=
(direct_sum.to_add_monoid_of _ _ _).trans (tensor_power.to_tensor_algebra_tprod _)

/-- The canonical map from the tensor algebra to a direct sum of tensor powers. -/
def to_direct_sum : tensor_algebra R M →ₐ[R] ⨁ n, ⨂[R]^n M :=
tensor_algebra.lift R $
direct_sum.lof R ℕ (λ n, ⨂[R]^n M) _ ∘ₗ
(linear_equiv.symm $ pi_tensor_product.subsingleton_equiv (0 : fin 1) : M ≃ₗ[R] _).to_linear_map

@[simp] lemma to_direct_sum_ι (x : M) :
to_direct_sum (ι R x) =
direct_sum.of (λ n, ⨂[R]^n M) _ (pi_tensor_product.tprod R (λ _ : fin 1, x)) :=
tensor_algebra.lift_ι_apply _ _

lemma of_direct_sum_comp_to_direct_sum :
of_direct_sum.comp to_direct_sum = alg_hom.id R (tensor_algebra R M) :=
begin
ext,
simp [direct_sum.lof_eq_of, tprod_apply],
end

@[simp] lemma of_direct_sum_to_direct_sum (x : tensor_algebra R M) :
of_direct_sum x.to_direct_sum = x :=
alg_hom.congr_fun of_direct_sum_comp_to_direct_sum x

@[simp] lemma mk_reindex_cast {n m : ℕ} (h : n = m) (x : ⨂[R]^n M) :
graded_monoid.mk m (pi_tensor_product.reindex R M (equiv.cast $ congr_arg fin h) x) =
graded_monoid.mk n x :=
eq.symm (pi_tensor_product.graded_monoid_eq_of_reindex_cast h rfl)

@[simp] lemma mk_reindex_fin_cast {n m : ℕ} (h : n = m) (x : ⨂[R]^n M) :
graded_monoid.mk m (pi_tensor_product.reindex R M (fin.cast h).to_equiv x) =
graded_monoid.mk n x :=
by rw [fin.cast_to_equiv, mk_reindex_cast h]

/-- The product of tensor products made of a single vector is the same as a single product of
all the vectors. -/
lemma _root_.tensor_power.list_prod_graded_monoid_mk_single (n : ℕ) (x : fin n → M) :
((list.fin_range n).map
(λ a, (graded_monoid.mk _ (pi_tensor_product.tprod R (λ i : fin 1, x a))
: graded_monoid (λ n, ⨂[R]^n M)))).prod =
graded_monoid.mk n (pi_tensor_product.tprod R x) :=
begin
refine fin.cons_induction _ _ x; clear x,
{ rw [list.fin_range_zero, list.map_nil, list.prod_nil],
refl, },
{ intros n x₀ x ih,
rw [list.fin_range_succ_eq_map, list.map_cons, list.prod_cons, list.map_map, function.comp],
simp_rw [fin.cons_zero, fin.cons_succ],
rw [ih, graded_monoid.mk_mul_mk, tensor_power.tprod_mul_tprod],
refine tensor_power.graded_monoid_eq_of_cast (add_comm _ _) _,
dsimp only [graded_monoid.mk],
rw [tensor_power.cast_tprod],
simp_rw [fin.append_left_eq_cons, function.comp],
congr' 1 with i,
congr' 1,
rw [fin.cast_trans, fin.cast_refl, order_iso.refl_apply] },
end

lemma to_direct_sum_tensor_power_tprod {n} (x : fin n → M) :
to_direct_sum (tprod R M n x) = direct_sum.of _ n (pi_tensor_product.tprod R x) :=
begin
rw [tprod_apply, alg_hom.map_list_prod, list.map_of_fn, function.comp],
simp_rw to_direct_sum_ι,
dsimp only,
rw direct_sum.list_prod_of_fn_of_eq_dprod,
apply direct_sum.of_eq_of_graded_monoid_eq,
rw graded_monoid.mk_list_dprod,
rw tensor_power.list_prod_graded_monoid_mk_single,
end

lemma to_direct_sum_comp_of_direct_sum :
to_direct_sum.comp of_direct_sum = alg_hom.id R (⨁ n, ⨂[R]^n M) :=
begin
ext,
simp [direct_sum.lof_eq_of, -tprod_apply, to_direct_sum_tensor_power_tprod],
end

@[simp] lemma to_direct_sum_of_direct_sum (x : ⨁ n, ⨂[R]^n M) :
(of_direct_sum x).to_direct_sum = x :=
alg_hom.congr_fun to_direct_sum_comp_of_direct_sum x

/-- The tensor algebra is isomorphic to a direct sum of tensor powers. -/
@[simps]
def equiv_direct_sum : tensor_algebra R M ≃ₐ[R] ⨁ n, ⨂[R]^n M :=
alg_equiv.of_alg_hom to_direct_sum of_direct_sum
to_direct_sum_comp_of_direct_sum
of_direct_sum_comp_to_direct_sum

end tensor_algebra