[Math] How to implement a group action in Sage ( for educational purposes )

abstract-algebragroup-theorymath-softwaresagemath

Let S= {"A","B","C","D"} and S4= SymmetricGroup(4). I want to create a table of the action S4 x S -> S which standardly permutes the letters in the set. The table should look like:

Permutation.   A.  B.  C.  D
()             A.  B.  C.  D
(1 2 )         B.  A.  C.  D.
etc.

How can this be done with Sage? ( The Set and Group in the question are just examples, I want to be able to create a table for any action.

Best Answer

Given a group $G$, an ordered set $X$ and an action $\varphi: G \times X \to X$, based on your example you want a table with rows $g, \operatorname{im} \varphi(g, \cdot)$, where the images of the elements of $X$ are computed in the given order.

We can arrange this in SAGE as follows (using your example):

G = SymmetricGroup(4)
X = ['A','B','C','D']
act = lambda g, x: X[g(X.index(x) + 1) - 1]
im = lambda g: [act(g,x) for x in X]

table([(g, im(g)) for g in G])

Output:

()           ['A', 'B', 'C', 'D']
(3,4)        ['A', 'B', 'D', 'C']
(2,3)        ['A', 'C', 'B', 'D']
(2,3,4)      ['A', 'C', 'D', 'B']
(2,4,3)      ['A', 'D', 'B', 'C']
(2,4)        ['A', 'D', 'C', 'B']
(1,2)        ['B', 'A', 'C', 'D']
(1,2)(3,4)   ['B', 'A', 'D', 'C']
(1,2,3)      ['B', 'C', 'A', 'D']
(1,2,3,4)    ['B', 'C', 'D', 'A']
(1,2,4,3)    ['B', 'D', 'A', 'C']
(1,2,4)      ['B', 'D', 'C', 'A']
(1,3,2)      ['C', 'A', 'B', 'D']
(1,3,4,2)    ['C', 'A', 'D', 'B']
(1,3)        ['C', 'B', 'A', 'D']
(1,3,4)      ['C', 'B', 'D', 'A']
(1,3)(2,4)   ['C', 'D', 'A', 'B']
(1,3,2,4)    ['C', 'D', 'B', 'A']
(1,4,3,2)    ['D', 'A', 'B', 'C']
(1,4,2)      ['D', 'A', 'C', 'B']
(1,4,3)      ['D', 'B', 'A', 'C']
(1,4)        ['D', 'B', 'C', 'A']
(1,4,2,3)    ['D', 'C', 'A', 'B']
(1,4)(2,3)   ['D', 'C', 'B', 'A']

The row with the identity element conveniently serves as a heading.

Clearly hardest part of this is to define the action.

Related Question