A (MATH1) - A (CS1) A (CS2) A (MATH1) Computer MATH1 Is Under Attack by An Intruder
A (MATH1) - A (CS1) A (CS2) A (MATH1) Computer MATH1 Is Under Attack by An Intruder
Introduction
In this section we will introduce a more powerful type of logic called predicate logic.
Predicates
Consider the statement: 𝑥𝑥 > 3. The statement has two parts:
1. the variable, 𝑥𝑥 and
2. the predicate, is greater than 3, > 3.
The statement "𝑥𝑥 is greater than 3”, 𝑥𝑥 > 3, can be denoted by 𝑃𝑃(𝑥𝑥). The statement 𝑃𝑃(𝑥𝑥) is said
to be the value of the propositional function 𝑃𝑃 at 𝑥𝑥. Once a value has been assigned to the
variable 𝑥𝑥, the statement 𝑃𝑃(𝑥𝑥) becomes a proposition and has a truth value.
EXAMPLE 1 Let 𝑃𝑃(𝑥𝑥) denote the statement “𝑥𝑥 > 3.” What are the truth values of 𝑃𝑃(4)
and 𝑃𝑃(2)?
Proposition Application Truth Value
𝑃𝑃(4) 𝟒𝟒 > 3 True
𝑃𝑃(2) 𝟐𝟐 > 3 False
EXAMPLE 2 Let 𝐴𝐴(𝑥𝑥) denote the statement “Computer 𝑥𝑥 is under attack by an intruder.”
Suppose that of the computers on campus, only CS2 and MATH1 are currently
under attack by intruders. What are the truth values of A(CS1), A(CS2), and
A(MATH1).
Proposition Application Truth
Value
A(CS1) Computer CS1 is under attack by an intruder. False
A(CS2) Computer CS2 is under attack by an intruder. True
A(MATH1) Computer MATH1 is under attack by an intruder. True
EXAMPLE 3 Let 𝑄𝑄(𝑥𝑥, 𝑦𝑦) denote the statement “𝑥𝑥 = 𝑦𝑦 + 3.” What are the truth values of
the propositions 𝑄𝑄(1,2) and 𝑄𝑄(3,0)?
Proposition Application Truth Value
𝑄𝑄(1,2) 1=2+3 False
𝑄𝑄(3,0) 3=0+3 True
In general, a statement involving the 𝑛𝑛 variables 𝑥𝑥1 , 𝑥𝑥2 , ⋯ , 𝑥𝑥𝑛𝑛 can be denoted by
A statement of the form 𝑃𝑃(𝑥𝑥1 , 𝑥𝑥2 , ⋯ , 𝑥𝑥𝑛𝑛 ) is the value of the propositional function 𝑃𝑃 at the 𝑛𝑛-
tuple (𝑥𝑥1 , 𝑥𝑥2 , ⋯ , 𝑥𝑥𝑛𝑛 ), and 𝑃𝑃 is also called an 𝑛𝑛-place predicate or a 𝑛𝑛-ary predicate.
1
Discrete Structures Lecture 4
CMSC 2123 1.4 Predicates and Quantifiers
Quantifiers
DEFINITION 1 The universal quantification of 𝑃𝑃(𝑥𝑥) is the statement
TABLE 1 Quantifiers
Statement When True? When False?
∀𝑥𝑥𝑥𝑥(𝑥𝑥) 𝑃𝑃(𝑥𝑥) is true for every x. There is an x for which 𝑃𝑃(𝑥𝑥) is false.
∃𝑥𝑥𝑥𝑥(𝑥𝑥) There is an x for which 𝑃𝑃(𝑥𝑥) is true. 𝑃𝑃(𝑥𝑥) is false for every x.
EXAMPLE 8 Let 𝑃𝑃(𝑥𝑥) be the statement “𝑥𝑥 + 1 > 𝑥𝑥. " What is the truth value of the
quantification ∀𝑥𝑥𝑥𝑥(𝑥𝑥), where the domain consists of all real numbers.
Solution: Because 𝑃𝑃(𝑥𝑥) is true for all real numbers x, the quantification
∀𝑥𝑥𝑥𝑥(𝑥𝑥)
is true.
EXAMPLE 9 Let 𝑄𝑄(𝑥𝑥) be the statement “𝑥𝑥 > 2.” What is the truth value of the
quantification ∀𝑥𝑥𝑥𝑥(𝑥𝑥), where the domain consists of all real numbers?
Solution: 𝑄𝑄(𝑥𝑥) is not true for every real number x, because, for instance, 𝑄𝑄(1)
is false. That is, 𝑥𝑥 = 1 is a counterexample for the statement ∀𝑥𝑥𝑥𝑥(𝑥𝑥). Thus,
∀𝑥𝑥𝑥𝑥(𝑥𝑥)
is false.
When all the elements in the domain can be listed – say, 𝑥𝑥1 , 𝑥𝑥2 , ⋯ , 𝑥𝑥𝑛𝑛 - it follows that the
universal quantification ∀𝑥𝑥𝑥𝑥(𝑥𝑥) is the same as the conjunction
because this conjunction is true if and only if 𝑃𝑃(𝑥𝑥1 ), 𝑃𝑃(𝑥𝑥2 ), ⋯ , 𝑃𝑃(𝑥𝑥𝑛𝑛 ) are all true.
EXAMPLE 11 What is the truth value of ∀𝑥𝑥𝑥𝑥(𝑥𝑥), where 𝑃𝑃(𝑥𝑥) is the statement “𝑥𝑥 2 < 10”
and the domain consists of the positive integers not exceeding 4?
2
Discrete Structures Lecture 4
CMSC 2123 1.4 Predicates and Quantifiers
We use the notation ∃𝑥𝑥𝑥𝑥(𝑥𝑥) for all the existential quantification of 𝑃𝑃(𝑥𝑥). Here
∃ is called the existential quantifier.
• A domain must always be specified when a statement ∃𝑥𝑥𝑥𝑥(𝑥𝑥) is used. Furthermore, the
meaning of ∃𝑥𝑥𝑥𝑥(𝑥𝑥) changes when the domain changes. Without specifying the domain,
the statement ∃𝑥𝑥𝑥𝑥(𝑥𝑥) has no meaning.
• Besides the words “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 is.” The
existential quantification ∃𝑥𝑥𝑥𝑥(𝑥𝑥) is read as
EXAMPLE 14 Let 𝑃𝑃(𝑥𝑥) be the statement “𝑥𝑥 > 3.” What is the truth value of the
quantification ∃𝑥𝑥𝑥𝑥(𝑥𝑥), where the domain consists of all real numbers?
Solution: Because “𝑥𝑥 > 3” is sometimes true – for instance, when 𝑥𝑥 = 4 𝑃𝑃(𝑥𝑥)
- the existential quantification of 𝑃𝑃(𝑥𝑥), which is ∃𝑥𝑥𝑥𝑥(𝑥𝑥), is true.
EXAMPLE 15 Let 𝑄𝑄(𝑥𝑥) be the statement “𝑥𝑥 = 𝑥𝑥 + 1.” What is the truth value of the
quantification ∃𝑥𝑥𝑥𝑥(𝑥𝑥), where the domain consists of all real numbers?
Solution: Because 𝑄𝑄(𝑥𝑥) is false for every real number x, the existential
quantification of 𝑄𝑄(𝑥𝑥), which is ∃𝑥𝑥𝑥𝑥(𝑥𝑥) is false.
Remark: Generally, an implicit assumption is made that all domains of discourse for quantifiers
are nonempty. If the domain is empty, then ∃𝑥𝑥𝑥𝑥(𝑥𝑥) is false whenever 𝑄𝑄(𝑥𝑥) is a propositional
function because when the domain is empty, there can be no element x in the domain for which
𝑄𝑄(𝑥𝑥) is true.
When all the elements in the domain can be listed – say, 𝑥𝑥1 , 𝑥𝑥2 , ⋯ , 𝑥𝑥𝑛𝑛 - it follows that the
existential quantification ∃𝑥𝑥𝑥𝑥(𝑥𝑥) is the same as the disjunction
because this disjunction is true if and only if at least one of 𝑃𝑃(𝑥𝑥1 ), 𝑃𝑃(𝑥𝑥2 ), ⋯ , 𝑃𝑃(𝑥𝑥𝑛𝑛 ) is true.
3
Discrete Structures Lecture 4
CMSC 2123 1.4 Predicates and Quantifiers
EXAMPLE 16 What is the truth value of ∃𝑥𝑥𝑥𝑥(𝑥𝑥), where 𝑃𝑃(𝑥𝑥) is the statement “𝑥𝑥 2 > 10”
and the universe of discourse consists of the positive integers not exceeding 4?
Solution: Because the domain is {1,2,3,4}, the proposition ∃𝑥𝑥𝑥𝑥(𝑥𝑥) is the same
as the disjunction
𝑃𝑃(1) ∨ 𝑃𝑃(2) ∨ 𝑃𝑃(3) ∨ 𝑃𝑃(4).
Because 𝑃𝑃(4), which is the statement “42 > 10,” is true, it follows that
∃𝑥𝑥𝑥𝑥(𝑥𝑥) is true.
Other Quantifiers
Name Notation Description
uniqueness quantifier ∃! The notation ∃! 𝑥𝑥𝑥𝑥(𝑥𝑥) states ”There exists a unique
x such that 𝑃𝑃(𝑥𝑥) is true.” Other phrases for
uniqueness quantification include “there is exactly
one” and “there is one and only one.”
uniqueness quantifier ∃1 ∃1 𝑥𝑥𝑥𝑥(𝑥𝑥)
EXAMPLE 17 What do the statements ∀𝑥𝑥 < 0(𝑥𝑥 2 > 0), ∀𝑦𝑦 ≠ 0(𝑦𝑦 3 ≠ 0), and ∃𝑧𝑧 > 0(𝑧𝑧 2 =
2) mean, where the domain in each case consists of the real numbers?
Solution: The statement ∀𝑥𝑥 < 0(𝑥𝑥 2 > 0) states that for every real number x
with 𝑥𝑥 < 0, 𝑥𝑥 2 > 0. That is, it states “The square of a negative real number is
positive.” This statement is the same as ∀𝑥𝑥(𝑥𝑥 < 0 → 𝑥𝑥 2 > 0).
The statement ∀𝑦𝑦 ≠ 0(𝑦𝑦 3 ≠ 0) states that for every real number y with 𝑦𝑦 ≠
0, we have 𝑦𝑦 3 ≠ 0. That is, it states “The cube of every nonzero real number is
nonzero.” Note that this statement is equivalent to , ∀𝑦𝑦(𝑦𝑦 ≠ 0 → 𝑦𝑦 3 ≠ 0).
Finally, the statement ∃𝑧𝑧 > 0(𝑧𝑧 2 = 2) states that there exists a real number z
with 𝑧𝑧 > 0 such that 𝑧𝑧 2 = 2. That is, it states “There is a positive square root
of 2.” This statement is equivalent to ∃𝑧𝑧(𝑧𝑧 > 0 ∧ 𝑧𝑧 2 = 2).
Precedence of Quantifiers
The quantifiers ∀ and ∃ have higher precedence than all logical operators from propositional
calculus. For example, ∀𝑥𝑥𝑥𝑥(𝑥𝑥) ∨ 𝑄𝑄(𝑥𝑥) is the disjunction of ∀𝑥𝑥𝑥𝑥(𝑥𝑥) and 𝑄𝑄(𝑥𝑥). In other words, it
means (∀𝑥𝑥𝑥𝑥(𝑥𝑥) ) ∨ (∀𝑥𝑥𝑥𝑥(𝑥𝑥)) rather than ∀𝑥𝑥(𝑃𝑃(𝑥𝑥) ∨ 𝑄𝑄(𝑥𝑥)).
4
Discrete Structures Lecture 4
CMSC 2123 1.4 Predicates and Quantifiers
Binding Variables
• An occurrence of a variable may be bound.
o An occurrence of a variable may be bound by a quantifier. For example
∀𝑥𝑥𝑥𝑥(𝑥𝑥, 𝑦𝑦) makes variable x bound and variable y free.
o An occurrence of a variable may be bound by being set to a particular value.
• An occurrence of a variable may be free.
EXAMPLE 18 In the statement ∃𝑥𝑥(𝑥𝑥 + 𝑦𝑦 = 1), the variable x is bound by the existential
quantification ∃𝑥𝑥, but the variable y is free because it is not bound by a
quantifier and no value is assigned to this variable.
DEFINITION 3 Statements involving predicates and quantifiers are logically equivalent if and
only if they have the same truth value no matter which predicates are
substituted into these statements and which domain of discourse is used for
the variables in these propositional functions. We use the notation 𝑆𝑆 ≡ 𝑇𝑇 to
indicate that two statements S and T involving predicates and quantifiers are
logically equivalent.
EXAMPLE 19 Show that ∀𝑥𝑥(𝑃𝑃(𝑥𝑥) ∧ 𝑄𝑄(𝑥𝑥)) and ∀𝑥𝑥𝑥𝑥(𝑥𝑥) ∧ ∀𝑥𝑥𝑥𝑥(𝑥𝑥) are logically equivalent
(where the same domain is used throughout).
5
Discrete Structures Lecture 4
CMSC 2123 1.4 Predicates and Quantifiers
Remark: When the domain of a predicate 𝑃𝑃(𝑥𝑥) consists of n elements, where n is a positive
integer, the rules for negating quantified statements are exactly the same as De Morgan’s laws
discussed in Section 1.2. This is why these rules are called De Morgan’s laws for quantifiers.
When the domain has n elements 𝑥𝑥1 , 𝑥𝑥2 , ⋯ , 𝑥𝑥𝑛𝑛 , it follows that ¬∀𝑥𝑥𝑥𝑥(𝑥𝑥) is the same as
¬�𝑃𝑃(𝑥𝑥1 ) ∧ 𝑃𝑃(𝑥𝑥2 ) ∧ ⋯ ∧ 𝑃𝑃(𝑥𝑥𝑛𝑛 )�, which is equivalent to ¬𝑃𝑃(𝑥𝑥1 ) ∨ ¬𝑃𝑃(𝑥𝑥2 ) ∨ ⋯ ∨ ¬𝑃𝑃(𝑥𝑥𝑛𝑛 ) by De
Morgan’s laws, and this is the same as ∃𝑥𝑥¬𝑃𝑃(𝑥𝑥). Similarly, ¬∃𝑥𝑥𝑥𝑥(𝑥𝑥) is the same as ¬( 𝑃𝑃(𝑥𝑥1 ) ∨
𝑃𝑃(𝑥𝑥2 ) ∨ ⋯ ∨ 𝑃𝑃(𝑥𝑥𝑛𝑛 )), which by De Morgan’s laws is equivalent to ¬𝑃𝑃(𝑥𝑥1 ) ∧ ¬𝑃𝑃(𝑥𝑥2 ) ∧ ⋯ ∧
¬𝑃𝑃(𝑥𝑥𝑛𝑛 ), and this is the same as ∀𝑥𝑥¬𝑃𝑃(𝑥𝑥).
EXAMPLE 20.1 What is the negation of the statement “There is an honest politician?”
6
Discrete Structures Lecture 4
CMSC 2123 1.4 Predicates and Quantifiers
EXAMPLE 21.1 What are the negations of the statements ∀𝑥𝑥(𝑥𝑥 2 > 𝑥𝑥) and ∃𝑥𝑥(𝑥𝑥 2 = 2)?
Solution: The negation of ∀𝑥𝑥(𝑥𝑥 2 > 𝑥𝑥) is the statement ¬∀𝑥𝑥(𝑥𝑥 2 > 𝑥𝑥), which is
equivalent to ∃𝑥𝑥¬(𝑥𝑥 2 > 𝑥𝑥). This can be rewritten as ∃𝑥𝑥(𝑥𝑥 2 ≤ 𝑥𝑥). The truth
values of these statements depend on the domain.
Solution:
Expression Justification
¬∀𝑥𝑥(𝑃𝑃(𝑥𝑥) → 𝑄𝑄(𝑥𝑥)) Initial assumption
∃𝑥𝑥(¬(𝑃𝑃(𝑥𝑥) → 𝑄𝑄(𝑥𝑥))) Table 2, row 2
∃𝑥𝑥(𝑃𝑃(𝑥𝑥) ∧ ¬𝑄𝑄(𝑥𝑥)) Section 1.2, Table 7, row 5
Expression Justification
∃𝑥𝑥(𝑃𝑃(𝑥𝑥) ∧ ¬𝑄𝑄(𝑥𝑥)) Initial assumption
∃𝑥𝑥(¬(𝑃𝑃(𝑥𝑥) → 𝑄𝑄(𝑥𝑥))) Section 1.2, Table 7, row 5
¬∀𝑥𝑥(𝑃𝑃(𝑥𝑥) → 𝑄𝑄(𝑥𝑥)) Table 2, row 2
EXAMPLE 23 Express the statement “Every student in this class has studied calculus” using
predicates and quantifiers.
Solution: First, we rewrite the statement so that we can clearly identify the
appropriate quantifiers to use.
“For every student in this class, that student has studied calculus.”
Next, we introduce a variable x so that our statement becomes
“For every student x in this class, x has studied calculus.”
We introduce 𝐶𝐶(𝑥𝑥), which is the statement “x has studied calculus.” We also
confine the domain of discourse to students in the class. Our statement can be
expressed
∀𝑥𝑥𝑥𝑥(𝑥𝑥)
Let 𝑆𝑆(𝑥𝑥) represent the statement “x is a person in this class.” Our statement
can be represented as
∀𝑥𝑥(𝑆𝑆(𝑥𝑥) → 𝐶𝐶(𝑥𝑥))
7
Discrete Structures Lecture 4
CMSC 2123 1.4 Predicates and Quantifiers
Logic Programming
• under construction