@Test public void deleteNonLocal() { final OWLAxiom[] axioms = { equivalentClasses(_A, all(_p, _B)), subClassOf(_C, all(_p, _B)), subClassOf(_D, all(_p, _B)), subClassOf(_D, _C) }; final OWLAxiom[] additions = {}; final OWLAxiom[] deletions = { subClassOf(_C, all(_p, _B)) }; updateTest(axioms, additions, deletions); }
@Test public void allValuesFrom() { assertRendering("p only A", OWL.all(_p, _A)); }
/** * Test that adding a non-local axiom is handled correctly. * * @throws OWLException */ @Test public void addNonLocal() { final OWLAxiom[] axioms = { declaration(_A) }; final OWLAxiom[] additions = { equivalentClasses(_B, all(_p, _B)) }; final OWLAxiom[] deletions = {}; updateTest(axioms, additions, deletions); }
@Test public void simpleType() throws Exception { // this test case is to check the effect of realization and caching // on explanations. the last axiom is to ebsure the EL classifier will // not be used final OWLAxiom[] axioms = { OWL.classAssertion(_a, _A), OWL.subClassOf(_A, _B), OWL.subClassOf(_A, OWL.all(_p, _B)) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _B), 0, axioms[0], axioms[1]); }
@Test public void simpleSubClass() throws Exception { // this test case is to check the effect of classification and caching // on explanations. the last axiom is to ebsure the EL classifier will // not be used final OWLAxiom[] axioms = { OWL.subClassOf(_A, _B), OWL.subClassOf(_B, _C), OWL.subClassOf(_A, OWL.all(_p, _B)) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.subClassOf(_A, _C), 0, axioms[0], axioms[1]); }
@Test public void allValuesTest() { final OWLAxiom[] axioms = { equivalentClasses(_A, all(_p, _B)) }; extractModules(axioms); testModule(_A, _A, _p, _B); testModule(_B, _A, _p, _B); } }
/** * Test that removal of all non-local axioms, but not *all* axioms referencing a class do not cause it to be removed from the class hierarchy. In this test * A [= B & A [= all(p,C) , A [= B is non-local w.r.t. A and is removed. A [= all(p,C) remains, but is local w.r.t. A and contains additional entities not * in the module signature, so the module for A becomes empty. (Failed in r93 and earlier) * * @throws OWLException */ @Test public void deleteAllAxiomsInModuleTest() { final OWLAxiom[] axioms = { subClassOf(_A, _B), subClassOf(_A, all(_p, _C)) }; final OWLAxiom[] additions = {}; final OWLAxiom[] deletions = { subClassOf(_A, _B) }; updateTest(axioms, additions, deletions); }
@Test public void testNested1() { _pattern.setMaxAllowed(2); final OWLClassExpression union = OWL.or(_cls[1], _cls[2], _cls[3]); final OWLClassExpression all = OWL.all(_pro[0], union); final OWLClassExpression and = OWL.and(all, _cls[4]); final OWLAxiom axiom = OWL.equivalentClasses(and, _cls[0]); assertNotNull(_pattern.match(_ontology, axiom)); }
/** * Test that universal object restriction subclasses are handled correctly */ @Test public void objectUniversalSubCls() { assertNonLocal(subClassOf(all(ObjectProperty("p"), Class("B")), Class("A")), Class("A")); assertNonLocal(subClassOf(all(ObjectProperty("p"), Class("B")), Class("A")), Class("A"), Class("B")); assertNonLocal(subClassOf(all(ObjectProperty("p"), Class("B")), Class("A")), Class("A"), ObjectProperty("p")); } }
/** * Test that universal object restriction subclasses are handled correctly */ @Test public void objectUniversalSubCls() { assertNonLocal(subClassOf(all(ObjectProperty("p"), Class("B")), Class("A")), Class("A")); assertNonLocal(subClassOf(all(ObjectProperty("p"), Class("B")), Class("A")), Class("A"), Class("B")); assertNonLocal(subClassOf(all(ObjectProperty("p"), Class("B")), Class("A")), Class("A"), ObjectProperty("p")); } }
@Test public void testNested2() { _pattern.setMaxAllowed(2); final OWLClassExpression union1 = OWL.or(_cls[1], _cls[2], _cls[3]); final OWLClassExpression all = OWL.all(_pro[0], union1); final OWLClassExpression union2 = OWL.or(all, _cls[4]); final OWLAxiom axiom = OWL.equivalentClasses(union2, _cls[0]); assertNotNull(_pattern.match(_ontology, axiom)); } }
@Before public void setUp() throws OWLOntologyCreationException { _manager = OWLManager.createOWLOntologyManager(); final IRI ontologyURI = IRI.create("tag:clarkparsia.com,2008:pellint:test"); _ontology = _manager.createOntology(ontologyURI); _cls = new OWLClass[5]; for (int i = 0; i < _cls.length; i++) _cls[i] = OWL.Class(ontologyURI + "#C" + i); _pro = new OWLObjectProperty[5]; for (int i = 0; i < _pro.length; i++) _pro[i] = OWL.ObjectProperty(ontologyURI + "#R" + i); _ind = new OWLIndividual[5]; for (int i = 0; i < _ind.length; i++) _ind[i] = OWL.Individual(ontologyURI + "#I" + i); _P0AllC0 = OWL.all(_pro[0], _cls[0]); _P0SomeC1 = OWL.some(_pro[0], _cls[1]); }
@Test public void multipleEquivalentClasses() throws Exception { // test cached explanations final OWLAxiom[] axioms = { OWL.equivalentClasses(_A, _C), OWL.subClassOf(_A, _D), OWL.subClassOf(_D, _E), OWL.subClassOf(_B, _E), OWL.equivalentClasses(_A, _B), // the following axiom is to ensure that we are not in // EL expressivity because we want to test CD optimized // classifier which cached explanations OWL.subClassOf(_A, OWL.all(_p, _A)) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.subClassOf(_C, _D), 0, new OWLAxiom[] { axioms[0], axioms[1] }); testExplanations(OWL.subClassOf(_A, _D), 0, new OWLAxiom[] { axioms[1] }); testExplanations(OWL.subClassOf(_B, _D), 0, new OWLAxiom[] { axioms[1], axioms[4] }); }
@Test public void indirectModuleTest() { final OWLAxiom[] axioms = { subClassOf(_A, and(_B, _C, some(_p, _C))), subClassOf(_B, or(all(_p, not(_C)), _D)), subClassOf(_D, _E) }; final OWLAxiom[] additions = { subClassOf(_A, not(_E)) }; final OWLAxiom[] deletions = {}; updateTest(axioms, additions, deletions); }
@Test public void userDefinedDatatype2() throws Exception { final OWLAxiom[] axioms = { OWL.classAssertion(_a, _A), OWL.subClassOf(_A, OWL.and(OWL.max(dp, 1), OWL.some(dp, OWL.restrict(XSD.INTEGER, OWL.minExclusive(10))))), OWL.equivalentClasses(_B, OWL.and(OWL.min(dp, 1), OWL.all(dp, OWL.restrict(XSD.INTEGER, OWL.minExclusive(5))))) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _B), 0, axioms); }
@Test public void deleteNonLocal() { final OWLAxiom[] axioms = { subClassOf(_A, _B), subClassOf(_C, _D), equivalentClasses(_D, all(_p, _D)) }; createOntology(axioms); final IncrementalClassifier modular = PelletIncremantalReasonerFactory.getInstance().createReasoner(_ontology); modular.classify(); assertTrue(modular.isEntailed(subClassOf(_A, _B))); assertFalse(modular.isEntailed(subClassOf(_B, _C))); assertTrue(modular.isEntailed(subClassOf(_C, _D))); _ontology.remove(Arrays.asList(equivalentClasses(_D, all(_p, _D)))); _ontology.add(Arrays.asList(subClassOf(_B, _C))); modular.classify(); assertTrue(modular.isEntailed(subClassOf(_A, _B))); assertTrue(modular.isEntailed(subClassOf(_B, _C))); assertTrue(modular.isEntailed(subClassOf(_C, _D))); _ontology.remove(Arrays.asList(subClassOf(_A, _B))); modular.classify(); assertFalse(modular.isEntailed(subClassOf(_A, _B))); assertTrue(modular.isEntailed(subClassOf(_B, _C))); assertTrue(modular.isEntailed(subClassOf(_D, _D))); modular.dispose(); }
@Test public void testInvalidTransitivity() { final String ns = "http://www.example.org/test#"; final OWLClass C = Class(ns + "C"); final OWLObjectProperty p1 = ObjectProperty(ns + "p1"); final OWLObjectProperty p2 = ObjectProperty(ns + "p2"); final OWLIndividual x = Individual(ns + "x"); final OWLIndividual y = Individual(ns + "y"); final OWLIndividual z = Individual(ns + "z"); final OWLOntology ont = OWL.Ontology(transitive(p1), classAssertion(x, all(p1, C)), propertyAssertion(x, p1, y), propertyAssertion(y, p1, z)); OpenlletReasoner reasoner = OpenlletReasonerFactory.getInstance().createReasoner(ont); assertTrue(reasoner.isEntailed(classAssertion(y, C))); assertTrue(reasoner.isEntailed(classAssertion(z, C))); final OWLAxiom[] axioms = new OWLAxiom[] { functional(p1), inverseFunctional(p1), irreflexive(p1), asymmetric(p1), disjointProperties(p1, p2), subClassOf(C, min(p1, 2)), classAssertion(x, max(p1, 3)), disjointClasses(C, min(p1, 2)) }; for (final OWLAxiom axiom : axioms) { ont.add(axiom); reasoner = OpenlletReasonerFactory.getInstance().createReasoner(ont); assertTrue(axiom.toString(), reasoner.isEntailed(classAssertion(y, C))); assertFalse(axiom.toString(), reasoner.isEntailed(classAssertion(z, C))); ont.remove(axiom); } }
@Test public void addNonLocal() { final OWLAxiom[] axioms = { subClassOf(_A, _B), subClassOf(_C, _D) }; createOntology(axioms); final IncrementalClassifier modular = PelletIncremantalReasonerFactory.getInstance().createReasoner(_ontology); modular.classify(); assertTrue(modular.isEntailed(subClassOf(_A, _B))); assertFalse(modular.isEntailed(subClassOf(_B, _C))); assertTrue(modular.isEntailed(subClassOf(_C, _D))); _ontology.add(Arrays.asList(equivalentClasses(_D, all(_p, _D)), subClassOf(_B, _C))); modular.classify(); assertTrue(modular.isEntailed(subClassOf(_A, _B))); assertTrue(modular.isEntailed(subClassOf(_B, _C))); assertTrue(modular.isEntailed(subClassOf(_C, _D))); _ontology.remove(Arrays.asList(subClassOf(_A, _B))); modular.classify(); assertFalse(modular.isEntailed(subClassOf(_A, _B))); assertTrue(modular.isEntailed(subClassOf(_B, _C))); assertTrue(modular.isEntailed(subClassOf(_D, _D))); modular.dispose(); }