A-1.2 Modulo Arithmetic

The supported modulo operations are addition, subtraction, and multiplication. The properties of these modulo operations are as follows:

⟨Theorem A-1.2.1⟩ Properties of Modulo Operations

For any integer x, the following is true:

1.
Addition: a ≡b mod q⟺a + x ≡b + x mod q
2.
Subtraction: a ≡b mod q⟺a −x ≡b −x mod q
3.
Multiplication: a ≡b mod q⟺a ⋅x ≡b ⋅x mod q. This equivalence holds provided that gcd ⁡ (x,q) = 1. Without this assumption, only the implication a ≡b mod q ⇒a ⋅x ≡b ⋅x mod q is guaranteed.

Proof.

For any integer x,

1.
Addition: a ≡b mod q⟺a = b + 𝑘𝑞 (for some integer k) # a and b differ by some multiple of q

⟺a + x = b + k ⋅q + x

⟺a + x = b + x + k ⋅q ▹ a + x and b + x differ by some multiple of q

⟺a + x ≡b + x mod q

2.
Subtraction: a ≡b mod q⟺a = b + 𝑘𝑞 (for some integer k)

⟺a −x = b + k ⋅q −x

⟺a −x = b −x + k ⋅q ▹ a −x and b −x differ by some multiple of q

⟺a −x ≡b −x mod q

3.
Multiplication: a ≡b mod q⟺a = b + 𝑘𝑞 (for some integer k)

⟹a ⋅x = b ⋅x + k ⋅q ⋅x

⟹a ⋅x = b ⋅x + kx ⋅q (where kx = k ⋅x) ▹ a ⋅x and b ⋅x differ by some multiple of q

⟹a ⋅x ≡b ⋅x mod q

Conversely, if x and q are coprime (i.e., gcd ⁡ (x,q) = 1), then x has a multiplicative inverse x−1 modulo q. From a ⋅x ≡b ⋅x mod q

⟹a ⋅x ⋅x−1 ≡b ⋅x ⋅x−1 mod q

⟹a ≡b mod q

□

Based on the modulo operations in Theorem A-1.2.1, we can also derive the following properties of modulo arithmetic:

⟨Theorem A-1.2.2⟩ Properties of Modulo Arithmetic

1.
Associative: (a ⋅b) ⋅c ≡a ⋅(b ⋅c) mod q
2.
Commutative: (a ⋅b) ≡(b ⋅a) mod q
3.
Distributive: (a ⋅(b + c)) ≡((a ⋅b) + (a ⋅c)) mod q
4.
Interchangeable: Congruent values are interchangeable in modulo arithmetic.

For example, suppose (a ≡b mod q) and (c ≡d mod q). Then, a and b are interchangeable, and c and d are interchangeable in modulo arithmetic as follows:

(a + c) ≡(b + d) ≡(a + d) ≡(b + c) mod q

(a −c) ≡(b −d) ≡(a −d) ≡(b −c) mod q

(a ⋅c) ≡(b ⋅d) ≡(a ⋅d) ≡(b ⋅c) mod q

The proof of Theorem A-1.2.2 is similar to that of Theorem A-1.2.1, which we leave as an exercise for the reader.