Top Banner
Slides adapted from Michael P. Frank's course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner
57

Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Apr 01, 2015

Download

Documents

Mekhi Kenfield
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Slides adapted fromMichael P. Frank's course based on the textDiscrete Mathematics & Its Applications

(5th Edition)by Kenneth H. Rosen

University of Aberdeen, Computing Science

CS2013Mathematics for Computing

ScienceAdam Wyner

Page 2: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Predicate Logic III

Page 3: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 3

Agenda

• Formal Evaluation• Nested Quantifiers• Quantifier equivalences• Defining (or not) other quantifiers

Page 4: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 4

Formal Evaluation - B(bill')

• Suppose M1 = (D,I) where D={bill, jill, mary}

I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill}I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)}

• B(bill') is T in M1 iff I(bill') I(B) is T in M1 iff bill {bill, jill} is T in M1.

• Work from bottom to top.

Page 5: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 5

Formal Evaluation - x B(x)

• Suppose M1 = (D,I) where D={bill, jill, mary}

I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill}I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)}

• x B(x) is T in M1 iff there is an a where I(a) D such that B(x)(x := a) is T in M1– where (x := bill'), B(x) is B(bill'). B(bill') is T in M1 iff....– where (x := jill'), B(x) is B(jill'). B(jill') is T in M1 iff....– where (x := mary'), B(x) is B(mary'). B(mary') is T in M1 iff....

• Look in the 'where' clauses. Is there some a that makes B(x)(x := a) is T in M1?

• Work from bottom to top.

Page 6: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 6

Formal Evaluation - x B(x)

• Suppose M1 = (D,I) where D={bill, jill, mary}

I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill}I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)}

• x B(x) is T in M1 iff for every a where I(a) D, B(x)(x := a) is T in M1– where (x := bill'), B(x) is B(bill'). B(bill') is T in M1 iff....– where (x := jill'), B(x) is B(jill'). B(jill') is T in M1 iff....– where (x := mary'), B(x) is B(mary'). B(mary') is T in M1 iff....

• Look in the 'where' clauses. Is it so that for every a, B(x)(x := a) is T in M1?

• Work from bottom to top.

Page 7: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 7

Formal Evaluation - x (G(x) B(x))

• Suppose M1 = (D,I) where D={bill, jill, mary}

I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill}I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)}

• x (G(x) B(x)) is T in M1 iff for every a where I(a) D, (G(x) B(x))(x := a) is T in M1– where (x:=bill'), (G(x) B(x)) is (G(bill') B(bill')); (G(bill')

B(bill')) is T in M1 iff G(bill') is F in M1 or B(bill') is T in M1.– where (x:=jill'), (G(x) B(x)) is (G(jill') B(jill')); (G(jill')

B(jill')) is T in M1 iff G(jill') is F in M1 or B(jill') is T in M1.– where (x:=mary'), (G(x) B(x)) is (G(jill') B(jill')); (G(jill')

B(jill')) is T in M1 iff G(jill') is F in M1 or B(jill') is T in M1.• Are all true?

Page 8: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 8

Nested Quantifiers

Example: Let D for x and y be people.

Let L(x,y) = x likes y (a predicate with 2 free variables)

y L(x,y) = "There is someone whom x likes" = "x likes someone". (A predicate with 1 free variable, x)

x (y L(x,y)) = "Everyone has someone whom they like" = "everyone likes someone". (A real proposition; no free variables left)

Page 9: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 9

Nested Quantifiers

Assume S(x,y) means “x sees y”

D = {bill, phil, jill, mell}

What does xS(x,bill') mean?

"For every x, x sees bill'"

In other words, "Everyone sees Bill."

Page 10: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 10

Formal Evaluation - x y A(x,y)

• Suppose M1 = (D,I) where D={bill, jill, mary}

I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill}I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)}

• x y A(x,y) is T in M1 iff for every a where I(a) D, y A(x,y)) (x:=a) is T in M1;

• y A(x,y)) (x:=a) is T in M1 iff there is some b where I(b) D such that A(x,y)) (x:=a) (x:=b) is T in M1.

Page 11: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 11

Formal Evaluation - x y A(x,y)

• Suppose M1 = (D,I) where D={bill, jill, mary}

I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill}I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)}

