On 07/11/2011 18:21, Thorben Wallmeyer wrote:
Hi all,
I do not really understand the inheritance of properties in class/sub
class constructs. As far as I understood the semantic web technologies a
subclass inherits all properties of its super-class(es).
There is no direct notion of "inheritance" in RDFS/OWL - that's an
object-oriented notion and RDFS/OWL are not object oriented. Thinking of
RDFS in terms of objects will almost always lead to confusion :)
It is true that if p has domain C and C has a subclass D then you can
"safely" apply p to an instance of D (instances of D are guaranteed to
be within the domain of p). So, for example, an editor that respects
this will offer you p as a legal property when creating instances of D.
However, here is no direct notion of an instance value being inherited.
The closest it gets is owl:hasValue.
Having this in
mind I've build up the following construct:
String PREFIX = "TEST://";
/*create model.*/
Model tmp = ModelFactory.createDefaultModel();
/*create resources and properties.*/
Resource A = tmp.createResource(PREFIX + "A");
Resource A1 = tmp.createResource(PREFIX + "A1");
Resource B = tmp.createResource(PREFIX + "B");
Property a = tmp.createProperty(PREFIX + "a");
Property b = tmp.createProperty(PREFIX + "b");
/*create a simple statement, where property 'a' should be inherited
afterwards.*/
tmp.add(tmp.createStatement(A, a, B));
//add additional knowledge
//1) A is a class and
//2) A is a member of its own class extension (set of things belonging
to A)
tmp.add(tmp.createStatement(A, RDF.type, RDFS.Class));
tmp.add(tmp.createStatement(A, RDF.type, A));
Why? It is true that in RDFS you are allowed to have something be both
an instance and a class and even a member of itself but that seems like
an orthogonal notion to inheritance and seems likely to just lead to
confusion.
//3) A1 is a subclass of A
//4) A1 is a member of its own class extension (set of things belonging
to A1)
tmp.add(tmp.createStatement(A1, RDFS.subClassOf, A));
tmp.add(tmp.createStatement(A1, RDF.type, A1));
/*build a inference model and list all statements about A1
In my opinion this should also list a statement like A1---a--->B.
as A1 is a subclass of A and a is a property of A. Unfortunately it does
not!*/
Why you expect that? There's nothing in the RDFS semantics that would
suggest something like that.
Model mDeductive =
ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF, tmp);
//for(Statement stmt : tmp.listStatements(A1, null, (RDFNode)
null).toList()){
for(Statement stmt : mDeductive.listStatements(A1, null, (RDFNode)
null).toList()){
System.out.println(stmt);
}
}
Can you tell me, why I do not get a statement like A1---a--->B, although
A1 is a subclass of A and 'a' is a property of A? What do I have to do
to achieve this, what I'm doing wrong?
Without a better idea of why you think an entailment like that should
follow it's a little hard to explain why it doesn't :)
Fundamentally don't think in terms on inheritance when dealing with
RDFS/OWL.
Guessing at what you are trying to achieve then one option to consider
would be to use owl:hasValue.
If you declare:
:A a owl:Class .
:p a owl:ObjectProperty .
:A rdfs:subClassOf [a owl:Restriction;
owl:onProperty :p;
owl:hasValue :i] .
:ai a :A .
then this should imply:
:ai :p :i .
then if you add:
:A1 rdfs:subClassOf :A .
:a1i a :A1 .
then you can deduce:
:a1i :p :i .
So the hasValue restriction implies a value for :p on each instance of A
and on instances of subclasses of A.
Is that what you want?
Dave