33
Discrete Structures & Algorithms Predicate Logic & Proofs EECE 320 // UBC 1

Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

Discrete Structures & Algorithms

Predicate Logic & Proofs

EECE 320 // UBC

1

Page 2: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

2

Bits of wisdom

What did our brains evolve to do?

What were our brains “intelligently designed” to do?

What kind of meat did the Flying Spaghetti Monster put in our heads?

Page 3: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

3

Page 4: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

4

Not for mathematics

 Our brains did not evolve to do mathematics? (Or computer engineering, for that matter.)

 Over the past 30,000 years or so, our brains have stayed (essentially) the same.

Page 5: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

5

Our brains can perform only simple, concrete tasks.

And that’s how math should be approached!

Draw simple pictures.

Try out small examples of the problem: What happens for n=1? n=2?

Substitute concrete values for the variables: x=0, x=100, …

Page 6: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

6

Expert

Novice

Page 7: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

7

• The better the problem solver, the less brain activity is evident. The real masters show almost no brain activity!

Simple and to the point

Page 8: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

8

Terry Tao; Fields Medalist, considered to be the best problem solver in the world.

“I don’t have any magical ability…I look at the problem, and it looks like one I’ve already done. When nothing’s working out, then I think of a small trick that makes it a little better. I play with the problem, and after a while, I figure out what’s going on.”

Page 9: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

Examples - I What is the negation of the statement “If I drive

then I am sober.”

Solution: Consider this as an implication.

P: I will drive.

Q: I am sober.

The statement is of the form P -> Q. An implication is essentially (not P) or Q, and its negation would be P and (not Q). The negation of the statement, in plain English, is “I will drive and I will not be sober.” (Don’t do that!)

9

Page 10: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

Examples - II Richard is a knight or a knave. Knights always

tell the truth and only the truth; knaves always tell falsehoods and only falsehoods. Someone asks Richard, “Are you a knight?” He replies, “If I am a knight then I’ll eat my hat.” Must Richard eat his hat?

10

Page 11: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

11

Predicates

• A predicate is a propositional function.

• When the function takes a specific value (or values), it becomes a proposition and has a truth value (true or false).

Page 12: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

12

Another predicate

True for all real numbers or integers greater than 6.

As is the case with normal functions, the domain for a predicate needs to be clearly defined.

Page 13: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

13

Quantifiers • Predicates are valid over a domain, and values

from the domain change the predicate into a proposition.

• Another way to obtain a proposition from a predicate is through quantifiers that operate on the domain.

If the domain is all positive real numbers, then the proposition is always true.

For all valid x, P(x) is true.

Page 14: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

14

The universal quantifier

• The universal quantifier of a predicate P(x) is the proposition “P(x) is true for all x in the universe of discourse.”

• The universe of discourse is the domain of interest.

True if and only if P(x) is true for all x. False if there exists at least one x such that P(x) is false.

Page 15: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

15

The universal quantifier

Suppose that the domain is the set of students enrolled in EECE 320.

Page 16: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

16

The existential quantifier

• The existential quantifier of a predicate P(x) is the proposition “P(x) is true for at least one value of x in the universe of discourse.”

• The universe of discourse is the domain of interest.

True if and only if P(x) is true for at least one value of x. False if there exists no value of x such that P(x) is true.

Page 17: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

17

The existential quantifier

Suppose that the domain is the set of students enrolled in EECE 320.

Page 18: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

18

Some facts about quantifiers

• Suppose the universe of discourse is a finite set {x1, x2, ..., xn} then:

Page 19: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

19

More examples with quantifiers • L(x) = x is a lion.

• F(x) = x is a fierce creature.

• C(x) = x drinks coffee.

• Let the universe U be the set of all creatures.

Page 20: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

20

Negating quantified predicates

not (P(x) is true for all x) not the same as (P(x) is not true for any x).

For some x, P(x) is false

De Morgan’s Laws for quantifiers What would the negation of the existential quantifier yield?

Page 21: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

21

Free and bound variables

• A variable is bound if its value is known or if the variable is within the scope of some quantifier.

• A variable that is not bound is free.

• In P(x), x is free. If we consider the proposition P(b), x is bound to the value b.

• Similarly, x is bound in ∀x, P(x).

• A predicate becomes a proposition only when all variables are bound.

Page 22: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

22

Multiple variables

• Predicates need not be restricted to one variable.

• P(x, y) = “x > y” (defined over the space of all integers x and y)

• Multiple variables permit multiple quantifiers.

• ∀x(P(x,y)) is not a proposition; y is free.

• ∀x∀y(P(x,y)) is a contradiction -- always false.

• ∀x∃y(P(x,y)) is a tautology -- always true.

Page 23: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

23

Interpreting multiple quantifiers

• ∀x∀y(P(x,y)): P(x,y) is true for every combination of x and y values.

• ∃x∃y(P(x,y)): P(x,y) is true for at least one combination of x and y values.

• ∃x∀y(P(x,y)): There is at least one value of x (call it a) such that P(a,y) is true for all values of y.

Start with the outermost (left-most) quantifier and work inwards.

Page 24: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

Methods of Proof

Page 25: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

25

Rules of inference

Page 26: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

26

Fallacies

• How proofs can go wrong!

• Example: Affirming the conclusion.

• If I am Katarina Witt then I skate fast.

• I skate fast.

• Therefore: I am Katarina Witt.

• Example: Denying the hypothesis.

• If it rains then it is cloudy.

• It is not raining.

• Therefore: It is not cloudy.

Page 27: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

27

Methods of Proof - 1

• Vacuous proof

• To show that “P implies Q” is true, it is sufficient to show that P is always false.

• P: Elephants are small.

• Q: Global warming is man-made.

• Trivial proof

• To show that “P implies Q” is true, it is sufficient to show that Q is always true.

• P: Elephants are small.

• Q: The Earth is not flat.

Page 28: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

28

Methods of Proof - 2

• Direct proof

• To show that “P implies Q” is true, assume that P is true and use the inference rules to show that Q is true.

• Common method of proof.

• Example: If n ≡ 3 mod 4 then n2 ≡ 1 mod 4.

Page 29: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

29

Methods of Proof - 3

• Indirect proof

• To show that “P implies Q”, we can show that the equivalent statement “not Q implies not P” is true.

• Proof by contradiction

• To prove that P is true, it is sufficient to prove that “not P implies Q” when Q is clearly false. (Similar to the disjunctive syllogism.)

• Example: Prove that √2 is irrational.

Page 30: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

30

Methods of Proof - 4

• Proof by cases

Page 31: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

31

Methods of Proof - 5

• Constructive and non-constructive proofs

• Constructive proof: To show that ∃x(P(x)) we can find x such that P(x) is true.

• Example: For any n (natural number), show that there exist n consecutive composite numbers.

• Non-constructive proof: We may be able to show that ∃x(P(x)) even without finding a specific x.

• Example: For any natural number n, show that there exists a prime number p such that p > n.

Page 32: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier

32

Wrap up

• Predicate logic • Quantifiers • Multiple variables

• Rules of inference • Methods of proof • Fallacies (beware!) • Various proof techniques

Page 33: Predicate Logic & Proofs - University of British …courses.ece.ubc.ca › 320 › lectures › 3-PredicateLogic+Proofs.pdfThe existential quantifier • The existential quantifier