Download presentation

Presentation is loading. Please wait.

Published byMekhi Kenfield Modified over 2 years ago

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 of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner

2
Predicate Logic III

3
Fall 2013Frank / van Deemter / Wyner2 Agenda Formal EvaluationFormal Evaluation Nested QuantifiersNested Quantifiers Quantifier equivalencesQuantifier equivalences Defining (or not) other quantifiersDefining (or not) other quantifiers

4
Fall 2013Frank / van Deemter / Wyner3 Formal Evaluation - B(bill') Suppose M1 = (D,I) where D={bill, jill, mary}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.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.Work from bottom to top.

5
Fall 2013Frank / van Deemter / Wyner4 Formal Evaluation - x B(x) Suppose M1 = (D,I) where D={bill, jill, mary}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 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?Look in the 'where' clauses. Is there some a that makes B(x)(x := a) is T in M1? Work from bottom to top.Work from bottom to top.

6
Fall 2013Frank / van Deemter / Wyner5 Formal Evaluation - x B(x) Suppose M1 = (D,I) where D={bill, jill, mary}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 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?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.Work from bottom to top.

7
Fall 2013Frank / van Deemter / Wyner6 Formal Evaluation - x (G(x) B(x)) Suppose M1 = (D,I) where D={bill, jill, mary}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 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?Are all true?

8
Fall 2013Frank / van Deemter / Wyner7 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)

9
Fall 2013Frank / van Deemter / Wyner8 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."

10
Fall 2013Frank / van Deemter / Wyner9 Formal Evaluation - x y A(x,y) Suppose M1 = (D,I) where D={bill, jill, mary}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; 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. 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.

11
Fall 2013Frank / van Deemter / Wyner10 Formal Evaluation - x y A(x,y) Suppose M1 = (D,I) where D={bill, jill, mary}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?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?Is one of these true?

12
Fall 2013Frank / van Deemter / Wyner11 Formal Evaluation - x y A(x,y) Suppose M1 = (D,I) where D={bill, jill, mary}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?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?Is one of these true?

13
Fall 2013Frank / van Deemter / Wyner12 Formal Evaluation - x y A(x,y) Suppose M1 = (D,I) where D={bill, jill, mary}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?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?Is one of these true?

14
Fall 2013Frank / van Deemter / Wyner13 Formal Evaluation - x y A(x,y) Suppose M1 = (D,I) where D={bill, jill, mary}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?" 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?"

15
Fall 2013Frank / van Deemter / Wyner14 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.

16
Fall 2013Frank / van Deemter / Wyner15 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?

17
Fall 2013Frank / van Deemter / Wyner16 Quantifier Exercise 1. x( y R(x,y)) Least informative 2. y( x R(x,y)) 3. x( y R(x,y)) Most informative If 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

18
Fall 2013Frank / van Deemter / Wyner17 Natural language is ambiguous "Everybody likes somebody.""Everybody likes somebody." Can mean:Can mean: –For everybody, there is somebody they like, x y Likes(x,y) x y Likes(x,y) Each to a different personEach to a different person –There is somebody whom everyone likes? y x Likes(x,y) y x Likes(x,y) Each to the same personEach to the same person

19
Fall 2013Frank / van Deemter / Wyner18 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) …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)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?Which propositional equivalence laws can be used to prove this?

20
Fall 2013Frank / van Deemter / Wyner19 More Equivalences x y P(x,y) y x P(x,y) x y P(x,y) y x P(x,y) 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)) 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φLet’s prove the last of these equivalences using the definition of the truth of a formula of the form xφ

21
Fall 2013Frank / van Deemter / Wyner20 Proving a Quantifier Equivalence x (P(x) Q(x)) ( x P(x)) ( x Q(x)) Proof: 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 is true. One possibility is that P(a) is true. In this case, P(x)(x:=a) is true. So, x P(x) 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) x P(x)) ( x Q(x)) is true. 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.

