Sparql servers, part 3


Now, the critical thing that I really want/need this pellet reasoner to do is to handle property chains that are made conditional by way of the inclusion of derived reflexive properties. Am I being unreasonable? No: I am not.

We have taxa. I’ll name ’em with an initial ‘t’: tA, tB, tC. Taxa have relationships, which are done as relationship objects. They are not done as predicates because they contain a fair bit of extra info: principally, the “asserted by”. For our accepted taxonomy, we are interested in parent/child relationship objects.

We want to turn these relationship objects into relationship predicates inside a custom vocabulary. We then want to make these predicates transitive – let’s make it a new predicate, call it “cladeIncludes” (yes, I know they aren’t really clades because the birds aren’t included in the reptiles). The effect of this will be that SPARQL query
{ :LEPIDOPTERA cladeIncludes ?t} {?t hasWingColour :YELLOW}

Will get us all the yellow butterflies, and not other things that might have yellow wings.

First: some raw data, which we shall put in a graph (I won’t bother with loading it into SDB at this point).

:Taxon a owl:Class . :hasRelationship a owl:ObjectProperty . :rtype a owl:ObjectProperty . :toTaxon a owl:ObjectProperty . :wingColour a owl:DatatypeProperty . :childOf a owl:NamedIndividual . :excludes a owl:NamedIndividual . :tLepidoptera a :Taxon , owl:NamedIndividual . :tButterflies a :Taxon , owl:NamedIndividual ; :hasRelationship [ :rtype :childOf ; :toTaxon :tLepidoptera ] . :tYellowButterflies a :Taxon , owl:NamedIndividual ; :wingColour "Yellow" ; :hasRelationship [ :rtype :childOf ; :toTaxon :tButterflies ] , [ :rtype :excludes ; :toTaxon :tBlueButterflies ] . :tBlueButterflies a :Taxon , owl:NamedIndividual ; :wingColour "Blue" ; :hasRelationship [ :rtype :childOf ; :toTaxon :tButterflies ] . :tAves a :Taxon , owl:NamedIndividual . :tYellowBirds a :Taxon , owl:NamedIndividual ; :wingColour "Yellow" ; :hasRelationship [ :rtype :childOf ; :toTaxon :tAves ] . :tBlueBirds a :Taxon , owl:NamedIndividual ; :wingColour "Blue" ; :hasRelationship [ :rtype :childOf ; :toTaxon :tAves ] .

Ok, no problem, and Joseki serves it up. … Now, lets create an empty ontology document and hook it up to Pellet. Fine. Let’s populate that ontology document with our classes and properties … done.

Right. At this stage I can open the vocabulary with protege and begin making rules.

First, a simple property chain. That’s stage 1. If pellet can’t manage that, then no point going further. If X hasRelationship FOO toTaxon Y, then X isRelatedTo Y.

:isRelatedTo a owl:ObjectProperty ; owl:propertyChainAxiom (b:hasRelationship b:toTaxon) .

loads … ok. Is the “is related to” triple there? … YES!

Awesome! Pellet does property chains. Now, I need more than a “is related to”. I specifically need an “isChildOf” property to be derived from only those relationship objects that have rtype :childOf. We don’t want to include the “excludes” relationship between tYellowButterflies and tBlueButterflies. Can I make these property chains conditional by adding a derived reflexive property?

First, create a class for “child of” relationship objects

:ChildofRelationship rdf:type owl:Class ; owl:equivalentClass [ rdf:type owl:Restriction ; owl:onProperty b:rtype ; owl:hasValue b:childOf ] .

… yes, pellet seems to be inferring that certain anonymous objects are of this type. I’ll assume it’s getting it right.

Next: create a reflexive property with a domain of ChildofRelationship

:iAmAChildofRelationship rdf:type owl:ObjectProperty , owl:ReflexiveProperty ; rdfs:range :ChildofRelationship ; rdfs:domain :ChildofRelationship .

… Yes! pellet is inferring the existence of these properties!

Now, create a childOf predicate over the property chain “hasRelationship iAmAChildofRelationship toTaxon”.

:childOfT a owl:ObjectProperty ; owl:propertyChainAxiom (b:hasRelationship :iAmAChildofRelationship b:toTaxon) .

And now pellet should infer that yellowButterflies are butterflies, but not that blue butterflies are yellow butterflies …

select ?c ?r ?p where {graph <; { ?c <; ?p . } }

Arrgh! No! It has incorrectly concluded that yellow butterflies are blue butterflies! Back to the drawing board. I’m going to need some more complex SPARQL to work out what went wrong.

select ?o where { graph <; { ?o <; <; } }

Woah! Pellet has decided that Everything is of type “ChildofRelationship”. I’ll bet I know why. Let’s remove that reflexive property …

Oh, doh! I forgot how to do it correctly – the mechanism is to use “has as self”.

:ChildofRelationship a owl:Class ; owl:equivalentClass [ a owl:Restriction ; owl:hasSelf "true"^^xsd:boolean ; owl:onProperty :iAmAChildofRelationship ] ; owl:equivalentClass [ a owl:Restriction ; owl:hasValue b:childOf ; owl:onProperty b:rtype ] .

… Win! Pellet has inferred that “childOfT” relationships exist only where they should.

Now, then.

property “inCladeT”. We want to infer it:

  • Reflexively on all taxa
  • for all childOfT relatopnships
  • transitively. This is the biggie.
:inCladeT a owl:TransitiveProperty , owl:ObjectProperty . :childOfT a owl:ObjectProperty ; rdfs:subPropertyOf :inCladeT ; owl:propertyChainAxiom (b:hasRelationship :iAmAChildofRelationship b:toTaxon) . b:Taxon rdf:type owl:Class ; rdfs:subClassOf [ rdf:type owl:Restriction ; owl:onProperty :inCladeT ; owl:hasSelf "true"^^xsd:boolean ] .

WARNING: Unsupported axiom: Ignoring transitivity axiom due to an existing self restriction for property inCladeT

Arrgh! Arrgh! So close, and yet so far! One thing left to try – simulating transitivity with a property chain. I think it might work because I think that pellet ignores transitivity not because there’s an OWL-DL issue, but because it’s a default to improve performance.

… nope. It still doesn’t like it. Ok. How about if I remove the self thing? We don’t really need it – it just means that a clade won’t include the root taxon.

… nope. It’s not complaining, but neither is it deducing that blue and yellow butterflies are lepidopterist, which is the point of the exercise. Can I add transitivity back?

… Nope. Get rid of the subproperty relationship and make it a property chain?

… Nope. And I don’t know what I have done, but now it isn’t complaining anymore when I expect it to be complaining, which is bad news.

Only partial success. We may have to simply generate the accepted taxonomy – the transitive closure of our child-of relationships – as data. Not as big a deal as it may appear.

Going home.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: