Professional Documents
Culture Documents
Lecture 4: Predicates and Quantifiers Sets.: Zeph Grunschlag
Lecture 4: Predicates and Quantifiers Sets.: Zeph Grunschlag
Quantifiers; Sets.
Zeph Grunschlag
Copyright Zeph
Grunschlag, 2001-2002.
Announcements
HW1 due now
L4
Agenda
Predicates and Quantifiers
Existential Quantifier
Universal Quantifier
Sets
L4
Motivating example
Consider the compound proposition:
If Zeph is an octopus then Zeph has 8 limbs.
L4
Motivating example
A1: Let p = Zeph is an octopus and q =
Zeph has 8 limbs. The compound
proposition is represented by p q.
A2: True!
A3: Conditional always true when p is
false!
Q: Why is this not satisfying?
L4
Motivating example
A: We wanted this to be true because of the fact
that octopi have 8 limbs and not because of
some (important) non-semantic technicality in
the truth table of implication.
But recall that propositional calculus doesnt take
semantics into account so there is no way that
p could impact on q or affect the truth of pq.
Logical Quantifiers help to fix this problem. In
our case the fix would look like:
For all x, if x is an octopus then x has 8 limbs.
L4
Motivating example
Expressions such as the previous are built up from
propositional functions statements that have a
variable or variables that represent various
possible subjects. Then quantifiers are used to
bind the variables and create a proposition with
embedded semantics. For example:
For all x, if x is an octopus then x has 8 limbs.
there are two atomic propositional functions
P (x) = x is an octopus
Q (x) = x has 8 limbs
L4
Semantics
If logical propositions are to have meaning, they
need to describe something. Up to now,
propositions such as Johnny is tall, Debbie is 5
years old, and Andre is immature had no
intrinsic meaning. Either they are true or false,
but no more.
In order to endow such propositions with meaning,
we need to have a universe of discourse, i.e.
a collection of subjects (or nouns) about which
the propositions relate.
Q: What is the universe of discourse for the three
propositions above?
L4
Semantics
A: There are many answers. Here are some:
L4
Predicates
A predicate is a property or description of
subjects in the universe of discourse. The
following predicates are all italicized :
Johnny is tall.
The bridge is structurally sound.
17 is a prime number.
L4
someLinkedList.isEmpty()
isPrime(17)
10
Propositional Functions
By taking a variable subject denoted by symbols
such as x, y, z, and applying a predicate one
obtains a propositional function (or formula).
When an object from the universe is plugged in
for x, y, etc. a truth value results:
L4
11
Multivariable Predicates
Multivariable predicates generalize
predicates to allow descriptions of
relationships between subjects. These
subjects may or may not even be in the
same universe of discourse. For example:
L4
12
Multivariable Predicates
A: Again, many correct answers. The most
obvious answers are:
L4
13
Multivariable Propositional
Functions
The multivariable predicates, together with
their variables create multivariable
propositional functions. In the above
examples, we have the following
generalizations:
x is taller than y
a is greater than one of b, c
x is at least n inches taller than y
14
Quantifiers
There are two quantifiers
Existential Quantifier
reads there exists
Universal Quantifier
reads for all
Each is placed in front of a propositional
function and binds it to obtain a
proposition with semantic value.
L4
15
Existential Quantifier
L4
16
Existential Quantifier.
Example
Consider a universe consisting of
Leo: a lion
Jan: an octopus with all 8 tentacles
Bill: an octopus with only 7 tentacles
17
Existential Quantifier.
Example
A: True. Proposition is equivalent to
(P (Leo)Q (Leo) ) (P (Jan) Q (Jan) ) (P(Bill)Q (Bill) )
18
L4
19
Universal Quantifier.
Example
Consider the same universe and
propositional functions as before.
x ( P (x) Q (x ) )
Q: Is the proposition true or false?
L4
20
Universal Quantifier.
Example
A: False. The proposition is equivalent to
21
Illegal Quantifications
Once a variable has been bound, we cannot
bind it again. For example the expression
x ( x P (x) )
is nonsensical. The interior expression
(x P (x)) bounded x already and
therefore made it unobservable to the
outside. Going back to our example, the
English equivalent would be:
Everybody is an everybody is an octopus.
L4
22
Multivariate Quantification
Quantification involving only one
variable is fairly straightforward. Just
a bunch of ORs or a bunch of ANDs.
When two or more variables are
involved each of which is bound by a
quantifier, the order of the binding is
important and the meaning often
requires some thought.
L4
23
Parsing Example
A: True.
For any exists we need to find a positive
instance.
Since x is the first variable in the
expression and is existential, we need
a number that works for all other y, z.
Set x = 0 (want to ensure that y -x is
not too small).
Now for each y we need to find a positive
instance z such that y - x z holds.
Plugging in x = 0 we need to satisfy y
z so set z := y.
Q: Did we have to set z := y ?
L4
26
Parsing Example
A: No. Could also have used the
constant z := 0. Many other valid
solutions.
Q: Isnt it simpler to satisfy
x y z (y - x z )
by setting x := y and z := 0 ?
L4
27
Parsing Example
A: No, this is illegal ! The existence of
x comes before we know about y.
I.e., the scope of x is higher than the
scope of y so as far as y can tell, x is
a constant and cannot affect x.
A Java example helps explain this
point. To evaluate x y Q (x,y )
might do the following.
L4
28
29
Order matters
Set the universe of discourse to be
all natural numbers {0, 1, 2, 3,
}.
Let R (x,y ) = x < y.
Q1: What does x y R (x,y ) mean?
Q2: What does y x R (x,y ) mean?
L4
30
Order matters
R (x,y ) = x < y
A1: x y R (x,y ):
All numbers x admit a bigger number
y
A2: y x R (x,y ):
Some number y is bigger than all x
Q: Whats the true value of each
expression?
L4
31
Order matters
A: 1 is true and 2 is false.
x y R (x,y ): All numbers x admit a
bigger number y --just set y = x + 1
y x R (x,y ): Some number y is bigger
than all numbers x --y is never bigger
than itself, so setting x = y is a
counterexample
Q: What if we have two quantifiers of the
same kind? Does order still matter?
L4
32
33
L4
34
DeMorgan Revisited
Recall DeMorgans identities:
Conjunctional negation:
(p1p2pn) (p1p2pn)
Disjunctional negation:
(p1p2pn) (p1p2pn)
Existential negation:
x P(x ) x P(x )
L4
35
Negation Example
Compute: x y x2 y
In English, we are trying to find the opposite
of every x admits a y greater or equal to
xs square. The opposite is that some x
does not admit a y greater or equal to xs
square
Algebraically, one just flips all quantifiers
from to and vice versa, and negates the
interior propositional function. In our case
we get:
x y ( x 2 y ) x y x 2 > y
L4
36
Blackboard Exercises
Section 1.3
1.3.41) Show that the following
are logically equivalent:
(x A(x ))(x B(x ))
x,y A(x )B(y )
L4
37
Blackboard Exercises
Section 1.3
Need to show that
(x A(x ))(x B(x ))x,y A(x )
B(y )
is a tautology, so LHS and RHS must
always have same truth values.
L4
38
39
40
41
Sets
Curly braces { and } are used to denote
sets.
Java note: In Java curly braces denote arrays,
a data-structure with inherent ordering.
Mathematical sets are unordered so different
from Java arrays. Java arrays require that all
elements be of the same type. Mathematical
sets dont require this, however. EG:
L4
{ 11, 12, 13 }
{
,
,
{
,
,
}
, 11, Leo }
42
Sets
A set is defined only by the elements
which it contains. Thus repeating
an element, or changing the
ordering of elements in the
description of the set, does not
change the set itself:
L4
The integers:
Z = { -3, -2, -1, 0, 1, 2, 3, }
L4
44
L4
2 , , e, or anyirrationalnumber
45
-Notation
The Greek letter (epsilon) is used to denote that
an object is an element of a set. When crossed
out denotes that the object is not an element.
EG: 3 S reads:
3 is an element of the set S .
Q: Which of the following are true:
4.
3R
-3 N
-3 R
0 Z+
x xR
1.
2.
3.
L4
x2=-5
46
-Notation
A: 1, 3 and 4
1. 3 R. True: 3 is a real number.
2. -3 N. False: natural numbers dont
contain negatives.
3. -3 R. True: -3 is a real number.
4. 0 Z+. True: 0 isnt positive.
L4
47
-Notation
DEF: A set S is said to be a subset of the set T iff
every element of S is also an element of T.
This situation is denoted by
ST
A synonym of subset is contained by.
Definitions are often just a means of establishing a
logical equivalence which aids in notation. The
definition above says that:
ST
x (xS ) (xT )
We already had all the necessary concepts, but the
notation saves work.
L4
48
-Notation
When is used instead of , proper
containment is meant. A subset S of T
is said to be a proper subset if S is
not equal to T. Notationally:
ST
S T
(x S
xT )
L4
49
-Notation
A: is to , as < is to .
L4
50
L4
{}
51
Subset Examples
Q: Which of the following are true:
1.
2.
3.
4.
L4
NR
ZN
-3 R
{1,2} Z+
52
Subset Examples
A: 1, 4 and 5
1.
2.
3.
4.
L4
Cardinality
The cardinality of a set is the number
of distinct elements in the set. |S |
denotes the cardinality of S.
Q: Compute each cardinality.
1.
2.
3.
4.
L4
54
Cardinality
Hint: After eliminating the redundancies just
look at the number of top level commas
and add 1 (except for the empty set).
A:
1.
2.
3.
4.
L4
Cardinality
DEF: The set S is said to be finite if its
cardinality is a nonnegative integer.
Otherwise, S is said to be infinite.
EG: N, Z, Z+, R, Q are each infinite.
Note: Well see later that not all infinities
are the same. In fact, R will end up
having a bigger infinity-type than N, but
surprisingly, N has same infinity-type as
Z, Z+, and Q.
L4
56
Power Set
DEF: The power set of S is the set
of all subsets of S.
Denote the power set by P (S ) or by
2s .
The latter weird notation comes from
the following.
Lemma: | 2s | = 2|s|
L4
57
L4
58
Ordered n-tuples
Notationally, n-tuples look like sets except
that curly braces are replaced by
parentheses:
59
Ordered n-tuples
As opposed to sets, repetition and
ordering do matter with n-tuples.
L4
60
Cartesian Product
The most famous example of 2-tuples are points
in the Cartesian plane R2. Here ordered pairs
(x,y) of elements of R describe the coordinates
of each point. We can think of the first
coordinate as the value on the x-axis and the
second coordinate as the value on the y-axis.
DEF: The Cartesian product of two sets A and
B denoted by A B is the set of all ordered
pairs (a, b) where aA and bB .
Q: Describe R2 as the Cartesian product of two
sets.
L4
61
Cartesian Product
A: R2 = RR. I.e., the Cartesian plane is
formed by taking the Cartesian product
of the x-axis with the y-axis.
One can generalize the Cartesian
product to several sets simultaneously.
Q: If A = {1,2}, B = {3,4}, C = {5,6,7}
what is A B C ?
L4
62
Cartesian Product
A: A = {1,2}, B = {3,4}, C = {5,6,7}
A B C =
{ (1,3,5), (1,3,6), (1,3,7),
(1,4,5), (1,4,6), (1,4,7),
(2,3,5), (2,3,6), (2,3,7),
(2,4,5), (2,4,6), (2,4,7) }
Lemma: The cardinality of the Cartesian
product is the product of the cardinalities:
| A1 A2 An | = |A1||A2| |An|
Q: What does S equal?
L4
63
Cartesian Product
A: From the lemma:
|S | = |||S | = 0|S | = 0
There is only one set with no elements
the empty set therefore, S must
be the empty set .
One can also check this directly from
the definition of the Cartesian
product.
L4
64
Blackboard Exercise
Section 1.4
Prove the following:
If A B and B C then A C .
L4
65