Skip to content

priyanshupant/group-theory-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Exploring Finite Groups through Python

About

The project aims to explore the intricate properties of finite groups through computational methods implemented in Python. Leveraging libraries such as NumPy for numerical computations, permutation for handling permutations, and Matplotlib for visualization, the project provides a comprehensive framework for conceptualizing and analyzing group theory concepts. The core component of the project is the GROUP class, which encapsulates functionalities to examine various properties of a group, including closure, identity, inverses, and Abelianity. Additionally, the EDP class facilitates operations on the Cartesian product of two groups, enhancing the project's versatility in studying group interactions. Through its modular design and rich functionality, this project serves as a valuable tool for both beginners and advanced learners seeking to delve into the depths of group theory using Python.

Key Features:

  • Check if the provided structure forms a Group.
  • Gives Identity element, and inverse of each element.
  • Verifies if Group is Abelian, Cyclic
  • Cayley Table Generation
  • Subgroup Identification
  • Centre Determination

Working On Ideas

  • Add functions to obtain a * b, a * b^-1, a^n
  • More info about groups like generators, normal subgroups
  • Add functionality like external direct product, quotient group.
  • Add popular groups like Z_n, U_m, K4, Q8, S(n), A(n), D(n) to easily initialize at go.
  • Further generalise it for rings, fields, ufds, pids.
  • visualizing datasets formed for this module for different groups.
  • incorporate groups formed using matrices.

Dependencies:

  • python3
  • numpy

Current Functionality

Initialise a Group

# example
from GROUP import GROUP
# defining function
def mod_5(a,b):
    return (a+b)%5

GROUP({0,1,2,3,4},mod_5 ).info()

Functions

  • g.info(): Provides all the info about the group
  • get_cayley_table(): Calculate the Cayley table for the group.
  • is_closed(): Check if the group operation is closed.
  • is_identity(): Determine if the group has an identity element.
  • is_inverse(): Check for the existence of inverses and self-invertible elements.
  • is_group(): Check if the given set forms a group.
  • is_abelian(): Check if the group is abelian (commutative).
  • is_cyclic(): Check if the group is cyclic.
  • get_not_self_invertible(): Return elements that are not self-invertible.
  • get_subgroups(): Find all subgroups of the group.
  • get_centre(): Find the centre of the group.
  • evaluate(a,b): gives a*b
  • a_power_n(a,n): Finds a^n for +,-ve value of n
  • get_normal_subgroups(): Find all normals subgroups of the group.
  • generators: gives all the generator
  • is_simple(): Checks if group is simple
  • visualize(): Visualizing cayley tables as images.

Example Usage:

from GROUP import GROUP
from define import Z, U, K4, Q8

GROUP(Z(7).elements, Z(7).function).info()
print('\n')
GROUP(U(15).elements, U(15).function).info()
print('\n')
GROUP(K4().elements, K4().function).info()
print('\n')
GROUP(Q8().elements, Q8().function).info()
print('\n')
GROUP(S(3).elements, S(3).function).info()

Output:

Is Group:  True
Elements:  {0, 1, 2, 3, 4, 5, 6}
Order:  7
Cayley Table: 
 [[0. 1. 2. 3. 4. 5. 6.]
 [1. 2. 3. 4. 5. 6. 0.]
 [2. 3. 4. 5. 6. 0. 1.]
 [3. 4. 5. 6. 0. 1. 2.]
 [4. 5. 6. 0. 1. 2. 3.]
 [5. 6. 0. 1. 2. 3. 4.]
 [6. 0. 1. 2. 3. 4. 5.]]
Identity Exist:  True
Identity:  0
Inverses exist:  True
Inverses:  {(4, 3), (6, 1), (5, 2), (0, 0)}
Self Invertible Elements:  {0}
Not Self Invertible Elements:  {1, 2, 3, 4, 5, 6}
Is Abelian:  True
Is Cyclic:  True
Subgroups:  [{0}, {0, 1, 2, 3, 4, 5, 6}]
Centre:  {0, 1, 2, 3, 4, 5, 6}
Generators:  {1, 2, 3, 4, 5, 6}
Normal Subgroups:  [{0}, {0, 1, 2, 3, 4, 5, 6}]
Is Simple:  True


Is Group:  True
Elements:  {1, 2, 4, 7, 8, 11, 13, 14}
Order:  8
Cayley Table: 
 [[ 1.  2.  4.  7.  8. 11. 13. 14.]
 [ 2.  4.  8. 14.  1.  7. 11. 13.]
 [ 4.  8.  1. 13.  2. 14.  7. 11.]
 [ 7. 14. 13.  4. 11.  2.  1.  8.]
 [ 8.  1.  2. 11.  4. 13. 14.  7.]
 [11.  7. 14.  2. 13.  1.  8.  4.]
 [13. 11.  7.  1. 14.  8.  4.  2.]
 [14. 13. 11.  8.  7.  4.  2.  1.]]
