Opened 2 years ago

Last modified 3 months 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: sage-9.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:

Status badges

Description

This coercion is going in the wrong direction and seems quite dangerous.

Change History (26)

comment:1 Changed 2 years ago by Eric Gourgoulhon

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

sage: M = FiniteRankFreeModule(ZZ, 2, name='M')
sage: T = M.tensor_module(2, 0)
sage: A = M.exterior_power(2)
sage: T.has_coerce_map_from(A)
True
sage: A.has_coerce_map_from(T)
False

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.

comment:2 Changed 2 years ago by Matthias Köppe

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 in reply to:  2 ; Changed 2 years ago by Eric Gourgoulhon

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 in reply to:  3 Changed 2 years ago by Michael Jung

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)
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.

Precisely. That is exactly what I was going to point out as well; but you were faster. :)

I also vote to keep the current behavior, with the same argument you gave above.

There is a canonical isomorphism between anti-symmetric tensors of rank (k,0) and the exterior algebra.

Version 1, edited 2 years ago by Michael Jung (previous) (next) (diff)

comment:5 Changed 2 years ago by Matthias Köppe

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 in reply to:  5 ; Changed 2 years ago by Michael Jung

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.

Last edited 2 years ago by Michael Jung (previous) (diff)

comment:7 in reply to:  3 Changed 2 years ago by Matthias Köppe

Replying to egourgoulhon:

[...] 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.

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): 
    448448            return (self._tensor_type == other._tensor_type
    449449                    and self._domain.is_subset(other._domain)
    450450                    and self._ambient_domain.is_subset(other._ambient_domain))
    451         if isinstance(other, DiffFormModule):
    452             # coercion of p-forms to type-(0,p) tensor fields
    453             return (self._vmodule is other.base_module()
    454                     and self._tensor_type == (0, other.degree()))
    455         if isinstance(other, MultivectorModule):
    456             # coercion of p-vector fields to type-(p,0) tensor fields
    457             return (self._vmodule is other.base_module()
    458                     and self._tensor_type == (other.degree(),0))
    459451        if isinstance(other, AutomorphismFieldGroup):
    460452            # coercion of automorphism fields to type-(1,1) tensor fields
    461453            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): 
    617617                                         self._fmodule is other.domain()
    618618            else:
    619619                return False
    620         if isinstance(other, ExtPowerFreeModule):
    621             # Coercion of an alternating contravariant tensor to a
    622             # 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()
    629620        if isinstance(other, FreeModuleLinearGroup):
    630621            # Coercion of an automorphism to a type-(1,1) tensor:
    631622            return self._tensor_type == (1,1) and \

comment:8 in reply to:  6 Changed 2 years ago by Matthias Köppe

Replying to gh-mjungmath:

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 Michael Jung

What would happen if one implements both directions, i.e. both coercions? Would that be possible?

comment:10 Changed 2 years ago by Matthias Köppe

I would think that this is dangerous because the composition antisymmetrizes.

comment:11 Changed 2 years ago by Matthias Köppe

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 Changed 2 years ago by Michael Jung

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.

Last edited 2 years ago by Michael Jung (previous) (diff)

comment:13 in reply to:  11 Changed 2 years ago by Michael Jung

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 Changed 2 years ago by Michael Jung

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).

Last edited 2 years ago by Michael Jung (previous) (diff)

comment:15 in reply to:  11 Changed 2 years ago by Eric Gourgoulhon

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.

Last edited 2 years ago by Eric Gourgoulhon (previous) (diff)

comment:16 in reply to:  14 Changed 2 years ago by Eric Gourgoulhon

Replying to gh-mjungmath:

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.

Why do you think this is not a good idea? At least, this would be mathematically correct for any base ring...

comment:17 in reply to:  12 Changed 2 years ago by Matthias Köppe

Replying to gh-mjungmath:

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 sage-manifolds worksheets.

comment:18 in reply to:  14 ; Changed 2 years ago by Matthias Köppe

Replying to gh-mjungmath:

Suggestion: What about just renaming ExtPowerFreeModule into something like AltContrTensorFreeModule, 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 Matthias Köppe

Dependencies: #30229

comment:20 in reply to:  18 Changed 2 years ago by Eric Gourgoulhon

Replying to mkoeppe:

Replying to gh-mjungmath:

Suggestion: What about just renaming ExtPowerFreeModule into something like AltContrTensorFreeModule, 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 Matthias Köppe

Milestone: sage-9.2sage-9.3

comment:22 Changed 22 months ago by Matthias Köppe

Milestone: sage-9.3sage-9.4

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

comment:23 Changed 17 months ago by Matthias Köppe

Milestone: sage-9.4sage-9.5

comment:24 Changed 12 months ago by Matthias Köppe

Milestone: sage-9.5sage-9.6

comment:25 Changed 9 months ago by Matthias Köppe

Milestone: sage-9.6sage-9.7

comment:26 Changed 3 months ago by Matthias Köppe

Milestone: sage-9.7sage-9.8
Note: See TracTickets for help on using tickets.