Integrative statistics with R.

Real is an integrative approach to statistical computing in logic programming.
It allows the seamless integration of R code with modern Prolog systems.
The primary reference for Real is the 2016 Journal of Approximate Reasoning paper.

Real works on current versions of SWI and Yap. It uses R's C interface to efficiently
exchange data between Prolog and the R executable which is ran as an OS shared library.

The code has be developed on linux and binaries are also included for MS Windows.
Provisio of a gcc in the path, it should also compile on Mac OS.



Real can be installed from within SWI using its package manager.
Real requires R to be available as a runtime library in your system.

?- pack_install(real).

And then load by :

?- [library(real)].

If you working on *nix like systems with gcc installed, you are adviced to rebuild from sources, by running

?- pack_rebuild(real).

To install a source distribution:

?- pack_install( 'the_source.tgz' ).

To install from git, replace the pack installed prolog/ and c/real.c. Then:

?- pack_rebuild( real ).

As of Real v1.4, Real takes advantage of the syntactic innovations introduced in
SWI v7 (see also SWI-7 extensions paper).


Yap binaries include real (libary(real)), although these are likely to be older versions.

Yap sources include real as a package. Include it in the built by using:

../configure --with-R

To build the release or git sources, replace packages/real with the desired version and build with the configure shown above.


There is a raft of examples in the file examples/ which also implements a run all script (for_real).

?- [pack(real/examples/for_real)].

?- edit( pack(real/examples/for_real) ).

?- for_real.


The following resources are available:


Sources for SWI packager: real
Sources (1.0.0, 2013/12/6, prepared for Yap): real-src-1.0.0.tgz


Advances in integrative statistics for logic programming
Nicos Angelopoulos, Samer Abdallah and Georgios Giamas
International Journal of Approximate Reasoning, (IJAR)
Volume 78, November 2016, pages 103-115. [j.ijar.2016.06.008],[bib]

Integrative functional statistics in logic programming.
Nicos Angelopoulos, Vitor Costa Santos, Joao Azevedo, Jan Wielemaker, Rui Camacho and Lodewyk Wessels
In Practical Aspects of Declarative Languages (PADL'13)
January, 2013. Rome, Italy.


We always welcome comments on use cases. Particularly, applications and publications that use this pack.
We also welcome fixes and bug reports. For contact details see: contact


To Jan Wielemaker, SWI-Prolog developer, for re-writing the original C code for v.0.1. A number of improvements for v.2
To Samer Abdallah for improvements to threads and automatically setting $R_HOME.


Nicos Angelopoulos
Vitor Costa Santos

London, March 2017

Last update June 2022.