Search code examples
semantic-webowlontologyprotege

OWL: Is it possible to predefine relations between an individual and a range of individuals?


Let's say we have the owl:Class Person and the owl:Class Fruit. Besides that we have the owl:ObjectProperty loves (Domain: Person, Range: Fruit). There are several instances of both classes.

Is it possible to express in OWL that one particular instance of the class Person likes all fruits except apples (instance of Fruit) without having to manually define all of the loves-relations between that person and all the other Fruit instances (except apple)?

On a more abstract level: Is it possible to define relations between an instance and a range of instances (either on a class-level or for the instance itself)?


Solution

  • The solution to your problem depends whether "apple" is an instance of "fruit" or "apple" is a subclass of "fruit". It would make more sense to say that "apple" is a class, because there are many instances of apples. But since Ignazio presented a solution where "apple" is an instance, and that his answer was accepted, I will start with assuming that "apple" is an instance. Then you can achieve what you want with:

    :Fruit  a  owl:Class .
    :apple  a  :Fruit .
    :Person a  owl:Class .
    :bob    a  :Person .
    :loves  a  owl:ObjectProperty .
    [ a owl:Class;
      owl:intersectionOf (
        :Fruit
        [ a owl:Class; owl:complementOf [a owl:Class; owl:oneOf (:apple)] ]
      )
    ]  rdfs:subClassOf  [
      a owl:Restriction;
      owl:onProperty [ owl:inverseOf :loves ];
      owl:hasValue :bob
    ] .
    

    This is saying that everything that is a :Fruit and is not :apple is necessary loved by :bob (assuming :bob is the identifier of the person who does not like apples. Note that this is different from Ignazio's solution, which does not exactly model what the OP wants.

    Now, if there is a class of apples, then the solution would be:

    :Fruit  a  owl:Class .
    :Apple  rdfs:subClassOf  :Fruit .
    :Person a  owl:Class .
    :bob    a  :Person .
    :loves  a  owl:ObjectProperty .
    [ a owl:Class;
      owl:intersectionOf (
        :Fruit
        [ a owl:Class; owl:complementOf :Apple ]
      )
    ]  rdfs:subClassOf  [
      a owl:Restriction;
      owl:onProperty [ owl:inverseOf :loves ];
      owl:hasValue :bob
    ] .