How do owl and rdfs property domain range work?

2019-07-30 08:25发布

I am trying to understand the semantics of rdfs domain and range. Because I am from an object oriented background, I am struggling to understand the semantics and how to validate data against the rdfs statements.

Here is a sample file in turtle format:

PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix tmpl: <http://template.example.com/>
prefix data: <http://data.example.com/>

    tmpl:Thing a owl:Class.
    tmpl:Employment rdfs:subClassOf tmpl:TemporalThing.
    tmpl:Party rdfs:subClassOf tmpl:Thing.
    tmpl:Individual rdfs:subClassOf tmpl:Party.
    tmpl:Organisation rdfs:subClassOf tmpl:Party.
    tmpl:LimitedLiabilityCompany rdfs:subClassOf tmpl:Organisation.
    tmpl:hasCurrentEmployer a owl:ObjectProperty;
        rdfs:domain tmpl:Party;
        rdfs:range tmpl:Party.
    data:Simon a tmpl:Individual;
        skos:prefLabel "Simon S".
    data:PtyLtd a tmpl:LimitedLiabilityCompany.
    data:Simon tmpl:hasCurrentEmployer data:PtyLtd.

    tmpl:Animal a owl:Thing.
    data:Beans a tmpl:Animal.
    data:Simon tmpl:hasCurrentEmployer data:Beans.

I am using GRAPHDB as my test environment. I would expect the last statement to fail with some sort of message because 'Beans' is an 'Animal' which is not a 'Party'.

Yet, GRAPHDB just accepts the statement.

Any ideas?

EDIT

Based on Stanislav's comment below: While An inference engine might not have a problem with this, we can use the domain and range for error checking in an application.

1条回答
beautiful°
2楼-- · 2019-07-30 08:43

As said in the comments, you misunderstood the semantics of domain and range.

P rdfs:domain D
P rdfs:range R

mean that if a statement s P o holds, then (with a reasoner running), it could be inferred that s rdf:type D and o rdf:type R.

Domain and range are never restrictions on the the property. That has to be clear.

To understand how things work, check for examplem OWL direct semantics for object properties here.

查看更多
登录 后发表回答