V
V
vania932015-02-20 05:59:13
Prolog
vania93, 2015-02-20 05:59:13

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.
90f041ba36e446b7a278c01df869daa7.png
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).

but as a result of the answer I get just "no"
where did I go wrong?
thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SHVV, 2015-02-20
@vania93

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 question

Ask a Question

731 491 924 answers to any question