1 / 145

University of Aberdeen, Computing Science CS3511 Discrete Methods Kees van Deemter

University of Aberdeen, Computing Science CS3511 Discrete Methods Kees van Deemter. Slides adapted from Michael P. Frank’s Course Based on the Text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen. Module #1: Part 2: Predicate Logic.

Download Presentation

University of Aberdeen, Computing Science CS3511 Discrete Methods Kees van Deemter

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. University of Aberdeen, Computing ScienceCS3511Discrete MethodsKees van Deemter Slides adapted from Michael P. Frank’s Course Based on the TextDiscrete Mathematics & Its Applications(5th Edition)by Kenneth H. Rosen Michael Frank / Kees van Deemter

  2. Module #1:Part 2: Predicate Logic Rosen 5th ed., §§1.3-1.4 (but much extended) ~135 slides, ~5 lectures Michael Frank / Kees van Deemter

  3. Topic #3 – Predicate Logic Predicate Logic (§1.3) • We can use propositional logic to prove that certain real-life inferences are valid. • If it’s cold then it snows. • If it snows there are accidents • There are no accidents. Therefore: • It’s not cold • In propositional logic: ((cs sa a) c) is a tautology Michael Frank / Kees van Deemter

  4. Topic #3 – Predicate Logic Predicate Logic (§1.3) • In propositional logic: (((cs) (sa) a) c) is a tautology • Saying this differently,It follows by propositional logic from(cs) (sa) a (premisse) that c (conclusion) Michael Frank / Kees van Deemter

  5. Topic #3 – Predicate Logic Predicate Logic (§1.3) • But other valid inferences cannot be proven valid by propositional logic • Some girl is adored by everyone. Therefore: • Everyone adores someone • For inferences like this, we need a more expressive logic • Needed: treatment of `some’ and `every’(a bit analogous to `or’ and `and’) Michael Frank / Kees van Deemter

  6. Topic #3 – Predicate Logic Predicate Logic (§1.3) • Predicate logic is an extension of propositional logic that permits quantification over classes of entities. • Propositional logic (recall) treats simple propositions (sentences) as atomic entities. • In contrast, predicate logic distinguishes the subject of a sentence from its predicate. Michael Frank / Kees van Deemter

  7. Topic #3 – Predicate Logic Applications of Predicate Logic It is one of the most-used formal notations for writing mathematical definitions, axioms, and theorems. For example, in linear algebra, a partial order is introduced saying that a relation R is reflexive and transitive – and these notions are defined using predicate logic. Michael Frank / Kees van Deemter

  8. Topic #3 – Predicate Logic Practical Applications of Predicate Logic • Basis for many Artificial Intelligence systems. • E.g. automatic program verification systems. • Predicate-logic like statements are supported by some of the more sophisticated database query engines • There are also limitations associated with using predicate logic. – More about that later Michael Frank / Kees van Deemter

  9. Topic #3 – Predicate Logic First: A bit of grammar • In the sentence “The dog is sleeping”: • The phrase “the dog” denotes the subject - which the sentence is about. • The phrase “is sleeping” denotes the predicate- a property that is true of the subject. • Predicate logic will follow the same pattern. Michael Frank / Kees van Deemter

  10. Topic #3 – Predicate Logic Formulas of predicate logic (informal) • We will usevarious kinds of individual constants thatdenote individuals/objects: a,b,c,… Constants are a bit like names • Individual variables over objects: x, y, z, … • The result ofapplying a predicate P to aconstant a is the propositionP(a)Meaning: the object denoted by a has the property denoted by P. Michael Frank / Kees van Deemter

  11. Topic #3 – Predicate Logic Formulas of predicate logic (informal) • The result ofapplying a predicate P to avariable x is the propositional form P(x). • E.g. if P = “is a prime number”, then P(x) is the propositionalform“x is a prime number”. Michael Frank / Kees van Deemter

  12. Topic #3 – Predicate Logic Predicates/relations with n places • Predicate logic generalises the notion of a predicate to include propositional functions of any number of arguments. E.g.: R(x,y) = “x adores y” P(x,y,z) = “x gave y the grade z” Q(x,y,z,u)= “ x*(y+z)=u ” Michael Frank / Kees van Deemter

  13. Topic #3 – Predicate Logic Universes of Discourse (U.D.s) • Predicate Logic lets you state things about many objects at once. • E.g., let P(x) = “ (x*2)  x ”. We can then say,“For any number x, P(x) is true” instead of(0*2 0)  (1*2 1) (2*2 2) ... • The collection of values that a variable x can take is called x’s universe of discourse.(u.d. is something outside the formula that helps giving it its intended interpretation.) Michael Frank / Kees van Deemter

  14. Topic #3 – Predicate Logic Universes of Discourse (U.D.s) • E.g., let P(x)=“x*2  x”. We can then say,“For any number x, P(x) is true” instead of(0*2 0)  (1*2 1) (2*2 2) ... • Applying the notion of an u.d.: • “For any number x, P(x) is true” is truewhen u.d. = N • “For any number x, P(x) is true” is falsewhen u.d. = Z Michael Frank / Kees van Deemter

  15. Back to propositional logic • In propositional logic, we could not simply say whether a formula is TRUE; what we could say is whether it is TRUE with respect to a given assignment of TRUE/FALSE to the Atoms in the formula • E.g., pq is TRUE with respect to the assignment p=TRUE, q=TRUE Michael Frank / Kees van Deemter

  16. Predicate logic • In predicate logic, we say that a formula is TRUE (FALSE) with respect to a model • Model = u.d. plus specification of the “meanings” of the predicates. This can be done e.g. • by giving an English equivalent of a predicate • by listing explicitly which objects the predicate is true of • ... as long the extension of the predicate is clear.(By definition, this is the set of objects in the u.d. for which the predicate holds.) Michael Frank / Kees van Deemter

  17. Topic #3 – Predicate Logic Quantifier Expressions • Quantifiers provide a notation that allows us to quantify (count) how many objects in the u.d. satisfy a given predicate. • “” is the FORLL or universal quantifier.“” is the XISTS or existential quantifier. • For example, xP(x) and x P(x) are propositions Michael Frank / Kees van Deemter

  18. Topic #3 – Predicate Logic Meaning of Quantified Expressions First, informally: • xP(x) means for all x in the u.d., P holds. • x P(x) means there exist x in the u.d. (that is, 1 or more) such thatP(x) is true. Michael Frank / Kees van Deemter

  19. Topic #3 – Predicate Logic Example:  Let the u.d. be the parking spaces at UF.Let P(x) mean “x is full.”Then the existential quantification of P(x), xP(x), is the proposition saying that • “Some parking spaces at UF are full.” • “There is a parking space at UF that is full.” • “At least one parking space at UF is full.” Michael Frank / Kees van Deemter

  20. Topic #3 – Predicate Logic Example:  Let the u.d. be parking spaces at UF.Let P(x) be the prop. form “x is occupied”Then the universal quantification of P(x), xP(x), is the proposition: • “All parking spaces at UF are occupied.” • “For each parking space at UF, that space is full.” Michael Frank / Kees van Deemter

  21. Syntax of predicate logic (for 1- and 2-place predicates) • Variable: x,y,z,… Constants: a,b,c,… • 1-place predicates: P,Q,… • 2-place predicates: R,S,… • Atomic formulas: If  is a 1-pace predicate and  a variable or constant then () is an atomic formula. If  is a 2-pace predicate and  and  are variables or constants then (,) is an atomic formula. Michael Frank / Kees van Deemter

  22. Syntax of predicate logic (for 1- and 2-place predicates) (Wellformed) Formulas: • All atomic formulas are formulas • If  and  are formulas then , ( ), (), ( ) are formulas. • If  is a formula then x and x are formulas. (Likewise, y and y,and so on.) This could be seen as “overgenerating” wellformed formulas somewhat Michael Frank / Kees van Deemter

  23. Syntax of predicate logic (for 1- and 2-place predicates) Show that these are wellformed formulas: xP(x) yQ(x) xy R(x,y) xP(b) Michael Frank / Kees van Deemter

  24. Syntax of predicate logic (for 1- and 2-place predicates) xP(x) yQ(x) xy R(x,y) xP(b) • P(x) is a (atomic) formula, hence xP(x) is a formula • Q(x) is a (atomic) formula, hence yQ(x) is a formula • R(x,y) is a (atomic) formula, hence y R(x,y) is a formula, hence xy R(x,y) is a formula • P(b) is a (atomic) formula, hence xP(b) is a formula Michael Frank / Kees van Deemter

  25. Syntax of predicate logic (for 1- and 2-place predicates) • Examples: xP(x) and yQ(x),x(y R(x,y)), x(x R(x,y)),xP(b)etc. • Lots of pathological cases. For example, • It will follow from the meaning of these formulas thatxP(b)is true iff P(b) is true • Rule of thumb: a quantifier that does not bind any variables can be ignored Michael Frank / Kees van Deemter

  26. Topic #3 – Predicate Logic Free and Bound Variables • An expression like P(x) is said to have a free variablex (i.e., x is not “defined”). • A quantifier (either  or ) operates on an expression having one or more free variables, and binds one or more of those variables, to produce an expression having one or more boundvariables. Michael Frank / Kees van Deemter

  27. Topic #3 – Predicate Logic Example of Binding • P(x,y) has 2 free variables, x and y. • xP(x,y) has 1 free variable, and one bound variable. [Which is which?] • An expression with zero free variables is a bona-fide (actual) proposition. • An expression with one or more free variables is similar to a predicate: e.g. let Q(y) = x Adore(x,y) y x Michael Frank / Kees van Deemter

  28. Topic #3 – Predicate Logic Free variables, defined formally • The free-variable occurrences in an Atom are: all the variable occurrences in that Atom • The free-variable occurrences in  are: the free-variable occurrences in  • The free-variable occurrences in ( connective ) are: the free-variable occurrences in  plus the free-variable occurrences in  • The free-variable occurrences in xand xare: the free-variable occurrences in  except for all/any occurrences of x. Michael Frank / Kees van Deemter

  29. Occurrences of variables that are not free are bound. • Test your understanding: Which (if any) variables are free in x P(x) x P(x) yQ(x) xP(b) (NB, b is a constant) x(y R(x,y)) Michael Frank / Kees van Deemter

  30. Occurrences of variables that are not free are bound. • Check your understanding: Which (if any) variables are free in x P(x) [no free variables] x P(x) [no free variables] yQ(x) [x is free] xP(b) (NB, b is a constant) [no free var.] x(y R(x,y)) [no free variables] Michael Frank / Kees van Deemter

  31. Topic #3 – Predicate Logic A more precise definition of the truth/falsity of quantified formulas • (Formulation is simplified somewhat because we assume that every object in the u.d. D has a `name` (i.e., a constant referring to it)). • First some notation: (x:=a) is the result of substituting all free occurrences of the variable x in  by the constant a Michael Frank / Kees van Deemter

  32. Topic #3 – Predicate Logic Exercise Say what (x:=a) is, if = • P(x) • R(x,y) • P(b) • x P(x) • yQ(x) Michael Frank / Kees van Deemter

  33. Topic #3 – Predicate Logic Exercise Say what (x:=a) is, if = • P(x) ..... P(a) • R(x,y) .... R(a,y) • P(b) ..... P(b) • x P(x) ...... x P(x) • yQ(x) ...... yQ(a) Michael Frank / Kees van Deemter

  34. Topic #3 – Predicate Logic A more precise definition of the truth/falsity of quantified formulas • (Formulation is simplified somewhat because we assume that every object in the u.d. has a `name` (i.e., a constant referring to it)). • Let  be a formula. Then x is true in D if at least one expression of the form (x:=a) is true in D, and false otherwise. (a can be any constant) Michael Frank / Kees van Deemter

  35. Topic #3 – Predicate Logic A more precise definition • Let  be a formula. Then x is true in D if at least one expression (x:=a) is true in D, and false otherwise. • A simple example: = P(x) P(x) is a formula, hence x P(x) is true in D if at least one expression of the form P(a) is true in D, and false otherwise. Michael Frank / Kees van Deemter

  36. Topic #3 – Predicate Logic Similarly for  • Let  be a formula. Then the propositionx is true in D if every expression of the form (x:=a) is true in D, and false otherwise. • A simple example: = P(x) P(x) is a formula, hence x P(x) is true in D if every expression P(a) is true in D, and false otherwise. Michael Frank / Kees van Deemter

  37. Topic #3 – Predicate Logic Complex formulas Example: Let the u.d. of x and y be people. Let L(x,y)=“x likes y” (a predicate w. 2 f.v.’s) Then y L(x,y) = “There is someone whom x likes.” (A predicate w. 1 free variable, x) Then x (y L(x,y)) = “Everyone has someone whom they like.” (a real proposition; no free variables left) Michael Frank / Kees van Deemter

  38. Topic #3 – Predicate Logic Consequences of Binding (work out for yourself by checking when each formula is true) • x x P(x) - x is not a free variable in x P(x), therefore the x binding isn’t used,as it were. • (xP(x))  Q(x) - The variable x is outside of the scope of the x quantifier, and is therefore free. Not a complete proposition! • (xP(x))  (x Q(x))– A complete proposition, and no superfluous quantifiers Michael Frank / Kees van Deemter

  39. Nested quantifiers Assume S(x,y) means “x sees y” u.d.=all people What does the following formula mean? xS(x,a) Michael Frank / Kees van Deemter

  40. Nested quantifiers Assume S(x,y) means “x sees y”. u.d.=all people xS(x,a) means “For every x, x sees a” In other words,“Everyone sees a” Michael Frank / Kees van Deemter

  41. Nested quantifiers What does the following formula mean? x(y S(x,y)) Michael Frank / Kees van Deemter

  42. Nested quantifiers x(y S(x,y)) means “For every x, there exists a y such that x sees y” In other words: “Everyone sees someone” Michael Frank / Kees van Deemter

  43. Topic #3 – Predicate Logic Quantifier Exercise If R(x,y)=“x relies upon y,” express the following in unambiguous English: x(y R(x,y))= y(xR(x,y))= x(y R(x,y))= y(x R(x,y))= x(y R(x,y))= Everyone has someone to rely on. There’s a poor overburdened soul whom everyone relies upon (including himself)! There’s some needy person who relies upon everybody (including himself). Everyone has someone who relies upon them. Everyone relies upon everybody, (including themselves)! Michael Frank / Kees van Deemter

  44. Topic #3 – Predicate Logic Quantifier Exercise R(x,y)=“x relies upon y”. Suppose the u.d. is not empty. Now consider these formulas: • x(y R(x,y)) • y(xR(x,y)) • x(y R(x,y)) Which of them is most informative? Which of them is least informative? Michael Frank / Kees van Deemter

  45. Topic #3 – Predicate Logic Quantifier Exercise (Recall: the u.d. is not empty. Empty u.d.’s are discussed later.) • x(y R(x,y)) Least informative • y(xR(x,y)) • 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 Michael Frank / Kees van Deemter

  46. “logically stronger than” • General:  is logically stronger than  iff • it is not possible for  to be true and  false • it is possible for  to be true and  false • E.g.  = John is older than 30,  = John is older than 20. • We write ‘iff’ for ‘if and only if’ Michael Frank / Kees van Deemter

  47. Topic #3 – Predicate Logic Natural language is ambiguous! • “Everybody likes somebody.” • For everybody, there is somebody they like, • x yLikes(x,y) • or, there is somebody (a popular person) whom everyone likes? • y xLikes(x,y) [Probably more likely.] Michael Frank / Kees van Deemter

  48. Interactions between quantifiers and connectives Let the u.d. be parking spaces at UF. Let P(x) be “x is occupied.” Let Q(x) be “x is free of charge.” • x (Q(x)  P(x)) • x (Q(x)  P(x)) • x (Q(x) P(x)) • x (Q(x)  P(x)) Michael Frank / Kees van Deemter

  49. I. Construct English paraphrases Let the u.d. be parking spaces at UF. Let P(x) be “x is occupied.” Let Q(x) be “x is free of charge.” • x (Q(x)  P(x)) • x (Q(x)  P(x)) • x (Q(x) P(x)) • x (Q(x)  P(x)) Michael Frank / Kees van Deemter

  50. I. Construct English paraphrases • x (Q(x)  P(x)) Some places are free of charge and occupied • x (Q(x)  P(x)) All places are free of charge and occupied • x (Q(x) P(x)) All places that are free of charge are occupied • x (Q(x)  P(x)) For some places x, if x is free of charge then x is occupied Michael Frank / Kees van Deemter

More Related