C-N Math 207 Discrete Math Kenneth Massey September 16, 2011 C-N Math 207 - Massey, 1 / 70
Question Introduction What is the smallest positive number? C-N Math 207 - Massey, 2 / 70
Sets Introduction a set S is a collection of objects (members, elements) S = {VT, UNC, GT, Mia, UVA, Duke} the cardinality (size) of S is written as S S is finite if S <, and infinite if S = empty / null set = { }, = 0 x is an element of S is denoted by x S C-N Math 207 - Massey, 3 / 70
Numbers Introduction Abstract notions of quantity, position, or size. natural numbers N = {0, 1, 2, 3, } (use N + to omit zero) integers Z = {, 2, 1, 0, 1, 2, 3, } set-builder notation: members such that conditions rational numbers Q = { n d n, d Z, d 0} real numbers R is the continuum of all points on number line including irrationals e.g. 2, π C-N Math 207 - Massey, 4 / 70
Set Examples Introduction 1. S = {x Z x 5 2} 2. S = {1, 1 2, 1 4, 1 8, } 3. S = {(x, y) R 2 x 2 + y 2 1} 4. S = {ticker symbols of S&P 500 members} C-N Math 207 - Massey, 5 / 70
Discrete vs Continuous Introduction A set is discrete if its members can be listed (enumerated) so that each has a next (successor), with nothing in-between all finite sets are discrete (loop) examples: 1. digital computers 2. money (Office Space rounding) 3. siblings ( 1 2 allowed) 4. water discrete, but practically continuous 5. quantum physics 6. movie frames vs real time? 7. Z vs R, Q? C-N Math 207 - Massey, 6 / 70
Existence and Uniqueness Introduction there exists is denoted by x Z x 2 = 9! means there exists a unique! x R 3x + 4 = 10 slash through a symbol means not x Q x 2 = 2 C-N Math 207 - Massey, 7 / 70
If-Then Statements Introduction If (condition) then (conclusion) The conclusion must be true whenever the condition is true. Any exception (counter-example) means the if-then statement is false. If c Z, then x R x 2 + 6x = c C-N Math 207 - Massey, 8 / 70
Function Introduction f : A B is a function that pairs each member of set A with a unique member of set B. y = f (x ) where x A and y B the set A is called the domain the set B is called the codomain {b B a A with f (a) = b} is called the range or image of f C-N Math 207 - Massey, 9 / 70
Function Examples Introduction 1. f : R R defined by y = f (x ) = x 2 2. f : Z N defined by y = f (x ) = x 2 3. f : N N defined by y = f (n) = n 4. f : N + Q defined by f (n) = n+1 n Which are onto (range equals codomain)? Which are one-to-one (no y value hit twice)? C-N Math 207 - Massey, 10 / 70
Invertible Function Introduction f is said to be invertible if each y in B is mapped to exactly once f 1 : B A is a function that reverses f To find the inverse, solve for x. x = f 1 (y) the composition of a function and its inverse is the identity function f 1 f = I f 1 (f (x )) = x and f (f 1 (y) = y C-N Math 207 - Massey, 11 / 70
Sequence Introduction A sequence is a function whose domain is some subset of Z (often N). an ordered indexed list, f (k) = f k geometric sequence a k = r k for some r R harmonic sequence { } 1 k k=1 C-N Math 207 - Massey, 12 / 70
Sum Notation Capital Greek sigma Σ indicates the sum of indexed terms, e.g. 6 k 2 = 3 2 + 4 2 + 5 3 + 6 2 = 86 k=3 k=1 a n = Introduction 1 10 k =.1 +.01 +.001 + =.11111 = 1 9 n k = k=1 n(n + 1) 2 C-N Math 207 - Massey, 13 / 70
Product Notation Introduction Capital Greek pi Π indicates the product of indexed terms, e.g. 4 k=1 k + 1 k = (2/1)(3/2)(4/3)(5/4) = 5 C-N Math 207 - Massey, 14 / 70
Factorials Introduction n factorial is defined for n N by n! = { n k=1 k n 1 1 n = 0 the sequence of factorials is 1, 1, 2, 6, 24, 120, n! = n (n 1)! C-N Math 207 - Massey, 15 / 70
Z is discrete, but infinite Subsets of Z can be used to label other discrete sets. Arithmetic operations: addition (+) and multiplication ( ) Basic properties: closed, commutative, associative, distributive, identities, inverses, ordered Number theory is the branch of mathematics that studies the properties of Z. C-N Math 207 - Massey, 16 / 70
Division Algorithm Note that 17 3 = 5 + 2 3 can be written as 17 = 3 5 + 2 Division algorithm: let a, b Z, with b 0, then! q, r Z such that a = bq + r, 0 r < b q is called the quotient, and r the remainder. example: a = ±73, b = 11 C-N Math 207 - Massey, 17 / 70
Place Value Ways to represent natural numbers: tally/tic marks, Egyptian, Roman numeral, place value (brilliant!). We are familiar with base 10, but other societies have used e.g. base 12 or 60. Computers use binary (base 2) octal (base 8), [hexadecimal] (base 16) C-N Math 207 - Massey, 18 / 70
Place Value Each x N can be uniquely represented in base b as a linear combination of powers of b, with each coefficient (digit) between 0 and b 1. x = (D d 1 D 2 D 1 D 0 ) b = (75) 10 = 7 10 1 + 5 10 0 d 1 k=0 (113) 8 = 1 8 2 + 1 8 1 + 3 8 0 (300) 5 = 3 5 2 (1001011) 2 = 2 6 + 2 3 + 2 1 + 2 0 (4B) 16 = 4 16 1 + 11 16 0 D k b k C-N Math 207 - Massey, 19 / 70
Place Value Write (146) 10 in base 3 using the division algorithm. 146 = 3 48 + 2 = 3 (3 16 + 0) + 2 = 3 (3 (3 5 + 1) + 0) + 2 = 3 (3 (3 (3 1 + 2) + 1) + 0) + 2 So (146) 10 = (12102) 3. C-N Math 207 - Massey, 20 / 70
Place Value There are 10 types of people in the world: those that understand binary, and those that don t. 1. Coach Sparks decides to use hexadecimal for the football team s jersey numbers. If a jersey reads AC, find the decimal and binary equivalents. 2. How many points did C-N win by if the scoreboard reads 53 32 in base 7? C-N Math 207 - Massey, 21 / 70
Place Value Arithmetic algorithms work the same way in other bases. 1. (234) 5 + (312) 5 2. (175) 8 (6) 8 3. (11010) 2 (1011) 2 C-N Math 207 - Massey, 22 / 70
Divides Definition: Let a, b Z. Then b divides a, if and only if (iff) there exists q Z such that a = bq. in the division algorithm, r = 0 Equivalent statements: notation: b a b divides (evenly into) a a is divisible by b b is a factor/divisor of a C-N Math 207 - Massey, 23 / 70
Generally True? 1. n 0 2. 0 n 3. n 1 4. 1 n 5. n n 6. n n 2 7. (a + b) (a 2 b 2 ) C-N Math 207 - Massey, 24 / 70
Your First Proof Theorem: If a b and b c, then a c (divisibility is transitive) Illustration: 4 12 and 12 72, therefore 4 72. Proof: Suppose a b and b c. By definition, b = aq 1 and c = bq 2. Then by substitution, c = bq 2 = (aq 1 )q 2 = a(q 1 q 2 ). Therefore a c. C-N Math 207 - Massey, 25 / 70
Direct If-Then Proofs 1. Understand what you are proving. Work an example; believe it is true. 2. Scratch work: what do you know? (the if part) what do you need to show? (the then part) use definitions to translate symbols/terminology deduce the desired result using algebra, substitution, tricks, previous theorems, etc 3. Rewrite your proof neatly. State the theorem. Prove the theorem, clearly justifying each step as you move from assumptions to the conclusion. C-N Math 207 - Massey, 26 / 70
Theorem: Suppose a, b N. If a b and b a, then a = b. Proof: C-N Math 207 - Massey, 27 / 70
Even and Odd Definitions: n Z is even iff q Z n = 2q n Z is odd iff q Z n = 2q + 1 Prove that 1. if n is odd, then n + 5 is even. 2. if n is odd, then n 2 is odd. C-N Math 207 - Massey, 28 / 70
Modulo As in the division algorithm, let a = bq + r. Then a modulo b is the remainder r. notation: a (mod b) = r b a iff a (mod b) = 0 odd if a (mod 2) = 1 List the possible values of a (mod 5). C-N Math 207 - Massey, 29 / 70
Congruence a and b are congruent (aliases) mod n a b (mod n) Equivalent definitions: n (a b) a (mod n) = b (mod n) (a b) (mod n) = 0 a b = qn for some q Z C-N Math 207 - Massey, 30 / 70
Equivalence Congruence is an equivalence relation: 1. reflexive a a (mod n) 2. symmetric if a b (mod n) then b a (mod n) 3. transitive if a b (mod n) and b c (mod n) then a c (mod n) C-N Math 207 - Massey, 31 / 70
(mod n) The equivalence class of a (mod n) is the set of all of a s aliases. [a] n = {b Z a b (mod n)} Z n is the set of all equivalence classes (mod n) Z n = {0, 1, 2, 3, n 1} Z mod n puts each integer into exactly one class loop around like a clock C-N Math 207 - Massey, 32 / 70
Proof of Transitivity Theorem: if a b (mod n) and b c (mod n) then a c (mod n) Proof: Assume that a b (mod n). Then by definition a b = nq 1 for some q 1 Z. Similarly b c = nq 2 for some q 2 Z. (therefore) a c = (a b)+(b c) = nq 1 +nq 2 = n(q 1 +q 2 ) and hence by definition n (a c) and a c (mod n). C-N Math 207 - Massey, 33 / 70
Algrebra of Congruence Theorem: if a b and c d, then a + c b + d and ac bd. Proof: By assumption, and the definition of congruence, a b = q 1 n and c d = q 2 n. Therefore, (a + c) (b + d) = (a b) + (c d) = q 1 n + q 2 n = (q 1 + q 2 )n ac bd = (b + q 1 n)c b(c q 2 n) = (q 1 c + q 2 b)n Thus by definition, a + c b + d and ac bd. C-N Math 207 - Massey, 34 / 70
Z n Algebra Hence we may develop algebra of + and on Z n. See the Affine Cipher Project. addition / [multiplication tables] inverses solving equations C-N Math 207 - Massey, 35 / 70
Problems 1. Compute 7 5 (mod 11), reducing as you go. 2. What day of the week will it be 10000 days from now? 3. Solve 4(6x 5) 5 (mod 7). C-N Math 207 - Massey, 36 / 70
Affine Cipher The affine cipher transforms each character in an alphabet by the formula: y = f (x ) = (ax + b) (mod n) Experiment with the [web app]. Using the alphabet (space, A-Z), decrypt VWBTU if y = 5x + 2 (mod 27). C-N Math 207 - Massey, 37 / 70
Invertibility If n = 27, a = 3, and b = 5 then J (letter 10) gets tranformed to H, but so does A To be decipherable, a cipher function must be invertible (reversible). Each character must be mapped to exactly once. If n = 27, what values of a make the affine cipher an invertible function? What if n = 28? C-N Math 207 - Massey, 38 / 70
Affine De-Cipher if y = f (x ) = ax + b then x = f 1 (y) = a 1 (y b) y = ax + b is invertible iff a 1 exists find 7 1 (mod 27) by writing {7k (mod 27)} 7 1 (mod 28) DNE inverses come in pairs (some may be their own inverse) hypothesize about when a 1 (mod n) exists C-N Math 207 - Massey, 39 / 70
A Weird Function Let δ : N + N be defined by δ(n) = {q N q n} Describe the function in words. Compute δ(21). C-N Math 207 - Massey, 40 / 70
Prime Numbers Let n > 1 be a natural number. Definition: n is prime if its only natural number divisors are 1 and n itself. n is prime iff δ(n) =. If n is not prime, then it is composite. If n is composite, then it has a prime factor which is n. Sieve of Eratosthenes C-N Math 207 - Massey, 41 / 70
Fundamental Theorem of Arithmetic Fundamental Theorem of Arithmetic: each n > 1 can be written uniquely (up to ordering) as the product of prime factors n = p α i i e.g. the prime factorization of 21560 is 21560 = 2 3 5 7 2 11 C-N Math 207 - Massey, 42 / 70
Prime Number Theorem Let π(n) be the number of primes p n. π(n) n ln(n) This estimate was proved to be asymptotic in 1896. lim n π(n) n/ ln(n) = 1 C-N Math 207 - Massey, 43 / 70
Greatest Common Divisor Define the greatest common divisor of a, b Z to be the largest integer that is a divisor of both a and b. e.g. gcd(36, 84) = 12 (can use prime factors) If a 0, then gcd(a, 0) = a. a and b are relatively prime (coprime) if gcd(a, b) = 1 C-N Math 207 - Massey, 44 / 70
Least Common Multiple Define the least common multiple of a, b Z to be the smallest natural number that is a multiple of both a and b. e.g. lcm(14, 35) = 70 (can use prime factors) If l = lcm(a, b) then a l and b l Define lcm(a, 0) = 0 as a special case. C-N Math 207 - Massey, 45 / 70
GCD and LCM gcd and lcm are commutative functions Use prime factors to find gcd(24, 30) and lcm(24, 30). Convince yourself that gcd(a, b) lcm(a, b) = ab. C-N Math 207 - Massey, 46 / 70
Proving or Disproving Consider a general if-then statement. To be true, it must hold for any condition that satisfies the if part. No exceptions. You can t prove the statement by cherry-picking examples that work. You can disprove the statement by finding one counter-example: a case where the if part is true, but the then part is false. C-N Math 207 - Massey, 47 / 70
Disprove Find a counter-example to the following: 1. if n > 0 then 2 2n + 1 is prime 2 25 + 1 = 4294967297 = (641)(6700417) 2. if c (ab) then either c a or c b 3. gcd(ma, nb) = gcd(m, n) gcd(a, b) C-N Math 207 - Massey, 48 / 70
Prove 1. If x 3 (mod 8) then x 2 9 (mod 16). 2. The product of two consecutive integers is even. (rewrite as if/then) 3. If n is odd, then 8 (n 2 1). 4. If c a and c b, then for any m, n Z, c (ma + nb). 5. If n N, then gcd(n, n + 1) = 1. C-N Math 207 - Massey, 49 / 70
Prove or disprove 1. If p is prime, then p + 7 is composite. 2. If n > 0, then 3 n + 2 is prime. 3. If a b (mod n) then a 2 b 2 (mod n 2 ) 4. If a b (mod n) then a 2 b 2 (mod n) C-N Math 207 - Massey, 50 / 70
Mathematical Statements conjecture: believed to be true, but unproven lemma: a precursor to a more noteworthy theorem theorem: has been proved corollary: follows as a special case of a theorem C-N Math 207 - Massey, 51 / 70
Fun Fact (Liouville) Pick any n N + and write down its divisors, e.g. if n = 50 then {1, 2, 5, 10, 25, 50}. Then count how many divisors each divisor has. C = {1, 2, 2, 4, 3, 6}. Then ( C x )2 = C x 3. (1+2+2+4+3+6) 2 = 1+8+8+64+27+216 Proof is beyond the scope of this class. C-N Math 207 - Massey, 52 / 70
E.A. Lemma 1 Lemma: For any k Z, x divides both a and b if and only if (iff) x divides both a + kb and b Proof: Suppose x a and x b. Then a = xq 1 and b = xq 2. Therefore a + kb = x (q 1 + kq 2 ), and so x (a + kb). Now suppose x (a + kb) and x b. Then a + kb = xq 1 and b = xq 2. Therefore a = xq 1 kb = x (q 1 kq 2 ), and so x a. C-N Math 207 - Massey, 53 / 70
E.A. Lemma 2 Lemma: For any k Z, gcd(a, b) = gcd(b, a + kb) Proof: By the previous lemma, the set of common divisors of a and b is identical to the set of common divisors of a + kb and b. Therefore the GCD s must be the same. C-N Math 207 - Massey, 54 / 70
Euclidean Algorithm Euclidean Algorithm Theorem: gcd(a, b) = gcd(b, a (mod b)) Proof: Use the division algorithm to write a = bq + r, where r = a (mod b). Then r = a bq. Taking k = q, the previous lemma says that gcd(a, b) = gcd(b, a bq) = gcd(b, r) C-N Math 207 - Massey, 55 / 70
E.A. Example The Euclidean algorithm repeatedly uses the previous theorem to find the GCD of two numbers. gcd(952, 210) = gcd(210, 112) = gcd(112, 98) = gcd(98, 14) = gcd(14, 0) = 14 C-N Math 207 - Massey, 56 / 70
E.A. Exercises 1. Use the EA to find gcd(12540, 2002), then find the lcm. 2. Show that 495 and 392 are relatively prime. 3. True or false? gcd(a, b, c) = gcd(gcd(a, b), c) 4. Draw a line from (0, 0) to (a, b) in the Cartesian plane. How many integer lattice points does it cross? C-N Math 207 - Massey, 57 / 70
GCD as a Linear Combination Back-substitution allows us to write the gcd as a linear combination of the two arguments, that is gcd(a, b) = c 1 a + c 2 b. 952 = (210)(4) + 112 210 = (112)(1) + 98 112 = (98)(1) + 14 98 = (14)(7) + 0 112 = 952(1) + (210)( 4) 98 = (952)( 1) + (210)(5) 14 = (952)(2) + (210)( 9) C-N Math 207 - Massey, 58 / 70
GCD as a Linear Combination Theorem a and b are relatively prime iff 1 can be written as a linear combination of a and b. Proof First suppose a and b are relatively prime. Then gcd(a, b) = 1, and the EA with back-substitution allows us to write c 1 a + c 2 b = gcd(a, b) = 1. Now suppose c 1 a + c 2 b = 1, and suppose x is a divisor of both a and b. Say a = xq 1 and b = xq 2. Then x (c 1 q 1 + c 2 q 2 ) = 1, and since everything is an integer, it must be that x = 1. Therefore gcd(a, b) = 1. C-N Math 207 - Massey, 59 / 70
Inverses in Z n Theorem If gcd(a, n) = 1, then a has an inverse in Z n. Proof Since gcd(a, n) = 1, we can write c 1 a + c 2 n = 1. Therefore c 1 a 1 (mod n), and c 1 is the candidate inverse. (existence) To be the inverse, c 1 must be the unique solution to ax 1 in Z n. If ax 1 then ac 1 ax 0, and therefore c 1 a(c 1 x ) 0. But since c 1 a 1, we get c 1 x 0 or x c 1. (uniqueness) a 1 = c 1 C-N Math 207 - Massey, 60 / 70
Inverses in Z n Theorem The converse is also true: if a has in inverse in Z n, then gcd(a, n) = 1. Proof Suppose ab 1 (mod n), so that ab = 1 + kn. Let d be a divisor of both a and n, so that a = dq 1 and n = dq 2. Then dq 1 b = 1 + kdq 2, and d(q 1 b kq 2 ) = 1. The only integer possibility is d = ±1. C-N Math 207 - Massey, 61 / 70
Finding an inverse in Z n 1. Show that a = 28 and n = 135 are relatively prime, and write 1 as a linear combination of a and n. 2. Find 28 1 (mod 135). 3. Find 4 1 in Z 27 (easy by inspection) 4. Find 8 1 in Z 27 (use EA) 5. Solve 10(x 7) = 6 + 2x in Z 27 C-N Math 207 - Massey, 62 / 70
Affine Cipher Decryption Recall the affine cipher function and its inverse: y = ax + b (mod n) x = a 1 (y b) We now know that a 1 exists iff gcd(a, n) = 1. In general, use the EA to write c 1 a + c 2 n = 1, and then a 1 = c 1. If n = 27, a = 2, and b = 5, then y = 2x + 5 (mod 27) x = 14(y 5). C-N Math 207 - Massey, 63 / 70
Pirate Treasure CRT A band of ten pirates captured a treasure chest full of gold coins. When they attempted to divide the coins evenly, 3 were left over. A fight ensued and one pirate was killed. Again they attempted to divide the coins, but now there were 8 left over. This time two pirates were killed fighting over the extras. On the third try, the coins divided evenly. How many coins were in the chest? C-N Math 207 - Massey, 64 / 70
Pirate Treasure CRT Solve the system of congruences: x 3 (mod 10) x 8 (mod 9) x 0 (mod 7) C-N Math 207 - Massey, 65 / 70
Chinese Remainder Theorem CRT Chinese Remainder Theorem: if m 1 and m 2 are relatively prime, then x r 1 (mod m 1 ) x r 2 (mod m 2 ) has a unique solution (mod m 1 m 2 ). This theorem can be extended to 3 or more congruences by induction. C-N Math 207 - Massey, 66 / 70
CRT Algorithm CRT Idea: absorb each congruence sequentially: x = 3 + 10n 3 + 10n 8 (mod 9) 1n 5 (mod 9) n 1 1 5 (mod 9) n = 5 x = 53 (mod 90) 53 + 90n 0 (mod 7) 4 + 6n 0 (mod 7) 6n 3 (mod 7) n = 6 1 3 (mod 7) n = 4 x = 413 (mod 630) C-N Math 207 - Massey, 67 / 70
Football Scores CRT Find all scores less than 100 that satisfy: x 1 (mod 2) x 2 (mod 3) x 3 (mod 7) C-N Math 207 - Massey, 68 / 70
CRT Conditions This system has solutions CRT x 3 (mod 4) x 5 (mod 6) but this one is inconsistent, and has no solution. x 2 (mod 4) x 5 (mod 6) C-N Math 207 - Massey, 69 / 70
Eggs CRT An old woman goes to market and a horse steps on her basket and crushes the eggs. The rider offers to pay for the damages and asks her how many eggs she had brought. She does not remember the exact number, but when she had taken them out two at a time, there was one egg left. The same happened when she picked them out three, four, five, and six at a time, but when she took them seven at a time they came out even. What is the smallest number of eggs she could have had? C-N Math 207 - Massey, 70 / 70