YSR – Semantic Web Prolog Reasoner

YSR (Yet another Semantic web Reasoner, pronounced “Wiser”) is a very simple but yet high performant RDFS and OWL reasoner that I have developed in 2009 when I was still a master student. It uses the SWI-Prolog suite, and it allows the user to do rule based RDFS and OWL reasoning over RDF data.

Initially it was developed as a reasoner to be used within the MaRVIN project. Since MaRVIN is a project written in Java and the reasoner is written in Prolog, a web interface was developed so that the two programs could exchange data using the HTTP protocol.

A logic programming language like Prolog matches very well with rule based reasoning because the reasoning rules can be encoded in a straightforward way. The SWI-Prolog suite was chosen among the others because it offers a complete and high performant environment. YSR can exchange data either using the RDF/XML format or using the specific binary format used in the semweb package.

The reasoner has good performance, not only when it is used as a library within an existing SWI-Prolog program but also when it is launched as standalone program. The binary format is specifically designed to reduce the up/downloading time and all the single rules were optimized in order to minimize the execution time.

The purpose of this page is to describe the program and report a minimal documentation for it. Of course, if you need more information don’t hesitate to contact me.


YSR uses the semweb package contained in the SWI-Prolog suite to load and store the triples. The package http is used for the web interface. The reasoner can be used as:

  • a library called by an external SWI-Prolog application
  • or as a standalone program. In this case the external application communicates with the reasoner using the HTTP protocol

Use YSR as a library within a SWI-Prolog application

This way is the simplest and the fastest. The module closure contains the predicate compute_closure/2 that can be used to compute the closure. The predicate compute_closure/2 requires two arguments: ruleset and steps.

  • Ruleset contains the ruleset we want to apply. It that can be rdfs_entailed for RDFS reasoning or owl_entailed for ter Horst OWL reasoning.
  • Steps is a variable that will contain the number of executed cycles after the predicate is executed.

After the closure is computed the derived triples are stored under the graph “entailed” and they can be retrieved using the standard predicates of the semweb package.

Use YSR as a standalone program

YSR can be launched as a standalone program. In this case the reasoner communicates with the other applications with the HTTP protocol.

YSR is started with the script run.pl. This script launches a web server on the localhost at the port 3020. If we open the browser and go to http://localhost:3020 we can see a very minimal web interface of the program.

A typical usage of the program is shown in the figure below.


First the user uploads some RDF data into the reasoner using an HTTP POST call at the URL http://localhost:3020/upload. If we encode the data using the binary format we need to set the mime type of the data as application/quickrdf. Otherwise, if we want to upload data in the RDF/XML format then we need to set the mime type as application/rdf+xml.

After the data is uploaded the user can proceeds to compute the closure. To do so, he simply calls the function by connecting to the URLhttp://localhost:3020/closure. We can specify what kind of reasoning we want to perform by adding some parameters to the URL. The parameters are:

language can be rdfs in case we want to apply rdfs reasoning or owl in case of OWL reasoning
completeness This parameter refers to RDFS reasoning. By default is set to false. If set to true it applies all the rules of the RDFS ruleset, even the ones considered “uninteresting” (like the one that says that every resource is type Resource, etc.).

After the closure is computed, the user can download the derived data at the URL http://localhost:3020/download. Again, by setting some parameters we can refine our request. The parameters are:

format The format in which the data should be returned. It can be xml in case we want the data in RDF/XML format or binary in case we want the data in the binary format.
graph With this parameter we can indicate which triples we want to be returned. If we leave it unspecified the program will return all the stored triples. If we set it to input the program will return only the triples that were uploaded. If we set to entailed the program will return only the derived triples.


The program is licensed under the Apache 2.0 license and it is available here.


During the development of this program I received a great help by Jan Wielemaker who helped me through all the development to solve the problems and to improve the performance. I also thank very much Willem van Hage for discovering (and correcting) some bugs in the reasoner. The MaRVIN project is a part of the LarKC project (Large Knowledge collider).