OWL/owlapi: Get Individuals with "unsatisfied" Object Properties

164 Views Asked by At

I'm working with an OWL Ontology in Protégé 5.1.0 (plus HermiT 1.3.8.413 Reasoner) that I later want to use with OWLAPI 4.1.0 and maybe DL-Query or SPARQL. My task at hand is to get all Individuals of a class that have a certain Object Property unfulfilled. Because of the open-world assumption, an unfulfilled Object Property doesn't usually show up as a problem, but I need the information and would like to avoid writing my own code to check the whole ontology.

I prepared I small example, as readable text and Turtle-code:

Classes: Pizza, Topping

Object Property: has

Assertion: Pizza has some Topping

Individuals: Pizza1, Pizza2, Topping1, Topping2 (of respective Classes)

Assertion: Pizza1 has Topping1

Code:

@prefix : <http://www.semanticweb.org/user/ontologies/2017/0/untitled-ontology-23#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://www.semanticweb.org/user/ontologies/2017/0/untitled-ontology-23> .

<http://www.semanticweb.org/user/ontologies/2017/0/untitled-ontology-23> rdf:type owl:Ontology .

#################################################################
#    Object Properties
#################################################################

###  http://www.semanticweb.org/user/ontologies/2017/0/untitled-ontology-23#has
:has rdf:type owl:ObjectProperty ;
     owl:inverseOf :isOn .


###  http://www.semanticweb.org/user/ontologies/2017/0/untitled-ontology-23#isOn
:isOn rdf:type owl:ObjectProperty ,
               owl:FunctionalProperty .


#################################################################
#    Classes
#################################################################

###  http://www.semanticweb.org/user/ontologies/2017/0/untitled-ontology-23#Pizza
:Pizza rdf:type owl:Class ;
       rdfs:subClassOf [ rdf:type owl:Restriction ;
                         owl:onProperty :has ;
                         owl:someValuesFrom :Topping
                       ] .


###  http://www.semanticweb.org/user/ontologies/2017/0/untitled-ontology-23#Topping
:Topping rdf:type owl:Class .


#################################################################
#    Individuals
#################################################################

###  http://www.semanticweb.org/user/ontologies/2017/0/untitled-ontology-23#Pizza1
:Pizza1 rdf:type owl:NamedIndividual ,
                 :Pizza ;
        :has :Topping1 .


###  http://www.semanticweb.org/user/ontologies/2017/0/untitled-ontology-23#Pizza2
:Pizza2 rdf:type owl:NamedIndividual ,
                 :Pizza .


###  http://www.semanticweb.org/user/ontologies/2017/0/untitled-ontology-23#Topping1
:Topping1 rdf:type owl:NamedIndividual ,
                   :Topping ;
          :isOn :Pizza1 .


###  http://www.semanticweb.org/user/ontologies/2017/0/untitled-ontology-23#Topping2
:Topping2 rdf:type owl:NamedIndividual ,
                   :Topping .


#################################################################
#    General axioms
#################################################################

[ rdf:type owl:AllDifferent ;
  owl:distinctMembers ( :Pizza1
                        :Pizza2
                      )
] .


[ rdf:type owl:AllDifferent ;
  owl:distinctMembers ( :Topping1
                        :Topping2
                      )
] .


###  Generated by the OWL API (version 4.2.6.20160910-2108) https://github.com/owlcs/owlapi

In this case, I would like to query the ontology and get the information that Pizza2 currently doesn't have any Topping, i.e. its Object Property is not asserted or inferred. Also, if Topping1 is changed to be of a different class, I now want to see Pizza1 show up in the query as well because "Pizza has some Topping" is unsatisfied.

Is there an elegant way to do this either directly in OWLAPI or using DL-Query/SPARQL?

0

There are 0 best solutions below