Changes between Version 2 and Version 3 of Ticket #30245


Ignore:
Timestamp:
08/01/20 02:13:54 (2 years ago)
Author:
mkoeppe
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #30245 – Description

    v2 v3  
    1 It inherits `_add_` and `_sub_` methods that make no sense in the coercion system. These methods are guaranteed by the coercion system to get elements of the parent, and are supposed to give elements as well.
     1It inherits `_add_` and `_sub_` methods that make no sense in the coercion system. These methods are guaranteed by the coercion system to get elements of the parent, and are supposed to give elements as well:
     2{{{
     3sage: M = FiniteRankFreeModule(ZZ, 2, name='M')
     4sage: G = M.general_linear_group()
     5sage: T11 = M.tensor_module(1, 1)
     6sage: from sage.structure.coerce import CoercionModel
     7sage: cm = CoercionModel()
     8sage: cm.explain(G, G, operator.add)
     9Identical parents, arithmetic performed immediately.
     10Result lives in General linear group of the Rank-2 free module M over the Integer Ring
     11General linear group of the Rank-2 free module M over the Integer Ring
     12}}}
    213
    314Also other operations inherited from the module are problematic because they are not type-stable. The result of operations is supposed to depend only on the parents of the operands, but:
    415{{{
     16sage: cm.explain(ZZ, G, operator.mul)
     17Action discovered.
     18    Left Integer Multiplication by Integer Ring on General linear group of the Rank-2 free module M over the Integer Ring
     19Result lives in General linear group of the Rank-2 free module M over the Integer Ring
     20General linear group of the Rank-2 free module M over the Integer Ring
    521sage: 2 * a
    622Type-(1,1) tensor on the Rank-2 free module M over the Integer Ring
     
    1228Automorphism of the Rank-2 free module M over the Integer Ring
    1329}}}
     30(Note in particular the scary last one...)
    1431
    15 (a) Instead, there should be a coercion map from `FreeModuleLinearGroup`, sending a `FreeModuleAutomorphism` to the underlying tensor.
    16 
    17 (b) Alternatively, + and - could be implemented as actions.
     32There is already a coercion map from `FreeModuleLinearGroup`, sending a `FreeModuleAutomorphism` to the underlying tensor:
     33{{{
     34sage: M = FiniteRankFreeModule(ZZ, 2, name='M')
     35sage: G = M.general_linear_group()
     36sage: T11 = M.tensor_module(1, 1)
     37sage: T11.coerce_map_from(G)
     38Coercion map:
     39  From: General linear group of the Rank-2 free module M over the Integer Ring
     40  To:   Free module of type-(1,1) tensors on the Rank-2 free module M over the Integer Ring
     41sage: _.category()
     42Category of elements of Set of Morphisms from General linear group of the Rank-2 free module M over the Integer Ring to Free module of type-(1,1) tensors on the Rank-2 free module M over the Integer Ring in Category of sets
     43}}}
     44This coercion can handle all of the module operations if we let it.
    1845
    1946