Predicate Logic
Formal Methods
Formal Methods
Predicate Logic
Example 3.1:
The following are examples of universal
statements:
1. Any student interested doing research with
Dr. Zafar must register FM course.
2. Nobody knows the trouble I seen.
3. Jim doesn't know anybody who can sign his
bail application.
Formal Methods
Predicate Logic
Example 3.2
The following are examples of existential
statements:
1. I heard it from one of your friends.
2. A mad dog has bitten Andy.
3. Some people prefer logic.
Dr. Nazir A. Zafar
Formal Methods
Predicate Logic
Formal Methods
Predicate Logic
Formal Methods
Formal Methods
Predicate Logic
Meanings of: x x > 5 (True)
Explanation: Let = {0, 1, 2, 3, . . .}
The above statement can be written as
0 > 5 1 > 5 2 > 5 3 > 5 4 > 5 .
Meanings of: x x > 5 (False)
Explanation:
This statement can be written as
0 > 5 1 > 5 2 > 5 3 > 5 4 > 5 .
Dr. Nazir A. Zafar
Formal Methods
Formal Methods
Formal Methods
Formal Methods
Formal Methods
Formal Methods
Formal Methods
Notations:
P stands for set of all people,
K(x, y) means x knows y
S(x, y) means x can sign ys application for bail
Formalization:
p P K(Jim, p) S(p, Jim)
Dr. Nazir A. Zafar
Formal Methods
Formal Methods
Validity Checking
Predicate Logic
p P K(Jim, p) S(p, Jim)
Propositional Logic
[K(Jim, p1) S(p1, Jim)] [K(Jim, p2) S(p2,
Jim)] [K(Jim, p3) S(p3, Jim)] [K(Jim, p4)
S(p4, Jim)]
[t t] [t t] [f t/f] [t t/f]
tttt
t, a tautology
Formal Methods
Algorithm
Sign-Appl (P, P1, Jim)
if P = [ ] then
true
else
for i = 1 to Length (P)
if K(Jim, P[i]) then
S(P[i], Jim)
endif
endfor
Formal Methods
Algorithm
P1 = known to Jim;
Jim: P;
known = {(Jim, p1), (Jim, p2)}
K : P x P Bool
K (Jim, x) ==
if (Jim, x) known then
true
else false
Formal Methods
Algorithm
P1 = known to Jim;
Jim: P;
known = {(Jim, p1), (Jim, p2)}
S : P x P Bool
S (x, Jim) ==
if x P1 then
false
endif
pre x Jim
Dr. Nazir A. Zafar
Formal Methods
Formal Methods
Useful Equivalences
1. ( x : a | p q) ( x : a p q)
2. ( x : a | p q) ( x : a p q)
Pronunciation:
x : a | p q is pronounced as there exists an x
in a satisfying p, such that q.
x : a | p q is pronounced for all x in a
satisfying p, q holds
Formal Methods
Scope of Variable
Example: Define scope of the variable x and y
( x : a | p q r) s t
y : a | p q ( y : b | r s t) u v
Scopes
(x : a | p q r )
scope of first x
y : a | p q (y : b | r s t ) u v
scope of second y
scope of first y
Dr. Nazir A. Zafar
Formal Methods
Formal Methods
Formal Methods
a : b c : a p
In this case, it would make no sense to merge
the two quantifications.
Formal Methods
x = 3 x : N 0 x
Free Occurrence
Bound Occurrence
Note: Occurrence of x adjacent to quantifier is
neither free nor bound;
Dr. Nazir A. Zafar
Formal Methods
Substitution
Formal Methods
Substitution
Example 3.13
1. (x y + 2) [0 / x]
0 y+2
2. ( x : N x y + 2) [0 / x]
( x : N x y + 2)
3. ( x : N x y + 2) [5 / y]
( x : N x 5 + 2)
Formal Methods
Substitution
Example 3.14
1. (x y + 2) [0 / x] [5 / y]
0 y + 2 [5 / y]
0 5+2
2. (x y + 2) [y / x] [5 / y]
(y y + 2) [5 / y]
5 5 + 2)
Formal Methods
Substitution
Example 3.15
1. (x y + 2) [y, 5 / x, y]
y 5+2
Parallel
2. (x y + 2) [y / x] [5 / y]
Sequential
(y y + 2)
5 5 + 2)
Dr. Nazir A. Zafar
Formal Methods