Logic Note
Logic Note
Definition
A predicate is a function. It takes some variable(s) as arguments; it
returns either True or False (but not both) for each combination of the
argument values.
Example:
P(x, y) : “x + 2 = y” is a predicate.
It has two variables x and y;
Universe of Discourse: x is in {1, 2, 3}; y is in {4, 5, 6}.
Example
Example
Suppose Q(x, y) : “x + y > 4”, where the universe of discourse is all
integer pairs.
Definition
Suppose P(x) is a predicate on some universe of discourse.
The universal quantification of P(x) is the proposition:
“P(x) is true for all x in the universe of discourse”.
We write ∀xP(x), and say ”for all x, P(x)”.
∀xP(x) is TRUE if P(x) is true for every single x.
∀xP(x) is FALSE if there is an x for which P(x) is false.
Example:
P(x) : “x + 2 = 5, universe of discourse: {1, 2, 3}.
More example:
A(x) : “x = 1” B(x) : “x > 2” C(x) : “x < 2”
Universe of discourse is {1, 2, 3}.
True or False?
a) ∀ x (C(x) → A(x))
b) ∀ x (C(x) ∨ B(x))
Definition
Suppose P(x) is a predicate on some universe of discourse.
The existential quantification of P(x) is the proposition:
“P(x) is true for some x in the universe of discourse.”
We write ∃ x P(x), and say “there exists x, P(x)”.
∃ x P(x) is TRUE if P(x) is true for any x.
∃ x P(x) is FALSE if for every x, P(x) is false.
Example:
P(x) : “x + 2 = 5”, universe of discourse: {1, 2, 3}.
True or False?
a) ∃ x (C(x) → A(x))
b) ∃ x B(x)
Example:
A(x): “x lives in Amherst.”
B(x): “x is a CSE 191 student.”
C(x): “x has a good GPA.”
D(x): “x majors in computer science.”
Universe of discourse: all UB students.
Quantifier negation
Example:
Consider the following two propositions:
Not every UB student majors in computer science: ¬ ∀x D(x).
There is UB student who does not major in computer science:
∃ x ¬ D(x).
Example:
Consider the following two propositions:
There is no UB student living in Amherst: ¬ ∃ x A(x).
Every UB student lives in a town other than Amherst: ∀ x ¬ A(x).
Nested Quantifier
Note: The variable is defined by its position in P(∗, ∗). We might use
different names for them. So when we write P(y, w), we are saying y
loves w.
P(Alice, CSE191): Alice loves CSE191.
∃ y P(Alice, y): Alice loves a UB CSE course.
∃ x (P(x, CSE191) ∧ P(x, CSE250)):
A student in this class loves both CSE 191 and CSE 250.
∃ x ∃ y ∀ z ((x 6= y) ∧ (P(x, z) → P(y, z))):
There are two different students x and y in this class such that if x
loves a UB CSE course, then y loves it as well.
c Xin He (University at Buffalo) CSE 191 Discrete Structures 14 / 22
Example:
A(x): “x lives in Amherst.”
B(x): “x is a CSE 191 student.”
C(x, y): “x and y are friends.”
D(x): “x majors in computer science.”
Universe of discourse: all UB students.
Either there is a computer science major who has a friend living in Amherst,
or all CSE 191 students major in computer science:
∃ x (D(x) ∧ ∃ y (A(y) ∧ C(x, y))) ∨ ∀ x (B(x) → D(x))
c Xin He (University at Buffalo) CSE 191 Discrete Structures 16 / 22
Compare examples
Example:
A(x): “x lives in Amherst.”
B(x): “x is a CSE 191 student.”
C(x, y): “x and y are friends.”
D(x): “x majors in computer science.”
Universe of discourse: all UB students.
Consider the following two statements:
∀ x ∃y(C(x, y) ∧ B(y)):
All UB students have friends taking CSE191.
∃ y ∀ x (C(x, y) ∧ B(y)):
There is a UB student who is the friend of all UB students and
takes CSE 191.
Do they mean the same thing? NO.
Example:
Let the universe of discourse be pairs of real numbers.
∀ x ∃ y (y > x) ≡ True
But
∃ y ∀ x (y > x) ≡ False
In general:
∀x∀yP(x, y) = T iff ∀y∀xP(x, y) = T.
∃x∃yP(x, y) = T iff ∃y∃xP(x, y) = T.
If ∃x∀yP(x, y) = T, then ∀y∃xP(x, y) = T.
If ∀y∃xP(x, y) = T, ∃x∀yP(x, y) might be F.
c Xin He (University at Buffalo) CSE 191 Discrete Structures 18 / 22
Compare examples
Example:
A(x): “x lives in Amherst.”
B(x): “x is a CSE 191 student.”
C(x, y): “x and y are friends.”
D(x): “x majors in computer science.”
Universe of discourse: all UB students.
Example:
∀ x (P(x) ∨ ¬ P(x)) ≡ True
But the truth value of
∀ x P(x) ∨ ¬ P(x)
depends on the truth value of free variable x. (The second x is not
bounded by any quantifier.) So this formula is not even a
proposition!
Example:
A(x): “x lives in Amherst.”
B(x): “x is a CSE 191 student.”
C(x): “x has a good GPA.”
D(x): “x majors in computer science.”
Universe of discourse: all UB students.
If all computer science majors have friends taking CSE191, then there
are a pair of friends both taking CSE191.
∀ x (D(x) → ∃ y (B(y) ∧ C(x, y))) → ∃ x ∃ y (B(x) ∧ B(y) ∧ C(x, y))