Prolog: In class I showed a simple family tree example of the basic capabilities of Prolog....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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.) 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.)
Expert Answer:
Answer rating: 100% (QA)
1 Express your inbetween XYZ rule as a Horn clause inbetweenXYZ westXY westYZ 2 a Did Prologs collec... View the full answer
Related Book For
Posted Date:
Students also viewed these operating system questions
-
Read the following text critically and answer the questions given below . In its widest sense, government means the framework and rules by which decisions that affect a community as a whole are...
-
Read the following scenario and answer the questions given at last: Robert is a delivery specialist. He started at a young age by delivering newspapers. Later, he delivered pizzas. He has since...
-
Case Study Analysis, Read carefully the following case/scenario and answer the questions given at the end. A manufacturing company, involved in the business of food processing, faces a technical...
-
On July 1, 2021, Katrina purchased tax-exempt bonds (face value of $75,000) for $82,000. The bonds mature in five years, and the annual interest rate is 3%. a. How much interest income and/or...
-
a. What is the present value of a 3-year annuity of $100 if the discount rate is 6%? b. What is the present value of the annuity in (a) if you have to wait 2 years instead of 1 year for the first...
-
Evaluate the cross products A Ã B and C Ã D. (a) A (b) 4 90 45 FIGURE EX12.38
-
A person donates a bag of clothes to Goodwill completely unaware that there is valuable sterling silver in the bag. The clothing and silver are subsequently sold, for a very economical price, to...
-
On January 1, 2012, Roosevelt Company purchased 12% bonds, having a maturity value of $500,000, for $537,907.40. The bonds provide the bondholders with a 10% yield. They are dated January 1, 2012,...
-
thank you I've been having lots of troubles opening any documents in full they just appear as blank would you know why this is or perhaps be able to assist me
-
The neural structure of the sea slug Aplysia has been widely studied (first by Nobel Laureate Eric Kandel) because it has only about 20,000 neurons, most of them large and easily manipulated....
-
Bonneville Company is producing a subassembly used in the production of a product. The costs incurred for the subassembly follow: Per Unit Direct materials $ 6.00 Direct labor 4.00 Variable factory...
-
What could be the end result of TCS's 2014 joint venture with MC? Did the company's 2019 increase in equity holding in the joint venture from 51 per cent to 66 per cent represent an appropriate level...
-
What additional system attributes, beyond basic computer specifications, does the sysinfo command typically furnish?
-
Gutenberg Equipment sells a two-ton printing press to Olden Publishers. The press will be a fixture, installed in Olden Publishers' bindery. How should Gutenberg file to perfect its security interest?
-
Using the Corporate Valuation Method, you have determined the market value of the firm LKM is $2.5 billion. LKM has debt and preferred with a market value of $1 billion. If LKM has 75 million shares...
-
Careful Bank and Carefree Bank both have loans to Middlemarch Industries, secured by Middlemarch Industries' equipment and inventory. Carefree Bank made its loan and security agreement first but did...
-
A portfolio has 30% of its value in Company A and the rest in Company B. The volatitly of Company A and B are 25% and 33%, respectively, and the correlation between both companies is 0.6. what is the...
-
Prove that if Σ an is absolutely convergent, then a. an
-
In 1905, R. Pearl published the article "Biometrical Studies on Man. I. Variation and Correlation in Brain Weight" (Biometrika, Vol. 4, pp. 13-104). According to the study, brain weights of Swedish...
-
A study published by E. Anionwu et al. in the British Medical Journal (Vol. 282, pp. 283-286) examined the steady-state hemoglobin levels of patients with three different types of sickle cell...
-
= 2 + x a. Decide, at the 10% significance level, whether the data provide sufficient evidence to conclude that x is useful for predicting y. b. Find a 90% confidence interval for the slope of the...
-
What types of noise are we likely to encounter in a professional environment? Are they physical, psychological, or physiological?
-
What does it mean to say that communication is dynamic? How can two people in a conversation be both senders and receivers simultaneously?
-
What is metacommunication, and how do people metacommunicate with one another?
Study smarter with the SolutionInn App