Answer the question
In order to leave comments, you need to log in
Genetic tree in prologue, where am I wrong?
Given a genetic tree, it is
necessary to find out who is who's brother-in-law.
Brother-in-law is the wife's brother.
did like this
predicates
parent (symbol, symbol)
man (symbol)
woman (symbol)
shurin (symbol, symbol)
suprugi (symbol, symbol)
clauses
parent (barbara, liza).
parent (valera, liza).
parent (barbara, nikolay).
parent (valera, nikolay).
parent (anna, katya).
parent (anna, petr).
parent (srgey, katya).
parent (srgey, petr).
parent (tatiana, natali).
parent (tatiana, mihail).
parent (dmitry, natali).
parent (dmitry, mihail).
parent (liza, alex).
parent (petr, alex).
parent (nikolay, raisa).
parent (natali, raisa).
parent (katya, alexandr).
parent (mihail, alexandr).
parent (katya, juli).
parent (mihail, juli).
parent (alex, kostya).
parent (juli, kostya).
parent (raisa, lyuda).
parent (alexandr, lyuda).
suprugi (barbara, valera).
suprugi (anna, sergey).
suprugi (tatiana, dmitry).
suprugi (liza, petr).
suprugi (nataly, nikolay).
suprugi (katya, mihail).
suprugi (raisa, alexandr).
suprugi (juli, alex).
suprugi (lyuda, kostya).
man (valera).
man (sergey).
man (dmitry).
man (nikolay).
man (petr).
man (mihail).
man (alex).
man (alexandr).
man (lyda).
woman (barbara).
woman (anna).
woman (tatiana).
woman (liza).
woman (katya).
woman (nataly).
woman (raisa).
woman (juli).
woman (lyuda).
shurin (y,x) :-
parent (z,k),
parent (z,y),
suprugi (k,x),
man (y).
goal
shurin (y, x),
write (y, "shurin", x).
Answer the question
In order to leave comments, you need to log in
The main code of the rules.
1. Variables must be capitalized, otherwise they are considered values.
2. In the original data you have a lot of typos, as a result sergey is sometimes srgey, natali is nataly, and kostya is not a man at all. Etc.
3. You get duplicates because both parents are checked. If you add a check for only one parent (for example, only mother or father), then the duplicates will go away.
Something like this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question