# inference by stariya

VIEWS: 5 PAGES: 11

• pg 1
```									ITCS 6150-8150           Fall 2011                Jing Xiao

Inference in First Order Logic (Chapt. 9)

Given KB, find if KB|= which is a FOL sentence)
Also can be viewed as theorem proving.
Ideas:
(1) Transform (KB and WFF’s into certain
normal forms
(2) Prove KB|= by resolution (P345)

 Transforming WFF's into Conjunctive Normal
Form, also called Clause Form (P345)

A formula in the first-order logic is said to be in a
prenex normal form iff it is in the form of
(Q1x1)...(Qnxn)(M)
where every (Qixi), i=1, ..., n is either (xi) or xi),
and M is a formula containing no quantifiers.
(Q1x1)...(Qnxn) is called the prefix, and M is
called the matrix of the formula.

Here are some formulas in prenex normal form:
(x)(y)(P(x,y)^Q(y)),
(x)(y)(~P(x,y) -> Q(y)),
(x)(y)(z)(Q(x,y) -> R(z))

1
ITCS 6150-8150         Fall 2011               Jing Xiao

Transform WFF’s into Prenex Normal Form:

In addition to the equivalence laws introduced for
propositional logic, there are also the following laws
for first-order logic:
let G be a formula that does not contain variable x.
1) (Qx)F(x) G = (Qx) (F(x)  G)
2) (Qx)F(x) ^ G = (Qx) (F(x) ^ G)
3) ~((x)F(x)) = (x) (~F(x))
4) ~((x) F(x)) = (x) (~F(x)
5) (x) F(x) ^ (x) H(x) = (x) (F(x) ^ H(x))
6) (x) F(x)  (x) H(x) = (x) (F(x)  H(x))

How about (x) F(x)  (x) H(x) and (x) F(x) ^
(x) H(x) ?
For cases like that, we have to do something special.
Since every bound variable in a formula can be
considered as a dummy variable, it can be
renamed z, and the formula (x)H(x) becomes
(z)H(z); that is (x)H(x) = (z)H(z).

Suppose variable z does not appear in F(x), then

7) (x) F(x)  (x) H(x) = (x) F(x)  (z) H(z)
(renaming all x's occurring)

2
ITCS 6150-8150           Fall 2011              Jing Xiao

= (x)(z) (F(x)  H(z))

Similarly, we can have

8) (x)F(x) ^ (x)H(x) = (x) F(x) ^ (z) H(z)
= (x)(z) (F(x) ^ H(z))

Using these laws, we can always transform a given
formula into prenex normal form:

Step 1: Eliminate <-> and ->
using laws
F <-> G = (F -> G) ^ (G -> F)
F -> G = ~F V G

Step 2: Bring the negation signs immediately before
atoms by repeatedly using
~(~F) = F
De Morgan's laws: ~(F V G) = ~F ^ ~G
~(F ^ G) = ~F V ~G, and
the laws 3) and 4)

Step 3: Rename bound variables if necessary

Step 4: Move the quantifiers to the left of the entire
formula to obtain a prenex form by using the laws
1), 2), 5), 6), 7), 8)

3
ITCS 6150-8150          Fall 2011               Jing Xiao

Examples.

Transform a formula in prenex normal form to
clause form --- a set of clauses:

1) Eliminate existential quantifiers by substituting for
the variable a constant or a function that contributes
to the desired truth value of the formula.

Example 1: (y)(President(y)) can be transformed
into (President(S1))

Example 2: (x)(y)(father-of(y, x)) can be
transformed into (x)(father-of(S(x), x)).
In this case, the substitution has to be bounded by the
universal quantifier since the existential quantifier
occurs within the scope of the universal one.

These substitutions are called Skolem functions or
constants.

2) Drop the prefix (universal quantifiers) with the
assumption that any variable in the matrix is
universally quantified.

4
ITCS 6150-8150          Fall 2011                Jing Xiao

3) Convert the matrix (i.e., formula w/o the
quantifiers) into a conjunction of disjuncts, i.e.,
conjunctive normal form.

4) Make each disjunct a clause so that the formula
now becomes a set of clauses.

5) Rename the variables so that no two clauses make
reference to the same variable. (We do this to keep
clauses in their most general form).
Example.

 Theorem Proving by Resolution (P277)
-- A Complete Inference Procedure

Theorem proving: Given a set of axioms (or known
theorems), prove that a WFF P is true.

Idea of Resolution: prove the theorem by refutation,
i.e., prove that ~P is not true.

Procedure:
1) First, transform all axioms to a set of clauses S.

2) Transform ~P to clauses and add them to the set S.

Note that we assume ~P is valid, therefore, all the

5
ITCS 6150-8150            Fall 2011             Jing Xiao

clauses generated from it are valid because of the
conjunctive relationships.

3) Repeat until a contradiction is found:
a) pick up two clauses from S and try to
resolve them to one clause by the rule of
resolution;
b) if the resolvent is empty, a contradiction is
found and the proof is done
else, add the resolvent to S.

Example: resolution in propositional logic.

How to resolve two clauses:

In propositional logic:

If there are any pair of literals L and ~L such that
one clause contains L and the other contains ~L,
then eliminate L and ~L from the clauses.

The resolvent will be the disjunction of the rest of
the literals of both clauses.

In first-order logic:

- If there are a pair of unifiable (or complementary)
literals T1 and ~T2 such that one clause contains T1

6
ITCS 6150-8150         Fall 2011               Jing Xiao

and the other contains T2, then the resolvent will be
the disjunction of the rest of the literals of both
clauses with proper substitution performed through
the unification process.

- If there is more than one pair of complementary
literals, only one pair should be omitted from the
resolvent.

What is unification and why it is needed? (P270)

Consider examples:
man(John) and ~man(Spot)
– even if man and ~man are complementary,
the two literals are not. We say man(John)
and man(Spot) cannot be unified.

~hate(x, y) and hate(Marcus, z)
– in this case, Marcus is one instance of x. We can
substitute Marcus for x, expressed as Marcus/x.
Also, for y and z, we can substitute one for
another, say, z/y.

With the substitutions, we will have two
complementary literals: ~hate(Marcus, y) and
hate(Marcus, y).
Hence, the original two literals are unifiable.

7
ITCS 6150-8150          Fall 2011               Jing Xiao

Question: can we x/Marcus?

Note that
1) only variables can be replaced by substituents.
2) because the final substitution produced by the
unification process will be used by the resolution
procedure, it is useful to generate the most general
unifier possible. For example, in the above
example, we do not want to substitute a particular
instance, say Caesar, to y or z.
3) A function cannot substitute its arguments.
E.g., f(x, x) and f(g(x), g(x))

Question: can we x/g(x)?
No, since g(x) is more specific than x.

The objective of the unification procedure is to
discover at least one substitution that causes two
literals to match.

Example:
Given:
- Steve only likes easy courses.
- Science courses are hard.
- All the courses in the basketweaving department
are easy.
- BK301 is a basketweaving course.
Prove “Steve likes BK301” by resolution.

8
ITCS 6150-8150         Fall 2011               Jing Xiao

Step 1: form WFF’s in First-order Logic

Axioms:
(x) (EasyCourse(x) <=> Likes(Steves, x))
(x) (SciCourse(x) => ~EasyCourse(x))
(x) (BKCourse(x)=> EasyCourse(x))
BKCourse(BK301)
Prove: Likes(Steve, BK301)

Step 2: convert the WFF’s into a set of clauses, and
add the negation of the theorem to the set.
(1) ~EasyCourse(x)  Likes(Steve, x)
(2) EasyCourse(x)  ~Likes(Steve, x)
(3) ~SciCourse(x)  ~EasyCourse(x)
(4) ~BKCourse(x)  EasyCourse(x)
(5) BKCourse(BK301)
(6) ~Likes(Steve, BK301)

Step 3: apply resolution algorithm

(1)    (4)
\ /
Likes(Steve, x)  ~BKCourse(x)           (5)
\       /
Likes(Steve, BK301)         (6)
\           /
‫ٱ‬

9
ITCS 6150-8150         Fall 2011                Jing Xiao

Therefore, “Steve likes BK301” is true.

Issues of concern:
1) How can it detect if a contradiction cannot be
generated, therefore the resolution process cannot
halt, and the theorem cannot be proven?

Note: the resolution process is complete in the sense
that it can always prove the theorem  if KB |= .
However, if KB | , then it cannot always prove
that.

The following strategies help to halt the algorithm:

a) If the axioms do not contain the literals that
the theorem to be proven contains, then the
theorem cannot be proven. (why?)

b) If the only resolvents that can be generated
have been generated before, i.e., no new
resolvent can be generated, then the theorem
cannot be proven.

2) How to select two clauses to speed up the process
of proof? (Resolution strategy) P284-286
10
ITCS 6150-8150         Fall 2011               Jing Xiao

a) Unit-preference strategy: whenever possible,
resolve with clauses that have a single literal.
Such resolutions generate new clauses with
fewer literals than the larger of their parent
clauses.
b) Set-of support strategy: whenever possible,
resolve either with one of the clauses that is
part of the statement we are trying to refute or
with a clause generated by a resolution with
such a clause.
c) Input-resolution strategy: every resolution
combines one of the input clauses (KB or the
query) with some other clause.
d) Linear-resolution strategy: a slight
generalization of the input-resolution strategy.
e) Eliminate certain clauses as soon as they are
generated so that they cannot participate in
later resolutions. Two kinds of clauses can be
eliminated: tautologies and clauses that are
subsumed by other clauses. For example,
PVQ is subsumed by P.
f) Only resolve pairs of clauses that contain
complementary literals.

Note: you can start working on HW#3.

11

```
To top