Chapter1 4
Chapter1 4
All slides' contents are adapted from the book Discrete Mathematics and its Applications by Rosen, 8th edition.
1
The Foundations:
Logic and Proofs
Chapter 1
2
The Foundations:
Logic and Proofs
3
Outline
Predicates
Quantifiers
Quantifiers over finite domains
Quantifiers with Restricted Domains
Precedence of Quantifiers
Binding Variables
Logical Equivalences Involving Quantifiers
Negating Quantified Expressions
Translating from English into Logical Expressions
Using Quantifiers in System Specifications
4
1 Predicates
5
Predicates (Propositional
Functions)
“x is greater than 3”
This statement is neither true nor false when the value of the
variable is not specified.
This statement has two parts:
The first part (subject of the statement) is the variable x.
The second (predicate) is “is greater than 3”, refers to a
property that the subject of the statement can have.
6
6
Predicates (Propositional
Functions)
7
Predicates (Propositional
Functions)
Propositional functions become propositions (and have truth values)
when their variables are each replaced by a value from the domain.
For example, let P(x) denote “x > 0” and let the domain be the set of
integers. Then:
P(-3) is false
P(0) is false
P(3) is true
Often the domain is denoted by U. So in this example U is the set of
integers.
8
Examples of Propositional Functions
Let “x + y = z” be denoted by R(x, y, z) and U (for all three variables) be the set of
integers. Find these truth values:
R(2,-1,5)
Solution: F
R(3,4,7)
Solution: T
R(x, 3, z)
Solution: Not a Proposition
Now let “x - y = z” be denoted by Q(x, y, z), with U as the set of 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 9
Predicates (Propositional
Functions)
Let P(x) denote “x is greater than 3”. What are the truth values
of P(4) and P(2)?
Let Q(x,y) denote “x = y+3”. What are the truth values of Q(1,2)
and Q(3,0)?
Let A(c,n) denote “computer c is connected to network n”,
suppose that the computer MATH1 is connected to network
CAMPUS2, but not to network CAMPUS1. What are the truth
values of: A(MATH1, CAMPUS1) and A(MATH1, CAMPUS2) ?
10
Predicates (Propositional
Functions)
Propositional functions (Predicates) occur in
computer programs:
P(x) : “x>0”
11
Compound Expressions:
Examples
Connectives from propositional logic carry over to predicate logic.
If P(x) denotes “x > 0,” find these truth values:
P(3) ∨ P(-1) Solution: T
P(3) ∧ P(-1) Solution: F
P(3) → P(-1) Solution: F
P(-1) → P(3) Solution: T
12
Propositional Logic Not
Enough
If we have:
“All men are mortal.”
“Socrates is a man.”
13
Predicate Logic/Calculus
Some people are killers. All killers are evil. Therefore, some people are evil.
A more powerful formalism that will let us capture sentences like the one
above is the Predicate Logic.
14
Introducing Predicate Logic
15
2
Quantifiers
16
Predicate Logic (Calculus)
\
17
Quantification
We need quantifiers to express the meaning of English
words including all and some:
“All men are Mortal.”
“Some cats have fur.”
The two most important quantifiers are:
Universal Quantifier, “For all,” symbol:
Existential Quantifier, “There exists,” symbol:
We write as in x P(x) and x P(x).
x P(x) asserts P(x) is true for every x in the
domain.
x P(x) asserts P(x) is true for some x in the domain.
18
Universal Quantifier:
Tells
us that a predicate is true for every element under consideration
( Domain / Universe of discourse).
The universal quantification of P(x) is the statement: “P(x) for all values
of x in the domain”
x P(x) read as “for all x P(x)” or “for every x P(x)”
is called universal quantifier .
An element for which P(x) is false is called a counterexample to ∀xP(x).
19
Universal Quantifier: Example
In our example:
If we let, K represents “is a killer ” and E represents “is
evil”, then we can write the sentence “all killers are evil” as:
x (K(x) E(x));
20
Existential Quantifier
21
Existential Quantifier:
In our example :
The sentence: “some people are killers” can be written as:
x (K(x));
which basically states that, there is at least one person who
is a killer.
22
Quantifiers
23
Quantifiers and Truth Values
x P(x)
True when: P(x) is true for every x.
False when: there is an x for which P(x) is false.
x P(x)
True when: There is an x for which P(x) is true
False when: P(x) is false for every x.
24
Domain of discourse/Universe of
discourse/ Domain
Note:
The domain specifies the possible values of the variable x. The
meaning of the quantification of P(x) changes when we change the
domain. The domain must always be specified when a quantifier is
used; without it, quantification of a statement is not defined.
25
Universal Quantifier: Examples
Examples:
If P(x) denotes “x > 0” and U is the integers, then x P(x) is false.
26
Existential Quantifier: Examples
x P(x) is read as “For some x, P(x)”, or as “There is an x such that P(x),” or “For
at least one x, P(x).”
Examples:
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.
If P(x) denotes “x < 0” and U is the positive integers, then x P(x) is false.
27
More examples for
Universal
quantifier
28
Example 1
Let Q(x) be “x<2” . What is the truth value of x Q(x) when the
domain consists of all real numbers?
Q(x) is not true for every real number x, for example Q(3) is
false.
29
Example 2
Example:
What is the truth value of x (x2 x) when the domain consists of:
Solution:
30
Example 3
Example:
Let Q(x) be “x2>0”. What is the truth value of ∀ x Q(x) when the
domain consists of all integer numbers?
Q(x) is not true for every integer number x, for example Q(0) is
false.
31
More examples for
Existential
quantifier
32
Example 1
Example:
Let Q(x) be “x=x+1”. What is the truth value of x Q(x) when the
domain consists of all real numbers?
33
Example 2
Example:
Let Q(x) be “x>3”. What is the truth value of x Q(x) when the
domain consists of all real numbers?
34
The uniqueness
quantifier
35
The uniqueness quantifier
Uniqueness Quantifier ∃! or ∃1
36
The uniqueness quantifier
Uniqueness Quantifier ∃! or ∃1
Examples:
37
Quantifiers over
3
finite domains
38
Quantifiers over finite domains
Example:
Let Q(x) be “x2<10”. What is the truth value of x Q(x)
when the domain consists of the positive integers not exceeding 4?
40
Quantifiers over finite domains
Example:
Let Q(x) be “x2<10”. What is the truth value of x Q(x), when the
domain consists of the positive integers not exceeding 4?
41
Connections between quantifications
and looping
If the domain consists of n (finite) objects and we need to
determine the truth value of:
∀x Q(x)
Loop through all n values of x to see if Q(x) is always true.
If you encounter a value x for which Q(x) is false, exit the loop
with ∀x Q(x) is false.
Otherwise ∀x Q(x) is true.
∃x Q(x)
Loop through all n values of x to see if Q(x) is true.
If you encounter a value x for which Q(x) is true, exit the loop
with ∃x Q(x) is true.
Otherwise ∃x Q(x) is false.
42
The domain
Note:
Generally, an implicit assumption is made that all domains of discourse for
quantifiers are nonempty.
If the domain is empty, then ∀x P(x) is true for any propositional function P(x),
because there are no elements x in the domain for which P(x) is false.
If the domain of discourse is empty, then ∃x Q(x) is false whenever Q(x) is a
propositional function, because when the domain is empty, there can be no element
x in the domain for which Q(x) is true.
43
The domain
Note:
A domain of discourse must always be specified when a statement ∃x
P(x) is used.
44
Infinite domains
The truth value of x P(x) and x P(x) depends on both the propositional function
P(x) and on the domain U.
Examples:
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.
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.
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.
45
Quantifiers with
4
restricted domain
46
Quantifiers with restricted
domain
What do these statements mean (domain real)
47
5 Precedence of Quantifiers
48
Precedence of Quantifiers
The quantifiers and have higher precedence than all the logical
operators .
49
6 Binding Variables
50
Binding Variables
When a quantifier is used on the variable x, we say that this occurrence of the
variable is bound.
x (x + y =1)
The variable x is bounded by the existential quantification x and the variable
y is free.
51
Binding Variables
52
Again…
x ( x y 1)
Bound free
variable variable
53
Logical Equivalences
7
Involving Quantifiers
54
Logical Equivalence involving
Quantifiers
Statements involving predicates and quantifiers are logically
equivalent iff they have the same truth value.
Hence, both P(a) and Q(a) are true for every element in the domain.
55
Next
suppose that ∀x P(x) ∀x Q(x) is true, it follows that both
∀x P(x) and ∀x Q(x) are true hence, if a is in the domain then
P(a) is true and Q(a) is true
This means that ∀x (P(x) Q(x)) is true.
56
Logical Equivalences with
Quantifiers
x ( P( x) Q( x)) xP( x) xQ( x)
x ( P ( x) Q( x)) xP ( x) xQ( x)
57
Negating Quantified
8
Expressions
58
Negating Quantified Expressions
Negation is:
“It is not the case that every student in your class has taken a calculus course.”
This implies that:
“There is a student in your class who has not taken calculus.”
x P(x)
i.e.,
x P(x) x P(x)
59
Negating Quantified Expressions
Symbolically
¬ x J(x) and x ¬J(x) are equivalent.
60
De Morgan’s laws for quantifiers
62
Negating Quantified Expressions
What are the negations of:
∀x (x2>x)
∃x (x2=x)
Solutions:
∀x (x2>x)
∀x (x2>x) ∃x (x2>x) ∃x (x2 x)
∃x (x2=x)
∃x (x2=x) ∀x (x2=x) ∀x (x2 x)
63
Negating Quantified Expressions
Solution:
∀x [P(x) Q(x)] ∃x [P(x) Q(x)] Negating
Quantifiers
∃x [P(x) Q(x)] Implication rule
∃x [ P(x) Q(x)] DeMorgan’s law
∃x [P(x) Q(x)] Double Negation
law
Recall that:
( p q) p q
64
Translating from English
9
into Logical Expressions
65
Translating from English into Logical
Expressions
66
Translating from English into Logical
Expressions
If we change the domain to consist of all people;
We need to express our statement as:
“For every person x, if person x is a student in this class, then
x has studied calculus”
C(x): “x has studied calculus”
S(x): “person x is a student in the class”
x (S(x) C(x))
Caution:
our statement cannot be expressed as:
x (S(x) C(x));
Which means: “All people are students in this class and have
studied calculus”. 67
Translating from English into Logical
Expressions
Finally, when we are interested in the background of people in
subjects besides calculus, we may prefer to use the two - variable
quantifier Q(x , y).
69
Translating from English into Logical
Expressions
If we are interested in people other than in this class, we look the
statement as:
“There is a person x having the properties that x is
a student in this class and x has visited Bahrain”;
In this case, the domain for the variable x consists of all people.
Let S(x): “x is a student in this class”
x (S(x) B(x)).
Caution:
This statement cannot be expressed as: x (S(x) B(x))
Which is true when there is someone not, in the class, because in this
class for such a person x,
S(x) B(x), becomes either FT or FF,
both of which are true !
Check the third case in page 53 (exercise 24)
70
Translating from English into Logical
Expressions
P ( x) x is a humming bird
Q( x) x is large bird Universe of
discourse is all birds.
R ( x) x lives on honey
S ( x) x is richly colored
72
Using Quantifiers in System
Specifications
m (S(m,1) C(m))
73
Using Quantifiers in System
Specifications
Express the statement “If a user is active, at least one network link
will be available” using predicates and quantifiers.
Let A(u): “user u is active” , where u has the domain of all users.
74
Summary
Predicates
Quantifiers
Quantifiers over finite domains
Quantifiers with Restricted Domains
Precedence of Quantifiers
Binding Variables
Logical Equivalences Involving
Quantifiers
Negating Quantified Expressions
Translating from English into
Logical Expressions
Using Quantifiers in System
Specifications
75
Reference
76