This DL-Query is not returning any individuals:
hasPet exactly 1 DomesticAnimal
Here\'s part of the ontolo
The class expression hasPet exactly 1 DomesticAnimal
has as instances exactly those individuals which are related by the property hasPet
to exactly one DomesticAnimal
. Exactly one means at least one and no more than one. Based on the triples
:Joe :hasPet :Lassy .
:Bob :hasPet :Sparkey ;
:hasPet :Lucky .
we know that Joe and Bob each have at least one pet, but we do not know anything about how many they might have. Joe might have pets other than Lassy, so we don't know that Joe has exactly one pet. It is possible that Sparkey and Lucky happen to be the same individual, so Bob has at least one pet, but we do not have an upper bound on the number of pets that Bob has.
OWL, as well as RDF, makes the open world assumption, which means that OWL does not assume that the data provided is an exhaustive enumeration of everything in the world that is true. If it did, there would be no point in inference. The absence of an assertion of s p o
does not imply that NOT( s p o )
, but rather just that there is no judgment yet on s p o
.
You can add some more knowledge to your data to get the conclusions that you want, though. You describe Joe with the following:
Joe a Human ;
hasPet Lassy ;
hasPet only { Lassy } .
Lassy a DomesticAnimal .
From this you will be able to infer that
Joe a (hasPet exactly 1 DomesticAnimal) .
For Bob, it looks like you expect that Sparkey and Lucky are different animals, so you'll need owl:differentFrom
:
Bob a Human ;
hasPet Sparkey, Lucky .
Sparkey a DomesticAnimal .
Lucky a DomesticAnimal ;
owl:differentFrom Sparkey .
I did not include Bob hasPet only { Sparkey, Lucky }
in these axioms, because they are not necessary to infer that Bob has more than one pet, but you could include it. I also included just one of the owl:differentFrom
assertions that could have been made. Now Bob is known to have two distinct pets, and thus known to not be a hasPet exactly 1 DomesticAnimal
. With this data loaded into Protégé, the DL query hasPet exactly 1 DomesticAnimal
works as expected:
In case you want to be able to quickly load this structure into Protégé, here's an ontology with individuals, property, and axioms as described above. I did not define the petOf
property, but you can still run your first two queries as inverse hasPet value Joe
and inverse hasPet value Bob
and get the expected results.
@prefix : .
@prefix rdfs: .
@prefix owl: .
@prefix xsd: .
@prefix rdf: .
@prefix owa: .
owa:Bob
a owl:NamedIndividual , owa:Human ;
owa:hasPet owa:Sparkey , owa:Lucky .
owa:Sparkey
a owl:NamedIndividual , owa:DomesticAnimal .
owa:Lassy
a owl:NamedIndividual , owa:DomesticAnimal .
[] a owl:AllDifferent ;
owl:distinctMembers (owa:Lucky owa:Sparkey) .
owa:Joe
a owl:NamedIndividual , owa:Human ;
a [ a owl:Restriction ;
owl:allValuesFrom
[ a owl:Class ;
owl:oneOf (owa:Lassy)
] ;
owl:onProperty owa:hasPet
] ;
owa:hasPet owa:Lassy .
a owl:Ontology .
owa:Lucky
a owl:NamedIndividual , owa:DomesticAnimal .
owa:Human
a owl:Class .
owa:hasPet
a owl:ObjectProperty .
owa:DomesticAnimal
a owl:Class .