Chap2-Predicates and Quantifiers
Chap2-Predicates and Quantifiers
We can also have statements that involve more than one variable. For instance,
1 Introduction consider the statement x = y + 3 We can denote this statement by Q(x, y), where x
and y are variables and Q is the predicate. When values are assigned to the variables
Propositional logic, studied previously, cannot adequately express the meaning of x and y, the statement Q(x, y) has a truth value.
all statements in mathematics and in natural language. For example, suppose that
we know that ”Every computer connected to the university network is functioning Example 2 : Let Q(x, y) denote the statement x = y + 3. What are the truth values
properly.” of the propositions Q(1, 2) and Q(3, 0) ?
No rules of propositional logic allow us to conclude the truth of the statement
”MATH3 is functioning properly,” where MATH3 is one of the computers connected To obtain Q(1, 2), set x = 1 and y = 2 in the statement Q(x, y). Hence, Q(1, 2)
to the university network. Likewise, we cannot use the rules of propositional logic to is the statement 1 = 2 + 3 which is false. The statement Q(3, 0) is the proposition
conclude from the statement ”CS2 is under attack by an intruder” where CS2 is a 3 = 0 + 3 which is true.
computer on the university network, to conclude the truth of ”There is a computer
on the university network that is under attack by an intruder.” Example 3 : Let R(x, y, z) denote the statement ”x + y = z”. What are the truth
values of the propositions R(1, 2, 3) and R(0, 0, 1) ?
In this section we will introduce a more powerful type of logic called predicate
logic. We will see how predicate logic can be used to express the meaning of a wide In general, a statement involving the n variables x1 , x2 , . . . , xn can be denoted by
range of statements in mathematics and computer science in ways that permit us to P (x1 , x2 , . . . , xn ).
reason and explore relationships between objects.
Remark : Propositional functions occur in computer programs :
Example :
2 Predicates Consider the statement if x > 0 then x := x + 1.
”Statements” in Logic of predicate is an ”expression” involving variables such as When this statement is encountered in a program, the value of the variable x at that
”computer x is under attack by an intruder”, ”x > 3”, or ”x = y + 3”. point in the execution of the program is inserted into P (x), which is ”x > 0”. If
The statement ”x is greater than 3” has two parts : P (x) is true for this value of x, the assignment statement x := x + 1 is executed, so
the value of x is increased by 1. If P (x) is false for this value of x, the assignment
1. First part : the variable x, is the subject of the statement. statement is not executed, so the value of x is not changed.
2. Second part : ”is greater than 3” refers to the property that the subject x has.
Definition 1. A predicate refers to a property that a subject of a statement can have.
3 Quantifiers
We can denote the statement ”x is greater than 3” by P (x), where P denotes the
predicate ”is greater than 3” and x is the variable. When the variables in a propositional function are assigned values, the resulting
The statement P (x) is also said to be the value of the propositional function P at statement becomes a proposition with a certain truth value. However, there is ano-
x. Once a value has been assigned to the variable x, the statement P (x) becomes a ther importantway, called quantification, to create a proposition from a propositional
proposition and has a truth value. function. Quantification expresses the extent to which a predicate is true over a range
of elements. In English, the words all, some, many, none, and few are used in quanti-
Once a value has been assigned to the variable x, the statement P (x) becomes a fications. We will focus on two types of quantification here : universal quantification,
proposition and has a truth value. which tells us that a predicate is true for every element under consideration, and
existential quantification, which tells us that there is one or more element under
1
consideration for which the predicate is true. The area of logic that deals with pre- Definition 3. The existential quantification of P (x) is the proposition : ”There exists
dicates and quantifiers is called the predicate calculus. an element x in the domain such that P (x).”
Definition 2. The universal quantification of P (x) is the statement : We use the notation ∃xP (x) for the existential quantification of P (x). Here ∃ is
called the existential quantifier.
”P (x) for all values of x in the domain”
The notation ∀xP (x) denotes the universal quantification of P (x). Here ∀ is called A domain must always be specified when a statement ∃xP (x) is used. Furthermore,
the universal quantifier.We read ∀xP (x) as ”for all xP (x)” or ”for every xP (x)”. the meaning of ∃xP (x changes when the domain changes. Without specifying the
An element for which P (x) is false is called a counterexample of ∀xP (x). domain, the statement ∃xP (x) has no meaning.
Remarks : Besides the phrase ”there exists” we can also express existential quantification in
many other ways, such as by using the words ”for some”, ”for at least one” or ”there
1. The domain (or also the domain of discourse) specifies all the possible values is”. The existential quantification ∃xP (x) is read as ”There is an x such that P(x)”,
of the variable x ”There is at least one x such that P(x)”, or ”For some xP (x)”.
2. If the domain is empty, the ∀xP (x) is True for any propositional function P (x)
because there are no elements x in the domain for which P () is false. Example :
A statement ∀xP (x) is false, where P (x) is a propositional function, if and only if Let P (x) denote the statement ”x > 3”. What is the truth value of the quantification
P (x) is not always true when x is in the domain. One way to show that P (x) is not ∃xP (x), where the domain consists of all real numbers ?
always true when x is in the domain is to find a counterexample to the statement Solution : Because ”x > 3” is sometimes true -for instance, when x = 4 - the
∀xP (x). Note that a single counterexample is all we need to establish that ∀xP (x) existential quantification of P (x), which is ∃xP (x), is true.
is false.
Observe that the statement ∃xP (x) is false if and only if there is no element x in the
Examples
domain for which P (x) is true. That is, ∃xP (x) is false if and only if P (x) is false for
every element of the domain.
1. Let P (x) be the statement ”x + 1 > x.” What is the truth value of the quanti- Example : Let Q(x) denote the statement ”x = x + 1”. What is the truth value of
fication ∀xP (x), where the domain consists of all real numbers ? the quantification ∃xQ(x), where the domain consists of all real numbers ?
Solution : Because P (x) is true for all real numbers x, the quantification ∀xP (x) Solution : Because Q(x) is false for every real number x, the existential quantification
is true. of Q(x), which is ∃xQ(x), is false.
2. Let Q(x) be the statement ”x < 2”. What is the truth value of the quantification
∀xQ(x), where the domain consists of all real numbers ? Remark :
Solution : Q(x) is not true for every real number x, because, for instance, Q(3) If the domain is empty, then ∃xQ(x) is false whenever Q(x) is a propositional
is false. That is, x = 3 is a counterexample for the statement ∀xQ(x). Thus function because when the domain is empty, there can be no element x in the
∀xQ(x) is false. domain for which Q(x) is true.
3. Suppose that P (x) is ”x2 > 0”. To show that the statement ∀xP (x) is false When all elements in the domain can be listed - say, x1 , x2 , . . . , xn - the existential
where the universe of discourse consists of all integers, we give a counte- quantification ∃xP (x) is the same as the disjunction P (x1 ) ∨ P (x2 ) ∨ . . . ∨ P (xn ),
rexample. We see that x = 0 is a counterexample because x2 = 0 when x = 0, because this disjunction is true if and only if at least one of P (x1 ), P (x2 ), . . . , P (xn )
so that x2 is not greater than 0 when x = 0. is true.
When all the elements in the domain can be listed - say, x1 , x2 , . . . , xn , it follows that
the universal quantification ∀xP (x) is the same as the conjunction P (x1 ) ∧ P (x2 ) ∧ Example :
. . . ∧ P (xn ), because this conjunction is true if and only if P (x1 ), P (x2 ), ..., P (xn ) are What is the truth value of ∃xP (x) , where P (x) is the statement ”x2 > 10” and the
all true. universe of discourse consists of the positive integers not exceeding 4 ?
Example : What is the truth value of ∀xP (x), where P (x) is the statement Solution : Because the domain is {1, 2, 3, 4}, the proposition ∃xP (x) is the same as
”x2 < 10” and the domain consists of the positive integers not exceeding 4 ? the disjunction P (1) ∨ P (2) ∨ P (3) ∨ P (4).
Solution : The statement ∀xP (x) is the same as the conjunction P (1) ∧ P (2) ∧ P (3) ∧ Because P (4), which is the statement ”42 > 10” is true, it follows that ∃xP (x) is
P (4). true.
2
Precedence of Quantifiers 4 Translating from English into Logical Expres-
The quantifiers ∀ and ∃ have higher precedence than all logical operators from pro- sions
positional calculus. For example, ∀xP (x)∨Q(x) is the disjunction of ∀xP (x) Or Q(x).
In other words, it means (∀xP (x)) ∨ Q(x) rather than ∀x(P (x) ∨ Q(x)). Translating sentences in English (or other natural languages) into logical expres-
sions is a crucial task in mathematics, logic programming, artificial intelligence,
software engineering, and many other disciplines.
Binding Variables
Example 1 :
When a quantifier is used on the variable x, we say that this occurrence of the
Express the statement ”Every student in this class has studied calculus” using
variable is bound. An occurrence of a variable that is not bound by a quantifier or
predicates and quantifiers.
set equal to a particular value is said to be free. All the variables that occur in a
Solution : First, we rewrite the statement so that we can clearly identify the
propositional function must be bound or set equal to a particular value to turn it
appropriate quantifiers to use. Doing so, we obtain : ”For every student in this class,
into a proposition. This can be done using a combination of universal quantifiers,
that student has studied calculus.
existential quantifiers, and value assignments.
Next, we introduce a variable x so that our statement becomes ”For every student
x in this class, x has studied calculus.” Continuing, we introduce C(x), which is the
The part of a logical expression to which a quantifier is applied is called the scope
statement ”x has studied calculus.”
of this quantifier. Consequently, a variable is free if it is outside the scope of all
Consequently, if the domain for x consists of the students in the class, we can
quantifiers in the formula that specify this variable.
translate our statement as : ∀xC(x).
Examples :
If we change the domain to consist of all people, we will need to express our
statement as ”For every person x, if person x is a student in this class then x has
— In the statement ∃x(x + y = 1), the variable x is bound by the existential quan-
studied calculus.”
tification ∃x, but the variable y is free because it is not bound by a quantifier
If S(x) represents the statement that ”person x is in this class”, we see that our
and no value is assigned to this variable. This illustrates that in the statement
statement can be expressed as : ∀x(S(x) → C(x)).
∃x(x + y = 1), x is bound, but y is free.
— In the statement ∃x(P (x) ∧ Q(x)) ∨ ∀xR(x), all variables are bound. The scope
Attention : Our statement cannot be expressed as ∀x(S(x) ∧ C(x)) because this
of the first quantifier, ∃x, is the expression P (x) ∧ Q(x) because ∃x is applied
statement says that all people are students in this class and have studied calculus !.
only to P (x) ∧ Q(x), and not to the rest of the statement. Similarly, the scope
of the second quantifier, ∀x, is the expression R(x). That is, the existential
quantifier binds the variable x in P (x) ∧ Q(x) and the universal quantifier ∀x Example 2 :
binds the variable x in R(x). Observe that we could have written our statement Express the statements ”Some student in this class has visited Mexico” and ”Every
using two different variables x and y, as ∃x(P (x) ∧ Q(x)) ∨ ∀yR(y), because the student in this class has visited either Canada or Mexico” using predicates and
scopes of the two quantifiers do not overlap. quantifiers.
The meaning of the universal quantifier is summarized in table 1.
Solution : The statement ”Some student in this class has visited Mexico” means
that ”There is a student in this class with the property that the student has visited
Statement When True ? When False ?
Mexico.” We can introduce a variable x, so that our statement becomes ”There is a
∀xP (x) P (x) is true for There is an x for student x in this class having the property that x has visited Mexico.”
every x which P (x) is false. We introduce M (x), which is the statement ”x has visited Mexico.” If the domain
∃xP (x) There is an x for P (x) is false for for x consists of the students in this class, we can translate this first statement as
which P (x) is true every x. ∃xM (x).
Table 1 – Meaning of the universal quantifier However, if we are interested in people other than those in this class, we look at
the statement a little differently. Our statement can be expressed as ”There is a
3
person x having the properties that x is a student in this class and x has visited your class who has not taken a course in calculus”. And this is simply the exis-
Mexico.” tential quantification of the negation of the original propositional function : ∃x¬P (x).
In this case, the domain for the variable x consists of all people. We introduce S(x)
to represent ”x is a student in this class”. Our solution becomes ∃x(S(x) ∧ M (x)) Consider the proposition ”There is a student in this class who has taken a course
because the statement is that there is a person x who is a student in this class and in calculus”. This is the existential quantification ∃xQ(x), and the domain consists
who has visited Mexico. to students in your class.
Attention : The negation of this statement is the proposition ”It is not the case that there is
Our statement cannot be expressed as ∃x(S(x) → M (x)), which is true when there a student in this class who has taken a course in calculus”. This is equivalent to
is someone not in the class because, in that case, for such a person x, S(x) → M (x) ”Every student in this class has not taken calculus” which is just the universal
becomes either F → T or F → F , both of which are true. quantification of the negation of the original propositional function, or, phrased in
the language of quantifiers : ∀x¬Q(x).
Similarly consider : ”For every x in this class, x has the property that x has visited
Mexico or x has visited Canada.”
Table 3 summarizes DeMorgan ’s Law.
We let C(x) be ”x has visited Canada”.
if the domain for x consists of the students in this class, this second statement can
be expressed as ∃x(C(x) ∨ M (x)). Negation Equivalent State- When is Negation When is False
ment True ?
However, if the domain for x consists of all people, our statement can be expressed ¬∃xP (x) ∀x¬P (x) For every x, P (x) is There is an x for
as ”For every person x, if x is a student in this class, then x has visited Mexico false which P (x) is True
or x has visited Canada”. Thus the statement can be expressed as : ∀x(S(x) → ¬∀xP (x) ∃x¬P (x) There is an x for P (x) is True for
(C(x) ∨ M (x))). which P (x) is false every x
Example :
Consider the negation of the statement ”Every student in your class has taken a 6.2 Exercise 2 :
course in calculus”.
This statement can be expressed as : ∀xP (x), where P (x) is the statement ”x has Express the following statement using quantifiers : ”All hummingbirds are richly
taken a course in calculus” and the domain consists of the students in your class. colored”, ”No large birds live on honey”, ”Birds that do not live on honey are dull
The negation of this statement is ”It is not the case that every student in your in color” and ”Hummingbirds are small.
class has taken a course in calculus”. This is equivalent to ”There is a student in The domain consists of all birds,
4
7 Nested Quantifiers Statement When True ? When False ?
∀x∀yP (x, y) P (x, y) is true for every There is a pair x, y for
Definition 5. Two quantifiers are nested if one is within the scope of the other. or pair x, y. which P (x, y) is false.
∀y∀xP (x, y)
Example 1 : ∀x ∃y (x + y = 0). This statement means that for every real number
x, it exists a real number y such that x + y = 0. ∀x∃yP (x, y) For every x, there is y for There is x for which
which P (x, y) is true P (x, y) is false for every y.
Example 2 : Translate into English the statement : ∀x ∀y ((x > 0) ∧ (y < 0) −→ ∃x∀yP (x, y) There is x for which For every x, there is y for
(xy < 0)) where the domain for both variables consists of all real numbers. P (x, y) is True for every y which P (x, y) is false
∃x∃yP (x, y) There is a pair x, y for P (x, y) is fale for every
This statement says that for every real number x and for every real number y, if or which P (x, y) is true pair x, y.
x > 0 and y < 0, then xy < 0. That is, this statement says that for real numbers x ∃y∃xP (x, y)
and y, if x is positive and y is negative, then xy is negative. This can be stated more
succinctly as ”The product of a positive real number and a negative real number is Table 3 – Quantifications of Two Variables.
always a negative real number.”
the quantifiers is important, unless all the quantifiers are universal quantifiers or all
THINKING OF QUANTIFICATION AS LOOPS : In working with quanti- are existential quantifiers.
fications of more than one variable, it is sometimes helpful to think in terms of nested Example 1 : Let P (x, y) be the statement ”x + y = y + x”. What are the truth
loops : values of the quantifications ∀x∀yP (x, y) and ∀y∀xP (x, y) where the domain for all
1. To see whether ∀x ∀y P (x, y) is true, we loop through the values for x, and for variables consists of all real numbers ?
each x we loop through the values for y. If we find that P (x, y) is true for all
values for x and y, we have determined that ∀x ∀y P (x, y) is true. If we ever hit The quantification ∀x∀yP (x, y) denotes the proposition ”For all real numbers x, for
a value x for which we hit a value y for which P (x, y) is false, we have shown all real numbers y, x + y = y + x. Because P (x, y) is true for all real numbers x and
that ∀x ∀y P (x, y) is false. y (it is the commutative law for addition).
2. To determine whether ∀x ∃y P (x, y) is true, we loop through the values for x.
For each x we loop through the values for y until we find a y for which P (x, y) Note that the statement ∀y∀xP (x, y) says ”For all real numbers y, for all real
is true. If for every x we hit such a y, then ∀x ∃y P (x, y) is true ; if for some x numbers x, x + y = y + x.” This has the same meaning as the statement ”For all
we never hit such a y, then ∀x ∃y P (x, y) is false. real numbers x, for all real numbers y, x + y = y + x.” That is, ∀x∀yP (x, y) and
∀y∀xP (x, y) have the same meaning.
3. To see whether ∃ x ∀y P (x, y) is true, we 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 we find such an x, we know that ∃ x ∀y P (x, y) is true. If we never Example 2 : Let Q(x, y) denote ”x + y = 0”. What are the truth values of the
hit such an x, then we know that ∃ x ∀y P (x, y) is false. quantifications ∃y∀xQ(x, y) and ∀x∃yQ(x, y) , where the domain for all variables
consists of all real numbers ?
4. To see whether ∃x ∃y P (x, y) is true, we loop through the values for x, where The quantification ∃y∀xQ(x, y) denotes the proposition ”There is a real number y
for each x we loop through the values for y until we hit an x for which we hit such that for every real number x, Q(x, y). No matter what value of y is chosen,
a y for which P (x, y) is true. The statement ∃x ∃y P (x, y) is false only if we there is only one value of x for which x + y = 0. Because there is no real number y
never hit an x for which we hit a y such that P (x, y) is true. such that x + y = 0 for all real numbers x, the statement ∃y∀xQ(x, y) is false.
7.1 Orders of Quantifiers The quantification ∀x∃yQ(x, y) denotes the proposition ”For every real number x
there is a real number y such that Q(x, y).” Given a real number x, there is a real
Many mathematical statements involve multiple quantifications of propositional number y such that x + y = 0 ; namely, y = −x. Hence, the statement ∀x∃yQ(x, y)
functions involving more than one variable. It is important to note that the order of is true.
5
7.2 Negating Nested Quantifiers 8. All fruits are eaten by all students.
Statements involving nested quantifiers can be negated by successively applying
the rules for negating statements involving a single quantifier (De Morgan’s law).
Example 1 : Express the negation of the statement ∀x∃y(xy = 1) so that no 9. Some fruits are eaten by some students.
negation precedes a quantifier. ¬∀x∃y(xy = 1) ≡ ∃x¬∃y(xy = 1) ≡ ∃x∀y¬(xy = 1)
thus the statement is equivalent to ∃x∀y(xy 6= 1)
14. All neither wise nor strong students do not eat banana.
15. For all student x and all fruits y : if x is wise and y not red, then x does not
eat y.
4. Some students eat all fruits.
16. If a student either strong or not wise , then he eats some red juicy fruits.
5. Jack eats all fruits.
6. Some students eat orange. 17. There exists a not wise or strong student that eat all fruits.
7. Harry does not eat banana. 18. Some fruits are eaten by all wise and strong students.
6
19. some wise students do not eat some not juicy fruits. 30. ∃y, ∀x : R(y) ∨ ¬C(y) ∧ [W (x) −→ T (x, y)].
20. some juicy or not red fruits are eaten by all not strong students. 31. ¬∀y : ¬C(x) −→ R(y).
Exercise 2 :
22. Not all students are wise or strong.
P (x, y) :”x bites y” , B(x) :”x is black” ,F (x) ”x is furry”. G(x) :”x is grumpy”.
C(x) : ”x is clumsy”. the domain for x and y are all cats.
23. No red fruits is not juicy. Convert from symbolic to English and vice versa.
28. ¬∀x, ∃y : ¬W (x) ∧ ¬H(x) −→ T (x, y). 6. All non black cats bite all grumpy cats.
29. ∃x, ∃y : H(x) ∧ ¬C(y) ∧ T (x, y). 7. All grumpy cats are bitten by all non black cats.
7
8. All cats are neither non black nor bite Catoo. 19. Some neither grumpy nor clumsy cats bite all either black or furry cats.
9. All cats are grumpy and bite all cats. 20. All neither grumpy nor clumsy cats are bitten by some either black or furry
cats.
10. All cats are not black or bite all furry cats .
21. Some neither grumpy nor clumsy cats do not bite all cats.
14. Some cats bite the clumsy black Catoo . 25. ∃x : P (x, Catoo) ∧ B(x).
15. Some furry cats are not bitten by the non furry Fifi. 26. ∀x, ∀y : ¬B(x) ∧ ¬P (x, y).
16. Some not furry black cats bite some cats. 27. ∀x, ∀y : ¬B(x) −→ ¬P (x, y).
17. There is a non clumsy cat such that it bites some black cats. 28. ∀x, ∀y : ¬P (x, y) −→ ¬B(x).
18. Some black grumpy cats bite all cats. 29. ∀x, ∀y : ¬B(y) −→ ¬P (x, y).
8
30. ∀y, ∀x : ¬B(y) −→ ¬P (x, y). 41. ¬∀x : B(x) −→ ¬F (x).
31. ∀x, ∃y : G(x) ∧ C(x) −→ P (x, y) ∧ F (y). 42. ¬∀x∀y : B(x) ∧ ¬G(y) −→ P (x, y).
Exercise 3 :
Find if the statement true or false. Justify your answer.
37. ∃y, ∀x : B(y) ∧ P (x, y).
1. ∃x ∈ Z, ∀y ∈ Z + : xy < 0.
9
√
5. ∀y ∈ Z+ , ∃x ∈ Z+ : y = x + 2. 16. ∀x, y ∈ Z : x2 + y 2 > 0.
6. ∃a ∈ Z, ∀b ∈ Z : a + b = 2. x2 − 2y
17. ∀x ∈ Z, ∃y ∈ Z : = 1.
y2 + 1
r
x
7. ∃x ∈ R : √ is rational but not integer. √
2 18. ∃x ∈ Z, ∀y ∈ R : xy 2 = 0.
√ √
8. ∀p ∈ N : if p is divisible by 5, then 2p − 1 is prime. 19. ∀x ∈ Z, ∀y ∈ Z : xy = x y.
9. ∀n ∈ Z + , ∃t ∈ Q+ : t2 − n − 1 = 0. 20. ∀x ∈ Z, ∃y ∈ Z : xy = 1.
11. ∃x, y ∈ Z : x − y = y. √
22. ∃x ∈ A : x2 − x = 0 where A= 0,1,2.
13. ∀x ∈ Z, ∃y ∈ Z : x − y = y. 24. ∀x ∈ Z, ∃y ∈ Z − : x2 − y 2 = 9.
14. ∃x ∈ R, ∀y ∈ R : x − y = y.
25. ∃x ∈ R, ∀y ∈ R : y < 5 −→ y 2 − x2 ≥ 0.
x
15. ∃x, y ∈ Z : =x+y . 26. ∀x ∈ Z : (x2 + 2x − 3 = 0) .
y
10
27. ∃x ∈ Z∃k ∈ Z : (x = 2k + 1) ∧ (x2 − 2x + 5 ≤ 0).
x
28. ∃m ∈ R, ∀x ∈ Z + : < m.
x+1
11