Predicates II
Predicates II
x( x y 1)
x( p ( x) q ( x)) xR( x)
x( p ( x) q ( x)) yR( y )
6
Equivalence
• we can distribute a universal quantifier
over a conjunction. Furthermore, we can
also distribute an existential quantifier over
a disjunction.
• However, we cannot distribute a universal
quantifier over a disjunction, nor can we
distribute an existential quantifier over a
conjunction.
Negating quantified expressions
x( x 2 x) x( x 2 2)
x ( x 2 x) x ( x 2 2)
x( x 2 x) x( x 2 2)
x( p ( x) q ( x)
x( ( p ( x) q ( x)))
x( ( p ( x) q ( x)))
x( p ( x) q ( x))
11
Translating English into logical
expressions
• “Every student in this class has studied
calculus”
Let c(x) be the statement that “x has
studied calculus”. Let s(x) be the
statement “x is in this class”
x c( x) if the domain consists of students of this class
x s ( x) c( x) if the domain consists of all people
x s ( x) c( x) ? if the domain consists of all people
12
Using quantifiers in system
specifications
• “Every mail message larger than one
megabyte will be compressed”
Let s(m,y) be “mail message m is larger
than y megabytes” where m has the
domain of all mail messages and y is a
positive real number. Let c(m) denote
“message m will be compressed”
m( s ( m,1) c ( m))
13
Example
• “If a user is active, at least one network
link will be available”
Let a(u) represent “user u is active” where
u has the domain of all users, and let s(n,
x) denote “network link n is in state x”
where n has the domain of all network
links, and x has the domain of all possible
states, {available, unavailable}.
u a (u ) n s (n, available)
14
Nested quantifiers
Nested quantifiers
Let the variable domain be real numbers
xy ( x y ) 0
same as xq ( x)
where q ( x) is yp ( x, y ) and p ( x, y ) is x y 0
xy ( x y y x)
xyz ( x ( y z ) ( x y ) z )
xy (( x 0) ( y 0) ( xy 0))
17
Quantification as loop
• xyp( x, y ) : loop through the values for x
until we find an x for which p(x,y) is always
true when we loop through all values for y
– Once found such one x, then it is true
• : loop though the values for x
xyp( x, y )
where for each x loop through the values of y
until we find an x for which we find a y such
that p(x,y) is true
– False only if we never hit an x for which we never
find y such that p(x,y) is true
18
Order of quantification
Let p ( x, y ) be the statement x y y x,
and the domain is real number
xyp( x, y )
xyp( x, y ) yxp( x, y ) ?
20
Quantification with more
variables
Let q ( x, y, z ) be the statement x y z ,
and the domain is real number
xyzq( x, y, z ) : What does it mean? Is it true?
zxyq( x, y, z ) : What does it mean? Is it true?
21
Translating mathematical
statements
• “The sum of two positive integers is
always positive”
xy (( x 0) ( y 0) ( x y 0))
where the domain for both variables consists of
all integers
xy ( x y 0)
where the domain for both variables consists of
all positive integers
22
Example
• “Every real number except zero has a
multiplicative inverse”
23
Translating statements into
English
• x(c( x) y (c( y ) f ( x, y ))) where c(x)
is “x has a computer”, f(x,y) is “x and y are
friends”, and the domain for both x and y
consists of all students in our school
• xyz (( f ( x, y ) f ( x, z ) ( y z )) f ( y, z ))
where f(x,y) means x and y are friends,
and the domain consists of all students in
our school
24
Negating nested quantifiers
xy ( xy 1)
xy ( xy 1)
xy ( xy 1)
xy ( xy 1)
• There does not exist a woman who has taken
a flight on every airline in the world
waf ( p ( w, f ) q ( f , a ))
waf ( p ( w, f ) q ( f , a ))
where p(w,f) is “w has taken f”, and q(f,a) is “f
is a flight on a
25
Let L(x, y) be the statement "x loves y," where the domain
for both x and y consists of all people in the world.
Use quantifiers to express each of these statements.
a) Everybody loves Jerry.
b) Everybody loves somebody.
c) There is somebody whom everybody loves.
d) Nobody loves everybody.
e) There is somebody whom Lydia does not love.
t) There is somebody whom no one loves.
g) There is exactly one person whom everybody loves.
h) There are exactly two people whom Lynn loves.
i) Everyone loves himself or herself.
j) There is someone who loves no one besides himself
or herself.
Let P (x, y) be the statement "student x has
taken class y," where the domain for x
consists of all students in your class and
for y consists of all computer science
courses at your school. Express each of
these quantifications in English.