Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/categories/examples/crystals.py
4072 views
1
r"""
2
Example of a crystal
3
"""
4
#*****************************************************************************
5
# Copyright (C) 2010 Anne Schilling <anne at math.ucdavis.edu>
6
#
7
# Distributed under the terms of the GNU General Public License (GPL)
8
# http://www.gnu.org/licenses/
9
#******************************************************************************
10
11
from sage.structure.parent import Parent
12
from sage.structure.element_wrapper import ElementWrapper
13
from sage.structure.unique_representation import UniqueRepresentation
14
from sage.categories.classical_crystals import ClassicalCrystals
15
from sage.graphs.all import DiGraph
16
from sage.categories.enumerated_sets import EnumeratedSets
17
from sage.combinat.root_system.cartan_type import CartanType
18
19
class HighestWeightCrystalOfTypeA(UniqueRepresentation, Parent):
20
r"""
21
An example of a crystal: the highest weight crystal of type `A_n`
22
of highest weight `\omega_1`.
23
24
The purpose of this class is to provide a minimal template for
25
implementing crystals. See
26
:class:`~sage.combinat.crystals.letters.CrystalOfLetters` for a
27
full featured and optimized implementation.
28
29
EXAMPLES::
30
31
sage: C = Crystals().example()
32
sage: C
33
Highest weight crystal of type A_3 of highest weight omega_1
34
sage: C.category()
35
Category of classical crystals
36
37
The elements of this crystal are in the set `\{1,\ldots,n+1\}`::
38
39
sage: C.list()
40
[1, 2, 3, 4]
41
sage: C.module_generators[0]
42
1
43
44
The crystal operators themselves correspond to the elementary
45
transpositions::
46
47
sage: b = C.module_generators[0]
48
sage: b.f(1)
49
2
50
sage: b.f(1).e(1) == b
51
True
52
53
TESTS::
54
55
sage: C = Crystals().example()
56
sage: TestSuite(C).run(verbose = True)
57
running ._test_an_element() . . . pass
58
running ._test_category() . . . pass
59
running ._test_elements() . . .
60
Running the test suite of self.an_element()
61
running ._test_category() . . . pass
62
running ._test_eq() . . . pass
63
running ._test_not_implemented_methods() . . . pass
64
running ._test_pickling() . . . pass
65
running ._test_stembridge_local_axioms() . . . pass
66
pass
67
running ._test_elements_eq() . . . pass
68
running ._test_enumerated_set_contains() . . . pass
69
running ._test_enumerated_set_iter_cardinality() . . . pass
70
running ._test_enumerated_set_iter_list() . . . pass
71
running ._test_eq() . . . pass
72
running ._test_fast_iter() . . . pass
73
running ._test_not_implemented_methods() . . . pass
74
running ._test_pickling() . . . pass
75
running ._test_some_elements() . . . pass
76
running ._test_stembridge_local_axioms() . . . pass
77
78
Only the following basic operations are implemented:
79
- :meth:`~sage.categories.crystals.Crystals.cartan_type` or an attribute _cartan_type
80
- an attribute module_generators
81
- :meth:`.Element.e`
82
- :meth:`.Element.f`
83
84
All the other usual crystal operations are inherited from the
85
categories; for example::
86
87
sage: C.cardinality()
88
4
89
"""
90
91
def __init__(self, n = 3):
92
"""
93
EXAMPLES::
94
95
sage: C = sage.categories.examples.crystals.HighestWeightCrystalOfTypeA(n=4)
96
sage: C == Crystals().example(n=4)
97
True
98
"""
99
Parent.__init__(self, category = ClassicalCrystals())
100
self.n = n
101
self._cartan_type = CartanType(['A',n])
102
self.module_generators = [ self(1) ]
103
104
def _repr_(self):
105
"""
106
EXAMPLES::
107
108
sage: Crystals().example()
109
Highest weight crystal of type A_3 of highest weight omega_1
110
"""
111
return "Highest weight crystal of type A_%s of highest weight omega_1"%(self.n)
112
113
# temporary woraround while an_element is overriden by Parent
114
_an_element_ = EnumeratedSets.ParentMethods._an_element_
115
116
class Element(ElementWrapper):
117
118
def e(self, i):
119
r"""
120
Returns the action of `e_i` on ``self``.
121
122
EXAMPLES::
123
124
sage: C = Crystals().example(4)
125
sage: [[c,i,c.e(i)] for i in C.index_set() for c in C if c.e(i) is not None]
126
[[2, 1, 1], [3, 2, 2], [4, 3, 3], [5, 4, 4]]
127
"""
128
assert i in self.index_set()
129
if self.value == i+1:
130
return self.parent()(self.value-1)
131
else:
132
return None
133
134
def f(self, i):
135
r"""
136
Returns the action of `f_i` on ``self``.
137
138
EXAMPLES::
139
140
sage: C = Crystals().example(4)
141
sage: [[c,i,c.f(i)] for i in C.index_set() for c in C if c.f(i) is not None]
142
[[1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5]]
143
"""
144
assert i in self.index_set()
145
if self.value == i:
146
return self.parent()(self.value+1)
147
else:
148
return None
149
150
151
class NaiveCrystal(UniqueRepresentation, Parent):
152
r"""
153
This is an example of a "crystal" which does not come from any kind of
154
representation, designed primarily to test the Stembridge local rules with.
155
The crystal has vertices labeled 0 through 5, with 0 the highest weight.
156
157
The code here could also possibly be generalized to create a class that
158
automatically builds a crystal from an edge-colored digraph, if someone
159
feels adventurous.
160
161
Currently, only the methods :meth:`highest_weight_vector`, :meth:`e`, and :meth:`f` are
162
guaranteed to work.
163
164
EXAMPLES::
165
166
sage: C = Crystals().example(choice='naive')
167
sage: C.highest_weight_vector()
168
0
169
"""
170
def __init__(self):
171
"""
172
EXAMPLES::
173
174
sage: C = sage.categories.examples.crystals.NaiveCrystal()
175
sage: C == Crystals().example(choice='naive')
176
True
177
"""
178
Parent.__init__(self, category = ClassicalCrystals())
179
self.n = 2
180
self._cartan_type = CartanType(['A',2])
181
self.G = DiGraph(5)
182
self.G.add_edges([ [0,1,1], [1,2,1], [2,3,1], [3,5,1], [0,4,2], [4,5,2] ])
183
self.module_generators = [ self(0) ]
184
185
def __repr__(self):
186
"""
187
EXAMPLES::
188
189
sage: Crystals().example(choice='naive')
190
A broken crystal, defined by digraph, of dimension five.
191
"""
192
return "A broken crystal, defined by digraph, of dimension five."
193
194
class Element(ElementWrapper):
195
def e(self, i):
196
r"""
197
Returns the action of `e_i` on ``self``.
198
199
EXAMPLES::
200
201
sage: C = Crystals().example(choice='naive')
202
sage: [[c,i,c.e(i)] for i in C.index_set() for c in [C(j) for j in [0..5]] if c.e(i) is not None]
203
[[1, 1, 0], [2, 1, 1], [3, 1, 2], [5, 1, 3], [4, 2, 0], [5, 2, 4]]
204
"""
205
assert i in self.index_set()
206
for edge in self.parent().G.edges():
207
if edge[1]==int(str(self)) and edge[2]==i:
208
return self.parent()(edge[0])
209
return None
210
211
def f(self, i):
212
r"""
213
Returns the action of `f_i` on ``self``.
214
215
EXAMPLES::
216
217
sage: C = Crystals().example(choice='naive')
218
sage: [[c,i,c.f(i)] for i in C.index_set() for c in [C(j) for j in [0..5]] if c.f(i) is not None]
219
[[0, 1, 1], [1, 1, 2], [2, 1, 3], [3, 1, 5], [0, 2, 4], [4, 2, 5]]
220
"""
221
assert i in self.index_set()
222
for edge in self.parent().G.edges_incident(int(str(self))):
223
if edge[2] == i:
224
return self.parent()(edge[1])
225
return None
226
227
228
229