No Slide Title

Download Report

Transcript No Slide Title

First Order Predicate Logic
Limitation of Propositional Logic
• The facts: “peter is a man”, “paul is a man”, “john is
a man” can be symbolized by P, Q and R,
respectively in PL.
• But we would not be able to draw any conclusions
about similarities between P, Q and R.
• It would be much better to represent these facts as
MAN(peter), MAN(paul) and MAN(john).
 Further, we are even in more difficulty, if we try to
represent sentences like “All men are mortal” in
PL.
 In Predicate Logic, such sentences can be easily
represented and the limitations of propositional logic are
removed to great extent.
 The predicate logic is logical extension of propositional
logic. The first order predicate logic is one where the
quantification is over simple variables.
Predicate Calculus
• It has three more logical notions as compared to
propositional calculus.
Terms,
Predicates
Quantifiers (universal or existential quantifiers i.e.
“for all' and “there exists”)
A term is a constant (single individual or concept
i.e.,5, john etc.), a variable that stands for different
individuals and n-place function f(t1, …, tn) where
t1, …, tn are terms.
 A function is a mapping that maps ‘n’ terms to a term.
 A predicate is a relation that maps ‘n’ terms to a truth
value true (T) or false (F).
Examples:
• A statement x is greater than y is represented in
predicate calculus as GREATER(x, y). It is defined as
follows:
GREATER( x, y) =
T , if x  y
=
F , otherwise
• A statement x loves y is represented as LOVE(x, y)
which maps it to true or false when x and y get
instantiated to actual values.
• A statement john’s father loves john is represented as
LOVE(father(john), john). Here father is a function
that maps john to his father.
• The predicate names GREATER and LOVE take two
terms and map to T or F depending upon the values of
their terms.
Quantifiers: Variables are used in conjunction with
quantifiers. There are two types of quantifiers viz..,
“there exist” () and “for all” ().
Example: Translate the text "Every man is mortal.
John is a man. Therefore, John is mortal" into
Predicate Calculus formula.
Solution:
Let MAN(x), MORTAL(x) represent
‘x is a man’ and ‘x is mortal’ respectively.
• Every man is mortal :(x) (MAN(x)  MORTAL(x))
• John is a man
:
MAN(john)
• John is mortal
:
MORTAL(john)
The whole text can be represented by the following
formula.
(x) ((MAN(x)  MORTAL(x))  MAN(john))
 MORTAL(john)
First Order Predicate Logic (FOL)
• First order predicate calculus becomes First Order
Predicate Logic if inference rules are added to it.
• Using inference rules one can derive new formula
using the existing ones.
Interpretations of Formulae in FOL
 In PL, an interpretation is simply an assignment of
truth values to the atoms. In FOL, there are variables,
so we have to do more than that.
 An interpretation of a formula  in FOL consists of a
non empty domain D and an assignment of values to
each constant, function symbol and predicate symbol.
 We use notation I[] = T (or F), which means
that  is evaluated to be true or false under
interpretation I over a domain D.
 Let  and  are formulae and I be an
interpretation over any domain D. The
following holds true.
 I[  ]
 I[ V ]
 I[  ]
 I[~]
=
=
=
=
=
I[]  I[]
I[] V I[]
I[]  I[]
~ I[]
T if and only if I[] = F
• For any interpretation I and formulae using (x) and
( x), the following results holds true.
 I[(x)P(x)] = T
iff I[P(x)] = T, x  D
= F, otherwise
 I[(x) P(x)] = T
iff  cD such that I[P(c)] = T
= F, otherwise
Example: Let  : (x) ( y) P(x, y) be a formula. Evaluate
it under the following interpretation I. (Ans: True)
I
D = {1, 2}
I[P(1, 1)] = F, I[P(1, 2)] = T,
I[P(2, 1)] = T, I[P(2, 2)] = F
• A formula  is said to be consistent (satisfiable) if
and only if there exists an interpretation I such that
I[] = T. Alternatively we say that I is a model of 
or I satisfies .
• A formula  is said to be inconsistent (unsatisfiable)
if and only if  no interpretation that satisfies  or
there exists no model for .
• A formula  is valid if and only if for every
interpretation I, I[] = T.
• A formula  is a logical consequence of a set of
formulae {1, 2, ..., n } if and only if for every
interpretation I, if I[1  … n ] = T, then I[] = T.
Prenex Normal Form
• In FOL, there are infinite number of domains and
consequently infinite number of interpretations of a formula.
• Therefore, unlike PL, it is not possible to verify a validity and
inconsistency of a formula by evaluating it under all possible
interpretations.
• We will discuss the formalism for verifying inconsistency and
validity in FOL. There is also a third type of normal form called
Prenex Normal Form in FOL, .
 A closed formula  of FOL is said to be in Prenex Normal
Form (PNF) if and only if  is represented as
(q1 x1) (q2 x2) … (qn xn) (M), where, qk , (1  k  n )
quantifiers ( or ) and M is a formula free from quantifiers.
 A list of quantifiers [(q1 x1) … (qn xn)] is called prefix and
M is called the matrix of a formula . Here M is represented
in CNF.
Transformation of Formula into Prenex
Normal Form
• A formula can be easily transformed into PNF
using various equivalence laws. We use the
following conventions:
 [x] a formula , which contains a
variable x.

a formula without a variable x.
q
Quantifier ( or  ).
Equivalence Laws: There are following pairs of
logically
equivalent
formulae
called
equivalence laws in addition to the equivalence
laws given for PL.
1.
(q x)  [x] V  
(q x) ( [x] V  )
2.
 V (q x)  [x] 
(q x) ( V  [x])
3.
(q x)  [x]   
(q x) ( [x]   )
4.
  (q x)  [x] 
(q x) (   [x])
5.
~ ((x)  [x])

(x) (~ [x])
6.
~ ((x)  [x])

(x) (~  [x])
There are few more equivalence laws:
7. (x)  [x]  (x)  [x]  (x) ( [x]   [x] )
8. (x)  [x] V (x)  [x]  (x) ( [x] V  [x])
• Quantifiers  and  can distribute over  and V
respectively, but cannot distribute over V and .
i. (x)  [x] V (x)  [x]  (x) ( [x] V  [x] )
ii. (x)  [x]  (x)  [x]  (x) ( [x]   [x])
• Show through an example that (x) [x] V (x)
[x] and (x) ([x] V [x] ) are not equivalent.
Example: Consider  : (x) P(x) V (x) Q(x) and
an interpretation I as follows.
I
D = {1, 2}
I[P(1)] = T, I[P(2)] = F
I[Q(1)] = F, I[Q(2)] = T
• We can easily show that  is false under
interpretation I whereas a formula (x) (P(x) V
Q(x)) is true under I.
Renaming Bound Variables
• For the cases mentioned below, we have to do
something special.
i. (x)  [x] V (x)  [x]  (x) ( [x] V  [x] )
ii. (x)  [x]  (x)  [x]  (x) ( [x]   [x])
• Every bound variable x in [x] can be renamed by
y such that y does not occur in  and .
Then, (x)  [x] V (x)  [x]

(x)  [x] V (y)  [y] ,

(x) (y) ( [x] V  [y] )
(using laws 1 and 2)
• Thus by renaming all occurrence of x by y  {,
} in a formula , we get, two more equivalence
laws as follows:
9.
(x)  [x] V (x)  [x]

(x) (y) ( [x] V  [y] )
10. (x)  [x]  (x)  [x]

(x) (y) ( [x]   [y] )
• These equivalence laws are used for transforming
a formula into PNF.
Skolemisation (Standard Form)
• Prenex normal form of a formula is further
transformed
into
special
form
called
Skolemisation or Standard Form.
• This form is used in resolution of clauses.
• The process of eliminating existential quantifiers
and replacing the corresponding variable by a
constant or a function is called skolemisation.
• A constant or a function is called skolem constant
or function.
Convertion of PNF to its equivalent Standard Form
• Scan prefix from left to right. If q1 is the first
existential quantifier then choose a new constant c 
Matrix. Replace all occurrence of x1 appearing in Matrix
by c and delete
(q1 x1) from the prefix to obtain new
prefix and matrix.
• If qr is an existential quantifier and q1….qr-1 are
universal quantifiers appearing before qr , then choose a
new (r-1) place function symbol ’ f '  Matrix. Replace
all occurrence of xr in Matrix by f(x1, …,xr-1 ) and
remove (qr xr ).
• Repeat the process till all existential quantifiers are
removed from matrix.
 Any formula  in FOL can be transformed into its
standard form.
 Matrix of standard formula is in CNF and prefix is
free from existential quantifiers.
 Formula in standard form is expressed as:
(x1)… (xn) (C1 … Cm),
where Ck ,(1 k m) is formula in disjunctive normal form.
 Since all the variables in prefix are universally
quantified, we omit prefix part from the standard
form for the sake of convenience and write
standard form as (C1 … Cm).
 A clause is a closed formula of the form (x1) …
(xn) (L1V … V Lm), where each Lk is a literal
and x1,…,xn are variables occurring in L1, …, Lm.
 Since all the variables in a clause are universally
quantified, we omit them and write clause as
(L1V … V Lm ) for the sake of simplicity.
 The standard form of any formula is of the form
(C1 … Cm), where each Ci , (1  i  m) is a
clause.
 Define S = { C1, … ,Cm } to be a set of clauses
that represents a standard form of a formula .
 S is said to be unsatisfiable (inconsistent) if and
only if there  no interpretation that satisfies all
the clauses of S simultaneously.
 A formula  is unsatisfiable (inconsistent) if and
only if its corresponding set S is unsatisfiable.
 S is said to be satisfiable (consistent) if and only if
each clause is consistent under at least one
interpretation i.e.,  an interpretation that satisfies
all the clauses of S simultaneously.
 Alternatively, an interpretation I models S if and
only if I models each clause of S.
Resolution in Predicate Logic
• Resolution method is used to test unsatisfiability
of a set S of clauses in Predicate Logic. It is an
extension of resolution method for propositional
logic.
• The resolution principle basically checks whether
empty clause is contained or derived from S.
• A clause is a closed formula of the form (x1) …
(xn) (L1V …V Lm), where Lk ,(1  k  m) is a
literal and xj, (1  j  n) are all the variables
occurring in L1, …, Lm.
• Resolution for the clauses containing no variables
is very simple and is similar to PL. It becomes
complicated when clauses contain variables.
• In such case, two complementary literals are
resolved after proper substitutions so that both the
literals have same arguments.
Example: Consider two clauses C1 and C2 as
follows:
C1
=
P(x) V Q(x)
C2
=
~ P(f(x)) V R(x)
• Substitute 'f(a)' for 'x' in C1 and 'a' for 'x' in C2 ,
where 'a' is a new constant from the domain, then
C3
=
P(f(a)) V Q(f(a))
C4
=
~ P(f(a)) V R(a)
• Resolvent of C3 and C4 is [Q(f(a)) V R(a)]
– Here C3 and C4 do not have variables. They are called
ground instances of C1 and C2 .
• In general, if we substitute 'f(x)' for 'x' in C1 , then
C’1 =
P(f(x)) V Q(f(x))
• Resolvent of C'1 and C2 is [Q(f(x)) V R(x)]
• We notice that [Q(f(a)) V R(a)] is an instance of
[Q(f(x)) V R(x)].
• Before we discuss a systematic method of
generating resolvent from the parents, we discuss
substitutions and unification of clauses .
Substitution and Unification
• A substitution  = {x1 / t1, …., xn / tn}, is a finite
set of elements, where each xk is a distinct
variable and each tk is a term different from xk , ( 1
 k  n). Each element xk / tk of a set  is called a
binding for xk .
• A term in predicate logic is either a constant, a
variable or n-place function symbol with t1, …, tn
as arguments, where each ti (1  ti  n) is a term.
• A ground term is one which is free from
variables.
• A substitution  is a ground if t1, t2 ,…, tn are
all ground terms.
• A substitution  is called a pure variable
substitution if t1, t2 ,…, tn are all variables.
• Let  = {x1 / t1, …., xn / tn} be a substitution and F
be any formula in predicate logic.
• The formula F is obtained by replacing each
occurrence of the variable xk in F by the
corresponding term tk .
• F is called an instance of F. If F is ground,
then it is called ground instance of F.
• Let  = {x1 / t1,…, xn / tn} and  = {y1 / s1,…,
ym / sm} be two substitutions.
• Then the composition    is obtained from the
set { x1 / (t 1 ) , …., xn / (tn  ), y1 / s1, …., ym
/ sm } after deleting any binding xk / (tk  ) for
which xk = tk   and binding yj / sj for which yj 
{x1, …., xn}
Example: Consider two substitutions  and 
defined as follows:
 ={x / f(y), y / z} and  = {x / a, y / b, z / y}.
Show that    = {x / f(b), z / y}.
Solution:    =
{x / f(y), y / z}  
= {x / (f(y)  ) , y / (z  ) , x / a, y / b, z / y }
= {x / f(b), y / y, x / a , y / b , z / y}
According to the definition, delete y / y, x / a and
y / b from above set, we get, {x / f(b), z / y}.
Hence   
=
{x / f(b), z / y}
• The substitution given by an empty set is called
identity substitution and denoted by . It satisfies
the condition F  = F,  formulae F.
• Let F1 and F2 be two formulae. F1 and F2 are
variants of each other, if there exist substitutions 
and  such that F1 = F2  and F2 = F1 .
Example: Show that P(f(x, y), g(z), a) and P(f(y, x),
g(u), a) are variant of each other.
Solution:Consider two substitutions
 ={x / y, y / x, z / u} and  = {y / x, x / y, u / z}
• Let F1= P(f(x, y), g(z), a) and F2 = P(f(y, x), g(u), a)
• Then,
F1 = F2  and F2 = F1
• Let F be a formula and U be a set of variables
occurring in F. A renaming substitution for F is
made a pure variable substitution such as {x1 / y1
, …, xn / yn } if following conditions are satisfied.
• {x1 , …, xn } U and yk (1  k  n) are distinct
• { U – {x1 , …, xn }}  {y1 , …, yn } = 
• If  = {F1, …, Fn} is a finite set of formulae and
 is any substitution, then  = {F1, …, Fn}.
• A substitution  is called a unifier for a set  if
and only if  is a singleton set (a set containing
single element) i.e., F1 = ….= Fn .
Example: Consider  = {P(f(x), z), P(y, a)}. Find an
unifier of  , if it exist
Solution:
Consider a substitution  = {y / f(a) , x / a , z / a}.
 =
{ P(f(a), a), P(f(a), a)}
=
{ P(f(a), a)}
Since  is a singleton set,  = {y / f(a) , x / a , z / a}
is an unifier of .
• An unifier  for a set  ={ F1, …, Fn } is most
general unifier (mgu), if for each unifier  of ,
there exists a substitution  such that  =   .
• The most general unifier may not be unique.
Example: Consider  = {P(f(x), z), P(y, a)}.
Find the most general unifier.
Solution:
• The most general unifier for  is  = {y/f(x),z/a},
because for any unifier, say,  = {y/f(a), x/a, z/a},
 a substitution  = {x / a} such that  =   
• Consider    = {y / f(x), z / a}  {x / a}
=
{y/f(a), x/a, z/a}
=

• Hence  =    and therefore  = {y/f(x), z/a} is
most general unifier.
Disagreement Set
• Consider two formulae F1 = P(a) and F2 = P(x)
which are not identical. The disagreement is that
'a' occurs in F1 but variable 'x' occurs in F2 .
• In order to unify F1 and F2 , find out the
disagreement set and then try to eliminate it. In
this case disagreement set is {a, x}. In general
disagreement set of S is obtained as follows:
– Locate the leftmost symbol position at which all the
formulae of  are different.
– Extract those sub formulae from  beginning at the
position located above. This set is called disagreement
set of  denoted by D(  ) at the particular position
located above.
Method:
 Initialize k = 0, k =  (identity substitution),
 Sk = Sk
 If Sk is a singleton set then k is mgu of S else find
disagreement set of Sk and denote it by Dk .
 If  a variable 'x' and a term 't' in Dk such that 'x' does
not occur in 't', then compute
k+1 = k  {x / t};
k = k+1; Sk = Sk-1k ; else S is not unifiable.
 Repeat the process
• In unification algorithm, we try to find 'x' and 't' in Dk such
that 'x' is a variable that does not occur in term 't'.
 This is called occurs check. We say that a variable 'x'
satisfies occurs check with respect to a term 't'.
Example: Apply unification algorithm and find mgu
of a set S = {P(a, x, f(g(y))) , P(z, f(z), f(u)) }.
Solution:0 =  ; S0 = {P(a, x, f(g(y))) , P(z, f(z), f(u)) }
D0 = {a, z}, 1 = {z / a };
S1 = S1 = { P(a, x, f(g(y))), P(a, f(a), f(u)) }
D1 = {x, f(a)}; 2 = 1  {x / f(a) } = {z / a, x / f(a) },
S2 = S12 = { P(a, f(a), f(g(y))), P(a, f(a), f(u)) }
D2 = {g(y), u};
3 = 2  {u / g(y) }= {z / a, x / f(a), u / g(y) },
S3 = S23 = {P(a, f(a), f(g(y))),P(a, f(a), f(g(y))) }
Since S3 is a singleton set, therefore,
3 = {z / a, x / f(a), u / g(y) } is the mgu of S.
Logical Consequence of a Set
• A clause L is defined to be a logical consequence
of a set of clauses S if and only if every
interpretation I that satisfies S also satisfies L.
Lemma :If S = {C1,...,Cn} is a set of clauses, then L
is a logical consequence of S if and only if
( C1  …  Cn  L ) is valid.
Lemma: Alternatively, we define L to be a logical
consequence of S if and only if
~ ( ~ ( C1  …  Cn ) V L )
is unsatisfiable or inconsistent.
Theorem: L is a logical consequence of S if and
only if S  { ~ L} = { C1, …, Cn , ~ L} is
unsatisfiable.
 A deduction of an empty clause from a set S of
clauses is called a resolution refutation of S.
Theorem: (Soundness and completeness of
resolution): There is a resolution refutation of S if
and only if S is unsatisfiable (inconsistent).
Theorem: L is a logical consequence of S if and
only if there is a resolution refutation of
S  {~L}.
 We can summarize that in order to show L to be a
logical consequence of the set of formulae {1, …,
n }, follow the following steps:
 Obtain a set S of all the clauses by converting each k
to its corresponding standard form and then to the
clauses.
 Show that a set S  { ~ L} is unsatisfiable i.e., the set
S  { ~ L} contains either empty clause or empty
clause can be derived in finite steps using resolution
method.
 If so, then report 'Yes' and conclude that L is a logical
consequence of S and subsequently of formulae 1, …,
n otherwise report 'No'.
Example:
Consider the following set of formulae:

: (x) (P(x)  (Q(x)  R(x)))

: (x) (P(x)  U(x))
Show that L = (x) (U(x)  R(x)) is a logical consequence
of  and .
Solution: Convert  and  to its corresponding clauses by
generating their standard forms.
Standard form of  : (x) (~ P(x) V (Q(x)  R(x))) is
(x) ((~ P(x) V Q(x))  (~ P(x) V R(x)))
Clauses of  are ~ P(x) V Q(x) and ~ P(x) V R(x)
Similarly the clauses of  are P(a) and U(a), where a is a
skolem constant.
Then, S = {~ P(x) V Q(x) , ~ P(x) V R(x), P(a), U(a) }
Negation of a goal:
~ L : ~ ((x) (U(x)  R(x))) 
(x) (~ U(x) V
~ R(x) )
Clause of ~ L:
~ U(x) V ~ R(x)
Therefore, S { ~ L} = {~ P(x) V Q(x) , ~ P(x) V R(x),
P(a), U(a), ~ U(x) V ~ R(x) }
Now resolve the following clauses of S  { ~ L} to get
empty clause.
 ~ P(x) V Q(x)
 ~ P(x) V R(x)
 P(a)
 U(a)
 ~ U(x) V ~ R(x)
• Inverted tree (resolution tree) is given below whose root is
deduced as  (empty clause) by resolving clauses in a set
S  { ~ L}. Hence L is a logical consequence of  and  .
U(a)
~ U(x) V ~ R(x)
{x / a}
~ R(a)
~ P(x) V R(x)
{x / a}
~ P(a)
P(a)
• Hence L is a logical consequence of  and .
• If the choice of clauses to resolve at each step is
made in a systematic ways, then resolution
algorithm will find a contradiction if one exists.
• There exist various strategies for making the right
choice that can speed up the process considerably.
Useful Tips:
 Initially choose a clause from the negated goal
clauses as one of the parents to be resolved ( This
corresponds to intuition that the contradiction we
are looking for must be because of the formula we
are trying to prove) .
 Choose a resolvent and some existing clause if both
contain complementary literals.
 If such clauses do not exists, then resolve any pairs
of clauses that contain complementary literals.
 Whenever possible, resolve with the clauses with
single literal. Such resolution generate new clauses
with fewer literals than the larger of their parent
clauses and thus probably algorithm terminates
faster.
 Eliminate tautologies and clauses that are subsumed
by other clauses as soon as they are generated.
Semantic Tableaux
(FOL)
• There are four more rules handling variables in a
predicate formula in addition to one given for
Propositional logic.
 Let us denote a formula containing a variable x
by [x].
Rule 10: ( x)  [x]
 [t]
for any ground term t, where t is a term free from
variables.
Rule 11:
~ {(x)  [x] }
~  [c]
for any new constant c not occurring in 
Rule 12 :
( x)  [x]
 [c]
for any new constant c
Rule 13:
~ {( x)  [x] }
~  [t]
for any ground term t
Example: Show that the formula
(x) (P(x)  ~ ( Q(x)  P(x)) ) is inconsistent.
Solutions: If we show that tableau for [(x) (P(x)
 ~ ( Q(x)  P(x)))] as a root is a contradictory
tableau, then the formula is inconsistent.
{Tableau root}
{Apply R10 on 1}
{Apply R1 on 2}
{Apply R7 on 3}
(x) (P(x)  ~ ( Q(x)  P(x)) (1)
P(t)  ~ ( Q(t)  P(t)) ,
(2)
where t is any ground term
P(t)
~ ( Q(t)  P(t))
(3)
Q(t)
~ P(t)
Closed {P(t), ~ P(t)}