P(x)

advertisement
Lecture 1.2: Equivalences, and
Predicate Logic*
CS 250, Discrete Structures, Fall 2011
Nitesh Saxena
*Adopted from previous lectures by Cinda Heeren, Zeph Grunschlag
Course Admin


Everyone receiving my emails?
Lecture slides worked okay?


Do you want me to post the pdf’s too?
Everyone knows how to access the course
web page?
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
2
Outline


Equivalences (contd.)
Predicate Logic (Predicates and Quantifiers)
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
3
Propositional Logic – Logical
Equivalence



p is logically equivalent to q if their truth tables are the
same. We write p  q.
In other words, p is logically equivalent to q if p  q is
True.
There are some famous laws of equivalence, which we
review next. Very useful in simplifying complex composite
propositions
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
4
Laws of Logical Equivalences
Rosen; page 27: Table 6








Identity laws
Like adding 0
Domination laws
Like multiplying by 0
Idempotent laws
Delete redundancies
Double negation
“I don’t like you, not”
Commutativity
Like “x+y = y+x”
Associativity
Like “(x+y)+z = y+(x+z)”
Distributivity
Like “(x+y)z = xz+yz”
De Morgan
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
5
De Morgan’s Law - generalized
De Morgan’s law allow for simplification of negations of
complex expressions
 Conjunctional negation:
(p1p2…pn)  (p1p2…pn)
“It’s not the case that all are true iff one is false.”

Disjunctional negation:
(p1p2…pn)  (p1p2…pn)
“It’s not the case that one is true iff all are false.”

Let us do a quick (white board) proof to show that
the law holds
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
6
Another equivalence example
if NOT (blue AND NOT red) OR red then…
(p  q)  q  p  q
(p  q)  q
8/18/2011

(p  q)  q

(p  q)  q
Double negation

p  (q  q)
Associativity

p  q
Lecture 1.2 - Equivalence, and
Predicate Logic
DeMorgan’s
Idempotent
7
Yet another example

Show that [p  (p  q)]  q is a tautology.

We use  to show that [p  (p  q)]  q  T.
[p  (p  q)]  q
 [p  (p  q)] q
 [(p  p)  (p  q)]q
substitution for 
distributive
 [ F  (p  q)]  q
 (p  q)  q
 (p  q)  q
 (p  q)  q
 p  (q  q )
 p  T
