Representing if-then sentence using OWL?
Asked Answered
P

2

8

I am working with basic OWL, and it's quite easy to represent some simple sentence like "Songoku is a lecturer, he teaches Maths".

E.g.:

<owl:Class rdf:ID="Lecturer"></owl:Class>
<owl:Class rdf:ID="Subject"></owl:Class>
<owl:Property rdf:ID="teach">
   <rdfs:domain rdf:resource="#Lecturer"/>
   <rdfs:range rdf:resource="#Subject"/>
</owl:Property>

<Subject rdf:ID="Maths"></Subject>
<Lecturer rdf:ID="Songoku">
    <teach>
        <Subject rdf:about="#Maths"></Subject>
    </teach>
</Lecturer>

But I faced a problem when I tried to represent this sentence: Bob is a Student, If Bob has 5 dogs, then he has at least 1 cat..

Can you tell me some suggestion?

Pyrostat answered 11/5, 2013 at 10:58 Comment(9)
The RDF snippet in the question doesn't expression "Songoku is a lecturer, he teaches Maths," it just says "Lecturer is an OWL class. Subject is an OWL class. teach is a property with domain Lecturer and range Subject."Monnet
Ah, good to see that. :) Does the provided answer suit you?Monnet
Thanks, the answer was suit what I ask :) And now I will try to represent some sentence like If Bob weighs 60Kg, then he highs 180cm by myself. (it's different from first sentence, because it does not mention about cardinality any more,right?)Pyrostat
It is different, yes. You could use some of the datatype facets to say something like "If Bob weighs at least 60kg, then his height is at least 180cm," too.Monnet
Hi, you're there? If the values are discrete, (for instance, age), I can represent sentences by using owl:oneOf, but with continuous values, how to represent "at least" or "greater than"? (Sorry if you think this stupid, but in my book about owl, it doesn't mention about this, and I do look it up on the Internet and nothing found)Pyrostat
I'm on mobile at the moment, but when I'm back, I'll update the answer with an example of restrictions on datatype properties, such as hasHeight.Monnet
I've updated my answer with an example relating to datatype properties.Monnet
Thank you :) Thanks to your help, I've done my job :)Pyrostat
No problem! Thanks to my job, I've been able to help!Monnet
M
18

You can represent some fairly complicated conditional sentences in OWL using general subclass axioms. Let's look at a few examples. If you were trying something a little bit simpler, say

Students with at least five dogs have at least one cat.

which is shorthand for the quantified conditional "For all x, if x is a student with at least five dogs, then x has at least one cat, you can do this in OWL with

(Student and hasPet min 5 Dog) subClassOf (hasPet some Cat)

Those are both anonymous class expressions, but you could define some equivalent classes to make some things simpler:

StudentWithAtLeastFiveDogs equivalentClass (Student and hasPet min 5 Dogs)
CatOwner equivalentClass (hasPet some Cat)
StudentWithAtLeastFiveDogs subClassOf CatOwner

Now, your example was Bob is a Student, If Bob has 5 dogs, then he has at least 1 cat. There are two sentences there. The first is easily encoded by

Bob a Student

The second is a bit more complicated. You're saying that Bob is a member of the class of things which, if they have at least five dogs, they have at least one cat. A (material) conditional "If P then Q" is logically equivalent to the disjunction "(not P) or Q". So we're saying that Bob is a member of the class of things that either do not have at least five dots or that do have at least one cat. The class expression for that is

(not (hasPet min 5 Dog)) or (hasPet some Cat)

Now our knowledge about Bob is that

Bob a Student
Bob a (not (hasPet min 5 Dog)) or (hasPet some Cat)

You could define an equivalent class for that anonymous class expression, but I doubt it will be rendered very naturally in most languages. Here's what an ontology containing that knowledge about Bob looks like (in the N3 format):

@prefix :        <http://www.example.com/example#> .
@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#> .

