/** * @param property is the property that support the given range. In fact can be all 'simple' DataProperty you may want. * @param range like [1..3] or more complex if you want. * @param literal to check, 2 is include [1..3], 4 isn't include in [1..3]. * @return true if the literal is in the range. * @since 2.6.1 */ default public boolean isLiteralIncludeInRange(final OWLDataProperty property, final OWLDataRange range, final OWLLiteral literal) { return getReasoner().isSatisfiable(// OWL.and(// You must be of all the following class OWL.some(property, OWL.oneOf(literal)), // The class of the 'literal' OWL.some(property, range), // The class of the range. OWL.max(property, 1))// But you can have the property only once. ); }
/** * @param property is the property that support the given range. In fact can be all 'simple' DataProperty you may want. * @param range like [1..3] or more complex if you want. * @param literal to check, 2 is include [1..3], 4 isn't include in [1..3]. * @return true if the literal is in the range. * @since 2.6.1 */ default public boolean isLiteralIncludeInRange(final OWLDataProperty property, final OWLDataRange range, final OWLLiteral literal) { return getReasoner().isSatisfiable(// OWL.and(// You must be of all the following class OWL.some(property, OWL.oneOf(literal)), // The class of the 'literal' OWL.some(property, range), // The class of the range. OWL.max(property, 1))// But you can have the property only once. ); }
/** * @param property is the property that support the given range. In fact can be all 'simple' DataProperty you may want. * @param range like [1..3] or more complex if you want. * @param literal to check, 2 is include [1..3], 4 isn't include in [1..3]. * @return true if the literal is in the range. * @since 2.6.1 */ default public boolean isLiteralIncludeInRange(final OWLDataProperty property, final OWLDataRange range, final OWLLiteral literal) { return getReasoner().isSatisfiable(// OWL.and(// You must be of all the following class OWL.some(property, OWL.oneOf(literal)), // The class of the 'literal' OWL.some(property, range), // The class of the range. OWL.max(property, 1))// But you can have the property only once. ); }
@Test public void testOneOf() { final OWLClassExpression oneOf = OWL.oneOf(_ind); final OWLAxiom axiom = OWL.equivalentClasses(CollectionUtil.<OWLClassExpression> asSet(_P0AllC0, oneOf)); assertNull(_pattern.match(_ontology, axiom)); }
@Test public void testOneOf() throws OWLException { addAxiom(OWL.subClassOf(_cls[0], _P0AllC0)); final OWLClassExpression oneOf = OWL.oneOf(_ind); addAxiom(OWL.equivalentClasses(CollectionUtil.asSet(_cls[0], _cls[1], oneOf))); final List<Lint> lints = _pattern.match(_ontology); assertEquals(0, lints.size()); }
@Test public void testPunningSingletonOneOf() { final OWLClass A = OWL.Class("A"); final OWLIndividual a = OWL.Individual("A"); final Set<OWLAxiom> axioms = new HashSet<>(); axioms.add(OWL.equivalentClasses(A, OWL.oneOf(a))); final OWLOntology ontology = OWL.Ontology(axioms); final OpenlletReasoner reasoner = OpenlletReasonerFactory.getInstance().createReasoner(ontology); final PelletExplanation explain = new PelletExplanation(reasoner); assertEquals(axioms, explain.getEntailmentExplanation(OWL.classAssertion(a, A))); }
@Test public void testPunningOneOf() { final OWLClass A = OWL.Class("A"); final OWLIndividual a = OWL.Individual("A"); final OWLIndividual b = OWL.Individual("b"); final Set<OWLAxiom> axioms = new HashSet<>(); axioms.add(OWL.equivalentClasses(A, OWL.oneOf(a, b))); final OWLOntology ontology = OWL.Ontology(axioms); final OpenlletReasoner reasoner = OpenlletReasonerFactory.getInstance().createReasoner(ontology); final PelletExplanation explain = new PelletExplanation(reasoner); assertEquals(axioms, explain.getEntailmentExplanation(OWL.classAssertion(a, A))); }
@Test public void datatypeEnumeration() throws Exception { final OWLAxiom[] axioms = { OWL.propertyAssertion(_a, dp, OWL.constant(1)), OWL.propertyAssertion(_a, dp, OWL.constant(2)), OWL.equivalentClasses(_A, OWL.some(dp, _dt)), OWL.datatypeDefinition(_dt, OWL.oneOf(OWL.constant(1), OWL.constant(2), OWL.constant(3))) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _A), 0, new OWLAxiom[] { axioms[0], axioms[2], axioms[3] }, new OWLAxiom[] { axioms[1], axioms[2], axioms[3] }); }
@Test public void testSameAs3() { final String ns = "urn:test:"; final IRI ontIRI = IRI.create(_base + "test.owl"); final OWLNamedIndividual i1 = Individual(ns + "i1"); final OWLNamedIndividual i2 = Individual(ns + "i2"); final OWLNamedIndividual i3 = Individual(ns + "i3"); final OWLClass c = Class(ns + "c"); final Set<OWLAxiom> axioms = new HashSet<>(); axioms.add(equivalentClasses(c, oneOf(i1, i2))); axioms.add(classAssertion(i3, c)); final OWLOntology ont = OWL.Ontology(axioms, ontIRI); final OpenlletReasoner reasoner = OpenlletReasonerFactory.getInstance().createReasoner(ont); assertTrue(!reasoner.isEntailed(sameAs(i1, i2))); assertTrue(!reasoner.isEntailed(sameAs(i1, i3))); assertStreamAsSetEquals(Stream.of(i1), reasoner.getSameIndividuals(i1).entities()); assertTrue(!reasoner.isEntailed(sameAs(i2, i1))); assertTrue(!reasoner.isEntailed(sameAs(i2, i3))); assertStreamAsSetEquals(Stream.of(i2), reasoner.getSameIndividuals(i2).entities()); assertTrue(!reasoner.isEntailed(sameAs(i3, i1))); assertTrue(!reasoner.isEntailed(sameAs(i3, i2))); assertStreamAsSetEquals(Stream.of(i3), reasoner.getSameIndividuals(i3).entities()); }
@Test public void removeTypeFromMergedNode() { createReasoner(OWL.classAssertion(_a, OWL.oneOf(_b, _c)), OWL.classAssertion(_a, _A), OWL.classAssertion(_b, _B), OWL.classAssertion(_c, _C), OWL.classAssertion(_a, _D)); assertTrue(_reasoner.isConsistent()); assertTrue(_reasoner.isEntailed(classAssertion(_a, _A))); assertFalse(_reasoner.isEntailed(classAssertion(_a, _B))); assertFalse(_reasoner.isEntailed(classAssertion(_a, _C))); assertTrue(_reasoner.isEntailed(classAssertion(_a, _D))); final boolean changeApplied = processRemove(OWL.classAssertion(_a, _D)); assertTrue(changeApplied); assertTrue(_reasoner.isEntailed(classAssertion(_a, _A))); assertFalse(_reasoner.isEntailed(classAssertion(_a, _B))); assertFalse(_reasoner.isEntailed(classAssertion(_a, _C))); assertFalse(_reasoner.isEntailed(classAssertion(_a, _D))); }