Inference in First Order Logic: Horn Clauses


Reasoning with FOL

We have talked about two kinds of logic: propositional and first-order (FOL).

Last time we sketched how the knowledge base of an intelligent agent could be expressed in terms of FOL.

Today we will discuss how we can reason using FOL.

What does it mean to reason?

One way of looking at it is to think in terms of asking and answering questions.

Suppose we have a sentence (in FOL) such as:

	Likes(Sally, Teacher)

We can think of this as the way the intelligent agent might ASK itself: "Does sally like the teacher?".

The answer could be "True", "False" or "don't know".

If the answer is "True", we would like to have an automatic procedure for inferring it from the database.

Inference just means constructing a proof.

Today we will discuss valid proof components--inference rules--and two algorithms for automatically constructing FOL proofs.

Notice that there is another type of question: "Do you know what time it is?".

This could be encoded as a sentence in FOL as follows:

	Exists t Knows(You,t) AND CurrentTime(t)

The answer to this question could still be "True", "False" or "don't know", but, if it is "True", it would be nice to know what the value of "t" (the current time) is!

Just like the previous question, this question can be answered by constructing a proof that either proves that "t1", say, is the current time, or proving that there is no current time.

To summarize then, reasoning in FOL involves finding the answers to questions by constructing proofs. If the questions have variables, then the values of the variables, not just the answer, are important.

Inference rules for FOL

  • Generalized Modus Ponens
  • The unification algorithm
    • There is a standard algorithm that given two sentences, finds their unique most general unifying substitution.

      Here are some examples of unification.

      	Knows(John, x) = Likes(John, x)
      	Knows(John, Jane)
      	Knows(y, Leonid)
      	Knows(y, Mother(y))

      The unification algorithm whould give the following results:

      	UNIFY(Knows(John,x), Knows(John,Jane)) = {x/Jane}
      	UNIFY(Knows(John,x), Knows(y,Leonid)) = {x/Leonid, y/John}

      The substitution makes the two sentences identical.

      	UNIFY(Knows(John,x), Knows(y,Mother(y))) = {x/John, x/Mother(John)}

      Notice that the substitutions always involve a variable and a ground term.

      	UNIFY(Knows(John,x), Knows(x,Elizabeth)) = fail

      The variable x cannot have two values at the same time, so this last example fails.

      Another example that would always fail is

      	UNIFY(x, F(x)) = fail

      This fails because a the variable may never occur in the term it is being unified with.

  • Horn clauses
    • Generalized modus ponens requires sentences to be in a standard form, called Horn clauses after the mathematician Alfred Horn.

      A Horn clause is a sentence of the form

              q1 AND q2 AND ... AND qn -> r

      where each qi and r is an atomic sentence and all variables are universally quantified.

      Recall that an atomic sentence is a just single predicate and does not allow negation.

      Normally the universal quantifiers are implicit (not written explicitly).

      To refresh your memory, here is the syntax of FOL in Backus-Naur form.

              Sentence        -> AtomicSentence
                              | Sentence Connective Sentence
                              | Quantifier Variable,... Sentence
                              | NOT Sentence
                              | (Sentence)
              AtomicSentence  -> Predicate(Term, ...) | Term = Term
              Term            -> Constant
                              | Variable
                              | Function(Term,...)
              Connective      -> AND | OR | => | <=>
              Quantifier      -> FORALL | EXISTS
              Constant        -> A | X_1 | John | ...
              Variable        -> a | x | s ...
              Predicate       -> Before | HasColor | Raining | ...
              Function        -> Smelly | LeftLegOf | Plus | ...

      In order to obtain Horn clauses, existential quantifiers must be eliminated using Skolemization.


      	EXISTS x Loves(John,x) AND Loves(x,John) 

      Note that above we have two Horn clauses, which share a Skolem constant.

  • Backward chaining
    • The backward chaining algorithm can answer questions in Horn clause knowledge bases.

      It works by taking the goal and checking to see if it unifies directly with a sentence in the database.

      If so, it returns the substitution list that makes the query equal the known sentence.

      Otherwise, backward chaining finds all the implications whose conclusions unify with the query and then tries to establish their premises.

      Consider a knowledge base that says it is illegal to sell weapons to hostile nations. It also says that Colonel West sold all of country Nono's missiles to it. And missiles are weapons.

      	American(x) AND Weapon(y) AND Nation(z) AND Hostile(z)
      		AND Sells(x,y,z) => Criminal(x)
      	Owns(Nono, x) AND Missile(x) => Sells(West,Nono,x)
      	Missile(x) => Weapon(x)
      	Enemy(x,America) => Hostile(x)

      We add to it the following facts:

      	Enemy(Nono, America)

      We want to solve the crime: Is West a criminal?