From: <jen...@us...> - 2009-04-14 07:01:54
|
Revision: 1695 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1695&view=rev Author: jenslehmann Date: 2009-04-14 07:01:50 +0000 (Tue, 14 Apr 2009) Log Message: ----------- test case showing a bug in Pellet Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/test/PelletBug.java Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2009-04-09 16:36:41 UTC (rev 1694) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2009-04-14 07:01:50 UTC (rev 1695) @@ -1051,17 +1051,23 @@ public boolean remainsSatisfiableImpl(Axiom axiom) { boolean consistent = true; OWLAxiom axiomOWLAPI = OWLAPIAxiomConvertVisitor.convertAxiom(axiom); + try { manager.applyChange(new AddAxiom(ontology, axiomOWLAPI)); + } catch (OWLOntologyChangeException e1) { + e1.printStackTrace(); + } + + try { consistent = reasoner.isConsistent(ontology); + } catch (OWLReasonerException e) { + e.printStackTrace(); + } + + try { manager.applyChange(new RemoveAxiom(ontology, axiomOWLAPI)); - } catch (OWLOntologyChangeException e) { - e.printStackTrace(); - } catch (OWLReasonerException e) { - - e.printStackTrace(); } return consistent; Modified: trunk/src/dl-learner/org/dllearner/test/PelletBug.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/PelletBug.java 2009-04-09 16:36:41 UTC (rev 1694) +++ trunk/src/dl-learner/org/dllearner/test/PelletBug.java 2009-04-14 07:01:50 UTC (rev 1695) @@ -8,16 +8,22 @@ import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.inference.OWLReasoner; import org.semanticweb.owl.inference.OWLReasonerException; +import org.semanticweb.owl.model.AddAxiom; +import org.semanticweb.owl.model.OWLAxiom; import org.semanticweb.owl.model.OWLClass; import org.semanticweb.owl.model.OWLDataFactory; import org.semanticweb.owl.model.OWLDescription; import org.semanticweb.owl.model.OWLOntology; +import org.semanticweb.owl.model.OWLOntologyChangeException; import org.semanticweb.owl.model.OWLOntologyCreationException; import org.semanticweb.owl.model.OWLOntologyManager; +import org.semanticweb.owl.model.OWLOntologyStorageException; +import org.semanticweb.owl.model.RemoveAxiom; +import org.semanticweb.owl.model.UnknownOWLOntologyException; public class PelletBug { - public static void main(String[] args) throws OWLOntologyCreationException, OWLReasonerException { + public static void main(String[] args) throws OWLOntologyCreationException, OWLReasonerException, UnknownOWLOntologyException, OWLOntologyStorageException { OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); File f = new File("examples/family/father_oe.owl"); @@ -25,26 +31,54 @@ OWLOntology ontology = manager.loadOntologyFromPhysicalURI(physicalURI); OWLDataFactory factory = manager.getOWLDataFactory(); + // create a view class expressions and an axiom String ontologyURI = "http://example.com/father#"; - - // super: (http://example.com/father#female AND http://example.com/father#male); sub: http://example.com/father#female - OWLClass male = factory.getOWLClass(URI.create(ontologyURI + "male")); OWLClass female = factory.getOWLClass(URI.create(ontologyURI + "female")); -// OWLDescription negA = factory.getOWLObjectComplementOf(a); + OWLClass father = factory.getOWLClass(URI.create(ontologyURI + "father")); OWLDescription insat = factory.getOWLObjectIntersectionOf(male, female); -// OWLClass d = factory.getOWLClass(URI.create(ontologyURI + "#b")); + OWLDescription test = factory.getOWLObjectComplementOf(male); + OWLAxiom axiom = factory.getOWLEquivalentClassesAxiom(father, test); + // load ontology Set<OWLOntology> ontologies = new HashSet<OWLOntology>(); ontologies.add(ontology); - OWLReasoner reasoner = new org.mindswap.pellet.owlapi.Reasoner(manager); reasoner.loadOntologies(ontologies); + // first subsumption check => everything runs smoothly boolean result = reasoner.isSubClassOf(female, insat); - System.out.println(result); + System.out.println("subsumption before: " + result); + + // add axiom causing the ontology to be inconsistent + try { + manager.applyChange(new AddAxiom(ontology, axiom)); + } catch (OWLOntologyChangeException e1) { + e1.printStackTrace(); + } -// System.out.println(reasoner.getIndividuals(female, true)); + // Pellet correctly detects the inconsistency + try { + System.out.println("consistent: " + reasoner.isConsistent(ontology)); + } catch (OWLReasonerException e) { + e.printStackTrace(); + } + + // remove axiom + try { + manager.applyChange(new RemoveAxiom(ontology, axiom)); + } catch (OWLOntologyChangeException e) { + e.printStackTrace(); + } + + // save file to verify that it remained unchanged (it is unchanged) + manager.saveOntology(ontology, new File("test.owl").toURI()); + + // perform subsumption check => Pellet now fails due to an inconsistency, + // although the ontology is unchanged from the point of view of the OWL API + result = reasoner.isSubClassOf(female, insat); + System.out.println("subsumption after: " + result); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |