Section 5. Congruence Arithmetic A number of computer languages have built-in functions that compute the quotient and remainder of division. Definition: div Let n, d 0. We define ndiv d as the least integer quotient obtained when n is divided b d. That is if n dq r, then n div d q. Alternativel: ndiv d n d Eamples. Find ndiv d for the following: n 54, d 4 54 4 13 2 54 div 4 13 n 32, d 9 32 9 ( 4) 4 32 div 9 4 Eercises: Find ndiv d for the following: n 54, d 4 n 54, d 70 WUCT121 Numbers 138
Definition: mod Let n, d 0. We define n mod d as the integer remainder obtained when n is divided b d. That is if n dq r, then n mod d r Eamples. Find n mod d for the following: n 54, d 4 54 4 13 2 54 mod 4 2 n 32, d 9 32 9 ( 4) 4 32 mod 9 4 Eercises: Find n mod d for the following: n 54, d 4 n 54, d 70 For n, for n mod 5 Congruence Arithmetic centres around a relation based on the idea of mod. WUCT121 Numbers 139
5.1. Definition: Congruence modulo n. Let n. We will define a relation on Ÿ called congruence modulo n (denoted ) b: a, b,( a b(mod n) n ( a b). Notes: a b(mod n) reads a is congruent to b modulo n. The definition sas that a b(mod n) if and onl if n divides the difference between a and b Another wa to think about congruence modulo n is in terms of remainders: a b(mod n) if and onl if a(mod n) b(mod n), that is, if a and b have the same remainder after being divided b n WUCT121 Numbers 140
Eamples: 38 2(mod 6) because 38 2 36 and 6 36. also 38 (mod 6) 2 and 2 (mod 6) 2 Find such that 12 (mod 5) Require such that 5 (12 ). That is need 12 5k, k. Set k 0, gives 12 0 12 Set k 1, gives 12 5 7 Set k 2, gives 12 10 2 Hence, Eercises: K, 3,2,7,12, K Find possible values for m in each case. 14 m(mod 8) 13 m(mod 7) WUCT121 Numbers 141
( n 1) m(mod n), n > 1 Determine whether each of the following is true or false. 7 9(mod 8) 2 8(mod11) 11 1(mod 5) Find values for in each case. 1(mod7) WUCT121 Numbers 142
3(mod5) 4(mod9) If m 0(mod 2), what can ou sa about m? If n 1(mod 2), what can ou sa about n? Fill in the spaces with the smallest possible nonnegative number. 21 (mod 4) 18 (mod 4) WUCT121 Numbers 143
5.2. Congruence Arithmetic 5.2.1. Theorem: Congruence Addition Let n, and a, b, c, d If a b(mod n) and c d(mod n), then ( a c) ( b d )(mod n). Proof: We know; a b(mod n) p, a b c d(modn) q, c d np K(1) nqk(2) We must show : ( a c) ( b d )(mod n), that is r, ( a c) ( b d ) nr Adding (1) and (2) gives ( a b) ( c d ) np nq ( a c) ( b d ) n( p q) nr r n ( a c) ( b d ) ( a c) ( b d )(mod n) p q WUCT121 Numbers 144
Eamples: 21 1(mod 4), 18 2(mod 4) 21 18 39 3(mod 4) 12 2(mod 5), 101 1(mod 5) 12 101 113 3(mod 5) Eercises: B considering 18 (mod12) and 73 (mod12), determine what time of da it will be 73 hours after 6pm on Sunda. B considering 15 (mod 60) and 135 (mod 60), determine where the minute hand on an analog clock will be located 135 minutes after 11:15. WUCT121 Numbers 145
5.2.2. Theorem: Congruence Multiplication Let n, and a, b, c, d If a b(mod n) and c d(mod n), then ac bd(mod n). Eercises: Complete the proof for congruence multiplication WUCT121 Numbers 146
Eamples: 21 1(mod 4), 18 2(mod 4) 21 18 378 2(mod 4) Find such that 3 9 (mod5), 0 < 5. 3 3 12(mod 5) 2(mod 5) 3 3 3 3(mod 5) 2 3 6 9 9 4(mod 5) 3 9 3 4(mod 5) 12(mod 5) 3 3 3 8(mod 5) 3(mod 5) 3 3 3 3 9 3 3 3 2(mod 5) 3 6 2 2(mod 5) 4(mod 5) 2 4(mod 5) 8(mod 5) 3(mod 5) WUCT121 Numbers 147
Eercises: Find the remainder when 7 7 is divided b 16. Need to find such that 7 7 ( mod16) 0 < 16 and Find such that 9 7 (mod15), 0 < 15. WUCT121 Numbers 148
5.2.3. Theorem: Cancellation Law Let n, and a, b, c If gcd( a, n) 1 and ab ac(mod n), then b c(mod n) Proof: We know; gcd( a, n) 1 and ab ac(mod n) Now, b the definition of congruence modulo n, we have ( ab ac) n a( b c) n ( b c) n see note b c(mod n) Note: Recall if gcd( a, b) 1 and a bc, then a c Eamples: gcd( 5,4) 1 and 5 6 5 2(mod 4), that is 30 10(mod 4) 6 2(mod 4) WUCT121 Numbers 149
gcd( 6,3) 3 and 6 1 6 2(mod 3) that is, 6 12(mod 3). However, 1 / 2(mod 3) Eercises: Given 10904 32(mod 9) Find such that 1363 (mod 9), 0 < 9. Simplif 6 36(mod10) WUCT121 Numbers 150
5.3. Congruence Classes Modulo n Lemma: Let n. If, then is congruent (modulo n) to eactl one element in { 0, 1, 2,, n 1} K. This lemma is important as it allows us to group integers according to their remainder after dividing b a given number n. 5.3.1. Definition: Equivalence Class Let n. The equivalence class determined b s, denoted s, is defined as s { : s(mod n)}. Eamples: The following are equivalence classes when n 3 o 0 { K, 12, 9, 6, 3, 0, 3, 6, 9,12,K} o 1 { K, 8, 5, 2, 1, 4, 7,K} o 2 { K, 7, 4, 1, 2, 5, 8,K} o 3 { K, 12, 9, 6, 3, 0, 3, 6, 9,12,K} WUCT121 Numbers 151
Eercises: Write down 10 elements in the following equivalence classes if n 4. o 0 o 1 o 2 o 3 o 4 o 5 How man distinct (i.e., different) equivalence classes (mod 4) do ou epect there to be? WUCT121 Numbers 152
Lemma: If n, then there are eactl n distinct equivalence classes determined b n, namel 0, 1, 2,, n 1. Proof: B previous Lemma, ever one of the numbers 0, 1, 2,, n 1. is congruent to eactl Therefore, is congruent to one of 0, 1, 2,, n 1. Hence, we have n classes. To prove the equivalence classes are distinct (disjoint), we must show that for Let 0 i < j n 1. Suppose that that i and j. Then, we have i j, i j. i j ; that is, there eists such i i(mod n) and j j(mod n) However, this contradicts the lemma that is congruent modulo n to eactl one of 0, 1, 2,, n 1., so our assumption that the result follows. i j is false, so i j and WUCT121 Numbers 153
5.4. Definition: Set of Residues Ÿ n For all and sa that Eercises: n, let { 0, 1, 2, K, n 1 } n n is the complete set of residues modulo n. What are 3, 218 and 1? In 3, what are the sets 4, 2,7,40 usuall epressed as? How man names" are there for 3 in 10? List three. In n, 0 1 2 K n 1 and 0 1 2 K n 1. WUCT121 Numbers 154
As seen above, an infinite number of names. Aside: n is a set of elements, each of which has Consider, the set of all rational numbers. For all, has an infinite number of names. Eample: 1 2 2 4 3 6 100 200 L How have we defined addition of rational numbers? Eample: 1 3 7 6 13. 2 7 14 14 Wh couldn't we define addition as follows? 1 2 3 7 1 3 2 7 4 9 When we define and on n, we must make sure our definitions do NOT depend on the name of the equivalence class. We can then sa that and on or consistent. n are well-defined WUCT121 Numbers 155
5.4.1. Definition: Addition on Ÿ n Addition on n is defined as follows: a, b n, a b a b. To prove that addition is consistent relies on the following propert a b a b(mod n) Proof: Let a c and b d in n. We must prove that a b c d. a c a c(mod n) K(1) and b d b d(mod n) K(2) Adding (1) and (2) using congruence addition gives ( a b) a b ( c d )(mod n) c d Therefore, addition on Eample: n is consistent. In 3, we know 1 4 and 2 5. We want 1 2 4 5 Now, 1 2 1 2 3 and 4 5 4 5 9 3 Therefore, 1 2 4 5. WUCT121 Numbers 156
5.4.2. Definition: Multiplication on Ÿ n Multiplication on n is defined as follows: a, b n, a b a b. Proof: Let a c and b d in n. We must prove that a b c d. a c a c(mod n) K(1) and b d b d(mod n) K(2) Adding (1) and (2) using congruence multiplication gives ( a b) ( c d )(mod n) a b c d Therefore, multiplication on Eample: n is consistent. In 3, we know 1 4 and 2 5. We want 1 2 4 5 Now, 1 2 1 2 2 and 4 5 4 5 20 2 Therefore, 1 2 4 5. WUCT121 Numbers 157
Eercises: Write out the addition and multiplication tables for 3. 0 1 2 0 1 2 0 1 2 0 1 2 Are addition and multiplication closed operations on 3? Solve these equations for in 3. o 2 0 o 2 1 o 0 1 o 0 2 Is 3 commutative under addition or multiplication? WUCT121 Numbers 158
WUCT121 Numbers 159 Is 3 associative under addition or multiplication? Does it have the distributive propert? How would ou prove or disprove our answers? Commutativit: and, 3 Associativit: ) ( ) ( ) ( ) ( and ) ( ) ( ) ( ) (,, 3
WUCT121 Numbers 160 Distributivit: ) ( ) ( ) ( ) ( and ) ) ( ) (,, 3 Does 3 have an identit under addition or multiplication? Does each element of 3 have an inverse under addition? What are the?
Does each element of 3 have an inverse under multiplication? What are the? Eercises: Write out the multiplication table for 4 0 1 2 3 0 1 2 3 Is multiplication a closed operation on 4? Solve these equations for in 4. o 2 2 o 2 0 o 2 1 o 3 1 WUCT121 Numbers 161
Is 4 commutative or associative under multiplication? Does 4 have an identit under multiplication? Does each element of 4 (ecept 0) have an inverse under multiplication? WUCT121 Numbers 162
Properties of Ÿ: Properties of n: Addition and multiplication are closed operations Commutative under addition and multiplication Associative under addition and multiplication Distributive Identities: 0 under addition; 1 under multiplication Inverses: Addition: of a a is the inverse Multiplication: onl ±1 have inverses Addition and multiplication are closed operations Commutative under addition and multiplication Associative under addition and multiplication Distributive Identities: 0 under addition; 1 under multiplication Inverses: Addition: In n, each element has an additive inverse: a (or n a) Multiplication: For certain values of n, each element, other than 0, has an inverse. WUCT121 Numbers 163
Notes: All non-ero elements in onl for certain values of n. n have multiplicative inverses In 3, ever non-ero element has a multiplicative inverse. In 4, 2 has no multiplicative inverse. What do ou think might be the condition on n for all nonero elements in n must be prime. n to have multiplicative inverses? WUCT121 Numbers 164