Repository navigation
feat(LinearAlgebra/PiTensorProduct): API for PiTensorProducts indexed by sets - #32608
PrParadoxy wants to merge 22 commits into
Conversation
…v` for dependent case Dependent `PiTensorProduct`s over singleton types occur naturally when using `tmulEquivDep` to split off one index from a dependent `PiTensorProduct`. This PR creates `subsingletonEquivDep` to deal with this situation. The non-dependent `subsingletonEquiv` is re-defined as a specialization of the general case. This breaks `toDirectSum_ι` in TensorAlgebra/ToTensorPower, which relies on the precise definition of `subsingletonEquiv`. Its proof is therefore changed to use `simp` lemmas.
PR summary 758284ccdaImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
This pull request has conflicts, please merge |
… by sets
This PR addresses a TODO item in LinearAlgebra/PiTensorProduct.lean:
* API for the various ways `ι` can be split into subsets; connect this
with the binary tensor product
-- specifically by describing tensors of type `⨂ (i : S), s i`, for `S : Set ι`.
Our primary motivation is to formalize the notion of "tensors with
infinite index set, which are equal to a distinguished element on all
but finitely many indices". This is a standard construction e.g. in the
theory of "infinite tensor products" of unital algebras.
Beyond that, the `Set` API is natural in contexts where the index type has
an independent interpretation. An example is quantum physics, where `ι`
ranges over distinguishable degrees of freedom, and where its is common
practice to annotate objects by the set of indices they are defined on.
This PR creates a directory LinearAlgebra/PiTensorProduct and starts the
file Set.lean.
A separate PR adds results on finite families of disjoint subsets.
---
The material is enough to define the notion of "tensors of finite
support", see WIP here:
https://github.com/PrParadoxy/mathlib4/blob/test/Mathlib/LinearAlgebra/PiTensorProduct/Finsupp.lean
a449915 to
23fed4b
Compare
|
This PR/issue depends on: |
|
This pull request has conflicts, please merge |
|
!bench |
|
Benchmark results for 7193e20 against d76e532 are in! @PrParadoxy No significant changes detected. |
dagurtomas
left a comment
There was a problem hiding this comment.
I haven't had time yet to review the proofs in detail, here are a few comments about documentation. Also, if this resolves a TODO somewhere, you should remove it. In the PR description, you mention applying this to formalize "tensors with infinite index set, which are equal to a distinguished element on all but finitely many indices". Do you have any concrete progress on this which uses the code in this PR? (It's ok if you don't, it's just nice to have evidence that the API is working well).
| * Equivalences for `PiTensorproduct`s over sets: | ||
|
|
||
| Definition... ...pertains to | ||
| `univEquiv` `univ : Set ι` | ||
| `singletonEquiv` `{i₀}` |
There was a problem hiding this comment.
You should say what each definition is, not what it pertains to.
| ## TODO | ||
|
|
||
| * Injectivity lemmas for the extensions. These are easy for vector spaces, but | ||
| can become quite subtle for `AddCommMonoid`s. |
There was a problem hiding this comment.
What precise statements are you after here?
There was a problem hiding this comment.
We've stated it more precisely.
Also, we've included a new TBD item, together with a reference to a PR that's already in the queue:
- We currently treat only pairs of subsets of the index type. The generalization
to finite collections isPR #32609.
OK?
| /-- Tensors indexed by `ι` are isomorphic to tensors indexed by `univ : Set ι`. -/ | ||
| def univEquiv : (⨂[R] i, s i) ≃ₗ[R] ⨂[R] i : ↥univ, s i.val := reindex R s (Equiv.Set.univ ι).symm |
There was a problem hiding this comment.
| /-- Tensors indexed by `ι` are isomorphic to tensors indexed by `univ : Set ι`. -/ | |
| def univEquiv : (⨂[R] i, s i) ≃ₗ[R] ⨂[R] i : ↥univ, s i.val := reindex R s (Equiv.Set.univ ι).symm | |
| /-- The tensor product of a family of modules indexed by `ι` is isomorphic | |
| to the tensor product of the corresponding family indexed by `univ : Set ι`. -/ | |
| def univEquiv : (⨂[R] i, s i) ≃ₗ[R] ⨂[R] i : ↥univ, s i.val := reindex R s (Equiv.Set.univ ι).symm |
Similar for other docstrings that say that "tensors ... are isomorphic to ..."
There was a problem hiding this comment.
We've reworked all the docstrings.
The format you suggest works well for the short definitions, but becomes a bit too verbose for the more complex ones. Our new format borrows idioms from PiTensorProduct.tmulEquivDep. Should be more precise now.
(Lesson learned: Writing good docstrings is surprisingly hard!)
dagurtomas
left a comment
There was a problem hiding this comment.
This looks mostly good to me, once my previous comments have been addressed. However, I wonder if we want specialized API for this, i.e. a definition Set.TensorProduct which is the restriction of a PiTensorProduct to a set of the indexing type.
I'll mark this PR as awaiting-zulip until we've had some input from regular users of tensor products on the [Zulip thread](#mathlib4 > Tensor products indexed by a set) I created.
| Definition... ...pertains to | ||
| `tmulUnionEquiv` `S₁ ∪ S₂` | ||
| `tmulBipartitionEquiv` `S ∪ Sᶜ` | ||
| `tmulUnifyEquiv` `S ∪ (T \ S)` | ||
| `tmulInsertEquiv` `{i₀} ∪ S` |
There was a problem hiding this comment.
This will render quite badly in docgen: I'd suggest just a bulleted list, or if you insist a markdown table.
There was a problem hiding this comment.
Changed to standard style.
|
|
||
| /-- For sets `S ⊆ T`, tensors indexed by `S` times tensors indexed by `T \ S` | ||
| are isomorphic to tensors indexed by `T`. -/ | ||
| def tmulUnifyEquiv : |
There was a problem hiding this comment.
This name seems a little weird to me, especially as unify appears neither in the docstring nor the implementation.
There was a problem hiding this comment.
@eric-wieser As tmulUnionEquiv already exists, what naming convention would you suggest for this particular equivalence?
| /-- An equivalence `e : Equiv.Perm ι` maps tensors indexed by a set `S` to | ||
| tensors indexed by `e '' S`. -/ | ||
| def permSetEquiv : (⨂[R] _ : S, M) ≃ₗ[R] ⨂[R] _ : (e '' S), M := | ||
| reindex R (fun _ ↦ M) (Equiv.image e S) |
There was a problem hiding this comment.
Arguably this one should have M be dependently-typed
There was a problem hiding this comment.
Right.
On consideration, we have removed the section containing this definition and the two simp lemmas.
Reasons:
- The definition is too thin a wrapper around
reindexto merit its own definition. - We've done some follow-up work and never felt the urge to use
permSetEquivso far.
|
|
||
| /-- For sets `S ⊆ T`, tensors indexed by `S` times tensors indexed by `T \ S` | ||
| are isomorphic to tensors indexed by `T`. -/ | ||
| def tmulUnifyEquiv : |
| @[simp] | ||
| theorem tmulInsertEquiv_tprod (x : s i₀) (f : (i : S) → s i) : | ||
| (tmulInsertEquiv h₀) (x ⊗ₜ[R] (⨂ₜ[R] i, f i)) = ⨂ₜ[R] i : ↥(insert i₀ S), | ||
| if h : i.val ∈ ({i₀} : Set ι) then cast (by grind) x else f ⟨i, by grind⟩ := by |
There was a problem hiding this comment.
Why not use an equality here, i.val = i₀?
|
Further changes since last review:
|
|
|
-awaiting-author |
| `tmulBipartitionEquiv` is the equivalence between the binary tensor product of | ||
| `PiTensorProduct`s indexed by `S` and its complement `Sᶜ`, and the | ||
| `PiTensorProduct` indexed by `ι`. -/ | ||
| def tmulBipartitionEquiv : (⨂[R] i₁ : S, M i₁) ⊗[R] (⨂[R] i₂ : ↥Sᶜ, M i₂) ≃ₗ[R] ⨂[R] i, M i := |
There was a problem hiding this comment.
This might be more useful as
| def tmulBipartitionEquiv : (⨂[R] i₁ : S, M i₁) ⊗[R] (⨂[R] i₂ : ↥Sᶜ, M i₂) ≃ₗ[R] ⨂[R] i, M i := | |
| def tmulBipartitionEquiv (hST : IsCompl S T) : (⨂[R] i₁ : S, M i₁) ⊗[R] (⨂[R] i₂ : T, M i₂) ≃ₗ[R] ⨂[R] i, M i := |
since that naturally lets you swap S and Sᶜ, and matches the interface of subtypeEquivProp.
| /-- Consider a family of modules indexed by `ι` and a set `S : Set ι`. | ||
| `tmulBipartitionEquiv` is the equivalence between the binary tensor product of | ||
| `PiTensorProduct`s indexed by `S` and its complement `Sᶜ`, and the | ||
| `PiTensorProduct`s indexed by `S` and its complement `T = Sᶜ`, and the |
There was a problem hiding this comment.
| `PiTensorProduct`s indexed by `S` and its complement `T = Sᶜ`, and the | |
| `PiTensorProduct`s indexed by complemtary sets `S` and `T`, and the |
|
Apologies for not raising it earlier; this API makes me a little uneasy, because I don't think we have anything analogous anywhere. Concretely, this PR adds the following def PiTensorProduct.univEquiv : (⨂[R] i, M i) ≃ₗ[R] ⨂[R] i : ↥univ, M i.val
def PiTensorProduct.singletonSetEquiv (i₀ : ι) : (⨂[R] i : ({i₀} : Set ι), M i) ≃ₗ[R] M i₀
def PiTensorProduct.tmulUnionEquiv :
((⨂[R] (i₁ : S₁), M i₁) ⊗[R] (⨂[R] (i₂ : S₂), M i₂)) ≃ₗ[R] ⨂[R] (i : ↥(S₁ ∪ S₂)), M i
def PiTensorProduct.tmulBipartitionEquiv :
(⨂[R] i₁ : S, M i₁) ⊗[R] (⨂[R] i₂ : T, M i₂) ≃ₗ[R] ⨂[R] i, M i :=
def PiTensorProduct.tmulDiffEquiv :
(⨂[R] i₁ : S, M i₁) ⊗[R] (⨂[R] i₂ : ↥(T \ S), M i₂) ≃ₗ[R] ⨂[R] i : T, M i
def PiTensorProduct.tmulInsertEquiv :
((M i₀) ⊗[R] (⨂[R] i₁ : S, M i₁)) ≃ₗ[R] (⨂[R] i₁ : ↥(insert i₀ S), M i₁)but there's nothing particularly special about def Pi.univEquiv : (Π i, M i) ≃ Π i : ↥univ, M i.val
def Pi.singletonSetEquiv (i₀ : ι) : (Π i : ({i₀} : Set ι), M i) ≃ M i₀
def Pi.prodUnionEquiv :
((Π (i₁ : S₁), M i₁) × (Π (i₂ : S₂), M i₂)) ≃ Π (i : ↥(S₁ ∪ S₂)), M i
def Pi.prodBipartitionEquiv :
(Π i₁ : S, M i₁) × (Π i₂ : T, M i₂) ≃ Π i, M i :=
def Pi.prodDiffEquiv :
(Π i₁ : S, M i₁) × (Π i₂ : ↥(T \ S), M i₂) ≃ Π i : T, M i
def Pi.prodInsertEquiv :
((M i₀) × (Π i₁ : S, M i₁)) ≃ (Π i₁ : ↥(insert i₀ S), M i₁)
-- and `AddEquiv`, `MulEquiv`, `LinearEquiv`, `RingEquiv`, `AlgEquiv` versions of the aboveor def DirectSum.univEquiv : (⨁ i, M i) ≃ ⨁ i : ↥univ, M i.val
def DirectSum.singletonSetEquiv (i₀ : ι) : (⨁ i : ({i₀} : Set ι), M i) ≃ M i₀
def DirectSum.prodUnionEquiv :
((⨁ (i₁ : S₁), M i₁) × (⨁ (i₂ : S₂), M i₂)) ≃ ⨁ (i : ↥(S₁ ∪ S₂)), M i
def DirectSum.prodBipartitionEquiv :
(⨁ i₁ : S, M i₁) × (⨁ i₂ : T, M i₂) ≃ ⨁ i, M i
def DirectSum.prodDiffEquiv :
(⨁ i₁ : S, M i₁) × (⨁ i₂ : ↥(T \ S), M i₂) ≃ ⨁ i : T, M i
def DirectSum.prodInsertEquiv :
((M i₀) × (⨁ i₁ : S, M i₁)) ≃ (⨁ i₁ : ↥(insert i₀ S), M i₁)(and for So either:
Did you have a use-case in mind for these, or was the primary motivation to fill out the TODO? |
|
(Perhaps let's continue discussion in #mathlib4 > Tensor products indexed by a set @ 💬 for everything except your motivation) |
|
@PrParadoxy nothing has happened here or in the Zulip discussion for quite a while. What's the status here? Do you feel like you have gotten clear feedback on how to proceed if you want this merged? Or is this stuck on some disagreement? |
|
The Zulip discussion did not produce a consensus that such an API was needed in Mathlib. @PrParadoxy and me wrote it in order to implement the restricted tensor product. After the Zulip discussion stalled, our plan changed to finishing that project first, and to re-open the discussion once this is done. The logic being that with a concrete project building on the Set API, it would be easier to see whether it is useful or whether there are better alternatives. We have since gotten sidetracked with a different project, and there isn't currently a time-line for the restricted tensor product. Should we mark this PR as WIP in the meantime, so as to remove it from the review queue? Another motivation for the PR was a "TBD item" in PiTensorProduct.lean calling for a Set API. This should probably be removed given the lack of consensus at the moment. We can submit a mini PR to that effect. |
|
-awaiting-author |
|
This pull request has conflicts, please merge |
|
This pull request is now in draft mode. No active bors state needed cleanup. While this PR remains draft, bors will ignore commands on this PR. Mark it ready for review before using commands like |
This PR addresses a TODO item in LinearAlgebra/PiTensorProduct.lean:
with the binary tensor product
-- specifically by describing tensors of type ⨂ (i : S), M i, for S : Set ι.
Our primary motivation is to formalise the notion of "restricted tensor
products". This will be the content of a follow-up PR.
Beyond that, the Set API is natural in contexts where the index type has
an independent interpretation. An example is quantum physics, where ι
ranges over distinguishable degrees of freedom, and where its is common
practice to annotate objects by the set of indices they are defined on.
Stub file with preliminary definition of the restricted tensor product as a direct limit of tensors indexed by finite subsets of an index type:
https://github.com/PrParadoxy/mathlib4/blob/restricted-stub/Mathlib/LinearAlgebra/PiTensorProduct/Restricted.lean
subsingletonEquivfor dependent case #32598