Identity Exist:  True
Identity:  1
Inverses exist:  True
Inverses:  {(4, 4), (14, 14), (13, 7), (1, 1), (8, 2), (11, 11)}
Self Invertible Elements:  {1, 11, 4, 14}
Not Self Invertible Elements:  {8, 2, 13, 7}
Is Abelian:  True
Is Cyclic:  False
Subgroups:  [{1}, {1, 4}, {8, 1, 2, 4}, {1, 11}, {1, 4, 13, 7}, {1, 14}, {1, 11, 4, 14}, {1, 2, 4, 7, 8, 11, 13, 14}]
Centre:  {1, 2, 4, 7, 8, 11, 13, 14}
Generators:  set()
Normal Subgroups:  [{1}, {1, 4}, {8, 1, 2, 4}, {1, 11}, {1, 4, 13, 7}, {1, 14}, {1, 11, 4, 14}, {1, 2, 4, 7, 8, 11, 13, 14}]
Is Simple:  False


Is Group:  True
Elements:  {'y', 'e', 'x', 'z'}
Order:  4
Cayley Table: 
 [['e' 'y' 'z' 'x']
 ['y' 'e' 'x' 'z']
 ['z' 'x' 'e' 'y']
 ['x' 'z' 'y' 'e']]
Identity Exist:  True
Identity:  e
Inverses exist:  True
Inverses:  {('x', 'x'), ('y', 'y'), ('e', 'e'), ('z', 'z')}
Self Invertible Elements:  {'y', 'e', 'x', 'z'}
Not Self Invertible Elements:  set()
Is Abelian:  True
Is Cyclic:  False
Subgroups:  [{'e'}, {'y', 'e'}, {'e', 'x'}, {'e', 'z'}, {'y', 'e', 'x', 'z'}]
Centre:  {'y', 'e', 'x', 'z'}
Generators:  set()
Normal Subgroups:  [{'e'}, {'y', 'e'}, {'e', 'x'}, {'e', 'z'}, {'y', 'e', 'x', 'z'}]
Is Simple:  False


Is Group:  True
Elements:  {'-i', 'k', '-k', '-j', '1', '-1', 'j', 'i'}
Order:  8
Cayley Table: 
 [['1' '-1' 'i' '-i' 'j' '-j' 'k' '-k']
 ['-1' '1' '-i' 'i' '-j' 'j' '-k' 'k']
 ['i' '-i' '-1' '1' 'k' '-k' '-j' 'j']
 ['-i' 'i' '1' '-1' '-k' 'k' 'j' '-j']
 ['j' '-j' '-k' 'k' '-1' '1' 'i' '-i']
 ['-j' 'j' 'k' '-k' '1' '-1' '-i' 'i']
 ['k' '-k' 'j' '-j' '-i' 'i' '-1' '1']
 ['-k' 'k' '-j' 'j' 'i' '-i' '1' '-1']]
Identity Exist:  True
Identity:  1
Inverses exist:  True
Inverses:  {('-1', '-1'), ('-k', 'k'), ('-i', 'i'), ('1', '1'), ('-j', 'j')}
Self Invertible Elements:  {'-1', '1'}
Not Self Invertible Elements:  {'-i', 'k', '-k', '-j', 'j', 'i'}
Is Abelian:  False
Is Cyclic:  False
Subgroups:  [{'1'}, {'-1', '1'}, {'-i', '-1', 'i', '1'}, {'-j', '-1', 'j', '1'}, {'-k', '-1', 'k', '1'}, {'-i', 'k', '-k', '-j', '1', '-1', 'j', 'i'}]
Centre:  {'-1', '1'}
Generators:  set()
Normal Subgroups:  [{'1'}, {'-1', '1'}, {'-i', '-1', 'i', '1'}, {'-j', '-1', 'j', '1'}, {'-k', '-1', 'k', '1'}, {'-i', 'k', '-k', '-j', '1', '-1', 'j', 'i'}]
Is Simple:  False

Is Group: True
Elements: {0, 1, 2, 3, 4}
Order: 5
Cayley Table: [[0. 1. 2. 3. 4.]
 [1. 2. 3. 4. 0.]
 [2. 3. 4. 0. 1.]
 [3. 4. 0. 1. 2.]
 [4. 0. 1. 2. 3.]]
Identity Exist: True
Identity: 0
Inverses exist: True
Inverses: {(3, 2), (4, 1), (0, 0)}
Self Invertible Elements: {0}
Not Self Invertible Elements: {1, 2, 3, 4}
Is Abelian: True
Is Cyclic: True
Subgroups: [{0}, {0, 1, 2, 3, 4}]
Centre: {0, 1, 2, 3, 4}
Generators: {1, 2, 3, 4}
Normal Subgroups: [{0}, {0, 1, 2, 3, 4}]
Is Simple: True

