edu.stanford.smi.protegex.owl.inference.protegeowl
Class DefaultProtegeOWLReasoner

java.lang.Object
  extended byedu.stanford.smi.protegex.owl.inference.protegeowl.DefaultProtegeOWLReasoner
All Implemented Interfaces:
ProtegeOWLReasoner

public class DefaultProtegeOWLReasoner
extends Object
implements ProtegeOWLReasoner

User: matthewhorridge
The Univeristy Of Manchester
Medical Informatics Group
Date: Jun 14, 2004

matthew.horridge@cs.man.ac.uk
www.cs.man.ac.uk/~horridgm


Field Summary
private  boolean autoSynchReasoner
           
private  ClassListener classListener
           
private  DIGLoggerListener digLoggerListener
           
private  String kbURI
           
private  OWLModel model
           
private  ModelListener modelListener
           
private  edu.stanford.smi.protege.event.ProjectListener projectListener
           
private  PropertyListener propertyListener
           
private  PropertyValueListener propertyValueListener
           
private  DIGReasoner reasoner
           
private  ResourceAdapter resourceAdapter
           
private  boolean synchronizeReasoner
           
 
Fields inherited from interface edu.stanford.smi.protegex.owl.inference.protegeowl.ProtegeOWLReasoner
CLS1_EQUIVALENT_TO_CLS2, CLS1_SUBSUMED_BY_CLS2, CLS1_SUBSUMES_CLS2, NO_SUBSUMPTION_RELATIONSHIP
 
Constructor Summary
DefaultProtegeOWLReasoner(OWLModel kb)
           
 
Method Summary
private  void addListeners()
           
 void classifyTaxonomy(ReasonerTaskListener taskListener)
          For each named class in the ontology, this method queries the reasoner for the consistency of the class, its inferred super classes and its inferred equivalent classes.
 void computeEquivalentConcepts(ReasonerTaskListener taskListener)
           
 void computeInconsistentConcepts(ReasonerTaskListener taskListener)
          This method queries the reasoner for the consistency of all classes in the ontology, and updates protege-owl with the information.
 void computeInferredHierarchy(ReasonerTaskListener taskListener)
          For each named class in the ontology, this method queries the reasoner to obtain its inferred superclasses.
 void computeInferredIndividualTypes(ReasonerTaskListener taskListener)
           
 void forceReasonerReSynchronization()
          Depending on the implementation of the ProtegeOWLReasoner, some kind of caching may be used.
 Collection getAncestorClasses(OWLClass aClass, ReasonerTaskListener taskListener)
          Gets the inferred ancestor classes of the specified class.
 Collection getDescendantClasses(OWLClass aClass, ReasonerTaskListener taskListener)
          Gets the inferred descendant classes of the specified class.
 DIGReasoner getDIGReasoner()
          Gets the DIGReasoner that this reasoner uses to talk to the external DIG Reasoner Process
 Collection getEquivalentClasses(OWLClass aClass, ReasonerTaskListener taskListener)
          Gets the equivalent classes of the specified class.
 DIGReasonerIdentity getIdentity()
          Gets the identity of the DIG reasoner.
 Collection getIndividualsBelongingToClass(OWLClass aClass, ReasonerTaskListener taskListener)
          Gets the individuals that are inferred to be members of the specified class.
 Collection getIndividualTypes(OWLIndividual individual, ReasonerTaskListener taskListener)
          Get the inferred types for the specified individual.
 OWLModel getKnowledgeBase()
          Gets the knowledge base (OWLModel) that this reasoner reasons over.
 String getReasonerKnowledgeBaseURI()
          The external DIG Reasoner that provides the reasoning services assigns each knowledgebase that it knows about a URI in order to identify the knowledgebase.
 Collection getSubclasses(OWLClass aClass, ReasonerTaskListener taskListener)
          Gets the (direct) inferred subclasses of the specified class.
 int getSubsumptionRelationship(OWLClass cls1, OWLClass cls2, ReasonerTaskListener taskListener)
          Gets the subsumption relationship between two classes - the subsumption relationship of cls1 to cls2.
 Collection getSuperclasses(OWLClass aClass, ReasonerTaskListener taskListener)
          Gets the (direct) inferred superclasses of the specified class.
 Collection getSuperclassesOfIntersection(OWLClass[] clses, ReasonerTaskListener taskListener)
          Gets the inferred superclasses of the intersection of the list of specified classes.
 String getURL()
          Gets the URL of the external DIG reasoner.
 boolean isAutoSynchronizationEnabled()
           
 boolean isConnected()
          Determines if the ProtegeOWLReasoner can connect to an external DIG compliant reasoner to provide reasoning services.
 boolean isDisjointTo(OWLClass cls1, OWLClass cls2, ReasonerTaskListener taskListener)
          Determines if the specified classes are disjoint from each other.
 boolean isIntersectionSatisfiable(OWLClass[] clses, ReasonerTaskListener taskListener)
          Determines if the intersection of the list of specified classes is satisfiable.
 boolean isSatisfiable(OWLClass aClass, ReasonerTaskListener taskListener)
          This method queries the reasoner to determine if the specified concept is satisfiable.
 boolean isSubsumedBy(OWLClass cls1, OWLClass cls2, ReasonerTaskListener taskListener)
          Determines if one class (cls1) is subsumed by another class (cls2).
 void performTask(ReasonerTask task, ReasonerTaskListener taskListener)
          Executes the specified task after synchronizing the reasoner if necessary.
