|
JTP API Documentation | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.beans.beancontext.BeanContextChildSupport | +--java.beans.beancontext.BeanContextSupport | +--jtp.context.BasicReasoningContext
A basic interface for JTP with a default
configuration
.
A reasoning context is the interface that a user should interact with.
A reasoning context provides an interface to an AskingControlReasoner,
a TellingControlReasoner, an AskingControlDispatcher, and a
TellingControlDispatcher. The BasicReasoningContext provides
usable methods such as ask(String)
, tell(Object)
,
and tellString(String)
.
The BasicReasoningContext exports several properties to its
nested children by firing java.beans.PropertyChangeEvents when
the properties are set/changed. In order for an object to import
one or more properties from this context, it should extend
PropertyImporter
and use the method PropertyImporter.setImportedProperties(java.lang.String[])
.
The object must also be added as a child to this context via the
method BeanContextSupport.add(Object)
.
Field Summary | |
Tracer |
tracer
|
Fields inherited from class java.beans.beancontext.BeanContextSupport |
bcmListeners, children, designTime, locale, okToUseGui |
Fields inherited from class java.beans.beancontext.BeanContextChildSupport |
beanContext, beanContextChildPeer, pcSupport, rejectedSetBCOnce, vcSupport |
Fields inherited from interface java.beans.beancontext.BeanContext |
globalHierarchyLock |
Fields inherited from interface java.beans.DesignMode |
PROPERTYNAME |
Constructor Summary | |
BasicReasoningContext()
|
Method Summary | |
ReasoningStepIterator |
ask(String query)
Submits a query. |
int |
assertString(String assertion)
Deprecated. Use tellString(String) . |
void |
defaultSetup()
Performs a default setup for this context. |
Dispatcher |
getAskingDispatcher()
Returns the AskingControlDispatcher. |
Reasoner |
getAskingReasoner()
Returns the AskingControlReasoner. |
ReasoningStepIterator |
getAssertionResults(DirectAssertion assertion)
Asserts assertion to the telling reasoners. |
Dispatcher |
getIntermediateResultDispatcher()
|
int |
getMaxDepth()
Returns an integer representing both the telling and asking systems' maximum depth. |
FirstOrderLogicParser |
getParser()
Returns parser used to parse String and URL arguments to tellString(String) , tellString(String, URL) ,
loadKB(URL, URL) , loadKB(URL) ,
getStringAssertionResults(String) , and
ask(String) . |
ReasoningStepIterator |
getStringAssertionResults(String assertion)
Asserts to the telling reasoners the clauses encoded in a String. |
Dispatcher |
getTellingDispatcher()
Returns the TellingControlDispatcher. |
Reasoner |
getTellingReasoner()
Returns the TellingControlReasoner. |
Tracer |
getTracer()
Returns the tracer being used by the system. |
FirstOrderLogicTranslator |
getTranslator()
Returns translator used to translate String argument in ask(String) . |
UndoManager |
getUndoManager()
Returns the Undo Manager used to store modifications to the system so that the system can be returned to previous states. |
void |
loadClauses(ClauseIterator cit,
URL publicLocation)
Feeds a sequence of clauses to the telling reasoner. |
void |
loadKB(URL url)
Loads a KB from a URL. |
void |
loadKB(URL actualLocation,
URL publicLocation)
Loads a KB from a URL. |
void |
setAskingDispatcher(Dispatcher v)
Sets the AskingControlDispatcher . |
void |
setAskingReasoner(Reasoner v)
Sets the AskingControlReasoner . |
void |
setIntermediateResultDispatcher(Dispatcher v)
Fires a PropertyChangeEvent. |
void |
setMaxDepth(int v)
Sets both the telling and asking systems' maximum depth . |
void |
setParser(FirstOrderLogicParser v)
Sets parser returned by getParser() . |
void |
setTellingDispatcher(Dispatcher v)
Sets the TellingControlDispatcher . |
void |
setTellingReasoner(Reasoner v)
Sets the TellingControlReasoner . |
void |
setTracer(Tracer v)
Sets the tracer to be used by the system. |
void |
setUndoManager(UndoManager undo)
Sets the UndoManager . |
int |
tell(Object assertion)
A DirectAssertion with assertion as its goal is
sent to the TellingControlReasoner . |
protected int |
tellInternal(DirectAssertion assertion)
Helper method called by most of the public tell
methods (e.g., tellString(String) ). |
int |
tellString(String assertion)
Asserts to the telling reasoners the Clauses encoded in a String. |
int |
tellString(String assertion,
URL url)
Asserts to the telling reasoners the clauses encoded in a String. |
boolean |
undo()
Undoes the last top-level modification made to the system. |
void |
untell(Object assertion)
Attempts to untell assertion via the undo manager. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.beans.beancontext.BeanContextChild |
addPropertyChangeListener, addVetoableChangeListener, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext |
Methods inherited from interface java.util.Collection |
equals, hashCode |
Field Detail |
public Tracer tracer
Constructor Detail |
public BasicReasoningContext()
Method Detail |
public FirstOrderLogicParser getParser()
tellString(String)
, tellString(String, URL)
,
loadKB(URL, URL)
, loadKB(URL)
,
getStringAssertionResults(String)
, and
ask(String)
.
public void setParser(FirstOrderLogicParser v)
getParser()
. Also sets
Translator
's parser.
Fires a PropertyChangeEvent.
v
- default FirstOrderLogicParser to be used by this contextpublic FirstOrderLogicTranslator getTranslator()
ask(String)
. Initially, this is an instance of
ParserBasedTranslator
.
public Reasoner getAskingReasoner()
AskingControlDispatcher
.
public void setAskingReasoner(Reasoner v)
AskingControlReasoner
.
Fires a PropertyChangeEvent.
v
- the AskingControlReasoner to be used by this contextpublic Dispatcher getAskingDispatcher()
AskingControlReasoner
.
The AskingControlDispatcher is the top-level manager of
all of the general-purpose and domain-specific asking
Reasoner
s that participate in the proof of a query
by proving and generating subgoals.
Use DispatcherUtils.addToDispatcher(Reasoner, Dispatcher)
and DispatcherUtils.removeFromDispatcher(Reasoner, Dispatcher)
to add and remove Reasoners from a Dispatcher.
public void setAskingDispatcher(Dispatcher v)
AskingControlDispatcher
.
Fires a PropertyChangeEvent.
v
- AskingControlDispatcher to be used by this contextpublic Reasoner getTellingReasoner()
TellingControlDispatcher
.
public void setTellingReasoner(Reasoner v)
TellingControlReasoner
.
Fires a PropertyChangeEvent.
v
- TellingControlReasoner to be used by this contextpublic Dispatcher getTellingDispatcher()
TellingControlReasoner
.
The TellingControlDispatcher is the top-level manager of
the general-purpose and domain-specific telling
Reasoner
s that participate in the assertion of
knowledge to the system by storing assertions and generating
derived consequences from assertions.
Use DispatcherUtils.addToDispatcher(Reasoner, Dispatcher)
and DispatcherUtils.removeFromDispatcher(Reasoner, Dispatcher)
to add and remove Reasoners from a Dispatcher.
public void setTellingDispatcher(Dispatcher v)
TellingControlDispatcher
.
Fires a PropertyChangeEvent.
v
- TellingControlDispatcher to be used by this contextpublic Dispatcher getIntermediateResultDispatcher()
public void setIntermediateResultDispatcher(Dispatcher v)
public Tracer getTracer()
public void setTracer(Tracer v)
Fires a PropertyChangeEvent.
v
- Tracer to be used by this reasoners that record tracing informationpublic UndoManager getUndoManager()
PropertyImporter
). Telling Reasoners are most
likely to use the UndoManager.
undo()
,
untell(Object)
,
UntellUndoManager
,
SnapshotUndoManager
,
PropertyImporter
public void setUndoManager(UndoManager undo)
UndoManager
.
Fires a PropertyChangeEvent.
undo
- UndoManager to be used (primarily by telling reasoners)public boolean undo()
undo()
immediately after
calling loadKB
will result in the removal of the
contents of the last loaded KB from the system.
public int getMaxDepth()
public void setMaxDepth(int v)
depth
.
Fires a PropertyChangeEvent.
v
- maximum depth of inferencepublic void untell(Object assertion) throws CannotUndoException, ReasoningException
assertion
via the undo manager.
After the assertion
has been untold, the assertions that needed to be retold will all be
wrapped in a new MultipleTellEdit, so calling undo()
will
perform differently after an untell than it would have before the
untell.
Executing SnapshotUndoManager.revertToSnapshot(Snapshot)
will
still work assuming the user took the Snapshot
before
the user originally told the assertion.
assertion
- a previously asserted object.
CannotUndoException
ReasoningException
public int tell(Object assertion) throws ReasoningException
DirectAssertion
with assertion
as its goal is
sent to the TellingControlReasoner
.
assertion
- a goal to be told. Most common goals are instances of CNFSentence
ReasoningException
protected int tellInternal(DirectAssertion assertion) throws ReasoningException
tell
methods (e.g., tellString(String)
).
tellInternal
wraps assertion
and all of the resulting modifications to the system in
a TellEdit
.
assertion
- the assertion to be added to the system
ReasoningException
public int assertString(String assertion) throws ReasoningException
tellString(String)
.
ReasoningException
public int tellString(String assertion) throws ReasoningException
parser
to convert
assertion
into Clause
s. The Clauses
are then sequentially passed to the
TellingControlReasoner
as the
goals of new DirectAssertion
s. The
DirectAssertions and their inferred consequences are
stored in the
system. Note that the consequences that are inferred and
stored are determined by the telling reasoners that the
system has been configured to use via the
TellingControlDispatcher
.
assertion
- a String that is parsed into Clauses by the FirstOrderLogicParser returned by getParser(), and the Clauses are asserted in the telling system as goals of DirectAssertions
assertion
ReasoningException
public int tellString(String assertion, URL url) throws ReasoningException
assertion
- a String that is parsed into Clauses by the FirstOrderLogicParser returned by getParser(), and the Clauses are asserted in the telling system as goals of DirectAssertionsurl
- used by the parser to resolve names of constants denoted in the String, as in RDF
assertion
ReasoningException
tellString(String)
public ReasoningStepIterator getStringAssertionResults(String assertion) throws ReasoningException
parser
to parse assertion
into Clause
s. The Clauses are the goals of
DirectAssertion
s that are asserted to the
TellingControlReasoner
.
This method returns a ReasoningStepIterator
that
contains proofs for all derived consequences of the
assertion
. The assertion and its consequences
are only asserted to the system as the returned
ReasoningStepIterator is
pulsed
.
The user must pulse through all results in the
ReasoningStepIterator in order for the assertion and all its
derived consequences to be asserted to the system.
Note that the consequences that are inferred and
stored are determined by the telling reasoners that the
system has been configured to use via the
TellingControlDispatcher
.
assertion
- a String to be parsed into Clauses that are asserted in the system
ReasoningException
tellString(String)
public ReasoningStepIterator getAssertionResults(DirectAssertion assertion) throws ReasoningException
assertion
to the telling reasoners.
assertion
is asserted to the
TellingControlReasoner
.
This method returns a ReasoningStepIterator
that
contains proofs for all derived consequences of the
assertion
. The assertion and its consequences
are only asserted to the system as the returned
ReasoningStepIterator is
pulsed
.
The user must pulse through all results in the
ReasoningStepIterator in order for the assertion and all its
derived consequences to be asserted to the system.
Note that the consequences that are inferred and
stored are determined by the telling reasoners that the
system has been configured to use via the
TellingControlDispatcher
.
assertion
- asserted in the sytem
ReasoningException
tellString(String)
,
getStringAssertionResults(String)
public ReasoningStepIterator ask(String query) throws ReasoningException
The query string is translated by the FirstOrderLogicTranslator
returned by getTranslator()
into a CNFSentence
.
The translator uses the specified parser
to
parse the string.
The query is passed to the
AskingControlReasoner
, and
reasoners that are in the
AskingDispatcher
will have an opportunity to prove the query.
query
- the query string
ReasoningStepIterator
containing proofs (if any)
of the query
ReasoningException
public void loadKB(URL actualLocation, URL publicLocation) throws ReasoningException, IOException
ClauseIterator
that the parser returns is fed
to loadClauses(ClauseIterator, URL)
.) The KB is assumed to be in the language of our parser. The "official"
location of the KB is set to publicLocation
.
ReasoningException
IOException
public void loadClauses(ClauseIterator cit, URL publicLocation) throws ReasoningException
cit
- a sequence of clauses (e.g., returned by a parser.)
ReasoningException
public void loadKB(URL url) throws ReasoningException, IOException
url
- the URL to load the KB from.
ReasoningException
IOException
public void defaultSetup()
ask
or tell
methods are called.
Sets the AskingControlReasoner
to an IterativeDeepening
reasoner whose theorem prover
is a ModelEliminationReasoner
.
Sets the TellingControlReasoner
to a BreadthFirstForwardReasoner
.
Sets the AskingControlDispatcher
and TellingControlDispatcher
to instances of SequentialDispatcher
.
Sets the Parser
to a KIF2CNF
.
Sets the Tracer
to a PrintStreamTracer
.
Sets the UndoManager
to a UntellUndoManager
.
|
JTP API Documentation | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |