请记住,OWL 使用开放世界假设,因此您在可以通过描述逻辑推断的内容方面受到一定限制。
因此,正如 Kaarel 所提到的,您的“查询”可能是:
flower and (hasColor only {red})
然而,这在开放世界假设中是无法证明的。在宇宙的某个地方,可能有一个声明,它断言:
<RedRose> :hasColor :StackOverflow .
其中,当与您的断言(您试图查询)结合使用时:
<RedRose> :hasColor :Red .
<RedRose> a :Flower .
将导致 DL 查询不返回任何结果。因此,由于开放世界假设,以及理论上存在狂野、不准确和不相关的断言(至少从您的角度来看),DL 查询将失败,因为它只能推断它可以证明是真的陈述。
但是,您的示例查询可以在 OWL 限制中使用,以确定某物是否不是其他物。例如,如果你有一个类 ( :OnlyRedFlower
),它必须只有红色,但它有蓝色(你已经断言了这个额外的颜色),那么你可以推断这朵新花不在的集合中:OnlyRedFlower
。
更新:对于那些有兴趣自己尝试的人,这是我根据这个问题创建的本体:
<?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>