-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3_RELATIONSHIPS.PRO
More file actions
40 lines (39 loc) · 1.02 KB
/
3_RELATIONSHIPS.PRO
File metadata and controls
40 lines (39 loc) · 1.02 KB
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
predicates
nondeterm father(String, String)
nondeterm son(String, String)
nondeterm brother(String, String)
nondeterm uncle(String, String)
nondeterm grandfather(String, String)
nondeterm who(String, String)
clauses
son("Alexey","Yuri").
son("Yuri","Ivan").
son("Sergey","Ivan").
son("Alexander","Ivan").
son("Pavel","Sergey").
father(FATHER,SON):-
son(SON,FATHER).
brother(SON1,SON2):-
son(SON1,FATHER),
son(SON2,FATHER),
SON1 <> SON2.
uncle(UNCLE,PL):-
son(PL,FATHER),
brother(FATHER,UNCLE).
grandfather(GRANDFATHER,GRANDSON):-
father(GRANDFATHER,FATHER),
son(GRANDSON,FATHER).
who(PERSON1,PERSON2):-
son(PERSON1,PERSON2),Write("Son"),nl;
son(PERSON2,PERSON1),Write("Father"),nl;
grandfather(PERSON1,PERSON2),Write("Grandfather"),nl;
grandfather(PERSON2,PERSON1),Write("Grandson"),nl;
uncle(PERSON1,PERSON2),Write("Uncle"),nl;
uncle(PERSON2,PERSON1),Write("Pl"),nl;
PERSON1 = PERSON2,Write("Himself"),nl.
/*
goal
brother("Sergey",X1)
grandfather(X2,"Pavel")
who("Sergey","Alexey")
*/