Skip to content
Tutorials Center
My learning

Topics

Lesson 3 of 37 ยท Getting Started

Binary Operations

Learn what a binary operation is and how to test closure, associativity, commutativity, identity and inverses, using a small property checker in Python.

Every algebraic structure starts with a way of combining two elements into one. Addition of numbers, multiplication of matrices and composition of functions are all examples. This lesson gives that idea a precise name and a checklist of properties that later define groups, rings and fields.

Definition

A binary operation on a set S is a function * : S ร— S โ†’ S. It takes an ordered pair (a, b) and returns an element a * b that is again in S. That last requirement is called closure.

  • Addition is a binary operation on โ„ค: the sum of two integers is an integer.
  • Subtraction is a binary operation on โ„ค, but not on the natural numbers {0, 1, 2, ...}, because 2 - 5 = -3 leaves the set.
  • Division is not a binary operation on โ„ค (1 รท 2 is not an integer, and a รท 0 is undefined).

The standard properties

For an operation * on S:

Property Statement
Associative (a * b) * c = a * (b * c) for all a, b, c
Commutative a * b = b * a for all a, b
Identity an element e with e * a = a * e = a for all a
Inverses given an identity e, each a has some b with a * b = b * a = e

Associativity says brackets do not matter, so a * b * c is unambiguous. Commutativity is optional: composing "put on socks" then "put on shoes" differs from the reverse.

A property checker

For a finite set we can test every case by brute force. The function below reports each property.

Python Test the properties of an operation

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Read the results. Subtraction mod 7 is closed but not associative, and it has no identity (0 works only on the right: a - 0 = a but 0 - a โ‰  a). Multiplication mod 6 is associative, commutative and has identity 1. Addition mod 6 has all the good properties.

An identity must work on both sides. For a - b, the element 0 satisfies a - 0 = a but not 0 - a = a, so subtraction has no identity.

Operation tables

A finite operation is completely described by its Cayley table: rows labelled by the left element, columns by the right element, and the entry a * b in row a, column b.

Python Print a Cayley table and find the identity

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Here every element has an inverse and the structure is a group (the next chapter makes that precise). The same operation on {0, 1, 2, 3, 4} fails: 0 has no inverse.

Non-numerical operations

Operations need not involve numbers. Composition of functions on a set is a binary operation on the set of all such functions, and it is associative but not commutative. Strings under concatenation are associative with identity the empty string, but not commutative ("ab" + "cd" โ‰  "cd" + "ab"). Sets under union are associative, commutative, with identity the empty set, but a nonempty set has no inverse.

flowchart LR
    A["Binary operation<br/>closure"] --> B["Associative"] --> C["Identity"] --> D["Inverses"] --> E["Group"]

Stacking properties on a closed operation leads to the definition of a group.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why is subtraction not a binary operation on the natural numbers {0, 1, 2, ...}?

    A binary operation must be closed, and 2 - 5 = -3 is not a natural number.
  2. 2. Which statement about a - b on the integers is correct?

    (5 - 3) - 1 = 1 but 5 - (3 - 1) = 3, so associativity fails.
  3. 3. What is the identity element of multiplication mod 6 on {0,...,5}?

    1 * a = a for every a, so 1 is the identity.
  4. 4. Does set union on subsets of {1,2,3} have inverses?

    The identity is the empty set. If A โˆช B = โˆ… then both are empty, so only โˆ… has an inverse (itself).

Summary

  • A binary operation on S is a closed function S ร— S โ†’ S.
  • The key properties are associativity, commutativity, an identity and inverses.
  • A finite operation is displayed in a Cayley table and can be tested by brute force.
  • Not every familiar operation has all the properties; mod arithmetic shows both successes and failures.

Next: Modular Arithmetic and the Integers