During our work with a triple store we noticed a strange behaviour related to inheritance chaining and linking properties to classes.
Consider the following example:
3 types defined - GrandParent, Parent and Child.
3 properties defined - GrandParentsProp, ParentsProp and ChildsProp.
Parent inherits GrandParent, Child inherits Parent.
GrandParentsProp has domain GrandParent.
ParentsProp has domain Parent.
ChildsProp has domain Child.
We are asking for properties related to each of these types. I am expecting to get result similar to result in OOP. Like
Child has GrandParentProp, ParentProp and ChildProp
GradnParent has GrandParentProp.
Unfortunately this was not what I got when testing reasoning in the triple store. I got exactly the opposite:
Child has ChildProp
GrandParent has GrandParentProp, ParentProp and ChildProp
In order to speak the same language I am providing the sample RDF data that was used.
# baseURI: http://sample/data
@prefix : <http://sample/data#> .
@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#> .
<http://sample/data>
a owl:Ontology .
:Child
a owl:Class ;
rdfs:label "Child"^^xsd:string ;
rdfs:subClassOf :Parent .
:ChildProp
a rdf:Property ;
rdfs:domain :Child ;
rdfs:label "Child prop"^^xsd:string .
:GrandParent
a owl:Class ;
rdfs:label "Grand parent"^^xsd:string .
:GrandParentProp
a rdf:Property ;
rdfs:domain :GrandParent ;
rdfs:label "Grand parent prop"^^xsd:string .
:Parent
a owl:Class ;
rdfs:label "Parent"^^xsd:string ;
rdfs:subClassOf :GrandParent .
:ParentProp
a rdf:Property ;
rdfs:domain :Parent ;
rdfs:label "Parent prop"^^xsd:string .
I am querying the data using these SPARQL query:
select * where
{
?s <http://www.w3.org/2000/01/rdf-schema#domain> <http://sample/data#GrandParent>
}
select * where
{
?s <http://www.w3.org/2000/01/rdf-schema#domain> <http://sample/data#Child>
}
I am wondering whether I am expecting something that is strange in semantic world or there is some problem with my statements or there is a problem with the reasoning in the triple store?