Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started