Does Apache Jena support reasoning over OWL restrictions?

levand Source

The capabilities of Jena's OWL reasoner listed here would seem to imply that Jena supports inference over restriction classes.

However, I am not observing this to be true. Specifically, I have an entity that is detected to be of a particular class, even though it's missing a property which a restriction with a minCardinality indicates must be present.

However, I am not sure if I am doing something wrong, my OWL is a bit rusty.

My data:

<?xml version="1.0"?>
<rdf:RDF xmlns      = ""
         xml:base   = ""
         xmlns:owl  = ""
         xmlns:rdf  = ""
         xmlns:rdfs = ""
         xmlns:xsd  = "">

    <owl:DatatypeProperty rdf:ID="name">
        <rdfs:domain rdf:resource="#Person"/>
        <rdfs:range rdf:resource="xsd:string"/>

    <owl:DatatypeProperty rdf:ID="age">
        <rdfs:domain rdf:resource="#Person"/>
        <rdfs:range rdf:resource="xsd:nonNegativeInteger"/>

    <owl:Class rdf:ID="Person">
                <owl:onProperty rdf:resource="#name"/>
                <owl:cardinality rdf:datatype="xsd:nonNegativeInteger">1</owl:cardinality>
                <owl:onProperty rdf:resource="#age"/>
                <owl:cardinality rdf:datatype="xsd:nonNegativeInteger">1</owl:cardinality>

    <!-- Is a person, because it's got a name and age -->
    <rdf:Description rdf:about="#john">
        <age rdf:datatype="xsd:nonNegativeInteger">42</age>

    <!-- Should not be a person, because it's missing an age -->
    <rdf:Description rdf:about="#zeus">


My Code:

 public static void main(String args[]) {
        System.out.println("hello world");

        OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);"src/main/resources/sample.owl");

        String queryString =
                "PREFIX ppl:  <>" +
                "PREFIX rdf: <>" +
                "SELECT ?obj " +
                "WHERE {" +
                "  ?obj rdf:type ppl:Person ." +

        Query query = QueryFactory.create(queryString);
        QueryExecution qe = QueryExecutionFactory.create(query, model);
        ResultSet results = qe.execSelect();
        ResultSetFormatter.out(System.out, results, query);

This outputs:

| obj      |
| ppl:john |
| ppl:zeus |

I would not expect ppl:zeus to be an instance of Person, because it does not satisfy the minCardinality restriction on age.

Any advice on what I'm doing wrong here? Is reasoning around rdfs:domain overriding the reasoning around the restriction class?



answered 6 months ago levand #1

The explanation for this is actually because I made a rookie mistake in thinking about OWL and RDF inference.

The simple explanation (as pointed out in the comments) is that the rdfs:domain on the property is sufficient for the inferencer to decide that the entity is a Person. If an entity is the subject of a name then it is an instance of Person, Q.E.D.

This leads to another question, however. The restriction class clearly states that it is not a person unless it has both a name and an age. So why isn't this a logical inconsistency? I have one piece of data that says Zeus is a Person, and another piece of data that says he's not, don't I?

Well, no. Because even though I've encountered it many times before, I once again tripped over the Open World model of reasoning. Which is that all inferencing occurs with the assumption that you don't actually have all the facts, and that things might be true even if the system hasn't explicitly asserted them to be true.

In other words, just because my data doesn't explicitly state that Zeus has an age, doesn't mean he doesn't. Someone else could come along and assert an age at any time.

As such, in general, minCardinality constraints can't really be enforced or checked via open-world reasoning.

maxCardinality is a different story, and does result in an inconsistent ontology error in a similar situation.

comments powered by Disqus