Translate the following sentences into a Prolog program (10)
Everyone who teaches programming module is smart.
Craig teaches the programming module.
Craig’s brother teaches the mathematics module.
The programing module is interesting.
Craig’s sister teaches all modules.
QUESTION ONE (20 MARKS)
1.1 Consider the state space graph shown below. P is the start state and V is the goal state. The costs for each edge are shown on the graph. Each edge can be traversed in both directions.
1.1.1 Use Breadth-First Search to generate the shortest path from P to V. (10)
1.1.2 Apply the Depth First Search method to find a path from P to V. (10)
Translate the following sentences into a Prolog program (10)
Everyone who teaches programming module is smart.
Craig teaches the programming module.
Craig’s brother teaches the mathematics module.
The programing module is interesting.
Craig’s sister teaches all modules.
Program(Queen Victoria's family):
male(albert).
male(edward).
female(alice).
female(victoria).
parents(edward,victoria,albert).
parents(alice,victoria,albert).
sister_of(X,Y):-
female(X),
parents(X,M,F),
parents(Y,M,F).
On the query sister_of(X,Y) more one answer can be
returned. Explain how all the answers are obtained,
and what they are.
You are to write a simple program in Prolog to find a path through a maze. Your input will consist of facts of the form
pway(a, b, 10).
indicating that there is a passageway from intersection a to intersection b of length 10 meters. You are to write a rule
solve(X, Y, P, N) :- ...
that will find a path P of length N (if one exists) from intersection X to intersection Y. The intent is that the user will invoke solve as a query, specifying X and Y as constants and P and N as variables.
Here is a concrete example. Suppose the database contains the following rules:
pway(a, b, 10).
pway(b, c, 15).
pway(d, c, 5).
pway(d, b, 10).
If the user types
solve(a, d, P, N)
the Prolog interpreter might respond with
P = [a, b, c, d]
N = 30