Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone help with this prolog In this assignment, you are given a city database (facts) and will need to write queries and rules that

can someone help with this prolog

In this assignment, you are given a city database (facts) and will need to write queries and rules that use the facts. here is the given code:

city_altitude(tempe, az, 1318).

city_altitude(atlanta, ga, 894).

city_altitude(chicago, il, 583).

city_altitude(denver, co, 5280).

city_altitude(seattle, wa, 260).

city_altitude(boise, id, 2704).

city_altitude(saltlakecity, ut, 4226).

Add two more facts by choosing two cities and adding them to the facts including their state and altitude.

Queries: (a) What is the answer after executing the following query? city_altitude(City, _, _).

(b) Write a Prolog query to return all pairs of each city and its altitude in the database. (Do not display their state) Rules: a) Write a prolog rule that confirms the following statement: City is a high city if its altitude in feet is greater than 1000 ft. i.e., define the new predicate: high_city(City):- ...... b) Write a prolog rule to compute each citys altitude in meters. Note that an altitude in meters can be computed as 0.3048 * altitude in feet. i.e., define the new predicate: city_altitude_in_meters(City, State, Feet, Meters):- ......

the following queries can be used to test the rules, You can also replace X or Y with names of people to see if Prolog answer the query correctly using the rule.

|?-high_city(City).

|?-city_altitude_in_meters(City,State, Feet, Meters).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

Introduce and define metals and nonmetals and explain with examples

Answered: 1 week ago

Question

What is IUPAC system? Name organic compounds using IUPAC system.

Answered: 1 week ago

Question

What happens when carbonate and hydrogen react with carbonate?

Answered: 1 week ago

Question

Understand how to design effective service guarantees.

Answered: 1 week ago

Question

Know when firms should not offer service guarantees.

Answered: 1 week ago