22
Fall 2013Frank / van Deemter / Wyner21 Proving a Quantifier Equivalence x (P(x) Q(x)) ( x P(x)) ( x Q(x)) Proof: ( 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, Pis 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 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

23
Fall 2013Frank / van Deemter / Wyner22 Another Equivalence Law? How about this one?How about this one? x (P(x) Q(x)) ( x P(x)) ( x Q(x))? x (P(x) Q(x)) ( x P(x)) ( x Q(x))?

24
Fall 2013Frank / van Deemter / Wyner23 Not an Equivalence Law x (P(x) Q(x)) ( x P(x)) ( x Q(x)) ? x (P(x) Q(x)) ( x P(x)) ( x Q(x)) ? This equivalence statement is false. Counterexample (i.e. model making this false):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 DecemberP(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.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.

25
Fall 2013Frank / van Deemter / Wyner24 Some consequences of these definitions Sometimes, predicate logic is taught very informallySometimes, predicate logic is taught very informally This makes it easy to understand simple formulasThis makes it easy to understand simple formulas But each more complex case has to be explained separately, as if it was an exceptionBut 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 casesBy defining things properly once, complex formulas fall out as special cases One example: quantifier nestingOne example: quantifier nesting

26
Fall 2013Frank / van Deemter / Wyner25 Theorems about logic We are studying logical languages/calculi to allow you to use them (better).We are studying logical languages/calculi to allow you to use them (better). Logicians study logical languages/calculi to understand their limitations.Logicians study logical languages/calculi to understand their limitations. Meta-theorems can say things about what can and cannot be expressed in predicate logic.Meta-theorems can say things about what can and cannot be expressed in predicate logic.

27
Fall 2013Frank / van Deemter / Wyner26 Theorems about logic About propositional logic, we asked “What types of things can we express?” How many connectives do we need?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’?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.This is a question about the expressive power of predicate logic.

28
Fall 2013Frank / van Deemter / Wyner27 Defining Other Quantifiers oneone at most oneat most one at least twoat least two exactly twoexactly two infinitely manyinfinitely many finitely manyfinitely many

29
Fall 2013Frank / van Deemter / Wyner28 Example: one As per their name, quantifiers can be used to express that a predicate is true of a given quantity (number) of objects.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”?Example: Can predicate logic say “there exists at most one object with property P”?

30
Fall 2013Frank / van Deemter / Wyner29 Example: at most one Example: Can predicate logic say “there exists at most one object with property P”?Example: Can predicate logic say “there exists at most one object with property P”? Yes (provided we have equality): Yes (provided we have equality): x y (( P(x) P(y)) x = y ) x y (( P(x) P(y)) x = y )

31
Fall 2013Frank / van Deemter / Wyner30 Example: one Can predicate logic say “there exists exactly one object with property P”?Can predicate logic say “there exists exactly one object with property P”?

32
Fall 2013Frank / van Deemter / Wyner31 Example: one Can predicate logic say “there exists exactly one object with property P”? xP(x) x y (( P(x) P(y)) x= y)Can predicate logic say “there exists exactly one object with property P”? xP(x) x y (( P(x) P(y)) x= y) “There exist x such that P(x)” and “There exists at most one x such that P(x)”“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)”)Abbreviation: !x P(x) (“there exists exactly one x such that P(x)”)

33
Fall 2013Frank / van Deemter / Wyner32 Example: one Another way to write this: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 ( 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 ) ) x binds x throughout the conjunction: x ( P(x) y ( P(y) y x ) )

34
Fall 2013Frank / van Deemter / Wyner33 At least two Can predicate logic say “there exist at least two objects with property P”?Can predicate logic say “there exist at least two objects with property P”?

35
Fall 2013Frank / van Deemter / Wyner34 At least two Can predicate logic say “there exist at least two objects with property P”?Can predicate logic say “there exist at least two objects with property P”? Yes: x y ( (P(x) P(y)) x y )Yes: x y ( (P(x) P(y)) x y ) Incorrect would be xP(x) y(P(y) x y), (where x occurs free, and which therefore does not express a proposition)Incorrect would be xP(x) y(P(y) x y), (where x occurs free, and which therefore does not express a proposition)

36
Fall 2013Frank / van Deemter / Wyner35 Exactly two Can predicate logic say “there exist exactly two objects with property P”?Can predicate logic say “there exist exactly two objects with property P”?

37
Fall 2013Frank / van Deemter / Wyner36 Exactly two Can predicate logic say “there exist exactly two objects with property P”?Can predicate logic say “there exist exactly two objects with property P”? Yes:Yes: x y ( P(x) P(y) x y z ( P(z) (z = x z = y) ) ) x y ( P(x) P(y) x y z ( P(z) (z = x z = y) ) )

38
Fall 2013Frank / van Deemter / Wyner37 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’? x y (P(x) P(y) x y) z ( P(z) (z= x z= y ) ) as a formalisation of ‘exactly two’?

39
Fall 2013Frank / van Deemter / Wyner38 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’? 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 propositionThis is a conjunction of two separate propositions. As a result, x and y are not bound, so this is not even a proposition

40
Fall 2013Frank / van Deemter / Wyner39 What Cannot be Expressed in Predicate Logic: Infinitely Many Can predicate logic say “there exist infinitely many objects with property P”?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”]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?How about finitely many?

41
Fall 2013Frank / van Deemter / Wyner40 What Cannot be Expressed in Predicate Logic: Finitely Many How about finitely many?How about finitely many? Suppose there existed a formula = “there exist only finitely many x such that so and so”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”Then = “there exist infinitely many x such that so and so” We know that such a formula does not existWe know that such a formula does not exist So, also does not existSo, also does not exist

42
Fall 2013Frank / van Deemter / Wyner41 Another Way to Infinity If we allow infinitely long disjunctions then all this can be expressed: If we allow infinitely long disjunctions then all this can be expressed: !x P(x) 2!x P(x) 3!x P(x) …

43
Fall 2013Frank / van Deemter / Wyner42 Remember In propositional logic, we can strictly speaking only build formulas of finite size.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.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 PBut this way, we could never say that all natural numbers have P

