Question: DLV ASCII Consider a geographical database ( see geo. db in Files / Programs / ) . Note that DLV can be provided with multiple

DLV ASCII
Consider a geographical database (see geo. db in Files/Programs/). Note that DLV can be provided with multiple input files so you can write your solution in a separate file and feed both files to DLV on the command line. The command line switch "-nofacts" will omit printing the entire database every time. The database has the schema listed below (essentially, each predicate is a table in a relational database)
state(name, abbreviation, captial, population, area, orderJoinedUSA,
largestcity, secondlargest, third, fourth)
city(state, stateabbrev, name, population)
river(riverName, length)
riverin(riverName, state).
borders(state, state).
highlow(state, abreviation, highPlace, height1, lowPlace, height2)
mountain(state, abreviation, mountainName, height)
lake(lakeName, size)
lakein(lakeName, state).
road(roadName, state).
Answer the following database queries. One way to surface the answers easily is to write predicates like "part4a(X) :-..." where you define the solution for that part.
(a) What are the names of rivers that run through Texas?
(b) Which lakes are in at least two different states?
(c) Two states are nearby if
(i) They share a border
(ii) They share a border with the same state
Find all the states nearby a state containing a city named Kansas City.
(d) A Symbolic Set in DLV is a syntactic construct { Variables : Conjunction} that creates a set of all variables that make the conjunction true. Much like in SQL, you can apply aggregate functions find the #count, #sum, #times, #min, and #max of the
(first) variable in the Symbolic Set. For example:
answer (C) I- C - #oount{N i riverin(N, "pennsylvanis"), river (N,L), L>1000}.
Counts the number of rivers in Pennsylvania that are longer than 1000 miles long (the answer is 1 by the way)."{N : riverin(N, "pennsylvania"), river (N,L), L>1000)" is a symbolic set representing all the values N that are the names of rivers in PA that are longer than 1000 miles long, and #count says to count how many.
Find the number of states that border any state containing the shortest river.
(e) What is the most populous state with a mountain higher than 4000(meters)?
Note use dlv.mingw.exe in Windows to solve

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!