Group Ring in SageMath

Introduction

Let \(G\) be a finite group whose elements are \(g_1, \dots, g_m\) and let \(F\) be \(\mathbb{R}\) or \(\mathbb{C}\). We define a vector space over \(F\) with \(g_1, \dots, g_n\) as a basis, and we call this vector space \(FG\). Take as the elements of \(FG\) all expressions of the form \(\sum_{i=1}^n a_i g_i\) (all \(a_i\in F\)). The rules for addition and scalar multiplication in \(FG\) are the natural ones: namely, $$ u = \sum_{i=1}^n a_i g_i\text{ and }v = \sum_{i=1}^n b_i g_i $$ are elements of \(FG\), and \(\lambda\in F\), then $$ u+v = \sum_{i=1}^n (a_i+b_i) g_i\text{ and }av = \sum_{i=1}^n ab_i g_i $$

With these rules, \(FG\) is a vector space over \(F\) of dimension \(n\), with basis \(g_1, \dots, g_n\). The basis \(g_1, \dots, g_n\) is called the natural basis of \(FG\).

Definition: Let \(V\) be a vector space over \(F\) and let \(G\) be a group. Then \(V\) is an \(FG\)-module if a multiplication \(vg\) (\(v \in V, g\in G\)) is defined, satisfying the following conditions for all \(u, v\in V, \lambda \in F\), and \(g, h\in G\):

Set up

  1. Start SageMath by opening a terminal (Linux/Mac) or command prompt (Windows) and typing sage to start the SageMath shell, or use the SageMath web-based interface (Jupyter Notebook, SageMathCell, or Cocalc).

  2. Import the required modules:

from sage.groups.perm_gps.permgroup import PermutationGroup
from sage.algebras.group_algebra import GroupAlgebra

Example

If we want to do addition and multiplication in \(\mathbb{C}[\mathfrak{S}_4]\), we have to set up \(\mathfrak{S}_4\) and \(\mathbb{C}\) first.

G = PermutationGroup([(1, 2, 3, 4), (1, 2)])
R = CC

Here \(G = \mathfrak{S}_4\) and \(R=\mathbb{C}\).

Now we will create the symmetric group algebra using the GroupAlgebra() constructor:

A = GroupAlgebra(G, R)

To denote an element in \(A=\mathbb{C}\mathfrak{S}_4\), for instance, we want \(x=e+(1,2)\) and \(y=e - (1,3)\), we will use the following construction:

x = A([()])+A([(1,2)])
y = A([()])-A([(1,3)])

Note In sage, when we do (1,2)*(1,3), actually sage calculates \((1,3)(1,2)=(1,2,3)\). So we have to reverse the order in order to get the result we want. In that case, if we want to calculate \(x\cdot y\), we have to type y*x.

y*x
1.00000000000000*() + 1.00000000000000*(1,2) - 1.00000000000000*(1,3,2) - 1.00000000000000*(1,3)
x+y
2.00000000000000*() + 1.00000000000000*(1,2) - 1.00000000000000*(1,3)