*********THIS IS A PROGRAMMING ASSIGNMENT******** Prolog Programming AssignmentDUE: 11:59PM April 13. ASSIGNMENT: This assignment concerns facts that might be part ofa world of stackable blocks (such...

*********THIS IS A PROGRAMMING ASSIGNMENT********
Prolog Programming AssignmentDUE: 11:59PM April 13.


ASSIGNMENT: This assignment concerns facts that might be part ofa world of stackable blocks (such as in exercise A.7). You will createa fact file and a rule file.
Facts: For each block (b1, b2, ...) there will be facts such as:

red(b1).blue(b2).weight(b3).
Also there will facts about the stacking order; if b2 is on b1 then we have:

on(b2,b1).
You can have one block on more than one block and vice versa. (The scene ofblocks described by the facts should be 2-dimensional.)
Rules: You will write the following rules (you can write more):

chain(X,Y)Succeeds if there is a chain of blocks from X to Y,each one on the next one.

goodchain(X,Y)Succeeds if there is a chain of blocks from X to Y,each one on the next one of greater weight.

monochain(X,Y)Succeeds if there is a monochromatic chain from X to Y.

top(X)Succeeds if block X is not under another block.

bottom(X)Succeeds if block X is not on another block.

maximalchain(X,Y)Succeeds there is a chain from X to Y, from the topto the bottom.

maxmonochain(X,Y)True if there is a maximal monochromatic chain fromX to Y.

supportedby(X,Y)True if X is on Y and only on Y.


WHAT TO DO: You will create your own file of facts, that will adequately test the rules. You will create your own file of rules as specified above. You will create your own file of queries, that will adequately test the rules.
The set of facts must be of your own invention. Your queries, at least 10, must bevaried (as in figure A.1) and test all your rules (even degenerate cases).You shouldbriefly annotate each query to indicate what the corresponding query would be inenglish. You will submit the three text files to the TA, ourfacts, your rules, and a text file. If there is something the TA needs to know torun your code you should mention that too. We will it test using our own facts.


GRADING: You will be graded on completeness, correctness, your facts and your queries.


SOME ADVICE: Study Appendix A of the text. Section A.2 has some practicaldetails. First try just starting and stopping (see table below).
Files: Before entering a Prolog session, create a file (using any editor) thatcontains the facts and rules you wish to test. Start with simple predicates. Avoid blanks between the predicate and the left parenthesis Start variable names with Capitals. Start predicates, facts and data names with lower case letters. Don't forget the period at the end of facts and rules.
Starting: At the Unix prompt, type the Unix command "prolog" to startinteracting with the Quintus Prolog interpreter on the server. To loadyour facts and/or rules from a file called file1 into the session, type[file1]. ending with a period. If you entered Prolog while not in thedirectory containing the file, give the full path, within single quotes:['pro/file1']. (You can also use the consult() command as described in thetext.) You can load two files at once, like this: [factfile, rulefile]. Ifyou unintentionally hit the key without the period, just type aperiod and another . After loading your file(s), type in queries andyou'll get the answers.
Stopping: Before you start anything, know how to stop it! To halt a Prologsession, use halt. which is a Prolog predicate with no arguments, with theside-effect of exiting Prolog. To stop an unresponsive Prolog process thatmay be in an infinite loop, use a .
Tracing: For debugging, you can have the Prolog processor trace the steps bywhich it reached its conclusions. This can get pretty complex, though, so youmay want to turn it off. Variables tend to have bizarre names in the trace.To start the process type trace and to turn it off, use notrace.
Online help: To get Prolog help, type the special predicate help. which tellsyou about the special predicate manual(...). You can also search Google forQuintus Prolog.
Apr 11, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here