-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path01-basics.pl
45 lines (31 loc) · 891 Bytes
/
01-basics.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
%--------------------------------------------------------
% some family facts
woman(alice).
man(bob).
man(charlie).
man(dennis).
father(bob, charlie).
father(dennis, bob).
mother(alice, charlie).
% some family rules
son(X, Y) :- father(Y, X), man(X).
son(X, Y) :- mother(Y, X), man(X).
%--------------------------------------------------------
blonde(X) :-
father(Father, X),
blonde(Father), % father is blond
mother(Mother, X),
blonde(Mother). % mother is blond
blonde(alice).
%--------------------------------------------------------
% some Prolog clauses (facts)
bigger(horse, duck).
bigger(duck, gnat).
% some Prolog clauses (rules)
is_bigger(X,Y) :- bigger(X,Y).
is_bigger(X,Y) :- bigger(X,Z), is_bigger(Z,Y).
%--------------------------------------------------------
% Goal execution example
mortal(X) :- man(X).
mortal(X) :- woman(X).
man(socrates).