Good question. The reason you need these types to be specified is due to the mapping from RDF graphs to OWL (2) Ontologies. In an OWL 2 ontology, every entities must be explicitly typed as either a class, an object property, a datatype property, an annotation property, a datatype or an ontology. To ensure this constraint is addressed in all RDF serialisation of an OWL ontology, one must explicitly type all resources introduced by the ontology, including these blank nodes associated with restrictions, intersections and so on.
With that said, there are many cases when the explicit typing is not really useful because the type can be inferred from the other triples. For instance:
:myClass owl:intersectionOf ( owl:Thing ) .
requires that :myClass
is an owl:Class
. Consider the example that you give:
:myClass owl:equivalentClass
[owl:intersectionOf (
[ owl:onProperty :hasProp ; owl:allValuesFrom :SomeOtherClass ]
[ owl:onProperty :hasProp ; owl:someValuesFrom :SomeOtherClass ] )
] .
On the one hand, :myClass
must be a class, because of owl:equivalentClass
; the two blank nodes inside the list are necessarily owl:Restriction
, because of the use of the predicate owl:onProperty
; this entails that the blank node with the owl:intersectionOf
attribute is necessarily a class.
On the other hand, it is not clear whether :SomeOtherClass
is a class or a datatype, because it is not known whether :hasProp
is an object property or a datatype property. So here you have a situation whether explicitly typing makes a difference.
Now, the real question may be: "do I really need to put these types explicitly in pratice?" I'd say, it depends on the tools you are using. Most OWL processors will interpret many non compliant RDF graphs as valid OWL ontologies, but you have to be careful, as surprises could happen. For example, I tried opening a file in Protégé containing the example that you give. Protégé did not manage to interpret the content as defining any class or property. However, the problem was not because of the missing owl:Restriction
or the missing owl:Class
for the blank nodes. If I simply added an explicit type for :myClass
, then Protégé interpreted the content as defining two classes, an object property, and an axiom about :myClass
. Compare:
# This does not work in Protégé 4.3
@prefix : <http://ex.com/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
:myClass owl:equivalentClass [
owl:intersectionOf (
[ owl:onProperty :hasProp; owl:allValuesFrom :SomeOtherClass ]
[ owl:onProperty :hasProp; owl:someValuesFrom :SomeOtherClass ]
)
] .
and:
# This works in Protégé 4.3
@prefix : <http://ex.com/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
:myClass a owl:Class;
owl:equivalentClass [
owl:intersectionOf (
[ owl:onProperty :hasProp; owl:allValuesFrom :SomeOtherClass ]
[ owl:onProperty :hasProp; owl:someValuesFrom :SomeOtherClass ]
)
] .
What is surprising is that Protégé decided to interpret :hasProp
as an object property while it could have been a datatype property.
Finally, to wrap this answer up, I noticed that if you discard the owl:Restriction
type completely, ontologies in RDF are still recognised as valid OWL 2 DL ontologies by the Manchester OWL 2 validator. Try this as an input:
@prefix : <http://ex.com/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
:SomeOtherClass a owl:Class .
:hasProp a owl:ObjectProperty .
:myClass a owl:Class;
owl:equivalentClass [
owl:intersectionOf (
[ owl:onProperty :hasProp; owl:allValuesFrom :SomeOtherClass ]
[ owl:onProperty :hasProp; owl:someValuesFrom :SomeOtherClass ]
)
] .
Edit: I just checked the OWL 2 specification and it appears that the RDF graph above should be classified as an OWL 2 DL ontology document. However, in this particular example, there is no ambiguity on the types of the entities.