编写Prolog程序以进行跟踪。我写了每件事,我需要知道我写的最后两个是正确还是错误。
1. saman likes maths.
2. saman likes science.
3. udara likes maths.
4. fazal likes science.
5. fazal likes music.
6. geetha likes history.
7. geetha likes science.
8. geetha likes music.
9. those who like maths and science will follow engineering for advance level.
10. those who likes history or music will follow art for advance level.
这对最后两个正确吗?
student(X):- like(X,maths_and_science),follow(X,engineering).
student(X):- likes(X,history_or_music), follow(X,art).
我不知道如何编写以下Prolog查询。
1) Does saman like maths or music?
2) Who likes science and music?
3) who will do engineering?
请帮助我。
答案 0 :(得分:0)
- 喜欢数学和科学的人会跟随工程学进阶。
- 喜欢历史或音乐的人会跟随艺术前进。
这对最后两个正确吗?
不。可能是:
will_follow(Student, engineering) :-
likes(Student, maths),
likes(Student, science).
will_follow(Student, art) :-
likes(Student, history) ;
likes(Student, music).
1)萨满喜欢数学还是音乐?
likes(saman, art) ; likes(saman, music). % intentionally incorrect
2)谁喜欢科学和音乐?
likes( Who, science) , likes( Who, maths). % intentionally incorrect
3)谁来做工程?
will_follow( Who, arts ). % intentionally incorrect
由于这看起来像是一项作业,因此我故意在各处使用错误的名称。您必须纠正这些问题。