<http://www.example.com/example>
      a       owl:Ontology .
:Cat  a       owl:Class .
:Student
      a       owl:Class .
:Dog  a       owl:Class .
:hasPet
      a       owl:ObjectProperty .
:Bob  a       :Student , owl:NamedIndividual ;
      a       [ a       owl:Class ;
                owl:unionOf ([ a       owl:Class ;
                            owl:complementOf
                                    [ a       owl:Restriction ;
                                      owl:minQualifiedCardinality
                                              "5"^^xsd:nonNegativeInteger ;
                                      owl:onClass :Dog ;
                                      owl:onProperty :hasPet
                                    ]
                          ] [ a       owl:Restriction ;
                            owl:onProperty :hasPet ;
                            owl:someValuesFrom :Cat
                          ])
              ] .

This same approach can be used for datatype properties and restrictions on their values. For instance, to say that "if Bob weighs at least 60kg, then he is at least 180cm tall," we can say that Bob is an element of the class of things that, if they weight at least 60kg, then they are at least 180cm tall, or equivalently, the class of things that either do not weight at least 60kg, or that are at least 180 cm tall. In the Manchester syntax, the class expression looks like

(not (hasWeight some int[>= 60])) or (hasHeight some int[>= 180])

The relevant portion from the N3 serialization of the ontology is:

:Bob  a       [ a       owl:Class ;
                owl:unionOf ([ a       owl:Class ;
                            owl:complementOf
                                    [ a       owl:Restriction ;
                                      owl:onProperty :hasWeight ;
                                      owl:someValuesFrom
                                              [ a       rdfs:Datatype ;
                                                owl:onDatatype xsd:int ;
                                                owl:withRestrictions
                                                        ([ xsd:minInclusive 60
                                                          ])
                                              ]
                                    ]
                          ] [ a       owl:Restriction ;
                            owl:onProperty :hasHeight ;
                            owl:someValuesFrom
                                    [ a       rdfs:Datatype ;
                                      owl:onDatatype xsd:int ;
                                      owl:withRestrictions
                                              ([ xsd:minInclusive 180
                                                ])
                                    ]
                          ])
              ] .
Monnet answered 11/5, 2013 at 13:9 Comment(4)
So, @Joshua Taylor, I should define 3 classes: Student (base class), Anon1 (student not hasPet min Dog - subclass of Student), Anon2 (Student hasPet some cat - subclass of Student too), also, Anon1 and Anon2 are disjoint (by using keyword owl:disjointWith), right?Pyrostat
Well, you don't need to define those classes (i.e., by having some named class that is owl:equivalentClass to the anonymous class expression), and you don't need to state the that classes are disjoint either. After all, someone might not have five dogs, but they could still have a cat, in which case they would be an Anon1 and an Anon2, which would be inconsistent if you make those classes disjoint.Monnet
@Songokute I've updated the answer to show what this "knowledge about Bob" looks like in an ontology where the only named classes are Student, Cat, and Dog. I didn't define the anonymous classes with any owl:equivalentClass.Monnet
Thanks for your enthusiasm :) Thank you very much! I will read more to comprehend OWL, and your answers help me very much :)Pyrostat
B
4

This is a text in Attempto Controlled English (ACE):

Bob is a student. If Bob has 5 dogs then Bob has at least 1 cat.

and it has this representation in OWL:

ClassAssertion(
  :student
  :Bob
)
SubClassOf(
  ObjectIntersectionOf(
     ObjectOneOf(
        :Bob
     )
     ObjectMinCardinality(
        5
        :have
        :dog
     )
  )
  ObjectSomeValuesFrom(
     :have
     :cat
  )
)

which can be computed automatically with the ACE parser (APE). So, if you have managed to conceptualize your statement in English, it's worth checking if the ACE parser can map it automatically to OWL, see the online demo of the ACE parser.

Barbabas answered 16/5, 2013 at 16:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.