Predicate Calculus PDF
Predicate Calculus PDF
Mbigili L.J
Mzumbe University
Introduction
In this section, we will be introduced to a
more powerful tool of logic called
predicate logic, that can handle such
cases.
Introduction
We will see how predicate logic can be used
to express the meaning of a wide range of
statements in mathematics and computer
science in ways that permit us to reason
and explore relationships between objects.
Introduction
To understand predicate logic, we first
need to be introduced to the concept of a
Predicate.
Predicates
Statements involving variables, such as
Predicates
Statements involving variables, such as
a) x > 3 (b) x = y + 3 (c) x + y = z
Predicates
Statements involving variables, such as
a) x > 3 (b) x = y + 3 (c) x + y = z
d) “Computer x is functioning properly”.
Predicates
Statements involving variables, such as
a) x > 3 (b) x = y + 3 (c) x + y = z
d) “Computer x is functioning properly”.
e) “Computer y is under attack by an
intruder”. are often found in mathematical
assertion, in computer programs, and in
system specifications.
Predicates
And from the examples above we have the
following definition.
Definition (Predicate)
A predicate is a statement containing variables.
Predicates
We can also have statements that involve
more than one variable.
Predicates
We can also have statements that involve
more than one variable.
For instance, consider the statement
“x = y + 3”.
Predicates
Example 3: Let Q(x, y) denote the
statement “x = y + 3”. What are the
truth values of the proposition
Q(1, 2), Q(2, 3), Q(3, 0) and Q(8, 5).
Predicates
P is also called an n−place predicate or a
n−ary predicate.
Predicates
P is also called an n−place predicate or a
n−ary predicate.
Propositional functions occur frequently in
computer programs.
Predicates
Solution: For the precondition, we
need to express that x and y have
particular values before we run the
program.
Predicates
So for this precondition we can use the
predicate P (x, y), where P (x, y) is the
statement “x = a and y = b”, where a and
b are the values of x and y before we run
the program.
Predicates
To verify that the program always does
what it is supposed to do. Suppose that
the precondition P (x, y) holds.
Predicates
To verify that the program always does
what it is supposed to do. Suppose that
the precondition P (x, y) holds.
That is, we suppose that the statement
“x = a and y = b”is true.
Predicates
This means that x = a and y = b.
Predicates
This means that x = a and y = b.
The first step of the program mict := x,
assigns the value of x to the variable mict.
Predicates
So after this step we know that
x = a, mict = a and y = b.
Predicates
So after this step we know that
x = a, mict = a and y = b.
After the second step, of the program,
x := y, we know that x = b, mict = a and
y = b.
Predicates
Finally, after the third step, we know that
x = b, mict = a and y = a.
Predicates
Finally, after the third step, we know that
x = b, mict = a and y = a.
Consequently, after this program is run,
the postcondition Q(x, y) holds, that is the
statement x = b and y = a is true.
Quantifiers
Quantification expresses the extend to
which a predicate is true over the range of
elements.
Quantifiers
Quantification expresses the extend to
which a predicate is true over the range of
elements.
In English, the words, all, some, many,
none and few are used in quantification.
Universal Quantification
We read ∀xP (x) as “for all xP (x)”or “for
every xP (x)”.
Universal Quantification
We read ∀xP (x) as “for all xP (x)”or “for
every xP (x)”.
An element for which P (x) is false is called
a Counterexample of ∀xP (x).
Universal Quantifier
Example 9: Let Q(x) be the statement
“x < 2”. What is the truth value of the
quantification ∀xP (x), where the domain
consists of all real numbers?
Universal Quantification
Solution: Q(x) is not true for every real
number x, because for instance, Q(3) is
false.
Universal Quantification
Solution: Q(x) is not true for every real
number x, because for instance, Q(3) is
false.
That is x = 3 is a counterexample for the
statement ∀xQ(x). Thus ∀xQ(x) is false.
Universal Quantification
Example 10: Suppose that P (x) is a
statement “x2 > 0”. To show that the
statement ∀xP (x) is false where the
universe of discourse consists of all
integers, we give a counterexample.
Universal Quantification
Example 11: What is the truth value of
∀xP (x), where P (x) is the statement
x2 < 10 and the domain consists of the set
of positive integers not exceeding 4?
Universal Quantification
Example 12: What does the statement
∀xN (x) mean, if N (x) is the “Computer
x is connected to the university
network”and the domain is the set of all
computers on campus?
Universal Quantification
Example 13: (a) What is the truth value
of ∀x(x2 ≥ x) if the domain consists of all
real numbers? (b) What is the truth value
of this statement if the domain consists of
all integers?
Existential Quantifier
Many mathematical statements assert that
there is an element with certain property.
Existential Quantifier
Many mathematical statements assert that
there is an element with certain property.
Such statements are expressed using
existential quantification.
Existential Quantifier
With existential quantification, we form a
proposition that is true if and only if
P (x) is true for at least one value of x in
the domain.
Existential Quantification
We use the notation ∃xP (x) for the
existential quantification of P (x), and ∃ is
called the Existential quantifier.
Existential Quantifier
Besides, the word “There exists”, we can
also express existential quantification in
many other ways such as “For some”,
“For at least”, or “There is”.
Existential Quantifier
The existential quantification ∃xP (x) is
read as “There is an x such that
P (x)”OR “There is at least one x such
that P (x)”OR “For some xP (x)”.
Existential Quantifier
Example 14: Let P (x) denote the
statement “x > 3”. What is the truth
value of the quantification ∃xP (x), where
the domain consists of all real numbers?
Existential Quantifier
Solution: Because “x > 3”is sometimes
true, for instance, when x = 4, then the
existential quantification of P (x) which is
∃xP (x) is true.
Existential Quantifier
Example 15: Let Q(x) denote the
statement “x = x + 1”. What is the truth
value of the quantification ∃xQ(x), where
the domain consists of all real numbers?
Existential Quantifier
Example 16: What is the truth value of
∃xP (x), where P (x) is the statement
“x2 > 10”and the universe of discourse
consists of the set of positive integers not
exceeding 4?
Other Quantifiers
The quantifiers we have seen so far are the
most important quantifiers in Mathematics
and Computer Science.
Other Quantifiers
However, there exist some different
quantifiers such as, “There are exactly
two”, “There are no more than
three”, “There are at least 100”and
so on.
Other Quantifiers
Of these quantifiers, the one that is most
often seen is the Uniqueness
quantifier, denoted by ∃! OR ∃1.
Other Quantifiers
In some occasion, it is necessary that
uniqueness quantifier be formulated as a
separate concept from existence, albeit
instead requiring the universal quantifier.
Other Quantifiers
The idea is that uniqueness states that
“if any two, not necessarily
different objects in S satisfy the same
particular statement P , then they must
in fact be the same object.”
Other Quantifiers
Finally we note that a proof of a statement
such as (∃!x ∈ S)P (x) is thus usually
divided into two separate proofs:
Other Quantifiers
Finally we note that a proof of a statement
such as (∃!x ∈ S)P (x) is thus usually
divided into two separate proofs:
1) Existence: (∃x ∈ S)P (x)
Other Quantifiers
Finally we note that a proof of a statement
such as (∃!x ∈ S)P (x) is thus usually
divided into two separate proofs:
1) Existence: (∃x ∈ S)P (x)
2) Uniqueness:
(∀, x, y ∈ S)[P (x) ∧ P (y) −→ x = y]
Other Quantifiers
In this setting, the existence is an axiom so
there is nothing to prove.
Other Quantifiers
In this setting, the existence is an axiom so
there is nothing to prove.
We turn then to the uniqueness.
Other Quantifiers
A proof is best written in prose, but it is
based upon proving that
(∀z1, z2 ∈ R)
[(z1 is an add. identity) ∧ (z2 is an add. ident
Other Quantifiers
This argument showed that if z1 and z2 are
any real numbers which act as additive
identities, then z1 = z2.
Other Quantifiers
In other words, if there are any, there is in
fact only one.
Other Quantifiers
In other words, if there are any, there is in
fact only one.
Of course, assuming existence we call that
unique real number zero.
Binding Variables
When a quantifier is used on the variable
x, we say that this occurrence of the
variable is Bound.
Binding Variables
When a quantifier is used on the variable
x, we say that this occurrence of the
variable is Bound.
An occurrence of a variable that is not
bound by a quantifier is said to be Free.
Note that
Example 19: Show that
∀x(P (x) ∧ Q(x)) and ∀xP (x) ∧ ∀xQ(x)
are logically equivalent(where the same
domain is used throughout).
Note that
However, we cannot distribute a universal
quantifier over a disjunction, nor can we
distribute an existential quantifier over a
Conjunction.
which is equivalent to
Alternatively
For example, we may be interested in a
wider group of people, than only those in
this class.
Alternatively
We can also use two variable quantifier
Q(x, y) for the statement “student x has
studied subject y”.
Nested Quantifiers
Consider the following sets: M = {Men}
and W = {Women}.
Nested Quantifiers
Note that (2) allows that different men
may need different women to love them,
and also that a given man may be loved by
more than one woman.
Nested Quantifiers
In other way, this would read more like,
“there exists a woman such that, for
every man, she loves him.”
Nested Quantifiers
Thus
∀m∀w[w loves m] ⇔ ∀w∀m[w loves m]
∃m∃w[w loves m] ⇔ ∃w∃m[w loves m]
(6)
Nested Quantifiers
In both representations in the existential
statements, we are stating that “there is
at least one man and one woman such
that she loves him.”
Nested Quantifiers
In fact that above equivalence is also valid
if we replace ∃ with ∃!, though it would
mean then that “there is exactly one man
and exactly one woman such that the
woman loves the man.”