Oregon Curriculum Network

# Group Theory¶

Group Theory is usually presented as a branch of exploration that started with Galois Theory, which in turn traces to searching for all roots of a polynomial, or at least knowing in principle how many one has.

The concept of a Group only makes sense in connection with other concepts: Ring and Field.

The School of Tomorrow does not aim to provide exhaustive treatment of topics touched on. You're in a web of windows, frames of reference. The School of Tomorrow is a hub of hyperlinks, floating in cyberspace (Cyberia).

## Permutations¶

One of the most abstract ways to understand Finite Groups, in a way that exercises coding skills, is to use permutations. A permutation is a reordering of elements. Think of pairing every lowercase letter with every other lowercase letter, throwing in a space.

In :
from string import ascii_lowercase as letters
from random import shuffle
members = list(letters + " ")
mem_copy = members[:]
shuffle(mem_copy)
p = {key:value for key, value in zip(members, mem_copy)}
p

Out:
{'a': 'p',
'b': 'j',
'c': 'f',
'd': 'r',
'e': 's',
'f': 't',
'g': 'b',
'h': 'm',
'i': 'x',
'j': 'y',
'k': ' ',
'l': 'c',
'm': 'd',
'n': 'o',
'o': 'i',
'p': 'e',
'q': 'q',
'r': 'n',
's': 'u',
't': 'l',
'u': 'a',
'v': 'h',
'w': 'v',
'x': 'z',
'y': 'w',
'z': 'k',
' ': 'g'}

For a more complete implementation of a Permutation type, you might want to check these other resources:

In Group Theory, we'll visit the idea of totatives, as we do in Number Theory as well. The totatives of N, multiplied modulo N, form a group. The totative of N module N when N is prime, form a field.

The properties of a Group are often summarized with the acronym CAIN, which is somewhat a worplay on Abel, one of the founders of Group Theory.

CAIN:

• Closure: given an operation *, every $a * b$ is in the group
• Associativity: $(a * b) * c == a * (b * c)$ Abelian groups commutative
• Inverse: every element has an inverse such the e * ~e = 1
• Neutral element: one element serves as an identity (call it 1)

Here's a simple integer-like class that builds in the modulus, so we can use the standard operators yet have the operation carried out modulo N.

We could flesh this out more. Subtracting is adding the additive inverse. Division is multiplying by the multiplicative inverse. That's why these two operations are, in a sense, "syntactic sugar" once we've defined an inverse vis-a-vis each of these operations.

In :
class Mod:

_modulus = 12

def __init__(self, n):
self.value = n % self._modulus

def __eq__(self, other):
return self.value == other.value % self._modulus

def __repr__(self):
return "({} mod {})".format(self.value, self._modulus)

return type(self)(self.value + other.value)

def __mul__(self, other):
return type(self)(self.value * other.value)

def __pow__(self, n):
return type(self)(pow(self.value, n, self._modulus))


You'll find more details on the code below in Number Theory.

In :
def gcd(a, b):
while b:
b, a = a % b, b
return a

def totatives(n):
return [totative for totative in range(1, n)
if gcd(totative, n) == 1]

In :
totatives(12)

Out:
[1, 5, 7, 11]
In :
group_12 = map(Mod, totatives(12))

In :
list(group_12)

Out:
[(1 mod 12), (5 mod 12), (7 mod 12), (11 mod 12)]

The itertools module (Standard Library) gives us a Cartesian Product, meaning we may quickly construct a Cayley Table for our group.

In :
from itertools import product

In :
group_12 = map(Mod, totatives(12))
n = list(group_12)

In :
n

Out:
[(1 mod 12), (5 mod 12), (7 mod 12), (11 mod 12)]

Iterators get "used up" in Python, meaning once you've traversed an iterator, you need to recreate it from scratch. The name table points to a listing of every member paired both with itself, and every other member of the group.

The list comprehension makes multiplication the operator for this Cayley Table, and shows Closure, meaning every outcome, every product, is a member of the Group.

In :
table = product(n, n)

In :
[a * b for a, b in table]  # closure

Out:
[(1 mod 12),
(5 mod 12),
(7 mod 12),
(11 mod 12),
(5 mod 12),
(1 mod 12),
(11 mod 12),
(7 mod 12),
(7 mod 12),
(11 mod 12),
(1 mod 12),
(5 mod 12),
(11 mod 12),
(7 mod 12),
(5 mod 12),
(1 mod 12)]
In :
table

Out:
<itertools.product at 0x10f5b1820>
In :
list(table)

Out:
[]

What happens if the modulus N is prime? Then by definition, every number from 1 up to N-1 is a totative of N. The totient of N, where N is prime, is N-1.

In this case, addition joins multiplication as an operator with group properties, while the distributive property connects the two operations thusly:

$$A * (B + C) = (A * B) + (A * C)$$

That means we have a Field.

A Ring is between a Group and a Field in that it features two operations, but without inverses and/or closure for one of them.

In :
Mod._modulus = 13

In :
group_13 = map(Mod, totatives(13))
n = list(group_13) + [Mod(0)] # 0 is added yet has no multiplicative inverse

In :
table = product(n, n)                   # Cayley Table
sums = [a + b for a, b in table]        # check addition this time
all([the_sum in n for the_sum in sums]) # closure

Out:
True