/** * Normalizes and adds a reflexive object property axiom * <p> * ReflexiveObjectProperty := 'ReflexiveObjectProperty' '(' axiomAnnotations ObjectPropertyExpression ')' * <p> * Implements rule [O3]:<br> * - ignores if top (which is reflexive by definition)<br> * - inconsistency if bot (which is not reflexive)<br> * - otherwise, removes the inverse if required * * @throws InconsistentOntologyException */ @Override public void addReflexiveObjectPropertyAxiom(ObjectPropertyExpression ope) throws InconsistentOntologyException { if (ope.isTop()) return; if (ope.isBottom()) throw new InconsistentOntologyException(); if (ope.isInverse()) reflexiveObjectPropertyAxioms.add(ope.getInverse()); else reflexiveObjectPropertyAxioms.add(ope); }
/** * Normalizes and adds an irreflexive object property axiom * <p> * ReflexiveObjectProperty := 'ReflexiveObjectProperty' '(' axiomAnnotations ObjectPropertyExpression ')' * <p> * Implements rule [O3]:<br> * - ignores if bot (which is irreflexive by definition)<br> * - inconsistency if top (which is reflexive)<br> * - otherwise, removes the inverse if required * * @throws InconsistentOntologyException */ @Override public void addIrreflexiveObjectPropertyAxiom(ObjectPropertyExpression ope) throws InconsistentOntologyException { if (ope.isTop()) throw new InconsistentOntologyException(); if (ope.isBottom()) return; if (ope.isInverse()) irreflexiveObjectPropertyAxioms.add(ope.getInverse()); else irreflexiveObjectPropertyAxioms.add(ope); }
/** * Creates a class assertion * <p> * ClassAssertion := 'ClassAssertion' '(' axiomAnnotations Class Individual ')' * <p> * Implements rule [C4]: * - ignore (return null) if the class is top * - inconsistency if the class is bot */ @Override public ClassAssertion createClassAssertion(OClass ce, ObjectConstant object) throws InconsistentOntologyException { if (ce.isTop()) return null; if (ce.isBottom()) throw new InconsistentOntologyException(); return new ClassAssertionImpl(ce, object); }
/** * Creates a data property assertion * <p> * DataPropertyAssertion := 'DataPropertyAssertion' '(' axiomAnnotations * DataPropertyExpression sourceIndividual targetValue ')' * <p> * Implements rule [D4]: * - ignore (return null) if the property is top * - inconsistency if the property is bot */ @Override public DataPropertyAssertion createDataPropertyAssertion(DataPropertyExpression dpe, ObjectConstant o1, ValueConstant o2) throws InconsistentOntologyException { if (dpe.isTop()) return null; if (dpe.isBottom()) throw new InconsistentOntologyException(); return new DataPropertyAssertionImpl(dpe, o1, o2); }
/** * implements rules [D1], [O1] and [C1]:<br> * - ignore if e1 is bot or e2 is top<br> * - replace by emptiness if e2 is bot but e1 is not top<br> * - inconsistency if e1 is top and e2 is bot * * @param e1 * @param e2 * @throws InconsistentOntologyException */ void addInclusion(T e1, T e2) throws InconsistentOntologyException { if (e1.isBottom() || e2.isTop()) return; if (e2.isBottom()) { // emptiness if (e1.isTop()) throw new InconsistentOntologyException(); NaryAxiom<T> ax = new NaryAxiomImpl<>(ImmutableList.of(e1, e1)); disjointness.add(ax); } else { BinaryAxiom<T> ax = new BinaryAxiomImpl<>(e1, e2); inclusions.add(ax); } }
/** * Normalizes and adds a data property range axiom * <p> * DataPropertyRange := 'DataPropertyRange' '(' axiomAnnotations DataPropertyExpression DataRange ')' * <p> * Implements rule [D3]: * - ignore if the property is bot or the range is rdfs:Literal (top datatype) * - inconsistency if the property is top but the range is not rdfs:Literal * * @throws InconsistentOntologyException */ @Override public void addDataPropertyRangeAxiom(DataPropertyRangeExpression range, Datatype datatype) throws InconsistentOntologyException { checkSignature(range); checkSignature(datatype); if (datatype.equals(DatatypeImpl.rdfsLiteral)) return; // otherwise the datatype is not top if (range.getProperty().isBottom()) return; if (range.getProperty().isTop()) throw new InconsistentOntologyException(); BinaryAxiom<DataRangeExpression> ax = new BinaryAxiomImpl<>(range, datatype); subDataRangeAxioms.add(ax); }
/** * Creates an object property assertion * <p> * ObjectPropertyAssertion := 'ObjectPropertyAssertion' '(' axiomAnnotations * ObjectPropertyExpression sourceIndividual targetIndividual ')' * <p> * Implements rule [O4]: * - ignore (return null) if the property is top * - inconsistency if the property is bot * - swap the arguments to eliminate inverses */ public ObjectPropertyAssertion createObjectPropertyAssertion(ObjectPropertyExpression ope, ObjectConstant o1, ObjectConstant o2) throws InconsistentOntologyException { if (ope.isTop()) return null; if (ope.isBottom()) throw new InconsistentOntologyException(); if (ope.isInverse()) return new ObjectPropertyAssertionImpl(ope.getInverse(), o2, o1); else return new ObjectPropertyAssertionImpl(ope, o1, o2); }