язык Пролог2

Jul 18, 2012 13:26

Предыдущая задача, но в другом виде


База:

function_proto(ethic).
function_proto(logic).
function_proto(sensoric).
function_proto(intuition).
color(white).
color(black).

function([Color|Function]) :-
 color(Color),
 function_proto(Function).

rational(X) :-
 (X = ethic; X= logic).

irrational(X) :-
 function_proto(X),
 \+ rational(X).

model(F1,F2):-
 function(F1),
 function(F2),
 [F1_color|F1_func]=F1,
 [F2_color|F2_func]=F2,
 \+ F1_color=F2_color,
 (
  ( rational(F1_func),
    irrational(F2_func)
  );(
    irrational(F1_func),
    rational(F2_func)
  )
 ).

Запрос ("выведи мне ИРРАЦИОНАЛЬНЫЕ ИНТРАВЕРТНЫЕ ТИМЫ"):

?- model([Color|Func],F2),irrational(Func),Color=white.

F1 = [white|sensoric],
F2 = [black|ethic],
Color = white,
Func = sensoric ;

F1 = [white|sensoric],
F2 = [black|logic],
Color = white,
Func = sensoric ;

F1 = [white|intuition],
F2 = [black|ethic],
Color = white,
Func = intuition ;

F1 = [white|intuition],
F2 = [black|logic],
Color = white,
Func = intuition ;
false.

Previous post Next post
Up