csci 2110 discrete mathematics tutorial 10

38
CSCI 2110 Discrete Mathematics Tutorial 10 Chin 1

Upload: teigra

Post on 06-Feb-2016

36 views

Category:

Documents


0 download

DESCRIPTION

CSCI 2110 Discrete Mathematics Tutorial 10. Chin. About me. Name: Chin Office: SHB 117 Email: [email protected] Office Hour: Friday 10:00 – 12:00 Outside office hour? Email me first. Proposition. A statement that can be true or false, but not both Examples I hate discrete maths - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CSCI 2110 Discrete Mathematics  Tutorial  10

1

CSCI 2110 Discrete Mathematics Tutorial 10

Chin

Page 2: CSCI 2110 Discrete Mathematics  Tutorial  10

2

About me

• Name: Chin• Office: SHB 117• Email: [email protected]• Office Hour: Friday 10:00 – 12:00– Outside office hour? Email me first

Page 3: CSCI 2110 Discrete Mathematics  Tutorial  10

3

Proposition

• A statement that can be true or false, but not both

• Examples– I hate discrete maths– The quizzes are difficult– 1 + 1 = 3– All primes are odd– No one likes this tutorial

Page 4: CSCI 2110 Discrete Mathematics  Tutorial  10

4

Predicate

• A function that maps elements from a domain to {true, false}

• A claim with variables• Examples– ocamp(x) := x went to ocamp– attend(y) := y attends 2110 lecture– odd(a, b) := a is odd and b is odd– compare(x, y) := x < y– female(p) := p is female

Page 5: CSCI 2110 Discrete Mathematics  Tutorial  10

5

Domain of a predicate

• A set that contains the values a variable can take

• attend(y) := y attends 2110 lecture• Domain can be the set of 2110 students– then attend(Chin) is undefined (neither true, nor false)– because Chin is not in the domain

• Sometimes, we omit the domain when the context is clear

Page 6: CSCI 2110 Discrete Mathematics  Tutorial  10

6

Quantifiers

• for ∀ll, – for any, for every, for each, given any, …– P(x) := x goes to tutorial– ∀x, P(x)

• there ∃xists, – (for) some, at least one, (for) one, …– P(x) := x teaches tutorial– ∃x, P(x)

Page 7: CSCI 2110 Discrete Mathematics  Tutorial  10

7

Domain is important

• Let P be a predicate from the domain D– P(x) := x loves discrete maths

• Is it true that ∀x ∈ D, P(x)?

• When D is the set of– 2110 tutors, yes– 2110 students, no

Page 8: CSCI 2110 Discrete Mathematics  Tutorial  10

8

Negation

• De Morgan’s laws for first order logic:

• ¬(∀x, P(x)) is equivalent to ∃x, ¬P(x)

• ¬(∃x, P(x)) is equivalent to ∀x, ¬P(x)

Page 9: CSCI 2110 Discrete Mathematics  Tutorial  10

9

De Morgan’s laws

• Let P(x) := x is female• ∀x, P(x) means everyone is female

• Which one is its negation, i.e. ¬(∀x, P(x)) ?– No one is female, i.e. ¬(∃x, P(x))– Everyone is not female, i.e. (∀x, ¬P(x))– Someone is female, i.e. ∃x, P(x)– Someone is not female, i.e. ∃x, ¬P(x)

Page 10: CSCI 2110 Discrete Mathematics  Tutorial  10

10

Express the following using predicates

• Every one goes to lectures

• Let attend(x) := x goes to lectures• ∀x, attend(x)

• What is its negation?

Page 11: CSCI 2110 Discrete Mathematics  Tutorial  10

11

More quantifiers

• Every one goes to some lectures

• Let attend(x, y) := x attend lecture y• ∀x, ∃y attend(x, y)

• What is its negation?

Page 12: CSCI 2110 Discrete Mathematics  Tutorial  10

12

More quantifiers

• What is the negation of ∀x, ∃y attend(x, y)?

• ¬(∀x, ∃y attend(x, y))• ∃x, ¬(∃y attend(x, y))• ∃x, ∀y ¬attend(x, y)

• Some students don’t attend any lectures

Page 13: CSCI 2110 Discrete Mathematics  Tutorial  10

13

Order of quantifiers are important

• Every one goes to some lectures• Let attend(x, y) := x attend lecture y

• ∀x, ∃y attend(x, y)– Everyone goes to some lectures– Alice can go to first lecture, Bob can go to the second

• ∃y, ∀x attend(x, y)– There exist some lectures that everyone attends– Everyone goes to the same lectures

Page 14: CSCI 2110 Discrete Mathematics  Tutorial  10

14

More quantifiers

