Lecture Ten - Predicate Logic
Lecture Ten - Predicate Logic
• Universal quantification
• Existential quantification
• Satisfaction and validity
• The negation of quantifiers
• Free and bound variables
• Substitution
• Restriction
• Uniqueness
• Equational reasoning
• Natural deduction
• One point rule
Page 2
Pros and cons of propositional
logic
• Propositional logic is declarative
Page 6
Universal Quantification
• Universal Quantification denoted as
• Universal Quantification allows us to capture
statements of the form “for all” or “for every”.
• For example, “every natural number is
greater than or equal to zero” can be written
formally as
n : N n 0
Page 7
Universal Quantification
• A quantified statement consists of three
parts: the quantifier, the quantification,
which describes the variables and the type of
variable with which the statement is
concerned and the predicate which is
normally some statement about the
quantified variables.
• Every predicate logic statement can be
considered as follows
quantifier quantifica tion predicate
Page 8
Universal Quantification
m, n : N m n m n m n
m : N ; n : N m n m n m n
m : N n : N m n m n m n
Page 9
Exercise
• Everybody likes Jaffa cakes
• All vegetarians don’t like Jaffa cakes
• Everybody either likes Jaffa cakes or is
a vegetarian
• Either every body likes Jaffa cakes or
everybody is a vegetarian
Page 10
Solution
Page 11
Universal Quantification
• Law 1
((x : X p ) (x : X q )) (x : X p q )
• Example
((p : Person p is tall) (p : Person p is strong))
(p : Person p is tall p is strong)
Page 12
Universal Quantification
• Law 2
(x : X p q ) ((x : X p ) (x : X q ))
• Example
((p : Person p is tall) (p : Person p is strong))
(p : Person p is tall p is strong)
Page 13
Existential quantification
• Existential quantifier denoted by
• As universal quantification is used to
assert that a certain property holds of
every element of a set, existential
quantification is used to assert that such a
property holds of some (or at least)
elements of a set
• “Some natural numbers are divisible by 3”
may be written as n : N n mod 3 0
Page 14
Exercise
• Some people like Jaffa cakes
• Some vegetarians don’t like Jaffa cakes
• Some people either like Jaffa cakes or
are vegetarian
• Either some people like Jaffa cakes or
some people are vegetarian
Page 15
Solution
x : People x likes Jaffa cakes
x : People x is vegetarian (x likes Jaffa cakes)
x : People (x likes Jaffa cakes x is vegetaria n)
(x : People x likes Jaffa cakes) (x : People x is vegetarian)
Page 16
Existential quantification
• Law 3
(x : X p q ) ((x : X p ) (x : X q ))
• Example
(c : Car fast (c ) small (c ))
((c : Car fast (c )) (c : Car small (c )))
Page 17
Existential quantification
• Law 4
(x : X p q) ((x : X p ) (x : X q ))
• Example
c : Car fast (c) small (c))
((c : Car fast (c)) (c : Car small (c)))
Page 18
Satisfaction and validity
• The predicate n>3 can be considered neither true
nor false unless we know the value associated with
n
• Example
The predicate n 0 is satisfiabl e as n : N n 0
is equivalent to true
Page 20
Satisfaction and validity
• A predicate p is unsatisfiable if, and only if, it
is false for all possible values of the
appropriate type.
Page 21
Satisfaction and validity
• The analogies between valid, satisfiable and
unsatisfiable predicates, and tautologies,
contingencies and contradictions:
• valid predicates and tautologies are always
true
• satisfiable predicates and contingencies are
sometimes true and sometimes false
• unsatisfiable predicates and contradictions
are never true
Page 22
The negation of quantifiers
• The statement “some body like Brian” may
be expressed via predicate logic as
p : Person p likes Brian
Page 23
The negation of quantifiers
• Logically saying “nobody likes Brian” is equivalent to
saying “everybody does not like Brian”.
• The negation of quantifiers behaves exactly in this
fashion, just as in natural language, “nobody likes
Brian” and “everybody does not like Brian” are
equivalent so in predicate logic
(p : Person p likes Brian)
• And
p : Person ( p likes Brian)
• are equivalent.
Page 24
The negation of quantifiers
• Law 5
(x : X p ) x : X p
(x : X p ) x : X p
Page 25
The negation of quantifiers
• Consider the statement,
x : X y : Y z : Z p ( x, y , z )
Page 27
Free and bound variables
• Consider two predicates
• n>5…..Eq. 1
n : N n 5.....Eq.2
Page 28
Free and bound variables
• Example
(y : People y likes robin) x likes richard
• In this statement, y and x are two variables. y is
universally quantified and it is bound, while x is free
variable.
• In statement, x : X p
• The occurrence of x in the declaration is binding, any
occurrences of x in p are bound, and any occurrences
of any variables other than x are free
Page 29
Free and bound variables
• Example
(x : N x 0 y x ) x 3
• Exercise, Determine the scope of the universal and
existential quantifiers of the following predicate,
(x : X p (y : Y q ) r )
• The distinction between predicates and propositions can
be stated as predicates are logical statements which can
contain free variables while propositions are logical
statements which contain no such holes
Page 30
Substitution
• Consider statement,
n : N n 5
• we may replace the name n with any term t,
provided that t is of the same type as n. This process
is called substitution: the expression p[t/n] denotes
the fact that the term t is being substituted for the
variable name n in the predicate p.
Page 32
Substitution
• More than one substitution in case of more than one free
variable
x is happy y is sad
• Consider predicate,
• Here x and y are both free variables. We may substitute
nigel for x as follows,
(x is happy y is sad)[nigel /x]
nigel is happy y is sad
Page 33
Substitution
• Similarly, in one step, overall substitution may be
denoted as,
(x is happy y is sad)[nigel/x][ken/y]
• These two substitutions take place sequentially,
first nigel is substituted for x, then ken is
substituted for y. However, for simultaneous
substitutions,
(x is happy y is sad)[nigel /x, ken/y]
Page 34
Substitution
• To illustrate the difference between sequential and
simultaneous substitution, consider the example,
( x 3 y 7)[ y / x,8 / y ]
y 38 7
( x 3 y 7)[ y / x][8 / y ]
y 3 y 7[8 / y ]
8 38 7
true
n : N | n is prime n 2 n is odd
n : N (n is prime n 2) n is odd
Page 37
Restriction
• Law 6
(x : X | p t) (x : X p t)
• Law 7
(x : X | p t ) (x : X p t )
Page 38
Exercise
• Represent the following statement in the
form,
quantifier quantifica tion | restrictio n predicate
Page 39
Solution
p : People | p likes cheese p likes spam
p : People | p likes cheese p likes spam
p : People | p likes cheese p likes spam p likes bananas
Page 40
Uniqueness
• Existential quantifier, allows us to represent
statements such as “there is at least one x,
such that…”.
• In order to be more specific, consider, “there
is exactly one x, such that…”
• Consider an example statement,
x : N x 1 1
it is the case that the predicate x+1=1 is true
for exactly one natural number:0
Page 41
Uniqueness
• The operator which allow us to state that “
there is exactly one natural number, x, is
denoted as 1
1 x : N x 1 1
• As an example,
1c : Country c is a richest
Page 42
Uniqueness
• Assuming the statement
1 x : X p
• It is sometimes useful to pinpoint exactly which
element of X for which predicate p holds. Also, it
is convenient to perform some operation on this
value.
• The µ operator allows us to do exactly this, the
statement (µx:X | p) is read as “ the unique x
from set X such that p holds of x”
• Example, (µx:N | x+1=1) where µ is associated
with value 0
Page 43
Uniqueness
• When a unique element of the relevant type does possess
the relevant property, then we are free to construct
statements as given previously
• On the other hand, µ expressions that are not associated
with a unique element generate an undefined value.
• As an example, the µ expressions
(µn:N | n is even)
and
(µc:Country | population (c) > 10,000,000)
are both undefined
Page 44
Uniqueness
• We can incorporate terms into set
comprehensions, so we can apply terms in µ
expressions. Expressions of the form,
( x : X | p t )
• return the result of applying the term t to the
unique element of the set X which satisfies the
predicate p
( c : Country | c is richest capital(c))
Page 45
Uniqueness
• If there is no unique element which possesses
the relevant property, then the result is
undefined
( n : N | n is even n 2 )
• and
( c : Country | population (c) 10,000,000 capital(c))
• are both undefined.
Page 46
Exercise
• Write the following in terms of µ
expressions
– The tallest mountain in the world
– The height of the tallest mountain
– The oldest person in the world
– The nationality of the oldest person in the
world
– The smallest natural number
Page 47
Solution
Page 48
Equational Reasoning
• Two methods of reasoning
– Equational reasoning
– Natural deduction
• Also,
x : X | p t
x : X p t
x : X | p t
x : X p t
Page 49
Equational Reasoning
• Law 8
If a predicate holds for all elements of a set,
then it holds for some of them
x : X p x : X p
• Law 9
If a predicate holds for exactly one element
of a set, then it holds for at least one of them
1 x : X p x : X p
Page 50
Equational Reasoning
• Law 10
If p holds for all elements of X and t is a term of type
X, then p holds for t
(x : X p(x) tX) p(t)
Example, prime(x) x 2 x is odd
The predicate
holds for all natural numbers. The term 3+4 is of type N
and as such,
prime(3 4) 3 4 2 3 4 is odd
holds.
Page 51
Equational Reasoning
• Law 11
This law states that if t is a term of type X
and p holds of t, then we can conclude that
p holds for some elements of X
(tX p (t )) (x : X p ( x))
• Example
The proposition 7εN is true and furthermore
7 is prime. As such, n : N n is prime
Page 52
Equational Reasoning
• The quantification of any variables with regards to propositions
which are always true or always has absolutely no effect. This
notion is captured by following laws,
• Law 12
(x : X true) true
• Law 13
(x : X true) true
• Law 14
(x : X false) false
• Law 15
(x : X false) false
Page 53
Equational Reasoning
• The predicate x : X p(x) y z is concerned
with three variables: x, y and z.
• x is bound and y and z are free. As x does not
appear in the predicate y=z, we are free to
assume that the existential quantification of x
has no effect on the truth or falsity of that
predicate.
• We conclude that following equivalence holds.
x : X ( p( x) y z )
(x : X p( x)) y z
Page 54
Equational Reasoning
• Law 16
It states that as x does not appear free in q,
the following holds
(x : X p q ) ((x : X p ) q )
• Example,
(n : N n 3 l 10) ((n : N n 3) l 10)
Page 55
Equational Reasoning
• Law 17
It states that as x does not appear free in q,
the following holds,
(x : X p q) ((x : X p) q )
• Example
(n : N n 3 l 10) ((n : N n 3) l 10)
Page 56
Equational Reasoning
• Law 18
It states as x does not appear free in q, the
following holds
(x : X p q) ((x : X p ) q)
• Example
(p : Person p likes spam l 10)
((p : Person p likes spam) l 10)
Page 57
Equational Reasoning
• Law 19
It states as x does not appear free in q, the
following holds
(x : X p q ) ((x : X p ) q )
• Example
(p : Person p likes spam l 10)
((p : Person p likes spam) l 10)
Page 58
Equational Reasoning
• Example: A theorem in predicate logic
(x : X p q ) (x : X p q )
• Proof:
x : X p q
x : X ( p q) (law 5)
x : X (p q ) (propositi onal law)
x : X p q (propositi onal law)
Page 59
Equational Reasoning
• Example Theorem
((x : X p) (x : X q)) (x : X p q)
((x : X p) (x : X q))
(x : X p) (x : X q) (propositi onal law)
(x : X p) (x : X q) (law 5)
(x : X p) (x : X q) (law 8)
x : Xp q (law 3)
x : X p q (law 18)
Page 60
Exercise
Page 61
Solution
x : X p q
x : X p q (propositi onal law)
(x : X p ) (x : X q ) (law 3)
(x : X p ) (x : X q ) (law 5)
(x : X p) (x : X q) (law 18)
Page 62
Natural deduction
• Natural deduction can also be extended to
predicate logic
• Natural deduction rules for universal
quantification
x : X p tx
( elim)
p (t / x )
• Rule1 states that if p holds for all values of X,
then provided that t is of type X- p holds for t
Page 63
Natural deduction
• Example:
All natural numbers which are prime and greater than
2 are odd. 7 is prime and greater than 2 and we may
conclude that it is odd.
n : N | prime(n) n 2 odd(n) prime(7) 7 2 7N
( elim)
odd (7)
Page 64
Natural deduction
• Rules for existential quantification
If xεX such that p holds for x, then if we
are able to define further predicate, q in
which x does not appear free, then we
may conclude q
x : X | p q
q
Page 65
Natural deduction
• Intro rule
• If p is true for any term t of set X, then we
conclude that, x : X p holds
tX p[t/x]
( intro)
x : X p
7N prime(7)
( intro)
n : N prime(n)
Page 66
Natural deduction
• Example
Page 67
The one-point rule
p : Person p likes emily p rick
• It states that p is a person that likes Emily, but also
that the name of person is Rick
• We can conclude that rick ε Person and rick likes
emily are both true
• Law 20
(x : X p x t) (t x p(t/x))
x : X p x t
p[t/x] t X
Page 68
The one-point rule
• Example
p : Person p owns a red car p becky
becky Person becky owns a red car
p[t/x] t X
x : X p x t
Page 69
References
• Discrete Mathematics with Examples
by Simpson
Page 70
Thank you!
Page 71