Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

code directory

Views: 4862
1
# This file was *autogenerated* from the file local_permgroup.sage
2
from sage.all_cmdline import * # import sage library
3
_sage_const_1 = Integer(1); _sage_const_0 = Integer(0)
4
"""
5
Local Permutation Groups
6
7
This module contains several extensions to classes inherited from sage PermutationGroup_generic classes.
8
It fills in missing methods resp. functionality
9
10
##############################################################################
11
# Copyright (C) 2016 Sebastian Oehms <[email protected]>
12
#
13
# Distributed under the terms of the GNU General Public License (GPL)
14
#
15
# The full text of the GPL is available at:
16
#
17
# http://www.gnu.org/licenses/
18
##############################################################################
19
20
This module contains extensions of the following classes
21
22
sage class | extended class
23
-------------------------------------------------------------------------------
24
PermutationGroup_subgroup: | local_PermutationGroup_subgroup
25
PGU | PGU
26
PSp | PSp
27
IrreducibleComplexReflectionGroup | IrreducibleComplexReflectionGroup
28
29
AUTHOR
30
31
- Sebastian Oehms, Sept. 2016
32
33
"""
34
35
36
37
38
39
####################################################################################################
40
# Extension to PermutationGroup_generic / PermutationGroup_subgroup
41
####################################################################################################
42
from sage.groups.perm_gps.permgroup import *
43
from sage.groups.perm_gps.permgroup_named import *
44
from lib.utils_sys import *
45
from lib.local_matrix_group import *
46
47
48
49
def _call_with_conversion_(PermGroup, x, check=True, try_conv_map=True):
50
"""
51
This function provides an adaption of the method __call__ of PermutationGroup_generic in order to make conversion_maps
52
to groups whose class is inherited from PermutationGroup_generic callable by name. This function should be used for
53
overloading the __call__ - method of such derived classes
54
55
If you don't see this well formatted type
56
57
sage: print _call_with_conversion_.__doc__
58
59
60
EXAMPLE:
61
62
see the applications of this function for PermutationGroup_subgroup and IrreducibleComplexReflectionGroup:
63
64
sage: print local_PermutationGroup_subgroup.__call__.__doc__
65
sage: print IrreducibleComplexReflectionGroup.__call__.__doc__
66
67
AUTHOR
68
69
- Sebastian Oehms, Sept. 2016
70
71
"""
72
73
# print_time_tb( Text="Begin %s %s %s" %(x, check, try_conv_map), MaxDepth=5, Level=TsLevel.StackInfo )
74
75
if isinstance(x, (int, long, Integer)) and x == _sage_const_1 :
76
return PermGroup.identity()
77
78
GroupFrom = None
79
80
try:
81
GroupFrom = x.parent()
82
if GroupFrom is PermGroup:
83
return x
84
except AttributeError:
85
GroupFrom = None
86
87
if try_conv_map == False:
88
return PermGroup._element_class()(x, PermGroup, check=check)
89
90
conv_map = None
91
if GroupFrom != None:
92
conv_map = PermGroup.coerce_map_from( GroupFrom )
93
if conv_map == None:
94
conv_map = PermGroup.convert_map_from( GroupFrom )
95
96
try:
97
return PermGroup._element_class()(x, PermGroup, check=check)
98
except:
99
if conv_map != None:
100
try:
101
return conv_map(x)
102
except:
103
return PermGroup._element_class()(x, PermGroup, check=check)
104
105
106
107
108
109
110
class local_PermutationGroup_subgroup(PermutationGroup_subgroup):
111
"""
112
Since the Method __call__ of PermutationGroup_subgroup(PermutationGroup_generic) does not support coerce_maps between
113
groups it is overloaded by this class to fill in the lack. Overloaded methods are:
114
- __call__
115
116
If you don't see this well formatted type
117
118
sage: print local_PermutationGroup_subgroup.__doc__
119
120
To see the docomentation of the original class type
121
122
sage: print PermutationGroup_subgroup.__doc__
123
124
AUTHOR
125
126
- Sebastian Oehms, Okt. 2016
127
128
"""
129
130
131
def __call__(self, x, check=True, try_conv_map=True):
132
"""
133
This method overloads the __call__-method of the original class since the method __call__ of
134
PermutationGroup_subgroup(PermutationGroup_generic) does not support coerce_maps between groups
135
Here is an improvement concerning this lack.
136
137
If you don't see this well formatted type
138
139
sage: print local_PermutationGroup_subgroup.__call__.__doc__
140
141
To see the docomentation of the original method type
142
143
sage: print PermutationGroup_subgroup.__call__.__doc__
144
145
EXAMPLE:
146
147
try to establish the natural projection from the general unitary group onto the projective unitary group.
148
first try without using the local_PermutationGroup_subgroup class
149
150
sage: GU4 = GU(4,2); GU4
151
General Unitary Group of degree 4 over Finite Field in a of size 2^2
152
sage: PGU4ambient = PGU(4,2); PGU4ambient
153
The projective general unitary group of degree 4 over Finite Field of size 2
154
sage: PGU4 = PGU4ambient.subgroup(PGU4ambient.gens()); PGU4
155
Subgroup of (The projective general unitary group of degree 4 over Finite Field of size 2) generated by [(3,4,5)
156
(7,8,9)(11,12,13)(15,16,17)(19,20,21)(26,34,30)(27,35,31)(28,36,32)(29,37,33)(38,70,54)(39,71,55)(40,72,56)
157
(41,73,57)(42,82,62)(43,83,63)(44,84,64)(45,85,65)(46,74,66)(47,75,67)(48,76,68)(49,77,69)(50,78,58)(51,79,59)
158
(52,80,60)(53,81,61), (1,6,22,26,43,3)(2,7,38)(4,8,54,30,60,48)(5,9,70,34,77,53)(10,39)(11,23,42)
159
(12,71,82,68,63,49)(13,55,62,81,83,52)(14,56,78,51,20,41)(15,72,50)(16,24,58,64,33,44)(17,40,18,73,66,47)
160
(19,57,46)(21,25,74,85,36,45)(28,75,37,29,59,32)(31,76,69)(35,61,80)(67,79)]
161
sage: isinstance( PGU4, PermutationGroup_subgroup )
162
True
163
sage: isinstance( PGU4, local_PermutationGroup_subgroup )
164
---------------------------------------------------------------------------
165
NameError Traceback (most recent call last)
166
<ipython-input-10-0dce512ea45e> in <module>()
167
----> 1 isinstance( PGU4, local_PermutationGroup_subgroup )
168
169
NameError: name 'local_PermutationGroup_subgroup' is not defined
170
sage: GU4_gap = GU4.gap()
171
sage: PGU4_gap = gap(PGU4)
172
sage: natProj_gap = GU4_gap.GroupHomomorphismByImagesNC( PGU4_gap, GU4_gap.GeneratorsOfGroup(),
173
PGU4_gap.GeneratorsOfGroup())
174
sage: def natProj_map( elem ):
175
res = natProj_gap.ImageElm( elem.gap() )
176
return res.sage()
177
....:
178
sage: natProj_hom = Hom( GU4, PGU(natProj_map)
179
sage: PGU4.register_conversion( natProj_hom )
180
sage: g1, g2 = GU4.gens()
181
sage: g = g1**3*g2; g
182
[1 0 1 0]
183
[1 0 0 0]
184
[0 1 0 1]
185
[0 1 0 0]
186
sage: PGU4(g)
187
---------------------------------------------------------------------------
188
TypeError Traceback (most recent call last)
189
<ipython-input-11-c93f0a431112> in <module>()
190
----> 1 PGU4(g)
191
.......................................
192
TypeError: 'UnitaryMatrixGroup_gap_with_category.element_class' object is not iterable
193
sage: natProj_hom(g)
194
(1,6,22,26,43,3)(2,7,38)(4,8,54,30,60,48)(5,9,70,34,77,53)(10,39)(11,23,42)(12,71,82,68,63,49)(13,55,62,81,83,52)
195
(14,56,78,51,20,41)(15,72,50)(16,24,58,64,33,44)(17,40,18,73,66,47)(19,57,46)(21,25,74,85,36,45)
196
(28,75,37,29,59,32)(31,76,69)(35,61,80)(67,79)
197
sage:
198
199
now trying the same using the class local_PermutationGroup_subgroup
200
201
sage: from lib.local_permgroup import *
202
sage: GU4 = GU(4,2); GU4
203
General Unitary Group of degree 4 over Finite Field in a of size 2^2
204
sage: PGU4ambient = PGU(4,2); PGU4ambient
205
The projective general unitary group of degree 4 over Finite Field of size 2
206
sage: PGU4 = PGU4ambient.subgroup(PGU4ambient.gens()); PGU4
207
Subgroup of (The projective general unitary group of degree 4 over Finite Field of size 2) generated by [(3,4,5)
208
(7,8,9)(11,12,13)(15,16,17)(19,20,21)(26,34,30)(27,35,31)(28,36,32)(29,37,33)(38,70,54)(39,71,55)(40,72,56)
209
(41,73,57)(42,82,62)(43,83,63)(44,84,64)(45,85,65)(46,74,66)(47,75,67)(48,76,68)(49,77,69)(50,78,58)(51,79,59)
210
(52,80,60)(53,81,61), (1,6,22,26,43,3)(2,7,38)(4,8,54,30,60,48)(5,9,70,34,77,53)(10,39)(11,23,42)
211
(12,71,82,68,63,49)(13,55,62,81,83,52)(14,56,78,51,20,41)(15,72,50)(16,24,58,64,33,44)(17,40,18,73,66,47)
212
(19,57,46)(21,25,74,85,36,45)(28,75,37,29,59,32)(31,76,69)(35,61,80)(67,79)]
213
sage: isinstance( PGU4, PermutationGroup_subgroup )
214
True
215
sage: isinstance( PGU4, local_PermutationGroup_subgroup )
216
True
217
sage: GU4_gap = GU4.gap()
218
sage: PGU4_gap = gap(PGU4)
219
sage: natProj_gap = GU4_gap.GroupHomomorphismByImagesNC( PGU4_gap, GU4_gap.GeneratorsOfGroup(),
220
PGU4_gap.GeneratorsOfGroup())
221
sage: def natProj_map( elem ):
222
res = natProj_gap.ImageElm( elem.gap() )
223
return res.sage()
224
....:
225
sage: natProj_hom = Hom(GU4, PGU4)(natProj_map)
226
sage: PGU4.register_conversion(natProj_hom)
227
sage: g1, g2 = GU4.gens()
228
sage: g = g1**3*g2; g
229
[1 0 1 0]
230
[1 0 0 0]
231
[0 1 0 1]
232
[0 1 0 0]
233
sage: PGU4(g)
234
(1,6,22,26,43,3)(2,7,38)(4,8,54,30,60,48)(5,9,70,34,77,53)(10,39)(11,23,42)(12,71,82,68,63,49)(13,55,62,81,83,52)
235
(14,56,78,51,20,41)(15,72,50)(16,24,58,64,33,44)(17,40,18,73,66,47)(19,57,46)(21,25,74,85,36,45)
236
(28,75,37,29,59,32)(31,76,69)(35,61,80)(67,79)
237
sage:
238
239
240
241
TESTS:
242
243
sage: from lib.local_permgroup import *
244
sage: sage.groups.perm_gps.permgroup.PermutationGroup_subgroup = local_PermutationGroup_subgroup
245
sage: GU4 = GU(4,2)
246
sage: PGU4ambient = PGU(4,2)
247
sage: PGU4 = PGU4ambient.subgroup(PGU4ambient.gens())
248
sage: TestSuite(PGU4).run()
249
250
AUTHOR:
251
252
- Sebastian Oehms, Okt. 2016
253
"""
254
return _call_with_conversion_(self, x, check=check, try_conv_map=try_conv_map)
255
256
257
def __contains__(self, item):
258
"""
259
Returns boolean value of ``item in self``.
260
This method from PermutationGroup_generic has been overwritten here to avoid recursion loops. This method uses the
261
__call__ method which has been extended here. But to check if an element is in the group the original version of
262
__call__ must be applied.
263
264
If you don't see this well formatted type
265
266
sage: print local_PermutationGroup_subgroup.__contains__.__doc__
267
268
To see the docomentation of the original method type
269
270
sage: print PermutationGroup_subgroup.__contains__.__doc__
271
"""
272
273
try:
274
item = self(item, check=True, try_conv_map=False)
275
except Exception:
276
return False
277
return True
278
279
280
281
def gap(self):
282
"""
283
Making the gap conversion accessible via the .gap -method
284
"""
285
286
return gap(self)
287
288
289
290
class PGU(PGU):
291
"""
292
Since the Method __call__ of PermutationGroup_subgroup(PermutationGroup_generic) does not support coerce_maps
293
it is overwritten by this class to fill in the lack. This is done by overwriting the class name
294
295
PermutationGroup_subgroup by local_PermutationGroup_subgroup
296
297
which contains the extended version of the __call__ methos
298
299
If you don't see this well formatted type
300
301
sage: print PGU.__doc__
302
303
To see the docomentation of the original class type
304
305
sage: print sage.groups.perm_gps.permgroup_named.PGU.__init__.__doc__
306
307
308
309
AUTHOR:
310
311
- Sebastian Oehms, Okt. 2016
312
313
"""
314
sage.groups.perm_gps.permgroup.PermutationGroup_subgroup = local_PermutationGroup_subgroup
315
316
class PSp(PSp):
317
"""
318
Since the Method __call__ of PermutationGroup_subgroup(PermutationGroup_generic) does not support coerce_maps
319
it is overwritten by this class to fill in the lack. This is done by overwriting the class name
320
321
PermutationGroup_subgroup by local_PermutationGroup_subgroup
322
323
which contains the extended version of the __call__ methos
324
325
If you don't see this well formatted type
326
327
sage: print PSp.__doc__
328
329
To see the docomentation of the original class type
330
331
sage: print sage.groups.perm_gps.permgroup_named.PSp.__init__.__doc__
332
333
AUTHOR:
334
335
- Sebastian Oehms, Okt. 2016
336
337
"""
338
sage.groups.perm_gps.permgroup.PermutationGroup_subgroup = local_PermutationGroup_subgroup
339
340
341
342
try:
343
from sage.combinat.root_system.reflection_group_complex import ComplexReflectionGroup, IrreducibleComplexReflectionGroup
344
345
class IrreducibleComplexReflectionGroup(IrreducibleComplexReflectionGroup):
346
"""
347
Since the Method __call__ of IrreducibleComplexReflectionGroup (inherited from PermutationGroup_generic) does not
348
support coerce_maps between groups it is overloaded by this class to fill in the lack. Overloaded methods are:
349
- __call__
350
351
If you don't see this well formatted type
352
353
sage: print IrreducibleComplexReflectionGroup.__doc__
354
355
To see the docomentation of the original class type
356
357
sage: print sage.combinat.root_system.reflection_group_complex.IrreducibleComplexReflectionGroup.__doc__
358
359
AUTHOR:
360
361
- Sebastian Oehms, Okt. 2016
362
363
"""
364
365
def __call__(self, x, check=True, try_conv_map=True):
366
"""
367
This method overloads the __call__-method of the original class since the method __call__ of
368
IrreducibleComplexReflectionGroup (inherited from PermutationGroup_generic) does not support coerce_maps between
369
groups Here is an improvement concerning this lack.
370
371
If you don't see this well formatted type
372
373
sage: print IrreducibleComplexReflectionGroup.__call__.__doc__
374
375
To see the docomentation of the original method type
376
377
sage: print sage.combinat.root_system.reflection_group_complex.IrreducibleComplexReflectionGroup.__call__.__doc__
378
379
EXAMPLE:
380
381
try to establish the natural projection from the braid group on 4 strands onto the irreducible complex
382
reflection group $G_{25}$ (Shephard-Todd number).first try without using this modification of the
383
IrreduclibeComplexReflectionGroup class
384
385
sage: from sage.combinat.root_system.reflection_group_complex import ComplexReflectionGroup,
386
IrreducibleComplexReflectionGroup
387
sage: G25 = IrreducibleComplexReflectionGroup(tuple([25]))
388
sage: B4 = BraidGroup(4)
389
sage: G25_gap = gap(G25)
390
sage: B4_gap = B4.gap()
391
sage: natProj_gap = B4_gap.GroupHomomorphismByImagesNC( G25_gap, B4_gap.GeneratorsOfGroup(),
392
G25_gap.GeneratorsOfGroup() )
393
sage: def natProj_map(elem):
394
395
res = natProj_gap.ImageElm( elem.gap() )
396
return res.sage()
397
....:
398
sage:
399
sage: natProj_hom = Hom( B4, G25)(natProj_map)
400
sage: G25.register_conversion(natProj_hom)
401
sage:
402
sage: b1, b2, b3 = B4.gens()
403
sage: ele = b1*b2*b1**(-1)
404
sage: G25(ele)
405
---------------------------------------------------------------------------
406
TypeError Traceback (most recent call last)
407
<ipython-input-13-9d71a15c3419> in <module>()
408
----> 1 G25(ele)
409
...........
410
TypeError: 'BraidGroup_class_with_category.element_class' object is not iterable
411
sage:
412
413
now trying the same using this modification of the IrreduclibeComplexReflectionGroup class
414
415
sage: from lib.local_permgroup import *
416
sage: G25 = IrreducibleComplexReflectionGroup(tuple([25]))
417
sage: B4 = BraidGroup(4)
418
sage: G25_gap = gap(G25)
419
sage: B4_gap = B4.gap()
420
sage: natProj_gap = B4_gap.GroupHomomorphismByImagesNC( G25_gap, B4_gap.GeneratorsOfGroup(),
421
G25_gap.GeneratorsOfGroup() )
422
sage: def natProj_map(elem):
423
res = natProj_gap.ImageElm( elem.gap() )
424
return res.sage()
425
....:
426
sage:
427
sage: natProj_hom = Hom( B4, G25)(natProj_map)
428
sage: G25.register_conversion(natProj_hom)
429
sage:
430
sage: b1, b2, b3 = B4.gens()
431
sage: ele = b1*b2*b1**(-1)
432
sage: G25(ele)
433
(1,5,16)(2,50,26)(3,34,47)(4,20,31)(6,9,32)(7,10,25)(11,70,60)(12,67,14)(15,21,61)(17,28,30)(18,49,52)
434
(19,22,55)(23,53,72)(27,33,66)(36,64,39)(37,45,69)(40,48,63)(42,68,46)(56,62,58)(57,71,65)
435
436
TESTS:
437
438
sage: from lib.local_permgroup import *
439
sage: G25 = IrreducibleComplexReflectionGroup(tuple([25]))
440
sage: TestSuite(G25).run()
441
442
AUTHOR:
443
444
- Sebastian Oehms, Mar 2017
445
446
"""
447
return _call_with_conversion_(self, x, check=check, try_conv_map=try_conv_map)
448
449
450
451
452
def __contains__(self, item):
453
"""
454
Returns boolean value of ``item in self``.
455
This method from PermutationGroup_generic has been overwritten here to avoid recursion loops. This method uses
456
the __call__ method which has been extended here. But to check if an element is in the group the original
457
version of __call__ must be applied.
458
459
If you don't see this well formatted type
460
461
sage: print local_PermutationGroup_subgroup.__contains__.__doc__
462
463
To see the docomentation of the original method type
464
465
sage: print PermutationGroup_subgroup.__contains__.__doc__
466
"""
467
468
try:
469
item = self(item, check=True, try_conv_map=False)
470
except Exception:
471
return False
472
return True
473
474
475
476
def as_matrix_group( self ):
477
"""
478
This method implements an extension of the IrreducibleComplexReflectionGroup_class.
479
It retuns a realization of the reflection group as a matrix group or (if possible) as a subgroup of the unitary
480
group over the universal cyclotomic field together with conversion maps to and from the refelection group
481
itselfe. To this purpose it uses the matrix-method of the IrreduclibleComplexReflectionGroup applied to the
482
genarators of self.
483
484
If you don't see this well formatted type
485
486
sage: print IrreducibleComplexReflectionGroup.as_matrix_group.__doc__
487
488
489
INPUT: --
490
491
OUTPUT:
492
493
A subgroup of the general linear (or unitary) group as instance of FinitelyGeneratedMatrixGroup_gap. The
494
instance of its ambient group is of the UnitaryMatrixGroup class (if possible) or again of
495
FinitelyGeneratedMatrixGroup_gap
496
497
EXAMPLES:
498
499
sage: print IrreducibleComplexReflectionGroup.as_unitary_group.__doc__
500
501
sage: G14 = IrreducibleComplexReflectionGroup(tuple([14]))
502
sage: U14 = G14.as_unitary_group()
503
sage:
504
sage: U14
505
Subgroup of General Unitary Group of degree 2 over Universal Cyclotomic Field generated by:
506
([ 1 0]
507
[ 0 -1],
508
[ 1/2*E(24) - 1/2*E(24)^16 + 1/2*E(24)^19 1/2*E(3)^2]
509
[ -1/2*E(3)^2 -1/2*E(24) - 1/2*E(24)^16 - 1/2*E(24)^19])
510
sage:
511
sage: isinstance( U14, FinitelyGeneratedMatrixGroup_gap)
512
True
513
sage: isinstance( U14.ambient(), UnitaryMatrixGroup_generic)
514
True
515
516
Conversion of Elements:
517
518
sage: g1, g2 = G14.gens()
519
sage: U14(g1*g2)
520
[1/2*E(24) - 1/2*E(24)^16 + 1/2*E(24)^19 1/2*E(3)^2]
521
[ 1/2*E(3)^2 1/2*E(24) + 1/2*E(24)^16 + 1/2*E(24)^19]
522
sage: gu = U14(g1*g2); gu
523
[1/2*E(24) - 1/2*E(24)^16 + 1/2*E(24)^19 1/2*E(3)^2]
524
[ 1/2*E(3)^2 1/2*E(24) + 1/2*E(24)^16 + 1/2*E(24)^19]
525
sage: g = G14(gu); g
526
(1,7,19,39,69,89,110,116,119,114,73,23,3,5,17,37,67,90,109,115,120,113,71,21)
527
(2,8,20,40,70,74,24,4,6,18,38,68,91,101,42,10,14,34,65,98,52,60,72,2 2)
528
(9,13,33,64,97,51,59,96,105,117,102,43,11,15,35,66,99,49,57,95,106,118,100,41)
529
(12,16,36,48,56,50,58,76,26,30,62,79,84,81,87,103,46,54,93,104,78,28,32,44)
530
(25,29,61,83,111,80,86,45,53,92,108,77,27,31,63,85,112,82,88,47,55,94,107,75)
531
sage: g == g1*g2
532
True
533
534
None unitary realization:
535
536
sage: G15 = IrreducibleComplexReflectionGroup(tuple([15]))
537
sage: M15 = G15.as_matrix_group(); M15
538
Matrix group over Universal Cyclotomic Field with 3 generators (
539
[-1/3*E(24) + 1/3*E(24)^11 + 1/3*E(24)^17 - 1/3*E(24)^19 1/3*E(24) + 1/6*E(24)^11 + 1/6*E(24)^17 + 1/3*E(24)^19]
540
[-1/3*E(24) - 2/3*E(24)^11 - 2/3*E(24)^17 - 1/3*E(24)^19 1/3*E(24) - 1/3*E(24)^11 - 1/3*E(24)^17 + 1/3*E(24)^19],
541
[ 1 0] [-1/3*E(12)^7 + 1/3*E(12)^11 1/3*E(12)^7 - 1/3*E(12)^11]
542
[ 0 E(3)], [ 2/3*E(12)^7 - 2/3*E(12)^11 1/3*E(12)^7 - 1/3*E(12)^11]
543
)
544
sage: isinstance( M15, FinitelyGeneratedMatrixGroup_gap )
545
True
546
sage: isinstance( M15.ambient(), FinitelyGeneratedMatrixGroup_gap )
547
True
548
549
550
AUTHOR:
551
552
- Sebastian Oehms, Mar 2017
553
554
"""
555
556
genList = [ gen.matrix() for gen in self.gens() ]
557
BaseRing = genList[_sage_const_0 ].base_ring()
558
559
BaseGroup = GU( self.rank(), BaseRing )
560
561
try:
562
MatGroup = BaseGroup.subgroup( genList )
563
except:
564
MatGroup = MatrixGroup( genList )
565
566
homToMat = gap_hom( self, MatGroup )
567
homFromMat = gap_hom( MatGroup, self )
568
569
570
return MatGroup
571
572
573
except:
574
pass
575
576
577