?- sum(0, 1, 1), sum(1, 1, 2). yes ?- sum(0, 1, 1), sum(1, 1, 3). noΜπορούμε να ορίσουμε ακόμα κανόνες με βάση ένα γεγονός και κάποιες σχετικές ερωτήσεις με την παρακάτω σύνταξη:
Παράδειγμα:
parent(X, Y) :-
father(X, Y).
parent(X, Y) :-
mother(X, Y).
?- parent(anthi, X).
X = giannis ->;
X = maria
yes
?- parent(X, giannis).
X = anthi ->;
X = petros ->;
X = thanasis ->;
X = iro ->;
no
Παράδειγμα:
grandfather(X, Y) :-
parent(X, Z),
father(Z, Y).
?- grandfather(X, Y).
X = giannis
Y = nikos ->;
X = giannis
Y = giorgos ->;
no