In the example hasProperty
from owl-api repository:
To test whether the instances of a class must have a property we create a some values from restriction and then ask for the satisfiability of the class interesected with the complement of this some values from restriction. If the intersection is satisfiable then the instances of the class don't have to have the property, otherwise, they do.
So to check if a class is a domain of an object property, I can use the snippet bellow:
OWLDataFactory dataFactory = manager.getOWLDataFactory();
OWLClassExpression restriction = dataFactory.getOWLObjectSomeValuesFrom(objectProperty, dataFactory.getOWLThing());
OWLClassExpression complement = dataFactory.getOWLObjectComplementOf(restriction);
OWLClassExpression intersection = dataFactory.getOWLObjectIntersectionOf(cls, complement);
boolean hasObjectProperty = !reasoner.isSatisfiable(intersection);
I want to know how to check if a class is a range of an object property, and if it is a domain of a data property. Can I use the following snippet (based on the example above) for checking data property domains?
OWLClassExpression restriction = dataFactory.getOWLDataSomeValuesFrom(dataProperty, dataFactory.getOWLThing());
OWLClassExpression complement = dataFactory.getOWLDataComplementOf(restriction);
OWLClassExpression intersection = dataFactory.getOWLDataIntersectionOf(cls, complement);
boolean hasDataProperty = !reasoner.isSatisfiable(intersection);