I want to write a nested DL query in Protege. I can run a simple query like:
Person and hasFather value PersonA
It retrieves the name of all the Persons whose Father is PersonA. But I want that PersonA value should also be retrieved from some query like
Person and hasFather value (Person and hasSon value PersonB)
It is showing syntax error in Protege. Please help me with the correct format.
The reason that
Person and hasFather value (Person and hasSon value PersonB)
is a syntax error is not that it's “nested”, but that value
requires an individual, but (Person and hasSon value PersonB)
is a class. If you use
Person and hasFather some (Person and hasSon value PersonB)
instead, you should be all set. This query asks for individuals that are people that have a father that is a person and has person B as a son. That is, it's asking for siblings of person B, i.e., other children of person B's father.
For instance, here's a query about the Simpson family where Bart and Lisa each have Homer as their father, and Homer has each of them as a child:
The data is:
@prefix : <http://www.example.org/families#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix families: <http://www.example.org/families#> .
<http://www.example.org/families>
a owl:Ontology .
families:Person a owl:Class .
families:hasFather a owl:ObjectProperty .
families:hasChild a owl:ObjectProperty .
families:Bart a owl:NamedIndividual , families:Person ;
families:hasFather families:Homer .
families:Lisa a owl:NamedIndividual , families:Person ;
families:hasFather families:Homer .
families:Homer a owl:NamedIndividual , families:Person ;
families:hasChild families:Bart , families:Lisa .
families:Milhouse a owl:NamedIndividual , families:Person .