Archive for August, 2007

Understanding SWRL (Part 2): DL Safety

Monday, August 27th, 2007 · Bijan Parsia

In the previous post, I gave a hint at the enormous power of (arbitrary) SWRL rules by showing how they can be used (directly and fairly easily) define various built in OWL constructs. SWRL faces the standard tradeoff for expressivity: loss of efficiency. SWRL is undecidable, that is, there is no algorithm that can, in finite time, compute the whether (for example) an axiom is entailed by a SWRL knowledge base. It is, in fact, semi-decidable—if an axiom is entailed, then there is an algorithm that can show that; but if an axiom is not entailed, it’s possible to “go into an infinite loop”, i.e., not to terminate.

In some future post I’ll explain exactly why, how, and when I think decidability matters, but for the moment, let’s presume that it is a desirable property. Also, we should remember that a critical goal of SWRL is to augment OWL, so we should expect serious users of OWL (e.g., people building large OWL ontologies) to want to use these rules and want to use them in conjunction with a reasoner in their existing ontologies. Thus, it would be good if we could add rule support as an extension of existing reasoners (e.g., Pellet!) and get workable performance.

DL Safety is a simple idea which is implicit in many rule systems (especially those with a database or Prolog connection) and has been used in other contexts to regain decidability: Variables in DL Safe rules bind only to explicitly named individuals in your ontology. Adding this restriction is sufficient to make SWRL rules decidable.

What does this restriction really mean? One way of thinking about it is that it shifts SWRL rules from being a kind of super powerful TBox and RBox (i.e., class and property) axiom to them being a (slightly odd) sort of data manipulation (i.e., ABox) axiom.

Consider the SWRL rule for the ancestor relation (discussed in part 1):


      ancestorOf(?X, ?Z) :- ancestorOf(?X, ?Y), ancestorOf(?Y, ?Z).

As you might recall, this is equivalent to declaring that ancestorOf is transitive property. If we impose the DL Safety restriction on it, then that is no longer true (though they coincidence in some cases; transitive properties are a strict expressive superset of the DL Safe version). Let’s consider a case where the DL Safe and non-DL Safe version of this rule diverge.

Consider a simple chain of ancestors:


    :mary :ancestorOf :sheevah.
    :sheevah :ancestorOf :akane.
    :akane a :AncestorOfACreep.

(Yes, I’ve switched to Turtle syntax because, well, either I’m perverse or the tool chain is perverse. My perversity may lie in using this freaking toolchain!)

We can ask for the ancestors of :akane by making a class that uses nominals:


    :AncestorOfAkane  a owl:Class;
        owl:equivalentClass [a owl:Restriction;
            owl:onProperty :ancestorOf;
            owl:hasValue :akane].

With nothing else in the ontology, the only instance of :AncestorOfAkane will be :sheevah, i.e., the direct ancestor. If we add a owl:TransitiveProperty assertion, or the DL Safe rule above, then :mary will also be found to be an instance of this class. So far so good. But what if we know that :akane has a descendent who is a creep, and we want to know who else is an ancestor of a creep. (Yeah, so I hate Akane’s descendants. Sue me. They’re creepy!)

    :akane a :AncestorOfACreep.
    :Creep a owl:Class.  

:AncestorOfACreep a owl:Class; owl:equivalentClass [a owl:Restriction; owl:onProperty :ancestorOf; owl:someValuesFrom :Creep].
If we are reasoning with the DL Safe rule, then only :akane is an instance of :AncestorOfACreep, because the DL Safe rule does not propagate values to unnamed/unknown entities, and we don’t know any of :akane’s decendents. We only know that she has at least one creepy one.

If we’ve made :ancestorOf transitive (or the rule is interpreted as unrestricted, i.e., not DL Safe), then not only do :mary and :sheevah become instances of :AncestorOfACreep but so do all possible instances of :AncestorOfAkane. So we have a new subsumption relation, as you can see in this screenshot of OWLSight:

OWLSight shows us the subsumption relation between AncestorOfACreep and AncestorOfAkane.

Clicking on the “Why?” button gives us the axioms sufficient to produce the subsumption:

The explanation of the subsumption between AncestorOfACreep and AncestorOfAkane clearly involves the transitivity axiom.

Since Pellet can process DL Safe rules (and backs OWLSight), we can browse the DL Safe rule version of this ontology:

OWLSight displays the lack of a subsumption between AncestorOfACreep and AncestorOfAkane .

As we can see, the only instance of :AncestorOfACreep is :akane, however, all the expected members of :AncestorOfAkane appear:

OWLSight displays the instances of :AncestorOfAkane.

Unfortunately, there is a bug in the explanation finder which, for some reason, thinks that :ancestorOf is transitive: doesn’t understand that SWRL rules are axioms (more on this in a future post):

OWLSight displays only a partial explanation since the explanation finder doesn’t know about SWRL rules.

You can also play with these from the Pellet command line. I have both versions of the ontology available both in Turtle and in RDF/XML (courtesy of Joshua Tabuer’s Validator/Converter—which, alas, is a bit finicky and doesn’t pretty print RDF/XML nicely at all; but hey, it worked). I use the following options:


     ./pellet.sh -if http://www.cs.man.ac.uk/~bparsia/2007/examples/dl-safe-ancestor.txt  -c TREE -r -s off -ifmt N3 

