Horn Clauses - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

Horn Clauses

Description:

where each new clause is not only negative but is a resolvent of the ... otherwise, the procedure takes the first goal, q1 and looks for ; ... – PowerPoint PPT presentation

Number of Views:637
Avg rating:3.0/5.0
Slides: 32
Provided by: sergeini
Category:

less

Transcript and Presenter's Notes

Title: Horn Clauses


1
Horn Clauses In its most general form,
resolution runs into problems of efficiency and
even tractability. We can limit ourselves to a
subset of FOL in which resolution is more
manageable.
2
In resolution-oriented systems, clauses are used
to express disjunctions Undergraduate,
Graduate. This might be construed to mean that
the individual so described is either an
undergraduate or a graduate student incomplete
knowledge. But a clause like ?Child, ?Male,
Boy can also be interpreted as a
conditional If an individual is a child and is
male then this individual is a boy. ?a ? b ? a
? b
3
A clause that contains at most one positive
literal is called a Horn clause. A Horn clause
with one positive literal is a positive or
definite Horn clause. A clause with no positive
literals is a negative Horn clause. In either
case there can be zero negative literals. This
means that the empty clause is a negative Horn
clause. How does one use resolution to reason
using the if-then statements (rules) formulated
as Horn clauses.
4
No two negative clauses can be resolved together
because they are of the same polarity (remember
that a quantum of resolution involves a clause
and its negation). When resolving a positive
and a negative Horn clause, the resolvent is
always a negative clause. This is because in
any instance of such resolution the single
positive literal in the Horn clause will be
canceled by its negation in the other clause.
And there will be no positive literals
remaining. When two positive clauses are
resolved, we are guaranteed to end up with a
positive clause as a resolvent. Right? In sum,
resolution with Horn clauses must always involve
a positiveclause if the second clause is
negative, the resolvent is negative if the
second clause is positive, the resolvent is
positive.
5
It has been shown that if S is a set of Horn
clauses and S - c, where c is a negative
clause, then there is a derivation of c where
all the new clauses in the derivation(that is,
clauses not in S) are negative. Moreover,
under the above assumptions, there is a
derivation of c where each new clause is not only
negative but is a resolvent of the previous one
in the derivation and an original clause in S.
6
These observations lead us to the following
conclusion There is a derivation of a
negative clause (including the empty clause) from
a set of Horn clauses S if and only if there is
one derivation where each new clause is a
negative resolvent of the previous clause in
the derivation and some element of S. Why is
this important?
7
Because this facilitates a restricted - and,
therefore, tractable - form of resolution. This
is the form of resolution where each new clause
is introduced as a resolvent of the previous
clause and a clause from the original set (so,
the search for the two clauses to try to resolve
is simplified).
8
Like this
9
but not this
10
Formally, for any set S of clauses (Horn or
not!), an SLD derivation of a clause c from S is
a sequence of clauses c1, c2, , cn such that cn
c, c1 ?S and ci1 is a resolvent of ci and some
clause in S. SLD means selected literals,
linear pattern over definite clauses. An SLD
derivation is a resolution derivation where only
c1 is overtly mentioned from the elements of S.
It is assumed that the appropriate positive
clause from S will be identified at each step, so
we can include in the description of the
derivation only the chain of negative
clauses from c1 to c. If S -sld c then S - c
but in the general case not vise versa (see
example in BL p. 88). However, if S is a set of
Horn clauses, then S - if and only if S -sld
c.
11
Thus, if S is a set of Horn clauses, then it is
unsatisfiable if and only if S -sld . Note
that each of the new clauses c2, , cn in the
derivation can be assumed to be negative. So,
c2 has a negative and a positive parent, so that
c1 ?S can be assumed to be negative as well.
c1



c2
c3

