# How to implement a group action in Sage ( for educational purposes )?

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.

• If you don't get answers here, you could try asking here or here. Commented Jan 2, 2015 at 13:28
• Thanks, I will definitely try that, I used to code a lot in Mathematica for which I have had so much excellent support here at Mathematica SE. I hoped to get some Sage support on SE but I think you are right: this might not be the place, despite the tag. I can do most of the stuff directly in GAP but I want to learn it the Sage way. Only then I can decide if Sage is what I need. Commented Jan 2, 2015 at 13:44
• Here is the sage-support thread groups.google.com/forum/#!topic/sage-support/20gEbPVFd_Y Commented Jan 2, 2015 at 15:52

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.

• ( Dank je wel Ricardo) Thanks, it is the answer I was looking for. Commented Jan 2, 2015 at 17:41
• Damn!! I was looking for it everywhere.
– S L
Commented Sep 8, 2016 at 16:45