RIF4J is a reasoning engine for RIF-BLD that provides a Java object model for RIF-BLD and supports the parsing and serialization of RIF-BLD formulas. Furthermore, it provides a prototype implementation of a RIF-BLD consumer based on the Datalog engine IRIS. It is an open-source library licensed under the Apache License 2.0 and hosted on Sourceforge.


RIF4J is developed as an Apache Maven project and is being deployed on a daily basis to the STI Maven repository. To get releases and snapshots of RIF4J and the dependent components, the following repositories have to be added to the project object model (POM) file:


The object model, parser and serializers can be used by by adding at.sti2.rif4j:rif4j-impl as dependency to the POM file:


In order to use the prototype reasoner based on IRIS, the following dependency needs to be added to the POM file:


For reasoning with combinations of RIF and RDF under the Simple Entailment semantics, the following dependency needs to be included:


Usage Example

import java.net.URI;

import at.sti2.rif4j.condition.Formula;
import at.sti2.rif4j.manager.DocumentLoadingException;
import at.sti2.rif4j.manager.DocumentManager;
import at.sti2.rif4j.reasoner.Reasoner;
import at.sti2.rif4j.reasoner.ReasonerFactory;
import at.sti2.rif4j.reasoner.ReasoningException;
import at.sti2.rif4j.reasoner.iris.IrisRifReasonerFactory;
import at.sti2.rif4j.rule.Document;

public class Example {

    public static void main(String[] args) throws DocumentLoadingException,
            ReasoningException {
        // The URI of the premise document.
        URI premiseUri = URI
                        + "tc/Class_Membership/Class_Membership-premise.rif");

        // The URI of the conclusion formula.
        URI conclusionUri = URI
                        + "tc/Class_Membership/Class_Membership-conclusion.rif");

        // Use the DocumentManager to load the premise and the conclusion.
        DocumentManager manager = new DocumentManager();
        Document premise = manager.loadDocument(premiseUri);
        Formula conclusion = manager.loadFormula(conclusionUri);

        // Create a RIF-BLD reasoner based on the IRIS Datalog system.
        ReasonerFactory factory = new IrisRifReasonerFactory();
        Reasoner reasoner = factory.createReasoner();

        // Register the premise document.

        // Check if the premise entails the conclusion.
        boolean entails = reasoner.entails(conclusion);

        if (entails) {
            // Do something.