Modular Arithmetic#
Theorem: Division with Remainder
For any two integers \(a, b \in \mathbb{Z}\) with \(b \ne 0\), there exist integers \(q, r \in \mathbb{Z}\) such that
with
Definition: Quotient
We call \(q\) the quotient of the division of \(a\) by \(b\).
Definition: Remainder
We call \(r\) the remainder of the division of \(a\) by \(b\).
Notation
We often write \(r\) in the following way:
Proof
TODO
Theorem: Finding the Remainder
The remainder is always given by the following formula:
Proof
TODO
Modular Congruence#
Definition: Modular Congruence
Let \(a, b \in \mathbb{Z}\) and let \(n \in \mathbb{Z} \setminus \{0\}\).
We say that \(a\) and \(b\) are congruent modulo \(n\) if \(n\) is a divisor of \(a - b\):
Notation
Modular Arithmetic#
Definition: Modular Addition
Let \(a, b \in \mathbb{Z}\) and let \(n \in \mathbb{N}\).
The addition of \(a\) and \(b\) modulo \(n\) is defined as the remainder upon dividing \(a + b\) by \(n\):
Notation
Theorem: Simplifying Modular Addition
Addition modulo \(n\) has the following property:
Proof
The following proof was generated by AI and has not been human-verified. As such, it may contain mistakes.
By definition, the left-hand side (LHS) is:
$$
a \oplus_n b = (a + b) \bmod n
$$
We want to prove that this is equal to the right-hand side (RHS):
$$
((a \bmod n) + (b \bmod n)) \bmod n
$$
We can express \(a\) and \(b\) in terms of their quotients and remainders when divided by \(n\).
Let:
- \(a = q_a n + r_a\), where \(q_a\) is an integer and \(r_a = a \bmod n\) (with \(0 \le r_a < n\)).
- \(b = q_b n + r_b\), where \(q_b\) is an integer and \(r_b = b \bmod n\) (with \(0 \le r_b < n\)).
Now, let's analyze the LHS by substituting these expressions:
The term \((q_a + q_b)n\) is an integer multiple of \(n\), so it does not affect the remainder when the entire sum is divided by \(n\). Therefore, the expression simplifies to:
Next, let's analyze the RHS by substituting the definitions of \(r_a\) and \(r_b\):
Since both the LHS and RHS simplify to the same expression, \((r_a + r_b) \bmod n\), they are equal.
This completes the proof.
Definition: Modular Addition
Let \(a, b \in \mathbb{Z}\) and let \(n \in \mathbb{N}\).
The multiplication of \(a\) and \(b\) modulo \(n\) is defined as the remainder upon dividing \(a \cdot b\) by \(n\):
Notation
Theorem: Simplifying Modular Multiplication
Multiplication modulo \(n\) has the following property:
Proof
The following proof was generated by AI and has not been human-verified. As such, it may contain mistakes.
By the definition of modular multiplication, the expression \(a \otimes_n b\) is equivalent to \((a \cdot b) \bmod n\). Therefore, our goal is to prove that:
For any integers \(a\) and \(n\) (with \(n > 0\)), there exist unique integers \(q\) (quotient) and \(r\) (remainder) such that \(a = qn + r\) and \(0 \le r < n\). By definition, \(r = a \bmod n\).
Let's apply this to integers \(a\) and \(b\):
- Let \(r_a = a \bmod n\). This means there exists an integer \(q_a\) such that \(a = q_a n + r_a\).
- Let \(r_b = b \bmod n\). This means there exists an integer \(q_b\) such that \(b = q_b n + r_b\).
Now, let's consider the product \(a \cdot b\):
We can factor out \(n\) from the first three terms:
Let \(k = q_a q_b n + q_a r_b + r_a q_b\). Since \(q_a, q_b, n, r_a, r_b\) are all integers, \(k\) must also be an integer. So we can write:
This equation shows that \(a \cdot b\) and \(r_a r_b\) have the same remainder when divided by \(n\). In the language of modular congruence, this means \(a \cdot b \equiv r_a r_b \pmod{n}\).
Therefore, by the definition of the modulo operator:
Now, we substitute back the definitions of \(r_a\) and \(r_b\):
This completes the proof.