jdrew.oo.bu
Class ForwardReasoner

java.lang.Object
  extended byjdrew.oo.bu.ForwardReasoner

public class ForwardReasoner
extends java.lang.Object

This class implements the forward reasoner (bottom-up) modules of OO jDREW; The unifier for this module is implemented by the jdrew.oo.bu.Unifier class and a subsumption checking system is implemented by the jdrew.oo.bu.Subsumption Class. A forward reasoner works by processing "new" facts; As each new fact is processed unificiation with all previously exisiting rules is attempted; if the unification is successful one of two things happens: if the resolvent is a fact then it is added to the end of the new facts list; if the resolvent is a rule then it is processed (attempting unification with all processed facts) and is then added to the list of rules.

Title: OO jDREW

Description: Reasoning Engine for the Semantic Web - Supporting OO RuleML 0.88

Copyright: Copyright (c) 2005


Constructor Summary
ForwardReasoner()
          This method constructs a new ForwardReasoner object (implementation of a bottom-up reasoning engine); creating the required buffers for knowledge base storage (oldFacts and rules Hashtable's and newFacts Vector) and registers the system provided built-in relations with the engine by calling the registerBuiltins();
 
Method Summary
 java.util.Vector getNewFacts()
          Allows user code to access the newFacts vector.
 java.util.Hashtable getOldFacts()
          Allows user code to access the oldFacts hash table.
 java.util.Hashtable getRules()
          Allows user code to access the rules hash table.
 void loadClauses(java.util.Iterator it)
          This method is used to load clauses into the reasoning engine.
 void printClauses()
          This method will print the entire knowledge base that has been loaded into this reasoning engine to standard out.
 void registerBuiltin(BUBuiltin b)
          This method is used to register a new user created built-in with the reasoning engine.
 void registerBuiltin(Builtin b)
          This method is used to register a new user created built-in with the reasoning engine.
 void runForwardReasoner()
          This method runs the main forward reasoner; causing the engine to find all possible conclusions from the knowledge base that was loaded into the engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForwardReasoner

public ForwardReasoner()
This method constructs a new ForwardReasoner object (implementation of a bottom-up reasoning engine); creating the required buffers for knowledge base storage (oldFacts and rules Hashtable's and newFacts Vector) and registers the system provided built-in relations with the engine by calling the registerBuiltins();

Method Detail

getNewFacts

public java.util.Vector getNewFacts()
Allows user code to access the newFacts vector. Users may want to use this in their code to allow the display of information in the knowledge base.

Returns:
Vector A reference to the newFacts Vector for this bottom-up reasoning engine.

getOldFacts

public java.util.Hashtable getOldFacts()
Allows user code to access the oldFacts hash table. Users may want to use this in their code to allow the display of information in the knowledge base.

Returns:
Hashtable A reference to the oldFacts Hashtable for this bottom-up reasoning engine.

getRules

public java.util.Hashtable getRules()
Allows user code to access the rules hash table. Users may want to use this in their code to allow the display of information in the knowledge base.

Returns:
Hashtable A reference to the oldFacts Hashtable for this bottom-up reasoning engine.

registerBuiltin

public void registerBuiltin(Builtin b)
This method is used to register a new user created built-in with the reasoning engine. This version of the method is for those built-ins that implement the jdrew.oo.builtins.Builtin interface (these can be used with both the bottom-up and the top-down engine). If the built-in that is being created requires access to the data structures of the reasoning engine it should instead extend the jdrew.oo.bu.builtins.BUBuiltin class and be registered with the registerBuiltin(BUBuiltin) method.

Parameters:
b - Builtin An instance of the class that implements the built-in relation; this should implement the jdrew.oo.builtins.Builtin interface.

registerBuiltin

public void registerBuiltin(BUBuiltin b)
This method is used to register a new user created built-in with the reasoning engine. This version of the method is for those built-ins that extend the jdrew.oo.bu.builtins.BUBuiltin class (those specific to the bottom-up engine).

Parameters:
b - BUBuiltin An instance of the class that implements the built-in relation; this should be a sub-class of the jdrew.oo.bu.builtins.BUBuiltin class.

printClauses

public void printClauses()
This method will print the entire knowledge base that has been loaded into this reasoning engine to standard out. The output is divided into three sections: new unprocessed facts; old process facts and rules.


loadClauses

public void loadClauses(java.util.Iterator it)
This method is used to load clauses into the reasoning engine. This will process each clause as it is loaded - placing new facts into the new facts list and processing new rules against all exisiting processed facts.

Parameters:
it - Iterator An iterator containing the new clauses to be loaded; this should only iterate over DefiniteClause objects. These iterators can be created by calling the iterator() method of parsers - such as RuleMLParser or POSLParser.

runForwardReasoner

public void runForwardReasoner()
This method runs the main forward reasoner; causing the engine to find all possible conclusions from the knowledge base that was loaded into the engine. Bellow is the main process of the system. As long as there is a new fact in the newFacts list remove the first fact from the list. Check to see if this fact is subsumed by another already processed fact (oldFacts); if it is subsumed, discard the fact and move to the next fact in the list. Add the fact to the old fact table. Find all rules that may be possible unification matches with the newly selected fact. Attempt unification with each possible rule; if the unification succeeds then build the resolvent and call the process(DefiniteClause) method passing the newly created resolvent.