#45280 feat(LinearAlgebra): complexification of real spaces
PR description
This provides the basic framework for complexifying spaces (module structures, star structures, and algebra structures). We also provide some API for complexifying linear operators.
Conversation on GitHub 20
PR summary a20eef52af
Import changes for modified files
No significant changes to the import graph
<details><summary>Import changes for all files</summary>
|Files|Import difference|
|-|-|
| Mathlib.LinearAlgebra.Complexification.Basic (new file)|1429|
</details>
<details><summary>
Declarations diff (regex)
</summary>
+ Complexification
+ I_smul
+ I_smul_mk
+ _root_.Submodule.comap_inclusion_complexification
+ _root_.Submodule.complexification
+ _root_.Submodule.complexification_bot
+ _root_.Submodule.complexification_comap_inclusion
+ _root_.Submodule.complexification_gc
+ _root_.Submodule.complexification_inf
+ _root_.Submodule.complexification_inj
+ _root_.Submodule.complexification_le_complexification
+ _root_.Submodule.complexification_le_iff
+ _root_.Submodule.complexification_mono
+ _root_.Submodule.complexification_sup
+ _root_.Submodule.complexification_top
+ _root_.Submodule.exists_complexification_eq_iff
+ _root_.Submodule.mem_complexification
+ algebraMap_apply
+ conj
+ conj_I_smul
+ conj_conj
+ conj_eq_self_iff
+ conj_mk
+ equivProd
+ im_add
+ im_conj
+ im_mk
+ im_mul
+ im_neg
+ im_one
+ im_real_smul
+ im_smul
+ im_star
+ im_sub
+ im_zero
+ imₗ
+ inclusion
+ instStarAddMonoid
+ instStarMul
+ instance : InvolutiveStar (Complexification A) where star_involutive _ := by simp [star_def]
+ instance : Module ℂ (Complexification V)
+ instance : Mul (Complexification A)
+ instance : NonAssocRing (Complexification A)
+ instance : NonUnitalNonAssocRing (Complexification A)
+ instance : One (Complexification A) where one := mk 1 0
+ instance : SMul ℂ (Complexification V)
+ instance : Star (Complexification A) where star x := mk (star x.re) (-star x.im)
+ instance : StarRing (Complexification A) where __ := instStarAddMonoid; __ := instStarMul
+ instance [AddCommGroup M] : AddCommGroup (Complexification M) := equivProd.addCommGroup
+ instance [AddCommMonoid M] : AddCommMonoid (Complexification M) := equivProd.addCommMonoid
+ instance [AddGroup M] : AddGroup (Complexification M) := equivProd.addGroup
+ instance [AddMonoid M] : AddMonoid (Complexification M) := equivProd.addMonoid
+ instance [Module ℝ A] [IsScalarTower ℝ A A] :
+ instance [Module ℝ A] [SMulCommClass ℝ A A] :
+ instance [Module ℝ A] [StarModule ℝ A] : StarModule ℂ (Complexification A)
+ instance {A : Type*} [CommRing A] : CommRing (Complexification A)
+ instance {A : Type*} [NonAssocCommRing A] : NonAssocCommRing (Complexification A)
+ instance {A : Type*} [NonUnitalCommRing A] : NonUnitalCommRing (Complexification A)
+ instance {A : Type*} [NonUnitalNonAssocCommRing A] :
+ instance {A : Type*} [NonUnitalRing A] : NonUnitalRing (Complexification A)
+ instance {A : Type*} [Ring A] : Ring (Complexification A)
+ instance {A : Type*} [Ring A] [Algebra ℝ A] : Algebra ℂ (Complexification A)
+ mk_add_mk
+ mk_eq_add_I_smul
+ mk_mul_mk
+ mk_re_im
+ mk_sub_mk
+ mk_zero_zero
+ mul_def
+ neg_mk
+ one_def
+ re_add
+ re_conj
+ re_mk
+ re_mul
+ re_neg
+ re_one
+ re_real_smul
+ re_smul
+ re_star
+ re_sub
+ re_zero
+ realLinearEquivComplex
+ reₗ
+ smul_def
+ star_I_smul
+ star_conj
+ star_def
+ star_mk
+ symm_conj
<details>
<summary>You can run this locally as follows</summary>
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>
## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>
</details>
The doc-module for scripts/pr_summary/declarations_diff.sh in the undefined repository contains some details about this script.
</details>
<details><summary>
Declarations diff (Lean)
</summary>
✅ Lean-aware diff — post-build, computed from the Lean environment (commit
a20eef5).
- +114 new declarations
- −0 removed declarations
+Complexification
+Complexification.I_smul
+Complexification.I_smul_mk
+Complexification.algebraMap_apply
+Complexification.casesOn
+Complexification.conj
+Complexification.conj_I_smul
+Complexification.conj_apply
+Complexification.conj_conj
+Complexification.conj_eq_self_iff
+Complexification.conj_mk
+Complexification.ctorIdx
+Complexification.delabMk
+Complexification.equivProd
+Complexification.equivProd_apply
+Complexification.equivProd_symm_apply
+Complexification.ext
+Complexification.ext_iff
+Complexification.im
+Complexification.im_add
+Complexification.im_conj
+Complexification.im_mk
+Complexification.im_mul
+Complexification.im_neg
+Complexification.im_one
+Complexification.im_real_smul
+Complexification.im_smul
+Complexification.im_star
+Complexification.im_sub
+Complexification.im_zero
+Complexification.imₗ
+Complexification.imₗ_apply
+Complexification.inclusion
+Complexification.inclusion_apply
+Complexification.instAddCommGroup
+Complexification.instAddCommMonoid
+Complexification.instAddGroup
+Complexification.instAddMonoid
+Complexification.instAlgebraComplexOfReal
+Complexification.instCommRing
+Complexification.instInvolutiveStar
+Complexification.instIsScalarTowerComplexOfReal
+Complexification.instModuleComplex
+Complexification.instMul
+Complexification.instNonAssocCommRing
+Complexification.instNonAssocRing
+Complexification.instNonUnitalCommRing
+Complexification.instNonUnitalNonAssocCommRing
+Complexification.instNonUnitalNonAssocRing
+Complexification.instNonUnitalRing
+Complexification.instOne
+Complexification.instRing
+Complexification.instSMulCommClassComplexOfReal
+Complexification.instSMulComplex
+Complexification.instStar
+Complexification.instStarAddMonoid
+Complexification.instStarModuleComplexOfReal
+Complexification.instStarMul
+Complexification.instStarRing
+Complexification.mk
+Complexification.mk.inj
+Complexification.mk.injEq
+Complexification.mk.noConfusion
+Complexification.mk.sizeOf_spec
+Complexification.mk_add_mk
+Complexification.mk_eq_add_I_smul
+Complexification.mk_mul_mk
+Complexification.mk_re_im
+Complexification.mk_sub_mk
+Complexification.mk_zero_zero
+Complexification.mul_def
+Complexification.neg_mk
+Complexification.noConfusion
+Complexification.noConfusionType
+Complexification.one_def
+Complexification.re
+Complexification.re_add
+Complexification.re_conj
+Complexification.re_mk
+Complexification.re_mul
+Complexification.re_neg
+Complexification.re_one
+Complexification.re_real_smul
+Complexification.re_smul
+Complexification.re_star
+Complexification.re_sub
+Complexification.re_zero
+Complexification.realLinearEquivComplex
+Complexification.realLinearEquivComplex_apply
+Complexification.realLinearEquivComplex_symm_apply
+Complexification.rec
+Complexification.recOn
+Complexification.reₗ
+Complexification.reₗ_apply
+Complexification.smul_def
+Complexification.star_I_smul
+Complexification.star_conj
+Complexification.star_def
+Complexification.star_mk
+Complexification.symm_conj
+Submodule.comap_inclusion_complexification
+Submodule.complexification
+Submodule.complexification_bot
+Submodule.complexification_comap_inclusion
+Submodule.complexification_gc
+Submodule.complexification_inf
+Submodule.complexification_inj
+Submodule.complexification_le_complexification
+Submodule.complexification_le_iff
+Submodule.complexification_mono
+Submodule.complexification_sup
+Submodule.complexification_top
+Submodule.exists_complexification_eq_iff
+Submodule.mem_complexification
</details>
No changes to strong technical debt. No changes to weak technical debt.
Current commit a20eef52af Reference commit 442ab0d377
This script lives in the undefined repository. To run it locally, from your mathlib4 directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
- The
relativevalue is the weighted sum of the differences with weight given by the inverse of the current value of the statistic. - The
absolutevalue is therelativevalue divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
@j-loreaux, here is the first PR on complexification.
There's probably more we can add (more instances, more useful API), but this is just the first PR.
~~(I can split the linear map stuff to its own PR if you want, since this PR is quite big.)~~
Isn't it easy enough to use
import Mathlib
open scoped TensorProduct
variable {𝕜 M : Type*} [RCLike 𝕜] [AddCommGroup M] [Module ℝ M]
noncomputable def TensorProduct.re : 𝕜 ⊗[ℝ] M →ₗ[ℝ] M :=
(TensorProduct.lid ℝ M).toLinearMap ∘ₗ RCLike.reLm.rTensor M
noncomputable def TensorProduct.im : 𝕜 ⊗[ℝ] M →ₗ[ℝ] M :=
(TensorProduct.lid ℝ M).toLinearMap ∘ₗ RCLike.imLm.rTensor MHmm.. true. I'll try to refactor later
This isn't necessarily an argument that your approach is a bad idea; merely that you need to go a bit further to justify it.
I get that. I don't really have any further justification besides convenience since I have a lot of the code written. So I think it's worth a shot at trying to refactor if it can shorten and remove lots of things.
Another thing you could consider is whether this is really a Module (QuadraticAlgebra _ _) (QuadraticAlgebra _ _) instance; that is, do we really want to specialize to C?
After some thinking, I don't think the tensor product approach is the right one anymore. It wouldn't work for normed spaces for example. So we wouldn't be able to complexify normed or C*-algebras.
I haven't though much about the QuadraticAlgebra approach besides seeing if I can have it as an abbreviation (but that wouldn't work).
/-- This prevents `mk x.re y.im` being printed as `{ re := x.re, im := x.im }` byThis is realised as a structure with a "real part" and an "imaginary part".- Regarding "do we really want to specialize to
C?". I think the answer is, yes, but even more so, doing this forQuadraticAlgebradoesn't really help us forℂ. - Regarding tensor products versus
Prodversus structures: I'll have more to say about this in another comment, but @themathqueen I want to point out that it is still totally feasible to useℂ ⊗[ℝ] Munder the hood, either by makingComplexificationa 1-field structure for that, or else an implicit-reducibledef(I would lean towards the former). - @eric-wieser note that your
TensorProduct.reforRCLike 𝕜has the annoying property thatRCLike.re = Complex.reis not a reducible defeq when𝕜 := ℂ. Also note that𝕜 ⊗[ℝ] Mis not really what we want. We really wantℂ ⊗[ℝ] Mwhen𝕜 := ℝ. (arguably, we want𝕜 ⊗[𝕜] M, but see my other comment).
@ADedecker and @faenuccio I have thought a lot about this since ICERM. Let me lay out things the way I see them.
(Note: I've structured this post more than usual, and it's long, but be assured that none of it is AI. This should be obvious since it's a GitHub comment, but I didn't want you to have any doubts.)
We have two options: create a complexification that always tensors over ℝ, or a version which takes a parameter 𝕜 and tensors over 𝕜; at ICERM we discussed ways to accomplish the latter. I will highlight the advantages and disadvantages I see of each, and then state my conclusions.
Tensor over ℝ
Advantages:
- It's simple and we always do the same thing, so there is never a need to consider
Complexification ℝ M,Complexification ℂ M, orComplexification 𝕜 M. - It matches the literature best. I don't know of any text that tries to implement complexification as
ℂ ⊗[𝕜] M, because they have no counterpart to our formalRCLikeclass. - We can implement as this as
ℂ ⊗[ℝ] MorM × Mor as a bespoke structure, they are all the same. We have lots of freedom and the complexification is always equivalent toM × M(as sets). - It is quite natural to get
Algebra ℂ (Complexification M)instances, without diamonds.
Disadvantages:
- It could cause some fracturing regarding how we handle things involving
RCLike. That is, it would be very sad to have to give up this nice general framework and start duplicating everything forℝandℂ. But see the mitigation suggestion below. Of course, this fracturing has already been forced upon us to some extent withContinuousFunctionalCalculus, and I still see no way around that. - It's perhaps not as elegant (i.e., it would be very nice if this were effectively the identity on complex algebras).
Mitigations:
In situations where we need to use the complexification to prove something over RCLike, we can always pass (e.g., a 𝕜-linear map) through .restrictScalars ℝ and then on to the complexification. In this way, we should still be able to prevent fracturing. Monica pointed this out to me, and I think it makes a lot of sense.
Tensor over 𝕜
Before jumping in, I want to point out that I think this is significantly simpler than we were discussing at ICERM. At ICERM we were concerned because we don't have an Algebra 𝕜 ℂ instance, and so we don't get a ℂ-algebra structure from ℂ ⊗[𝕜] M. So we contemplated a type synonym RCLike.Complex for ℂ that takes a parameter 𝕜 and give an Algebra 𝕜 (RCLike.Complex 𝕜) instance. On #42744, Anatole pointed out that this would mean we need a CLike typeclass, and that seems like a whole mess. We considered this the big downside to this approach.
However, I think this is not a problem at all. I think all we need to do is make RCLike extend NormedAlgebra 𝕜 ℂ. The forgetful inheritance I believe prevents any diamonds. Then we can easily consider ℂ ⊗[𝕜] M.
Advantages: prevents fracturing (but see below!) and is more elegant.
Disadvantages:
- We have to worry about three different kinds of complexification. Hopefully we would never need to transition between these, but it is a bit weird.
- Hard to explain to outsiders why we would ever want to do this: "why would you ever do
Complexification ℂ M", "we don't really", "but then why do you haveComplexification 𝕜 M, you only ever allow𝕜 := ℝor𝕜 := ℂ?", "because ... reasons." - I am actually worried about fracturing problems. The
ℂ ⊗[𝕜] Mapproach effectively, although not literally does an invisible case split based on whether𝕜 := ℝor𝕜 := ℂ(because you get eitherM × MorMback). It's quite elegant that we can do this in a uniform way, but it means that you really can't take real and imaginary parts unless𝕜 := ℝ, and so we still end up with a fractured landscape.
Conclusion
I think Monica's approach here is the correct one (modulo implementation details, e.g., making this a structure wrapper around ℂ ⊗[ℝ] M).
@ADedecker and @faenuccio I have thought a lot about this since ICERM. Let me lay out things the way I see them.
(Note: I've structured this post more than usual, and it's long, but be assured that none of it is AI. This should be obvious since it's a GitHub comment, but I didn't want you to have any doubts.)
We have two options: create a complexification that always tensors over
ℝ, or a version which takes a parameter𝕜and tensors over𝕜; at ICERM we discussed ways to accomplish the latter. I will highlight the advantages and disadvantages I see of each, and then state my conclusions.Tensor over
ℝAdvantages:
- It's simple and we always do the same thing, so there is never a need to consider
Complexification ℝ M,Complexification ℂ M, orComplexification 𝕜 M.
- It matches the literature best. I don't know of any text that tries to implement complexification as
ℂ ⊗[𝕜] M, because they have no counterpart to our formalRCLikeclass.
- We can implement as this as
ℂ ⊗[ℝ] MorM × Mor as a bespoke structure, they are all the same. We have lots of freedom and the complexification is always equivalent toM × M(as sets).
- It is quite natural to get
Algebra ℂ (Complexification M)instances, without diamonds.Disadvantages:
- It could cause some fracturing regarding how we handle things involving
RCLike. That is, it would be very sad to have to give up this nice general framework and start duplicating everything forℝandℂ. But see the mitigation suggestion below. Of course, this fracturing has already been forced upon us to some extent withContinuousFunctionalCalculus, and I still see no way around that.
- It's perhaps not as elegant (i.e., it would be very nice if this were effectively the identity on complex algebras).
Mitigations:
In situations where we need to use the complexification to prove something over
RCLike, we can always pass (e.g., a𝕜-linear map) through.restrictScalars ℝand then on to the complexification. In this way, we should still be able to prevent fracturing. Monica pointed this out to me, and I think it makes a lot of sense.Tensor over
𝕜Before jumping in, I want to point out that I think this is significantly simpler than we were discussing at ICERM. At ICERM we were concerned because we don't have an
Algebra 𝕜 ℂinstance, and so we don't get aℂ-algebra structure fromℂ ⊗[𝕜] M. So we contemplated a type synonymRCLike.Complexforℂthat takes a parameter𝕜and give anAlgebra 𝕜 (RCLike.Complex 𝕜)instance. On #42744, Anatole pointed out that this would mean we need aCLiketypeclass, and that seems like a whole mess. We considered this the big downside to this approach.However, I think this is not a problem at all. I think all we need to do is make
RCLikeextendNormedAlgebra 𝕜 ℂ. The forgetful inheritance I believe prevents any diamonds. Then we can easily considerℂ ⊗[𝕜] M.Advantages: prevents fracturing (but see below!) and is more elegant.
Disadvantages:
- We have to worry about three different kinds of complexification. Hopefully we would never need to transition between these, but it is a bit weird.
- Hard to explain to outsiders why we would ever want to do this: "why would you ever do
Complexification ℂ M", "we don't really", "but then why do you haveComplexification 𝕜 M, you only ever allow𝕜 := ℝor𝕜 := ℂ?", "because ... reasons."
- I am actually worried about fracturing problems. The
ℂ ⊗[𝕜] Mapproach effectively, although not literally does an invisible case split based on whether𝕜 := ℝor𝕜 := ℂ(because you get eitherM × MorMback). It's quite elegant that we can do this in a uniform way, but it means that you really can't take real and imaginary parts unless𝕜 := ℝ, and so we still end up with a fractured landscape.Conclusion
I think Monica's approach here is the correct one (modulo implementation details, e.g., making this a structure wrapper around
ℂ ⊗[ℝ] M).
Thanks for the excellent summary of our ICERM discussion, @j-loreaux ! Two questions:
- Currently
RCLike KextendsNormedAlgebra ℝ K: when you suggest that it extendsNormedAlgebra K ℂ, you want in particular to put anAlgebra K ℂand, I suppose, aIsScalarTower ℝ K ℂ: is then theNormedAlgebra K ℂreally needed or would theAlgebra K ℂsuffice? - With Monica's approach, the complexification of
ℂisℂ^2but with our approach it wasℂ(not defeq-ly, perhaps, but at least mathematically) so they seems to very different approaches. In particular, I don't see how this approach would allow for a somewhat uniform treatment of the continuous calculus, and it would oblige to fall back to a complex-continuous calculus vs a real one, no?
One nice property of using 𝕜 ⊗[ℝ] M instead of ℂ ⊗[𝕜] M is that the former makes it easier to generalize parts to arbitrary star-module such as ℍ ⊗[ℝ] M. Of course complexification is terrible name for this, and it's really just BaseChange at this point.
or would the
Algebra K ℂsuffice?
Probably that would suffice yes, although I don't think it would be terribly (any?) more work to make it extend NormedAlgebra K ℂ.
- With Monica's approach, the complexification of
ℂisℂ^2but with our approach it wasℂ(not defeq-ly, perhaps, but at least mathematically) so they seems to very different approaches. In particular, I don't see how this approach would allow for a somewhat uniform treatment of the continuous calculus, and it would oblige to fall back to a complex-continuous calculus vs a real one, no?
There are several things to say about this:
- There is no meaningful
ContinuousFunctionalCalculus 𝕜 A ?pinstance precisely because there is no predicate?p : A → Propthat works forRCLike 𝕜(because when𝕜 := ℝit needs to beIsSelfAdjointand when𝕜 := ℂit needs to beIsStarNormal). There are a small handful of lemmas where we assumeRCLikeforcfc-related material, but it has to be the case that the predicate plays essentially no role in those lemmas. - Note that
ContinuousFunctionalCalculusis aProp-valued class, so it doesn't really matter how we get aContinuousFunctionalCalculus ℝ A IsSelfAdjointclass on a real vs. complex C⋆-algebra, we do not need them to "agree" at any transparency. So, GivenRCLike 𝕜and a𝕜-C⋆-algebraA(also assuming it is aℝ-algebra withIsScalarTower ℝ 𝕜 A), then we can complexifyAto getComplexification A(≃ A × A), which is aℂ-C⋆-algebra, and then we getContinuousFunctionalCalculus ℝ (Complexification A) IsSelfAdjointfor free. Given a selfadjoint elementa : A, if↑a : Complexification A, then we can show thatcfc (?f : ℝ → ℝ) ↑aalways lives inSet.range (↑), and so we can restrict to get aContinuousFunctionalCalculus ℝ A IsSelfAdjointinstance on our𝕜-C⋆-algebra; hence no fracturing at this step. - Probably you are not familiar with this, but there is a distinction between continuous functional calculi over
ℝ-C⋆-algebras and overℂ-C⋆-algebras. In particular, over a complex C⋆-algebra, and for an elementa : Awith is normal/selfadjoint/nonnegative, we can make sense off(a)for anyf : ℂ → ℂ/f : ℝ → ℝ/f : ℝ≥0 → ℝ≥0which is continuous on the spectrum. However, for real C⋆-algebras, while the versions overℝorℝ≥0work the same, the version overℂfor normal elements is different. In particular, you can only make sense off(a)forf : ℂ → ℂwhich are continuous on theℂ-spectrum (of↑a, of course, becauseℂ-spectrum ofamakes no sense) AND which satisfyf (star z) = star (f z)for allz ∈ spectrum ℂ ↑a(note: for↑a : ℂ ⊗[ℝ] A, the spectrum is always self-conjugate, so this makes sense). Note that this distinction in theℂ-valued function case overℝ-C⋆-algebras means thatContinuousFunctionalCalculusis already not workable for normal elements in a non-complex C⋆-algebra. Anatole and I already knew this when designing this class, and mentioned this limitation in our paper.
Does this all make sense? Happy to expand if necessary.
@eric-wieser, @ADedecker, @faenuccio I'm interested in your opinions because I would like to get this moving. My (private) hope was to have it merged before the end of November, but that clearly won't happen. Nevertheless, I want to get complexification done whichever way we decide is better as soon as is reasonably possible.
In the absence of your comments, I'll probably start reviewing this as-is with the plan to pursue the ⊗[ℝ] approach.
smul_add _ _ _ := by ext <;> simp <;> moduleThanks, I've left several stylistical comments for the time being. In the next round (coming now) I'll focus more on the content.
@themathqueen I know I'm taking a bit for the promised review about the content, but I'm overwhelmed the following 3 days. I'm on it and promise to finish my review by the beginning of next week.
Mathlib.lean +1 −0
public import Mathlib.LinearAlgebra.Complex.DeterminantMathlib/LinearAlgebra/Complexification/Basic.lean +342 −0 new file
technically it isn't products, it's a structure (need to change that)
and probably can justify further why this is a better choice, but maybe this is enough.
I agree it would be nicer if this is more justified, for future people wondering what problem is being mentioned here.
Is this a ##To Do ?
Both in the infoview and in the code, the re (and im) comes after the smul: so I'd call this smul_re and the next smul_im.
I would, as in the above lemmas, call this real_smul_re (and propagate this change further below to the im ones).
Don't we want to create a new section Submodule for the following results?
simp only [Submodule.mem_complexification, Submodule.mem_comap, Submodule.restrictScalars_mem]Can we split this in two lines?
simp [Complexification.ext_iff, ← two_smul ℝ] simp [Complexification.ext_iff, ← two_smul ℝ]I confess this is very very minor, but I prefer "if and only if" rather than "iff" in docstrings, it's nicer to our readers.
variable {A : Type*} [NonUnitalNonAssocRing A]As above, I would advocate for mul_re and the like below.
In this and in the two instances below grind could be replaced by module.
Can we give a name to this section?
variable {A : Type*} [NonAssocRing A]Once more, I'd go for one_re
Can you insert a new line after each of these instances? And likewise further below about the InvolutiveStar ones?
Shouldn't this be section Star?
variable {A : Type*} [NonUnitalNonAssocRing A] [StarRing A]docs/references.bib +10 −0
@Book{ roigdomingues1992