@Test public void maxExclusive() { assertRendering("double[< \"2.0\"^^double]", OWL.restrict(XSD.DOUBLE, OWL.maxExclusive(2.0))); }
@Test public void maxInclusive() { assertRendering("double[<= \"2.0\"^^double]", OWL.restrict(XSD.DOUBLE, OWL.maxInclusive(2.0))); }
@Test public void minInclusive() { assertRendering("double[>= \"2.0\"^^double]", OWL.restrict(XSD.DOUBLE, OWL.minInclusive(2.0))); } }
@Test public void minExclusive() { assertRendering("double[> \"2.0\"^^double]", OWL.restrict(XSD.DOUBLE, OWL.minExclusive(2.0))); }
@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 userDefinedDatatype1() throws Exception { final OWLAxiom[] axioms = { OWL.classAssertion(_a, _A), OWL.propertyAssertion(_a, dp, OWL.constant(9)), OWL.equivalentClasses(_B, OWL.and(_A, OWL.some(dp, OWL.restrict(XSD.INTEGER, OWL.maxExclusive(10))))) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _B), 0, axioms); }
@Test public void userDefinedDatatype3() throws Exception { final OWLAxiom[] axioms = { OWL.classAssertion(_a, _A), OWL.propertyAssertion(_a, dp, OWL.constant(9)), OWL.equivalentClasses(_B, OWL.and(_A, OWL.some(dp, _dt))), OWL.datatypeDefinition(_dt, OWL.restrict(XSD.INTEGER, OWL.maxExclusive(10))) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _B), 0, axioms); }
OWL.restrict(XSD.INTEGER, // OWL.facetRestriction(OWLFacet.MIN_INCLUSIVE, OWL.constant(100)), // OWL.facetRestriction(OWLFacet.MAX_INCLUSIVE, OWL.constant(250))// OWL.restrict(XSD.INTEGER, // OWL.facetRestriction(OWLFacet.MIN_INCLUSIVE, OWL.constant(250)), // OWL.facetRestriction(OWLFacet.MAX_INCLUSIVE, OWL.constant(252))//
OWL.restrict(XSD.INTEGER, // OWL.facetRestriction(OWLFacet.MIN_INCLUSIVE, OWL.constant(100)), // OWL.facetRestriction(OWLFacet.MAX_INCLUSIVE, OWL.constant(250))// OWL.restrict(XSD.INTEGER, // OWL.facetRestriction(OWLFacet.MIN_INCLUSIVE, OWL.constant(250)), // OWL.facetRestriction(OWLFacet.MAX_INCLUSIVE, OWL.constant(252))//
@Test public void testRegexRestriction() throws OWLOntologyCreationException { try (final OWLManagerGroup group = new OWLManagerGroup()) { final OWLOntologyID ontId = OWLHelper.getVersion(IRI.create(NS + "owlapi.inc.regex.restriction"), 1.0); final OWLHelper owl = new OWLGenericTools(group, ontId, true); final OWLNamedIndividual x1 = i.apply("I1"); final OWLNamedIndividual x2 = i.apply("I2"); owl.addAxiom(OWL.equivalentClasses(ClsA, OWL.some(propB, OWL.restrict(XSD.STRING, OWL.facetRestriction(OWLFacet.PATTERN, OWL.constant("A.A")))))); owl.addAxiom(OWL.propertyAssertion(x1, propB, OWL.constant("AAA"))); owl.addAxiom(OWL.propertyAssertion(x2, propB, OWL.constant("BBB"))); owl.addAxiom(OWL.differentFrom(x1, x2)); final OWLReasoner r = owl.getReasoner(); assertTrue(r.isEntailed(OWL.classAssertion(x1, ClsA))); assertFalse(r.isEntailed(OWL.classAssertion(x2, ClsA))); } }
@Test public void testRegexRestriction() throws OWLOntologyCreationException { try (final OWLManagerGroup group = new OWLManagerGroup()) { final OWLOntologyID ontId = OWLHelper.getVersion(IRI.create(NS + "owlapi.inc.regex.restriction"), 1.0); final OWLHelper owl = new OWLGenericTools(group, ontId, true); final OWLNamedIndividual x1 = i.apply("I1"); final OWLNamedIndividual x2 = i.apply("I2"); owl.addAxiom(OWL.equivalentClasses(ClsA, OWL.some(propB, OWL.restrict(XSD.STRING, OWL.facetRestriction(OWLFacet.PATTERN, OWL.constant("A.A")))))); owl.addAxiom(OWL.propertyAssertion(x1, propB, OWL.constant("AAA"))); owl.addAxiom(OWL.propertyAssertion(x2, propB, OWL.constant("BBB"))); owl.addAxiom(OWL.differentFrom(x1, x2)); final OWLReasoner r = owl.getReasoner(); assertTrue(r.isEntailed(OWL.classAssertion(x1, ClsA))); assertFalse(r.isEntailed(OWL.classAssertion(x2, ClsA))); } }
@Test public void datatypeDefinition() { final OWLDatatype between5and10 = OWL.Datatype("between5and10"); final OWLDatatype between6and8 = OWL.Datatype("between6and8"); createReasoner(OWL.datatypeDefinition(between5and10, OWL.restrict(XSD.INTEGER, OWL.minInclusive(5), OWL.maxInclusive(10))), OWL.datatypeDefinition(between6and8, OWL.restrict(XSD.INTEGER, OWL.minInclusive(6), OWL.maxInclusive(8))), OWL.equivalentClasses(_A, OWL.some(_dp, between5and10)), OWL.equivalentClasses(_B, OWL.some(_dp, between6and8)), OWL.propertyAssertion(_a, _dp, OWL.constant(9)), OWL.propertyAssertion(_b, _dp, OWL.constant(7))); assertTrue(_reasoner.isEntailed(OWL.subClassOf(_B, _A))); assertTrue(_reasoner.isEntailed(OWL.classAssertion(_a, _A))); assertFalse(_reasoner.isEntailed(OWL.classAssertion(_a, _B))); assertTrue(_reasoner.isEntailed(OWL.classAssertion(_b, _A))); assertTrue(_reasoner.isEntailed(OWL.classAssertion(_b, _B))); }
@Test public void testMaxLengthRestriction() throws OWLOntologyCreationException { try (final OWLManagerGroup group = new OWLManagerGroup()) { final OWLOntologyID ontId = OWLHelper.getVersion(IRI.create(NS + "owlapi.inc.maxLength.restriction"), 1.0); final OWLHelper owl = new OWLGenericTools(group, ontId, true); final OWLNamedIndividual x0 = i.apply("I0"); final OWLNamedIndividual x1 = i.apply("I1"); final OWLNamedIndividual x2 = i.apply("I2"); owl.addAxiom(OWL.equivalentClasses(ClsA, OWL.some(propB, OWL.restrict(XSD.STRING, OWL.facetRestriction(OWLFacet.MAX_LENGTH, OWL.constant(3L)))))); owl.addAxiom(OWL.propertyAssertion(x0, propB, OWL.constant(""))); owl.addAxiom(OWL.propertyAssertion(x1, propB, OWL.constant("AA"))); owl.addAxiom(OWL.propertyAssertion(x2, propB, OWL.constant("AAAAA"))); owl.addAxiom(OWL.differentFrom(SetUtils.create(x0, x1, x2))); final OWLReasoner r = owl.getReasoner(); assertTrue(r.isEntailed(OWL.classAssertion(x0, ClsA))); assertTrue(r.isEntailed(OWL.classAssertion(x1, ClsA))); assertFalse(r.isEntailed(OWL.classAssertion(x2, ClsA))); } }
@Test public void testMaxLengthRestriction() throws OWLOntologyCreationException { try (final OWLManagerGroup group = new OWLManagerGroup()) { final OWLOntologyID ontId = OWLHelper.getVersion(IRI.create(NS + "owlapi.inc.maxLength.restriction"), 1.0); final OWLHelper owl = new OWLGenericTools(group, ontId, true); final OWLNamedIndividual x0 = i.apply("I0"); final OWLNamedIndividual x1 = i.apply("I1"); final OWLNamedIndividual x2 = i.apply("I2"); owl.addAxiom(OWL.equivalentClasses(ClsA, OWL.some(propB, OWL.restrict(XSD.STRING, OWL.facetRestriction(OWLFacet.MAX_LENGTH, OWL.constant(3L)))))); owl.addAxiom(OWL.propertyAssertion(x0, propB, OWL.constant(""))); owl.addAxiom(OWL.propertyAssertion(x1, propB, OWL.constant("AA"))); owl.addAxiom(OWL.propertyAssertion(x2, propB, OWL.constant("AAAAA"))); owl.addAxiom(OWL.differentFrom(SetUtils.create(x0, x1, x2))); final OWLReasoner r = owl.getReasoner(); assertTrue(r.isEntailed(OWL.classAssertion(x0, ClsA))); assertTrue(r.isEntailed(OWL.classAssertion(x1, ClsA))); assertFalse(r.isEntailed(OWL.classAssertion(x2, ClsA))); } }
@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))); }