180 likes | 491 Views
Quantification. Another example: Let the universe of discourse be the real numbers. What does xy (x + y = 320) mean ? “For every x there exists a y so that x + y = 320.”. Is it true?. yes. Is it true for the natural numbers?. no. Disproof by Counterexample.
E N D
Quantification • Another example: • Let the universe of discourse be the real numbers. • What does xy (x + y = 320) mean ? • “For every x there exists a y so that x + y = 320.” Is it true? yes Is it true for the natural numbers? no Applied Discrete Mathematics Week 3: Algorithms
Disproof by Counterexample • A counterexample to x P(x) is an object c so that P(c) is false. • Statements such as x (P(x) Q(x)) can be disproved by simply providing a counterexample. Statement: “All birds can fly.” Disproved by counterexample: Penguin. Applied Discrete Mathematics Week 3: Algorithms
Negation • (x P(x)) is logically equivalent to x (P(x)). • (x P(x)) is logically equivalent to x (P(x)). Applied Discrete Mathematics Week 3: Algorithms
Quantification • Introducing the universal quantifier and the existential quantifier facilitates the translation of world knowledge into predicate calculus. • Examples: • Paul beats up all professors who fail him. • x([Professor(x) Fails(x, Paul)] BeatsUp(Paul, x)) • All computer scientists are either rich or crazy, but not both. • x (CS(x) [Rich(x) Crazy(x)] [Rich(x) Crazy(x)] ) • Or, using XOR: • x (CS(x) [Rich(x) Crazy(x)]) Applied Discrete Mathematics Week 3: Algorithms
More Practice for Predicate Logic • Important points: • Define propositional functions in a useful and reusable manner, just like functions in a computer program. • Make sure your formalized statement evaluates to “true” in the context of the original statement and evaluates to “false” whenever the original statement is violated. Applied Discrete Mathematics Week 3: Algorithms
More Practice for Predicate Logic • More Examples: • Jenny likes all movies that Peter likes (and possibly more). • x [Movie(x) Likes(Peter, x) Likes(Jenny, x)] • There is exactly one UMass professor who won a Nobel prize • x[UMBProf(x) Wins(x, NobelPrize)] y,z[y z UMBProf(y) UMBProf(z) Wins(y, NobelPrize) Wins(z, NobelPrize)] Applied Discrete Mathematics Week 3: Algorithms
Let us get into… • Number Theory Applied Discrete Mathematics Week 3: Algorithms
Introduction to Number Theory • Number theory is about integers and their properties. • We will start with the basic principles of • divisibility, • greatest common divisors, • least common multiples, and • modular arithmetic • and look at some relevant algorithms. Applied Discrete Mathematics Week 3: Algorithms
Division • If a and b are integers with a 0, we say that a divides b if there is an integer c so that b = ac. • When a divides b we say that a is a factor of b and that b is a multiple of a. • The notation a | b means that a divides b. • We write a X b when a does not divide b. • (see book for correct symbol). Applied Discrete Mathematics Week 3: Algorithms
Divisibility Theorems • For integers a, b, and c it is true that • if a | b and a | c, then a | (b + c) • Example: 3 | 6 and 3 | 9, so 3 | 15. • if a | b, then a | bc for all integers c • Example: 5 | 10, so 5 | 20, 5 | 30, 5 | 40, … • if a | b and b | c, then a | c • Example: 4 | 8 and 8 | 24, so 4 | 24. Applied Discrete Mathematics Week 3: Algorithms
Primes • A positive integer p greater than 1 is called prime if the only positive factors of p are 1 and p. • A positive integer that is greater than 1 and is not prime is called composite. • The fundamental theorem of arithmetic: • Every positive integer can be written uniquely as the product of primes, where the prime factors are written in order of increasing size. Applied Discrete Mathematics Week 3: Algorithms
Primes 15 = 3·5 • Examples: 48 = 2·2·2·2·3 = 24·3 17 = 17 100 = 2·2·5·5 = 22·52 512 = 2·2·2·2·2·2·2·2·2 = 29 515 = 5·103 28 = 2·2·7 = 22·7 Applied Discrete Mathematics Week 3: Algorithms
Primes • If n is a composite integer, then n has a prime divisor less than or equal . • This is easy to see: if n is a composite integer, it must have two divisors p1 and p2 such that p1p2 = n and p1 2 and p2 2. • p1 and p2 cannot both be greater than • , because then p1p2 would be greater than n. • If the smaller number of p1 and p2 is not a prime itself, then it can be broken up into prime factors that are smaller than itself but 2. Applied Discrete Mathematics Week 3: Algorithms
The Division Algorithm • Let a be an integer and d a positive integer. • Then there are unique integers q and r, with 0 r < d, such that a = dq + r. • In the above equation, • d is called the divisor, • a is called the dividend, • q is called the quotient, and • r is called the remainder. Applied Discrete Mathematics Week 3: Algorithms
The Division Algorithm • Example: • When we divide 17 by 5, we have • 17 = 53 + 2. • 17 is the dividend, • 5 is the divisor, • 3 is called the quotient, and • 2 is called the remainder. Applied Discrete Mathematics Week 3: Algorithms
The Division Algorithm • Another example: • What happens when we divide -11 by 3 ? • Note that the remainder cannot be negative. • -11 = 3(-4) + 1. • -11 is the dividend, • 3 is the divisor, • -4 is called the quotient, and • 1 is called the remainder. Applied Discrete Mathematics Week 3: Algorithms
Greatest Common Divisors • Let a and b be integers, not both zero. • The largest integer d such that d | a and d | b is called the greatest common divisor of a and b. • The greatest common divisor of a and b is denoted by gcd(a, b). • Example 1: What is gcd(48, 72) ? • The positive common divisors of 48 and 72 are 1, 2, 3, 4, 6, 8, 12, 16, and 24, so gcd(48, 72) = 24. • Example 2: What is gcd(19, 72) ? • The only positive common divisor of 19 and 72 is1, so gcd(19, 72) = 1. Applied Discrete Mathematics Week 3: Algorithms
Greatest Common Divisors • Using prime factorizations: • a = p1a1 p2a2 … pnan , b = p1b1 p2b2 … pnbn , • where p1 < p2 < … < pn and ai, bi N for 1 i n • gcd(a, b) = p1min(a1, b1) p2min(a2, b2)… pnmin(an, bn) • Example: a = 60 = 22 31 51 b = 54 = 21 33 50 gcd(a, b) = 21 31 50 = 6 Applied Discrete Mathematics Week 3: Algorithms