3.1: Modulo Operation
( \newcommand{\kernel}{\mathrm{null}\,}\)
Definition: Modulo
Let m ∈ Z+.
a is congruent to b modulo m denoted as a≡b(modn), if a and b have the remainder when they are divided by n, for a,b∈Z.
Example 3.1.1:
Suppose n=5, then the possible remainders are 0,1,2,3, and 4, when we divide any integer by 5.
Is 6≡11(mod5)? Yes, because 6 and 11 both belong to the same congruent/residue class 1. That is to say when 6 and 11 are divided by 5 the remainder is 1.
Is 7≡15(mod5)? No, because 7 and 15 do not belong to the same congruent/residue class. Seven has a remainder of 2, while 15 has a remainder of 0, therefore 7 is not congruent to 15(mod5). That is 7≢15(mod5).
Example 3.1.2: Clock arithmetic
Find 18:00, that is find 18(mod12).
Solution
18mod(12)≡6. 6 pm.
Properties
Let n∈Z+. Then
Theorem 1 :
Two integers a and b are said to be congruent modulo n, a≡b(modn), if all of the following are true:
a) m∣(a−b).
b) both a and b have the same remainder when divided by n.
c) a−b=kn, for some k∈Z.
NOTE: Possible remainders of n are 0,...,n−1.
Reflexive Property
Theorem 2:
The relation " ≡ " over Z is reflexive.
Proof: Let a∈Z.
Then a−a=0(n), and 0∈Z.
Hence a≡a(modn).
Thus congruence modulo n is Reflexive.
Symmetric Property
Theorem 3:
The relation " ≡ " over Z is symmetric.
Proof: Let a,b∈Z such that a≡b (mod n).
Then a−b=kn, for some k∈Z.
Now b−a=(−k)n and −k∈Z.
Hence b≡a(modn).
Thus the relation is symmetric.
Antisymmetric Property
Is the relation " ≡ " over Z antisymmetric?
Counter Example: n is fixed
choose: a=n+1,b=2n+1, then
a≡b(modn) and b≡a(modn)
but a≠b.
Thus the relation " ≡ "on Z is not antisymmetric.
Transitive Property
Theorem 4 :
The relation " ≡ " over Z is transitive.
Proof: Let a,b,c∈ Z, such that a≡b(modn) and b≡c(modn).
Then a=b+kn,k∈ Z and b=c+hn,h∈ Z.
We shall show that a≡c(modn).
Consider a=b+kn=(c+hn)+kn=c+(hn+kn)=c+(h+k)n,h+k∈ Z.
Hence a≡c(modn).
Thus congruence modulo n is transitive.
Theorem 5:
The relation " ≡ " over Z is an equivalence relation.
Modulo classes
Let . The relation ≡ on
by a≡b if and only if
, is an equivalence relation. The Classes of
have the following equivalence classes:
Example of writing equivalence classes:
Computational aspects:
Finding "mod 5"
%%python3 print( "integer integer mod 5") for i in range(30): print(i, " ", i%5)
Code 3.1.1 (Python):
%%python3