One of my favorite classes in college was Abstract Algebra. It was my first non-CS non-elementary math class, and I took it because I knew I didn’t want to graduate without having broadened my mathematical horizons beyond CS.

As it turned out, Abstract Algebra felt pretty familiar. Many of the constructs we form and play with in Algebra underlie many CS fields, such as crytography and graph theory. There is also a lot of overlap between the tools used in Algebra and CS, such as homo/isomorphisms.

### Mathematical Structures

Many mathematical fields share a common theme - define some structures (often types of sets) then prove things about them. In Computation Theory, the structures are automata and languages. In Calculus/Real Analysis, the structures are continuous, differentiable, riemann-integrable, etc real valued functions of real variables. In Abstract Algebra, the structures are groups, rings and fields.

There are some similarities between mathematical structures and the classes of object-oriented programming. Often we study general structures that must obey some axiom, and then define “subclasses” of those structures that obey additional axioms. For example, rings are subclasses of groups - they satisfy all of the same axioms, but they add an additional operation and some additional structure.

Why do we spend the effort developing and proving theorems about general mathematical structures? For the same reason that we define classes and subclasses rather than build each object seperately - to minimize redundancy and reduce complexity. When we’ve proven a theorem about a particular structure, then that theorem applies to everything with that structure. If we define a new structure as a special case of a parent structure, then all of the work that we’ve done to understand the parent structure applies to the child structure as well.

Consider writing a program in Java where you define a method that accepts a “foo.” Then you can write that function with the certainty that anything passed in will have access to all of foo’s methods. When we write a proof about groups it’s the same idea - regardless of the inner workings of the infinite different groups, we know that as long as we build the proof on the group axioms it will hold for all groups.

### The Group

One basic structure in Abstract Algebra is the group. A group is a set, which we will denote by , combined with a “group operation,” which we will denote by , that satisfies the following axioms:

- For all in , is also an element in ( is closed under )
- For all in , ( is associative)
- There is an identity element in such that
- For all in , there is a in such that (every element in has an inverse)

Note that this definition does not require that be commutative, that is, for many groups . Groups where is commutative are called “abelian” groups.

### Examples of Groups

Groups are everywhere in mathematics, and you’ve probably worked with many groups in the past without realizing it.

#### Example 1: Integers and Addition

The integers () and the addition operation (lets use rather than for clarity) form a group. Let’s prove it.

- The sum of two integers is an integer, so is closed under .
- Addition is associative
- For any integer, , , so is the identity element.
- For any integer, , .

Note that the integers and the multiplication operation don’t form a group, since the multiplicative inverses of integers are usually not integers (they are rational numbers). However…

#### Example 2: Integers and Multiplication modulo

If you haven’t encountered modular arithmetic before, there is a great introduction here. As a refresher, is the remainder of .

Some of the astute readers might now be asking “what about modular arithmetic? Do the integers and multiplication modulo form a group?” This is a great question, and the answer is “sometimes.”

Let’s consider the integers and the operation multiplication modulo . For two integers , must be less than . Since is only when is divisible by , then as long as is prime, will be in .

That proves the closure condition (condition 1). For the other 3 conditions:

- Multiplication is associative
- For any integer, , , so is the identity element.
- The proof of the existence of multiplicative inverses is a little complicated and relies on Bezel’s theorem, you can find it here.

Therefore the set of integers and the multiplication modulo operation form a group if is prime.

#### Example 3: Rotations of a square (and cyclic groups)

Let’s step away from numbers for a moment. The “rotational symmetries” of a polygon are the different mappings of the polygon to itself by rotation. Consider some triangle . We can enumerate the rotational symmetries of by sequentially rotating by degrees. Lets denote “no rotation” of as or , and rotations of as .

This is :

This is :

This is

Note that . Now, lets prove that the set of rotational symmetries of along with the rotation operation forms a group.

- If we rotate times, and then rotate it times, this is the same as rotating times, so , and the closure condition holds.
- Since the order of rotations doesn’t matter, the associativity condition holds.
- Since the “no rotation” element does not change the orientation of , then is the identity element.
- Since we can always rotate any rotational symmetry of back to the original orientation, (i.e. and ), each element has an inverse.

Notice that the proof above applies to more than just - it applies to any regular polygon.

### Other Resources

If you’ve enjoyed learning about groups and you want to learn more about them and other algebraic structures, I recommend Dummit and Foote. This textbook is extremely readable and contains an extraordinary number of worked examples and well-fleshed-out proofs.