44
Fall 2013Frank / van Deemter / Wyner43 What Cannot be Expressed in Predicate Logic: Most, Many Can predicate logic say “most objects have property P”?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.]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”?Can predicate logic say “many objects have property P”? No, only precisely defined quantitiesNo, only precisely defined quantities

45
Fall 2013Frank / van Deemter / Wyner44 Formulas of Infinite Length? In predicate logic, you can say this easily: xP(x)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.It’s sometimes useful to pretend that propositional logic allows infinitely long formulas, but in the “official” version this is not possible.

46
Fall 2013Frank / van Deemter / Wyner45 Decidability We’ve shown you two ways of checking propositional logic equivalencies:We’ve shown you two ways of checking propositional logic equivalencies: 1.Checking truth tables 2.Using equivalence laws You’ve seen how (1) can be done algorithmically (consider the T-tables and semantic evaluation).You’ve seen how (1) can be done algorithmically (consider the T-tables and semantic evaluation). This shows that checking propositional logic equivalence is decidableThis 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 decidableBut, predicate logic has variables over (potentially) infinite domains and combinations of quantifiers, so checking predicate logic equivalence is not decidable

47
Fall 2013Frank / van Deemter / Wyner46 Decidability Checking proplog equivalence is decidableChecking proplog equivalence is decidable Checking predlog equivalence is not decidable. Therefore, theorem proving will always remain an art (for both computers and humans)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: PROLOGSome “fragments” of predlog are decidable. One application: PROLOG

48
Fall 2013Frank / van Deemter / Wyner47 Bonus Topic: Logic Programming Some programming languages are based entirely on (a part of) predicate logicSome programming languages are based entirely on (a part of) predicate logic The most famous one is called Prolog.The most famous one is called Prolog. A Prolog program is a set of propositions (“facts”) and (“rules”) in predicate logic.A Prolog program is a set of propositions (“facts”) and (“rules”) in predicate logic. The input to the program is a “query” proposition.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.The Prolog interpreter does some automated deduction to determine whether the query follows from the facts.

49
Fall 2013Frank / van Deemter / Wyner48 Facts in Prolog A fact in Prolog represents a simple, non- compound proposition in predicate logic.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.

50
Fall 2013Frank / van Deemter / Wyner49 Rules in Prolog A rule in Prolog represents a universally quantified proposition of the general form x y (P(x,y) → Q(x)), where x and y are variables, P a possibly compound predicate, and Q an atomic proposition.A rule in Prolog represents a universally quantified proposition of the general form x y (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).In Prolog: q(X) :- p(X,Y). i.e., the , quantifiers are implicit. Example: likable(X) :- likes(Y,X).Example: likable(X) :- likes(Y,X).

51
Fall 2013Frank / van Deemter / Wyner50 Rules in Prolog Note that x y (P(x,y)→Q(x)) is equivalent to x(( y P(x,y)→Q(x))Note that x y (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)In other words, Q(x) holds if you can find a y such that P(x,y)

52
Fall 2013Frank / van Deemter / Wyner51 Conjunction and Disjunction Logical conjunction is encoded using multiple comma-separated terms in a rule.Logical conjunction is encoded using multiple comma-separated terms in a rule. Logical disjunction is encoded using multiple rules.Logical disjunction is encoded using multiple rules. E.g., x ((P(x) Q(x)) R(x))→S(x) can be rendered in Prolog as: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)

53
Fall 2013Frank / van Deemter / Wyner52 Deduction in Prolog When a query is input to the Prolog interpreter,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.

54
Fall 2013Frank / van Deemter / Wyner53 Simple Prolog Example An example input program:An example input program:likes(john,mary).likes(mary,fred).likes(fred,mary). likable(X) :- likes(Y,X). An example query: ? likable(Z) returns:...An example query: ? likable(Z) returns:...

55
Fall 2013Frank / van Deemter / Wyner54 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

56
Fall 2013Frank / van Deemter / Wyner55 Relation between PROLOG and Predicate Logic PROLOG cannot use all predicate logic formulas. (It covers a decidable “fragment” of predicate logic.)PROLOG cannot use all predicate logic formulas. (It covers a decidable “fragment” of predicate logic.) It uses ‘negation as failure’It uses ‘negation as failure’ Based on these limitations, PROLOG-based deduction is decidable.Based on these limitations, PROLOG-based deduction is decidable. PROLOG is more than just logic (I/O, cut!), but logic is its hard core.PROLOG is more than just logic (I/O, cut!), but logic is its hard core.

57
Fall 2013Frank / van Deemter / Wyner56 Relation between PROLOG and Predicate Logic PROLOG cannot use all predicate logic formulas. (It covers a decidable “fragment” of predicate logic.)PROLOG cannot use all predicate logic formulas. (It covers a decidable “fragment” of predicate logic.) It uses ‘negation as failure’It uses ‘negation as failure’ Based on these limitations, PROLOG-based deduction is decidable.Based on these limitations, PROLOG-based deduction is decidable. PROLOG is more than just logic (I/O, cut!), but logic is its hard core.PROLOG is more than just logic (I/O, cut!), but logic is its hard core.

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google