Given the following graph of possible flights between seven US cities: Define a
ID: 3597654 • Letter: G
Question
Given the following graph of possible flights between seven US cities:
Define a predicate route/3 that takes two cities as arguments and finds the routes to get
from city A to a city B. Your predicate should have the signature route(cityA, cityB,
Route).
Examples:
?- route(seattle, boston, X).
X = [seattle, omaha, atlanta, boston] ;
false.
?- route(fresno, atlanta, X).
X = [fresno, seattle, omaha, atlanta] ;
X = [fresno, albany, seattle, omaha, atlanta] ;
X = [fresno, albany, dallas, seattle, omaha, atlanta] ;
false.
?- route(albany, atlanta, X).
X = [albany, seattle, omaha, atlanta] ;
X = [albany, dallas, seattle, omaha, atlanta] ;
false.
?- route(boston, atlanta, X).
false.
Define and test the Prolog predicates described below. Each of your predicates must have the
same name and signature as the examples below. Your predicates must behave properly on all
instances of valid input types. Your submission should consist of a single source code text file
that includes all facts, predicate definitions, and propositions.
Omaha Seattle Albany Boston Fresno Dallas AtlantaExplanation / Answer
Mnemonic Opcode Effect
ADD m 18 A <- (A) + (m..m+2)
AND m 58 A <- (A) & (m..m+2) [bitwise]
COMP m 28 cond code <- (A) : (m..m+2)
DIV m 24 A <- (A) / (m..m+2)
J m 3C PC <- m
JEQ m 30 PC <- m if cond code set to =
JGT m 34 PC <- m if cond code set to >
JLT m 38 PC <- m if cond code set to <
JSUB m 48 L <- (PC); PC <- m
LDA m 00 A <- (m..m+2)
LDCH m 50 A[rightmost byte] <- (m)
LDL m 08 L <- (m..m+2)
LDX m 04 X <- (m..m+2)
MUL m 20 A <- (A) * (m..m+2)
OR m 44 A <- (A) | (m..m+2) [bitwise]
RD m D8 A[rightmost byte] <-
data from device specified by (m)
RSUB 4C PC <- (L)
STA m 0C m..m+2 <- (A)
STCH m 54 m <- (A)[rightmost byte]
STL m 14 m..m+2 <- (L)
STX m 10 m..m+2 <- (X)
SUB m 1C A <- (A) - (m..m+2)
TD m E0 Test device specified by (m)
TIX m 2C X <- (X) + 1; compare X and (m..m+2)
WD m DC Device specified by (m) <-
(A)[rightmost byte]
SIC Assembler Directives
START n Program is to be loaded at location n (given in hexadecimal)
END label Physical end of program; label is first executable program statement
BYTE v Stores either character strings (C'...') or hexadecimal values (X'...')
WORD v Stores the value v in a WORD
RESB n Reserves space for n bytes
RESW n Reserves space for n words (3n bytes)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.