15
15
16
16
from sage .misc .cachefunc import cached_method
17
17
from sage .misc .misc_c import prod
18
+ from copy import copy
18
19
19
20
from sage .categories .algebras_with_basis import AlgebrasWithBasis
20
21
from sage .categories .graded_algebras_with_basis import GradedAlgebrasWithBasis
@@ -37,6 +38,35 @@ class AssociatedGradedAlgebra(CombinatorialFreeModule):
37
38
INPUT:
38
39
39
40
- ``A`` -- a filtered algebra
41
+
42
+ EXAMPLES:
43
+
44
+ sage: A = Algebras(QQ).WithBasis().Filtered().example()
45
+ sage: grA = A.graded_algebra()
46
+ sage: x,y,z = map(lambda s: grA.algebra_generators()[s], ['x','y','z'])
47
+ sage: x
48
+ bar(U['x'])
49
+ sage: y * x + z
50
+ bar(U['x']*U['y']) + bar(U['z'])
51
+ sage: A(y) * A(x) + A(z)
52
+ U['x']*U['y']
53
+
54
+ We note that the conversion between ``A`` and ``grA`` is the canonical
55
+ ``QQ``-module isomorphism::
56
+
57
+ sage: grA(A.an_element())
58
+ bar(U['x']^2*U['y']^2*U['z']^3)
59
+ sage: elt = A.an_element() + A.algebra_generators()['x'] + 2
60
+ sage: grelt = grA(elt); grelt
61
+ bar(U['x']^2*U['y']^2*U['z']^3) + bar(U['x']) + 2*bar(1)
62
+ sage: A(grelt) == elt
63
+ True
64
+
65
+ .. TODO::
66
+
67
+ The algebra ``A`` must currently be an instance of (a subclass of)
68
+ :class:`CombinatorialFreeModule`. This should work with any algebra
69
+ with a basis.
40
70
"""
41
71
def __init__ (self , A , category = None ):
42
72
"""
@@ -51,16 +81,21 @@ def __init__(self, A, category=None):
51
81
if A not in AlgebrasWithBasis (A .base_ring ()).Filtered ():
52
82
raise ValueError ("the base algebra must be filtered" )
53
83
self ._A = A
84
+
54
85
if category is None :
55
86
category = A .category ().Graded ()
56
- from copy import copy
57
87
opts = copy (A .print_options ())
58
88
if not opts ['prefix' ] and not opts ['bracket' ]:
59
89
opts ['bracket' ] = '('
60
90
opts ['prefix' ] = opts ['prefix' ] + 'bar'
91
+
61
92
CombinatorialFreeModule .__init__ (self , A .base_ring (), A .indices (),
62
93
category = category , ** opts )
63
94
95
+ # Setup the conversion back
96
+ phi = self .module_morphism (lambda x : A .monomial (x ), codomain = A )
97
+ self ._A .register_conversion (phi )
98
+
64
99
def _repr_ (self ):
65
100
"""
66
101
Return a string representation of ``self``.
@@ -92,6 +127,11 @@ def _element_constructor_(self, x):
92
127
"""
93
128
Construct an element of ``self`` from ``x``.
94
129
130
+ .. NOTE::
131
+
132
+ This constructs an element from the filtered algebra ``A``
133
+ by the canonical module isomorphism.
134
+
95
135
EXAMPLES::
96
136
97
137
sage: A = Algebras(QQ).WithBasis().Filtered().example()
0 commit comments