SWI-Prolog è la versione qui utilizzata.
Sistema: Ubuntu 13.04.
Strumenti: Gedit, Terminale.
Per installarlo : sudo apt-get install swi-prolog

Prolog is a declarative programming language. This means that in prolog, you do not write out what the computer should do line by line, as in procedural languages such as C and Java . The general idea behind declarative languages is that you describe a situation. Based on this code, the interpreter or compiler will tell you a solution. In the case of prolog, it will tell you whether a prolog sentence is true or not and, if it contains variables, what the values of the variables need to be.

Piccolo script per iniziare a conoscere il Prolog

largeFamily.pl

% database familiare
% iniziamo da lontano definendo un insieme di esseri umani..

human(john).
human(david).
human(gino).
human(bobbysolo).
human(karen).
human(gloria).
% ora separiamoli in base al sesso :
sex(john, man). % maschietti
sex(david, man).
sex(gino, man).
sex(bobbysolo, man).
sex(karen, woman). % femminucce
sex(sasha, woman).
sex(gloria, woman).
% iniziamo a definire le coppie
partner(john, gloria).
partner(david, britney).
partner(gino, topino).
partner(john, karen).
haveChild(john, sasha). % genitori
%haveChild(john, david).
% john,karen -> sasha,bobbysolo -> rocco,brigitte -> moana
haveChild(karen, sasha).
haveChild(gloria, david).
haveChild(sasha, rocco).
haveChild(bobbysolo, rocco).
haveChild(rocco, moana).
haveChild(brigitte, moana).
% definiamo ora delle funzioni che controllino se
% - A sia il padre di B
isFather(A, B) :- sex( A, man), haveChild(A,B).
% - A sia la madre di B
isMother(A, B) :- sex( A, woman), haveChild(A,B).
% - F e M siano padre a madre di A
parents(A, F, M) :- isFather(F, A), isMother(M,A).
% - A sia un avo di B
ancestor(A,B) :- haveChild(A,B).
ancestor(A,B) :- haveChild(A,X), ancestor(X,B). % non senti puzza di ricorsione ?
% - uno dei due è il padre/madre, il figliastro, il fratello/astro o un progenitore
areRelatives(A,B) :- isFather(A,B) | isFather(B,A) | isMother(A,B) | isMother(B,A);
partner(A,C), haveChild(C,B);
partner(C,A), haveChild(C,B);
haveChild(C,A), haveChild(D,B), ( partner(C,D); partner(D,C) );
ancestor(A,B); ancestor(B,A).

Mentre queste sono delle possibili interrogazioni da terminale

?- isFather(john,_).
true.
?- isFather(john,B).
B = david.
?- parents(david,Father,Mother).
Father = john,
Mother = gloria ;
false.

?- ancestor(john, Discendente).
Discendente = sasha ;
Discendente = rocco ;
Discendente = moana ;
false.

?- areRelatives(gloria, sasha).
true .
?- areRelatives(john,david).
true .
?- areRelatives(karen, moana).
true ;