1 / 23

CS 1502 Formal Methods in Computer Science

CS 1502 Formal Methods in Computer Science. Lecture Notes 14 Translations Mixed Quantifiers. Informal Proof. Prove that if the square of an integer is even, then so is that integer. Proving the contrapositive is easier: If an integer is not even, then its square isn’t even either.

conlan
Télécharger la présentation

CS 1502 Formal Methods in Computer Science

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. CS 1502 Formal Methods in Computer Science Lecture Notes 14 Translations Mixed Quantifiers

  2. Informal Proof • Prove that if the square of an integer is even, then so is that integer. • Proving the contrapositive is easier: If an integer is not even, then its square isn’t even either. • Let n be an integer. Assume ~Even(n), i.e., Odd(n). Then we can express n as 2m + 1 for some m. But we see that n*n = 2(2m*m + 2m) + 1,showing that n*n is odd. Thus, we have shown ~Even(n)  ~Even(n*n)

  3. Translations • Every Steeler is taller than Jim. x (Steeler(x)  Taller(x, jim)) • Every Steeler is taller than anyone who is the same size as Jim. x [Steeler(x)  y (SameSize(y, jim)  Taller(x, y))]

  4. Translations • Some Steeler is taller than Jim. x (Steeler(x)  Taller(x, jim)) • Some Steeler is taller than anyone who is the same size as Jim. x [Steeler(x)  y (SameSize(y, jim)  Taller(x, y))]

  5. Translations • Some Steeler is not taller than Jim. x (Steeler(x)  Taller(x, jim)) • Some Steeler is not taller than someone who is the same size as Jim. x [Steeler(x)  y (SameSize(y, jim)  Taller(x, y))]

  6. Translations • No Steeler is taller than Jim. x (Steeler(x)  Taller(x, jim)) • No Steeler is taller than somebody who is the same size as Jim. x [Steeler(x)  y(SameSize(y, jim)  Taller(x, y))]

  7. Orders of Quantifiers • x y P(x,y) is logically equivalent to y x P(x,y) • x y P(x,y)is logically equivalent to y x P(x,y) • x y P(x,y) is not logically equivalent to y x P(x,y)

  8. A Gotcha (before moving on) • Suppose a world has 4 cubes, all in the same row (a,b,c,d) • Is the following true of that world? all x all y ((Cube(x) ^ Cube(y))  (LeftOf(x,y) v RightOf(x,y))) No! Can infer: LeftOf(a,a) v RightOf(a,a) (sameforb,c,d) Want: all x all y ((Cube(x) ^ Cube(y) ^ x != y)  (LeftOf(x,y) v RightOf(x,y)))

  9. Translation • x y P(x,y)For each x there is a y such that P(x,y). y x

  10. Translation • x y P(x,y)There is a special x such that for all y, P(x,y).

  11. Prenex Normal Form • Sentence containing no quantifiers at all, or • A sentence of the form Q1x1 Q2x2 … Qnxn P where Qi are either the universal or existential quantifier, xi are variables and wff P is free of quantifiers.

  12. Conversion to Prenex Normal Form • Replace implications (whose left- or right-hand sides include quantifiers) (A  B) by A B • Move  “inwards” until there are no quantifiers in the scope of a negation • Rename variables so each separate variable has its own name • Move quantifiers to the front of the sentence, without changing their order

  13. Example x[(C(x)  y(T(y)  L(x,y)))  y(D(y)  B(x,y))] x[(C(x)  y(T(y)  L(x,y))) y(D(y)  B(x,y))] x[ y(C(x)  T(y)  L(x,y)) y(D(y)  B(x,y))] xy[(C(x)  T(y)  L(x,y)) z(D(z)  B(x,z))] xyz[(C(x)  T(y)  L(x,y)) (D(z)  B(x,z))] If you want to restore the conditional: xyz[(C(x)  T(y)  L(x,y))  (D(z)  B(x,z))]

  14. Translation All cubes are to the left of something large. x [Cube(x)  x is to the left of something large] x [Cube(x)  y (Large(y)  LeftOf(x,y))] Some cube is to the left of everything large. x [Cube(x)  x is to the left of everything large] x [Cube(x)  y [Large(y)  LeftOf(x,y)]]

  15. Translation • Taken(x,y) means x has taken class y • Domain of discourse for x is all (Pitt) students • Domain of discourse for y is all (Pitt) CS classes • Continued…

  16. exist x exist y Taken(x,y) A student has taken a CS class • exist x all y Taken(x,y) A student has taken all the CS classes • all x exist y Taken(x,y) Each student has taken some CS class • exist y all x Taken(x,y) There is a CS class that all students have taken • all y exist x Taken(x,y) Each CS class has been taken by at least one student

  17. Translation • Everyone ate a sandwich • Ate(x,y); DoD of x is all people; DoD of y is all sandwiches • Most natural:everyone ate their ownsandwich: all x exist y Ate(x,y) • But perhaps it was one huge sandwich: exist y all x Ate(x,y)

  18. What do these sentences mean? • exist y (Small(y) ^ all x (Small(x)  y=x)) There is exactly one small thing! • all x all y ((Small(x) ^ Small(y))  y=x) There is at most one small thing T if there are 0 or 1 small things (try it in TW)

  19. Valid Arguments? YES! All Are Valid exists y (Tet(y) ^ all x (Cube(x)  SameSize(y,x))) --- all x (Cube(x)  exists y (Tet(y) ^ SameSize(y,x))) exists y (Girl(y) ^ all x (Boy(x) Likes(x,y))) --- all x (Boy(x)  exists y (Girl(y)^ Likes(x,y))) exists y all x (x != y  Adjoins(x,y)) --- all x exists y (x != y  Adjoins(x,y))

  20. Valid Arguments? No! All Are Invalid!! all x (Cube(x)  exists y (Tet(y) ^ SameSize(y,x))) --- exists y (Tet(y) ^ all x (Cube(x)  SameSize(y,x))) all x (Boy(x)  exists y (Girl(y)^ Likes(x,y))) --- exists y (Girl(y) ^ all x (Boy(x) Likes(x,y))) all x exists y (x != y  Adjoins(x,y)) --- exists y all x (x != y  Adjoins(x,y))

  21. Translations with Function Symbols Domain of discourse: people • Every person has exactly one mother, who is older than he or she. With a function: all x OlderThan(mother(x),x) • With a predicate? all x exist y (MotherOf(y,x) ^ OlderThan(y,x) ^ all z (MotherOf(z,x)  y=z)) Moral: use a function when appropriate

  22. Proofs with Multiple Quantifiers x (P(x) y F(y,x))x y (F(y,x) L(y,x))x (P(x)  y L(y,x))

More Related