Addition, multiplication, negation of modular numbers is well defined

- Division is sometimes defined
- Units are numbers that you can divide by
- \(φ(m)\) is the number of units

Exponentiation is not well defined (we'll fix this next lecture)

**Review exercises:**- Prove that addition, multiplication, negation, subtraction of elements of \(\mathbb{Z}_m\) are all well-defined
- Prove that if an inverse exists, it is unique (so that the "inverse" operation is a well-defined partial function)
- Prove that exponentiation of elements of \(\mathbb{Z}_m\) is not well-defined

Last lecture, we defined modular numbers as equivalence classes of integers. In this lecture, we define basic operations on modular numbers. We will define the operations using representatives; we need to check that the operations are well defined.

**Claim:** Let \(+ : \mathbb{Z}_m \times \mathbb{Z}_m → \mathbb{Z}_m\) be given by \([a] + [b] ::= [a+b]\). Then \(+\) is well-defined.

**Proof:** We need to check that if \([a] = [a']\) and \([b] = [b']\) then \([a + b] = [a'+b']\). Assume \([a] = [a']\) and \([b] = [b']\). Then there exist \(c\) and \(d\) such that \(cm = a - a'\) and \(dm = b - b'\). Then \(a + b - (a' + b') = (a - a') + (b - b') = cm + dm = (c+d)m\). Therefore \(m | (a+b)-(a'+b')\), so \([a+b] = [a'+b']\).

**Claim:** Let the multiplication operation \(\cdot : \mathbb{Z}_m \times \mathbb{Z}_m → \mathbb{Z}_m\) be given by \([a][b] ::= [ab]\). Then \(\cdot\) is well defined.

**Proof:** Assume \([a] = [a']\) and \([b] = [b']\). Then as in the previous proof, there exist \(c\) and \(d\) with \(cm = a - a'\) and \(dm = b - b'\). We want to show that \(m | ab - a'b'\). We can substitute \(b'\) and \(a'\) in this equation using the assumptions:

\[ \begin{aligned} ab - a'b' &= ab - (a-cm)(b-dm) && \text{since $cm = a-a'$ and $dm = b-b'$} \\ &= ab - ab +(ad+bc)m - dcm^2 = (\cdots)m && \text{algebra} \\ \end{aligned} \]

This shows that \(m | ab-a'b'\) so \(\cdot\) is well-defined.

**Claim:** The negation operation \(- : \mathbb{Z}_m → \mathbb{Z}_m\) given by \(-[a] ::= [-a]\) is well-defined.

**Proof:** left as exercise.

**Definition:** If \(x\) and \(y\) are numbers, we say that \(y\) is an **inverse** of \(x\) if \(xy = 1\). If \(x\) has an inverse, it is called a **unit**.

**Note:** This is a very general definition: it applies in any set that has a reasonable definition of multiplication and 1. Sets having operations called \(+\) and \(\cdot\) that satisfy certain conditions are called rings; one can talk about the units of any ring.

**Examples:** - The only units of \(\mathbb{Z}\) are \(1\) and \(-1\) - All non-zero elements of \(\mathbb{Q}\) and \(\mathbb{R}\) are units - We will see in a later lecture that \([a]\) is a unit of \(\mathbb{Z}_m\) if and only if \(gcd(a,m) = 1\).

As another example, let's consider \(\mathbb{Z}_5\). The elements of \(\mathbb{Z}_5\) are \(\{[0],[1],[2],[3],[4]\}\). \([0]\) is never a unit: there is nothing you can multiply 0 by to get 1. \([1]\) and \([-1]\) are always units, and are always their own inverses. In this case, \([-1] = [4]\). \([2]\) and \([3]\) are also units, because \([2][3] = [6] = [1]\).

In this case, all non-zero elements of \(\mathbb{Z}_5\) were units, but this is not always the case. For example, in \(\mathbb{Z}_6\), the only units are \([1]\) and \([-1] = [5]\). For example, \([2]\) is not a unit, because

- \([2][0] = [0] \neq [1]\),
- \([2][1] = [2] \neq [1]\),
- \([2][2] = [4] \neq [1]\),
- \([2][3] = [6] = [0] \neq [1]\),
- \([2][4] = [8] = [2] \neq [1]\),
- \([2][5] = [10] = [4] \neq [1]\).

**Definition:** \(φ(m)\) is the number of units of \(\mathbb{Z}_m\). It is called the **totient** of \(m\) (\(φ\) is also sometimes called the "Euler phi-function").

The above examples show that \(φ(5) = 4\) and \(φ(6) = 2\).

**Claim:** If \(x \in \mathbb{Z}_m\) has an inverse, then it is unique.

**Proof:** Suppose \(xy = [1]\) and \(xy' = [1]\). We want to show \(y = y'\). We have \[ y = [1]y = (xy')y = (xy)y' = [1]y' = y' \]

Since the inverse is unique, we can give it a symbol: \(x^{-1}\) is the inverse of \(x\). We define \(x^{-n} ::= (x^{-1})^n\) and note that \(x^nx^{-n} = [1]\).

We have seen that addition, multiplication, and subtraction of equivalence classes, when defined in the obvious way, are well-defined. This is not true of exponentiation; we show this and fix it in the next lecture.