Feb13.2020

1537 days ago by tixu6187

# Today we'll talk about what we can do in Sage, especially things related to Coxeter groups. # We can ... 
       
# do simple calculations: 1+3 
       
4
4
# create variables and carry out symbolic computations: f=(x+1)^2 x, f.canonicalize_radical(), ((x+1)^2).canonicalize_radical(), f.simplify_exp() 
       
(x, x^2 + 2*x + 1, x^2 + 2*x + 1, x^2 + 2*x + 1)
(x, x^2 + 2*x + 1, x^2 + 2*x + 1, x^2 + 2*x + 1)
# create some special, pre-programmed Coxeter groups by so-called 'Cartan type': A5=CoxeterGroup(["A",5],implementation='matrix') A5 
       
Weyl Group of type ['A', 5] (as a matrix group acting on the ambient
space)
Weyl Group of type ['A', 5] (as a matrix group acting on the ambient space)
 
       
 
       
# More generally we can create an arbitrary Coxeter group using a Coxeter matrice: h3matrix=matrix(3,[1,5,2,5,1,3,2,3,1]) H3=CoxeterGroup(h3matrix) # this is using the default 'reflection' implementation 
       
H3 
       
Finite Coxeter group over Number Field in a with defining polynomial x^2
- 5 with Coxeter matrix:
[1 5 2]
[5 1 3]
[2 3 1]
Finite Coxeter group over Number Field in a with defining polynomial x^2 - 5 with Coxeter matrix:
[1 5 2]
[5 1 3]
[2 3 1]
# Later we may want to use the 'coxeter3' implementation for faster computations. h3=CoxeterGroup(h3matrix,implementation='coxeter3') h3 
       
Finite Coxeter group over Number Field in a with defining polynomial x^2
- 5 with Coxeter matrix:
[1 5 2]
[5 1 3]
[2 3 1]
Finite Coxeter group over Number Field in a with defining polynomial x^2 - 5 with Coxeter matrix:
[1 5 2]
[5 1 3]
[2 3 1]
# We can access methods on the groups: H3.is_finite(), h3.is_commutative() 
       
(True, False)
(True, False)
# get the generators as a list: gens= H3.gens() (gens[0]*gens[1])^5 
       
[1 0 0]
[0 1 0]
[0 0 1]
[1 0 0]
[0 1 0]
[0 0 1]
# change the symbols for the generators: a,b,c=H3.gens() # may not do much; still returns things like [2,1,3] as reduced words. H3.gens() 
       
(
[         -1 1/2*a + 1/2           0]
[          0           1           0]
[          0           0           1],

[          1           0           0]  [ 1  0  0]
[1/2*a + 1/2          -1           1]  [ 0  1  0]
[          0           0           1], [ 0  1 -1]
)
(
[         -1 1/2*a + 1/2           0]
[          0           1           0]
[          0           0           1],

[          1           0           0]  [ 1  0  0]
[1/2*a + 1/2          -1           1]  [ 0  1  0]
[          0           0           1], [ 0  1 -1]
)
# create an element using a reduced word: w=H3.from_reduced_word([1,2]) # by default the generators "are" 1,2,3,...; the exact relations can be ambiguous though. 
       
w=H3.from_reduced_word([1,2,1,2,1,3,2,1]) w 
       
[-1/2*a - 3/2  1/2*a + 3/2           -1]
[      -a - 1  1/2*a + 3/2            0]
[-1/2*a - 1/2  1/2*a + 1/2            0]
[-1/2*a - 3/2  1/2*a + 3/2           -1]
[      -a - 1  1/2*a + 3/2            0]
[-1/2*a - 1/2  1/2*a + 1/2            0]
# create the reduced word graph and show it: w_rwg=w.reduced_word_graph() w_rwg, w_rwg.show() 
       
(Graph on 7 vertices, None)
(Graph on 7 vertices, None)
# Actually the input for from_reduced_word doesn't have to be reduced (!): x=H3.from_reduced_word([2,3,2,3]) x 
       
[          1           0           0]
[1/2*a + 1/2          -1           1]
[1/2*a + 1/2          -1           0]
[          1           0           0]
[1/2*a + 1/2          -1           1]
[1/2*a + 1/2          -1           0]
x.reduced_words() # returns the list of all reduced words of the elements 
       
[[3, 2]]
[[3, 2]]
x.is_reduced() # there is no direct command to check if a word is reduced 
       
Traceback (click to the left of this block for traceback)
...
AttributeError: 'CoxeterMatrixGroup_with_category.element_class' object
has no attribute 'is_reduced'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_33.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("eC5pc19yZWR1Y2VkKCkgIyB0aGVyZSBpcyBubyBkaXJlY3QgY29tbWFuZCB0byBjaGVjayBpZiBhIHdvcmQgaXMgcmVkdWNlZA=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpy4PGP3/___code___.py", line 2, in <module>
    exec compile(u'x.is_reduced() # there is no direct command to check if a word is reduced
  File "", line 1, in <module>
    
  File "sage/structure/element.pyx", line 493, in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4550)
  File "sage/structure/element.pyx", line 506, in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4659)
  File "sage/cpython/getattr.pyx", line 389, in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2469)
AttributeError: 'CoxeterMatrixGroup_with_category.element_class' object has no attribute 'is_reduced'
# but since we have the list of reduced words, we can easily check if a word is reduced l=[2,3,2,3] y=H3.from_reduced_word(l) l in y.reduced_words() # not in, so l is not reduced 
       
False
False
# of the reduced words, Sage has a way of picking a canonical reduced word; # we don't know how Sage picks the canonical word, same as in Bjorner--Brenti? x.reduced_word(), w.reduced_word() 
       
