Because learning changes
®
everything.
Predicate Logic
CLO2 – Part3
© McGraw Hill LLC. All rights reserved. No reproduction or distribution without the prior written consent of McGraw Hill LLC.
Introduction
Propositional logic, which we studied earlier, is not
enough to express all types of statements in
mathematics or everyday language.
In this lecture, we will learn a more powerful form of
logic called predicate logic.
Predicate logic helps us describe and reason about
relationships between objects in mathematics and
computer science.
To begin, we will learn what a predicate is.
Then, we will study quantifiers, which allow us to
talk about statements that apply to all objects of a
certain kind or the existence of an object with a
specific property.
© McGraw Hill LLC 2
Contents
Introduction.
Propositional Functions.
• Variables.
• Predicates.
Quantifiers.
• Universal Quantifier.
• Existential Quantifier.
Negating Quantifiers.
Translating English to Logic.
© McGraw Hill LLC 3
Extending Propositional Logic
Statements involving variables, such as
“x > 3”, and
“computer x is functioning properly”
are neither true nor false (i.e., not
propositions) when the values of the
variables are not specified.
Can statements with variables be turned into
propositions?
Need propositional functions.
© McGraw Hill LLC 4
Propositional Functions 1
Propositional functions are a generalization of
propositions.
They contain variable(s) and a predicate, e.g., P(x) =
“x > 3”.
The statement “x is greater than 3” has two parts:
• The first part, the variable x, is the subject of the statement.
• The second part—the predicate, “is greater than 3”—refers
to a property that the subject of the statement can have.
Propositional functions become propositions (and
have truth values) when their variables are replaced
by elements from their domain or universe (often
denoted by U).
© McGraw Hill LLC 5
Propositional Functions 2
Example:
Let A(x) denote the statement “Computer x 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 truth
values of A(CS1), A(CS2), and A(MATH1)?
Solution:
We obtain the statement A(CS1) by setting x = CS1
in the statement “Computer x is under attack by an
intruder.” Because CS1 is not on the list of
computers currently under attack, we conclude that
A(CS1) is false. Similarly, because CS2 and MATH1
are on the list of computers under attack, we know
© McGraw Hill LLC
that A(CS2) and A(MATH1) are true. 6
Propositional Functions 3
Example:
Let A(c, n) denote the statement “Computer c is
connected to network n,” where c is a variable
representing a computer and n is a variable
representing a network. Suppose that the computer
MATH1 is connected to network CAMPUS2, but not to
network CAMPUS1. What are the values of A(MATH1,
CAMPUS1) and A(MATH1, CAMPUS2)?
Solution:
Because MATH1 is not connected to the CAMPUS1
network, we see that A(MATH1, CAMPUS1) is false.
However, because MATH1 is connected to the
CAMPUS2 network, we see that A(MATH1, CAMPUS2)
© McGraw Hill LLC 7
Propositional Functions 4
Let “x = y + 3” be denoted by P(x, y) and U (for both
variables) be the integers. Find these truth values:
P(1, 2)
Solution: F
P(3, 0)
Solution: T
P(x, 3)
Solution: Not a Proposition
© McGraw Hill LLC 8
Propositional Functions 5
Let “x - y = z” be denoted by Q(x, y, z), with U as
the integers. Find these truth values:
Q(2, -1, 3)
Solution: T
Q(3, 4, 7)
Solution: F
Q(x, 3, z)
Solution: Not a Proposition
© McGraw Hill LLC 9
Charles
Quantifiers Peirce
(1839-
1914)
We saw that when the variables in a propositional function
are assigned values, the resulting statement becomes a
proposition.
There is another important way, called quantification, to
create a proposition from a propositional 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 quantifications.
The two most important quantifiersare:
Universal Quantifier,
• Existential Quantifier,“For all,”exists,”
“There symbol:
Wesymbol:
write as x P(x).
inx P(x) and
x P(x) asserts P(x) is true for every x in the
xdomain.
P(x) asserts P(x) is true for some x in the
© McGraw Hill LLC domain. 10
Truth Value of Quantifiers
An element for which P(x) is false is called a counterexample of
∀x P(x).
© McGraw Hill LLC 11
Universal Quantifier
x P(x) is read as “For all x, P(x)” or “For
every x, P(x)”
Examples: x P(x)
1) false is then
If P(x) denotes “x 0” and U is the integers,
.
2) If P(x) denotes “x 0” and U is the positive
x P(x) isthen
integers,
true.
3) If P(x) denotes “x is even” and U is the x
P(x) is
integers, then
false.
© McGraw Hill LLC 12
Existential Quantifier
x P(x) is read as “For some x, P(x)”, or
isas
an“There
x such that P(x),” or “For at least
one x, P(x).”
Examples: x P(x)
1. true.
If P(x)Itdenotes
is also true if Uand
“x 0” is the positive
U is is then
the integers,
integers.
2. If P(x) denotes “x 0” and U is the positive x
P(x) is
integers, then
false.
3. If P(x) denotes “x is even” and U is the x P(x)
true.
integers, then is
© McGraw Hill LLC 13
Dependence of Quantifier Truth Value
The truth valueof
x P(x) x P(x) depend on
the propositionaland bothand on the
function P(x)
domain U.
Examples:
xthe
1. If U is P(x)positive x P(x) is
is true, integers and P(x) is the
but “x 2”, then
statement false.
2. If U is the negative integers and P(x) is the
statement x “x
P(x)2”, then
x P(x) are
both
and true.
3. If U consists of 3, 4, and 5, and P(x) is the
statement x“x 2”,
P(x) x P(x)
then are true. But if P(x)
both
statementand “x 2”, then x P(x) x P(x) are
is the
both and false.
© McGraw Hill LLC 14
Thinking about Quantifiers 1
When the domain of discourse is finite, we can think
of quantification as looping through the elements of
the domain. x P(x) loop through all x in the
To
• Ifevaluate
at every domain.
step P(x) is x P(x) is
true, then true.
• If at a step P(x) is false, x P(x) is false, and the loop
then terminates.
To x P(x) loop through all x in the
evaluate
• If at some domain. x P(x) is true, and the loop
step, P(x) is true,
then terminates.
• If the loop ends without finding an x for which P(x) x P(x)
false.
is true, then is
Even if the domains are infinite, we can still think of
the quantifiers this fashion, but the loops will not
terminate in some cases.
© McGraw Hill LLC 15
Thinking about Quantifiers 2
If the domain is finite, a universally quantified
proposition is equivalent to a conjunction of
propositions without quantifiers and an
existentially quantified proposition is equivalent
to a disjunction of propositions without
quantifiers.
If U consists of the integers 1, 2, and 3:
Even if the domains are infinite, you can still think
of the quantifiers in this fashion, but the
equivalent expressions without quantifiers will be
© McGraw Hill LLC
infinitely long. 16
Negating Quantified Expressions
De Morgan’s laws for quantifiers.
© McGraw Hill LLC 17
Understanding Quantifiers
Example 1: What does the statement ∀x N(x) mean if
N(x) is “Computer x is connected to the network” and
the domain consists of all computers on campus?
Solution: Every computer on campus is connected to
the network.
Example 2: What is the negation of the statement
“Every student in your class has taken a course in
calculus”?
Solution: “There is a student in your class who has not
taken a course in calculus.”
Example 3: What is the negation of the statement
“There is an honest politician”?
© McGraw Hill LLC Solution: “Every politician is dishonest.” 18
Translating from English to Logic 1
Translating sentences in English (or other natural languages)
into logical expressions is a crucial task in mathematics, logic
programming, artificial intelligence, software engineering, and
many other disciplines.
To properly translate an English sentence into predicate logic,
we should first define the domain (or universe) of discourse,
as this determines how we express properties of its elements.
Tips to convert an English sentence to a statement in
predicate logic:
• Define the domain of discourse.
• Identify properties of elements of the chosen domain.
• Define propositional functions.
• Determine appropriate quantifiers.
© McGraw Hill LLC 19
Translating from English to Logic 2a
Example: “Every student studies mathematics.”
Solution:
o Define the domain: Suppose the domain is all students.
o Identify properties of the chosen domain’s elements (i.e., students):
• study mathematics
o Define propositional functions:
• M(x): “x studies mathematics”
o Apply quantifiers:
• ∀x M(x) (i.e., “for every x (where x is already assumed to be a
student), x studies mathematics.”)
© McGraw Hill LLC 20
Translating from English to Logic 2b
Example: “Every student studies mathematics.”
Solution:
o Define the domain: Suppose the domain is all people.
o Identify properties of the chosen domain’s elements (i.e., persons):
• being a student
• study mathematics
o Define propositional functions:
• S(x): “x is a student”
• M(x): “x studies mathematics”
o Apply quantifiers:
• ∀x( S(x) → M(x) ) (i.e., “for every person x, if x is a student, then x
studies mathematics.”)
© McGraw Hill LLC 21
Translating from English to Logic 2c
Example: “Some students study mathematics.”
Solution:
o Define the domain: Suppose the domain is all students.
o Identify properties of the chosen domain’s elements (i.e., students):
• study mathematics
o Define propositional functions:
• M(x): “x studies mathematics”
o Apply quantifiers:
• ∃x M(x) (i.e., “for some x (where x is already assumed to be a student),
x studies mathematics.”)
© McGraw Hill LLC 22
Translating from English to Logic 2d
Example: “Some students study mathematics.”
Solution:
o Define the domain: Suppose the domain is all people.
o Identify properties of the chosen domain’s elements (i.e., persons):
• being a student
• study mathematics
o Define propositional functions:
• S(x): “x is a student”
• M(x): “x studies mathematics”
o Apply quantifiers:
• ∃x( S(x) M(x) ) (i.e., “there exists at least one person x such that x is a
student and x studies mathematics.”)
© McGraw Hill LLC 23
Translating from English to Logic 3
Translate the following sentences into predicate logic:
a. “All parrots can talk”. Suppose the domain of
discourse is all parrots.
∀x T(x)
b. “All parrots can talk”. Suppose the domain of
discourse is all birds.
∀x (P(x) → T(x))
c. “Some parrots can talk”. Suppose the domain of
discourse is all parrots.
∃x T(x)
d. “Some parrots can talk”. Suppose the domain of
discourse is all birds.
∃x (P(x) ∧
© McGraw Hill LLC T(x)) 24
Translating from English to Logic 4
Translate the following sentences into predicate logic:
a. “All parrots can talk or fly”. Suppose the domain of
discourse is all parrots.
∀x (T(x) ∨
F(x))
b. “All parrots can talk or fly”. Suppose the domain of
discourse is all birds.
∀x (P(x) → (T(x) ∨ F(x)))
c. “Some parrots can talk or fly”. Suppose the
domain of discourse ∃x
is (T(x)
all parrots.
∨
F(x))
d. “Some parrots can talk or fly”. Suppose the
domain of discourse ∃x
is (P(x)
all birds.
∧ (T(x) ∨ F(x)))
© McGraw Hill LLC 25
Translating from English to Logic 5
Let
P(x) = “x is a hummingbird”,
Q(x) = “x is large”,
R(x) = “x lives on honey”, and
S(x) = “x is richly colored”
If the domain consists of all birds, express each of these
statements using quantifiers and P(x), Q(x), R(x), and
S(x).
∀x(P(x) → S(x))
a. All hummingbirds are richly colored.
∀x(Q(x) → ¬
b. No large birds live on honey.
R(x)) ∀x( ¬ R(x)→ ¬
c. Birds that do not live on honey are dullS(x))
in color.
∀x(P(x)→ ¬ Q(x))
d. Hummingbirds are small.
© McGraw Hill LLC 26
Translating from English to Logic 6
Problem:
Express the following system specification into
predicate logic: “Every mail message larger than
one megabyte will be compressed.”
Solution:
Let S(m, y) be “Mail message m is larger than y
megabytes,” where the variable m has the domain
of all mail messages, and the variable y is a positive
real number; and let C(m) denote “Mail message m
will be compressed.” Then the specification “Every
mail message larger than one megabyte will be
compressed” can be represented as ∀m(S(m, 1) →
C(m)).
© McGraw Hill LLC 27
End of Main Content
Because learning changes everything. ®
www.mheducation.com
© McGraw Hill LLC. All rights reserved. No reproduction or distribution without the prior written consent of McGraw Hill LLC.