Question: PROLOG: Please answer a and b (a) try to trace through search process for Q2; (b) try to trace through Q1, but with sub-goals reversed.
PROLOG: Please answer a and b
(a) try to trace through search process for Q2;
(b) try to trace through Q1, but with sub-goals reversed.
Who teaches what.
f1: teaches(john, database, s1).
f2: teaches(john, ai, s1).
f3: teaches(mary, os, s1).
f4: teaches(mary, ai, s2).
f5: teaches(paul, compiler, s1).
Query 1: Whats the course taught by John and Mary?
?- teaches(john, X, _), teaches(mary, X, _).
Query 2: Who teaches both os and compiler?
?- teaches(X, os, _), teaches(X, compiler, _).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