• A(x,y) is true where (x:=bill') and y is some constant?– where (x:=bill') (y:=bill'), A(x,y) is A(bill',bill'); A(bill',bill') is T in

M1 iff (bill, bill) I(A).– where (x:=bill') (y:=jill'), A(x,y) is A(bill',jill'); A(bill',jill') is T in

M1 iff (bill, jill) I(A).– where (x:=bill') (y:=mary'), A(x,y) is A(bill',mary'); A(bill',mary')

is T in M1 iff (bill, mary) I(A).

• Is one of these true?

Page 12: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 12

Formal Evaluation - x y A(x,y)

• Suppose M1 = (D,I) where D={bill, jill, mary}

I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill}I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)}

• A(x,y) is true where (x:=jill') and y is some constant?– where (x:=jill') (y:=bill'), A(x,y) is A(jill',bill'); A(jill',bill') is T in

M1 iff (jill, bill) I(A).– where (x:=jill') (y:=jill'), A(x,y) is A(jill',jill'); A(jill',jill') is T in

M1 iff (jill, jill) I(A).– where (x:=jill') (y:=mary'), A(x,y) is A(jill',mary'); A(jill',mary') is

T in M1 iff (jill, mary) I(A).

• Is one of these true?

Page 13: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 13

Formal Evaluation - x y A(x,y)

• Suppose M1 = (D,I) where D={bill, jill, mary}

I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill}I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)}

• A(x,y) is true where (x:=mary') and y is some constant?– where (x:=mary') (y:=bill'), A(x,y) is A(mary',bill'); A(mary',bill')

is T in M1 iff (mary, bill) I(A).– where (x:=mary') (y:=jill'), A(x,y) is A(mary',jill'); A(mary',jill') is

T in M1 iff (mary, jill) I(A).– where (x:=mary') (y:=mary'), A(x,y) is A(mary',mary');

A(mary',mary') is T in M1 iff (mary, mary) I(A).

• Is one of these true?

Page 14: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 14

Formal Evaluation - x y A(x,y)

• Suppose M1 = (D,I) where D={bill, jill, mary}

I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill}I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)}

• x y A(x,y) is true in M1 so long as we can answer T to each of the preceding questions "Is one of these true?"

Page 15: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 15

Quantifier Exercise

If R(x,y)="x relies on y" express the following:

x(y R(x,y)) = Everyone has someone to rely on.

y(x R(x,y)) = There is someone whom everyone relies on.

x(y R(x,y)) = There is someone who relies on everyone.

y(x R(x,y)) = Everyone has someone who relies on them.

x(y R(x,y)) = Everyone relies on everyone.

Page 16: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 16

Quantifier Exercise

R(x,y) = "x relies on y" where D is not empty.

1. x(y R(x,y))2. y(x R(x,y))3. x(y R(x,y))

Which of them is most informative?Which of them is least informative?

Page 17: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 17

Quantifier Exercise

1. x(y R(x,y)) Least informative2. y(x R(x,y))3. x(y R(x,y)) Most informativeIf 3 is true then 2 must also be true.If 2 is true then 1 must also be true.

We say: 3 is logically stronger than 2 than 1

Page 18: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 18

Natural language is ambiguous

• "Everybody likes somebody."• Can mean:

– For everybody, there is somebody they like,• x y Likes(x,y)• Each to a different person

– There is somebody whom everyone likes?• y x Likes(x,y)• Each to the same person

Page 19: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 19

Quantifier Equivalences

• Expanding quantifiers: If D = {a,b,c,…}x P(x) P(a) P(b) P(c) … x P(x) P(a) P(b) P(c) …

• From those, we can “prove” the laws:x P(x) x P(x)x P(x) x P(x)

• Which propositional equivalence laws can be used to prove this?

Page 20: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 20

More Equivalences

• x y P(x,y) y x P(x,y)x y P(x,y) y x P(x,y)

• x (P(x) Q(x)) (x P(x)) (x Q(x))x (P(x) Q(x)) (x P(x)) (x Q(x))

• Let’s prove the last of these equivalences using the definition of the truth of a formula of the form xφ

Page 21: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 21

Proving a Quantifier Equivalence

• x (P(x) Q(x)) (x P(x)) (x Q(x))Proof: Suppose x (P(x) Q(x)) is true. So, there is a constant a such that (P(x) Q(x)) (x:=a) is true. So, for that a, the formula P(a) Q(a) is true. One possibility is that P(a) is true. In this case, P(x)(x:=a) is true. So, x P(x) is true, so (x P(x)) (x Q(x)) is true. The other possibility is that Q(a) is true. In this case, Q(x)(x:=a) is true. So, x Q(x) is true, so (x P(x)) (x Q(x))is true.

Page 22: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 22

Proving a Quantifier Equivalence

