Index of /besson/publis/Tiny-Prolog-in-OCaml.git

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  - Root of the website (in English or in French)
[DIR]examples/2018-03-29 19:02 -  
[DIR]prolog/2018-03-23 11:26 -  
[   ]_config.yml2018-03-19 17:00 25  
[   ]Makefile2018-03-29 19:09 168  
[   ]LICENSE2018-02-24 14:58 1.1K 
[TXT]README.md2018-03-23 11:07 3.5KSome details about this page
[   ]example.ipynb2018-03-23 11:39 25K 
[TXT]example.html2018-03-29 19:08 286Kexample
# [Tiny-Prolog-in-OCaml](
> A tiny implementation of a small subset of the Prolog language, in OCaml. With small and fun examples.
> WARNING: this project only has an **educational purpose**, for a real-world use of Prolog, please refer to [GNU Prolog (gprolog)](XXX).

This project contains [the code](prolog/) and [examples](examples/) for a tiny [Prolog]( implementation, written in [the OCaml language](

- See [this folder](prolog/) for instructions to build the project (really easy: clone, run `make`, relax and enjoy :tada:). The implementation focuses on a very small subset of Prolog, see the examples for a good idea of what is supported.
- See [this other folder](examples/) for examples (in English).

## Example
- A theory has this form, first with axioms (predicate):
- Then maybe some rules, stating that [a mouse is fast and a cat can be stupid](
fast(X) <-- mouse(X).
stupid(X) <-- cat(X).

- If you save this file (see [this example](examples/, you can then load it with the `prolog` binary:

$ ./prolog/prolog ./examples/
?- stupid(tom).
  { }
continue ? (o/n) [o] :

- This `{ }` is an empty model, meaning that `stupid(tom).` evaluates to True in an empty model (no need for instanciation).
- You can also ask your question directly in the command line:
$ ./prolog/prolog ./examples/ "fast(tom)."
?- fast(tom).
- An empty response mean that the term is false, no matter the model.

- You can add more rules, as you want.
ishuntedby(X, Y) <-- mouse(X), cat(Y).
$ ./prolog/prolog ./examples/ "ishuntedby(tom, jerry)."
?- ishuntedby(tom, jerry).
$ ./prolog/prolog ./examples/ "ishuntedby(jerry, tom)."
?- ishuntedby(jerry, tom).
  { }

- You can also add comments, that are lines starting with one or more `#` character.
# the mouse always espace the cat!
istrickedby(X, Y) <-- cat(X), mouse(Y).

## More example
- See [this folder](examples/),
- Or [this notebook](example.ipynb).


### :scroll: License ? [![GitHub license](](
This (small) repository is published under the terms of the [MIT license]( (file [LICENSE](LICENSE)).
© [Lilian Besson](, 2018.

[![Ask Me Anything !](](


[![ForTheBadge built-with-science](](
[![ForTheBadge uses-badges](](
[![ForTheBadge uses-git](](