T
uniqueness
identity
substitution for 
De Morgan’s
associative
uniqueness
domination
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
8
Predicate Logic – why do we need it?
Proposition, YES or NO?
3+2=5
YES
X+2=5
NO
X + 2 <= 5 for any choice of X in {1, 2, 3}
X + 2 = 5 for some X in {1, 2, 3}
YES
YE
S
Propositional logic can not handle statements such
as the last two.
Predicate logic can.
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
9
Predicate Logic Example
…
Alicia eats pizza at least once a week.
Garrett eats pizza at least once a week.
Allison eats pizza at least once a week.
Gregg eats pizza at least once a week.
Ryan eats pizza at least once a week.
Meera eats pizza at least once a week.
Ariel eats pizza at least once a week.
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
10
Predicates -- Definition
…
Alicia eats pizza at least once a week.
Define:
P(x) = “x eats pizza at least once a week.”
Universe of Discourse - x is a student in cs250
A predicate, or propositional function, is a function that
takes some variable(s) as arguments and returns True or
False.
Note that P(x) is not a proposition, P(Ariel) is.
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
11
Predicates with multiple variables
Suppose Q(x,y) = “x > y”
Proposition, YES or NO?
Q(x,y)
Q(3,4)
NO
Q(x,9)
Predicate, YES or NO?
YES
Q(x,y)
YES
NO
Q(3,4)
NO
Q(x,9)
YES
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
12
The Universal Quantifier
Another way of changing a predicate into a proposition.
Suppose P(x) is a predicate on some universe of discourse.
The universal quantifier of P(x) is the proposition:
“P(x) is true for all x in the universe of discourse.”
We write it x P(x), and say “for all x, P(x)”
x P(x) is TRUE if P(x) is true for every single x.
x P(x) is FALSE if there is an x for which P(x) is false.
Ex: B(x) = “x is carrying a backpack,” x is a set of cs250 students.
x B(x)?
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
13
The Universal Quantifier - example
B(x) = “x is allowed to drive a car”
L(x) = “x is at least 16 years old.”
Universe of discourse
is people in this room.
Are either of these propositions true?
a)
b)
x (L(x)  B(x))
x B(x)
A: only a is true
B: only b is true
C: both are true
D: neither is true
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
14
The Existential Quantifier
Another way of changing a predicate into a proposition.
Suppose P(x) is a predicate on some universe of discourse.
The existential quantifier of P(x) is the proposition:
“P(x) is true for some x in the universe of discourse.”
We write it x P(x), and say “for some x, P(x)”
x P(x) is TRUE if there is an x for which P(x) is true.
x P(x) is FALSE if P(x) is false for every single x.
Ex. C(x) = “x has black hair,” x is a set of cs 250 students.
x C(x)?
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
15
The Existential Quantifier - example
B(x) = “x is wearing sneakers.”
L(x) = “x is at least 21 years old.”
Y(x)= “x is less than 24 years old.”
Universe of discourse
is people in this room.
Are either of these propositions true?
a)
b)
x B(x)
x (Y(x)  L(x))
A: only a is true
B: only b is true
C: both are true
D: neither is true
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
16
Predicates – more examples
L(x) = “x is a lion.”
F(x) = “x is fierce.”
C(x) = “x drinks coffee.”
Universe of discourse
is all creatures.
x (L(x)  F(x))
All lions are fierce.
Some lions don’t drink coffee.
x (L(x)  C(x))
Some fierce creatures don’t drink coffee.
x (F(x)  C(x))
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
17
Predicates – some more example
B(x) = “x is a hummingbird.”
L(x) = “x is a large bird.”
H(x) = “x lives on honey.”
R(x) = “x is richly colored.”
Universe of discourse
is all creatures.
All hummingbirds are richly colored.
x (B(x)  R(x))
No large birds live on honey.
x (L(x)  H(x))
Birds that do not live on honey are dully colored.
x (H(x)  R(x))
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
18
Quantifier Negation
Not all large birds live on honey.
x (L(x)  H(x))
x P(x) means “P(x) is true for every x.”
What about x P(x) ?
Not [“P(x) is true for every x.”]
“There is an x for which P(x) is not true.”
x P(x)
So, x P(x) is the same as x P(x).
x (L(x)  H(x))
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
19
Quantifier Negation
No large birds live on honey.
x (L(x)  H(x))
x P(x) means “P(x) is true for some x.”
What about x P(x) ?
Not [“P(x) is true for some x.”]
“P(x) is not true for all x.”
x P(x)
So, x P(x) is the same as x P(x).
x (L(x)  H(x))
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
20
Quantifier Negation
So, x P(x) is the same as x P(x).
So, x P(x) is the same as x P(x).
General rule: to negate a quantifier, move negation to the
right, changing quantifiers as you go.
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
21
Some quick questions




p  T =? (what law?)
p  T =? (what law?)
(p  q) = ? (what law?)
P(x) = “x >3”




P(x) is a proposition: yes or no?
P(3) is a proposition: yes or no? If yes, what is its value?
P(4) is True or False?
If the universe of discourse is all natural numbers, what is the
value of


8/18/2011
x P(x)
x P(x)
Lecture 1.2 - Equivalence, and
Predicate Logic
22
Today’s Reading and Next Lecture



Rosen 1.3 and 1.4
Please start solving the exercises at the end
of each chapter section. They are fun.
Please read 1.4 and 1.5 in preparation for the
next lecture
8/18/2011
Lecture 1.2 - Equivalence, and
Predicate Logic
23
Download