4

What I am trying to do is create a datatype property that accepts and recognizes numeric intervals. For example lets say I have the property "temperature". In the ontology I want to create 2 sub properties "hot" and "cold". Hot would be temperatures 20-30 and cold 0-19. What I am doing at the moment is having some properties set as lowerlim and upperlim. But is there a more convenient way to express intervals directly through the property? So that when I query for example "23" it would recognise its "hot". Any tips?

Thank you in advance

user3211165
  • 225
  • 1
  • 3
  • 14
  • 4
    There's this [teenager example](http://stackoverflow.com/questions/4192435/owls-equivalentclass-vs-subclassof) all around the web. That's one way to do it. – scozy May 06 '14 at 10:33
  • 1
    @scozy I dont really get this example. Using this when you ask for the age 14 for example, will it recognize and provide as output the "teenager"? And this code should be placed in the class expression? Because I am looking a way to do it through the datatype property. – user3211165 May 06 '14 at 13:21
  • The OWL 2 specification is pretty clear about that. See [§9.6.6](http://www.w3.org/TR/owl2-syntax/#Positive_Data_Property_Assertions). – scozy May 06 '14 at 14:04
  • 2
    @user3211165 The answer in that linked question points out that if you say `Teenager subClassOf (hasAge some xsd:integer[> 12, <= 19])`, then it means that if something is a Teenager, then it has such an age, but it *doesn't* mean that everything with such an age is a teenager. To get the other direction, you'd either need the order reversed, or to use an `equivalentClass` axiom. – Joshua Taylor May 06 '14 at 15:33
  • @scozy thank you for your answer. But how do I enter a range of values for an individual/instance. For example I want the instance Meg to have values from 3 to 10 for a specific data property? – user3211165 May 06 '14 at 15:36
  • 1
    Do you mean you want that `Meg hasAge 3`, and `Meg hasAge 4`, and …, and `Meg hasAge 10`? That's sort of an unusual thing to want… – Joshua Taylor May 06 '14 at 15:43
  • @JoshuaTaylor Yes but not for ages specifically. For ages it does not make sense but for other things it does. Instead of adding everytime has 1, has 2, has 3.. etc is there a way to define to an instance through a data property the numeric values from 2 to 5 for example? – user3211165 May 06 '14 at 17:09
  • 1
    There's not really an easy way to do that. If you'll need to do this for multiple individuals, it's probably best to define a class once, e.g., `HasValues2Through5 subClassOf ((hasValue value 2) and (hasValue value 3) and (hasValue value 4) and (hasValue value 5))`, and then say things like `Meg rdf:type HasValues2Through5`. It's a bit clunky, but I don't know if you can do much better… – Joshua Taylor May 06 '14 at 17:14
  • There exist description logics with "fancy" concrete domains. For instance, you could define a role with range Q². [Here](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.10.6936) is an interesting survey if you are interested, or just look into temporal description logics. I don't think there is any straightforward way to translate those to any OWL standard, though, without resorting to what you were trying to avoid--double roles and lots of knowledge to maintain consistency. – scozy May 06 '14 at 20:10
  • @JoshuaTaylor I guess theres no easy way then. I wanted to be able to ask a query about a number and get back as an answer the interval of numbers that belongs to. Doing hasvalue for big intervals is pretty pointless i believe. Thanks though – user3211165 May 08 '14 at 13:56

1 Answers1

8

This is quite straightforward in OWL, however the kind of inferences you're expecting may be a little different to the ones I'll now explain.

In OWL, you can define restrictions on datatype properties (as I've shown before).

However, datatype reasoning is required to infer that some resource/individual with a particular datatype value belongs to some class. Note that not all reasoner implementations support this, however I'll focus on Pellet, which does.

To demonstrate, I'll create a small OWL ontology. I'll write it out in OWL/XML syntax. It will be long, but hopefully will explain how it's done.

Firstly, define a 'reified' class called Temp:

<Declaration>
    <Class IRI="#Temp"/>
</Declaration>

Next, two sub-classes called Hot and Cold:

<Declaration>
    <Class IRI="#Hot"/>
</Declaration>

<SubClassOf>
    <Class IRI="#Hot"/>
    <Class IRI="#Temp"/>
</SubClassOf>

<Declaration>
    <Class IRI="#Cold"/>
</Declaration>

<SubClassOf>
    <Class IRI="#Cold"/>
    <Class IRI="#Temp"/>
</SubClassOf>

Now, we can define our datatype property, called tempDegC:

<Declaration>
    <DataProperty IRI="#tempDegC"/>
</Declaration>

I'll also create a couple of individuals which use this property, as follows:

<Declaration>
    <NamedIndividual IRI="#x"/>
</Declaration>

<DataPropertyAssertion>
    <DataProperty IRI="#tempDegC"/>
    <NamedIndividual IRI="#x"/>
    <Literal datatypeIRI="&xsd;double">13.5</Literal>
</DataPropertyAssertion>

<Declaration>
    <NamedIndividual IRI="#y"/>
</Declaration>

<DataPropertyAssertion>
    <DataProperty IRI="#tempDegC"/>
    <NamedIndividual IRI="#y"/>
    <Literal datatypeIRI="&xsd;double">23.4</Literal>
</DataPropertyAssertion>

Note that I haven't asserted which class x or y belong to, just that they have tempDegC of certain xsd:double values.

If we asked a reasoner to classify the ontology at this point, we wouldn't see any new inferences.

What we want is for the reasoner to automatically infer that x belongs to class Cold, and that y belongs to class Hot.

We can achieve this by restricting the definition of the classes Cold and Hot in terms of the datatype property tempDegC, as follows:

<EquivalentClasses>
    <Class IRI="#Cold"/>
    <DataSomeValuesFrom>
        <DataProperty IRI="#tempDegC"/>
        <DatatypeRestriction>
            <Datatype abbreviatedIRI="xsd:double"/>
            <FacetRestriction facet="&xsd;maxInclusive">
                <Literal datatypeIRI="&xsd;double">19.0</Literal>
            </FacetRestriction>
        </DatatypeRestriction>
    </DataSomeValuesFrom>
</EquivalentClasses>

Here, this axiom defines Cold as "any instance which has a tempDegC with a xsd:double value which is <= 19".

Similarly, we can restrict Hot as follows:

<EquivalentClasses>
    <Class IRI="#Hot"/>
    <DataSomeValuesFrom>
        <DataProperty IRI="#tempDegC"/>
        <DatatypeRestriction>
            <Datatype abbreviatedIRI="xsd:double"/>
            <FacetRestriction facet="&xsd;maxInclusive">
                <Literal datatypeIRI="&xsd;double">30.0</Literal>
            </FacetRestriction>
            <FacetRestriction facet="&xsd;minExclusive">
                <Literal datatypeIRI="&xsd;double">19.0</Literal>
            </FacetRestriction>
        </DatatypeRestriction>
    </DataSomeValuesFrom>
</EquivalentClasses>

Here, this axiom defines Hot as "any instance which has a tempDegC with a xsd:double value which is > 19 and <= 30".

Now, with these definitions, asking the reasoner to classify the ontology infers two new statements:

x : Cold

y : Hot

Explanation

A key to obtaining these inferences was the use of EquivalentClasses to define the restriction on Cold and Hot classes. By using EquivalentClasses instead of SubClassOf, we're saying that anything with a tempdegC within the specified ranges belongs in the class.

If, however, we were to instead use SubClassOf in defining the restriction on Cold and Hot classes above, this would only restrict instances of Cold and Hot to abide by the constraint, a so-called necessary condition, in that it is necessary for all instances to abide by the restriction.

In contrast, EquivalentClasses defines both necessary and so-called sufficient conditions: not only must all instances (necessarily) abide by the restriction, but it is sufficient that if any individual (such as x or y) meet the restrictions, that they are also members. It is this sufficient condition which the reasoner uses to infer that x : Cold and y : Hot.

A link to the full example ontology is here. Try loading it into Protege and classify it using the Pellet reasoner plugin.

Note that I tried classifying this ontology with HermiT and FaCT++ which otherwise failed to produce the inferences, throwing exceptions, indicating they do not support such datatype reasoning.