@Test public void differentFromAndFunctionality() throws Exception { assumeTrue(!_classify); final OWLAxiom[] axioms = { OWL.functional(_p), OWL.propertyAssertion(_a, _p, _b), OWL.propertyAssertion(_a, _p, _c), OWL.propertyAssertion(_a, _p, _d), OWL.differentFrom(_b, _c), OWL.differentFrom(_c, _d) }; setupGenerators(Stream.of(axioms)); testInconsistencyExplanations(0, new OWLAxiom[] { axioms[0], axioms[1], axioms[2], axioms[4] }, new OWLAxiom[] { axioms[0], axioms[2], axioms[3], axioms[5] }); } }
@Test public void testNone() throws OWLException { addAxiom(OWL.differentFrom(_ind[0], _ind[1])); addAxiom(OWL.differentFrom(_ind[2], _ind[3])); _pattern.setMaxAllowed(3); final List<Lint> lints = _pattern.match(_ontology); assertEquals(0, lints.size()); assertFalse(_pattern.isFixable()); }
private static OpenlletReasoner setupReasonerIndividualNodeSetPolicy(final IndividualNodeSetPolicy p) { final OWLAxiom[] axioms = { OWL.classAssertion(_a, _C), OWL.classAssertion(_b, _C), OWL.classAssertion(_c, _C), OWL.sameAs(_a, _b), OWL.differentFrom(_b, _c), OWL.differentFrom(_a, _c) }; final OWLOntology ont = OWL.Ontology(axioms); final OWLReasonerConfiguration config = new SimpleConfiguration(new NullReasonerProgressMonitor(), FreshEntityPolicy.ALLOW, Long.MAX_VALUE, p); final OpenlletReasoner pellet = OpenlletReasonerFactory.getInstance().createReasoner(ont, config); return pellet; }
@Override @Before public void setUp() throws OWLOntologyCreationException { super.setUp(); _axioms = new OWLAxiom[] { OWL.subClassOf(_cls[0], OWL.or(_cls[1], _cls[2], _cls[3])), OWL.equivalentClasses(_cls[0], _cls[1]), OWL.differentFrom(_ind[2], _ind[3]) }; }
@Test public void testOne() throws OWLException { addAxiom(OWL.differentFrom(CollectionUtil.asSet(_ind[0], _ind[1], _ind[2]))); _pattern.setMaxAllowed(3); List<Lint> lints = _pattern.match(_ontology); assertEquals(0, lints.size()); addAxiom(OWL.differentFrom(_ind[3], _ind[4])); lints = _pattern.match(_ontology); assertEquals(1, lints.size()); final Lint lint = lints.get(0); assertNull(lint.getLintFixer()); assertEquals(6 + 2, lint.getSeverity().doubleValue(), DOUBLE_DELTA); assertSame(_ontology, lint.getParticipatingOntology()); } }
@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 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))); } }
owl.addAxiom(OWL.propertyAssertion(x4, propB, OWL.constant("AAAAAAAAA"))); owl.addAxiom(OWL.differentFrom(SetUtils.create(x0, x1, x2, x3, x4)));
owl.addAxiom(OWL.propertyAssertion(x4, propB, OWL.constant("AAAAAAAAA"))); owl.addAxiom(OWL.differentFrom(SetUtils.create(x0, x1, x2, x3, x4)));
assertTrue(reasoner.isEntailed(differentFrom(ind1, ind3))); assertTrue(reasoner.isEntailed(differentFrom(ind1, ind4))); assertTrue(reasoner.isEntailed(differentFrom(ind5, ind6))); assertTrue(reasoner.isEntailed(propertyAssertion(ind1, p, ind1))); assertTrue(reasoner.isEntailed(classAssertion(ind1, test2)));
assertTrue(reasoner.isEntailed(propertyAssertion(grandfather, hasChild, father))); assertTrue(reasoner.isEntailed(propertyAssertion(grandfather, hasSon, father))); assertTrue(reasoner.isEntailed(differentFrom(grandfather, grandmother))); assertTrue(reasoner.isEntailed(differentFrom(grandfather, father))); assertTrue(reasoner.isEntailed(differentFrom(grandfather, mother))); assertTrue(reasoner.isEntailed(differentFrom(grandfather, son))); assertTrue(reasoner.isEntailed(differentFrom(grandfather, daughter))); assertFalse(reasoner.isEntailed(propertyAssertion(daughter, hasBrother, son))); assertTrue(reasoner.isEntailed(differentFrom(personX, personY))); assertTrue(reasoner.isEntailed(differentFrom(personX, personZ))); assertTrue(reasoner.isEntailed(differentFrom(personY, personZ)));