Algebra in Lean

1 Groups

1.1 Defining the Group

Definition 1.1 Group
#

A group is a nonempty set \(G\) with a closed binary operation (\(\mu : G \times G \rightarrow G\)), satisfying the following group axioms:

  • Associativity: \(\forall \, a, b, c \in G, ~ \mu (\mu (a, b), c) = \mu (a, \mu (b, c))\)

  • Identity element: \(\mathbb {e}\in G\) where \(\forall \, a \in G, ~ \mu (a, \mathbb {e}) = \mu (\mathbb {e}, a) = a\)

  • Inverses (\(\iota \)): \(\forall \, a \in G, ~ \mu (\iota (a), a) = \mathbb {e}\)

Theorem 1.2
#

Applying the group operation to an element and its inverse returns the identity: \(\forall a \in G, ~ \mu (a, \iota (a)) = \mathbb {e}\)

1.2 Other Algebraic Structures

Definition 1.3 Magma
#

A magma is a set G with an operation \(\mu : G \rightarrow G \rightarrow G\)

Definition 1.4 Semigroup
#

A semigroup is a magma with the associative property: \(\forall a,~ b,~ c \in G, ~ \mu (\mu (a, b), c) = \mu (a,~ \mu (b, c))\)

Definition 1.5 Monoid
#

A monoid is a semigroup with an identity \(\mathbb {e}\) where \(\forall a \in G, ~ \mu (a, \mathbb {e}) = \mu (\mathbb {e},~ a) = a\)

Definition 1.6 Commutative Monoid
#

A commutative monoid is a monoid with the commutative property: \(\forall a,~ b \in G, ~ \mu (a, b) = \mu (b, a)\)

Definition 1.7 Abelian Group
#

An abelian group is a group with the commutative property: \(\forall a,~ b \in G, ~ \mu (a,~ b) = \mu (b,~ a)\)

Theorem 1.8
#

A group has the left cancellation property \(\forall a,~ b,~ c \in G, ~ \mu (a,~ b) = \mu (a,~ c) \Rightarrow b = c\)

Theorem 1.9
#

A group has the right cancellation property \(\forall a, ~ b, ~ c \in G,~ \mu (b,~ a) = \mu (c,~ a) \Rightarrow b = c\)

1.3 Uniqueness Theorems

Theorem 1.10
#

In a monoid, the identity element is unique: \(\forall a \in G, ~ (\forall b \in G, ~ \mu (a,~ b) = \mu (b,~ a) = b) \Rightarrow a = \mathbb {e}\)

Theorem 1.11
#

In a group, each element has a unique inverse: \(\forall a,~ b \in G,~ (\mu (a,~ b) = \mu (b,~ a) = \mathbb {e}) \Rightarrow b = \iota (a)\)

Theorem 1.12 Shoes and Socks Theorem
#

The inverse of a product is the product of the inverses in reverse order: \(\forall a,~ b \in G,~ \iota (\mu (a,~ b)) = \mu (\iota (b),~ \iota (a))\)

Theorem 1.13
#

The inverse of the inverse of an element is that element: \(\forall a \in G,~ \iota (\iota (a)) = a\)

Theorem 1.14
#

The inverse of the identity is itself: \(\iota (\mathbb {e}) = \mathbb {e}\)

1.4 Some Examples of Groups

Definition 1.15
#

\((\mathbb {Z},~ +)\), the integers over addition, form a group, The identity of the group is \(0\), and the inverse of an element \(x \in \mathbb {Z}\) is \(-x\).

Definition 1.16 \(C_3\)
#

\(C_3\) is the group of rotational symmetries of an equilateral triangle with the group operation being the composition of symmetries. This is treated as an inductive type with three elements. The identity is a \( 0 ^{\circ } \) rotation, and the inverse of an \(x ^{\circ } \) rotation is a \((360 - x)^{\circ } \) rotation.

1.5 \(C_n\) as a Group

Definition 1.17 \(C_n\)
#

\(C_n\) is the generalization of \(C_3\), and is therefore the group of rotations of a regular n-gon. It uses mathlib’s Fin n type, and addition on that type. Since Fin allows modular arithmetic, rotations that are seperated by a multiple of \(360^{\circ }\) are treated as equal. Similarly to \(C_3\), the identity is a \(0^{\circ }\) rotation, and the inverse of an \(x ^{\circ }\) rotation is a \((360 - x)^{\circ }\) rotation.

1.6 \(D_n\) as a group

Definition 1.18 Dihedral Group
#

\(D_n\) is the dihedral group of order \(2n\). This is the group of all symmetries of a regular n-gon. This includes n rotations and n reflections. It is represented by a pair of a boolean and an element of Fin n. The boolean represents whether the element is a rotation or not, and the element of Fin n represents how much the first vertex is rotated. The identity is a \(0^{\circ }\) rotation, the inverse of an \(x^{\circ }\) rotation is a \((360 - x)^{\circ }\) rotation, and any reflection is its own inverse.

Theorem 1.19
#

\(D_3\) is the first example we’ve seen of a nonabelian group.

1.7 \(S_n\) as a group

Definition 1.20 Symmetric Group
#

\(S_n\), the symmetric group of order \(n!\), is the set of all permutations of \(n\) elements. It is represented as the set of all bijections from Fin n to Fin n, with function composition as the group operation. The identity is the identity function, and the inverse of a group element is its inverse function (which exists since all bijections are invertible).