• Every year, someone goes to every lecture

• attend(x, y, z) := x goes to lecture y in year z• ∀z, ∃x, ∀y attend(x, y, z)

• What is its negation?

Page 15: CSCI 2110 Discrete Mathematics  Tutorial  10

15

More quantifiers

• What is the negation of ∀z, ∃x, ∀y, attend(x, y, z)?

• ¬(∀z, ∃x, ∀y, attend(x, y, z))• ∃z, ¬(∃x, ∀y, attend(x, y, z))• ∃z, ∀x, ¬(∀y, attend(x, y, z))• ∃z, ∀x, ∃y, ¬attend(x, y, z)

• In some years, every student does not go to some lectures.

Page 16: CSCI 2110 Discrete Mathematics  Tutorial  10

16

More and more quantifiers

• For every d, there exists x and y, so that for every f, f(x) – f(y) < d

• Let P(f, x, y, d) := f(x) – f(y) < d• ∀d, ∃x, ∃y, ∀f, P(f, x, y, d)

• What is its negation?

Page 17: CSCI 2110 Discrete Mathematics  Tutorial  10

17

More and more quantifiers

• What is the negation of– ∀d, ∃x, ∃y, ∀f, P(f, x, y, d)

• ¬(∀d, ∃x, ∃y, ∀f, P(f, x, y, d))• ∃d, ¬(∃x, ∃y, ∀f, P(f, x, y, d))• ∃d, ∀x, ¬(∃y, ∀f, P(f, x, y, d))• ∃d, ∀x, ∀y, ¬(∀f, P(f, x, y, d))• ∃d, ∀x, ∀y, ∃f, ¬P(f, x, y, d)

Page 18: CSCI 2110 Discrete Mathematics  Tutorial  10

18

Statements in First Order Logic

• Every odd prime can be written as a sum of the square of two integers

• What are the predicates?– Let P(p) := p is an odd prime and can be written as a

sum of the square of two integers– ∀p, P(p). Correct, but …

• In the quiz and exam, you have to break predicates down whenever it is possible

Page 19: CSCI 2110 Discrete Mathematics  Tutorial  10

19

Mathematical Statements

• ∀p, P(p)– P(p) := p is an odd prime and can be written as a

sum of the square of two integers

• P(p) := oddprime(p) ∧ sumoftwo(p)

• Can we do more?

Page 20: CSCI 2110 Discrete Mathematics  Tutorial  10

20

Mathematical Statements

• P(p) := oddprime(p) ∧ sumoftwo(p)• oddprime(p) := odd(p) ∧ prime(p)– odd(p) := ∃k , ∈ℤ p = 2k + 1– prime(p) := (p > 1) ∧ (∀a ,∈ℤ ∀b , ∈ℤ ((a > 1) (∧ b > 1) → ab ≠ p))

Page 21: CSCI 2110 Discrete Mathematics  Tutorial  10

21

Mathematical Statements

• P(p) := oddprime(p) ∧ sumoftwo(p)– sumoftwo(p) := p = x2 + y2 for some integers x, y

• sumoftwo(p) := p = x2 + y2 for some integers x, y• sumoftwo(p) := ∃x , ∈ℤ ∃y , ∈ℤ p = x2 + y2

Page 22: CSCI 2110 Discrete Mathematics  Tutorial  10

22

Mathematical Statements

• P(p) := oddprime(p) ∧ sumoftwo(p)• oddprime(p) := odd(p) ∧ prime(p)– odd(p) := ∃k , ∈ℤ p = 2k + 1– prime(p) := (p > 1) ∧ (∀a ,∈ℤ ∀b , ∈ℤ ((a > 1) (∧ b > 1) → ab ≠ p))

• sumoftwo(p) := ∃x , ∈ℤ ∃y , ∈ℤ p = x2 + y2

• ∀p, P(p)

Page 23: CSCI 2110 Discrete Mathematics  Tutorial  10

23

Method of proofs

• Direct proof• Proof by contradiction• Proof by cases

Page 24: CSCI 2110 Discrete Mathematics  Tutorial  10

24

Direct Proof

• Let a be an even number and b be an odd. Show that ab is an even number

• Write a = 2s, and b = 2t + 1 for some integers s and t

• Then ab = 2s(2t + 1) = 4st + 2s = 2(2st + s)• Therefore ab is an even number because 2st+s

is an integer.

cannot use the same letter

Page 25: CSCI 2110 Discrete Mathematics  Tutorial  10

25

Proof by contradiction

• Show that if 2x + 45 < 85, then x < 20

• Suppose x ≥ 20• 2x ≥ 40• 2x + 40 ≥ 85• Contradiction!

