com.hammurapi.reasoning
Interface ForwardReasoningSession<F>

Type Parameters:
F - Base class for facts.
All Superinterfaces:
ReasoningSession

public interface ForwardReasoningSession<F>
extends ReasoningSession

Marker base interface for forward reasoning sessions.

Author:
Pavel

Method Summary
 boolean contains(Handle<F> handle)
           
 boolean contains(Object fact)
           
 void executeRules()
          Fires rules execution.
 F get(Handle<F> handle)
          Retrieves object by its handle.
 Map<Class<F>,Set<Class<F>>> getConclusionMap()
          Retrieves mapping of conclusion types to fact types from which given conclusion type can be inferred.
 Collection<Derivation<F>> getDerivations(F obj)
          Returns information on how given object was derived.
 Collection<Derivation<F>> getDerivations(Handle<F> handle)
          Returns information on how given object was derived.
 Handle<F> getHandle(Object fact)
          Retrieves object handle.
 Collection<Handle<F>> getHandles()
           
 InferenceListener<F> getInferenceListener()
           
 Collection<? extends F> getObjects()
           
 Handle<F> put(F fact)
          Puts object to knowledge base.
 Handle<F>[] putAll(F... facts)
          Puts facts to the knowledge base and returns array of their handles.
 List<Handle<F>> putAll(List<? extends F> facts)
          Puts objects in the list to the knowledge base and returns their handles.
 void remove(F fact, boolean strict)
          Removes fact from the knowledge base.
 void remove(Handle<F> handle, boolean strict)
          Removes fact from the knowledge base.
 void setInferenceListener(InferenceListener<F> listener)
          Sets reasoning listener for the session.
 void updateObject(Handle<F> handle, F obj)
          Updates fact.
 
Methods inherited from interface com.hammurapi.reasoning.ReasoningSession
close, getDescription, getExceptionHandler, getName, reset, setExceptionHandler
 

Method Detail

put

Handle<F> put(F fact)
              throws ReasoningException
Puts object to knowledge base. If the same object (equals() based comparison) is put to the knowledge base several times, each time shall return the same handle. onAdd() listener method shall fire only the first time.

Parameters:
fact -
Returns:
Object handle.
Throws:
ReasoningException

putAll

List<Handle<F>> putAll(List<? extends F> facts)
                       throws ReasoningException
Puts objects in the list to the knowledge base and returns their handles.

Parameters:
facts -
Returns:
Throws:
ReasoningException

putAll

Handle<F>[] putAll(F... facts)
                   throws ReasoningException
Puts facts to the knowledge base and returns array of their handles.

Parameters:
facts -
Returns:
Throws:
ReasoningException

contains

boolean contains(Object fact)
                 throws ReasoningException
Parameters:
fact - Fact.
Returns:
True if knowledge base contains given fact.
Throws:
ReasoningException

contains

boolean contains(Handle<F> handle)
                 throws ReasoningException
Parameters:
handle - Handle.
Returns:
True if knowledge base contains fact identified by given handle.
Throws:
ReasoningException

get

F get(Handle<F> handle)
      throws ReasoningException
Retrieves object by its handle.

Parameters:
handle -
Returns:
Throws:
ReasoningException

getHandle

Handle<F> getHandle(Object fact)
Retrieves object handle.

Parameters:
fact -
Returns:
Object handle or null if object is not present in the knowledge base.

remove

void remove(F fact,
            boolean strict)
            throws ReasoningException
Removes fact from the knowledge base.

Parameters:
fact - Fact to be removed.
strict - True means that the fact is known to be false and the fact and all derivations shall be removed from the knowledge base. False means that it is not known that the fact is true, but it is not known that the fact is false either. As such, the fact shall be removed (and all derivations) only if it wasn't derived from other facts.
Throws:
ReasoningException

remove

void remove(Handle<F> handle,
            boolean strict)
            throws ReasoningException
Removes fact from the knowledge base.

Parameters:
handle - Fact represented by this handle to be removed.
strict - True means that the fact is known to be false and the fact and all derivations shall be removed from the knowledge base. False means that it is not known that the fact is true, but it is not known that the fact is false either. As such, the fact shall be removed (and all derivations) only if it wasn't derived from other facts.
Throws:
ReasoningException

getObjects

Collection<? extends F> getObjects()
                                   throws ReasoningException
Returns:
Collection of all objects in the knowledge base.
Throws:
ReasoningException

getHandles

Collection<Handle<F>> getHandles()
                                 throws ReasoningException
Returns:
Collection of handles to all objects in the knowledge base.
Throws:
ReasoningException

getDerivations

Collection<Derivation<F>> getDerivations(F obj)
                                         throws ReasoningException
Returns information on how given object was derived.

Parameters:
obj - Conclusion.
Returns:
List of derivation trees which lead to given conclusion.
Throws:
ReasoningException

getDerivations

Collection<Derivation<F>> getDerivations(Handle<F> handle)
                                         throws ReasoningException
Returns information on how given object was derived.

Parameters:
handle - Conclusion handle.
Returns:
List of derivation trees which lead to given conclusion.
Throws:
ReasoningException

executeRules

void executeRules()
                  throws ReasoningException
Fires rules execution. All rules shall finish execution before this method returns.

Throws:
ReasoningException

setInferenceListener

void setInferenceListener(InferenceListener<F> listener)
                          throws ReasoningException
Sets reasoning listener for the session.

Parameters:
listener -
Throws:
ReasoningException

getInferenceListener

InferenceListener<F> getInferenceListener()
                                          throws ReasoningException
Returns:
Session's inference listener.
Throws:
ReasoningException

updateObject

void updateObject(Handle<F> handle,
                  F obj)
                  throws ReasoningException
Updates fact. This operation is equivalent to strict removal and subsequent addition of the fact to the knowledge base.

Parameters:
handle - Fact handle.
obj - New fact value.
Throws:
InvalidReasoningSessionException
InvalidHandleException
ReasoningException

getConclusionMap

Map<Class<F>,Set<Class<F>>> getConclusionMap()
Retrieves mapping of conclusion types to fact types from which given conclusion type can be inferred. This is an optional operation to support wrapping forward reasoning sessions into backward reasoning sessions.

Returns:
Mapping Conclusion type -> Collection of fact types to support conclusion.