12
This means that for sets of Horn clauses SLD
derivations must begin with a negative clause in
the original set. To repeat an earlier example
13
Example 1. Toddler Toddler ? Child Child ? Male
? Boy Infant ? Child Child ?
Female ? Girl Female We can read the sentences
as if they describe a particular person the
person is a toddler, if the person is a toddler
then the person is a child, etc. Suppose, the
query is Is the person a girl? That is, we
wish to show that KB Girl, that is that there
is an SLD derivation of from KB augmented with
the negative Horn clause ?Girl.
KB of positiveHorn Clauses
14
Because it is the only negative clause in the KB,
it must be the c1 of the derivation. By
resolving it with the fifth clause in the KB, we
get ?Child, ?Female as c2. Resolving this
against the sixth clause in the KB, we get
?Child as c3. Resolving this with the second
clause, we get ?Toddler as the c4 resolvent.
Resolving that against the first clause in the
KB, we finally get as the final clause in the
derivation. All the clauses in the derivation
are negative! 1. Toddler 2. Toddler ? Child 3.
Child ? Male ? Boy 4. Infant
? Child 5. Child ? Female ? Girl 6. Female
15
A new format and terminology for SLD derivations
Goal Trees All the literals in all the clauses
in a Horn SLD derivation of the empty clause are
negative. We are looking for positive clauses in
the KB to cancel these negative literals and
produce an empty clause. Sometimes there is a
singleton clause in the KB that eliminates that
literal directly (e.g., the ?Toddler case in
our example). This signifies the end of a
derivation if the negative clause has just
one literal. In such a case it is common to say
that the goal Toddler is satisfied (or solved).
16
Sometimes there is a positive clause that
eliminates the literal but causes other negative
literals to appear. For example, when ?Child
is in the derivation, we resolve it against the
clause ?Toddler, Child and end up with
?Toddler. In this case one says that the goal
Child reduces to the subgoal Toddler. In our
example, the goal Girl reduces to two subgoals,
Child and Female.
17
We restate the sample SLD derivation as
follows We start with the goal Girl. This
reduces to two subgoals Child and Female. The
goal Female is satisfied (solved), and Child
reduces to Toddler. Finally, Toddler is solved.
1. Toddler 2. Toddler ? Child 3. Child ? Male ?
Boy 4. Infant ? Child 5.
Child ? Female ? Girl 6. Female
18
Such derivations can be represented using goal
trees. We draw the original goal(s) at the top
and from there point to subgoals. For a
derivation to be complete, the leaves of the
tree must be satisfied (solved).
Girl
Child Female Toddler
The argument is formulated as follows We want to
show that Girl is entailed by the KB. Traversing
the tree from the bottom up, we knowthat Toddler
is entailed because it is in the KB. This means
that Childis entailed. Female is entailed from
the KB. Therefore, Girl is entailed.
When one introduces variables into the process,
one ends up with the core of the PROLOG
programming language.
19
Reasoning with Horn clauses. Suppose we are
given a KB containing a list of positive Horn
clauses representing if-then sentences and we
wish to know whether or not some atom (or set of
atoms) is entailed. In other words, we are
determining the satisfiability of a set of
Horn clauses containing exactly one negative
clause.
20
Backward Chaining Input a finite list of atomic
sentences q1,qn the input is a set of goals
(viewed as atoms in a single negative Horn
clause) Output Yes if a given KB entails all the
qi No otherwise procedure SOLVEq1,,qn if n
0 then return YES if there are no goals, we
are done otherwise, the procedure takes the
first goal, q1 and looks for a clause in the
KB with the positive literal q1 for each clause
c ? KB, do if c q1, ? p1,, ? pm using
the negative literals in c as subgoals, the
procedure calls itself recursively with these
subgoals TOGETHER WITH the remainder of the
original goals. and
SOLVEp1,,pm,q2,,qn if successful, end if
not, look for another clause in KB with the
positive literal q1 then return YES if none
is found, the derivation failed, and the goal is
not satisifed. end for return NO
21
This procedure is called backward chaining
because it works from goals to facts in the KB.
The particular function that we discussed is
also depth-first because it attempts to solve the
new goals pi before going on to the residue of
original goals q2, , qn. This procedure is also
left-to-right because it attempts the goals qi in
ascending order. This procedure is typically
used in Prolog implementations. The
backward-chaining procedure has a number of
drawbacks. First, it can go into an infinite
loop even in the propositional case. Suppose
that we have a tautologous p, ?p in the KB.
Then, a goal of p can reduce to a subgoal of p
and so on, indefinitely The backward-chaining
algorithm is also inefficient as the search is
sometimes too exponential.
22
  • In the propositional case, a much more efficient
    procedure to determine
  • if a Horn KB entails a set of atoms is forward
    chaining from facts to
  • the goals. The idea is to mark atoms as solved
    as soon as we have
  • determined that they are entailed in the KB.
    This idea is similar to that
  • of dynamic programming.
  • input a finite list of atomic sentences q1,,qn
  • Output Yes if a given KB entails all the qi No
    otherwise
  • if all of the goals qi are marked as solved, then
    return YES.
  • check if there is a clause p, ?p1, , ?pn in KB
    such that all of its negative atoms are marked
    as solved while the positivemarker p is not
    marked as solved.
  • If there is such a clause, mark p as solved and
    go to step 1.
  • Otherwise, return No.

23
Girl Child Toddler Female
Back to our example 1. Toddler 2. Toddler ?
Child ? Toddler, Child 3. Child ? Male ? Boy
?Child, ?Male, Boy 4. Infant ? Child ?
Infant, Child 5. Child ? Female ? Girl ? Child,
? Female, Girl 6. Female The goal Girl At the
beginning, Girl is not marked as solved, so we go
to Step 2 and check whether there is a clause
with all its negative literals solved. Toddler is
onesuch clause (trivially, because it does not
have any negative literals). So, we mark Toddler
as solved and loop around. This time, we will
find Clause 2, where the negative clauses are
solved. So, we mark Child as solved and loop
around. At this point, we mark Female as solved.
Next, we note that Clause 5 can be processed, as
a result of which we mark Girl as solved. And,
eventually, get to success.
24
The behavior of this procedure is better than
that of the backward chaining procedure. Note
in particular that on each loop we must find a
clause in the KB with an atom that was not marked
as solved. Thus, we will iterate at most as
many times as there are clauses in the KB. Each
such iteration may require a scan of the entire
KB but the overall result will not be
exponential. It has been shown that this
procedure can be programmed to run in time that
is linear in the size of the KB.
25
The First Order Case In the first order case
there is still a possibility that resolution can
be infinite. The problem of deterimining whether
a set of first-order Horn clauses entails an atom
remains undecidable. In bad cases, there must
be a provision to give control over reasoning to
the user who can help to avoid redundancies and
infinite branches in search.
26
(No Transcript)
27
(No Transcript)
28
(No Transcript)
29
(No Transcript)
30
(No Transcript)
31
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com