1 / 34

Chapter 2, Predicate Logic

Chapter 2, Predicate Logic. Definitions. Subject / predicate John / went to the store. The sky / is blue. Propositional logic- uses statements Predicate logic or calculus- uses predicates predicates must be applied to a subject in order to be true or false P(x)

madra
Download Presentation

Chapter 2, 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. Chapter 2, Predicate Logic

  2. Definitions • Subject / predicate John / went to the store. The sky / is blue. • Propositional logic- uses statements • Predicate logic or calculus- uses predicates • predicates must be applied to a subject in order to be true or false • P(x) • means this predicate represented by P • applied to the object represented by x

  3. Quantification • x There exists an x • x For all x's • Domain- the set where these subjects come from • (x) [P(x)] there exists an x for which predicate p is true • (x) [P(x)] for all x, predicate p is true • Notation: • x  Z there exists an x in the integers • x  R for all x's in the reals

  4. Predicate translation • A student of mine is wearing a blue shirt. • Domain: all people P • Quantification: There is at least one • Predicates: "wearing a blue shirt" and "is my student" Let B(x) represent "x is wearing a blue shirt" Let S(x) represent "x is my student" x  P such that B(x) ^ S(x) • All good students are in class. • Domain: all people P • Quantification: All of them • Predicates: "are in class" and "is a good student" Let C(x) represent "x is in class" Let G(x) represent “x is a good student" x  P such that G(x)  C(x)

  5. Establishing truth and falsity • To show an existentially quantified statement () is true, find an example. • One way to show an existentially quantified statement is false is to show it's false for every member of the domain. • To show a universally quantified statement () is false, find a counterexample. • One way to show a universally quantified statement is true is to show it's true for every member of the domain.

  6. Negation of quantified statements • (there is a cat which can fly)  • some cats can’t fly? • only some cats can fly? • cats can only fly sometimes? • all cats can’t fly? • watch me throw this cat out the window… • Let F(x) represent the predicate "x can fly" ~ (x  cats) [F(x)]  (x  cats) [~F(x)]

  7. Negation of quantified statements • (everybody likes me)  • nobody likes me? • everybody doesn’t like me? • somebody doesn’t like me? • Let L(x) represent the predicate "x likes me" ~(x  people) [L(x)]  (x  people) [~L(x)]

  8. Discrete StructuresCMSC 250Lecture 9 February 15, 2008

  9. Vacuous cases (for universally quantified statements) • All even prime numbers which are greater than or equal to 10 are the sum of two squares. • All students in this class who are ten feet tall have green hair. • Are these true or false? How would we show they’re true or false?

  10. Universal conditional statements and variants • A universal conditional statement: (x  D) [P(x)  Q(x)] • Its contrapositive: (x  D) [~Q(x)  ~P(x)] • Its converse: (x  D) [Q(x)  P(x)] • Its inverse: (x  D) [~P(x)  ~Q(x)] • Also applies to existentially quantified conditional statements

  11. Multiple quantification • Let C = {all chairs} and P = {all people}, and S(c,p) represent “person p is sitting in chair c " • (p  P) (c  C) [S(c,p)] • (c  C) (p  P) [S(c,p)] • (p  P) (c  C) [S(c,p)] • (c  C) (p  P) [S(c,p)]

  12. Order of mixed quantifiers •  and  are different! • Example- domain N- the following do not mean the same thing! • (x) (y) [y > x] • (y) (x) [y > x]

  13. Mixed multiple quantification variations • Let C = {all chairs} and P = {all people}, and S(c,p) represent “person p is sitting in chair c" • (c  C) (p  P) [S(c,p)] • (p  P) (c  C) [S(c,p)] • (p  P) (c  C) [S(c,p)] • (c  C) (p  P) [S(c,p)]

  14. Negations of multiply quantified statements • Let P= {all people}, and C= {all cats}, and L(p,c) represent “person p likes cat c" ~((p  P) (c  C) [L(p,c)])  (p  P) (c  C) [~L(p,c)]

  15. Other variations • Let S be the set of all students and C be the set of all colleges, and A(s,c) represent "student s attends college c". • Exactly one student attends college: (s  S) ( c C) [A(s,c)  ~((p  S) (u  C) [p  s  A(p,u)])] (s  S) (c  C) [A(s,c)  ((p  S) (u  C) [p = s  ~A(p,u)])] • At most one student attends college: (s,p  S) (c,u  C) [(A(s,c)  A(p,u))  p = s] • At least two students attend college: (s,p  S) (c,u  C) [A(s,c)  A(p,u)  p  s]

  16. Discrete StructuresCMSC 250Lecture 10 February 18, 2008

  17. Establishing truth and falsity with multiple quantification • Recall: • to show x is true, find an example. • to show x is false, find a counterexample. • Let the domain be the natural numbers

  18. Set (Euler) diagrams • Circles are used to indicate “truth sets" for a predicate • where the predicate applied to an object is true • A dot is used to indicate a specific instance • A completely contained circle indicates a "for all" relationship • An overlapping circle indicates "some" All college students are brilliant. All brilliant people are scientists. All college students are scientists. Some poets are unsuccessful. Some athletes are unsuccessful. Some poets are athletes. OR U U A P P S B C A

  19. Interpretations • Assign meanings to predicates and domains to quantified variables • One interpretation: domain N, L is < • Another interpretation: domain Q, L is < • Another interpretation: domain N, L is / (L(x, y) means "x can be divided by y evenly") • An interpretation is analogous to a row of a truth table (except there are an infinite number of them).

  20. Rules of inference for quantified statements

  21. Rules that don't exist or need more clarification • Existential Modus Ponens doesn't exist • Existential Modus Tollens doesn't exist • Universal generalization: P(a), (x  D) [P(x)] • only if a is completely arbitrary in the domain • Existential instantiation: (x  D) [P(x)], P(a) • only if a is completely arbitrary in the domain

  22. Converse error: (x  D) [P(x)  Q(x)] Q(a)  P(a) Called asserting the consequence Inverse error: (x  D) [P(x)  Q(x)] ~P(a)  ~Q(a) Called denying the hypothesis Errors in deduction

  23. Easy formal direct proofs by deduction

  24. More formal direct proofs by deduction

  25. Discrete StructuresCMSC 250Lecture 11 February 20, 2008

  26. One more proof • Note: (x  D) [A(x)  ~N(x)]  (y  D) [A(y)  ~N(y)]  (z  D) [A(z)  ~N(z)] etc. • Also, the quantified variables are completely independent in different quantified predicates like (y  D) [A(y)] and (y  D) [B(y)  Q(y)]

  27. Example using predicate logic • Once we define operations or concepts we can use them in defining other operations. • Consider only , , =, and the domain N • Define DIV(x,y): (z)[x  z = y] • Now we can define PRIME(y): (x)[DIV(x,y)  x = 1  x = y] • Also ODD(y): (x)[y = 2  x + 1]

  28. Example, continued • Using these, define SUM3P(x): • Now we can state the following: (n)(x)[x  n  ODD(x)  SUM3P(x)]

  29. Another application- describing properties of programs • Motivation: • finding bugs • proofs of correctness • specifying programs- clarifying goals before coding A precondition is a property which must be true before some piece of code is executed, otherwise it won’t work correctly • A postcondition is a property which will be true after some piece of code executes (assuming the precondition was true beforehand) • An invariant is a property which is true at every iteration of a loop (at the top of the loop)

  30. Example i= 0; // precondition: true (meaning there are no // requirements or conditions which must be // satisfied in order for the code to work correctly) while (i < n && arr[i] < x) // invariant: 0  i < n  // (j, 0  j < i)[arr[j] < x] i++; // postcondition: n < 0  // (0  i  n  // (j, 0  j < i)[arr[j] < x]  // i < n  arr[i]  x)

  31. Discrete StructuresCMSC 250Lecture 12 February 22, 2008

  32. Another example i= 1; max= arr[0]; // precondition: true while (i < n) { // invariant: 1  i < n  // (j, 0  j < i)[arr[j] = max]  // (k, 0  k < i)[arr[k]  max] if (arr[i] > max) max= arr[i]; i++; } // postcondition: n < 1  // (i = n  // (j, 0  j < n)[arr[j] = max]  // (k, 0  k < n)[arr[k]  max])

  33. A further example i= 0; found= 0; // precondition: true while (i < n && !found) // invariant: found = 0  0  i < n  // (j, 0  j < i)[arr[j]  x] if (arr[i] == x) found= 1; else i++; // postcondition: // n < 0  // ((found = 0  i = n  // (j, 0  j < i)[arr[j]  x]))  // (found = 1  0  i < n  arr[i] = x  // (j, 0  j < i)[arr[j]  x]]))

  34. One more example • If we need to refer to the initial value of a variable, the convention is to use its name with a prime symbol i= 0; // precondition: n  0 while (i < n – 1) { // invariant: i < n – 1  // (j, 0 ≤ j < i)[arr[j] = arr'[j + 1]]  // (j, i ≤ j < n)[arr[j] = arr'[j]] arr[i]= arr[i + 1]; i++; } // postcondition: // n < 0  // (i = n – 1  // (j, 0 ≤ j < i)[arr[j] = arr'[j + 1]]  // [arr[n - 1] = arr'[n - 1]])

More Related