mr kw
mr kw

Reputation: 2113

How to set up generic owl object relationships

Warning: newbie question.

I am trying to model (as a simplified example) dogs with an associated numerical value for a set of classes associated with a dog, such as "fluffiness". I'm confused about how to represent a specific type (e.g. Dog) taking on a specific numerical value with respect to another type (e.g. Fluffiness). For example:

:Dog rdf:type owl:Class .
:Fluffiness rdf:type owl:Class .
:describedBy rdf:type owl:ObjectProperty ;
             rdfs:domain :Dog ;
             rdfs:range :Fluffiness .
:hasValue rdf:type owl:DatatypeProperty ;
          rdfs:domain :Fluffiness ;
          rdfs:range :&xsd;float .

:Chihuahua rdf:type :Dog .

How do I associate the Chihuahua with the specific value of, say 0.1, of a generic property of dog, such as Fluffiness? And is there a way to do it without resorting to just dropping Fluffiness as a class and defining a "hasFluffiness" Datatype property?

Upvotes: 2

Views: 234

Answers (1)

Joshua Taylor
Joshua Taylor

Reputation: 85843

At the moment, your representation works, but it's a little bit convoluted, in my opinion. You end up with instance data like:

Chihuahua describedBy fluffiness72 .
fluffiness72 hasValue 4.

As you note, you could instead have a hasFluffiness datatype property, but if you don't want to do that, I think your best bet here is to have an Attribute class of which things like Fluffiness, Size, Friendliness, etc., are instances. Then, you can have an AttributeValue class and properties attribute and value (you can probably come up with better names), so that you write data like this:

:chihuahua62 rdf:type :Chihuahua ;
             :hasAttributeValue [ :attribute :Fluffiness   ; :value 3 ] ;
             :hasAttributeValue [ :attribute :Friendliness ; :value 2 ] . 

With this kind of representation, you can say things like "every chihuahua has a fluffiness level less than 4":

((∃hasAttributeValue-1.Chihuahua) ⊓ (=attribute.Fluffiness)) ⊑ ∀value.xsd:float[≤4.0]

((inverse(hasAttributeValue) some Chihuahua) and (attribute value Fluffiness)) SubClassOf (value only xsd:float[<= 4.0])

In English, that says that every AttributeValue for a Chihuahua that's for the attribute Fluffiness must have a value less than 4.0.

You could use an alternative representation that says "if a Chihuahua has an attribute value, then if the attribute is Fluffiness, then then the value is less than 4.0". That's equivalent to "if a Chihuahua has an attribute value, then either the attribute is not Fluffiness, or the value is less than 4.0":

Chihuahua ⊑ ∀hasAttributeValue.(¬(=attribute.Fluffiness) ⊔ (∀value.xsd:float[≤4.0]))

That's easier to write into an ontology editor, since it's a subclass axiom about a class that you're interested in.

Here's an ontology that shows both approaches:

@prefix :      <http://stackoverflow.com/q/24760392/1281433/dogProperties#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .

:Shagginess  a  owl:NamedIndividual , :Attribute .

:hasValue  a         owl:DatatypeProperty ;
        rdfs:domain  :_attVal .

[ a                   owl:Class ;
  rdfs:subClassOf     [ a                  owl:Restriction ;
                        owl:allValuesFrom  [ a                     rdfs:Datatype ;
                                             owl:onDatatype        xsd:float ;
                                             owl:withRestrictions  ( [ xsd:minInclusive
                                                               10 ] )
                                           ] ;
                        owl:onProperty     :hasValue
                      ] ;
  owl:intersectionOf  ( [ a                   owl:Restriction ;
                          owl:onProperty      [ owl:inverseOf  :hasAttributeValue ] ;
                          owl:someValuesFrom  :Newfoundland
                        ] [ a               owl:Restriction ;
                            owl:hasValue    :Shagginess ;
                            owl:onProperty  :hasAttribute
                          ] )
] .

:Newfoundland  a         owl:Class ;
        rdfs:subClassOf  :Dog .

:Attribute  a   owl:Class .

:_attVal  a     owl:Class .

:hasAttribute  a     owl:ObjectProperty ;
        rdfs:domain  :_attVal ;
        rdfs:range   :Attribute .

:Chihuahua  a            owl:Class ;
        rdfs:subClassOf  :Dog ;
        rdfs:subClassOf  [ a                  owl:Restriction ;
                           owl:allValuesFrom  [ a            owl:Class ;
                                                owl:unionOf  ( [ a                 owl:Class ;
                                                                 owl:complementOf  [ a               owl:Restriction ;
                                                                                     owl:hasValue    :Shagginess ;
                                                                                     owl:onProperty  :hasAttribute
                                                                                   ]
                                                               ] [ a                  owl:Restriction ;
                                                                   owl:allValuesFrom  [ a                     rdfs:Datatype ;
                                                                                        owl:onDatatype        xsd:float ;
                                                                                        owl:withRestrictions  ( [ xsd:maxInclusive
                                                                                                          4 ] )
                                                                                      ] ;
                                                                   owl:onProperty     :hasValue
                                                                 ] )
                                              ] ;
                           owl:onProperty     :hasAttributeValue
                         ] .

:hasAttributeValue  a  owl:ObjectProperty ;
        rdfs:range  :_attVal .

:Dog    a       owl:Class .

<http://stackoverflow.com/q/24760392/1281433/dogProperties>
        a       owl:Ontology .

Upvotes: 4

Related Questions