Today 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

Run it:

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>

Interactively load rules or facts from a file “test.pl“:

[test].
# or:
['path/to/test.pl'].

Open the source file containing a given object in your default editor (e.g. Vim):

edit(male).

The file is automatically reloaded afterwards. To reload files that have been edited independently:

make.

Run a query:

male(X).

Press ; or spacebar after each result to see the next result.
Press enter to stop looking for results.
Press Ctrl-C then a to abort.

That’s all for now. To actually learn the Prolog language, I’m currently reading Learn Prolog Now.