Opened 2 years ago
Last modified 4 weeks ago
#30278 new defect
TensorFreeModule should not have a coercion from its quotients, ExtPowerFreeModule/ExtPowerDualFreeModule
Reported by:  Matthias Köppe  Owned by:  

Priority:  major  Milestone:  sage9.8 
Component:  linear algebra  Keywords:  
Cc:  Travis Scrimshaw, Eric Gourgoulhon, Michael Jung  Merged in:  
Authors:  Reviewers:  
Report Upstream:  N/A  Work issues:  
Branch:  Commit:  
Dependencies:  #30229  Stopgaps: 
Description
This coercion is going in the wrong direction and seems quite dangerous.
Change History (26)
comment:1 Changed 2 years ago by
comment:2 followup: 3 Changed 2 years ago by
Compare with:
sage: ZZ.has_coerce_map_from(Z5) False sage: Z5.has_coerce_map_from(ZZ) True sage: QQ.has_coerce_map_from(QQ/ZZ) False sage: (QQ/ZZ).has_coerce_map_from(QQ) True
comment:3 followups: 4 7 Changed 2 years ago by
Replying to mkoeppe:
Compare with:
sage: ZZ.has_coerce_map_from(Z5) False sage: Z5.has_coerce_map_from(ZZ) True sage: QQ.has_coerce_map_from(QQ/ZZ) False sage: (QQ/ZZ).has_coerce_map_from(QQ) True
The coercion direction is clear from the quotient view point, but the opposite direction is also clear from the "tensor with symmetries" view point. IMHO, this is the latter that we need for tensor calculus: when we do a + t
, with a
in A
and t
in T
(notations from comment:1), we want the result to be in T
with a prior coercion of a
to an element of T
.
comment:4 Changed 2 years ago by
Replying to egourgoulhon:
Replying to mkoeppe:
Compare with:
sage: ZZ.has_coerce_map_from(Z5) False sage: Z5.has_coerce_map_from(ZZ) True sage: QQ.has_coerce_map_from(QQ/ZZ) False sage: (QQ/ZZ).has_coerce_map_from(QQ) TrueThe coercion direction is clear from the quotient view point, but the opposite direction is also clear from the "tensor with symmetries" view point. IMHO, this is the latter that we need for tensor calculus: when we do
a + t
, witha
inA
andt
inT
(notations from comment:1), we want the result to be inT
with a prior coercion ofa
to an element ofT
.
Precisely. That is exactly what I was going to point out as well; but you were faster. :)
There is a canonical isomorphism between antisymmetric tensors of rank (k,0)
and the exterior algebra.
I also vote to keep the current behavior, with the same argument you gave above.
comment:5 followup: 6 Changed 2 years ago by
Being canonical is a necessary condition for a coerce map, but not a sufficient one.
In #30242 (unfinished), this canonical injection from the exterior module to the tensor module is made available as the "lift" map. But it should not be a coercion.
comment:6 followup: 8 Changed 2 years ago by
Replying to mkoeppe:
...But it should not be a coercion.
Why not?
I cannot see any practical use for such a coercion. The current coercion, on the other hand, is needed to perform tensor calculus. This is what the whole piece of software is about.
Furthermore, removing the current coercion could corrupt many notebooks which have already been written with SageManifolds.
comment:7 Changed 2 years ago by
Replying to egourgoulhon:
[...] we need for tensor calculus: when we do
a + t
, witha
inA
andt
inT
(notations from comment:1), we want the result to be inT
with a prior coercion ofa
to an element ofT
.
Could you point me to a good example where you need this coercion, and where it would not be practical to use the lift map from A to T explicitly? This would be very helpful.
There is nothing really in the doctests of sage manifolds that needs these coercions. Indeed, if I disable these coercions, almost all tests pass.

