Program 5 • Logic Programming : Prolog Solution



1. Logic Programming in Prolog

You will use Prolog to write an airline reservation system for the Twilight Zone Air-lines. Given a request to travel from one city to another, print out the flight schedule. For each leg of the trip, print out the departure airport, airport, city name, and time. For example :

| ?- fly( lax, sea).

depart LAX Los Angeles 14:22

arrive SFO San Francisco 15:29

depart SFO San Francisco 16:02

arrive SEA Seattle-Tacoma 17:42

true ?


A database has been provided which lists some airports, their cities, and the North latitudes and West longitudes of the airports. A flight schedule has also been pro-vided listing the departure and arrival airports and the departure times.

2. Logic

Some notes about the logic of the program.

    1. To compute the distance between airports, use the haversine formula. The database contains degrees and minutes, which must be converted to radians. The result must be converted to miles.

    1. Planes fly at a constant speed of 500 miles per hour and always using great circle paths, so the arrival time can be computed from the departure time.

    1. A flight transfer always takes 30 minutes, so during a transfer at a hub, the departure of a connecting flight must be at least 30 minutes later than the arrival of the incoming flight.

    1. There are no overnight trips. The complete trip departs and arrives in the same day, although the final arrival time may be shown as greater than 23:59.

  1. What to Submit

Submit one file : Also submit README, and if applicable, PARTNER. The grader will copy in the files .score/ and the test data.

error: Content is protected !!