Java-based lightweight Prolog virtual machine
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

License: Apache 2.0

  • tested with Java 8, developed with IntelliJ and cmd line

  • it assumes SWI-Prolog 7.x for compiling from .pl to files


  • add
  • perms
  • queens


  • < any pure Prolog program in directory prog >

with Prolog files assumed having suffix .pl


  • doc/paper.pdf (A Hitchhiker's Guide to Reinventing a Prolog Machine)


for some motivations for this and justification of implementation choices

a swi prolog script first compiles the code to a file, than Main calls stuff in Engine which loads it in memory and runs it


primitive types:

  • int
  • ground
  • var (U+V)
  • ref
  • array

see main code (~1000lines) in

  • compiles a .pl file to its .nl equivalent, ready to run by the java based runtime system

  • emulates its work by compiling back .nl files to Prolog clauses


  • design a self-contained compiler
  • convert to C for more effective benchmarking against C-based Prolog systems
  • faster runtime: memory efficiency - eg recursive loop, LCO code to be mem_copied with ptrs to var/ref cells to be relocated?

some out of the box thoughts:

  • no symbol tables: a symbol is just a (small) ground array of ints, and instead of a symbol table we would have a "ground cache" - that helps with better memory usege and also speed

  • when a non-ground compound tries to unify with a ground, the ground term is expanded to the heap

  • when a ground unifies with a ground - it's just pointer equality and when a var unifies with a ground, it just points to it - as if it were a constant


Paul Tarau

August 2017