Title: CS 1502 Formal Methods in Computer Science
1CS 1502 Formal Methods in Computer Science
- Lecture Notes 14
- Translations
- Mixed Quantifiers
2Informal 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 isnt 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 nn 2(2mm 2m) 1,
showing that nn is odd. Thus, we have shown
Even(n) ? Even(nn)
3Translations
- 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))
4Translations
- 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))
5Translations
- 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))
6Translations
- 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))
7Orders 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)
8A 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) (same
for b,c,d) - Want all x all y ((Cube(x) Cube(y) x ! y) ?
- (LeftOf(x,y) v RightOf(x,y)))
9Translation
- ?x ?y P(x,y)For each x there is a y such that
P(x,y).
y
x
10Translation
- ?x ?y P(x,y)There is a special x such that for
all y, P(x,y).
11Prenex 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.
12Conversion 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
13Example
?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))
14Translation
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)
15Translation
- 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
17Translation
- Everyone ate a sandwich
- Ate(x,y) DoD of x is all people DoD of y is all
sandwiches - Most natural everyone ate their own sandwich
all x exist y Ate(x,y) - But perhaps it was one huge sandwich exist y all
x Ate(x,y)
18What do these sentences mean?
- exist y (Small(y) all x (Small(x) ? yx))
- There is exactly one small thing!
- all x all y ((Small(x) Small(y)) ? yx)
- There is at most one small thing
- T if there are 0 or 1 small things (try it in TW)
19Valid 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))
20Valid 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))
21Translations 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) ? yz)) - Moral use a function when appropriate
22Proofs 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))
23(No Transcript)