Rules

The rule engine in Mulgara is called "Krule", so named because it was originally the "Kowari Rules Engine".

Apply Command

Rules in Mulgara are available as a TQL command. The format of the command is:

  apply <ruleGraph> to <dataGraph>;

If you want entailed data to go into a different graph, then use:

  apply <ruleGraph> to <dataGraph> <entailmentGraph>;

Rule application can be viewed as a batch operation. Rules are only ever applied as a result of running the apply command. No entailments are ever made automatically. This is a feature that is being considered, but we are cautious about it, as it will have significant performance implications.

Result of Applying Rules

When rules are applied to a graph, every possible entailment is generated and stored. When fundamental schemas such as RDFS are applied, the level of detail can be surprising, with a number of overly obvious entailments, along with a few unexpected ones. If a separate entailment graph is used, then it is very common for a lot of the original data to be entailed, as internal consistency often refers to some level of redundancy to the information.

Rule application is an idempotent operation. This means that Rules can be run multiple times with no consequences. Consequently, rules can be re-applied after loading new data, with no impact on existing data or existing entailments.

For the moment, Mulgara does not do any kind of consistency checking. This is expected before the end of the year (2008).

The Rules Graph

As with most rule systems, Mulgara rules are based on Horn clauses. The internal structure is represented as an RDF graph which represents these clauses. Once a rule graph is loaded, it is applied using the URI of the graph containing the rules.

The format for rules is defined in the rules/RuleFormat.txt file in the source distribution. The schema/ontology for this format is described in rules/krule.owl. Unfortunately, this format is verbose and very specific. This can make rules tedious to write and difficult to debug.

RDFS Rules

A graph describing the RDFS entailment rules is found in the Mulgara sources as rules/rdfs-krule.rdf. An example for using this is given in the script in rules/example.itql.

RLog

To make it easier to create rule files, a tool called RLog has been developed. This is a program that takes a set of Prolog-like Horn clauses and converts them to a valid RDF/XML file that can be loaded as a rule graph. RLog will eventually be integrated into Mulgara, allowing files with horn clauses to be applied directly to graphs, without an intermediate conversion step.

RLog is available for download from the Mulgara site.

The latest development version can also be accessed via Subversion:

  svn co http://mulgara.org/svn/rlog/trunk rlog

Details on running RLog are provided in the README file. An implementation of RDFS entailment is also provided as an example script.

While a lot more is planned for both the rules engine and RLog, development is currently slow, as the developers are hard at work on the main Mulgara project.