Skip to content

Question: inconsistent ontology detection? #31

@midijohnny

Description

@midijohnny

Thanks for releasing this ! Very helpful utility.

One question - is there a way to detect whether an ontology is inconsistent or not?

I have built a simple ontology using Protege.
I'm using Python bindings - using the basic pattern like this:

from rdflib import Graph
import reasonable
 
g = Graph()
g.parse('marbles.ttl')

r = reasonable.PyReasoner()
r.from_graph(g)
triples = r.reason()

inferred_graph = Graph()
inferred_graph += r.reason()
inferred_graph.serialize(destination="inferred_output.ttl", format="turtle")

In this test - the universe consists of red and blue marbles.

I have created two disjoint classes for 'RedMarble' and 'BlueMarble' - any particular individual is axiomatically either a Red Marble or a Blue Marble - but it can't be both.

If I enable a reasoner in Proteger - I tried three:

All three of them pickup on the inconsistency and report it back.
Can I call reasonable in a way that also reports this back?

I include the TTL of the ontology below - it includes a deliberately inconsistent individual ":myInvalidMarble" - which is asserted to be both Red and Blue.

@prefix : <http://www.semanticweb.org/testing/ontologies/2025/4/this-is-inconsistent/> .
@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/testing/ontologies/2025/4/this-is-inconsistent/> .

<http://www.semanticweb.org/testing/ontologies/2025/4/this-is-inconsistent/> rdf:type owl:Ontology .

:Colour rdf:type owl:Class .
:Red rdf:type owl:Class ;
     rdfs:subClassOf :Colour .
:Blue rdf:type owl:Class ;
      rdfs:subClassOf :Colour .
:Marble rdf:type owl:Class .

:hasColour rdf:type owl:ObjectProperty ,
                    owl:FunctionalProperty ;
           rdfs:domain :Marble ;
           rdfs:range :Colour .

:BlueMarble rdf:type owl:Class ;
            owl:equivalentClass [ owl:intersectionOf ( :Marble
                                                       [ rdf:type owl:Restriction ;
                                                         owl:onProperty :hasColour ;
                                                         owl:someValuesFrom :Blue
                                                       ]
                                                     ) ;
                                  rdf:type owl:Class
                                ] ;
            rdfs:subClassOf :Marble ;
            owl:disjointWith :RedMarble .
:RedMarble rdf:type owl:Class ;
           owl:equivalentClass [ owl:intersectionOf ( :Marble
                                                      [ rdf:type owl:Restriction ;
                                                        owl:onProperty :hasColour ;
                                                        owl:someValuesFrom :Red
                                                      ]
                                                    ) ;
                                 rdf:type owl:Class
                               ] ;
           rdfs:subClassOf :Marble .
:myInvalidMarble rdf:type owl:NamedIndividual ,
                          [ owl:intersectionOf ( :Marble
                                                 [ rdf:type owl:Restriction ;
                                                   owl:onProperty :hasColour ;
                                                   owl:someValuesFrom :Blue
                                                 ]
                                                 [ rdf:type owl:Restriction ;
                                                   owl:onProperty :hasColour ;
                                                   owl:someValuesFrom :Red
                                                 ]
                                               ) ;
                            rdf:type owl:Class
                          ] .
:myMarble rdf:type owl:NamedIndividual ,
                   [ owl:intersectionOf ( :Marble
                                          [ rdf:type owl:Restriction ;
                                            owl:onProperty :hasColour ;
                                            owl:someValuesFrom :Red
                                          ]
                                        ) ;
                     rdf:type owl:Class
                   ] .

###  Generated by the OWL API (version 4.5.29.2024-05-13T12:11:03Z) https://github.com/owlcs/owlapi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions