General
Material
Lecture 1
Lecture 2
Lecture 3
Lecture 4
Lecture 5

Traveling by car, train, and plane

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(losAngeles,auckland).
    
Download knowledge base.

Write a predicate travel/2 which determines 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).
Hint

So, by using travel/2 to query the above database, you can find out that it is possible to go from Valmont to Raglan. In case you are planning a travel, that's already very good information, but what you would then really want to know is how exactly to get from Valmont to Raglan. Write a predicate travel/3 which tells you how to travel from one place to another. The program should, e.g., answer yes to the query travel(valmont,paris,go(valmont,metz,go(metz,paris))) and X = go(valmont,metz,go(metz,paris,go(paris,losAngeles))) to the query travel(valmont,losAngeles,X).
Hint

Extend the predicate travel/3 so that it not only tells you via which other cities you have to go to get from one place to another, but also how (i.e. by car, train, or plane) you get from one city to the next.
Hint

Back to the practical session of day2.