Consider the following problem: 1. You have a four-gallon jug and a three-gallon jug, neither of which has any markings. Understand what this means. The only reliable observations are: a jug is empty in which case it has zero gallons in it; or, a jug is full, in which case it has its "capacity" gallons in it, and any other conclusions you can logically draw from these states. For example, say you fill the 4-gallon jug, and then fill the 3-gallon jug from it, you can logically conclude that there is 1 gallon left in the 4-gallon jug. Since the jugs have no markings, no other amounts can be transferred from the full 4- gallon jug to the 3-gallon jug. In this example, you cannot transfer 1, or 1.5, or 2, or 2.25, or 3.142 gallons of water from the 4- gallon jug to the 3-gallon jug. 2. There is a faucet from which you can top off the jugs as many times as you wish. Following this, a jug has its "capacity" gallons in it. 3. You can empty one jug into the other, or onto the ground, in which case the jug is known to have zero gallons in it. 4. You can transfer water between the two jugs. Again, since the jugs have no markings, the only transfers that are logical are those that leave one jug full or the other empty. Write a Prolog program that finds a sequence of moves (in the form of a list of instructions) that, starting from two empty jugs, ends with exactly two gallons of water in the 4-gallon jug and no water in the 3-gallon jug.
Consider the following problem: 1. You have a four-gallon jug and a three-gallon jug, neither of which has any markings. Understand what this means. The only reliable observations are: a jug is empty in which case it has zero gallons in it; or, a jug is full, in which case it has its "capacity" gallons in it, and any other conclusions you can logically draw from these states. For example, say you fill the 4-gallon jug, and then fill the 3-gallon jug from it, you can logically conclude that there is 1 gallon left in the 4-gallon jug. Since the jugs have no markings, no other amounts can be transferred from the full 4- gallon jug to the 3-gallon jug. In this example, you cannot transfer 1, or 1.5, or 2, or 2.25, or 3.142 gallons of water from the 4- gallon jug to the 3-gallon jug. 2. There is a faucet from which you can top off the jugs as many times as you wish. Following this, a jug has its "capacity" gallons in it. 3. You can empty one jug into the other, or onto the ground, in which case the jug is known to have zero gallons in it. 4. You can transfer water between the two jugs. Again, since the jugs have no markings, the only transfers that are logical are those that leave one jug full or the other empty. Write a Prolog program that finds a sequence of moves (in the form of a list of instructions) that, starting from two empty jugs, ends with exactly two gallons of water in the 4-gallon jug and no water in the 3-gallon jug.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
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 2 steps
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education