Logan: Supporting Inference over Named Graphs

Logan is an extension to NG4J (Named Graphs for Jena) that uses the Jess rule engine to support inference over Named Graphs.

The current release is version 0.81. Download Logan.




Logan is used in exactly the same way as any other NG4J application. The only difference is how the graph set is constructed. To get up and running:

  1. Add the jar files in the distribution (logan-0.8.jar and everything under the lib directory) to your classpath.
  2. Obtain a copy of Jess (see the download section) and add it to your classpath.
  3. Create the graph set in your Java code as follows, passing the constructor any rule files to be loaded:

Data can then be loaded into the model, manipulated, and queried as per any other NG4J application.

Using the Reasoner

Using the reasoner requires some familiarity with Jess. Logan works by representing all quads in memory as Jess Facts, against which rules can be defined.

Each Quad Fact is represented by a data structure consisting of 7 slots: graph, subject, predicate, object, literal, lang, and datatype.

Not all of these slots are used in any given Quad representation. Specifically:

Inference Example

This section illustrates the use of Logan via a simple example.

Using properties from the Ontonym person ontology, we define a generic rule to say that the brother of a person’s parent is that person’s uncle. More formally: parentOf(x, y) and brotherOf(z, y) => uncleOf(x, z).

we encode this using Jess as follows:

We save this as “uncle.clp” in the root of the project directory and pass it as a parameter when creating a graph set:

and create three people, Sam, Richard, and Christopher:

We then assert that Christopher is Richard’s brother, and that Richard is Sam’s father:

Now we can query to see if Sam has an uncle:

This prints “Sam has uncle: http://example.org/christopher” to the console.

We can also use SPARQL to inspect the quad store:

This prints “urn:inferred { http://example.org/christopher is the uncle of http://example.org/sam . }” to the console.

We can see the full contents of the quad store by printing out the complete model. The following prints out the model using TriG syntax:

which  gives us:

Rule Sets

What use an inference engine without some rules? Rule sets providing support for RDFS and OWL models will be distributed in the next release of Logan. For now, they are available to download here:


Logan version 0.81 can be downloaded from its Google Code project page and is licensed under the terms of the Berkeley Software Distribution (BSD) License.

Logan requires both NG4J (included) and Jess (not included) to operate.

  • Version 0.9.3 of NG4J is contained within the Logan distribution. Please visit the NG4J website for more details about the project.
  • Logan uses version 7.1 of Jess. Jess is not available for Open Source licensing under any GPL license. To license and download Jess, please visit the Jess website.

In The Pipeline

The next steps are to release rule sets for RDFS and OWL and to extend Logan with persistence support.


Found a bug? Please report it using the issue tracker.

Any other comments? Please email me using the details below.


Logan is an extension to NG4J (Named Graphs for Jena) that uses the Jess rule engine to support inference over Named Graphs. The current release is version 0.8. Download Logan.