org.semanticweb.owlapi.model.OWLSubPropertyAxiom Java Examples
The following examples show how to use
org.semanticweb.owlapi.model.OWLSubPropertyAxiom.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleOntology.java From mobi with GNU Affero General Public License v3.0 | 5 votes |
private Stream<IRI> getSubDatatypePropertiesFor(OWLDataProperty property, boolean direct) { if (direct) { return owlOntology.axioms(AxiomType.SUB_DATA_PROPERTY, Imports.INCLUDED) .filter(axiom -> axiom.getSuperProperty().equals(property)) .map(OWLSubPropertyAxiom::getSubProperty) .filter(subproperty -> !subproperty.isBottomEntity() && subproperty.isOWLDataProperty() && !subproperty.asOWLDataProperty().getIRI().equals(property.getIRI())) .map(subproperty -> SimpleOntologyValues.mobiIRI(subproperty.asOWLDataProperty().getIRI())); } else { return owlReasoner.getSubDataProperties(property, false).entities() .filter(subproperty -> !subproperty.isBottomEntity() && !subproperty.getIRI().equals(property.getIRI())) .map(subproperty -> SimpleOntologyValues.mobiIRI(subproperty.getIRI())); } }
Example #2
Source File: SimpleOntology.java From mobi with GNU Affero General Public License v3.0 | 5 votes |
private Stream<IRI> getSubObjectPropertiesFor(OWLObjectProperty property, boolean direct) { if (direct) { return owlOntology.axioms(AxiomType.SUB_OBJECT_PROPERTY, Imports.INCLUDED) .filter(axiom -> axiom.getSuperProperty().equals(property)) .map(OWLSubPropertyAxiom::getSubProperty) .filter(subproperty -> !subproperty.isBottomEntity() && subproperty.isOWLObjectProperty() && !subproperty.getNamedProperty().getIRI().equals(property.getIRI())) .map(subproperty -> SimpleOntologyValues.mobiIRI(subproperty.getNamedProperty().getIRI())); } else { return owlReasoner.getSubObjectProperties(property, false).entities() .filter(subproperty -> !subproperty.isBottomEntity() && !subproperty.getNamedProperty().getIRI().equals(property.getIRI())) .map(subproperty -> SimpleOntologyValues.mobiIRI(subproperty.getNamedProperty().getIRI())); } }
Example #3
Source File: OwlHelper.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static Set<OWLObjectPropertyExpression> getSuperProperties(OWLObjectPropertyExpression prop, OWLOntology ont) { Set<OWLObjectPropertyExpression> result = new HashSet<>(); Set<OWLSubObjectPropertyOfAxiom> axioms = ont.getObjectSubPropertyAxiomsForSubProperty(prop); for (OWLSubPropertyAxiom<OWLObjectPropertyExpression> axiom : axioms) { result.add(axiom.getSuperProperty()); } return result; }
Example #4
Source File: OWLQLCompiler.java From quetzal with Eclipse Public License 2.0 | 5 votes |
protected Triple basicRewrite(Triple t, OWLSubPropertyAxiom ax, String key, NewVariableGenerator varGen) { assert key.equals(tbox.getKey(ax.getSuperProperty())) : key +"\n"+ ax; assert key.equals(getKey(t)) : key+"\n"+t; Node subj = t.getSubject(); Node obj = t.getObject(); Node pred = t.getPredicate(); assert pred.isURI() : t; assert subj.isVariable() || obj.isVariable() : t; OWLPropertyExpression sub = getSimplified(ax.getSubProperty()); OWLPropertyExpression sup = getSimplified(ax.getSuperProperty()); if (!pred.getURI().equals(RDFConstants.RDF_TYPE)) { OWLProperty subp; if (sub.isAnonymous()) { OWLObjectInverseOf inv =(OWLObjectInverseOf) sub; subp = (OWLProperty) inv.getInverse(); } else { subp = (OWLProperty) sub; } // same polarity? if ((sub.isAnonymous() && sup.isAnonymous()) || (!sub.isAnonymous() && !sup.isAnonymous())) { return toTriple(subp, subj, obj, varGen); } else { return toTriple(subp, obj, subj, varGen); } } return null; }
Example #5
Source File: NormalizedOWLQLTbox.java From quetzal with Eclipse Public License 2.0 | 5 votes |
private static void organizeNegativeClosure(Collection<OWLAxiom> normalizedNegClosureAxioms, Collection<OWLSubClassOfAxiom> negIncAxInNegClos, Collection<OWLDisjointObjectPropertiesAxiom> negObjectSubPropAxInNegClos, Collection<OWLDisjointDataPropertiesAxiom> negDataSubPropAxInNegClos) { organizeTboxAxioms(normalizedNegClosureAxioms, negIncAxInNegClos, negObjectSubPropAxInNegClos, negDataSubPropAxInNegClos, new HashSet<OWLSubClassOfAxiom>(), new HashSet<OWLSubPropertyAxiom>(), new HashSet<OWLObjectProperty>(), new HashSet<OWLObjectProperty>(), new HashMap<String, Set<OWLSubClassOfAxiom>>(), new HashMap<String, Set<OWLSubPropertyAxiom>>()); }
Example #6
Source File: NormalizedOWLQLTbox.java From quetzal with Eclipse Public License 2.0 | 4 votes |
protected Set<OWLAxiom> computeNegativeInclusionClosure(Set<OWLSubClassOfAxiom> deltaNegIncAx, Set<OWLDisjointObjectPropertiesAxiom> deltaNegObjSubPropAx,Set<OWLDisjointDataPropertiesAxiom> deltaNegDataSubPropAx, Set<OWLSubClassOfAxiom> deltaPosIncAx, Set<OWLSubPropertyAxiom> deltaPosSubPropAx) { return computeNegativeInclusionClosure(deltaNegIncAx, deltaNegObjSubPropAx, deltaNegDataSubPropAx, deltaPosIncAx, deltaPosSubPropAx, null); }
Example #7
Source File: NormalizedOWLQLTbox.java From quetzal with Eclipse Public License 2.0 | 4 votes |
private static void organizeTboxAxioms(Collection<OWLAxiom> normalizedAxioms, Collection<OWLSubClassOfAxiom> negIncAxInTbox, Collection<OWLDisjointObjectPropertiesAxiom> negObjectSubPropAxInTbox,Collection<OWLDisjointDataPropertiesAxiom> negDataSubPropAxInTbox, Collection<OWLSubClassOfAxiom> posIncAxInTbox, Collection<OWLSubPropertyAxiom> posSubPropAxInTbox, Collection<OWLObjectProperty> reflexivePropsInTbox, Collection<OWLObjectProperty> irreflexivePropsInTbox, Map<String, Set<OWLSubClassOfAxiom>> iri2PosIncAxInTbox, Map<String, Set<OWLSubPropertyAxiom>> iri2PosSubPropAxInTbox) { // organize Tbox axioms per type for (OWLAxiom ax: normalizedAxioms ) { if (ax.getAxiomType().equals(AxiomType.SUBCLASS_OF)) { OWLSubClassOfAxiom subax = (OWLSubClassOfAxiom) ax; OWLClassExpression sub = subax.getSubClass(); OWLClassExpression superclass = subax.getSuperClass(); if (!superclass.isAnonymous() || superclass.getClassExpressionType().equals(ClassExpressionType.OBJECT_SOME_VALUES_FROM) || superclass.getClassExpressionType().equals(ClassExpressionType.DATA_SOME_VALUES_FROM)) { posIncAxInTbox.add(subax); String key = getKey(superclass); Set<OWLSubClassOfAxiom> axs = iri2PosIncAxInTbox.get(key); if (axs==null) { axs = new HashSet<OWLSubClassOfAxiom>(); iri2PosIncAxInTbox.put(key, axs); } axs.add(subax); } else { assert superclass.getClassExpressionType().equals(ClassExpressionType.OBJECT_ALL_VALUES_FROM) || superclass.getClassExpressionType().equals(ClassExpressionType.DATA_ALL_VALUES_FROM) || superclass.getClassExpressionType().equals(ClassExpressionType.OBJECT_COMPLEMENT_OF) : ax; negIncAxInTbox.add(subax); } } else if (ax.getAxiomType().equals(AxiomType.SUB_DATA_PROPERTY) || ax.getAxiomType().equals(AxiomType.SUB_OBJECT_PROPERTY)) { OWLSubPropertyAxiom subax = (OWLSubPropertyAxiom) ax; OWLPropertyExpression superprop = subax.getSuperProperty(); posSubPropAxInTbox.add(subax); String key = getKey(superprop); Set<OWLSubPropertyAxiom> axs = iri2PosSubPropAxInTbox.get(key); if (axs==null) { axs = new HashSet<OWLSubPropertyAxiom>(); iri2PosSubPropAxInTbox.put(key, axs); } axs.add(subax); } else if (ax.getAxiomType().equals(AxiomType.DISJOINT_OBJECT_PROPERTIES)) { OWLDisjointObjectPropertiesAxiom dax = (OWLDisjointObjectPropertiesAxiom) ax; negObjectSubPropAxInTbox.add(dax); } else if (ax.getAxiomType().equals(AxiomType.DISJOINT_DATA_PROPERTIES)) { OWLDisjointDataPropertiesAxiom dax = (OWLDisjointDataPropertiesAxiom) ax; negDataSubPropAxInTbox.add(dax); } else if (ax.getAxiomType().equals(AxiomType.REFLEXIVE_OBJECT_PROPERTY)) { OWLReflexiveObjectPropertyAxiom rax = (OWLReflexiveObjectPropertyAxiom) ax; reflexivePropsInTbox.add(rax.getProperty().getNamedProperty()); } else if (ax.getAxiomType().equals(AxiomType.IRREFLEXIVE_OBJECT_PROPERTY)) { OWLIrreflexiveObjectPropertyAxiom irrax = (OWLIrreflexiveObjectPropertyAxiom) ax; irreflexivePropsInTbox.add(irrax.getProperty().getNamedProperty()); } else if (isAboxAxiom(ax)) { // abox assertions } else { assert false : "Unknown Normalized Axiom Type: " + ax; } } }
Example #8
Source File: NormalizedOWLQLTbox.java From quetzal with Eclipse Public License 2.0 | 4 votes |
public Set<OWLSubPropertyAxiom> getPositivePropertyInclusions(String key) { return iri2PosSubPropAxInTbox.get(key); }
Example #9
Source File: NormalizedOWLQLTbox.java From quetzal with Eclipse Public License 2.0 | 4 votes |
public boolean isSubClass(OWLClassExpression sub, OWLClassExpression sup) { // if sup is equivalent to Top return true if (sup.isOWLThing()) { return true; } if (sup.getClassExpressionType().equals(ClassExpressionType.OBJECT_COMPLEMENT_OF) && ( ((OWLObjectComplementOf) sup).getOperand().isOWLNothing() || getUnsatisfiableNamedClasses().contains(((OWLObjectComplementOf) sup).getOperand()) ) ) { return true; } // // if sub is equivalent to Bottom return true if (sub.isOWLNothing() || getUnsatisfiableNamedClasses().contains(sub)) { return true; } if (sub.getClassExpressionType().equals(ClassExpressionType.OBJECT_COMPLEMENT_OF) && ((OWLObjectComplementOf) sub).getOperand().isOWLThing()) { return true; } if ( (sub.getClassExpressionType().equals(ClassExpressionType.OBJECT_SOME_VALUES_FROM) || sub.getClassExpressionType().equals(ClassExpressionType.DATA_SOME_VALUES_FROM)) && (((OWLQuantifiedRestriction) sub).getProperty().isOWLBottomObjectProperty() ||((OWLQuantifiedRestriction) sub).getProperty().isOWLBottomDataProperty() || getUnsatisfiableProperties().contains(((OWLQuantifiedRestriction) sub).getProperty()))) { return true; } // // check that tbox union {subclass(NC, sub), sublcass(NC, not(sup)), NC(Nind)} // is inconsistent. NC: new concept, Nind: new individual List<OWLAxiom> newAxioms = new LinkedList<OWLAxiom>(); NormalizedOWLQLTbox ret = this;//copy(); OWLClass newConcept = ret.getNormalizer().createNewNamedClass(); newAxioms.add(fac.getOWLSubClassOfAxiom(newConcept, sub.getNNF())); newAxioms.add(fac.getOWLSubClassOfAxiom(newConcept, sup.getComplementNNF())); List<OWLAxiom> newNonOWLQLAxioms = new LinkedList<OWLAxiom>(); Set<OWLAxiom> normalizedAxioms = ret.getNormalizer().toQLNormalForm(newAxioms, newNonOWLQLAxioms); if (!newNonOWLQLAxioms.isEmpty()) { throw new RuntimeException("Both concepts must be OWL QL valid concepts"); } List<OWLSubClassOfAxiom> deltaNegIncAx = new LinkedList<OWLSubClassOfAxiom>(); List<OWLDisjointObjectPropertiesAxiom> deltaNegObjSubPropAx = new LinkedList<OWLDisjointObjectPropertiesAxiom>(); List<OWLDisjointDataPropertiesAxiom> deltaNegDataSubPropAx = new LinkedList<OWLDisjointDataPropertiesAxiom>(); List<OWLSubClassOfAxiom> deltaPosIncAx = new LinkedList<OWLSubClassOfAxiom>(); List<OWLSubPropertyAxiom> deltaPosSubPropAx = new LinkedList<OWLSubPropertyAxiom>(); organizeTboxAxioms(normalizedAxioms, deltaNegIncAx, deltaNegObjSubPropAx, deltaNegDataSubPropAx,deltaPosIncAx, deltaPosSubPropAx, new HashSet<OWLObjectProperty>(), new HashSet<OWLObjectProperty>(), new HashMap<String, Set<OWLSubClassOfAxiom>>(), new HashMap<String, Set<OWLSubPropertyAxiom>>()); // inconsistent iff subclass(NC, not(NC)) is in the negative closure OWLAxiom inconsistencyWitness = fac.getOWLSubClassOfAxiom(newConcept, newConcept.getComplementNNF()); Set<OWLAxiom> newNegClos = ret.computeNegativeInclusionClosure(deltaNegIncAx, deltaNegObjSubPropAx, deltaNegDataSubPropAx, deltaPosIncAx, deltaPosSubPropAx, inconsistencyWitness); //assert newNegClos == null || !newNegClos.contains(inconsistencyWitness) : newNegClos; // return newNegClos == null; }