Drools vs. Pellet for SWRL rules
Updated: Nov 8, 2022
One of the most common things that new users of the SWRLTab in Protege do is use the three buttons at the bottom of the window: "OWL + SWRL ->Drools", "Run Drools", and "Drools->OWL" to run their SWRL rules. This post explains the difference between using Drools and using the Pellet reasoner and why using Pellet is usually the better option.
SWRL is meant to be an extension of OWL so the standard way to run SWRL rules is to just run a reasoner that supports the W3C SWRL specification. Unfortunately, most reasoners at this point don't support the specification. The only one that does is the Pellet reasoner which is not the default reasoner for Protege. So to run your rules as part of running the reasoner you need to download the Pellet plugin and then select it as your reasoner in Protege. Once you do this then you can completely ignore those Drools buttons at the bottom. Your rules will run every time you run the reasoner, just as any other inferences about properties or class definitions.
The reason those buttons are there is because Drools can be useful for specific purposes. For more detail on Drools I recommend this paper by Martin O’Connor and Amar Das. However for the average user Pellet is a better choice.
There are two reasons Pellet is usually preferable to Drools.
Because Pellet fires SWRL rules as part of the reasoner, any inference caused by a rule will be highlighted in yellow (just as any other inference). Also, just like any other reasoner inference, it will have a "?" next to it so that the user can click on the "?" and get an explanation of which rule(s) or other axioms caused that inference. These capabilities are lost when one uses Drools. Drools asserts new information into the ontology as axioms which to Protégé look the same as other user defined axioms. Hence the fact that an axiom was inferred by a rule rather than stated by the user is lost as is the ability to understand what specific rules caused the inference.
Drools is a kind of theorem prover and like most such engines it keeps churning away inferences until it can't churn anymore. This can result in a lot of redundant information being added to your ontology. For example, suppose you define a simple class hierarchy where Mammal is a subclass of Animal and Dog is a subclass of Mammal. The reasoner will infer that Dog is a subclass of Animal because the subclass relation is transitive. However, the Protégé UI won't show this information because it is redundant. However, suppose you run your SWRL rules using the Drools buttons. Drools will churn away making every inference it can including that Dog is a subclass of Animal. After running Drools you will have this redundant information added to your ontology because to Protégé it looks as if you have specifically stated that subclass information and Protégé shows all user declared information even if as in this case it is redundant.
For these reasons it is usually best to use Pellet to run your SWRL rules rather than Drools. Drools can be useful for specific purposes that are mostly for more advanced users. For example the experimental builtin makeOWLThing is only supported by Drools. A good rule of thumb is: if you don't know of a good reason to use Drools then stick to Pellet.