I've defined a class as restriction for a property:
:A rdf:type owl:Class ;
owl:equivalentClass [ rdf:type owl:Restriction ;
owl:onProperty :P ;
owl:someValuesFrom xsd:string
] .
and would like to 'reuse' this restriction in another class, whereby I'm using the equivalentClass hierarchy:
:B rdf:type owl:Class ;
owl:equivalentClass :A.
But then I'm confused with the results shown by Protege: The :B is displayed as equivalentClass to :A (as expected) but as "subClassOf (Anonymous Ancestor)" to "P some xsd:string". I've expected, that :B inherits the property restriction also as equivalentClass.
The subclassing of the property restriction in B instead of equivalent class relation influences the type inferencing of an individual that contains the property P:
:Ind rdf:type owl:NamedIndividual ;
:P "p" .
A reasoner (I'm using FACT++) infers that the Ind is of type A because it contains the property P, and of type B - because it is A, and A is equal to B, but not because of the property P.
So, I'd like to ask, why the property restriction is inherited as subClassOf in my example, and if there is a posibility to inherit it as equivalentClass?
Thanks for any hint.
View from A:
View from B:
Be careful not to confuse Protégé's behaviour with how a reasoner works, or how OWL works. It's possible that, when you apply reasoning in Protégé, Protégé is only asking for what is in the upper hierarchy of the classes. Maybe Protégé does not ask the reasoner what is equivalent. I have noticed that, for several kinds of inferences, Protégé does not display them, even when the reasoners are themselves able to deduce them. I have never put my nose into Protégé's source code, and I have only limited knowledge of how Pellet work, limited theoretical knowledge of HermiT's algorithm, no other knowledge of the code of other reasoners, so I cannot say more.
In any case, you are not misunderstanding how the semantics of OWL works, and this is probably not a bug in the reasoner. It is certainly due to the way Protégé works.
Related
I tried to use the same object property between multiple classes, but I got a warning that the same object property has been set multiple times as follows, can you please let me know what is wrong with that and how to solve it? Does this restrict reasoning later on (i.e. confuse the reasoner since the same object property is set multiple times)?
Thanks
Contrary to the comments it actually is very problematic to use the same object property between multiple classes.
What you don't see in your visualization is that in RDF/OWL, the starting point of your relation arrows is modelled as rdfs:domain and the target point of the arrows is modelled as rdfs:range.
The semantic of an OWL class is that it is a set of individuals and rdfs:domain and rdfs:range specify the domain, respectively range of a relation. That is, they specify the sets of allowed values in subject, respectively object position of a triple with that relation in the predicate position.
If you express your example in RDF Turtle it would look like this:
:hasPart rdfs:domain :ClassA, :ClassB;
rdfs:range :ClassB, :ClassC, :ClassD.
This causes multiple problems:
Intersection
The semantic of multiple domains, respectively ranges, is the intersection of those classes, not the union!
Even if we disregard the relation between :ClassB and :ClassD, this means :hasPart is only allowed by individuals that are instances of class C and class D at the same time!
For example, lets say class A is "car", class B is "tire" and class C is "motor". Now you want to say that a car can have tires and motors but what you actually specify is that a car can only have things that are a motor and a tire at the same time!
Unwanted but allowed usage
If you fix the first problem but specifying the union instead of the intersection, it will be very messy in serialized RDF because you need a large amount of triples to represent OWL restrictions such as unions. But even if you do that, you could now connect an instance of class A with an instance of class D, which is not allowed in the image.
Solution
The solution is simple, just separate those relations, for example into :hasB, :hasC and :hasD, although in a real scenario you can probably find a more suitable naming scheme, where the "has" prefix is often not used. For example, in DBpedia, the property for the country of a city is expressed using dbo:country, not dbo:hasCountry.
Suppose I have
:hasParent rdfs:subPropertyOf :hasAncestor .
:hasAncestor rdf:type owl:TransitiveProperty .
This has the satisfying result of inferring all true ancestor relationships given the parentage. But I'm surprised it doesn't have the negative side-effect of making :hasParent effectively transitive too. Doesn't p rdfs:subPropertyOf q mean p "inherits" q's meta-properties, including a owl:TransitiveProperty?
Seemingly asymmetrically, we see with A rdfs:subClassOf B and B :hasFriend C that A :hasFriend C also since A rdf:type B. Why doesn't this happen with sub-properties too?
Stanislav has already given a good answer to this question. What I want to address here is the idea mentioned in the comment that "inheritance of classes" are asymmetric with "inheritance of properties".
Object Orientation
(1) In object oriented programming languages, when class A inherits from class B, it means that the set of all the instances of class A is a subset of the set of all the instances of class B. Moreover, because attributes belong to a specific class, it means class A will have all the attributes of class B (i.e.
class A inherits all the attributes of class B).
(2) When class A has an attribute c of type C, it states (more or less) that there is an association c between classes A and C.
OWL/RDFS
(1) A big difference with OWL/RDFS is that properties do not belong to a class. When we say that A rdfs:subClassOf B, we say that the set A is a subset of B. It says nothing more. As an example if we have
B a rdfs:Class .
B rdfs:label "Label for class B" .
A a rdfs:Class .
A rdfs:subClassOf B .
class A will not "inherit" the label of class B.
(2) Properties in OWL/RDFS are specified between instances, not between classes. I have written about this in detail on my blog. When you state that P rdfs:subProperty R it means that the set of pairs of individuals in P is a subset of the set of pairs of individuals in R.
But Functional Properties are inherited...
No, they are not. It just seems so due to the semantics of functional properties. If we have a property R that is functional it means a satisfying assignment for R can be {(a,1), (b,2)}. That is the same subject cannot be linked to 2 different objects. I.e. you cannot have {(a,1), (a,2)}.
Now, if you have that P rdfs:subPropertyOf R, P is subset of R and thus P will be functional as well. I.e. if R = {(a,1), (b,2)} any subset of R will be functional as well.
Doesn't P rdfs:subPropertyOf Q mean P "inherits" Q's meta-properties,
including a owl:TransitiveProperty?
In general, no.
P rdfs:subPropertyOf Q means that ∀x∀y(P(x,y) → Q(x,y)) (1)
Q a owl:TransitiveProperty means that ∀x∀y∀z(Q(x,y) ∧ Q(y,z) → Q(x,z)) (2)
Unfortunately, (1) and (2) do not entail ∀x∀y∀z(P(x,y) ∧ P(y,z) → P(x,z)).
You can find a countermodel online:
By the way, a subproperty of a functional property is also functional.
For example, I have three classes: Flock, Bird, Velocity. I also have two properties: hasMember (the domain is Flock, range is Bird), and hasAttribute (the domain is Bird, and the range is Velocity). Now I want to add a EquivalentClass restriction to Flock class as the definition. Let consider a very simple definition: in a flock, all birds have the same velocity. How to express this in OWL?
Warning: this answer is in fact incorrect, please look at the comments to see why.
To the question "Could we use owl:sameAs in an OWL restriction?" the answer is no, not in an OWL (2) ontology. However, you can do whatever you like in an OWL Full ontology (i.e., an RDF graph interpreted according to the OWL RDF-based semantics). Yet, this is irrelevant to the details of your question where you want to say something about the velocity of the birds in a flock.
There is a solution to your problem within the limits of OWL 2 DL. Introduce a property flockVelocity and make the property chain hasMember o hasAttribute a subproperty of flockVelocity. Make flockVelocity a functional property and you're done. Alternatively, you could define a cardinality restriction on flockVelocity. In Turtle:
:hasMember a owl:ObjectProperty;
rdfs:domain :Flock;
rdfs:range :Bird .
:hasAttribute a owl:ObjectProperty; # why not :hasVelocity?
rdfs:domain :Bird;
rdfs:range :Velocity .
:flockVelocity a owl:ObjectProperty, owl:FunctionalProperty;
owl:propertyChainAxiom (:hasMember :hasAttribute) .
Done. If you don't care about being in OWL DL and allow yourself total OWL Full freedom, you could use a blank node instead of :flockVelocity such that you don't have to introduce an artificial property name.
I've been searching around but couldn't find a good way to model the following, I have two classes in owl and one is the base class of the other:
:Base rdf:type owl:Class .
:Sub rdf:type owl:Class;
rdfs:subClassOf :Base .
:hasDescription rdf:type owl:DatatypeProperty .
I want all instances of :Base to have a fixed description (:hasDescription "BASE"), and all instances of :Sub to have a different fixed description (:hasDescription "SUB"). But I want to avoid creating a triple for every instances such as
:Base1 rdf:type :Base;
:hasDescription "BASE" .
I tried using owl:Restriction :
:Base rdf:type owl:Class .
rdf:subClassOf [ rdf:type owl:Restriction ;
owl:onProperty :hasDescription ;
owl:hasValue "BASE"
] .
:Sub rdf:type owl:Class;
rdfs:subClassOf :Base ,
[ rdf:type owl:Restriction ;
owl:onProperty :hasDescription ;
owl:hasValue "SUB"
] .
but this wouldn't work because then :Sub would have both "BASE" and "SUB" as description since it's a subclass of :Base, which in turn is a subclass of the restriction with value "BASE". Anyone has any suggestion on how this can be done in owl? Thanks.
I think that this is probably possible, but it highlight the differences between object oriented programming languages and the class hierarchies as present in OWL. They're very different things, and it might make sense to consider changing your model, because you may not find a satisfactory solution to this issue.
Every instance of a subclass is an instance of all of its ancestors. That's why if you assert something like
Base SubClassOf (hasDescription value "BASE")
all the instances of the subclassses of Base will also have that value. (You already know that, of course; you described it in the question.)
You can say that instances of Base that are not instances of Sub have the value "BASE" and that instances of Sub have the value "SUB" with two axioms. One says that instances of Sub have the value "SUB" (you already know how to do this):
Sub SubClassOf (hasDescription value "SUB")
To say that instances of Base that are not instances of Sub have the value "BASE", you use a general class axiom like:
Base and (not Sub) SubClassOf (hasDescription value "BASE")
The process of creating general class axioms has been discussed in other questions and answers, and isn't difficult. See, e.g.:
owl protege how can I describe a class that has just some properties?
Defining Protege class with expression of numerical data
Inferencing in protege
The difficulty that you may run into is getting this axiom to be used. In general, when you assert that something is an instance of Base, you don't explicitly assert that it's not an instance of a subclass. That's a manifestation of the Open World Assumption: just because you don't know that something is true does not mean that you don't know that it's false.
You can do that, of course, by adding an additional type assertion to individuals. For instance, if x is a Base and not a Sub, you just need to say that:
x : Base
x : not Sub
I'm working on an ontology and I need to tell protege that one class x can only have the values y and z.
I want something like:
Vegetable rdf:type owl:Class;
owl:oneOf (carrot corn).
Must I edit the file directly or is there a way to do it via Protege?
In the Class Description you should choose "Equivalent To" option and in Class Expression editor write the comma-separated list of the individuals in curly brackets. In your example:
Vegetable equivalentTo {carrot,corn}