src/sage/manifolds/differentiable/tensorfield_module.py
diff git a/src/sage/manifolds/differentiable/tensorfield_module.py b/src/sage/manifolds/differentiable/tensorfield_module.py index fff3fac10b..4cf940a28b 100644
a b class TensorFieldModule(UniqueRepresentation, Parent): 448 448 return (self._tensor_type == other._tensor_type 449 449 and self._domain.is_subset(other._domain) 450 450 and self._ambient_domain.is_subset(other._ambient_domain)) 451 if isinstance(other, DiffFormModule):452 # coercion of pforms to type(0,p) tensor fields453 return (self._vmodule is other.base_module()454 and self._tensor_type == (0, other.degree()))455 if isinstance(other, MultivectorModule):456 # coercion of pvector fields to type(p,0) tensor fields457 return (self._vmodule is other.base_module()458 and self._tensor_type == (other.degree(),0))459 451 if isinstance(other, AutomorphismFieldGroup): 460 452 # coercion of automorphism fields to type(1,1) tensor fields 461 453 return (self._vmodule is other.base_module() 
src/sage/tensor/modules/tensor_free_module.py
diff git a/src/sage/tensor/modules/tensor_free_module.py b/src/sage/tensor/modules/tensor_free_module.py index 9285cbc0de..9886c90062 100644
a b class TensorFreeModule(FiniteRankFreeModule): 617 617 self._fmodule is other.domain() 618 618 else: 619 619 return False 620 if isinstance(other, ExtPowerFreeModule):621 # Coercion of an alternating contravariant tensor to a622 # type(p,0) tensor:623 return self._tensor_type == (other.degree(), 0) and \624 self._fmodule is other.base_module()625 if isinstance(other, ExtPowerDualFreeModule):626 # Coercion of an alternating form to a type(0,p) tensor:627 return self._tensor_type == (0, other.degree()) and \628 self._fmodule is other.base_module()629 620 if isinstance(other, FreeModuleLinearGroup): 630 621 # Coercion of an automorphism to a type(1,1) tensor: 631 622 return self._tensor_type == (1,1) and \
comment:8 Changed 2 years ago by
Replying to ghmjungmath:
Replying to mkoeppe:
...But it should not be a coercion.
Why not?
Basically, because not everything that we call "canonical" is actually canonical in a technical sense. The map from T to the quotient A is actually canonical. "The" lift map from A to T is not  we are merely picking a preferred choice.
comment:9 Changed 2 years ago by
What would happen if one implements both directions, i.e. both coercions? Would that be possible?
comment:10 Changed 2 years ago by
I would think that this is dangerous because the composition antisymmetrizes.
comment:11 followups: 13 15 Changed 2 years ago by
I just found a good discussion of the two viewpoints of ExtPower
as a quotient space vs. as a subspace (which I was not familiar with) in https://kconrad.math.uconn.edu/blurbs/linmultialg/extmod.pdf, page 12/13.
comment:12 followup: 17 Changed 2 years ago by
Replying to mkoeppe:
I would think that this is dangerous because the composition antisymmetrizes.
Where's the problem in that?
However, due to my comment:7 in #30095, the aforementioned map is not necessarily an isomorphism if the field characteristic is not zero. Usually it is given, but we also allow other fields/rings as base. Hence, I tend to agree with you, Matthias.
Anyway, it would be good to keep the from Eric mentioned behavior a+T
in case of characteristic zero. Is there a compromise, we can go?
By the way: not having a doctest doesn't mean that it is not used in practice, I'd say. Imho, the documention is in general very sparse, even though the manifolds extension has a comparatively comprehensive documentation.
comment:13 Changed 2 years ago by
Replying to mkoeppe:
I just found a good discussion of the two viewpoints of
ExtPower
as a quotient space vs. as a subspace (which I was not familiar with) in https://kconrad.math.uconn.edu/blurbs/linmultialg/extmod.pdf, page 12/13.
Thank you. This is more trustworthy than my reference to Wikipedia. On top, it is very good explained.
comment:14 followups: 16 18 Changed 2 years ago by
Suggestion: What about just renaming ExtPowerFreeModule
into something like AltContrTensorFreeModule
, and keep the coercion as it is.
In a next step, we create the class ExtPowerFreeModule
which behaves similar to quotients of polynomial rings. Namely, applying a tensor to ExtPowerFreeModule
(i.e. reducing w.r.t. the ideal <x*x>
) yields an element of AltContrTensorFreeModule
. In that class, we can include all the things we need for a quotient such as a method lift and the coercion from tensor fields to the exterior algebra given by this quotient.
Just as a rough idea. This would make everyone happy and is mathematical rigorous.
Edit: Sorry. Wasn't such a good idea. I don't think that is what we want.
I think there should be no problem in implementing a coercion from FreeModuleTensor
to ExtPowerFreeModule
(given by the quotient) and a coercion from ExtPowerFreeModule
to FreeModuleTensor
(given by 1/k! α_(k,V)
in case of zero field characteristic).
comment:15 Changed 2 years ago by
Replying to mkoeppe:
I just found a good discussion of the two viewpoints of
ExtPower
as a quotient space vs. as a subspace (which I was not familiar with) in https://kconrad.math.uconn.edu/blurbs/linmultialg/extmod.pdf, page 12/13.
Indeed, in page 12 of this reference, we can read: It means we can think of Λ^{k} (V ) as a subspace of the tensor power V^{⊗k} instead of as a quotient space. This viewpoint is widely used in differential geometry. This is of course the differential geometry viewpoint that I took when introducing ExtPowerFreeModule
. It is also written: That is fine for real and complex
vector spaces (as in differential geometry), but it is not a universal method.
comment:16 Changed 2 years ago by
Replying to ghmjungmath:
Suggestion: What about just renaming
ExtPowerFreeModule
into something likeAltContrTensorFreeModule
, and keep the coercion as it is.In a next step, we create the class
ExtPowerFreeModule
which behaves similar to quotients of polynomial rings. Namely, applying a tensor toExtPowerFreeModule
(i.e. reducing w.r.t. the ideal<x*x>
) yields an element ofAltContrTensorFreeModule
. In that class, we can include all the things we need for a quotient such as a method lift and the coercion from tensor fields to the exterior algebra given by this quotient.Just as a rough idea. This would make everyone happy and is mathematical rigorous.
Edit: Sorry. Wasn't such a good idea. I don't think that is what we want.
Why do you think this is not a good idea? At least, this would be mathematically correct for any base ring...
comment:17 Changed 2 years ago by
Replying to ghmjungmath:
By the way: not having a doctest doesn't mean that it is not used in practice, I'd say.
Yes, I didn't mean to imply that.
Imho, the documention is in general very sparse, even though the manifolds extension has a comparatively comprehensive documentation.
Rather, as we discussed briefly on another ticket, I think it is crucial to extend the doctests so that typical use in practice is covered, perhaps by importing the sagemanifolds worksheets.
comment:18 followup: 20 Changed 2 years ago by
Replying to ghmjungmath:
Suggestion: What about just renaming
ExtPowerFreeModule
into something likeAltContrTensorFreeModule
, and keep the coercion as it is.
Note that #30229 (unfinished) creates submodules of the tensor modules with arbitrary prescribed symmetries. Prescribed antisymmetries are a special case. These submodules, of course, do have coercions into the ambient tensor module.
comment:19 Changed 2 years ago by
Dependencies:  → #30229 

comment:20 Changed 2 years ago by
Replying to mkoeppe:
Replying to ghmjungmath:
Suggestion: What about just renaming
ExtPowerFreeModule
into something likeAltContrTensorFreeModule
, and keep the coercion as it is.Note that #30229 (unfinished) creates submodules of the tensor modules with arbitrary prescribed symmetries. Prescribed antisymmetries are a special case. These submodules, of course, do have coercions into the ambient tensor module.
Indeed, this seems the way to go.
comment:21 Changed 2 years ago by
Milestone:  sage9.2 → sage9.3 

comment:22 Changed 20 months ago by
Milestone:  sage9.3 → sage9.4 

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.
comment:23 Changed 15 months ago by
Milestone:  sage9.4 → sage9.5 

comment:24 Changed 10 months ago by
Milestone:  sage9.5 → sage9.6 

comment:25 Changed 7 months ago by
Milestone:  sage9.6 → sage9.7 

comment:26 Changed 4 weeks ago by
Milestone:  sage9.7 → sage9.8 

What do you mean by "this coercion is going in the wrong direction"? It seems to me that the direction is correct. For instance, we have
This is correct because any element of
A
is a tensor of type (2,0) (and the identification is canonical), whereas the reverse is not true.