Hi Joshua,
On 03/07/13 18:51, Joshua TAYLOR wrote:
HI all, A recent StackOverflow question [1] mentioned that OWL2's
owl:NamedIndividual couldn't be converted to an OntClass (presumably
for an OntModel with a OntModelSpec with an OWL profile). Ian
Dickinson pointed out that this arises from the fact that Jena's
reasoners don't yet support OWL2, so owl:NamedIndividual isn't known
to be an rdfs:Class. (I know OWL2 support isn't currently planned,
but that contributions are welcome. :) This isn't the question here.)
I was surprised to learn that things which are rdfs:Classes can be
converted to OntClasses, even if they are not owl:Classes.
There are two reasons for this. The first is that OntClass is not a
semantic commitment: none of the Ont* Java classes add any
representation or state to the resources in the underlying model. It's
just a convenience API. In principle, all of the API on the Ont* classes
is available to non-OntAPI code, you just have to work a bit harder to
get the underlying triples out. The second reason to be permissive is
the open-world assumption. Not knowing something (this resource is an
owl:Class) is not the same as it being false. The corollary of this
observation is that any resource should be able to .as() any Ont* facet
class, without checking. I do wonder, in hindsight, if this should have
been the default (ie that strictMode would be false by default). It's a
change we can still make, if there's support for doing that.
Parenthetically, as you note from the code the .as() checking does not
assume that the model has an inference engine attached. Some of the
.as() checks would be much easier if we could presume the presence of a
reasoner, but the conservative case is to assume not.
I understand that Jena is being rather permissive here, and that the
implementation is intentional. The code that checks whether something
can be converted to an OntClass for the OWLDLProfile clearly checks
for RDFS.Class, RDFS.Datatype, and also anything that has been used as
the RDFS.domain or RDFS.range of a property (from OWLDLProfile.java):
[...]
This leads to some surprising results in some situations that are
surprising to me.
You've cited one "surprising result". Do you have others?
For instance, it means that a Resource can be
viewed as an OntClass, but that trying to listInstances of the
OntClass results in more conversion errors. For instance, the
following code gets an OntClass for OWL.Class, and then throws an
error when owl:Thing can't be converted to an Individual:
I think that's just a bug, related to a case that's not currently
covered by the "let's assume we don't have a reasoner" conditional. If
you'd like to log it as a Jira item, I will fix it as soon as I have a
moment.
This seems to be by design, but now I'm curious whether allowing
rdfs:Classes to be converted to OntClasses in OWLDL OntModels is
useful in practice and, if so, for what purposes?
I think in practice relatively few Jena users are strictly in DL. Most
ontologies that I see are effectively in OWL Full, or at least, the
developer doesn't care one way or the other (e.g. it's a linked data
project rather than an ontology project per se). If I was going to
propose a change at this point, based on the bug reports or help
requests we've received over the years that Jena has been in use, I
would make strict mode checking more rather than less permissive. Or,
indeed, turn strict mode off by default as I mention above.
Ian