How to express numeric intervals in datatype prope

2020-03-04 07:48发布

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

1条回答
ゆ 、 Hurt°
2楼-- · 2020-03-04 08:36

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.

查看更多
登录 后发表回答