Skip to content

Abstract Algebra: An implementation of Finite Algebras: Groups, Rings, Fields, Vector Spaces, Modules, Monoids, Semigroups, and Magmas. See the ReadTheDocs link.

License

Notifications You must be signed in to change notification settings

jopetty/abstract_algebra

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dih 4 Cayley Graph; generators a, b

Abstract Algebra

A pedagogical implementation of Finite Algebras in Python: Groups, Rings, Fields, Vector Spaces, Modules, Monoids, Semigroups, and Magmas.

Currently the representation of an algebra here depends on being able to explicitely represent its Cayley table. Consequently, only relatively small algebras can be represented - few hundred elements at most.

Summary

The finite_algebras module contains class definitions, methods, and functions for working with algebras that only have a finite number of elements.

  • The primary constructor of algebras is the function, make_finite_algebra. It examines the properties of the input table and returns the appropriate instance of an algebra.
  • Algebras can be input from, or output to, JSON files/strings or Python dictionaries.
  • Each algebra is defined by name (str), a description (str), a list of element names (str) and a square, 2-dimensional table that defines a binary operation (list of lists of int). Rings & Fields have two such tables.
  • Each algebra has methods for examining its properties (e.g., is_associative, is_commutative, center, commutators, etc.)
  • Algebraic elements can be "added" (or "multiplied") via their binary operations (e.g., v4.op('h','v') ==> 'r').
  • Inverses & identities can be obtained, if the algebra supports them (e.g., z3.inv('a') = 'a^2', z3.identity ==> 'e').
  • Direct products of two or more algebras can be computed using Python's multiplication operator (e.g., z4 * v4).
  • If two algebras are isomorphic, the mapping between their elements can be determined (e.g., v4.isomorphic(z2 * z2) ==> {'h': 'e:a', 'v': 'a:e', 'r': 'a:a', 'e': 'e:e'})
  • Autogeneration of some types of algebras, of arbitrary order, is supported (e.g., symmetric, cyclic).
  • Subalgebras (e.g., subgroups) can be determined, along with related functionality (e.g, is_normal()).
  • Groups, Rings, and Fields can be used to construct Modules and Vector Spaces, including n-dimensional Modules and Vector Spaces using the direct products of Rings and Fields, resp.

Installation

This module runs under Python 3.7+ and requires NumPy.

Clone the github repository to install: $ git clone https://github.com/alreich/abstract_algebra.git

Documentation

See full documentation at ReadTheDocs.

Quick Look

Create an algebra:

>>> from finite_algebras import make_finite_algebra

>>> v4 = make_finite_algebra('V4',
                             'Klein-4 group',
                             ['e', 'h', 'v', 'r'],
                             [[0, 1, 2, 3],
                              [1, 0, 3, 2],
                              [2, 3, 0, 1],
                              [3, 2, 1, 0]])
>>> v4
Group(
'V4',
'Klein-4 group',
['e', 'h', 'v', 'r'],
[[0, 1, 2, 3], [1, 0, 3, 2], [2, 3, 0, 1], [3, 2, 1, 0]]
)

Look at the algebra's properties:

>>> v4.about(use_table_names=True)
** Group **
Name: V4
Instance ID: 140598447984400
Description: Klein-4 group
Order: 4
Identity: e
Associative? Yes
Commutative? Yes
Cyclic?: No
Elements:
   Index   Name   Inverse  Order
      0       e       e       1
      1       h       h       2
      2       v       v       2
      3       r       r       2
Cayley Table (showing names):
[['e', 'h', 'v', 'r'],
 ['h', 'e', 'r', 'v'],
 ['v', 'r', 'e', 'h'],
 ['r', 'v', 'h', 'e']]

Autogenerate a small cyclic group:

>>> from finite_algebras import generate_cyclic_group

>>> z2 = generate_cyclic_group(2)

>>> z2.about()
** Group **
Name: Z2
Instance ID: 140599793107344
Description: Autogenerated cyclic Group of order 2
Order: 2
Identity: e
Associative? Yes
Commutative? Yes
Cyclic?: Yes
  Generators: ['a']
Elements:
   Index   Name   Inverse  Order
      0       e       e       1
      1       a       a       2
Cayley Table (showing indices):
[[0, 1], [1, 0]]

Compute the Direct Product of the cyclic group with itself:

>>> z2_sqr = z2 * z2

>>> z2_sqr.about(use_table_names=True)
** Group **
Name: Z2_x_Z2
Instance ID: 140599793109968
Description: Direct product of Z2 & Z2
Order: 4
Identity: e:e
Associative? Yes
Commutative? Yes
Cyclic?: No
Elements:
   Index   Name   Inverse  Order
      0     e:e     e:e       1
      1     e:a     e:a       2
      2     a:e     a:e       2
      3     a:a     a:a       2
Cayley Table (showing names):
[['e:e', 'e:a', 'a:e', 'a:a'],
 ['e:a', 'e:e', 'a:a', 'a:e'],
 ['a:e', 'a:a', 'e:e', 'e:a'],
 ['a:a', 'a:e', 'e:a', 'e:e']]

Are z2_sqr & v4 isomorphic?

Yes, and here's the mapping between their elements:

>>> v4.isomorphic(z2_sqr)
{'e': 'e:e', 'h': 'e:a', 'v': 'a:e', 'r': 'a:a'}

About

Abstract Algebra: An implementation of Finite Algebras: Groups, Rings, Fields, Vector Spaces, Modules, Monoids, Semigroups, and Magmas. See the ReadTheDocs link.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 88.9%
  • Python 11.1%