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 $20 $75 $100 $45 $100 Denver $125 $90 LA $80 Dallas $45 $90 San Diego $50 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. route of 2 legs(chicago,la). should return yes route of 2 legs(chicago,denver). should return no Example queries: d) (optional, 3 extra points)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).

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
1. **(10 points)** This is a classical Prolog application. Given the following graph of possible flights between eight US cities:

The graph shows the cities and the cost of direct flights between them. Here are the details:

- **San Francisco** to:
  - Chicago: $75
  - Denver: $100
  - L.A.: $45

- **L.A.** to:
  - Chicago: $80
  - San Diego: $45

- **San Diego** to L.A.: $45

- **Denver** to:
  - San Francisco: $100
  - Chicago: $90
  - Dallas: $125

- **Chicago** to:
  - San Francisco: $75
  - New York: $75

- **Dallas** to Miami: $90

- **New York** to Miami: $90

**Tasks:**

a) **Build a knowledge base** using the predicate `directFlight/2` which encodes one city has a direct flight to another city.

b) **Add a 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 Francisco').` 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, 3 extra points)* **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).
Transcribed Image Text:1. **(10 points)** This is a classical Prolog application. Given the following graph of possible flights between eight US cities: The graph shows the cities and the cost of direct flights between them. Here are the details: - **San Francisco** to: - Chicago: $75 - Denver: $100 - L.A.: $45 - **L.A.** to: - Chicago: $80 - San Diego: $45 - **San Diego** to L.A.: $45 - **Denver** to: - San Francisco: $100 - Chicago: $90 - Dallas: $125 - **Chicago** to: - San Francisco: $75 - New York: $75 - **Dallas** to Miami: $90 - **New York** to Miami: $90 **Tasks:** a) **Build a knowledge base** using the predicate `directFlight/2` which encodes one city has a direct flight to another city. b) **Add a 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 Francisco').` 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, 3 extra points)* **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).
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY