3

I have an OWL 2 ontology containing several named individuals belonging to a class that need to have the same object property with the same value.

I would like to make this property assertion "on the class" in such a way that a reasoner could infer the property to be had by all of its members, thus without needing an explicit assertion for each. (obtaining something similar to a class-based object-oriented property inheritance)

A simple example could be an ontology containing the individuals milkBottle1, milkBottle2, milkBottle3 that belong to the class Milk. They should all have the property containsNutrient with the value protein, but clearly this is something that is shared by all members of the Milk class and should only be explicitly asserted once.

I have found the same question only here, but the only answer suggests an inappropriate solution: to make the class a subclass of a property restriction class. This leads the reasoner to infer the class to be equivalent to the Nothing class (since there are no named individuals with such property), thus creating an inconsistence because of the assignment of individuals to it.

I am aware that this is a straightforward task using a SWRL rule like

Milk(?a) → containsNutrient(?a, protein)

but I'd like to avoid them if possible.

Is this possible without workarounds in OWL 2? If so, how can it be done?

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353

1 Answers1

5

I would like to make this property assertion "on the class" in such a way that a reasoner could infer the property to be had by all of its members, thus without needing an explicit assertion for each. (obtaining something similar to a class-based object-oriented property inheritance)

If you want to say that every member of some class C has individual v as the value for property p, you can write:

C subClassOf (p value v)

Now, regarding your additional comment:

I have found the same question only here, but the only answer suggests an inappropriate solution: to make the class a subclass of a property restriction class. This leads the reasoner to infer the class to be equivalent to the Nothing class (since there are no named individuals with such property), thus creating an inconsistence because of the assignment of individuals to it.

What I've just suggested is the same as what's described in that answer. There's nothing inconsistent about saying "C subClassOf (p value v)", even if there are no declared named individuals of type C. If you're running into some particular problem with this type of solution, you may want to elaborate on it (and perhaps ask an additional question); the axiom C subClassOf (p value v) subsumes the SWRL rule C(?c) → p(?c,v). (The SWRL rule is less general because it only applies to named individuals, whereas the axiom applies to all individuals.)

Example

Figure 1: C is a subclass of (p value v). C subClassOf (p value v)

Figure 2: When a reasoner has been enabled, individual c of type C is inferred to have v as a value for property p. p(c,v)

Ontology (TTL and RDF/XML)

@prefix :      <http://stackoverflow.com/q/29075078/1281433#> .
@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#> .

:c      a       owl:NamedIndividual , :C .

:C      a                owl:Class ;
        rdfs:subClassOf  [ a               owl:Restriction ;
                           owl:hasValue    :v ;
                           owl:onProperty  :p
                         ] .

:p      a       owl:ObjectProperty .

:       a       owl:Ontology .

:v      a       owl:Thing , owl:NamedIndividual .
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns="http://stackoverflow.com/q/29075078/1281433#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
  <owl:Ontology rdf:about="http://stackoverflow.com/q/29075078/1281433#"/>
  <owl:Class rdf:about="http://stackoverflow.com/q/29075078/1281433#C">
    <rdfs:subClassOf>
      <owl:Restriction>
        <owl:onProperty>
          <owl:ObjectProperty rdf:about="http://stackoverflow.com/q/29075078/1281433#p"/>
        </owl:onProperty>
        <owl:hasValue>
          <owl:Thing rdf:about="http://stackoverflow.com/q/29075078/1281433#v">
            <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
          </owl:Thing>
        </owl:hasValue>
      </owl:Restriction>
    </rdfs:subClassOf>
  </owl:Class>
  <owl:NamedIndividual rdf:about="http://stackoverflow.com/q/29075078/1281433#c">
    <rdf:type rdf:resource="http://stackoverflow.com/q/29075078/1281433#C"/>
  </owl:NamedIndividual>
</rdf:RDF>
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • But if you explicitly don't say that an individual hasProperty some individual, and only say class hasProperty some class, the reasoner cannot produce it. At least, if it can, please tell me how. – Artemis Mar 16 '15 at 14:49
  • @Artermis I don't understand what you're asking in that comment. If you say that "C subClassOf (p value v)" and then say that "c ∈ C", you can infer that "p(c,v)". – Joshua Taylor Mar 16 '15 at 14:50
  • I think what was asked was if you have instances of a class, and you define restriction as you suggest, then how to get the reasoner to generate the inference. Have you tried it out? I have done with OWLAPI and am unable to get it. I want to know how you did it. – Artemis Mar 16 '15 at 14:53
  • I've added an example that shows that this works with the HermiT reasoner under Protege. I don't know offhand how to use reasoners under the OWLAPI, but I know that there are lots of examples in its documentation. – Joshua Taylor Mar 16 '15 at 15:02
  • This should suffice to show that this is possible, however, and that a hasValue restriction is the appropriate way to do it. The question, after all, was about an OWL2 construct to do this; not about an OWLAPI way of accessing the result. – Joshua Taylor Mar 16 '15 at 15:02
  • 1
    The solution you offered is correct. (as is the solution I referenced) I was getting inconsistency messages from Protégé, (classes were marked red) but clearly the problem lied elsewhere, since I was able to reproduce your simple example and several similar ones outside of a large ontology. I'm not sure what had me believe it was the wrong way to do this. Thank you for your incredibly detailed answer. –  Mar 17 '15 at 14:05
  • 2
    Note that Protege will mark a class a red if it's unsatifiable; that is, if nothing can be an instance of it. That's different from the ontology being inconsistent. There'd only be an inconsistency if some individual is required to be an instance of an unsatisfiable class. – Joshua Taylor Mar 17 '15 at 15:17