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

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  - Root of the website (in English or in French)
[TXT]resolution.ml2018-03-23 11:26 2.7K 
[   ]prolog.opt2018-03-23 11:12 1.4M 
[TXT]prolog.ml2018-03-23 10:32 832  
[   ]prolog2018-03-23 11:25 175K 
[TXT]lib.ml2018-03-23 11:04 4.0K 
[TXT]README.md2018-03-23 10:10 3.4KSome details about this page
[   ]Makefile2018-03-19 16:39 700  
# This folder contains the source 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)](XXX).

## Requirements
- Have OCaml installed, with camlp4o
- And GNU Makefile

## How to build
- Clone or download the repository,
- Go in this folder,
- Run `make`, wait 5 seconds, and :taad: tadaa!

$ cd /tmp/
$ git clone
$ cd Tiny-Prolog-in-OCaml
$ cd prolog
$ make prolog
ocamlc -pp camlp4o -c
ocamlc on -pp camlp4o -c
ocamlc lib.cmo -c
ocamlc on lib.cmo -c
ocamlc -o prolog lib.cmo resolution.cmo
ocamlc on -o prolog lib.cmo resolution.cmo
$ make clean
$ file prolog
prolog: a ocamlrun script executable (binary data)

- If you need a native binary, do `make prolog.opt` instead.

## List of files
- [Makefile](Makefile) defines the rules to build the binary,
- [``]( implements (manually) the command line binary (parse input, etc),
- [``]( implements useful functions,
- [``]( implements the data structure to manipulate terms, the parsing of a theory file, and the resolution algorithm to answer logical questions on a 0th-order theory.


## How to use `prolog`
- Load a theory (`.pl` file), and ask a question:
$ ./prolog
?- ... # ask your question, end with .

- Or load a theory and ask a question, directly from the command line:
$ ./prolog "question(...,...)."
?- ... # give the answer, and quit

## How to test
- Use one of the [examples](../examples/):

cd ..
cd exemples
../prolog/prolog ./ "pair(o)."  # load a theory and ask a question
../prolog/prolog ./ "impair(o)."  # load a theory and ask a question
../prolog/prolog ./ "ancetre(X,renaud)."  # load a theory and ask a question


### :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](](