org.semanticweb.kaon2.api.reasoner
Interface Reasoner


public interface Reasoner

Provides methods to answer questions over an ontology. Instances of this class are obtained from Ontology. After usage, they should be closed using dispose(); otherwise, serious resource leakage is possible. All reasoning methods can be interrupted. Reasoner objects are not thread-safe objects; however, you can use different reasoner instances on different threads.


Method Summary
 Query createQuery(java.util.List<Literal> queryLiterals, java.util.List<Variable> distinguishedVariables)
          Creates a conjunctive DL-safe query over the ontology owned by the reasoner.
 Query createQuery(java.util.List<Literal> queryLiterals, java.util.List<Variable> distinguishedVariables, java.util.List<Rule> additionalRules, java.util.List<Literal> constructPattern)
          Creates a conjunctive DL-safe query over the ontology owned by the reasoner.
 Query createQuery(Literal[] queryLiterals, Variable[] distinguishedVariables)
          Creates a conjunctive DL-safe query over the ontology owned by the reasoner.
 Query createQuery(Literal[] queryLiterals, Variable[] distinguishedVariables, Rule[] additionalRules, Literal[] constructPattern)
          Creates a conjunctive DL-safe query over the ontology owned by the reasoner.
 Query createQuery(Predicate predicate)
          Creates a conjunctive DL-safe query which returns the complete extension of the supplied predicate.
 Query createQuerySPARQL(Namespaces namespaces, java.lang.String queryText)
          Creates a query object from a SPARQL query text.
 void dispose()
          Frees the resources used by this reasoner.
 boolean equivalent(Description description1, Description description2)
          Checks if descriptions are equivalent.
 Ontology getOntology()
          Returns the ontology to which this reasoner is attached.
 java.lang.Object getParameter(java.lang.String parameterName)
          Returns the parameter of the reasoner.
 java.util.List<Rule> getReductionToDisjunctiveDatalog(boolean processABox, boolean unfoldNewPredicates, boolean unfoldNonAtomicDescriptionsInABox, boolean includeRules)
          Reduces the ontology to disjunctive datalog and returns thus obtained rules.
 java.util.List<Rule> getReductionToDLP(boolean processABox, boolean unfoldNewPredicates, boolean unfoldNonAtomicDescriptionsInABox, boolean includeRules)
          Reduces to ontology to disjunctive datalog, provided that it is in the DLP fragment.
 SubsumptionHierarchy getSubsumptionHierarchy()
          Computes the subsumption hierarchy for the knowledge base managed by this reasoner.
 void interrupt()
          Interrupts the current reasoning operation conducted by this reasoner.
 boolean isSatisfiable()
          Checks if the knowledge base is satisfiable.
 boolean isSatisfiable(Description description)
          Checks if a description is satisfiable w.r.t. the TBox and the RBox.
 boolean isTBoxRBoxSatisfiable()
          Checks if the TBox and RBox of an ontology are satisfiable (i.e. it takes only terminological information into accout).
 void setParameter(java.lang.String parameterName, java.lang.Object parameterValue)
          Sets the parameter of the reasoner.
 void setTrace(java.lang.String target, boolean state, java.io.PrintWriter out, Namespaces namespaces)
          Activates or deactivates tracing in this reasoner.
 boolean subsumedBy(Description subDescription, Description superDescription)
          Checks if one description subsumes the other w.r.t. the knowledge base.
 

Method Detail

getOntology

Ontology getOntology()
Returns the ontology to which this reasoner is attached.

Returns:
the ontology to which this reasoner is attached

dispose

void dispose()
Frees the resources used by this reasoner. This method should be called after the reasoner is not needed any more to avoid resource leakage. The effects of calls on this object after dispose() is called once are undefined.


interrupt

void interrupt()
               throws KAON2Exception
Interrupts the current reasoning operation conducted by this reasoner. This method is thread-safe. If no reasoning operation is in progress on this reasoner, this invocation has no effect.

Throws:
KAON2Exception - thrown if there is an error

setParameter

void setParameter(java.lang.String parameterName,
                  java.lang.Object parameterValue)
                  throws KAON2Exception
Sets the parameter of the reasoner. If the parameter is not supported, an exception is thrown. The names and values of the reasoner parameters are implementation-dependent.

