Sets & Binary Operations
Sets & Binary Operations
Abstract algebra studies algebraic structures — sets equipped with operations that satisfy certain axioms. Before we dive into groups, we need to understand binary operations and their properties.
Binary Operations
A binary operation on a set is a function . The operation is closed if for all , we have .
For example, addition on the integers is a binary operation: for any two integers and , is also an integer.
Modular Arithmetic as a Set
The set with addition modulo is a fundamental example. We can represent this in Python:
def mod_add(a, b, n):
return (a + b) % n
def mod_mul(a, b, n):
return (a * b) % n
Properties of Binary Operations
A binary operation on may have these properties:
- Associative: for all
- Commutative: for all
- Identity element: There exists such that for all
- Inverse: For each , there exists such that
Cayley Table
A Cayley table displays the results of a binary operation. For under addition:
| + | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| 0 | 0 | 1 | 2 | 3 |
| 1 | 1 | 2 | 3 | 0 |
| 2 | 2 | 3 | 0 | 1 |
| 3 | 3 | 0 | 1 | 2 |
Your Task
Implement cayley_table(n) that returns the Cayley table (as a list of lists) for addition modulo , and is_commutative(table) that checks whether a Cayley table represents a commutative operation.