Question 1
We are given the following knowledge base of travel information:
byCar(auckland,hamilton).
byCar(hamilton,raglan).
byCar(valmont,saarbruecken).
byCar(valmont,metz).
byTrain(metz,frankfurt).
byTrain(saarbruecken,frankfurt).
byTrain(metz,paris).
byTrain(saarbruecken,paris).
byPlane(frankfurt,bangkok).
byPlane(frankfurt,singapore).
byPlane(paris,losAngeles).
byPlane(bangkok,auckland).
byPlane(singapore,auckland).
byPlane(losAngeles,auckland).
a) Write a predicate travel/2 which calculates whether it is possible to travel from one place to another by chaining together car, train, and plane journeys. For example, your program should answer yes to the query travel(valmont,raglan).
So, by using travel/2 to query the above database, you can ?nd out that it is possible to go from Valmont to Raglan. If you are planning such a voyage, that's already something useful to know, but you would probably prefer to have the precise route from Valmont to Raglan.
b) Write a predicate travel/3 which tells you which route to take when travelling from one place to another. For example, the program should respond
X = go(valmont,metz,
go(metz,paris,
go(paris,losAngeles)))
to the query travel(valmont,losAngeles,X).
c) Extend the predicate travel/3 so that it not only tells you the route to take to get from one place to another, but also how you have to travel.