Parameters:
parameterName - the name of the parameter
parameterValue - the value of the parameter
Throws:
KAON2Exception - thrown if there is an error
KAON2Exception - thrown if the parameter name of value are incorrect

getParameter

java.lang.Object getParameter(java.lang.String parameterName)
                              throws KAON2Exception
Returns the parameter of the reasoner. If the reasoner does not support the given parameter, null is returned.

Parameters:
parameterName - the name of the parameter
Returns:
the value (or null if the parameter is not supported
Throws:
KAON2Exception - thrown if the parameter name of value are incorrect

setTrace

void setTrace(java.lang.String target,
              boolean state,
              java.io.PrintWriter out,
              Namespaces namespaces)
              throws KAON2Exception
Activates or deactivates tracing in this reasoner. This method changes approrpiate parameters of this reasoner.

Parameters:
target - the target of the trace (can be "queryAnswering", "reasoner", "theoremProver", "clausification", "clausificationSPASS" or "clausificationTPTP")
state - true if the tracing is to be turned on
out - the print writer receiving the output
namespaces - the namespaces object used to abbreviate names in the output
Throws:
KAON2Exception - thrown if the parameter name of value are incorrect

isTBoxRBoxSatisfiable

boolean isTBoxRBoxSatisfiable()
                              throws KAON2Exception,
                                     java.lang.InterruptedException
Checks if the TBox and RBox of an ontology are satisfiable (i.e. it takes only terminological information into accout).

Returns:
true if the terminological part of the ontology is satisfiable
Throws:
KAON2Exception - thrown if there is an error
java.lang.InterruptedException - thrown if reasoning is interrupted

subsumedBy

boolean subsumedBy(Description subDescription,
                   Description superDescription)
                   throws KAON2Exception,
                          java.lang.InterruptedException
Checks if one description subsumes the other w.r.t. the knowledge base. In the check, only the terminological part is taken into account (i.e. a possible inconsistency in the ABox is not taken into account).

Parameters:
subDescription - the subdescription
superDescription - the superdescription
Returns:
true if the subdescription is subsumed by the superdescription
Throws:
KAON2Exception - thrown if there is an error
java.lang.InterruptedException - thrown if reasoning is interrupted

equivalent

boolean equivalent(Description description1,
                   Description description2)
                   throws KAON2Exception,
                          java.lang.InterruptedException
Checks if descriptions are equivalent. In the check, only the terminological part is taken into account (i.e. a possible inconsistency in the ABox is not taken into account).

Parameters:
description1 - the first description
description2 - the second description
Returns:
true if the descriptions are equivalent
Throws:
KAON2Exception - thrown if there is an error
java.lang.InterruptedException - thrown if reasoning is interrupted

isSatisfiable

boolean isSatisfiable(Description description)
                      throws KAON2Exception,
                             java.lang.InterruptedException
Checks if a description is satisfiable w.r.t. the TBox and the RBox. This method does not take the ABox into account.

Parameters:
description - the description
Returns:
true if the description is satisfiable
Throws:
KAON2Exception - thrown if there is an error
java.lang.InterruptedException - thrown if reasoning is interrupted

isSatisfiable

boolean isSatisfiable()
                      throws KAON2Exception,
                             java.lang.InterruptedException
Checks if the knowledge base is satisfiable. This method takes TBox, RBox and ABox into account.

Returns:
true if this knowledge base is satisfiable
Throws:
KAON2Exception - thrown if there is an error
java.lang.InterruptedException - thrown if reasoning is interrupted

getSubsumptionHierarchy

SubsumptionHierarchy getSubsumptionHierarchy()
                                             throws KAON2Exception,
                                                    java.lang.InterruptedException
Computes the subsumption hierarchy for the knowledge base managed by this reasoner.

Returns:
the subsumption hierarchy
Throws:
KAON2Exception - thrown if there is an error
java.lang.InterruptedException - thrown if reasoning is interrupted

getReductionToDisjunctiveDatalog

java.util.List<Rule> getReductionToDisjunctiveDatalog(boolean processABox,
                                                      boolean unfoldNewPredicates,
                                                      boolean unfoldNonAtomicDescriptionsInABox,
                                                      boolean includeRules)
                                                      throws KAON2Exception,
                                                             java.lang.InterruptedException
Reduces the ontology to disjunctive datalog and returns thus obtained rules. Thus obtained program does not contain the DL-safe rules; these should be appended manually.

Parameters:
processABox - true if ABox is to be processed as well
unfoldNewPredicates - true if the predicates introduced in the reduction should removed by rule unfolding
unfoldNonAtomicDescriptionsInABox - true if the new predicates should be unfolded from the ABox assertions as well
includeRules - true if the rules should be included in the translation
Returns:
the list of disjunctive rules
Throws:
KAON2Exception - thrown if there is an error
java.lang.InterruptedException - thrown if reasoning is interrupted

getReductionToDLP

java.util.List<Rule> getReductionToDLP(boolean processABox,
                                       boolean unfoldNewPredicates,
                                       boolean unfoldNonAtomicDescriptionsInABox,
                                       boolean includeRules)
                                       throws KAON2Exception,
                                              java.lang.InterruptedException
Reduces to ontology to disjunctive datalog, provided that it is in the DLP fragment. If the ontology is not in the DLP fragment, an exception is thrown. This method is basically similar to getReductionToDisjunctiveDatalog(); however, for onotlogies in the DLP fragment it may be significantly faster, since it does not invoke the saturation algorithm.

Parameters:
processABox - true if ABox is to be processed as well
unfoldNewPredicates - true if the predicates introduced in the reduction should removed by rule unfolding
unfoldNonAtomicDescriptionsInABox - true if the new predicates should be unfolded from the ABox assertions as well
includeRules - true if the rules should be included in the translation
Returns:
the list of disjunctive rules
Throws:
KAON2Exception - thrown if there is an error
java.lang.InterruptedException - thrown if the process is interrupted

createQuery

Query createQuery(Literal[] queryLiterals,
                  Variable[] distinguishedVariables)
                  throws KAON2Exception
Creates a conjunctive DL-safe query over the ontology owned by the reasoner.

Parameters:
queryLiterals - the literals of the query
distinguishedVariables - the distinguished (returned) variables
Returns:
the query object
Throws:
KAON2Exception - thrown if there is an error

createQuery

Query createQuery(Literal[] queryLiterals,
                  Variable[] distinguishedVariables,
                  Rule[] additionalRules,
                  Literal[] constructPattern)
                  throws KAON2Exception
Creates a conjunctive DL-safe query over the ontology owned by the reasoner. This method additionally takes several rules which are to be considered "temporary", i.e. they are valid only during the execution of the query.

Parameters:
queryLiterals - the literals of the query
distinguishedVariables - the distinguished (returned) variables
additionalRules - the array of additional rules
constructPattern - the construct pattern of the query (may be null)
Returns:
the query object
Throws:
KAON2Exception - thrown if there is an error

createQuery

Query createQuery(java.util.List<Literal> queryLiterals,
                  java.util.List<Variable> distinguishedVariables)
                  throws KAON2Exception
Creates a conjunctive DL-safe query over the ontology owned by the reasoner.

Parameters:
queryLiterals - the literals of the query
distinguishedVariables - the distinguished (returned) variables
Returns:
the query object
Throws:
KAON2Exception - thrown if there is an error

createQuery

Query createQuery(java.util.List<Literal> queryLiterals,
                  java.util.List<Variable> distinguishedVariables,
                  java.util.List<Rule> additionalRules,
                  java.util.List<Literal> constructPattern)
                  throws KAON2Exception
Creates a conjunctive DL-safe query over the ontology owned by the reasoner. This method additionally takes several rules which are to be considered "temporary", i.e. they are valid only during the execution of the query.

Parameters:
queryLiterals - the literals of the query
distinguishedVariables - the distinguished (returned) variables
additionalRules - the array of additional rules
constructPattern - the construct pattern of the query (may be null)
Returns:
the query object
Throws:
KAON2Exception - thrown if there is an error

createQuery

Query createQuery(Predicate predicate)
                  throws KAON2Exception
Creates a conjunctive DL-safe query which returns the complete extension of the supplied predicate.

Parameters:
predicate - the predicate whose extension is retrieved
Returns:
the query object
Throws:
KAON2Exception - thrown if there is an error

createQuerySPARQL

Query createQuerySPARQL(Namespaces namespaces,
                        java.lang.String queryText)
                        throws KAON2Exception
Creates a query object from a SPARQL query text.

Parameters:
namespaces - the namespaces object (will be extended by the prefixes found in the query)
queryText - the text of the query
Returns:
the query object
Throws:
KAON2Exception - thrown if there is an error