([3, 2], [1, 2, 1, 2, 3, 1, 2, 1])
([3, 2], [1, 2, 1, 2, 3, 1, 2, 1])
# find the left or right descent set of an element, better to specify a side: x.reduced_words(), x.descents(side='left') 
       
([[3, 2]], [3])
([[3, 2]], [3])
# without specifying a side Sage picks a side randomly: x.descents() 
       
[2]
[2]
w.reduced_words(), w.descents(side='right') 
       
([[1, 2, 1, 2, 3, 1, 2, 1],
  [1, 2, 1, 2, 1, 3, 2, 1],
  [2, 1, 2, 3, 1, 2, 1, 3],
  [2, 1, 2, 1, 3, 2, 1, 3],
  [2, 1, 2, 1, 2, 3, 2, 1],
  [2, 1, 2, 3, 1, 2, 3, 1],
  [2, 1, 2, 1, 3, 2, 3, 1]],
 [1, 3])
([[1, 2, 1, 2, 3, 1, 2, 1],
  [1, 2, 1, 2, 1, 3, 2, 1],
  [2, 1, 2, 3, 1, 2, 1, 3],
  [2, 1, 2, 1, 3, 2, 1, 3],
  [2, 1, 2, 1, 2, 3, 2, 1],
  [2, 1, 2, 3, 1, 2, 3, 1],
  [2, 1, 2, 1, 3, 2, 3, 1]],
 [1, 3])
# Sage can't check if an element is fully commutative (FC) in general groups w.is_fully_commutative() 
       
Traceback (click to the left of this block for traceback)
...
AttributeError: 'CoxeterMatrixGroup_with_category.element_class' object
has no attribute 'is_fully_commutative'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_39.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("IyBTYWdlIGNhbid0IGNoZWNrIGlmIGFuIGVsZW1lbnQgaXMgZnVsbHkgY29tbXV0YXRpdmUgKEZDKSBpbiBnZW5lcmFsIGdyb3Vwcwp3LmlzX2Z1bGx5X2NvbW11dGF0aXZlKCk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmp4li5V_/___code___.py", line 3, in <module>
    exec compile(u'w.is_fully_commutative()
  File "", line 1, in <module>
    
  File "sage/structure/element.pyx", line 493, in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4550)
  File "sage/structure/element.pyx", line 506, in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4659)
  File "sage/cpython/getattr.pyx", line 389, in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2469)
AttributeError: 'CoxeterMatrixGroup_with_category.element_class' object has no attribute 'is_fully_commutative'
# But it can check FC-ness in affine Coxeter groups W=CoxeterGroup(['A',5,1]) # the 1 indicates we have an "affine" group W, W is A5 
       
(Coxeter group over Integer Ring with Coxeter matrix:
 [1 3 2 2 2 3]
 [3 1 3 2 2 2]
 [2 3 1 3 2 2]
 [2 2 3 1 3 2]
 [2 2 2 3 1 3]
 [3 2 2 2 3 1], False)
(Coxeter group over Integer Ring with Coxeter matrix:
 [1 3 2 2 2 3]
 [3 1 3 2 2 2]
 [2 3 1 3 2 2]
 [2 2 3 1 3 2]
 [2 2 2 3 1 3]
 [3 2 2 2 3 1], False)
z=W.from_reduced_word([1,2,1,3]) 
       
z.is_fully_commutative() # probably can't access the check if W is created this way 
       
Traceback (click to the left of this block for traceback)
...
AttributeError: 'CoxeterMatrixGroup_with_category.element_class' object
has no attribute 'is_fully_commutative'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_42.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ei5pc19mdWxseV9jb21tdXRhdGl2ZSgpICMgcHJvYmFibHkgY2FuJ3QgYWNjZXNzIHRoZSBjaGVjayBpZiBXIGlzIGNyZWF0ZWQgdGhpcyB3YXk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpdGmCnX/___code___.py", line 2, in <module>
    exec compile(u"z.is_fully_commutative() # probably can't access the check if W is created this way" + '\n', '', 'single')
  File "", line 1, in <module>
    
  File "sage/structure/element.pyx", line 493, in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4550)
  File "sage/structure/element.pyx", line 506, in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4659)
  File "sage/cpython/getattr.pyx", line 389, in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2469)
AttributeError: 'CoxeterMatrixGroup_with_category.element_class' object has no attribute 'is_fully_commutative'
# But the check works if we create the group specifically as an affine group WW=AffinePermutationGroup(['A',5,1]) W, WW # Sage thinks of W and WW as different things because they were created using different methods; consequently their elements have access different methods. 
       
(Coxeter group over Integer Ring with Coxeter matrix:
 [1 3 2 2 2 3]
 [3 1 3 2 2 2]
 [2 3 1 3 2 2]
 [2 2 3 1 3 2]
 [2 2 2 3 1 3]
 [3 2 2 2 3 1], The group of affine permutations of type ['A', 5, 1])
(Coxeter group over Integer Ring with Coxeter matrix:
 [1 3 2 2 2 3]
 [3 1 3 2 2 2]
 [2 3 1 3 2 2]
 [2 2 3 1 3 2]
 [2 2 2 3 1 3]
 [3 2 2 2 3 1], The group of affine permutations of type ['A', 5, 1])
v=WW.from_reduced_word([1,2,1,3]) v, v.is_fully_commutative() # we don't know how this is done or whether it easily generalizes 
       
(Type A affine permutation with window [3, 2, 4, 1, 5, 6], False)
(Type A affine permutation with window [3, 2, 4, 1, 5, 6], False)