-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignement11.pl
82 lines (61 loc) · 1.06 KB
/
Assignement11.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
parent(pam,bob).
parent(tom,bob).
parent(tom,liz).
parent(bob,ann).
parent(bob,pat).
parent(pat,jim).
male(tom).
male(bob).
male(jim).
female(pam).
female(liz).
female(pat).
female(ann).
offspring(Y, X) :- parent(X, Y).
mother(X, Y) :-
parent(X, Y),
female(X).
grandparent(X, Z) :-
parent(X, Y),
parent(Y, Z).
different( X, Y) :-
X = Y, !, fail;
true.
sister( X, Y):-
parent( Z, X),
parent( Z, Y),
female( X),
different( X, Y).
predecessor(X, Z) :-
parent(X, Z).
predecessor(X, Z) :-
parent(X, Y),
predecessor(Y, Z).
fallible( X) :-
man( X).
man( socrates).
hasachild( X) :- parent( X, _).
somebody_has_child :- parent( _, _).
seq( r1, r2).
par( r1, r2).
par( r1, par(r2, r3)).
par( r1, seq(par( r2, r3), r4)).
f( 1, one).
f( s(1), two).
f( s((1)), three).
f( s(s(s(X))),N) :-
f( X, N).
translate(Number, Word):-
Number = 1, Word = one;
Number = 2, Word = two;
Number = 3, Word = three.
big( bear).
big( elephant).
small( cat).
brown( bear).
black( cat).
gray( elephant).
dark( Z) :-
black( Z).
dark( Z) :-
brown( Z).