Reasoning with SWRL Rules

Hi Stardog Community,

I have having trouble reasoning with a OWL+SWRL ontology in Stardog.

Say we have the following hierarchy:

  • Fruit
    • Apple
    • Orange

In the ontology, we have the following rule:

Fruit(?x) ^ Fruit(?y) ^ isFromSameFruitTreeAs(?y, ?x) ^ colorOf(?z, ?x) -> colorOf(?z, ?y)
This rule says that if two peices of fruit are from the same tree, then they are the same color (perhaps not true but let's say it is for this example).

Then say, for example, I have an two individuals of type Apple that are from the same tree. If apple ?x in red, then the rule should infer that apple ?y is red.

This works alright when I run it in Protege. However, when I move to Stardog this inference is not made (using the SL reasoner). However, the rule does work if I remove the part of the rule that says Fruit(?x) ^ Fruit(?y).

I may be missing something here. It seems that the class inference (Apple is a Fruit) not included in the rule inference.

I was wondering what the issue could be here? Am I doing something wrong or is this just how the SL reasoner works?

Kind Regards,

Hi Caitlin,

Thanks for the report. Nothing looks wrong in what you're doing. Do you mind sharing your example data to make it easier for us to reproduce the issue?


Thanks for the quick response!

fruit-example.ttl (4.8 KB)

Attached is a .ttl file that causes this issue for me.

Here is the query that I run in stardog to realise this issue.

prefix o:
SELECT ?fruit ?color
?fruit o:hasColor ?color;

Kind Regards,

Turns out it's indeed the case that you cannot have type patterns in the recursive rule's body, see here: User-defined Rule Reasoning | Stardog Documentation 7.6.2 (specifically, bullet 3)

Let us know if you need help working around that limitation.