I have an OWL2 QL ontology like the following one:
Prefix(:=<http://example.org/my-ontology#>)
Ontology(<http://example.org/my-ontology>
Declaration(Class(:Student))
Declaration(Class(:BachelorStudent))
Declaration(Class(:Teacher))
Declaration(ObjectProperty(:EnrolledIn))
SubClassOf(:BachelorStudent :Student)
SubClassOf(ObjectSomeValuesFrom(:EnrolledIn owl:Thing) :Student)
)
My goal is to rewrite a Conjunctive Query (CQ) with respect to the above intensional rules. I can express a CQ in SPARQL as follows:
PREFIX : <http://example.org/my-ontology#>
SELECT ?x WHERE {
?x a :Student ;
a :Teacher .
}
The expected output is a Union of Conjunctive Queries (UCQ), like the following one:
PREFIX : <http://example.org/my-ontology#>
SELECT ?x WHERE {
{ ?x a :Student ; a :Teacher . } UNION
{ ?x a :BachelorStudent ; a :Teacher . } UNION
{ ?x :EnrolledIn ?y ; a :Teacher . }
}
(or, equivalently, a set of CQs)
I know there is some theoretical algorithm that accomplishes this task, like PerfectRef (see [1]).
Is there any already-implemented open-source Java library for achieving this or I have to implement this from scratch?