Prolog is a programming language that was born in 1972 and known as a logic programming language.
To run Prolog programs on your computer, using docker is the easiest way. It helps you set up and manage the environment.
Assuming that you already have docker installed, pull the SWI-Prolog Docker image by running the following command:
docker pull swipl
and run a container
docker run --name swipl -it swipl /bin/bash
After that in a docker container you started, create a Prolog code. For example:
likes(sam, lisa).
likes(sam, james).
likes(jiro, james).
and save it as main.pl
And then load your Prolog code by running
swipl main.pl
In the terminal, you will see a prompt like below
root@4d1dad014ee6:~# swipl main.pl
Welcome to SWI-Prolog (threaded, 64 bits, version 9.1.10)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?-
You can now type Prolog queries at the prompt and receive answers. For example, try:
?- likes(X, lisa).
The Prolog interpreter will provide the answer:
X = sam.
Enjoy exploring Prolog!
Top comments (0)