state(5,1, [state(5,1)|_1). start(): - state(0,0,[state(0,0)]). state(X,Y,W): - x < 5, upd_state(5, Y, w, 'Rule 1: Fil1 Jug 1 full --->'). state(X, Y,W): - Y<2, upd_state(X,2, W, 'Rule 2: Fill Jug 2 full --- >'). state(X,Y,W): -X>e, upd_state(0,Y, W, 'Rule 3: Empty Jug 1 --->'). state(X,Y,W):-Y>0, upd_state(X,0,w, 'Rule 4: Empty Jug 2 --->'). state(X,Y,W): -X+Y=<5,Y>0, X1 is X+Y, upd_state(X1,0,w, 'Rule 5: Pour all of Jug 2 to Jug 1 --->'). state(X,Y,W): -X+Y>=5,Y>0, Y1 is Y-(5-X), upd_state(5, Y1,W, 'Rule 6: Fill Jug 1 from Jug 2 --->'). state(X,Y,W) : -X+Y>=2, X>0, X1 is X-(2-Y), upd_state(X1,2, W, 'Rule 7: Fill Jug 2 from Jug 1 --->'). upd_state(X, Y, W, P):- not (member(state(X,Y),W)), print ([P,' Current State: (',x,',',Y,').\n'1), state(X,Y, [state(X,Y) |W]). print([]). print([H|T]): -write(H), print (T).
state(5,1, [state(5,1)|_1). start(): - state(0,0,[state(0,0)]). state(X,Y,W): - x < 5, upd_state(5, Y, w, 'Rule 1: Fil1 Jug 1 full --->'). state(X, Y,W): - Y<2, upd_state(X,2, W, 'Rule 2: Fill Jug 2 full --- >'). state(X,Y,W): -X>e, upd_state(0,Y, W, 'Rule 3: Empty Jug 1 --->'). state(X,Y,W):-Y>0, upd_state(X,0,w, 'Rule 4: Empty Jug 2 --->'). state(X,Y,W): -X+Y=<5,Y>0, X1 is X+Y, upd_state(X1,0,w, 'Rule 5: Pour all of Jug 2 to Jug 1 --->'). state(X,Y,W): -X+Y>=5,Y>0, Y1 is Y-(5-X), upd_state(5, Y1,W, 'Rule 6: Fill Jug 1 from Jug 2 --->'). state(X,Y,W) : -X+Y>=2, X>0, X1 is X-(2-Y), upd_state(X1,2, W, 'Rule 7: Fill Jug 2 from Jug 1 --->'). upd_state(X, Y, W, P):- not (member(state(X,Y),W)), print ([P,' Current State: (',x,',',Y,').\n'1), state(X,Y, [state(X,Y) |W]). print([]). print([H|T]): -write(H), print (T).
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
show the output with screenshots of the prolog code below,
![state(5,1, [state(5,1)|_1).
1
2
start():- state(0,0, [state(0,0)]).
state(X, Y,W): - X < 5,
upd_state(5,Y, w, 'Rule 1: Fil1 Jug 1 full --->').
7
state(X, Y,W): - Y<2,
upd_state(X, 2, W, 'Rule 2: Fill Jug 2 full --->').
8
9.
10
state(X,Y,W): -X>0,
upd_state(0, Y, W, 'Rule 3: Empty Jug 1 --->').
11
12
13
state(X, Y,W): -Y>0,
upd_state(X,0,W, 'Rule 4: Empty Jug 2 --->').
14
15
16
state(X,Y,W) : -X+Y=<5,Y>0,
X1 is X+Y,
17
18
19
upd_state(X1,0,W, 'Rule 5: Pour all of Jug 2 to Jug 1 --->').
20
state(X, Y,W): -X+Y>=5,Y>0,
Y1 is Y-(5-x),
upd_state(5, Y1,W, 'Rule 6: Fill Jug 1 from Jug 2 --->').
21
22
23
24
state(X,Y,W) : -X+Y>=2, X>0,
X1 is X-(2-Y),
upd_state(X1,2, W, 'Rule 7: Fill Jug 2 from Jug 1 --->').
25
26
27
28
upd_state(X, Y,W, P): -
not (member(state(X,Y),W)),
print ([P,' Current State: (' ,x,',',Y,').\n']),
state(X,Y, [state(X, Y) |W]).
29
30
31
32
33
print([]).
print([H|T]): -write(H), print(T).
34
35](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F7a7dd82e-c148-41e1-a372-bcc0fedb04b3%2Fabbf3d78-bf56-47e2-a964-2b65b1e163b3%2Fe8btslo_processed.jpeg&w=3840&q=75)
Transcribed Image Text:state(5,1, [state(5,1)|_1).
1
2
start():- state(0,0, [state(0,0)]).
state(X, Y,W): - X < 5,
upd_state(5,Y, w, 'Rule 1: Fil1 Jug 1 full --->').
7
state(X, Y,W): - Y<2,
upd_state(X, 2, W, 'Rule 2: Fill Jug 2 full --->').
8
9.
10
state(X,Y,W): -X>0,
upd_state(0, Y, W, 'Rule 3: Empty Jug 1 --->').
11
12
13
state(X, Y,W): -Y>0,
upd_state(X,0,W, 'Rule 4: Empty Jug 2 --->').
14
15
16
state(X,Y,W) : -X+Y=<5,Y>0,
X1 is X+Y,
17
18
19
upd_state(X1,0,W, 'Rule 5: Pour all of Jug 2 to Jug 1 --->').
20
state(X, Y,W): -X+Y>=5,Y>0,
Y1 is Y-(5-x),
upd_state(5, Y1,W, 'Rule 6: Fill Jug 1 from Jug 2 --->').
21
22
23
24
state(X,Y,W) : -X+Y>=2, X>0,
X1 is X-(2-Y),
upd_state(X1,2, W, 'Rule 7: Fill Jug 2 from Jug 1 --->').
25
26
27
28
upd_state(X, Y,W, P): -
not (member(state(X,Y),W)),
print ([P,' Current State: (' ,x,',',Y,').\n']),
state(X,Y, [state(X, Y) |W]).
29
30
31
32
33
print([]).
print([H|T]): -write(H), print(T).
34
35
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY