Getting started with SWI-Prolog
Today (May 2017) I decided to learn a bit about Prolog. Here is how to start using it...
Install it on Ubuntu:
sudo apt-get install swi-prolog
swipl # or: prolog
Run Prolog and load rules and facts from a file:
prolog -s test # or: prolog -s test.pl
Interactively add rules or facts:
assert(male(dave)). % or: [user]. male(dave). male(john). <Ctrl-D>
user" means add interactively instead of reading from a file.)
Load rules or facts from a file
[test]. % or the full filename: ['path/to/test.pl'].
Open the source file containing a given object in your default editor (e.g. Vim):
The file is automatically reloaded afterwards. To reload files that have been edited independently:
Run a query:
spacebar after each result to see the next result.
enter to stop looking for results.
a to abort.
That's all for now. To actually learn the Prolog language, I'm currently reading Learn Prolog Now.