protected void checkTopDataPropertyUse(OWLDataPropertyExpression dataPropertyExpression,OWLAxiom axiom) { if (dataPropertyExpression.isOWLTopDataProperty()) throw new IllegalArgumentException("Error: In OWL 2 DL, owl:topDataProperty is only allowed to occur in the super property position of SubDataPropertyOf axioms, but the ontology contains an axiom "+axiom+" that violates this condition."); }
protected void checkTopDataPropertyUse(OWLDataPropertyExpression dataPropertyExpression,OWLAxiom axiom) { if (dataPropertyExpression.isOWLTopDataProperty()) throw new IllegalArgumentException("Error: In OWL 2 DL, owl:topDataProperty is only allowed to occur in the super property position of SubDataPropertyOf axioms, but the ontology contains an axiom "+axiom+" that violates this condition."); }
protected void topAsSubProperty(OWLSubDataPropertyOfAxiom axiom) { if (axiom.getSubProperty().isOWLTopDataProperty()) { violations.add(new UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom( getCurrentOntology(), axiom)); } }
protected void topAsSubProperty(OWLSubDataPropertyOfAxiom axiom) { if (axiom.getSubProperty().isOWLTopDataProperty()) { violations.add(new UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom( getCurrentOntology(), axiom)); } }
protected void topAsSubProperty(OWLSubDataPropertyOfAxiom axiom) { if (axiom.getSubProperty().isOWLTopDataProperty()) { violations.add(new UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom( getCurrentOntology(), axiom)); } }
@NonNull @Override public Boolean visit(@NonNull OWLEquivalentDataPropertiesAxiom axiom) { return axiom.getProperties().size() == 1 || (axiom.getProperties().size() == 2 && axiom.getProperties().stream() .anyMatch(p -> p.isOWLTopDataProperty())); }
public Object visit(OWLSubDataPropertyOfAxiom axiom) { if (axiom.getSubProperty().isOWLTopDataProperty()) { profileViolations.add(new UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom(getCurrentOntology(), axiom)); } return null; }
@NonNull @Override public Boolean visit(@NonNull OWLDataPropertyAssertionAxiom axiom) { return axiom.getProperty().isOWLTopDataProperty(); }
@Override public void visit(OWLSubDataPropertyOfAxiom axiom) { OWLDataPropertyExpression subDataProperty=axiom.getSubProperty(); checkTopDataPropertyUse(subDataProperty,axiom); OWLDataPropertyExpression superDataProperty=axiom.getSuperProperty(); if (!subDataProperty.isOWLBottomDataProperty() && !superDataProperty.isOWLTopDataProperty()) addInclusion(subDataProperty,superDataProperty); } @Override
public void visit(OWLSubDataPropertyOfAxiom axiom) { OWLDataPropertyExpression subDataProperty=axiom.getSubProperty(); checkTopDataPropertyUse(subDataProperty,axiom); OWLDataPropertyExpression superDataProperty=axiom.getSuperProperty(); if (!subDataProperty.isOWLBottomDataProperty() && !superDataProperty.isOWLTopDataProperty()) addInclusion(subDataProperty,superDataProperty); } public void visit(OWLEquivalentDataPropertiesAxiom axiom) {
@Override public OWLClassExpression visit(OWLDataAllValuesFrom object) { OWLDataRange filler=object.getFiller(); OWLDataPropertyExpression prop=object.getProperty(); if (prop.isOWLTopDataProperty()) throwInvalidTopDPUseError(object); if (isLiteral(filler)) return m_factory.getOWLDataAllValuesFrom(prop,filler); else { OWLDatatype definition=getDefinitionFor(filler,m_alreadyExists); if (!m_alreadyExists[0]) m_newDataRangeInclusions.add(Arrays.asList(negative(definition),filler)); return m_factory.getOWLDataAllValuesFrom(prop,definition); } } protected void throwInvalidTopDPUseError(OWLClassExpression ex) {
/** * Gets a String representation of an OWL 2 data property. * * @param p An OWL 2 data property. * @return A String representation of p. */ public String getDataPropertyName(OWLDataPropertyExpression p) { if (p.isOWLTopDataProperty()) return getTopDataPropertyName(); else if (p.isOWLBottomDataProperty()) return getBottomDataPropertyName(); else return getAtomicDataPropertyName(p.asOWLDataProperty()); }
public OWLClassExpression visit(OWLDataAllValuesFrom object) { OWLDataRange filler=object.getFiller(); OWLDataPropertyExpression prop=object.getProperty(); if (prop.isOWLTopDataProperty()) throwInvalidTopDPUseError(object); if (isLiteral(filler)) return m_factory.getOWLDataAllValuesFrom(prop,filler); else { OWLDatatype definition=getDefinitionFor(filler,m_alreadyExists); if (!m_alreadyExists[0]) m_newDataRangeInclusions.add(new OWLDataRange[] { negative(definition),filler }); return m_factory.getOWLDataAllValuesFrom(prop,definition); } } protected void throwInvalidTopDPUseError(OWLClassExpression ex) {
@Override public OWLClassExpression visit(OWLDataSomeValuesFrom object) { OWLDataRange filler=object.getFiller(); OWLDataPropertyExpression prop=object.getProperty(); if (prop.isOWLTopDataProperty()) throwInvalidTopDPUseError(object); if (isLiteral(filler)) return m_factory.getOWLDataSomeValuesFrom(object.getProperty(),filler); else { OWLDatatype definition=getDefinitionFor(filler,m_alreadyExists); if (!m_alreadyExists[0]) m_newDataRangeInclusions.add(Arrays.asList(negative(definition),filler)); return m_factory.getOWLDataSomeValuesFrom(object.getProperty(),definition); } } @Override
@Override public OWLClassExpression visit(OWLDataMinCardinality object) { OWLDataRange filler=object.getFiller(); OWLDataPropertyExpression prop=object.getProperty(); if (prop.isOWLTopDataProperty()) throwInvalidTopDPUseError(object); if (isLiteral(filler)) return m_factory.getOWLDataMinCardinality(object.getCardinality(),prop,filler); else { OWLDatatype definition=getDefinitionFor(filler,m_alreadyExists); if (!m_alreadyExists[0]) m_newDataRangeInclusions.add(Arrays.asList(negative(definition),filler)); return m_factory.getOWLDataMinCardinality(object.getCardinality(),prop,definition); } } @Override
public void visit(OWLDataAllValuesFrom object) { LiteralDataRange literalRange=m_dataRangeConverter.convertDataRange(object.getFiller()); if (object.getProperty().isOWLTopDataProperty()) { if (literalRange.isAlwaysFalse()) return; // bottom } Variable y=nextY(); m_bodyAtoms.add(getRoleAtom(object.getProperty(),X,y)); if (literalRange.isNegatedInternalDatatype()) { InternalDatatype negatedRange=(InternalDatatype)literalRange.getNegation(); if (!negatedRange.isAlwaysTrue()) m_bodyAtoms.add(Atom.create(negatedRange,y)); } else { if (!literalRange.isAlwaysFalse()) m_headAtoms.add(Atom.create((DLPredicate)literalRange,y)); } } public void visit(OWLDataHasValue object) {
public OWLClassExpression visit(OWLDataSomeValuesFrom object) { OWLDataRange filler=object.getFiller(); OWLDataPropertyExpression prop=object.getProperty(); if (prop.isOWLTopDataProperty()) throwInvalidTopDPUseError(object); if (isLiteral(filler)) return m_factory.getOWLDataSomeValuesFrom(object.getProperty(),filler); else { OWLDatatype definition=getDefinitionFor(filler,m_alreadyExists); if (!m_alreadyExists[0]) m_newDataRangeInclusions.add(new OWLDataRange[] { negative(definition),filler }); return m_factory.getOWLDataSomeValuesFrom(object.getProperty(),definition); } } public OWLClassExpression visit(OWLDataAllValuesFrom object) {
public OWLClassExpression visit(OWLDataMinCardinality object) { OWLDataRange filler=object.getFiller(); OWLDataPropertyExpression prop=object.getProperty(); if (prop.isOWLTopDataProperty()) throwInvalidTopDPUseError(object); if (isLiteral(filler)) return m_factory.getOWLDataMinCardinality(object.getCardinality(),prop,filler); else { OWLDatatype definition=getDefinitionFor(filler,m_alreadyExists); if (!m_alreadyExists[0]) m_newDataRangeInclusions.add(new OWLDataRange[] { negative(definition),filler }); return m_factory.getOWLDataMinCardinality(object.getCardinality(),prop,definition); } } public OWLClassExpression visit(OWLDataMaxCardinality object) {
@Override public OWLClassExpression visit(OWLDataMaxCardinality object) { OWLDataRange filler=object.getFiller(); OWLDataPropertyExpression prop=object.getProperty(); if (prop.isOWLTopDataProperty()) throwInvalidTopDPUseError(object); if (isLiteral(filler)) return m_factory.getOWLDataMaxCardinality(object.getCardinality(),prop,filler); else { OWLDataRange complementDescription=m_expressionManager.getComplementNNF(filler); OWLDatatype definition=getDefinitionFor(complementDescription,m_alreadyExists); if (!m_alreadyExists[0]) m_newDataRangeInclusions.add(Arrays.asList(negative(definition),filler)); return m_factory.getOWLDataMaxCardinality(object.getCardinality(),prop,m_expressionManager.getComplementNNF(definition)); } } @Override
public OWLClassExpression visit(OWLDataMaxCardinality object) { OWLDataRange filler=object.getFiller(); OWLDataPropertyExpression prop=object.getProperty(); if (prop.isOWLTopDataProperty()) throwInvalidTopDPUseError(object); if (isLiteral(filler)) return m_factory.getOWLDataMaxCardinality(object.getCardinality(),prop,filler); else { OWLDataRange complementDescription=m_expressionManager.getComplementNNF(filler); OWLDatatype definition=getDefinitionFor(complementDescription,m_alreadyExists); if (!m_alreadyExists[0]) m_newDataRangeInclusions.add(new OWLDataRange[] { negative(definition),filler }); return m_factory.getOWLDataMaxCardinality(object.getCardinality(),prop,m_expressionManager.getComplementNNF(definition)); } } public OWLClassExpression visit(OWLDataExactCardinality object) {