Why do we need SWRL and RIF in an OWL2 world?

What are the limitations of OWL 2, i.e. in which cases do we require a rule language such as SWRL? If SWRL was developed to address the shortcomings of OWL 1 (e.g. no property chains), do we really need it in addition to OWL 2, or is it just another way of expressing the same things?

Additionally, my understanding is that RIF is not really a rule language (although you can use it to construct rules), but rather a way of converting existing rule languages to vocabularies.

Maybe I'm confusing my rules with my ontologies, but I have this idea that anything that can be represented using SWRL or RIF, could also be represented in OWL 2.

OWL addresses a fairly small problem space. Basically those classification problems that can be expressed using Description Logic (tractable subsets of FOL). Most applications will need to augment OWL with rules that either cannot be implemented with OWL or will be prohibitively difficult to do so. As a simple example, try using OWL inferences to infer that anyone with a firstname and lastname also have a fullname in the format .

It's certainly not the case that anything that can be represented in a rule system, such as RIF or SWRL, can also be represented in OWL. Rules will always address a larger part of the solution space as rule systems are not concerned with consistency with certain logic profiles. OWL and rules are separate entities and have their own place in the solution space.

I admittedly don't know as much about RIF as I might want. A follow-on question I have is why we need RIF and SWRL when SPARQL can express rules with CONSTRUCT. Rule interchange is a good idea, but parts of RIF seems to be a heavy solution to a problem already solved by SPARQL.

Also note that the OWL 2 RL profile spans the gap for OWL inference vs. rules. It addresses a significant subset of OWL 2 and is fully specified as rules. This not only makes it easily implementable - there are plenty of rule engines that work on triples, including SPARQL - but also allows both OWL and rules to be implemented in the same rule language.

Other answers have covered the the main part of the question, that rules do indeed allow you to express things that can't be expressed in OWL 2.

However, I wanted to answer some of the embedded "what is RIF" questions.

gerrit : "my understanding is that RIF is not really a rule language (although you can use it to construct rules), but rather a way of converting existing rule languages to vocabularies".

No, RIF is a format to allow rules to be interchanged, i.e. you can take rules out of one rule engine translate them to RIF, publish them, someone else can then translate them to their own rule engine and run them. Since it provides an exchange syntax and a semantics then it is also a rule language it is own right so someone could come along and implement RIF from scratch rather than implementing a translator if they wanted to.

Note RIF is actually an extensible family of rule languages not a single language. There is a production rule dialect (RIF PR) suited for exchange of business rules, a logic programming dialect (RIF BLD) which includes equality and a core dialect (RIF Core) which is the intersection of the two.

scottheninger : "A follow-on question I have is why we need RIF and SWRL when SPARQL can express rules with CONSTRUCT."

First, RIF is not specific to RDF. Indeed a lot of the motivation for RIF comes from exchange of business rules which are typically production rules running over XML or object data structures. SPARQL isn't really appropriate or sufficient for either the data or the semantics in that case.

Second, SPARQL Construct is not itself a rule language. As formally specified it just allows you to make a one step transformation from one graph match to another graph. It is true that you can then iteratively apply a set of SPARQL constructs and think of that as a rule language. However, you have to actually specify how that iteration is set up, how recursive rule behave, when the results of one iteration are made available (especially given that SPARQL in effect has negation-as-failure). This can be done in various ways which will have different implications. Axel Polleres has papers on this such as SPARQL Rules! which define a rule extension of SPARQL Construct using Answer Set semantics. TopQuadrant have their SPIN language which is based on using SPARQL Constructs but with different semantics[*].

Third, even restricting oneself to rules over RDF then RIF allows you to express things which you can't express as iterative SPARQL Constructs. Of course RIF BLD and RIF PR are each more expressive in their own way but even within the simple horn rule RIF Core dialect then are some useful extras. You have more builtins (e.g. list operators) and you have n-ary predicates which solve a lot of problems with building intermediate results which things like Jena Rules have to hack around with hidden predicates.

All that said, I think it would be really valuable to develop a SPARQL-friendly RIF Core syntax which would then make the links between iterated SPARQL and RIF clearer. RIF then brings a defined rule semantics, extra builtins and n-ary relations; SPARQL brings a friendly syntax for RDF developers and a simple route to a (brute force) implementation for at least a partial implementation.

[*] I believe SPIN that is based on a procedural semantics of iterative applications but don't know the details and don't know whether things like "refraction" and the conflict set resolution machinery of production rules is included.

Just to add to the answers already given, The intuition behind the expressive restrictions of DL are that the models we care about are 'tree-shaped', function symbols (and 'built-ins') are excluded, the arity of predicates are restricted (binary and unary predicates only), and the interpretation of negation assumes that the data is incomplete (OWA v.s. CWA). Depending on your domain these restrictions might require the need for rule languages (which share a common lineage with the knowledge representation underlying database theory - horn clause logic)

In practice, I often need to use rules in the following situations:

  • Where I need built-ins (such as those defined for CWM/N3)
  • Where closed world assumption negation is more appropriate (where we are dealing with complete data)

There are two references I would suggest that do a decent job in the differences in the expressive restrictions underlying both approaches to knowledge representation (DL and horn clause logic):

A quick superficial difference: SWRL and RIF contain built-ins that cannot be "emulated" in OWL 2. So you could not, for example, define the class of Minor as a subclass of Person whose members' ages' are less than eighteen. (see here instead).

To me, OWL 2 and (e.g.) SWRL are orthogonal and suited to different tasks. You can enable certain types of inferences very elegantly in SWRL which would require fairly verbose OWL 2 -- and vice-versa.

As for RIF: the clue is in the acronym... RIF simply provides a common format for interchanging rules.

One does not make the other redundant.