Discrete Mathematics Linear congruences December 2014

Discrete Mathematics
Linear congruences
December 2014
Congruence relation for m, n ∈ Z and p ∈ N \ {0} is defined as follows:
m ≡ n (mod p)
m mod p = n mod p.
iff
Note the parentheses which are quite important—they distinguish congruence relation from the operation of
taking remainder: m mod p.
Example 1
10 ≡ 17 (mod 7) since both have remainder 3: 10 = 1 · 7 + 3 and 17 = 2 · 7 + 3.
Example 2
−5 ≡ 7 (mod 6) since both have remainder 1: −5 = (−1) · 6 + 1 and 7 = 1 · 6 + 1.
Exercise
Prove the following facts (facts 1–3 state that congruence is an equivlence relation):
1. m ≡ m (mod p),
2. if m ≡ n (mod p) then n ≡ m (mod p),
3. if m ≡ n (mod p) and n ≡ q (mod p) then m ≡ q (mod p),
4. if 0 6 m < p then m = m mod p,
5. (m mod p) ≡ m (mod p),
6. m ≡ n (mod p) iff p|(m − n),
7. if 0 < m, n < p and m ≡ n (mod p) then m = n,
8. if p ⊥ q, 0 6 m, n < p and qm ≡ qn (mod p) then m = n,
9. if m ≡ n (mod p) and µ ≡ ν (mod p) then m + n ≡ µ + ν (mod p) and mn ≡ µν (mod p),
10. (m mod p) + (n mod p) ≡ m + n (mod p), (m mod p)(n mod p) ≡ mn (mod p),
11. if q|p and m ≡ n (mod p) then m ≡ n (mod q),
12. if q 6= 0 then m ≡ n (mod p) iff qm ≡ qn (mod qp),
13. if q 6= 0 then qm ≡ qn (mod p) iff m ≡ n (mod gcd(p, q)),
14. if p ⊥ q then m ≡ n (mod p) iff qm ≡ qn (mod p),
15. if p ⊥ q then m ≡ n (mod pq) iff m ≡ n (mod p) and m ≡ n (mod q),
16. if m ≡ n (mod p) then gcd(m, p) = gcd(n, p).
The converse of 16 is not true since gcd(6, 9) = gcd(21, 9) = 3 but 6 6≡
21 mod 9 = 3.
If mn ≡ 1 (mod p) and 0 6 n < p then n is called the inverse of m mod p.
Theorem 1
Any m is invertible mod p iff m ⊥ p.
Proof.
“⇒” Let mn ≡ 1 (mod p). Then mn − 1 = kp for some k
gcd(m, p)|1.
“⇐” Let xm + yp = 1 for some x, y ∈ Z. By this xm ≡ 1 (mod p) and so
Properties of the inverse
1. (mn)−1 mod p ≡ (m−1 mod p) · (n−1 mod p) (mod p),
2. (−m)−1 mod p ≡ −(m−1 mod p) (mod p),
3. (mn )−1 mod p ≡ (m−1 mod p)n (mod p).
1
21 (mod 9), for 6 mod 9 = 6 and
We write n = m−1 mod p.
∈ Z. Hence 1 = mn − kp and so
x = m−1 mod p.
Theorem 2
If a ⊥ m then the equation ax ≡ b (mod m) has a unique solution mod p for x in the following
sense. If x0 , x1 are solutions then x0 ≡ x1 (mod p).
Proof.
Obviously a is invertible mod m since a ⊥ m. Thus
(a−1 mod m)ax ≡ (a−1 mod m)b (mod m),
by which
x ≡ (a−1 mod m)b (mod m).
Assume that ax0 ≡ b (mod m) and ax1 ≡ b (mod m). Then ax0 ≡ ax1 (mod m) and by 14 x0 ≡ x1 (mod m).
If a 6⊥ m but d := gcd(a, m) | b then by 12
ax ≡ b (mod m)
a/d · x ≡ b/d (mod m/d).
iff
If gcd(a, m) 6 | b then ax ≡ b (mod m) has no solutions for x.
The solutions to ax ≡ 0 (mod m) for x are
xk = k ·
Example
m
,
gcd(a, m)
for
k ∈ Z.
Let’s solve 9x ≡ 27 (mod 15) for x. First observe that gcd(9, 15) = 3 and 3 | 27. By 12 we have
3x ≡ 9 (mod 5).
Hence by 5
3x ≡ 4 (mod 5).
Now we need to invert 3 mod 5. This can be done according to Extended Euclidean Algorithm or by multiplication mod 5 table (Cayley table):
0 1 2 3 4
0 0 0 0 0 0
1 0 1 2 3 4
2 0 2 4 1 3
3 0 3 1 4 2
4 0 4 3 2 1
We see that 3 · 2 ≡ 1 (mod 5), therefore (by 1 and 9) 2 · 3x ≡ x (mod 5) and so
x ≡ 8 (mod 5).
Finally
x ≡ 3 (mod 5),
which gives x = 3 + 5k, k ∈ Z.
Exercise
Solve for x:
1. 3x ≡ 2 (mod 4),
7. 6x ≡ 4 (mod 10),
13. 5x ≡ 1 (mod 15),
19. 18x ≡ 30 (mod 42),
2. 2x ≡ 1 (mod 4),
8. 2x ≡ 5 (mod 11),
14. 6x ≡ 9 (mod 15),
20. 42x ≡ 12 (mod 78),
3. 3x ≡ 7 (mod 4),
9. 6x ≡ 5 (mod 11),
15. 9x ≡ 15 (mod 23),
21. 3x ≡ 50 (mod 113),
4. 2x ≡ 3 (mod 7),
10. 5x ≡ 1 (mod 11),
16. 14x ≡ 7 (mod 28),
5. 5x ≡ 7 (mod 8),
11. 4x ≡ 4 (mod 12),
17. 14x ≡ 7 (mod 35),
6. 6x ≡ 7 (mod 8),
12. 6x ≡ 12 (mod 12),
18. 10x ≡ 35 (mod 42),
2
22. 39x ≡ 27 (mod 123),
23. 230x ≡ 1081 (mod 12167).