Hello. Please help solve the problem:

In the Prolog database there are facts like:

родитель(Марья, Петр). родитель(Марья, Иван). и т.д. Запрос к базе данных имеет вид ?-q(X, Y). 

The value of the 1st argument is one of the chains of the form:

 [Кто, брат, Ивана, '?'] [Чей, брат, Пётр, '?'] [Иван, брат, Петра, '?'] 

At the output you need to get: Y = Пётр, Y = Иван, Y = yes

  • one
    @ anastasia05, According to the rules of the forum, questions should not be limited to solving or completing student assignments. Please clarify what you have done yourself and what did not work out. - iksuy Nov.
  • @ anastasia05, If you are given a comprehensive answer, mark it as correct (click on the check mark next to the selected answer). - Nicolas Chabanovsky

1 answer 1

 predicates nondeterm q(string, string) facts parent(string,string) clauses parent("Masha","Ivan"). parent("Masha","Petr"). parent("Dasha","Fedr"). parent("Dasha","Cenya"). q(X,Y):-parent(Z,X),parent(Z,Y),X<>Y. goal %1 q("Ivan",Y). %2 q("Petr",Y). %3 q("Ivan","Petr").