{'Is Group': True,
 'Elements': {permutation.Permutation(2, 3, 1),
  permutation.Permutation(2, 1),
  permutation.Permutation(3, 1, 2),
  permutation.Permutation(3, 2, 1),
  permutation.Permutation(1, 3, 2),
  permutation.Permutation()},
 'Order': 6,
 'Cayley Table': array([[permutation.Permutation(), permutation.Permutation(2, 1),
         permutation.Permutation(1, 3, 2),
         permutation.Permutation(3, 1, 2),
         permutation.Permutation(2, 3, 1),
         permutation.Permutation(3, 2, 1)],
        [permutation.Permutation(2, 1), permutation.Permutation(),
         permutation.Permutation(2, 3, 1),
         permutation.Permutation(3, 2, 1),
         permutation.Permutation(1, 3, 2),
         permutation.Permutation(3, 1, 2)],
        [permutation.Permutation(1, 3, 2),
         permutation.Permutation(3, 1, 2), permutation.Permutation(),
         permutation.Permutation(2, 1), permutation.Permutation(3, 2, 1),
         permutation.Permutation(2, 3, 1)],
        [permutation.Permutation(3, 1, 2),
         permutation.Permutation(1, 3, 2),
         permutation.Permutation(3, 2, 1),
         permutation.Permutation(2, 3, 1), permutation.Permutation(),
         permutation.Permutation(2, 1)],
        [permutation.Permutation(2, 3, 1),
         permutation.Permutation(3, 2, 1), permutation.Permutation(2, 1),
         permutation.Permutation(), permutation.Permutation(3, 1, 2),
         permutation.Permutation(1, 3, 2)],
        [permutation.Permutation(3, 2, 1),
         permutation.Permutation(2, 3, 1),
         permutation.Permutation(3, 1, 2),
         permutation.Permutation(1, 3, 2), permutation.Permutation(2, 1),
         permutation.Permutation()]], dtype=object),
 'Identity Exist': True,
 'Identity': permutation.Permutation(),
 'Inverses exist': True,
 'Inverses': {(permutation.Permutation(), permutation.Permutation()),
  (permutation.Permutation(1, 3, 2), permutation.Permutation(1, 3, 2)),
  (permutation.Permutation(2, 1), permutation.Permutation(2, 1)),
  (permutation.Permutation(2, 3, 1), permutation.Permutation(3, 1, 2)),
  (permutation.Permutation(3, 2, 1), permutation.Permutation(3, 2, 1))},
 'Self Invertible Elements': {permutation.Permutation(2, 1),
  permutation.Permutation(3, 2, 1),
  permutation.Permutation(1, 3, 2),
  permutation.Permutation()},
 'Not Self Invertible Elements': {permutation.Permutation(2, 3, 1),
  permutation.Permutation(3, 1, 2)},
 'Is Abelian': False,
 'Is Cyclic': False,
 'Subgroups': [{permutation.Permutation()},
  {permutation.Permutation(2, 1), permutation.Permutation()},
  {permutation.Permutation(1, 3, 2), permutation.Permutation()},
  {permutation.Permutation(2, 1),
   permutation.Permutation(1, 3, 2),
   permutation.Permutation()},
  {permutation.Permutation(2, 3, 1),
   permutation.Permutation(3, 1, 2),
   permutation.Permutation()},
  {permutation.Permutation(3, 2, 1), permutation.Permutation()},
  {permutation.Permutation(2, 1),
   permutation.Permutation(3, 2, 1),
   permutation.Permutation()},
  {permutation.Permutation(3, 2, 1),
   permutation.Permutation(1, 3, 2),
   permutation.Permutation()},
  {permutation.Permutation(2, 3, 1),
   permutation.Permutation(2, 1),
   permutation.Permutation(3, 1, 2),
   permutation.Permutation(3, 2, 1),
   permutation.Permutation(1, 3, 2),
   permutation.Permutation()}],
 'Centre': {permutation.Permutation()},
 'Generators': set(),
 'Normal Subgroups': [{permutation.Permutation()},
  {permutation.Permutation(2, 3, 1),
   permutation.Permutation(3, 1, 2),
   permutation.Permutation()},
  {permutation.Permutation(2, 3, 1),
   permutation.Permutation(2, 1),
   permutation.Permutation(3, 1, 2),
   permutation.Permutation(3, 2, 1),
   permutation.Permutation(1, 3, 2),
   permutation.Permutation()}],
 'Is Simple': False}

Group Visualization

Integers under addition modulo, Zn

Integers under multiplication modulo, Un

Klein's four group, K4

image

Quaternion group, Q8

image

Symmetry group, Sn

image image

Some External Direct Products

image image image

image image image

Contribution

Contributions are welcome! Feel free to fork the repo.

License

This project is licensed under the MIT License.

Releases

No releases published

Packages

No packages published

Languages