• x (P(x) Q(x)) (x P(x)) (x Q(x))Proof: Suppose (x P(x)) (x Q(x)) is true. One possibility is that x P(x) is true. This would mean that there is an a such that P(x) (x:=a) is true. So, for that constant a, P(a) is true.Therefore, P(a) Q(a) would also be true. Hence, (P(x) Q(x))(x:=a) would be true. Hence, x (P(x) Q(x)) would be true. The other possibility is that x Q(x). From this, x (P(x) Q(x)) is proven in the same way QED

Page 23: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 23

Another Equivalence Law?

• How about this one?

x (P(x) Q(x)) (x P(x)) (x Q(x))?

Page 24: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 24

Not an Equivalence Law

• x (P(x) Q(x)) (x P(x)) (x Q(x)) ?• This equivalence statement is false.

Counterexample (i.e. model making this false):• P(x): x’s birthday is on 30 April

Q(x): x’s birthday is on 20 December• We can pick different people for x on the right

since x in P(x) and x in Q(x) are not both bound to the same quantifier.

Page 25: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 25

Some consequences of these definitions

• Sometimes, predicate logic is taught very informally

• This makes it easy to understand simple formulas• But each more complex case has to be explained

separately, as if it was an exception• By defining things properly once, complex

formulas fall out as special cases• One example: quantifier nesting

Page 26: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 26

Theorems about logic

• We are studying logical languages/calculi to allow you to use them (better).

• Logicians study logical languages/calculi to understand their limitations.

• Meta-theorems can say things about what can and cannot be expressed in predicate logic.

Page 27: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 27

Theorems about logic

• About propositional logic, we asked “What types of things can we express?” How many connectives do we need?

• About predicate logic, logicians ask similar questions. For example, are these two quantifiers enough to be able to ‘say everything’?

• This is a question about the expressive power of predicate logic.

Page 28: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 28

Defining Other Quantifiers

• one• at most one• at least two• exactly two• infinitely many• finitely many

Page 29: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 29

Example: one

• As per their name, quantifiers can be used to express that a predicate is true of a given quantity (number) of objects.

• Example: Can predicate logic say “there exists at most one object with property P”?

Page 30: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 30

Example: at most one

• Example: Can predicate logic say “there exists at most one object with property P”?

Yes (provided we have equality):

xy ((P(x) P(y)) x = y)

Page 31: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 31

Example: one

• Can predicate logic say “there exists exactly one object with property P”?

Page 32: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 32

Example: one

• Can predicate logic say “there exists exactly one object with property P”?

xP(x) xy((P(x) P(y)) x= y)• “There exist x such that P(x)” and

“There exists at most one x such that P(x)”• Abbreviation: !x P(x)

(“there exists exactly one x such that P(x)”)

Page 33: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 33

Example: one

• Another way to write this:

• x (P(x) y (P(y) y x))“There is an x such that P(x), such that there is no y such that P(y) and y x.”

• x binds x throughout the conjunction:

x (P(x) y (P(y) y x))

Page 34: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 34

At least two

• Can predicate logic say “there exist at least two objects with property P”?

Page 35: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 35

At least two

• Can predicate logic say “there exist at least two objects with property P”?

• Yes:

x y ((P(x) P(y)) x y)• Incorrect would be

xP(x) y(P(y) x y),(where x occurs free, and whichtherefore does not express a proposition)

Page 36: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 36

Exactly two

• Can predicate logic say “there exist exactly two objects with property P”?

Page 37: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 37

Exactly two

• Can predicate logic say “there exist exactly two objects with property P”?

• Yes:

• x y (P(x) P(y) x y

z (P(z) (z = x z = y) ))

Page 38: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 38

What’s wrong with

• x y (P(x) P(y) x y) z (P(z) (z= x z= y ))as a formalisation of ‘exactly two’?

Page 39: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 39

What’s wrong with

• x y (P(x) P(y) x y) z (P(z) (z= x z= y ))as a formalisation of ‘exactly two’?

• This is a conjunction of two separate propositions. As a result, x and y are not bound, so this is not even a proposition

Page 40: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 40

What Cannot be Expressed in Predicate Logic: Infinitely Many

• Can predicate logic say “there exist infinitely many objects with property P”?

• No! [This follows from the so-called Compactness Theorem: “An infinite set S of formulas has a model iff every finite subset of S has a model”]

• How about finitely many?

Page 41: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 41

What Cannot be Expressed in Predicate Logic: Finitely Many

• How about finitely many?• Suppose there existed a formula =

“there exist only finitely many x such that so and so”

• Then = “there exist infinitely many x such that so and so”

• We know that such a formula does not exist• So, also does not exist

Page 42: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 42

Another Way to Infinity

If we allow infinitely long disjunctions then all this can be expressed:

