public class HornClauseFilter extends KBAssertFilter
HornClauseFilter
makes it possible to process the assertion of
Horn clauses (like in Prolog). Horn clauses are disjunction of exactly one
positive literal (the "head") and one or more negative literals (the "body").
In other words, they are material implications, the right hand-side of which
(i.e. its consequent) is a single positive literal (and not a disjunction).
For example:
(B ??myself (implies (and p1 p2 ... pn) q))Which is logically equivalent to:
(B ??myself (or (not p1) (not p2) ... (not pn)) q)
The application of this filter consists in installing a proper query filter for each asserted Horn clause. The installed query filter simply replaces queries on the head of the asserted Horn clause (i.e. the only positive literal of the clause) with queries on the conjunction of its body literals (i.e. the negative literals of the clause).
The HornClauseFilter
is automatically loaded by the
DefaultFilterKBaseLoader
, so that default semantics agents benefit
from it.
Modifier and Type | Class and Description |
---|---|
(package private) class |
HornClauseFilter.HornClauseQueryFilter
Private class, which implements the query filter installed for each
asserted Horn clause.
|
Modifier and Type | Field and Description |
---|---|
(package private) static int |
count |
Constructor and Description |
---|
HornClauseFilter() |
Modifier and Type | Method and Description |
---|---|
Formula |
apply(Formula formula)
The
apply(Formula) method applies on asserted Horn clauses. |
afterAssert, beforeAssert
getMyKBase, setMyKBase
public Formula apply(Formula formula)
apply(Formula)
method applies on asserted Horn clauses. It
consists in intalling dynamically a query filter that deals with queries
on the head of the asserted Horn clause.
Applies the filter before asserting the formula into the KBase.
This method may modify the formula to assert by returning another formula.
By default, it returns the same formula. The boolean mustApplyAfter
is set to true.apply
in class KBAssertFilter
formula
- the formula to assert