In the owl "Dl query", how to use the extended evaluation query in the protégé
I am developing an ontology and I have a problem with my Dl query
there is a class called "flower"
and this class has subclasses which are color names
and there is also another class called "flowersColor"
and it has these meanings ("red", "green" and "blue") as individuals, not a subclass -
each flower has one color or more
I want to find a flower with red and only red
My DL request:
"flower and hasColor value red"
this query will give me all flowers with red color even if it has other colors
however I want all flowers to be ONLY red
I want to write something like this
"flower and hasColor only value red" <- this is not grammatically correct
I'm in charge, if the color has a combination of "red" and "green" then I don't want to see it in my result
Hope you can help me with my request
thanks
a source to share
Remember that OWL uses an open world assumption, so you are somewhat limited in what the description logic can do.
So your "request", as Kaarel mentions, could be:
flower and (hasColor only {red})
However, this is unprovable in the open world assumption. There may be a statement, somewhere in the universe, that states:
<RedRose> :hasColor :StackOverflow .
Which, combined with your assertions (which you are trying to query):
<RedRose> :hasColor :Red .
<RedRose> a :Flower .
Will not trigger a DL request. So, due to the open world assumption and the theoretical existence of wild, imprecise and irrelevant statements (at least from your point of view), the DL query will fail as it can only infer the statements it can prove to be true.
However, your example query can be used in an OWL constraint to determine if something is not something else. For example, if you have a class ( :OnlyRedFlower
) that should only be red, but blue (you specified this additional color), you might infer that this new flower is missing from the set :OnlyRedFlower
.
Update: For those interested in trying this out on their own, here's an ontology I created based on this question:
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY owl2xml "http://www.w3.org/2006/12/owl2-xml#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY onto "http://www.elastra.com/onto/2009/5/30/onto.owl#" >
]>
<rdf:RDF xmlns="http://stackoverflow.com/users/64881/ontology_842588.rdf#"
xml:base="http://stackoverflow.com/users/64881/ontology_842588.rdf"
xmlns:owl2xml="http://www.w3.org/2006/12/owl2-xml#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:onto="http://www.elastra.com/onto/2009/5/30/onto.owl#">
<owl:Ontology rdf:about="">
<rdfs:comment xml:lang="en"
>Example for http://stackoverflow.com/questions/842588/in-owl-dl-query-how-to-use-advanced-valu-query-in-protege</rdfs:comment>
</owl:Ontology>
<owl:ObjectProperty rdf:about="&onto;hasColor"/>
<owl:Class rdf:about="&onto;Color"/>
<owl:Class rdf:about="&onto;ExampleFlower">
<rdfs:subClassOf rdf:resource="&onto;Flower"/>
</owl:Class>
<owl:Class rdf:about="&onto;Flower"/>
<owl:Class rdf:about="&onto;OnlyRedFlower">
<owl:equivalentClass>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
<rdf:Description rdf:about="&onto;Flower"/>
<owl:Restriction>
<owl:onProperty rdf:resource="&onto;hasColor"/>
<owl:allValuesFrom>
<owl:Class>
<owl:oneOf rdf:parseType="Collection">
<rdf:Description rdf:about="&onto;Red"/>
</owl:oneOf>
</owl:Class>
</owl:allValuesFrom>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
</owl:equivalentClass>
<rdfs:subClassOf rdf:resource="&onto;Flower"/>
</owl:Class>
<owl:Class rdf:about="&onto;OtherFlower">
<rdfs:subClassOf rdf:resource="&onto;Flower"/>
</owl:Class>
<onto:Color rdf:about="&onto;Blue">
<rdf:type rdf:resource="&owl;Thing"/>
</onto:Color>
<onto:Flower rdf:about="&onto;BlueOrchid">
<rdf:type rdf:resource="&owl;Thing"/>
<onto:hasColor rdf:resource="&onto;Blue"/>
</onto:Flower>
<onto:Color rdf:about="&onto;Red">
<rdf:type rdf:resource="&owl;Thing"/>
</onto:Color>
<onto:Flower rdf:about="&onto;RedRose">
<rdf:type rdf:resource="&owl;Thing"/>
<onto:hasColor rdf:resource="&onto;Red"/>
</onto:Flower>
</rdf:RDF>
a source to share
The query you are using is the following:
flower and (hasColor only {red})
Note that the constructor {.}
creates a class from an individual or a list of individuals. This way you can use it wherever syntactically a class is required, for example
(not {blue}) subClassOf
{red} and {green,blue} or (hasColor max 10 ({red} or {blue}))
a source to share