!x P(x) 2!x P(x) 3!x P(x) …

Page 43: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 43

Remember

• In propositional logic, we can strictly speaking only build formulas of finite size.

• E.g., we can write P(a) P(b) P(a) P(b) P(c) P(a) P(b) P(c) P(d) , etc up to some finite length.

• But this way, we could never say that all natural numbers have P

Page 44: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 44

What Cannot be Expressed in Predicate Logic: Most, Many

• Can predicate logic say “most objects have property P”?

• No! [This follows from the Compactness Theorem as well. Again, this is unless we allow infinitely long disjunctions.]

• Can predicate logic say “many objects have property P”?

• No, only precisely defined quantities

Page 45: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 45

Formulas of Infinite Length?

• In predicate logic, you can say this easily: xP(x)

• It’s sometimes useful to pretend that propositional logic allows infinitely long formulas, but in the “official” version this is not possible.

Page 46: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 46

Decidability

• We’ve shown you two ways of checking propositional logic equivalencies:

1. Checking truth tables2. Using equivalence laws

• You’ve seen how (1) can be done algorithmically (consider the T-tables and semantic evaluation).

• This shows that checking propositional logic equivalence is decidable

• But, predicate logic has variables over (potentially) infinite domains and combinations of quantifiers, so checking predicate logic equivalence is not decidable

Page 47: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 47

Decidability

• Checking proplog equivalence is decidable• Checking predlog equivalence is not decidable.

Therefore, theorem proving will always remain an art (for both computers and humans)

• Some “fragments” of predlog are decidable. One application: PROLOG

Page 48: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 48

Bonus Topic: Logic Programming

• Some programming languages are based entirely on (a part of) predicate logic

• The most famous one is called Prolog.• A Prolog program is a set of propositions (“facts”)

and (“rules”) in predicate logic.• The input to the program is a “query” proposition.

– Want to know if it is true or false.• The Prolog interpreter does some automated

deduction to determine whether the query follows from the facts.

Page 49: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 49

Facts in Prolog

• A fact in Prolog represents a simple, non-compound proposition in predicate logic.– E.g., likes(john,mary)– Lowercase symbols are used for constants and

predicates, uppercase is used for variables.

Page 50: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 50

Rules in Prolog

• A rule in Prolog represents a universally quantified proposition of the general form

xy (P(x,y) → Q(x)),where x and y are variables, P a possibly compound predicate, and Q an atomic proposition.

• In Prolog: q(X) :- p(X,Y).i.e., the , quantifiers are implicit.

• Example: likable(X) :- likes(Y,X).

Page 51: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 51

Rules in Prolog

• Note that xy (P(x,y)→Q(x)) is equivalent to x((y P(x,y)→Q(x))

• In other words, Q(x) holds if you can find a y such that P(x,y)

Page 52: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 52

Conjunction and Disjunction

• Logical conjunction is encoded using multiple comma-separated terms in a rule.

• Logical disjunction is encoded using multiple rules.

• E.g., x ((P(x)Q(x))R(x))→S(x) can be rendered in Prolog as:s(X) :- p(X),q(X)s(X) :- r(X)

Page 53: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 53

Deduction in Prolog

• When a query is input to the Prolog interpreter, – it searches its database to determine if the query can be

proven true from the available facts.– if so, it returns “yes”, if not, “no” (! Called Negation-

as-failure)– If the query contains any variables, all values that make

the query true are printed.

Page 54: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 54

Simple Prolog Example

• An example input program:likes(john,mary).likes(mary,fred).likes(fred,mary).likable(X) :- likes(Y,X).

• An example query: ? likable(Z)returns: ...

Page 55: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 55

Simple Prolog Example

An example input program:

likes(john,mary).

likes(mary,fred).likes(fred,mary).likable(X) :- likes(Y,X).

An example query:? likable(Z)

returns:maryfred

Page 56: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 56

Relation between PROLOG and Predicate Logic

• PROLOG cannot use all predicate logic formulas. (It covers a decidable “fragment” of predicate logic.)

• It uses ‘negation as failure’• Based on these limitations, PROLOG-based

deduction is decidable.• PROLOG is more than just logic (I/O, cut!), but

logic is its hard core.

Page 57: Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.

Fall 2013 Frank / van Deemter / Wyner 57

Relation between PROLOG and Predicate Logic

• PROLOG cannot use all predicate logic formulas. (It covers a decidable “fragment” of predicate logic.)

• It uses ‘negation as failure’• Based on these limitations, PROLOG-based

deduction is decidable.• PROLOG is more than just logic (I/O, cut!), but

logic is its hard core.