Тема: PROLOG
Лабораторные на PROLOG
predicates
man(symbol)
woman(symbol)
parent(symbol, symbol)
suprug(symbol, symbol)
nevestka (symbol, symbol)
dever (symbol, symbol)
clauses
man(sergey).
man(dmitriy).
man(valera).
man(petr).
man(mihail).
man(nikolay).
man(alex).
man(alexandr).
man(kostya).
woman(barbara).
woman(anna).
woman(tatiana).
woman(liza).
woman(katya).
woman(juli).
woman(raisa).
woman(lyuda).
parent(barbara, liza).
parent(liza, alex).
parent(alex, kostya).
parent(anna, katya).
parent(anna, petr).
parent(sergey, katya).
parent(sergey, petr).
parent(katya, juli).
parent(petr, alex).
parent(petr, alexandr).
parent(alexandr, lyuda).
parent(juli, lyuda).
parent(tatiana, mihail).
parent(dmitriy, mihail).
parent(mihail, juli).
parent(valera, nikolay).
parent(nikolay, raisa).
parent(raisa, kostya).
suprug (anna, sergey).
suprug (tatiana, dmitriy).
suprug (liza, petr).
suprug (katya, mihail).
suprug (raisa, alex).
suprug (juli, alexandr).
nevestka (X, Y):-
parent (H, Y),
parent (H, B),
Y<>B,
suprug (X, B),
woman(X),
man(B).
nevestka (X, Y):-
parent (Y, S),
man(S),
suprug (X,S),
woman(X).
dever (X, Y):-
suprug (Y, M),
man(M),
woman(Y),
parent(R, X),
parent(R, M),
X<>M,
man(X).
goal
nevestka (Who, Whom),
write ("Tetya ");
dever (Who, Whom),
write ("_Dever ").