@Test public void basicTypesUpdateTest() { final OWLAxiom[] axioms = { classAssertion(_a, _A), classAssertion(_b, _B), domain(_p, _C), range(_p, _D), propertyAssertion(_a, _p, _b) }; final OWLAxiom[] additions = { range(_p, _E) }; final OWLAxiom[] deletions = { range(_p, _D) }; typesUpdateTest(axioms, additions, deletions); }
@Test public void basicInstancesUpdateTest() { final OWLAxiom[] axioms = { classAssertion(_a, _A), classAssertion(_b, _B), domain(_p, _C), range(_p, _D), propertyAssertion(_a, _p, _b) }; final OWLAxiom[] additions = { range(_p, _E) }; final OWLAxiom[] deletions = { range(_p, _D) }; instancesUpdateTest(axioms, additions, deletions); }
@Test public void dataRangeEntailment() { createReasoner(OWL.range(_dp, XSD.INT)); assertTrue(_reasoner.isEntailed(OWL.range(_dp, XSD.INT))); assertTrue(_reasoner.isEntailed(OWL.range(_dp, XSD.INTEGER))); assertFalse(_reasoner.isEntailed(OWL.range(_dp, XSD.FLOAT))); assertFalse(_reasoner.isEntailed(OWL.range(_dp, XSD.STRING))); }
@Test public void multipleDatatypeRange() throws Exception { final OWLAxiom[] axioms = { OWL.range(dp, XSD.BYTE), OWL.range(dp, XSD.NON_POSITIVE_INTEGER), OWL.range(dp, XSD.NON_NEGATIVE_INTEGER), OWL.subClassOf(_A, OWL.min(dp, 1)), OWL.classAssertion(_a, _A) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.propertyAssertion(_a, dp, OWL.constant(0)), 0, new OWLAxiom[] { axioms[1], axioms[2], axioms[3], axioms[4] }); }
@Test public void testObjectRangeWithSubClasses() { createReasoner(OWL.domain(_p, _A), OWL.range(_p, _C), OWL.range(_p, _D), OWL.subClassOf(_C, _E)); assertTrue(_reasoner.isEntailed(OWL.range(_p, _C))); assertStreamAsSetEquals(Stream.of(_C, _D), _reasoner.getObjectPropertyRanges(_p, true).entities()); assertStreamAsSetEquals(Stream.of(_C, _D, _E, OWL.Thing), _reasoner.getObjectPropertyRanges(_p, false).entities()); }
@Test public void disjointRange() throws Exception { final OWLAxiom[] axioms = { OWL.subClassOf(_A, OWL.some(_p, _B)), OWL.range(_p, _C), OWL.disjointClasses(_B, _C) }; final OWLAxiom axiom = OWL.equivalentClasses(_A, OWL.Nothing); final OWLAxiom[] explanation = new OWLAxiom[] { OWL.subClassOf(_A, OWL.some(_p, _B)), OWL.range(_p, _C), OWL.disjointClasses(_B, _C) }; setupGenerators(Stream.of(axioms)); testExplanations(axiom, 0, explanation); }
@Test public void basicInstancesTest() { final OWLAxiom[] axioms = { classAssertion(_a, _A), classAssertion(_b, _B), domain(_p, _C), range(_p, _D), propertyAssertion(_a, _p, _b) }; instancesTest(axioms); }
@Test public void basicTypesTest() { final OWLAxiom[] axioms = { classAssertion(_a, _A), classAssertion(_b, _B), domain(_p, _C), range(_p, _D), propertyAssertion(_a, _p, _b) }; typesTest(axioms); }
/** * A _data property range axiom should be removable without causing a full KB reload */ @Test public void removeDataPropertyRangeAxiom() { createReasoner(declaration(_dp), declaration(_C), range(_dp, XSD.INTEGER), propertyAssertion(_a, _dp, constant("foo"))); assertFalse(_reasoner.isConsistent()); final boolean changeApplied = processRemove(range(_dp, XSD.INTEGER)); assertTrue("Unable to remove _data property range axiom", changeApplied); assertTrue(_reasoner.isConsistent()); }
@Test public void expressionInRange() throws Exception { final OWLAxiom[] axioms = { OWL.subClassOf(_A, OWL.some(_p, _B)), OWL.range(_p, OWL.or(_C, _D)), OWL.disjointClasses(_B, _C), OWL.disjointClasses(_B, _D) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.subClassOf(_A, OWL.Nothing), 0, axioms); }
@Test public void testObjectRangeWithEquivalents() { createReasoner(OWL.equivalentClasses(_C, some(inverse(_p), OWL.Thing)), OWL.range(_p, _D), OWL.subClassOf(_C, _E)); _reasoner.getKB().printClassTree(); assertTrue(_reasoner.isEntailed(OWL.range(_p, _C))); assertStreamAsSetEquals(Stream.of(_C), _reasoner.getEquivalentClasses(some(inverse(_p), OWL.Thing)).entities()); assertStreamAsSetEquals(Stream.of(_C), _reasoner.getObjectPropertyRanges(_p, true).entities()); assertStreamAsSetEquals(Stream.of(_C, _D, _E, OWL.Thing), _reasoner.getObjectPropertyRanges(_p, false).entities()); }
@Test public void disjointRangeSuper() throws Exception { final OWLAxiom[] axioms = { OWL.subClassOf(_A, OWL.some(_p, _B)), OWL.range(_p, _C), OWL.subClassOf(_B, _D), OWL.disjointClasses(_D, _C), OWL.subClassOf(_A, _E), OWL.subClassOf(_B, _F) }; setupGenerators(Stream.of(axioms)); // explain disjointness of _B and _C first so reasoner will _cache this // result testExplanations(OWL.disjointClasses(_B, _C), 0, new OWLAxiom[] { axioms[2], axioms[3] }); // explain the unsatisfiability of _A and make sure cached results do not // interfere with clashExplanation testExplanations(OWL.equivalentClasses(_A, OWL.Nothing), 0, new OWLAxiom[] { axioms[0], axioms[1], axioms[2], axioms[3] }); }
/** * An object property range axiom should be removable without causing a full KB reload */ @Test public void removeObjectPropertyRangeAxiom() { createReasoner(declaration(_p), declaration(_C), range(_p, _C), propertyAssertion(_a, _p, _b)); assertTrue(_reasoner.isConsistent()); assertTrue(_reasoner.isEntailed(classAssertion(_b, _C))); final boolean changeApplied = processRemove(range(_p, _C)); assertTrue("Unable to remove object property range axiom", changeApplied); assertTrue(_reasoner.isConsistent()); assertFalse(_reasoner.isEntailed(classAssertion(_b, _C))); }
/** * An object property range axiom should be removable without causing a full KB reload even if it is a class expression */ @Test public void removeObjectPropertyRangeAxiomExpression() { createReasoner(declaration(_p), declaration(_C), declaration(_D), range(_p, or(_C, _D)), propertyAssertion(_a, _p, _b)); assertTrue(_reasoner.isConsistent()); assertTrue(_reasoner.isEntailed(classAssertion(_b, or(_C, _D)))); final boolean changeApplied = processRemove(range(_p, or(_C, _D))); assertTrue("Unable to remove object property range axiom", changeApplied); assertTrue(_reasoner.isConsistent()); assertFalse(_reasoner.isEntailed(classAssertion(_b, or(_C, _D)))); }
@Test /** * Tests for the bug reported in #150 */ public void test150_2() { createReasoner(OWL.domain(_p, _C), OWL.range(_q, _D), OWL.disjointClasses(_C, _D)); assertTrue(_reasoner.isEntailed(OWL.disjointProperties(_p, OWL.inverse(_q)))); assertTrue(_reasoner.isEntailed(OWL.disjointProperties(OWL.inverse(_p), _q))); }
@Test /** * Test for the enhancement required in #252 */ public void testBooleanDatatypeConstructors() { final OWLDatatype nni = XSD.NON_NEGATIVE_INTEGER; final OWLDatatype npi = XSD.NON_POSITIVE_INTEGER; final OWLDatatype ni = XSD.NEGATIVE_INTEGER; final OWLDatatype pi = XSD.POSITIVE_INTEGER; final OWLDatatype f = XSD.FLOAT; final OWLDatatype i = XSD.INTEGER; createReasoner(OWL.declaration(nni), OWL.declaration(npi), OWL.declaration(ni), OWL.declaration(pi), OWL.declaration(f), OWL.declaration(_dq), OWL.range(_dp, OWL.dataAnd(pi, ni))); assertTrue(_reasoner.isSatisfiable(OWL.some(_dq, pi))); assertTrue(_reasoner.isSatisfiable(OWL.some(_dq, OWL.dataNot(pi)))); assertFalse(_reasoner.isSatisfiable(OWL.some(_dq, OWL.dataAnd(pi, ni)))); assertFalse(_reasoner.isSatisfiable(OWL.some(_dq, OWL.dataAnd(f, OWL.dataOr(pi, ni))))); assertTrue(_reasoner.isSatisfiable(OWL.some(_dq, OWL.dataAnd(npi, ni)))); assertTrue(_reasoner.isSatisfiable(OWL.some(_dq, OWL.dataAnd(nni, pi)))); assertTrue(_reasoner.isSatisfiable(OWL.some(_dq, OWL.dataOr(nni, npi)))); assertTrue(_reasoner.isSatisfiable(OWL.some(_dq, OWL.dataAnd(nni, npi)))); assertFalse(_reasoner.isSatisfiable(OWL.some(_dq, OWL.dataAnd(pi, OWL.restrict(i, OWL.maxExclusive(0)))))); assertFalse(_reasoner.isSatisfiable(OWL.some(_dp, XSD.ANY_TYPE))); }