If you use one of the .owl files, you can leave off the -ifmt. You might try commenting out the transitivity axiom to see what things look like with neither rule. When using SWRL syntax, Pellet will throw up a lot of warnings: Just Ignore Them. UPDATE: Thanks to Mike Smith (in comments) for pointing out that -s off will turn off the warnings.

I’ve not tested these with KAON2, which would have some problems with the nominal I’m using instead of a query. You could pretty easily make some SPARQL queries that exhibit the difference.

I used transitivity because it’s a fairly obvious sort of rule and the unrestricted SWRL version can be paraphrased can be in plain OWL. It’s important to note that unrestricted SWRL can say a hell of a lot more than this!

Still to come: DL Safe SWRL rules vs. other sorts of rules; some SPARQL connections; SWRL and SROIQ; builtins; implementation issues; and who knows?

Understanding SWRL (Part 1)

Sunday, August 12th, 2007 · Bijan Parsia

By my rather hasty coding, 9 OWLED 2007 papers mentioned SWRL (or DL-Safe rules) as a need, often a critical need. There’s 1 that goes for DLP, and 5 for SPARQL over OWL (which is closely related to rule extensions). There was also a lively panel devoted to rules and queries, and, last but not least, there is an OWLED task force developing a report on DL Safe rules (and one developing a spec for SPARQL/OWL).

So, “we” want some sort of rules, and all the benefits they bring. SWRL is something of a de facto standard for extending OWL with rules with DL Safe SWRL rules (as I shall canonically call them) being the most commonly implemented varient.

However, it’s also clear that most people aren’t too clear on exactly what the difference is between arbitrary SWRL and DL Safe SWRL (remember that DL Safe SWRL is a restricted version of SWRL). It’s very clear that most don’t understand the consequences for modeling (and definitely not for implementation). It’s a complex topic, so I’m going to have a series of posts. Some of the material overlaps with the part I wrote of a chapter for the new edition of the Ontology Handbook on “Rules and Ontologies”.

So, first, what is SWRL? Syntactically, SWRL is an extension to OWL with a new sort of conditional (i.e., if-then statements). OWL already has several sorts of conditional, e.g., (I’m using OWL 1.1’s functional syntax):


    SubClassOf(Person, ObjectUnionOf(Human IntelligentComputer)) 
    SubObjectPropertyOf(parentOf, ancestorOf) 

The first line says that if you are a Person, then you are either a Human or an IntelligentComputer, and the second says that if you have the parent relation then you have the ancestor relation.

However, for a variety of reasons, OWL conditionals are very constrained and specialized. For example, the SubClassOf conditional can only have class expressions in the “if” or the “then” parts. For example, you can’t mix classes and properties (directly) as in:


    SubClassOf(parentOf, ObjectUnionOf(Human IntelligentComputer)) 

That’s just ill formed. These specialized conditionals have several advantages: They allow for variable free syntax; they are more intention revealing; and they help enforce restrictions which make OWL easier to process (e.g., by making it decidable).

However, there is a price: expressivity. This is especially obvious when it comes to the property conditionals. In OWL 1.0, they were restricted to relations between single named properties. Hence the famous “you can’t define uncleOf in OWL” issue.

SWRL generalized OWL conditionals in two ways:


  1. It allows for arbitrary patterns of variables

  2. It allows for fairly free mixing of expressions (e.g., property and class expressions)


SWRL is like OWL (and unlike many traditional rule languages, e.g., Prolog or Datalog) in that it embraces the open world assumption. There is no negation as failure, among other things, in SWRL. Thus, if anyone says that they “translate” SWRL Rules to Prolog, be wary. This might be a sensible thing to do, but it’s highly unlikely to respect SWRL semantics.

All these facts conspire to make SWRL very expressive. There are lots of built in features of OWL that become redundant in SWRL. Consider transitivity. While OWL has a specific construct to express that a property is transitive (e.g., TransitiveObjectProperty(ancesterOf)), you can encode that directly with SWRL rule:


      ancestorOf(?X, ?Z) :- ancestorOf(?X, ?Y), ancestorOf(?Y, ?Z). 

(I’m using a Prolog like style for the syntax.)

This rule means exactly the same thing as the OWL construct. (Note: Some people think that the rule is “more transparent”, but I think it’s much worse than the simpler OWL construct for a number of reasons, mostly having to do with readability.)

So, (full) SWRL rules are really a kind of OWL axiom. They can make for more expressive property and class axioms (for example, you can’t make classes whose members depend on certain sorts of cyclic structure in OWL, but easily do so with SWRL rules).

In the next post, I’ll explore the DL Safety restriction.

OWLSight is here

Friday, August 3rd, 2007 · Michael Grove

Today we announced the release of OWLSight which is our new lightweight web-based ontology browser. OWLSight is a 100% Java application deployed as a webapp using the magic of the Google Web Toolkit and is powered by our OWL DL Reasoner Pellet. OWLSight is intended to serve as an online demo of Pellet and to provide quick and easy access to its services and to be a testbed for experimental and upcoming features of Pellet. One of the big attractions for OWLSight is its easy, hyperlink based navigation, and its explanation facility; while browsing your ontology you can recieve explanations for inferred axioms by simply clicking the “Why?” button next to the axiom. We hope OWLSight provides users with an easy way to browse an ontology and to try out Pellet. OWLSight is still experimental, we’re still working towards an alpha release, but we wanted to get a preview version out there for people to use now. We look forward to hearing your feedback.