Upload
imogen-hunt
View
216
Download
1
Embed Size (px)
Citation preview
11
CS 1502 Formal Methods in CS 1502 Formal Methods in Computer ScienceComputer Science
Lecture Notes 14Lecture Notes 14
TranslationsTranslations
Mixed QuantifiersMixed Quantifiers
22
Informal ProofInformal Proof
Prove that if the square of an integer is even, Prove that if the square of an integer is even, then so is that integer. then so is that integer.
Proving the contrapositive is easier: If an integer Proving the contrapositive is easier: If an integer is not even, then its square isn’t even either.is not even, then its square isn’t even either.
Let n be an integer. Assume ~Even(n), i.e., Let n be an integer. Assume ~Even(n), i.e., Odd(n).Odd(n). Then we can express n as 2m + 1 for Then we can express n as 2m + 1 for some m. some m. But we see that n*n = 2(2m*m + 2m) + But we see that n*n = 2(2m*m + 2m) + 1,1, showing that n*n is odd.showing that n*n is odd. Thus, we have Thus, we have shown ~Even(n) shown ~Even(n) ~Even(n*n) ~Even(n*n)
33
TranslationsTranslations
Every Steeler is taller than Jim.Every Steeler is taller than Jim.x (Steeler(x) x (Steeler(x) Taller(x, jim)) Taller(x, jim))
Every Steeler is taller than anyone who is Every Steeler is taller than anyone who is the same size as Jim. the same size as Jim. x [Steeler(x) x [Steeler(x) y (SameSize(y, jim) y (SameSize(y, jim)
Taller(x, y))]Taller(x, y))]
44
TranslationsTranslations
Some Steeler is taller than Jim.Some Steeler is taller than Jim.x (Steeler(x) x (Steeler(x) Taller(x, jim)) Taller(x, jim))
Some Steeler is taller than anyone who is Some Steeler is taller than anyone who is the same size as Jim. the same size as Jim. x [Steeler(x) x [Steeler(x) y (SameSize(y, jim) y (SameSize(y, jim)
Taller(x, y))]Taller(x, y))]
55
TranslationsTranslations
Some Steeler is not taller than Jim.Some Steeler is not taller than Jim.x (Steeler(x) x (Steeler(x) Taller(x, jim))Taller(x, jim))
Some Steeler is not taller than someone Some Steeler is not taller than someone who is the same size as Jim. who is the same size as Jim. x [Steeler(x) x [Steeler(x) y (SameSize(y, jim) y (SameSize(y, jim)
Taller(x, y))]Taller(x, y))]
66
TranslationsTranslations
No Steeler is taller than Jim.No Steeler is taller than Jim.x (Steeler(x) x (Steeler(x) Taller(x, jim))Taller(x, jim))
No Steeler is taller than somebody who No Steeler is taller than somebody who is the same size as Jim. is the same size as Jim. x [Steeler(x) x [Steeler(x) y(SameSize(y, jim) y(SameSize(y, jim)
Taller(x, y))]Taller(x, y))]
77
Orders of QuantifiersOrders of Quantifiers
x x y P(x,y) y P(x,y) isis logically equivalent to logically equivalent to y y x P(x,y)x P(x,y)
x x y P(x,y)y P(x,y) isis logically equivalent to logically equivalent to
y y x P(x,y)x P(x,y)
x x y P(x,y) is y P(x,y) is notnot logically equivalent logically equivalent to to y y x P(x,y)x P(x,y)
88
A Gotcha (before moving on)A Gotcha (before moving on)
Suppose a world has Suppose a world has 4 cubes4 cubes, all in the same row , all in the same row (a,b,c,d)(a,b,c,d)
Is the following true of that world?Is the following true of that world?
all x all y ((Cube(x) ^ Cube(y)) all x all y ((Cube(x) ^ Cube(y))
(LeftOf(x,y) v RightOf(x,y)))(LeftOf(x,y) v RightOf(x,y)))
No! Can infer: LeftOf(a,a) v RightOf(a,a) No! Can infer: LeftOf(a,a) v RightOf(a,a) (same(same forfor b,c,d)b,c,d)
Want:Want: all x all y ((Cube(x) ^ Cube(y) ^ x != y) all x all y ((Cube(x) ^ Cube(y) ^ x != y)
(LeftOf(x,y) v RightOf(x,y)))(LeftOf(x,y) v RightOf(x,y)))
99
TranslationTranslation
x x y P(x,y)y P(x,y)For each x there is a y such that P(x,y).For each x there is a y such that P(x,y).
x y
1010
TranslationTranslation
x x y P(x,y)y P(x,y)There is a special x such that for all There is a special x such that for all y, P(x,y).y, P(x,y).
1111
Prenex Normal FormPrenex Normal Form
Sentence containing no quantifiers at all, Sentence containing no quantifiers at all, oror
A sentence of the formA sentence of the form Q Q11xx11 Q Q22xx22 … Q … Qnnxxnn P P
where Qwhere Qii are either the universal or are either the universal or
existential quantifier, xexistential quantifier, xii are variables and are variables and
wff P is free of quantifiers.wff P is free of quantifiers.
1212
Conversion to Prenex Normal Conversion to Prenex Normal FormForm
1.1. Replace implications (whose left- or right-hand sides Replace implications (whose left- or right-hand sides include quantifiers) (A include quantifiers) (A B) by B) by AA BB
2.2. Move Move “inwards” until there are no quantifiers in the “inwards” until there are no quantifiers in the scope of a negationscope of a negation
3.3. Rename variables so each separate variable has its Rename variables so each separate variable has its own nameown name
4.4. Move quantifiers to the front of the sentence, without Move quantifiers to the front of the sentence, without changing their orderchanging their order
1313
ExampleExample
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))]
xy[(C(x) T(y) L(x,y)) z(D(z) B(x,z))]
xyz[(C(x) T(y) L(x,y)) (D(z) B(x,z))]
If you want to restore the conditional:
xyz[(C(x) T(y) L(x,y)) (D(z) B(x,z))]
1414
TranslationTranslationAll cubes are to the left of something large.All cubes are to the left of something large.
x [Cube(x) x [Cube(x) x is to the left of something large] x is to the left of something large]
x [Cube(x) x [Cube(x) y (Large(y) y (Large(y) LeftOf(x,y))] LeftOf(x,y))]
Some cube is to the left of everything large.Some cube is to the left of everything large.
x [Cube(x) x [Cube(x) x is to the left of everything large] x is to the left of everything large]
x [Cube(x) x [Cube(x) y [Large(y) y [Large(y) LeftOf(x,y)]]LeftOf(x,y)]]
1515
TranslationTranslation
Taken(x,y) means x has taken class yTaken(x,y) means x has taken class y
Domain of discourse for x is all (Pitt) Domain of discourse for x is all (Pitt) studentsstudents
Domain of discourse for y is all (Pitt) CS Domain of discourse for y is all (Pitt) CS classesclasses
Continued…Continued…
1616
exist x exist y Taken(x,y)exist x exist y Taken(x,y)A student has taken a CS classA student has taken a CS class
exist x all y Taken(x,y)exist x all y Taken(x,y)A student has taken all the CS classesA student has taken all the CS classes
all x exist y Taken(x,y)all x exist y Taken(x,y)Each student has taken some CS classEach student has taken some CS class
exist y all x Taken(x,y)exist y all x Taken(x,y)There is a CS class that all students have takenThere is a CS class that all students have taken
all y exist x Taken(x,y)all y exist x Taken(x,y)Each CS class has been taken by at least one studentEach CS class has been taken by at least one student
1717
TranslationTranslation
Everyone ate a sandwichEveryone ate a sandwich
Ate(x,y); DoD of x is all people; DoD of y is Ate(x,y); DoD of x is all people; DoD of y is all sandwichesall sandwiches
Most natural:Most natural: everyone ate their owneveryone ate their own sandwich:sandwich: all x exist y Ate(x,y) all x exist y Ate(x,y)
But perhaps it was one huge sandwich:But perhaps it was one huge sandwich: exist y all x Ate(x,y)exist y all x Ate(x,y)
1818
What do these sentences What do these sentences mean?mean?
exist y (Small(y) ^ all x (Small(x) exist y (Small(y) ^ all x (Small(x) y=x)) y=x))
There is exactly one small thing!There is exactly one small thing!
all x all y ((Small(x) ^ Small(y)) all x all y ((Small(x) ^ Small(y)) y=x) y=x)
There is at most one small thingThere is at most one small thing
T if there are 0 or 1 small things (try it in TW)T if there are 0 or 1 small things (try it in TW)
1919
Valid Arguments? Valid Arguments?
exists y (Tet(y) ^ all x (Cube(x) exists y (Tet(y) ^ all x (Cube(x) SameSize(y,x))) SameSize(y,x)))------all x (Cube(x) all x (Cube(x) exists y (Tet(y) ^ SameSize(y,x))) exists y (Tet(y) ^ SameSize(y,x)))
exists y (Girl(y) ^ all x (Boy(x)exists y (Girl(y) ^ all x (Boy(x) Likes(x,y))) Likes(x,y)))------all x (Boy(x) all x (Boy(x) exists y (Girl(y)^ Likes(x,y))) exists y (Girl(y)^ Likes(x,y)))
exists y all x (x != y exists y all x (x != y Adjoins(x,y)) Adjoins(x,y))------all x exists y (x != y all x exists y (x != y Adjoins(x,y)) Adjoins(x,y))
YES! All Are Valid
2020
Valid Arguments? Valid Arguments?
all x (Cube(x) all x (Cube(x) exists y (Tet(y) ^ SameSize(y,x))) exists y (Tet(y) ^ SameSize(y,x)))------exists y (Tet(y) ^ all x (Cube(x) exists y (Tet(y) ^ all x (Cube(x) SameSize(y,x))) SameSize(y,x)))
all x (Boy(x) all x (Boy(x) exists y (Girl(y)^ Likes(x,y))) exists y (Girl(y)^ Likes(x,y)))------exists y (Girl(y) ^ all x (Boy(x)exists y (Girl(y) ^ all x (Boy(x) Likes(x,y))) Likes(x,y)))
all x exists y (x != y all x exists y (x != y Adjoins(x,y)) Adjoins(x,y))------exists y all x (x != y exists y all x (x != y Adjoins(x,y)) Adjoins(x,y))
No! All Are Invalid!!
2121
Translations with Function SymbolsTranslations with Function Symbols
Domain of discourse: peopleDomain of discourse: people
Every person has exactly one mother, who Every person has exactly one mother, who is older than he or she. With a function:is older than he or she. With a function:
all x OlderThan(mother(x),x) all x OlderThan(mother(x),x)
With a predicate?With a predicate?
all x exist y (MotherOf(y,x) ^ OlderThan(y,x) all x exist y (MotherOf(y,x) ^ OlderThan(y,x) ^ all z (MotherOf(z,x) ^ all z (MotherOf(z,x) y=z)) y=z))
Moral: use a function when appropriateMoral: use a function when appropriate
2222
Proofs with Multiple Proofs with Multiple QuantifiersQuantifiers
x (P(x) y F(y,x))x y (F(y,x) L(y,x))
x (P(x) y L(y,x))