Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Prolog: In class I showed a simple family tree example of the basic capabilities of Prolog. On the class web page you will find

Prolog: In class I showed a simple family tree example of the basic capabilities of Prolog. On the class web page you will fi

Prolog: In class I showed a simple family tree example of the basic capabilities of Prolog. On the class web page you will find a brief Prolog tutorial that uses that same example. To help you understand how Prolog works, implement the following in it, and answer the questions given below. Consider the north side of 4th Street on the UA campus. From west to east, ignoring minor buildings, the buildings are Cochise, South Hall, Saguaro, Yavapai, Marley, Shantz, and Biological Sciences East. On the south side of 4th, again west to east, are McClelland Park, Gould-Simpson, Physics Atmospheric Sciences, CHRP, and Pueblo De La Cienega. Create a Prolog database in a file named fourth.pl that allows the user to ask queries about the reachability of these buildings along 4th Street. In particular, here's what we want your program to include: Facts about these buildings' orientations relative to one another. Only one binary fact name is needed: west (). west (X, Y) is used to represent the fact that building X is adjacent to and immediately west of building Y. Use west() to reflect the orientation of the buildings, as given above. For the buildings with multi-word names, use these abbreviations: sh for South Hall, bse for Biological Sciences East, mp for McClelland Park, gs for Gould-Simpson, pas for Physics-Atmospheric Sciences, and pdle for Pueblo De La Cienega. Of course, all names need to be capitalized appropriately (see the Prolog tutorial). The following rules that Prolog can use to determine various building relationships: nextdoor (X,Y): Determines if X and Y are adjacent buildings (that is, next to one another and on the same side of the street) - inbetween (X,Y,Z): Determines if building Y is adjacent to both buildings X and Z. - waywest (X, Y): Determines if building X is more than one building west of building Y. - wayeast (X, Y): Determines if building X is more than one building east of building Y. Note: Do not add any more facts to your database to write this; use what you've got. - farapart (X, Y): Determines if at least one building is positioned between buildings X and Y. Important Note: We will not accept rules that include predetermined answers. Write the rules so that Prolog has to figure out the answers for you. If you find yourself trying to put constants in your rules instead of variables, you're not writing the rules correctly. A comment at the top of the file giving, at minimum, your name, group #, and assignment number. After you have created your program and, using gprolog on lectura, verified that your rules are working as they should with the given facts, submit your completed program file(s) using the turnin command on lectura. The submission directory is cs245h4. Instructions are available from the brief turnin tutorial linked to the class web page. (The same tutorial explains one way to get files from your home PC to lectura.) Remember to name your database file fourth.pl so that we don't have to guess which file to test. Finally, provide written answers to the following questions. Add these answers to those you created for the questions on the front; that is, don't put them in your Prolog database file. 1. Express your inbetween (X,Y,Z) rule as a Horn clause. (The tutorial handout defines 'Horn clause.') 2. Consider the following rule, which is meant to find out if Y can be reached from X without crossing the street: nostreet (X,Y) - nextdoor (X,Y); ( nextdoor (X, Z), nostreet (Z,Y) ). (In Prolog, ';' means 'or'.) Add this rule to your database, and use it to answer this query: nostreet (mp, X). Based on the results, answer the following questions: (a) Did Prolog's collection of results include all of the correct answers? (b) Why does it produce "mp" as an answer? Provide a detailed explanation. (Hint: You might find the trace command to be helpful.)

Step by Step Solution

3.36 Rating (146 Votes )

There are 3 Steps involved in it

Step: 1

1 Express your inbetween XYZ rule as a Horn clause inbetweenXYZ westXY westYZ 2 a Did Prologs collec... 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

Step: 3

blur-text-image

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

Elementary Statistics

Authors: Neil A. Weiss

8th Edition

321691237, 978-0321691231

More Books

Students also viewed these Operating System questions

Question

Prove that if Σ an is absolutely convergent, then a. an

Answered: 1 week ago