Could you help me to understand what my error is in the code? It is very necessary to understand ..
Task:
Describe a knowledge base on Prolog containing the following information:
Data:
- Alexey is the son of Yuri
- Yuri is the son of Ivan,
- Sergey is the son of Ivan
- Alexander is the son of Ivan
- Pavel is the son of Sergey.
Rules:
- X is the father of Y, if Y is the son of X
- X is a brother of Y if they are two different people, but both are sons of the same person.
- X is the uncle of Y, if the father of Y is Z, and X and Z are brothers
- X is the grandfather of Y, if X is the father of Z, and Z is the father of Y
Formulate goals and answer the following questions:
- Display the list of brothers Sergey
- What is the name of Paul's grandfather?
- Who is Sergei Aleksey?
predicates nondeterm son(string,string) /*who, whose*/ nondeterm father(string,string) /*who, whose*/ nondeterm brother(string,string) /*who, whose*/ nondeterm uncle(string,string) /*(who, whose*/ nondeterm grandfather(string,string) /*who, whose*/ clauses %Facts son(aleksej,yurij). son(yurij,ivan). son(sergej,ivan). son(alexandr,ivan). son(pavel,sergej). %Rules father(X,Y):-son(Y,X). brother(X,Y):-X<>Y,father(Z,X),father(Z,Y). uncle(X,Y):-father(Z,Y), brother(X,Z),brother(Z,X). grandfather(X,Y):-father(X,Z),father(Z,Y). goal brother(X,sergej). grandfather(X,pavel). X(sergej,aleksej). It seems that everything is logical, it should compile and produce a result, but for some reason it gives errors ..
I do not understand what is wrong ..
brother(X,Z),brother(Z,X)- you have no difference in what order the arguments are passed to - Grundy