This is a classical Prolog application. Given the following graph of possible flights between eight US cities. (See Attached Screenshot) A) Build a prolog 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

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter3: Designing A Page Layout: Creating A Website For A Chocolatier
Section3.2: Visual Overview: Page Layout Grids
Problem 6QC
icon
Related questions
icon
Concept explainers
Question

This is a classical Prolog application. Given the following graph of possible flights between eight US cities. (See Attached Screenshot)

A) Build a prolog 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) 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).

 

 

New York
Chicago
$75
San Francisco
$25
$20
$75
$100
$45
$100
Denver
$125
$90
LA.
$80
Dallas
$45
$90
San Diego
$50
Miami
Transcribed Image Text:New York Chicago $75 San Francisco $25 $20 $75 $100 $45 $100 Denver $125 $90 LA. $80 Dallas $45 $90 San Diego $50 Miami
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Concepts in designing Database
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning