This folder contains the examples code of 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).
List of examples
Basic examples
pair.pl
defines a predicatepair
on integer, usingo
as 0 ands(X)
forX+1
.impair.pl
defines a predicatepair
on integer, usingo
as 0 ands(X)
forX+1
.lapin.pl
is a fun small example on a family of bunnies.tomandjerry.pl
is another fun small example on Tom and Jerry.
Other examples
famille.pl
andgenealogie.pl
are two implementations of a same examples, the first one is as detailed as possible, and the other one is as concise as possible.nat.pl
implements basic arithmetic operations on integers.domino.pl
is the solution of a harder problem.
How to run them?
- First, build
prolog
- Then:
cd exemples
../prolog/prolog ./pair.pl "pair(o)." # load a theory and ask a question
:scroll: License ?
This (small) repository is published under the terms of the MIT license (file LICENSE). © Lilian Besson, 2018.