Lesson 1 of 15

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 SS is a function :S×SS*: S \times S \to S. The operation is closed if for all a,bSa, b \in S, we have abSa * b \in S.

For example, addition on the integers Z\mathbb{Z} is a binary operation: for any two integers aa and bb, a+ba + b is also an integer.

Modular Arithmetic as a Set

The set Zn={0,1,2,,n1}\mathbb{Z}_n = \{0, 1, 2, \ldots, n-1\} with addition modulo nn 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 SS may have these properties:

  • Associative: (ab)c=a(bc)(a * b) * c = a * (b * c) for all a,b,cSa, b, c \in S
  • Commutative: ab=baa * b = b * a for all a,bSa, b \in S
  • Identity element: There exists eSe \in S such that ea=ae=ae * a = a * e = a for all aa
  • Inverse: For each aSa \in S, there exists a1Sa^{-1} \in S such that aa1=a1a=ea * a^{-1} = a^{-1} * a = e

Cayley Table

A Cayley table displays the results of a binary operation. For Z4\mathbb{Z}_4 under addition:

+0123
00123
11230
22301
33012

Your Task

Implement cayley_table(n) that returns the Cayley table (as a list of lists) for addition modulo nn, and is_commutative(table) that checks whether a Cayley table represents a commutative operation.

Pyodide loading...
Loading...
Click "Run" to execute your code.