private  void reactToKnowledgeBaseChange()
           
private  void removeListeners()
           
 void setAutoSynchronizationEnabled(boolean b)
          Depending on the implementation of the ProtegeOWLReasoner, the DIG reasoner may automatically be sunchronized with changes in the Protege-OWL knowledgebase.
protected  void setKnowledgeBase(OWLModel kb)
           
 void setURL(String url)
          Sets the URL of the external DIG reasoner
protected  void synchronizeReasoner(ReasonerTaskListener taskListener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reasoner

private DIGReasoner reasoner

model

private OWLModel model

synchronizeReasoner

private boolean synchronizeReasoner

autoSynchReasoner

private boolean autoSynchReasoner

kbURI

private String kbURI

projectListener

private edu.stanford.smi.protege.event.ProjectListener projectListener

modelListener

private ModelListener modelListener

resourceAdapter

private ResourceAdapter resourceAdapter

propertyListener

private PropertyListener propertyListener

classListener

private ClassListener classListener

propertyValueListener

private PropertyValueListener propertyValueListener

digLoggerListener

private DIGLoggerListener digLoggerListener
Constructor Detail

DefaultProtegeOWLReasoner

public DefaultProtegeOWLReasoner(OWLModel kb)
Method Detail

getDIGReasoner

public DIGReasoner getDIGReasoner()
Gets the DIGReasoner that this reasoner uses to talk to the external DIG Reasoner Process

Specified by:
getDIGReasoner in interface ProtegeOWLReasoner

setKnowledgeBase

protected void setKnowledgeBase(OWLModel kb)

removeListeners

private void removeListeners()

addListeners

private void addListeners()

setURL

public void setURL(String url)
Description copied from interface: ProtegeOWLReasoner
Sets the URL of the external DIG reasoner

Specified by:
setURL in interface ProtegeOWLReasoner

getURL

public String getURL()
Description copied from interface: ProtegeOWLReasoner
Gets the URL of the external DIG reasoner.

Specified by:
getURL in interface ProtegeOWLReasoner
Returns:
A String representing the URL.

isConnected

public boolean isConnected()
Description copied from interface: ProtegeOWLReasoner
Determines if the ProtegeOWLReasoner can connect to an external DIG compliant reasoner to provide reasoning services. If this method returns false then none of the reaoning methods will work.

Specified by:
isConnected in interface ProtegeOWLReasoner

reactToKnowledgeBaseChange

private void reactToKnowledgeBaseChange()

forceReasonerReSynchronization

public void forceReasonerReSynchronization()
Description copied from interface: ProtegeOWLReasoner
Depending on the implementation of the ProtegeOWLReasoner, some kind of caching may be used. This method will force the ProtegeOWLReasoner to synchronize the contents of the external DIG reasoner prior to the next query. (Note that this will not cause the reasoner to be resynchronized immediately - synchronisation will take place the next time the reasoner is queried).

Specified by:
forceReasonerReSynchronization in interface ProtegeOWLReasoner

setAutoSynchronizationEnabled

public void setAutoSynchronizationEnabled(boolean b)
Description copied from interface: ProtegeOWLReasoner
Depending on the implementation of the ProtegeOWLReasoner, the DIG reasoner may automatically be sunchronized with changes in the Protege-OWL knowledgebase. This method will enable/disable this autosynchronization (if it is used). Note that if reasoner synchronisation is disabled, and then it is subsequently necessary to resynchronise the reasoner, the forceReasonerReSynchronization method should be used.

Specified by:
setAutoSynchronizationEnabled in interface ProtegeOWLReasoner
Parameters:
b - true to enable autosync, or false to disable autosync.

isAutoSynchronizationEnabled

public boolean isAutoSynchronizationEnabled()
Specified by:
isAutoSynchronizationEnabled in interface ProtegeOWLReasoner

getReasonerKnowledgeBaseURI

public String getReasonerKnowledgeBaseURI()
Description copied from interface: ProtegeOWLReasoner
The external DIG Reasoner that provides the reasoning services assigns each knowledgebase that it knows about a URI in order to identify the knowledgebase. This method returns the URI corresponding to the Protege-OWL knowledgebase that this reasoner reasons about.

Specified by:
getReasonerKnowledgeBaseURI in interface ProtegeOWLReasoner
Returns:
A String representing the URI.

synchronizeReasoner

protected void synchronizeReasoner(ReasonerTaskListener taskListener)
                            throws DIGReasonerException
Throws:
DIGReasonerException

getIdentity

public DIGReasonerIdentity getIdentity()
Description copied from interface: ProtegeOWLReasoner
Gets the identity of the DIG reasoner. The DIGReasonerIdentity describes the name, version and capabilities of an external DIG reasoner.

Specified by:
getIdentity in interface ProtegeOWLReasoner

getKnowledgeBase

public OWLModel getKnowledgeBase()
Description copied from interface: ProtegeOWLReasoner
Gets the knowledge base (OWLModel) that this reasoner reasons over.

Specified by:
getKnowledgeBase in interface ProtegeOWLReasoner

classifyTaxonomy

public void classifyTaxonomy(ReasonerTaskListener taskListener)
                      throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
For each named class in the ontology, this method queries the reasoner for the consistency of the class, its inferred super classes and its inferred equivalent classes. The method updates the protege-owl structures that hold this information, meaning that methods on RDFSClass such as getInferredSuperClasses will return meaningful results.

Specified by:
classifyTaxonomy in interface ProtegeOWLReasoner
Parameters:
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Throws:
DIGReasonerException

computeInferredHierarchy

public void computeInferredHierarchy(ReasonerTaskListener taskListener)
                              throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
For each named class in the ontology, this method queries the reasoner to obtain its inferred superclasses. This information is then pieced together to form the inferred hierarchy. The method updates the protege-owl structures that hold information about inferred superclasses, which means that methods such as getInferredSuperClasses on RDFSClass will return meaningful results.

Specified by:
computeInferredHierarchy in interface ProtegeOWLReasoner
Parameters:
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Throws:
DIGReasonerException

computeEquivalentConcepts

public void computeEquivalentConcepts(ReasonerTaskListener taskListener)
                               throws DIGReasonerException
Specified by:
computeEquivalentConcepts in interface ProtegeOWLReasoner
Parameters:
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Throws:
DIGReasonerException

computeInconsistentConcepts

public void computeInconsistentConcepts(ReasonerTaskListener taskListener)
                                 throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
This method queries the reasoner for the consistency of all classes in the ontology, and updates protege-owl with the information.

Specified by:
computeInconsistentConcepts in interface ProtegeOWLReasoner
Parameters:
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Throws:
DIGReasonerException

computeInferredIndividualTypes

public void computeInferredIndividualTypes(ReasonerTaskListener taskListener)
                                    throws DIGReasonerException
Specified by:
computeInferredIndividualTypes in interface ProtegeOWLReasoner
Parameters:
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Throws:
DIGReasonerException

isSatisfiable

public boolean isSatisfiable(OWLClass aClass,
                             ReasonerTaskListener taskListener)
                      throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
This method queries the reasoner to determine if the specified concept is satisfiable.

Specified by:
isSatisfiable in interface ProtegeOWLReasoner
Parameters:
aClass - The OWLClass whose satisfiablity is to be determined.
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Returns:
true if the specified class is satisfiable (consistent) , or false if the specified class is not satisfiable (not consistent).
Throws:
DIGReasonerException

isIntersectionSatisfiable

public boolean isIntersectionSatisfiable(OWLClass[] clses,
                                         ReasonerTaskListener taskListener)
                                  throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
Determines if the intersection of the list of specified classes is satisfiable.

Specified by:
isIntersectionSatisfiable in interface ProtegeOWLReasoner
Parameters:
clses - An array of OWLClasses, of which the satisfiablity of the intersection will be determined.
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Returns:
true if the intersection of the list of classes is satisfiable (consistent) or false if the intersection of the list of classes is not satisfiable (not consistent)
Throws:
DIGReasonerException

isSubsumedBy

public boolean isSubsumedBy(OWLClass cls1,
                            OWLClass cls2,
                            ReasonerTaskListener taskListener)
                     throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
Determines if one class (cls1) is subsumed by another class (cls2). In other words, determines if cls2 is a superclass of cls1.

Specified by:
isSubsumedBy in interface ProtegeOWLReasoner
Parameters:
cls1 - The subsumee (the expected subclass)
cls2 - The subsumer (the expected superclass)
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Returns:
true if cls1 is subsumed by cls2, or false if cls1 is not subsumed by cls2.
Throws:
DIGReasonerException

isDisjointTo

public boolean isDisjointTo(OWLClass cls1,
                            OWLClass cls2,
                            ReasonerTaskListener taskListener)
                     throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
Determines if the specified classes are disjoint from each other. Note that because disjointedness is a symmetric property, the order of the specified classes does not matter.

Specified by:
isDisjointTo in interface ProtegeOWLReasoner
Parameters:
cls1 - An OWLClass
cls2 - An OWLClass
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Returns:
true if cls1 is disjoint with cls2.
Throws:
DIGReasonerException

getSubsumptionRelationship

public int getSubsumptionRelationship(OWLClass cls1,
                                      OWLClass cls2,
                                      ReasonerTaskListener taskListener)
                               throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
Gets the subsumption relationship between two classes - the subsumption relationship of cls1 to cls2. The ordering of arguments is important.

Specified by:
getSubsumptionRelationship in interface ProtegeOWLReasoner
Parameters:
cls1 - An OWLClass
cls2 - An OWLClass
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Returns:
An integer that indicates the subsumption relationship of cls1 in relation to cls2. See the constants defined in ProtegeOWLReasoner for result values
Throws:
DIGReasonerException

getSuperclasses

public Collection getSuperclasses(OWLClass aClass,
                                  ReasonerTaskListener taskListener)
                           throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
Gets the (direct) inferred superclasses of the specified class.

Specified by:
getSuperclasses in interface ProtegeOWLReasoner
Parameters:
aClass - The class whose inferred superclasses are to be retrieved.
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Returns:
A Collection containing the classes that are the inferred superclasses of the specified class.
Throws:
DIGReasonerException

getSuperclassesOfIntersection

public Collection getSuperclassesOfIntersection(OWLClass[] clses,
                                                ReasonerTaskListener taskListener)
                                         throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
Gets the inferred superclasses of the intersection of the list of specified classes.

Specified by:
getSuperclassesOfIntersection in interface ProtegeOWLReasoner
Parameters:
clses - An array of OWLClasses, the intersection of which will be obtained and then the inferred superclasses of this intersection class will be retrieved from the reasoner.
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Returns:
A Collection of classes.
Throws:
DIGReasonerException

getSubclasses

public Collection getSubclasses(OWLClass aClass,
                                ReasonerTaskListener taskListener)
                         throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
Gets the (direct) inferred subclasses of the specified class.

Specified by:
getSubclasses in interface ProtegeOWLReasoner
Parameters:
aClass - The class whose inferred subclasses are to be retrieved.
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Returns:
A Collection containing the inferred subclasses of the specified class.
Throws:
DIGReasonerException

getAncestorClasses

public Collection getAncestorClasses(OWLClass aClass,
                                     ReasonerTaskListener taskListener)
                              throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
Gets the inferred ancestor classes of the specified class. The inferred ancestor classes is equivalent to the transitive closure of the inferred superclasses.

Specified by:
getAncestorClasses in interface ProtegeOWLReasoner
Parameters:
aClass - The class whose inferred ancestor classes are to be retrieved.
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Returns:
A Collection containing the inferred ancestor classes of the specified class.
Throws:
DIGReasonerException

getDescendantClasses

public Collection getDescendantClasses(OWLClass aClass,
                                       ReasonerTaskListener taskListener)
                                throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
Gets the inferred descendant classes of the specified class. The inferred descendant classes is equivalent to the transitive closure of the inferred subclasses.

Specified by:
getDescendantClasses in interface ProtegeOWLReasoner
Parameters:
aClass - The class whose descendent classes are to be retrieved.
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Returns:
A Collection containing the inferred descendent classes.
Throws:
DIGReasonerException

getEquivalentClasses

public Collection getEquivalentClasses(OWLClass aClass,
                                       ReasonerTaskListener taskListener)
                                throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
Gets the equivalent classes of the specified class.

Specified by:
getEquivalentClasses in interface ProtegeOWLReasoner
Parameters:
aClass - The class whose equivalent classes are to be retrieved.
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Returns:
A Collection containing the inferred equivalent classes of the specified class.
Throws:
DIGReasonerException

getIndividualsBelongingToClass

public Collection getIndividualsBelongingToClass(OWLClass aClass,
                                                 ReasonerTaskListener taskListener)
                                          throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
Gets the individuals that are inferred to be members of the specified class.

Specified by:
getIndividualsBelongingToClass in interface ProtegeOWLReasoner
Parameters:
aClass - The class whose members are to be retrieved.
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Returns:
A Collection containing the OWLIndividuals that are members of the specified class.
Throws:
DIGReasonerException

getIndividualTypes

public Collection getIndividualTypes(OWLIndividual individual,
                                     ReasonerTaskListener taskListener)
                              throws DIGReasonerException
Description copied from interface: ProtegeOWLReasoner
Get the inferred types for the specified individual.

Specified by:
getIndividualTypes in interface ProtegeOWLReasoner
Parameters:
individual - The individual whose inferred types are to be retrieved.
taskListener - - A listener which will be informed of the progress of the task. May be null if the progress of the task does not need to be monitored.
Returns:
A Collection of OWLClasses that represent the inferred types for the specified individual.
Throws:
DIGReasonerException

performTask

public void performTask(ReasonerTask task,
                        ReasonerTaskListener taskListener)
                 throws DIGReasonerException
Executes the specified task after synchronizing the reasoner if necessary. The task listener (if not null) is automatically registered with the task before task execution, and the unregistered after task execution.

Parameters:
task - The task to be executed.
taskListener - The listener to be registered with the task. May be null if no listener should be registered.
Throws:
DIGReasonerException