Question: 1. (10 points) This is a classical Prolog application. Given the following graph of possible flights between eight Us cities: New York Chicago $75 San

1. (10 points) This is a classical Prolog application. Given the following graph of possible flights between eight Us cities: New York Chicago $75 San Francisco $25 75 $100 S45 $100 Denver $125 $90 LA $80 Dallas S45 $90 San Diego S50 Miami a) Build a knowledge base using the predicate directFlight/2 which encodes one city has direct flight to another city b) Add to rule that checks if there is a route between two cities. Routes of length zero are allowed. Example queries: route (chicago, chicago). should return yes route (chicago,la) should return yes. route (la, 'San Fracisco') . should return no. c) Add a rule that checks if a route has two legs. Example queries: route_of_2_legs (chicago,la). should return yes route of 2 legs(chicago, denver, should return no d) (optional) Add cost factor to directFlight, route, and route_of_2_legs so that the knowledge base can tell the cost associated with each flight For example, route (chicago, X, Y) . tells all the cities reachable from Chicago, and the cost (Y) to fly from Chicago to each city (X) 1. (10 points) This is a classical Prolog application. Given the following graph of possible flights between eight Us cities: New York Chicago $75 San Francisco $25 75 $100 S45 $100 Denver $125 $90 LA $80 Dallas S45 $90 San Diego S50 Miami a) Build a knowledge base using the predicate directFlight/2 which encodes one city has direct flight to another city b) Add to rule that checks if there is a route between two cities. Routes of length zero are allowed. Example queries: route (chicago, chicago). should return yes route (chicago,la) should return yes. route (la, 'San Fracisco') . should return no. c) Add a rule that checks if a route has two legs. Example queries: route_of_2_legs (chicago,la). should return yes route of 2 legs(chicago, denver, should return no d) (optional) Add cost factor to directFlight, route, and route_of_2_legs so that the knowledge base can tell the cost associated with each flight For example, route (chicago, X, Y) . tells all the cities reachable from Chicago, and the cost (Y) to fly from Chicago to each city (X)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
