2

I am looking for a Jave implementation of Datalog that does not evaluate unnecessary rules. I looked at IRIS reasoner which seems to be the most stable one.

However, it evaluates all the rules rather than only the ones being used. As an example:

parent('homer', 'bart').
parent('abe', 'homer').
ancestor(?a, ?b) :- parent(?a, ?b).
ancestor(?a, ?b) :- ancestor(?a, ?c), ancestor(?c, ?b).

// query.. find all parent-child pairs.
?-parent(?x, ?y).

I find that IRIS computes the relation ancestor even if it is never used.

What other implementations are available for Java? Do any of those perform this optimization?

Jus12
  • 17,824
  • 28
  • 99
  • 157

2 Answers2

0

Quote from the IRIS website that the OP linked to:

The following program optimisations are supported: - Rule filtering (removing rules that do not contribute to answering a query) - Magic sets and sideways information passing strategy (SIPS)

0

There is an option for this in IRIS,

From here

import org.deri.iris.optimisations.rulefilter.RuleFilter;
import org.deri.iris.Configuration;

Configuration config = new Configuration();
config.programOptmimisers.add(new RuleFilter());

However, I could not get this to work. I get a "loop exception" in the underlying JGraphT library used.

Finally, I ended up writing my own rule filter. It is not difficult. We need to ensure that we only include rules that are referenced in the tail of rules leading to the final relation.

Jus12
  • 17,824
  • 28
  • 99
  • 157