Now that I have owlexplanation compiling without errors I'm still unable to determine WHY my ontology is considered inconsistent. :-(
I have an ontology with 208 classes and Protege processes it just fine using the HermiT reasoner. No inconsistencies found.
But if I use the same ontology and the HermiT reasoner in Java it is flagged as inconsistent. I would like to know what is causing the inconsistency.
In both cases below the call to reasoner.isConsistent() is true. Before the call my debugger shows isConsistent=false in the reasoner meta-data.
I've tried determining the offending classes two ways, both have yielded unsatisfactory results.
Here is the first attempt, which yields an empty set.
It uses reasoner.getSubClasses(nothing, false):
public void createReasoner(OWLOntology ont) {
Configuration config=new Configuration();
config.reasonerProgressMonitor = new HxProgressMonitor();
config.ignoreUnsupportedDatatypes = false;
config.throwInconsistentOntologyException = false;
org.semanticweb.HermiT.Reasoner reasoner;
reasoner = new Reasoner(config, ont);
if (!reasoner.isConsistent()) {
OWLOntologyManager manager= OWLManager.createOWLOntologyManager();
OWLDataFactory dataFactory=manager.getOWLDataFactory();
OWLClass nothing = dataFactory.getOWLNothing();
// Note: I've tried true and false, same result
NodeSet<OWLClass> subClasses = reasoner.getSubClasses(nothing, false);
System.out.println("\n" + subClasses.toString());
}
}
The output is:
NodeSet[]
--------------
My second attempt uses reasoner.getUnsatisfiableClasses() and returns every class in the ontology, including owl:thing and owl:nothing:
public void precompute() {
Configuration config=new Configuration();
config.reasonerProgressMonitor = new HxProgressMonitor();
config.ignoreUnsupportedDatatypes = false;
config.throwInconsistentOntologyException = false;
org.semanticweb.HermiT.Reasoner reasoner;
reasoner = new Reasoner(config, ont);
// Set the config to inference every type available
Set<InferenceType> precompute = EnumSet.of(InferenceType.CLASS_HIERARCHY);
precompute.addAll(reasoner.getPrecomputableInferenceTypes());
if (!reasoner.isConsistent()) {
System.out.println("---------------------------------------------------------");
System.out.println("Here are the bad classes:\n");
Node<OWLClass> badClasses = reasoner.getUnsatisfiableClasses();
Iterator itr = badClasses.iterator();
while (itr.hasNext()) {
OWLClass myClass = (OWLClass)itr.next();
System.out.println(myClass.toString());
}
System.out.println("---------------------------------------------------------");
}
// Do the actual inferencing
reasoner.precomputeInferences(precompute.toArray(new InferenceType[precompute.size()]));
}
The fact that Protege doesn't find the ontology inconsistent makes me think I am doing something wrong, but what?.
BTW: the ending call to reasoner.precomputeInferences(…) crashes with a null pointer exception.
Your help is greatly appreciated.