Laborator 10

Laborator 10

distance(X,Y,List, Result) :- nth0(Index, List, X), nth0(Index2, List, Y),

R is Index2-Index, abs(R, Result).

path(S) :- S =[_,_,_,_],

distance(a,c,S,R1), distance(c,d,S,R2),

distance(b,d,S,R3), distance(b,c,S,R4),

R1>R2, R3>R4.

label(S) :- S=[p,t].

label2(S) :- S=[p,t]; S=[t,p].

label3(S) :- label(S), not(label2(S)) ;

label2(S), not(label(S)).

emperor(S) :- S = [_,_], label3(S).