Task:
- Three friends - Peter, Roman and Sergey study at the Faculty of Mathematics, Physics and Chemistry.
- If Peter is a mathematician, then Sergey is not a physicist.
- If Roman is not a physicist, then Peter is a mathematician.
- If Sergey is not a mathematician, then Roman is a chemist.
Determine the specialty of Sergei.
Code:
domains dep=symbol predicates faculty(dep) cond1(dep, dep) cond2(dep, dep) cond3(dep, dep) solve(dep, dep, dep) % Peter, Roman, Sergey clauses faculty(physics). faculty(math). faculty(chemistry). cond1(Fa1, Fa3):- Fa1=math, Fa3<>physics. cond2(Fa2, Fa1):- Fa2<>physics, Fa1=math. cond3(Fa3, Fa2):- Fa3<>math, Fa2=chemistry. solve(Fa1, Fa2, Fa3):- faculty(Fa1), faculty(Fa2), faculty(Fa3), Fa1<>Fa2, Fa2<>Fa3, Fa1<>Fa3, cond1(Fa1, Fa3); cond2(Fa2, Fa1); cond3(Fa3, Fa2). When you run this code, the following error pops up:
How can I correct this error and does this problem have any other solution on the prolog?
The answer to the problem should be this: Peter is a chemist, Roman is a physicist, Sergey is a mathematician

factssection - Grundy