Question

I have an OWL ontology with three interconnected individuals: a, b, and c, and also has two isolated individuals x, and y.

interconnected individuals:

  1. have at least one outbound object property assertion. e.g.: a hasRelationWith b; or
  2. have at least on inbound object property assertion e.g.: such c, as b hasRelationWith c.

isolated individuals:

  1. have zero outbound object property assertion e.g.: x hasRelationWith [no individual]; and
  2. have zero inbound object property assertion e.g.: such x, as [no individual] hasRelationWith x.

Is it possible to classify (by logical inference, not by enumeration) all the isolated individuals using a DL Query (in Protégé 4.3, if it makes a difference), and if it is possible, how do I do it?

My intuitive guess is something like: (hasRelationWith min 0 Thing) exclude (hasRelationWith min 1 Thing), but DL-Query seems not supporting Set Subtraction syntax...


UPDATE: The following SPARQL can make it, although it cannot be used within class definition.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX my: <http://localhost:8080/ontology/untitled-ontology-26#>
SELECT DISTINCT ?src_obj
WHERE {
  ?src_obj a owl:NamedIndividual .
  minus {?src_obj my:hasRelationWith ?target_obj}
  minus {?target_obj my:hasRelationWith ?src_obj}
}
Was it helpful?

Solution

You can query about what's logically provable. That means that if you can infer that some individual isn't related to any others by some property, you can ask about it. For instance, if you have disjoint classes Cat and Dog, so that nothing can be an instance of both, and you have a Person jim who also has the additional type hasPet only Cat and Dog, then a reasoner can infer that jim hasPet exactly 0.

In the DL query language, you can also use inverse properties. The previous example showed that jim has no pets (i.e., is an instance of hasPet exactly 0). You could ask for animals that aren't the pets of anyone by asking for instances of inverse hasPet exactly 0. For instance, if you add disjoint subclasses of Person, ThisKind and ThatKind, and say that missy the Cat inverse hasPet only ThisKind and ThatKind, then a reasoner can infer that no one is related to missy by the hasPet property. An ontology for these two examples is given at the end of this answer.

For your particular query, you just combine two class expressions of the forms I've just described:

hasRelationWith exactly 0 and inverse hasRelationWith exactly 0

or, with some parenthesis:

(hasRelationWith exactly 0) and ((inverse hasRelationWith) exactly 0)

It is very important to note, however, that this only returns individuals for which it can be proven that there are no such relations. It's not enough for the data to simply not contain such relations yet. OWL makes the open world assumption, meaning something that isn't explicitly stated or provable isn't assumed to be true or false.

Example ontology

@prefix :      <http://www.example.org/cardinality-example#> .
@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#> .

:fido   a       owl:NamedIndividual , :Dog .

:Dog    a       owl:Class .

:fluffy  a      owl:NamedIndividual , :Cat ;
        a       [ a                   owl:Class ;
                  owl:intersectionOf  ( :ThatKind [ a                  owl:Restriction ;
                                                    owl:allValuesFrom  :ThisKind ;
                                                    owl:onProperty     [ owl:inverseOf  :hasPet ]
                                                  ] )
                ] .

:ThatKind  a              owl:Class ;
        rdfs:subClassOf   :Person ;
        owl:disjointWith  :ThisKind .

:rover  a       owl:NamedIndividual , :Dog .

:hasPet  a      owl:ObjectProperty .

<http://www.example.org/cardinality-example>
        a       owl:Ontology .

:Person  a      owl:Class .

:jim    a       owl:NamedIndividual , :Person ;
        a       [ a                owl:Restriction ;
                  owl:cardinality  "0"^^xsd:nonNegativeInteger ;
                  owl:onProperty   :hasPet
                ] .

:missy  a       owl:NamedIndividual , :Cat .

:Cat    a                 owl:Class ;
        owl:disjointWith  :Dog .

:ThisKind  a             owl:Class ;
        rdfs:subClassOf  :Person .
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top