Sections 1.3-1.4 of Rosen: Cse235@cse - Unl.edu
Sections 1.3-1.4 of Rosen: Cse235@cse - Unl.edu
Predicate
Logic and
Predicate
Logic and
Consider the following statements:
Quantifiers Quantifiers
CSE235
Predicate Logic and Quantifiers CSE235
x > 3, x = y + 3, x+y =z
The truth value of these statements has no meaning without
specifying the values of x, y, z.
Slides by Christopher M. Bourke
However, we can make propositions out of such statements.
Instructor: Berthe Y. Choueiry
A predicate is a property that is affirmed or denied about the
subject (in logic, we say “variable” or “argument”) of a
statement.
Spring 2006
“ |{z}
x is greater than 3”
| {z }
subject predicate
Computer Science & Engineering 235
Introduction to Discrete Mathematics Terminology: affirmed = holds = is true; denied = does not
1/1 Sections 1.3–1.4 of Rosen 2/1 hold = is not true.
[email protected]
Predicate Predicate
Logic and To write in predicate logic: Logic and
Quantifiers Quantifiers
Definition
CSE235 CSE235
A statement of the form P (x1 , x2 , . . . , xn ) is the value of the
“ |{z}
x is greater than 3” propositional function P . Here, (x1 , x2 , . . . , xn ) is an n-tuple
| {z }
subject predicate and P is a predicate.
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235
Example CSE235
Example
Let Q(x, y, z) denote the statement “x2 + y 2 = z 2 ”. What is Let Q(x, y, z) denote the statement “x2 + y 2 = z 2 ”. What is
the truth value of Q(3, 4, 5)? What is the truth value of the truth value of Q(3, 4, 5)? What is the truth value of
Q(2, 2, 3)? How many values of (x, y, z) make the predicate Q(2, 2, 3)? How many values of (x, y, z) make the predicate
true? true?
5/1 6/1
Universe of Discourse Universe of Discourse
Multivariate Functions
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235 CSE235
Consider the previous example. Does it make sense to assign to Moreover, each variable in an n-tuple may have a different
x the value “blue”? universe of discourse.
Intuitively, the universe of discourse is the set of all things we Let P (r, g, b, c) = “The rgb-value of the color c is (r, g, b)”.
wish to talk about; that is, the set of all objects that we can
sensibly assign to a variable in a propositional function. For example, P (255, 0, 0, red) is true, while P (0, 0, 255, green)
is false.
What would be the universe of discourse for the propositional
function P (x) = “The test will be on x the 23rd” be? What are the universes of discourse for (r, g, b, c)?
7/1 8/1
Predicate Predicate
Logic and
Quantifiers
Logic and
Quantifiers
Definition
CSE235 CSE235 The universal quantification of a predicate P (x) is the
proposition “P (x) is true for all values of x in the universe of
A predicate becomes a proposition when we assign it fixed discourse” We use the notation
values. However, another way to make a predicate into a
proposition is to quantify it. That is, the predicate is true (or ∀xP (x)
false) for all possible values in the universe of discourse or for
some value(s) in the universe of discourse. which can be read “for all x”
Such quantification can be done with two quantifiers: the
If the universe of discourse is finite, say {n1 , n2 , . . . , nk }, then
universal quantifier and the existential quantifier.
the universal quantifier is simply the conjunction of all
elements:
9/1 10 / 1
Predicate Predicate
Logic and Let P (x) be the predicate “x must take a discrete Logic and Let P (x) be the predicate “x must take a discrete
Quantifiers Quantifiers
mathematics course” and let Q(x) be the predicate “x is a mathematics course” and let Q(x) be the predicate “x is a
CSE235 CSE235
computer science student”. computer science student”.
The universe of discourse for both P (x) and Q(x) is all The universe of discourse for both P (x) and Q(x) is all
UNL students. UNL students.
Express the statement “Every computer science student Express the statement “Every computer science student
must take a discrete mathematics course”. must take a discrete mathematics course”.
∀x(Q(x) → P (x))
Express the statement “Everybody must take a discrete Express the statement “Everybody must take a discrete
mathematics course or be a computer science student”. mathematics course or be a computer science student”.
11 / 1 12 / 1
Universal Quantifier Universal Quantifier
Example I Example I
Predicate Predicate
Logic and Let P (x) be the predicate “x must take a discrete Logic and Let P (x) be the predicate “x must take a discrete
Quantifiers Quantifiers
mathematics course” and let Q(x) be the predicate “x is a mathematics course” and let Q(x) be the predicate “x is a
CSE235 CSE235
computer science student”. computer science student”.
The universe of discourse for both P (x) and Q(x) is all The universe of discourse for both P (x) and Q(x) is all
UNL students. UNL students.
Express the statement “Every computer science student Express the statement “Every computer science student
must take a discrete mathematics course”. must take a discrete mathematics course”.
∀x(Q(x) → P (x)) ∀x(Q(x) → P (x))
Express the statement “Everybody must take a discrete Express the statement “Everybody must take a discrete
mathematics course or be a computer science student”. mathematics course or be a computer science student”.
∀x(Q(x) ∨ P (x)) ∀x(Q(x) ∨ P (x))
13 / 1 14 / 1
Are these statements true or false?
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235
Express the statement “for every x and for every y, x + y > 10” CSE235
Express the statement “for every x and for every y, x + y > 10”
Let P (x, y) be the statement x + y > 10 where the universe of
discourse for x, y is the set of integers.
15 / 1 16 / 1
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235
Express the statement “for every x and for every y, x + y > 10” CSE235
Express the statement “for every x and for every y, x + y > 10”
Let P (x, y) be the statement x + y > 10 where the universe of Let P (x, y) be the statement x + y > 10 where the universe of
discourse for x, y is the set of integers. discourse for x, y is the set of integers.
Answer: Answer:
∀x∀yP (x, y) ∀x∀yP (x, y)
∀x, yP (x, y)
17 / 1 18 / 1
Existential Quantifier Existential Quantifier
Definition Example I
Predicate Predicate
Logic and
Quantifiers
Definition Logic and
Quantifiers
19 / 1 20 / 1
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235 CSE235
Express the statement “there exists a real solution to Express the statement “there exists a real solution to
ax2 + bx − c = 0” ax2 + bx − c = 0”
√
2
Let P (x) be the statement x = −b± 2a b −4ac
where the universe
of discourse for x is the set of reals. Note here that a, b, c are
all fixed constants.
21 / 1 22 / 1
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235 CSE235
Express the statement “there exists a real solution to
ax2 + bx − c = 0” Question: what is the truth value of ∃xP (x)?
√
b2 −4ac
Let P (x) be the statement x = −b± 2a where the universe
of discourse for x is the set of reals. Note here that a, b, c are
all fixed constants.
The statement can thus be expressed as
∃xP (x)
23 / 1 24 / 1
Existential Quantifier Existential Quantifier
Example II Continued Example II Continued
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235 CSE235
Question: what is the truth value of ∃xP (x)? Question: what is the truth value of ∃xP (x)?
b2
Answer: it is false. For any real numbers such that < 4ac, Answer: it is false. For any real numbers such that b2 < 4ac,
there will only be complex solutions, for these cases no such there will only be complex solutions, for these cases no such
real number x can satisfy the predicate. real number x can satisfy the predicate.
How can we make it so that it is true? How can we make it so that it is true?
Answer: change the universe of discourse to the complex
numbers, C.
25 / 1 26 / 1
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
27 / 1 28 / 1
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235 CSE235
Express, in predicate logic, the statement that there are an Express, in predicate logic, the statement that there are an
infinite number of integers. infinite number of integers.
Let P (x, y) be the statement that x < y. Let the universe of
discourse be the integers, Z.
31 / 1 32 / 1
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235 CSE235
Express the commutative law of addition for R.
Express, in predicate logic, the statement that there are an
infinite number of integers.
Let P (x, y) be the statement that x < y. Let the universe of
discourse be the integers, Z.
Then the statement can be expressed by the following.
∀x∃yP (x, y)
33 / 1 34 / 1
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235 CSE235
Express the commutative law of addition for R. Express the commutative law of addition for R.
We want to express that for every pair of reals, x, y the We want to express that for every pair of reals, x, y the
following identity holds: following identity holds:
∀x∀y(x + y = y + x)
35 / 1 36 / 1
Mixing Quantifiers Mixing Quantifiers
Example II: More Mathematical Statements Continued Example II: More Mathematical Statements Continued
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235 CSE235
Express the multiplicative inverse law for (nonzero) rationals Express the multiplicative inverse law for (nonzero) rationals
Q \ {0}. Q \ {0}.
We want to express that for every real number x, there exists a
real number y such that xy = 1.
37 / 1 38 / 1
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235 CSE235
Express the multiplicative inverse law for (nonzero) rationals Is commutativity for subtraction valid over the reals?
Q \ {0}.
We want to express that for every real number x, there exists a
real number y such that xy = 1.
Then we have the following:
∀x∃y(xy = 1)
39 / 1 40 / 1
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235 CSE235
Is commutativity for subtraction valid over the reals? Is commutativity for subtraction valid over the reals?
That is, for all pairs of real numbers x, y does the identity That is, for all pairs of real numbers x, y does the identity
x − y = y − x hold? Express this using quantifiers. x − y = y − x hold? Express this using quantifiers.
The expression is
∀x∀y(x − y = y − x)
41 / 1 42 / 1
Mixing Quantifiers Mixing Quantifiers
Example II: False Mathematical Statements Continued Example II: False Mathematical Statements Continued
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
CSE235 CSE235
Is there a multiplicative inverse law over the nonzero integers? Is there a multiplicative inverse law over the nonzero integers?
That is, for every integer x does there exists a y such that
xy = 1?
43 / 1 44 / 1
Predicate Predicate
Logic and Logic and
Express the statement “there is a number x such that
Quantifiers Quantifiers
when it is added to any number, the result is that
CSE235 CSE235
number, and if it is multiplied by any number, the
Is there a multiplicative inverse law over the nonzero integers? result is x” as a logical expression.
That is, for every integer x does there exists a y such that
Solution:
xy = 1?
This is false, since we can find a counter example. Take any
integer, say 5 and multiply it with another integer, y. If the
statement held, then 5 = 1/y, but for any (nonzero) integer y,
|1/y| ≤ 1.
45 / 1 46 / 1
Predicate Predicate
Logic and
Express the statement “there is a number x such that Logic and
Express the statement “there is a number x such that
Quantifiers
when it is added to any number, the result is that Quantifiers
when it is added to any number, the result is that
CSE235 CSE235
number, and if it is multiplied by any number, the number, and if it is multiplied by any number, the
result is x” as a logical expression. result is x” as a logical expression.
Solution: Solution:
Let P (x, y) be the expression “x + y = y”. Let P (x, y) be the expression “x + y = y”.
Let Q(x, y) be the expression “xy = x”.
47 / 1 48 / 1
Mixing Quantifiers Mixing Quantifiers
Exercise Exercise
Predicate Predicate
Logic and
Express the statement “there is a number x such that Logic and
Express the statement “there is a number x such that
Quantifiers
when it is added to any number, the result is that Quantifiers
when it is added to any number, the result is that
CSE235 CSE235
number, and if it is multiplied by any number, the number, and if it is multiplied by any number, the
result is x” as a logical expression. result is x” as a logical expression.
Solution: Solution:
Let P (x, y) be the expression “x + y = y”. Let P (x, y) be the expression “x + y = y”.
Let Q(x, y) be the expression “xy = x”. Let Q(x, y) be the expression “xy = x”.
Then the expression is Then the expression is
∃x∀y (P (x, y) ∧ Q(x, y)) ∃x∀y (P (x, y) ∧ Q(x, y))
Over what universe(s) of discourse does this statement
hold?
49 / 1 50 / 1
Predicate Predicate
Logic and
Express the statement “there is a number x such that Logic and
Quantifiers
when it is added to any number, the result is that Quantifiers
CSE235 CSE235
number, and if it is multiplied by any number, the When a quantifier is used on a variable x, we say that x is
result is x” as a logical expression. bound. If no quantifier is used on a variable in a predicate
statement, it is called free.
Solution:
Example
Let P (x, y) be the expression “x + y = y”. In the expression ∃x∀yP (x, y) both x and y are bound.
Let Q(x, y) be the expression “xy = x”. In the expression ∀xP (x, y), x is bound, but y is free.
Then the expression is
∃x∀y (P (x, y) ∧ Q(x, y)) A statement is called a well-formed formula, when all variables
are properly quantified.
Over what universe(s) of discourse does this statement
hold?
This is the additive identity law and holds for N, Z, R, Q
51 / 1 but does not hold for Z+ . 52 / 1
Predicate Predicate
Logic and Logic and
Quantifiers Quantifiers
Just as we can use negation with propositions, we can use
CSE235 CSE235
them with quantified expressions.
The set of all variables bound by a common quantifier is the
scope of that quantifier. Lemma
Let P (x) be a predicate. Then the following hold.
Example
In the expression ∃x, y∀zP (x, y, z, c) the scope of the ¬∀xP (x) ≡ ∃x¬P (x)
existential quantifier is {x, y}, the scope of the universal
quantifier is just z and c has no scope since it is free. ¬∃xP (x) ≡ ∀x¬P (x)
53 / 1 54 / 1
Negation Prolog
Truth Values
Predicate
Logic and
Predicate
Logic and
Prolog (Programming in Logic) is a programming language
Quantifiers Quantifiers based on (a restricted form of) Predicate Calculus. It was
CSE235 CSE235 developped by the logicians of the artificial intelligence
community for symbolic reasoning.
Statement True When False When
¬∃xP (x) ≡ For every x, P (x) is There is an x for Prolog allows the user to express facts and rules
∀x¬P (x) false. which P (x) is true. Facts are proposational functions: student(juana),
¬∀xP (x) ≡ There is an x for P (x) is true for every enrolled(juana,cse235), instructor(patel,cse235), etc.
∃x¬P (x) which P (x) is false. x. Rules are implications with conjunctions:
teaches(X,Y) :- instructor(X,Z), enrolled(Y,Z)
Table: Truth Values of Negated Quantifiers
Prolog answers queries such as:
?enrolled(juana,cse478)
?enrolled(X,cse478)
?teaches(X,juana)
by binding variables and doing theorem proving (i.e.,
applying inference rules) as we will see in Section 1.5.
55 / 1 56 / 1
Predicate Predicate
Logic and Logic is more precise than English. Logic and
Quantifiers Quantifiers Examples? Exercises?
CSE235 Transcribing English to Logic and vice versa can be tricky. CSE235
When writing statements with quantifiers, usually the correct Rewrite the expression,
meaning is conveyed with the following combinations: ¬∀x ∃y∀zP (x, y, z) ∧ ∃z∀yP (x, y, z)
Use ∀ with ⇒
Example: ∀xLion(x) ⇒ F ierce(x)
∀xLion(x) ∧ F ierce(x) means “everyone is a lion and
everyone is fierce” Let P (x, y) denote “x is a factor of y” where
x ∈ {1, 2, 3, . . .} and y ∈ {2, 3, 4, . . .}.
Let Q(y) denote
Use ∃ with ∧
“∀x P (x, y) → ((x = y) ∨ (x = 1)) ”. When is Q(y)
Example: ∃xLion(x) ∧ Drinks(x, cof f ee): holds when
true?
you have at least one lion that drinks coffee
∃xLion(x) ⇒ Drinks(x, cof f ee) holds when you have
people even though no lion drinks coffee.
57 / 1 58 / 1
Conclusion Conclusion
Predicate Predicate
Logic and Logic and
Quantifiers Examples? Exercises? Quantifiers Examples? Exercises?
CSE235 CSE235
Let P (x, y) denote “x is a factor of y” where Let P (x, y) denote “x is a factor of y” where
x ∈ {1, 2, 3, . . .} and y ∈ {2, 3, 4, . . .}.
Let Q(y) denote x ∈ {1, 2, 3, . . .} and y ∈ {2, 3, 4, . . .}.
Let Q(y) denote
“∀x P (x, y) → ((x = y) ∨ (x = 1)) ”. When is Q(y) “∀x P (x, y) → ((x = y) ∨ (x = 1)) ”. When is Q(y)
true? true?
Answer: Only when y is a prime number.
59 / 1 60 / 1
Extra Question
Predicate
Logic and
Quantifiers
Some students wondered if
CSE235
61 / 1