Page 26: CSCI 2110 Discrete Mathematics  Tutorial  10

26

Proof by contradiction

• Show that 3 is not rational.

• How to say 3 is a rational number?– 3 = p/q for some integers p and q

√√

Page 27: CSCI 2110 Discrete Mathematics  Tutorial  10

27

Proof by contradiction

• 3 = p/q for some integers p and q

• We choose p and q so that have no common factors that are greater than 1.– 12/64 → 3/16– You can always reduce a fraction

• If we can show p and q have 3 as their common factor, done. But how?

Page 28: CSCI 2110 Discrete Mathematics  Tutorial  10

28

Proof by contradiction

• 3 = p/q for some integers p and q– Where p and q have no common factors that are > 1

• 3q2 = p2

• If p2 = 3s, p = 3t for some integer t– Prove by contradiction

Page 29: CSCI 2110 Discrete Mathematics  Tutorial  10

29

Proof by contradiction

• If p2 = 3s for some integer s, p = 3t for some integer t– Prove by contradiction

• Suppose p ≠ 3t for any t– Case 1: p = 3t + 1 for some t– Case 2: p = 3t + 2 for some t

Page 30: CSCI 2110 Discrete Mathematics  Tutorial  10

30

Proof by contradiction

• If p2 = 3s for some integer s, p = 3t for some integer t

• Suppose p2 = 3s for some integer s but p ≠ 3t for any t– Case 1:

p = 3t + 1, p2 = 9t2 + 6t + 1 = 3(3t2 + 2t) + 1p2 ≠ 3s for any s

– Case 2:p = 3t + 2, p2 = 9t2 + 12t + 4 = 3(3t2 + 4t + 1) + 1p2 ≠ 3s for any s

• Contradiction.

Page 31: CSCI 2110 Discrete Mathematics  Tutorial  10

31

Proof by contradiction

• 3q2 = p2

– If p2 = 3s for some integer s, p = 3t for some integer t

• p = 3t for some integer t

• 3q2 = p2 = 9t– q2 = 3t– If p2 = 3t for some integer t, p = 3u for some

integer u• q = 3u for some integer u

Page 32: CSCI 2110 Discrete Mathematics  Tutorial  10

32

Proof by contradiction

• p = 3t for some integer t• q = 3u for some integer u

• So p and q have 3 as their common factor.

• Contradiction because we begin with the fact that p and q do not have common factor > 1.

Page 33: CSCI 2110 Discrete Mathematics  Tutorial  10

33

Proof by contradiction

• Suppose 100 students took a quiz and the mean is 80 (out of 100). Show that at least 50 students score greater than 60.

• What is the negation of at least 50 students score > 60?– At most 49 students score > 60– (or at least 51 score ≤ 60)

Page 34: CSCI 2110 Discrete Mathematics  Tutorial  10

34

Proof by contradiction

• What is the highest mean we can get?• The 49 students who score > 60 get 100• The rest of the 51 students who score ≤ 60 get 60

• Then the mean is (# people who score 100) × 100 + (# people who score 60) × 60

= (49 × 100 + 51 × 60) / 100= (4900 + 3060) / 100= 79.6 < 80• Contradiction!

(total number of students)

Page 35: CSCI 2110 Discrete Mathematics  Tutorial  10

35

Proof by cases

• Prove that max(x, y) + min(x, y) = x + y.

• If y > x– max(x, y) = y and min(x, y) = x– max(x, y) + min(x, y) = y + x = x + y

• If y ≤ x– max(x, y) = x and min(x, y) = y– max(x, y) + min(x, y) = x + y

• done, since either x < y or y <= x must be true.

Page 36: CSCI 2110 Discrete Mathematics  Tutorial  10

36

Proof by cases

• Suppose x > 0 and y > 0.• Prove that (|x + y| - |x – y|)/2 = min(x, y)

• If x > y– min(x, y) = y– |x + y| = x + y , |x – y| = x – y– |x + y| - |x – y| = (x + y) – (x – y) = 2y– (|x + y| - |x – y|)/2 = y = min(x, y)

Page 37: CSCI 2110 Discrete Mathematics  Tutorial  10

37

Proof by cases

• Suppose x > 0 and y > 0.• Prove that (|x + y| - |x – y|)/2 = min(x, y)

• If x ≤ y– min(x, y) = x– |x + y| = x + y , |x – y| = y – x– (because |a| = -a if a ≤ 0, and (x – y) ≤ 0)– |x + y| - |x – y| = (x + y) – (y – x) = 2x– (|x + y| - |x – y|)/2 = x = min(x, y)

Page 38: CSCI 2110 Discrete Mathematics  Tutorial  10

38

End

• Questions?