1 / 48

Predicate Logic

Predicate Logic. Section 1.3 & 1.4 . 1. Limitation of Propositional Logic. Consider the following reasoning All cats have tails Gouchi is a cat Therefore, Gouchi has a tail . To formalize the reasoning in this simple argument, we need a more expressive logic. 2. Outline. Introduction

zaynah
Télécharger la présentation

Predicate Logic

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. Predicate Logic Section 1.3 & 1.4 1

  2. Limitation of Propositional Logic • Consider the following reasoning • All cats have tails • Gouchi is a cat • Therefore, Gouchi has a tail. • To formalize the reasoning in this simple argument, we need a more expressive logic. 2 PREDICATE LOGIC

  3. Outline • Introduction • Predicates (Propositional functions) • Quantifiers • Universal quantification • Existential quantification • Translating sentences into predicate logic • Binding variables • Negating quantified predicate logic formulas • Nested quantification 3 PREDICATE LOGIC

  4. English Definition of “predicate” pred·i·cate/ˈpredikət/ • Noun: The part of a sentence or clause containing a verb and stating something about the subject. • Examples: • English: The Spartans trounced Iowa State. • Math: x + 1 = 5 subject subject predicate predicate PREDICATE LOGIC

  5. Propositional function • A predicate determines a propositional function, i.e., a function which is used to produce propositions • Example: • IfPdenotes the predicate “+ 1 = 5”, then P(x)denotes the propositional function “x + 1 = 5” • Notation: we write P(x) : x + 1 = 5 as a short-hand for “P(x)denotes the propositional function ‘x + 1 = 5’ ” • What are the truth values of the following propositions: • P(1) : 1 + 1 = 5 • P(2) : 2 + 1 = 5 • . . . , which is False , which is False 5 PREDICATE LOGIC

  6. Universe of Discourse • Suppose P(x) denotes “x > 5”. • Do the following have truth values? P(∞)P(Ø) P($3.00) • Can you list the values for which P(x) is true as a (possibly infinite) sequence? • Answer depends on the domainof consideration: • the values that the variable can stand for • the subjects that the predicate may state something about • This domain is called the Universe of Discourse,and is generally denotedU PREDICATE LOGIC

  7. Propositional functions of multiple arguments • Let Q(x, y) : x = y – 4,whereUis the set of positive integers. • What is the truth value of: Q(2, 6) : 2 = 6 – 4, which is True Q(5, 1) : 5 = 1 – 4, which is False Q(-3, 5) has no truth value; it is undefined (ill-formed) because -3 is not inU. • Can you list the values for which Q(x, y) is true as a (possibly infinite) sequence? Yes: (1, 5), (2, 6), (3, 7), (4, 8), …, (n, n + 4), … • Exercise: If the domain of discourse U is the set of all integers, do these answers change? 7 PREDICATE LOGIC

  8. Propositional functions of multiple arguments • Let Q(x, y) : x = y – 4,whereUis the set of positive integers. • What is the truth value of: Q(2, 6) : 2 = 6 – 4, which is True Q(5, 1) : 5 = 1 – 4, which is False Q(-3, 5) has no truth value; it is undefined (ill-formed) because -3 is not inU. • Can you list the values for which Q(x, y) is true as a (possibly infinite) sequence? Yes: (1, 5), (2, 6), (3, 7), (4, 8), …, (n, n + 4), … • Exercise: If the domain of discourse U is the set of all integers, do these answers change? • Exercise: If the domain of discourse U is the set of all real numbers, do these answers change? 8 PREDICATE LOGIC

  9. Propositional Functions Determine Propositions • How can we use a propositional function to define propositions? • Assign a value to each of its variables • Use quantifiers. • Universal quantifier • Existential quantifier 9 PREDICATE LOGIC

  10. Quantifiers: Universal • Definition: The universal quantification of P(x), denoted by x P(x),is the proposition: “everyx in the universe of discourse has property P.” •  is called the universal quantifier, andxP(x)is read as. • “For all x, P(x),” or “For all x, P(x) is true.” • “For every x, P(x).” • Usage: formalize statements such as: • Every integer has a unique set of prime factors. • All cats have tails • All values of type int lie in the range -232 .. 232 10 PREDICATE LOGIC

  11. Example: From English to Predicate Logic Consider: “Every CSE 260 student knows calculus.” • If U (universe of discourse) is “all CSE 260 students”: • Let C(x) : “x knows calculus” • ThenxC(x) : “Every CSE 260 student knows calculus” • If U is “all MSU students”: • Let C(x) : “x knows calculus” and E(x) : “x is a CSE 260 student” • Thenx (E(x) → C(x)) : “Every CSE 260 student knows calculus” 11 PREDICATE LOGIC

  12. The Universal Quantifier • Suppose the universe of discourse is finite:If U = {x1, x2, …, xn}, where n is a positive integer,then xP(x) ≡ P(x1)  P(x2)  …P(xn). • Previous Example: • If U = {Adam, Ben, …, Zoey} is “all CSE 260 students”: • Let C(x) : “x knows calculus” • ThenxC(x) : “Every CSE 260 student knows calculus” and xC(x) ≡ C(Adam)  C(Ben)  …C(Zoey) • Note again that xP(x)is a proposition. 12 PREDICATE LOGIC

  13. Quantifiers: The existential • Definition: The existential quantification of P(x), denoted by x P(x), is the proposition: “One or morexin the universe of discourse has propertyP.” •  is called the existential quantifier, and it is read as: • “There exists an xsuch thatP(x),” or • “There is at least one xsuch thatP(x),” or • “For some x, P(x).” • Usage: formalize statements such as: • There exists an integer larger than 232. • Some CSE 260 student knows calculus. 13 PREDICATE LOGIC

  14. Examples • Let U : set of positive integers • What is the truth value ofx (x > 3)? • Solution:x (x > 3) is true since x > 3 is true , for instance, when x = 4. • Let U : {-3, -2, -1, 0, 1, 2, 3} • What is the truth value ofx (x > 3)? • Solution:x (x > 3) is false since, for there is no xinU for whichx > 3 is true. 14 PREDICATE LOGIC

  15. The Existential Quantifier • Suppose the universe of discourse is finite:If U = {x1, x2, …, xn}, where n is a positive integer,then xP(x) ≡ P(x1)  P(x2)  … P(xn). • Previous Example: • If U = {-3, -2, -1, 0, 1, 2, 3} • Thenx (x > 3)≡ (-3>3)  (-2>3)  (-1>3)  (0>3) (1>3)  (2>3)  (3>3) • Note again that xP(x)is a proposition. 15 PREDICATE LOGIC

  16. Proposition When True? When False? xP(x) WhenP(x) is true for everyx in U. When there is an x in U for which P(x) is false. xP(x) When there is anx in U for which P(x) is true. WhenP(x) is false for every x in U. Quantifiers - summary • Exercise: Restate “there is an x in U for which P(x) is false” (i.e., ¬ xP(x)) as an existential quantification. • x (¬P(x)) • (Generalize) DeMorgan’s Laws • ¬ xP(x) ≡ x (¬P(x))¬ xP(x) ≡ x (¬P(x)) 16 PREDICATE LOGIC

  17. Application: Relational Databases • A relational database implements a set of predicates, e.g. • Major(pid, cuc) : the student with PIDpidhas declared the majorcuc • DeansList(pid, sem) : the student with PID pid made the Dean’s List in semester sem • Properties of the database can be expressed in predicate logic; e.g. • p (DeansList( p, SS14)) “Some student made the Dean’s list in SS14.” • p (DeansList( p, SS14) m (Major(p, m))) “Every student who made the Dean’s list in SS14 has declared some major.” 17 PREDICATE LOGIC

  18. Interesting proposition • English: Every even number greater than 2 is the sum of two primes.E.g., 4=2+2; 6=3+3; 8=5+3; 10 = 3+7; 12=7+5; 14=7+7; 16=9+7; … • Let U be the set of positive integers, {1, 2, 3, …}E(x) : x is evenP(x) : x is prime • Predicate logic:n( (n > 2)  E(n)→m k (P(m)  P(k)  (n = k + m)) ) • This has never been proved or disproved! PREDICATE LOGIC

  19. Scope of a Quantifier • The scope of a quantifier (or) is the part of the expression that the quantifier applies to. • Precedence: quantification takes precedence over the propositional operators • Inx (S(x) → P(x)), the scope of xisS(x) → P(x). • This expression is a proposition—it is true or false, depending on the universe of discourse and what S and P stand for (all given). • InxS(x) → P(x), the scope of xisS(x). • This expression is not a proposition—its truth value depends not just on the universe of discourse and on what S and P stand for, but also on what x refers to in P(x) • Note: since xS(x) ≡ yS(y), it follows that xS(x) → P(x) ≡ yS(y) → P(x) 19 PREDICATE LOGIC

  20. Exercise: Scope of a Quantifier In n( G(n, 2)  E(n)→m k (P(m)  P(k)  S(m, k, n)) ) what is the scope of • n ( G(n, 2)  E(n)→m k (P(m)  P(k)  S(m, k, n)) ) • m k (P(m)  P(k)  S(m, k, n)) • k (P(m)  P(k)  S(m, k, n)) PREDICATE LOGIC

  21. Binding Variables • A variable of a propositional function said to be bound when: • a value is assigned to the variable, or • the variable is in the scope of a quantifier Otherwise, the variable is said to be free. • x (S(x) → P(y)) • To produce a proposition from a predicate, you must bind all of its variables. • y x (S(x) → P(y)) • n( G(n, 2)  E(n)→m k (P(m)  P(k)  S(m, k, n)) ) Bound Free 21 PREDICATE LOGIC

  22. Free and Bound Variables • When all the variables of a propositional function are bound when it becomes a proposition. Let P(x, y) : x < y • InxP(x, y),variable x is bound butyis free, and xP(x, y) is not yet a proposition. • xP(x, 2)is now a proposition; all the variables are bound now. • x yP(x, y) is also a proposition, all the variables are bound now. 22 PREDICATE LOGIC

  23. Negating Quantification Over Finite Domains • If the universe of discourse U is {x1, x2, …, xn}, where n is a positive integer, then: ¬xP(x) ≡ ¬ (P(x1)  P(x2)  …P(xn) ) by def. univ. ≡ ¬P(x1)  ¬P(x2)  …¬P(xn) by DeMorgan ≡ x (¬P(x) ) by def. exist. ¬xP(x) ≡ ¬ (P(x1)  P(x2)  …P(xn) ) by def. exist. ≡ ¬P(x1)  ¬P(x2)  …¬P(xn) by DeMorgan ≡ x (¬P(x) ) by def. univ. • Thus, • ¬xP(x) ≡ x ¬P(x). • ¬xP(x) ≡ x ¬P(x). 23 PREDICATE LOGIC

  24. Example • The negation of “Lansing is a small city” is “Lansing is not a small city”. • The negation of “every city in Michigan is clean” is “not every city in Michigan is clean” which is the same as saying, “some city in Michigan is not clean.” 24 PREDICATE LOGIC

  25. Negating Quantification In General Negation When True? When False? When “there is some x for which P(x) is true” is false, i.e, when P(x) is false for every x. When there is an x for which P(x) is true. ¬xP(x) ≡ x (¬ P(x)) When “P(x) is true for every x” is false, i.e., whenthere is an x for which P(x) is false. When P(x) is true for every x. ¬xP(x) ≡ x (¬P(x)) 25 PREDICATE LOGIC

  26. Translating English Sentences into Logical Expressions “Not every security vulnerability is due to a buffer overflow” • Let:The universe of discourse be the set of all vulnerabilities.S(v) :“v is a security vulnerability.”O(v) :“v is due to a buffer overflow.” • Several possible translations: • ¬v (S(v)  O(v)) • v (¬ (S(v)  O(v))) • v (S(v)  ¬ O(v)) 26 PREDICATE LOGIC

  27. Exercise • Assume the universe of discourse is the set of all positive integers and define the following predicates P(x) : x is a prime number D(x,y) : x is evenly divisible by y • Using these predicates, symbolize the following: • Every integer which is evenly divisible by 10 is evenly divisible by 5 and evenly divisible by 2. x [D(x,10) → (D(x,5)  D(x,2))] • Some odd integer is not prime. x (¬ D(x,2)  ¬ P(x)) 27 PREDICATE LOGIC

  28. Guidelines in Translating…. • The proposition y (P(y) → Q(y))can be translated as “All individuals that have property P also have property Q” • The proposition y (P(y) Q(y))can be translated as “All individuals have property P and property Q” • Exercise: Give an example that illustratesy (P(y) → Q(y)) ≡ y (P(y) Q(y)) • The proposition  y (P(y) Q(y)) can be translated as “Some individual that has property P also has property Q” 28 PREDICATE LOGIC

  29. Exercise • Assume the universe of discourse is all positive integers and define: • E(x) : “x is an even integer” • P(x) : “x is prime” • Q(x, y) : “x equals y ” (i.e., “x = y”) • Using these predicates, symbolize the following. • There is exactly one integer that is both even and prime.. x [ E(x) P(x) y (E(y) P(y) →Q(x, y))] 29 PREDICATE LOGIC

  30. Nested Quantifiers • When we have more than one variable in a predicate, one way to make a proposition is to use nested quantifiers. • When using nested quantifiers, we must pay attention to the order in which they are used. 30 PREDICATE LOGIC

  31. Quantification of Two Variables 31 PREDICATE LOGIC

  32. Quantification of Two Variables 32 PREDICATE LOGIC

  33. Quantification of Two Variables 33 PREDICATE LOGIC

  34. Quantification of Two Variables 34 PREDICATE LOGIC

  35. Quantification of Two Variables 35 PREDICATE LOGIC

  36. Quantification of Two Variables 36 PREDICATE LOGIC

  37. Quantification of Two Variables 37 PREDICATE LOGIC

  38. Quantification of Two Variables y may depend on x x does not depend on y 38 PREDICATE LOGIC

  39. Examples • Let P(x, y) denote “x + y = 5.” • The universe of discourse for both x and y is {1, 2, 3, 4} • Find the truth value for x yP(x, y) • Solution:False; for example, if x =1 and y = 3, then x + y ≠ 5 • Find the truth value for y xP(x, y) • Solution: 39 PREDICATE LOGIC

  40. Examples • Let P(x, y) denote “x + y = 5.” • The universe of discourse for both x and y is {1, 2, 3, 4} • Find the truth value for x yP(x, y) • Solution: False; for example, if x =1 and y = 3, then x + y ≠ 5 • Find the truth value for y xP(x, y) • Solution: True;for example, let x = 3 and y = 2; then x + y = 5. 40 PREDICATE LOGIC

  41. Examples • Let P(x, y) denote “x + y = 5.” • The universe of discourse for both x and y is {1, 2, 3, 4} • Find the truth value for x yP(x, y) • Solution: True; for x=1, let y=4; for x=2, let y=3; for x=3, for y=2; for x=4, let y=1; • Find the truth value for x yP(x, y) • Solution: 41 PREDICATE LOGIC

  42. Examples • Let P(x, y) denote “x + y = 5.” • The universe of discourse for both x and y is {1, 2, 3, 4} • Find the truth value for x yP(x, y) • Solution: True; for x=1, let y=4; for x=2, let y=3; for x=3, let y=2; for x=4, let y=1. • Find the truth value for x yP(x, y) • Solution: 42 PREDICATE LOGIC

  43. Examples • Let P(x, y) denote “x + y = 5.” • The universe of discourse for both x and y is {1, 2, 3, 4} • Find the truth value for x yP(x, y) • Solution: True; for x=1, let y=4; for x=2, let y=3; for x=3, let y=2; for x=4, let y=1. • Find the truth value for x yP(x, y) • Solution: False; there is no (fixed) x such that, for every y, x + y = 5 is true; in other words, for every choice of x, there is some y, such that x + y ≠ 5; e.g, if x=1, let y=1; if x=2, let y=2; if x=3, let y=3; if x=4, let y=4; in all the cases x + y ≠ 5. 43 PREDICATE LOGIC

  44. Negation again • When negating a proposition with nested quantifiers, use (generalized) DeMorgan’s Laws: • ¬xP(x) ≡ x (¬P(x)) • ¬xP(x) ≡ x (¬P(x)) • Exercise: Rewrite each negation so that negation applies only to predicates PREDICATE LOGIC

  45. Negation again • When negating a proposition with nested quantifiers, use (generalized) DeMorgan’s Laws: • ¬xP(x) ≡ x (¬P(x)) • ¬xP(x) ≡ x (¬P(x)) • Exercise: Rewrite each negation so that negation applies only to predicates PREDICATE LOGIC

  46. Negation again • When negating a proposition with nested quantifiers, use (generalized) DeMorgan’s Laws: • ¬xP(x) ≡ x (¬P(x)) • ¬xP(x) ≡ x (¬P(x)) • Exercise: Rewrite each negation so that negation applies only to predicates PREDICATE LOGIC

  47. Negation again • When negating a proposition with nested quantifiers, use (generalized) DeMorgan’s Laws: • ¬xP(x) ≡ x (¬P(x)) • ¬xP(x) ≡ x (¬P(x)) • Exercise: Rewrite each negation so that negation applies only to predicates PREDICATE LOGIC

  48. Negation again • When negating a proposition with nested quantifiers, use (generalized) DeMorgan’s Laws: • ¬xP(x) ≡ x (¬P(x)) • ¬xP(x) ≡ x (¬P(x)) • Exercise: Rewrite each negation so that negation applies only to predicates PREDICATE LOGIC

More Related