A pseudo-Prolog that tries to answer queries by building the least Herbrand model.
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.


herbrand-prolog Build Status

A pseudo-Prolog that tries to answer queries by building the least Herbrand model.

Written as a final project for COMP360 Computational Logic and Logic Programming, Fall 2014, Prof. Lipton, Wesleyan University.

Here's a blog post about the development process of the project.


  • Currently, you cannot use functions in your program, such as s(o). The parser doesn't handle them yet, neither does the least Herbrand model builder.

  • You cannot use ; as "or". Try adding separate Horn clauses to the program for this.

  • You cannot use \+, !..

  • You cannot use natural numbers or lists. You can only use constants and relations.


In order to use or compile the program you need to have Haskell installed.

After you cloning the repository, go the repository folder and do

cabal build

Now you compiled the program. There is an example Prolog file in the "usage" folder. You can run it like this:

./dist/build/repl/repl usage/travel.prolog

Then you can ask questions like reachable(istanbul, newhaven).

Here's an example REPL session for the Prolog program we have in usage/travel.prolog:

herbrand-prolog REPL
?- reachable(istanbul, newhaven).
?- reachable(meriden, X).
Possible answers:
[reachable/2(meriden, meriden),reachable/2(meriden, middletown),reachable/2(meriden, newhaven),reachable/2(meriden, istanbul),reachable/2(meriden, newyork)]
?- reachable(istanbul, london).

Note that the system build a language from your program, that has all the constants used in your program. This means that if you define a predicate like always_say_yes(X,Y)., and try always_say_yes(hello,world)., the system will say no, because hello and world are not in the language (unless they are used somewhere else in the program) and therefore the system doesn't include them into the least Herbrand model, since it tries to build the entire list of ground formulae.


MIT License