The OWL-using world wanted 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 variant.
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
conditional can only have class expressions in the “if” or the “then”
parts. For example, you can’t mix classes and properties (directly) as
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:
- It allows for arbitrary patterns of variables
- 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.