Lecture 2
Lecture 2
and
Quantifiers
SECTION 1.4
Section Summary
Predicates
Variables
Quantifiers
Universal Quantifier
Existential Quantifier
Negating Quantifiers
De Morgan’s Laws for Quantifiers
Translating English to Logic
Logic Programming (optional)
Propositional Logic Not
Enough
If we have:
“All men are mortal.”
“Socrates is a man.”
Does it follow that “Socrates is mortal?”
Can’t be represented in propositional logic.
Need a language that talks about objects, their
properties, and their relations.
Later we’ll see how to draw inferences.
Introducing Predicate
Logic
Predicate logic uses the following new features:
Variables: x, y, z
Predicates: P(x), M(x)
Quantifiers (to be covered in a few slides):
Propositional functions are a generalization of
propositions.
They contain variables and a predicate, e.g., P(x)
Variables can be replaced by elements from their
domain.
Propositional Functions
Propositional functions become propositions (and have
truth values) when their variables are each replaced by a
value from the domain (or bound by a quantifier, as we
will see later).
The statement P(x) is said to be the value of the
propositional function P at x.
For example, let P(x) denote “x > 0” and the domain be
the integers. Then:
P(-3) is ?
P(0) is ?
P(3) is ?
Often the domain is denoted by U. So in this example U is
the integers.
Examples of Propositional
Functions
Let “x + y = z” be denoted by R(x, y, z) and U (for all three variables) be
the integers. Find these truth values:
R(2,-1,5)
Solution: ?
R(3,4,7)
Solution: ?
R(x, 3, z)
Solution: ?
Now 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: ?
Q(3,4,7)
Solution: ?
Q(x, 3, z)
Solution: ?
Compound Expressions
Connectives from propositional logic carry over to predicate
logic.
If P(x) denotes “x > 0,” find these truth values:
P(3) ∨ P(-1) Solution:?
P(3) ∧ P(-1) Solution:?
P(3) → P(-1) Solution:?
P(3) → ¬P(-1) Solution: ?
Expressions with variables are not propositions and therefore do
not have truth values. For example,
P(3) ∧ P(y)
P(x) → P(y)
When used with quantifiers (to be introduced next), these
expressions (propositional functions) become propositions.
Quantifiers
We need quantifiers to express the meaning of English
words including all and some:
“All men are Mortal.”
“Some cats do not have fur.”
The two most important quantifiers are:
Universal Quantifier, “For all,” symbol:
Examples:
1. If P(x) denotes “x > 0” and U is the integers, then x P(x)
is true. It is also true if U is the positive integers.
2. If P(x) denotes “x < 0” and U is the positive integers, then
x P(x) is false.
3. If P(x) denotes “x is even” and U is the integers, then x
P(x) is true.
Thinking about Quantifiers
When the domain of discourse is finite, we can think of
quantification as looping through the elements of the domain.
To evaluate x P(x) loop through all x in the domain.
If at every step P(x) is true, then x P(x) is true.
If at a step P(x) is false, then x P(x) is false and the loop
terminates.
To evaluate x P(x) loop through all x in the domain.
If at some step, P(x) is true, then x P(x) is true and the loop
terminates.
If the loop ends without finding an x for which P(x) is true, then x
P(x) is false.
Even if the domains are infinite, we can still think of the
quantifiers this fashion, but the loops will not terminate in some
cases.
Properties of Quantifiers
The truth value of x P(x) and x P(x) depend on both the
propositional function P(x) and on the domain U.
Examples:
1. If U is the positive integers and P(x) is the statement
“x < 2”, then x P(x) is true, but x P(x) is false.
2. If U is the negative integers and P(x) is the statement
“x < 2”, then both x P(x) and x P(x) are true.
3. If U consists of 3, 4, and 5, and P(x) is the statement
“x > 2”, then both x P(x) and x P(x) are true. But if P(x) is
the statement “x < 2”, then both x P(x) and x
P(x) are false.
Precedence of Quantifiers
Even if the domains are infinite, you can still think of the
quantifiers in this fashion, but the equivalent expressions
without quantifiers will be infinitely long.
Negating Quantified
Expressions
Consider x J(x)
“Every student in your class has taken a course in
Java.”
Here J(x) is “x has taken a course in Java” and
the domain is students in your class.
Negating the original statement gives “It is not the
case that every student in your class has taken
Java.” This implies that “There is a student in your
class who has not taken Java.”
Symbolically ¬x J(x) and x ¬J(x) are equivalent
Negating Quantified
Expressions (continued)
Now Consider x J(x)
“There is a student in this class who has taken a
course in Java.”
Where J(x) is “x has taken a course in Java.”
Negating the original statement gives “It
is not the case that there is a student in
this class who has taken Java.” This
implies that “Every student in this class has
not taken Java”
Symbolically ¬ x J(x) and x ¬J(x) are
equivalent
De Morgan’s Laws for
Quantifiers
The rules for negating quantifiers are:
Mathematical Proofs
Forms of Theorems
Direct Proofs
Indirect Proofs
Proof of the Contrapositive
Proof by Contradiction
Proofs of Mathematical
Statements
A proof is a valid argument that establishes the truth of a
statement.
In math, CS, and other disciplines, informal proofs which are
generally shorter, are generally used.
More than one rule of inference are often used in a step.
Steps may be skipped.
The rules of inference used are not explicitly stated.
Easier for to understand and to explain to people.
But it is also easier to introduce errors.
Proofs have many practical applications:
verification that computer programs are correct
establishing that operating systems are secure
enabling programs to make inferences in artificial intelligence
showing that system specifications are consistent
Definitions
A theorem is a statement that can be shown to be true
using:
definitions
other theorems
axioms (statements which are given as true)
rules of inference
A lemma is a ‘helping theorem’ or a result which is needed
to prove a theorem.
A corollary is a result which follows directly from a theorem.
Less important theorems are sometimes called propositions.
A conjecture is a statement that is being proposed to be
true. Once a proof of a conjecture is found, it becomes a
theorem. It may turn out to be false.
Forms of Theorems
Many theorems assert that a property holds for all elements in
a domain, such as the integers, the real numbers, or some of
the discrete structures that we will study in this class.
Often the universal quantifier (needed for a precise
statement of a theorem) is omitted by standard
mathematical convention.
For example, the statement:
“If x > y, where x and y are positive real numbers, then
x2 > y2 ”
really means
“For all positive real numbers x and y, if x > y, then x2 >
y2 .”
Proving Theorems
Many theorems have the form:
where v = pu + qt
w = qu ≠ 0
Thus the sum is rational.
Proving Conditional
Statements: p → q
Proof by Contraposition: Assume ¬q and show ¬p is true also. This
is sometimes called an indirect proof method. If we give a direct
proof of ¬q → ¬p then we have a proof of p → q.
Why does this work?
Example: Prove that if n is an integer and 3n + 2 is odd,
then n is odd.
Solution: Assume n is even. So, n = 2k for some integer k.
Thus
3n + 2 = 3(2k) + 2 =6k +2 = 2(3k + 1) = 2j for j = 3k +1
Therefore 3n + 2 is even. Since we have shown ¬q → ¬p , p →
q must hold as well. If n is an integer and 3n + 2 is odd (not
even) , then n is odd (not even).
Proving Conditional
Statements: p → q
Proof by Contradiction: (AKA reductio ad absurdum).
To prove p, assume ¬p and derive a contradiction
such as p ∧ ¬p. (an indirect form of proof). Since we
have shown that ¬p →F is true , it follows that the
contrapositive T→p also holds.
A preview of Chapter 4.
Example: Use a proof by contradiction to give a proof that √2
is irrational.
Solution: Suppose √2 is rational. Then there exists integers a and b
with √2 = a/b, where b≠ 0 and a and b have no common factors. Then
Solution: ????
Looking Ahead
Proof by Cases
Existence Proofs
Constructive
Nonconstructive
Disproof by Counterexample
Nonexistence Proofs
Uniqueness Proofs
Proof Strategies
Proving Universally Quantified Assertions
Open Problems
Proof by Cases
To prove a conditional statement of the form:
Case 1: a ≥ b ≥ c
(a @ b) = a, a @ c = a, b @ c = b
Hence (a @ b) @ c = a = a @ (b @ c)
Therefore the equality holds for the first case.
We only cover the case where x is odd because the case where y is odd is
similar. The use phrase without loss of generality (WLOG) indicates
this.
Existence Proofs
Mathematical Induction
Examples of Proof by Mathematical Induction
Mistaken Proofs by Mathematical Induction
Guidelines for Proofs by Mathematical Induction
Climbing an
Infinite Ladder
Suppose we have an infinite ladder:
1. We can reach the first rung of the ladder.
2. If we can reach a particular rung of the
ladder, then we can reach the next rung.
We can conjecture that the sum of the first n positive odd integers is n2,
Assume the inductive hypothesis holds and then show that P(k + 1) holds has well.
Hence, we have shown that P(k + 1) follows from P(k). Therefore the sum of the first n positive odd integers is n2.
Proving Inequalities
Example: Use mathematical induction to prove that n < 2n for all positive
integers n.
Solution: Let P(n) be the proposition that n < 2n.
BASIS STEP: P(1) is true since 1 < 21 = 2.
INDUCTIVE STEP: Assume P(k) holds, i.e., k < 2k, for an arbitrary positive integer k.
Must show that P(k + 1) holds. Since by the inductive hypothesis, k < 2k, it follows
that:
k + 1 < 2k + 1 ≤ 2k + 2k = 2 ∙ 2k = 2k+1
Therefore n < 2n holds for all positive integers n.
Proving Inequalities
Example: Use mathematical induction to prove that 2n < n!, for every
integer n ≥ 4.
Solution: Let P(n) be the proposition that 2n < n!.
BASIS STEP: P(4) is true since 24 = 16 < 4! = 24.
INDUCTIVE STEP: Assume P(k) holds, i.e., 2k < k! for an arbitrary integer k ≥
4. To show that P(k + 1) holds:
2k+1 = 2∙2k
< 2∙ k! (by the inductive hypothesis)
< (k + 1)k!
= (k + 1)!
Therefore, 2n < n! holds, for every integer n ≥ 4.
Note that here the basis step is P(4), since P(0), P(1), P(2), and P(3) are
all false.
Proving Divisibility Results
continued
→
Number of Subsets of a Finite Set
Inductive Hypothesis: For an arbitrary nonnegative integer
k, every set with k elements has 2k subsets.
By the inductive hypothesis S has 2k subsets. Since there are two subsets of T for each
subset of S, the number of subsets of T is 2 ∙2k = 2k+1 .
Tiling Checkerboards
Example: Show that every 2n ×2n checkerboard with one square removed can be tiled using right
triominoes.
INDUCTIVE STEP: Assume that P(k) is true for every 2k ×2k checkerboard, for some positive integer k.
continued
→
Tiling Checkerboards
Consider a 2k+1 ×2k+1 checkerboard with one square removed. Split this checkerboard into four checkerboards of size 2k ×2k,by dividing it
in half in both directions.
Remove a square from one of the four 2k ×2k checkerboards. By the inductive hypothesis, this board can be tiled. Also by the inductive
hypothesis, the other three boards can be tiled with the square from the corner of the center of the original board removed. We can then
cover the three adjacent squares with a triominoe.
Hence, the entire 2k+1 ×2k+1 checkerboard with one square removed can be tiled using right triominoes.
An Incorrect “Proof” by
Mathematical Induction
Example: Let P(n) be the statement that every set of n lines in the
plane, no two of which are parallel, meet in a common point. Here
is a “proof” that P(n) is true for all positive integers n ≥ 2.
BASIS STEP: The statement P(2) is true because any two lines in the plane
that are not parallel meet in a common point.
INDUCTIVE STEP: The inductive hypothesis is the statement that P(k) is
true for the positive integer k ≥ 2, i.e., every set of k lines in the plane, no
two of which are parallel, meet in a common point.
We must show that if P(k) holds, then P(k + 1) holds, i.e., if every set of k
lines in the plane, no two of which are parallel, k ≥ 2, meet in a common
point, then every set of k + 1 lines in the plane, no two of which are
parallel, meet in a common point.
continued
→
An Incorrect “Proof” by
Mathematical Induction
Inductive Hypothesis: Every set of k lines in the plane,
where k ≥ 2, no two of which are parallel, meet in a
common point.
Consider a set of k + 1 distinct lines in the plane, no two parallel. By the inductive
hypothesis, the first k of these lines must meet in a common point p1. By the inductive
hypothesis, the last k of these lines meet in a common point p2.
If p1 and p2 are different points, all lines containing both of them must be the same
line since two points determine a line. This contradicts the assumption that the lines are
distinct. Hence, p1 = p2 lies on all k + 1 distinct lines, and therefore P(k + 1) holds.
Assuming that k ≥2, distinct lines meet in a common point, then every k + 1 lines meet in a
common point.
There must be an error in this proof since the conclusion is absurd. But where is the error?
Answer: P(k)→ P(k + 1) only holds for k ≥3. It is not the case that P(2) implies P(3). The first
two lines must meet in a common point p1 and the second two must meet in a common
point p2. They do not have to be the same point since only the second line is common to
both sets of lines.
Guidelines:
Mathematical Induction Proofs
Kenneth H. Rosen (2012)
Discrete Mathematics and its Applications, 7th ed.