Lecture 4 (Predicates and Quantifiers)
Lecture 4 (Predicates and Quantifiers)
Quantifiers
CS131 Fall 24
Preethi Narayanan
Propositions are true or false
• We are in Boston
• 3 > 17
• 11 and 29 are both prime
Predicates could be true or could be false
• Under what circumstances could a logical statement be either
true or false?
• If it contains a variable
• A predicate aka propositional function is a logical statement
whose truth value is a function of one or more variables
• In other words, a function with a True or False output
Predicates
• We are in c
• c = Boston
• c = Albuquerque, New Mexico
• x > 17
• x=3
• x = 20
• p1 and p2 are both prime
• p1 = 11, p2 = 29
• p1 = 5, p2 = 6
How to write it
• Let P(x) be a propositional function (aka predicate) dependent
on the variable x.
• We can also have predicates dependent on multiple variables
• Ex: Q(y, z)
• We need to define our variable domain:
• x is a city
• x is an animal
• x is an integer (x ℤ)
• If S is a set, x S means that x is a member of the set S
Turning predicates into propositions
P(x) is a predicate. How do we make it a proposition?
1. Assignment: P(7) is true or false
• (as long as 7 is within our variable domain)
Quantified statements
• “All students in this room like cats”
• “There is a student in this room that likes cats”
• “There is exactly one student in this room that likes cats”
Universal Quantification ()
• correct
• incorrect
Turning predicates into propositions
P(x) is a predicate. How do we make it a proposition?
1. Assignment: P(7) is true or false
• (as long as 7 is within our variable domain)
2. Quantification:
• is true or false
• is true or false
• is true or false
Question:
Which of the following are universally quantified (multiple correct
answers)
A) ∀x in N: (x + 1) in N
B) Everyone on the Celtics is over 6' tall
C) I had a sandwich for lunch
D) ∃x in N: x / 5 in Q
E) It's raining somewhere
Question:
Which of the following are existentially quantified (multiple correct
answers)
Proposition
Predicate
Free vs Bound Variables
Bound
Bound Free
Turning predicates into propositions
P(x) is a predicate. How do we make it a proposition?
1. Assignment: P(7) is true or false
• (as long as 7 is within our variable domain)
2. Quantify the predicate such that there are no free variables
Alternatively, quantify the predicate such that all variables are bound
• is true or false
• is true or false
• is true or false
• is true or false
Variable Domains
• A variable can only take values from a specified set
• That set is called the variable’s domain
• e.g. the domain of Propositional variables is {T, F}
• Domains matter!
• x – 1 0 is true for all x + but not for all x
Restricting Variable Domains
• How do I restrict a predicates domain?
• Example:
• y the set of all dogs, but y is not a golden retriever
• x , but x > 0
(x > 0) ∧ (x2 + 3 = 7)
• Why not
“There exists an integer x such that if x > 0, then x 2 + 3 = 7 ”?
• (x > 0) (x2 + 3 = 7) is true (in the wrong cases)
• F F is true
Example
x ∈ BU students
E(x): x is enrolled in the class
T(x): x took the test
1. Someone who is enrolled in the class took the test.
How would we write "Everyone who took the test is enrolled in the
class." ?
How would we write "At least one student who is enrolled in the class
did not take the test." ?
Negate: “There is a patient who took the medication and had migraines.”
∀x ∈ ℤ, ∃y ∈ ℤ : x > y
∃y ∈ ℤ, ∀x ∈ ℤ : x > y
Nested Quantifiers
Ex: F(x, y): x is friends with y
A) ∀x ∈ ℤ, ∃y ∈ ℤ : x + y = 0
B) ∃y ∈ ℤ, ∀x ∈ ℤ : x + y = 0
C) Both are true
Question:
Express “every integer has a prime factor” using quantifiers and
the predicate P(x, y): “y is a prime factor of x”.
A) ∀x ∈ ℤ, ∃y ∈ ℤ: P(x, y)
B) ∃x ∈ ℤ, ∀y ∈ ℤ: P(x, y)
C) Both work