Areas Reasoning and proof Heuristics of discovery Example
Measuring 6 liters with jugs of 4 and 9 liters, found by working backwards
Builds on Working backwards
Example
We have a jug that holds exactly liters, a jug that holds exactly liters, and an unlimited supply of water. The jugs have no marks. A move fills a jug completely, empties a jug completely, or pours one jug into the other until the first is empty or the second is full. The goal is exactly liters in the large jug.
We write a state as a pair , where is the amount in the small jug and the amount in the large jug, and the start is . We use working backwards: from the goal, we ask at each stage which state comes just before.
- The goal is . A full large jug holds liters, so liters remain if exactly liters are poured out of a full large jug.
- A pour into the small jug stops when the small jug is full. So exactly liters flow when the small jug already holds liter, and the state before is .
- The state comes from by filling the large jug.
- The state comes from by pouring the large jug into the small jug.
- A full large jug holds liters. Two pours into the empty small jug, with the small jug emptied in between, leave liter, so comes from .
- The state comes from the start by filling the large jug, so the backward chain has reached the start.
Now we reverse the chain and check each move forward.
- Fill the large jug: .
- Pour the large jug into the small jug, which moves liters: .
- Empty the small jug: .
- Pour the large jug into the small jug: .
- Empty the small jug: .
- Pour the large jug into the small jug, which moves liter: .
- Fill the large jug: .
- Pour the large jug into the small jug, which moves liters: .
The large jug holds liters after moves.
Remarks
The forward search from branches at every state, and most branches do not lead to liters. The backward search starts from one fact about the goal, , and each step reduces the goal to a smaller one, such as "have liter in the small jug". A breadth-first search over the states that can be reached from confirms that moves is the least possible number.
The answer depends on the sizes of the jugs. With jugs of and liters, the large jug can hold every whole number of liters from to , which agrees with . With jugs of and liters, the amount cannot be reached, and the backward search for 5 liters with jugs of 4 and 6 liters shows why working backwards alone cannot settle that case.
Going deeper
For a student
We use the same method on a smaller case: get liter with jugs of and liters. We guess that the last move pours a full small jug into the large jug and stops when the large jug is full. Such a pour leaves liter when liters flow, so the large jug held liters, and the state before is . That state comes from by filling the small jug, which comes from by a pour, which comes from the start by filling the small jug. The forward check is so the small jug holds liter after moves.
This is the typical use: write the target as a combination of the capacities, such as or , and read the moves from it. Watch out: the guess for the last move could be wrong, and another guess can lead back to a state already met. Working backwards is a search with a good starting point, not an algorithm that always succeeds.
Reading path
To understand this page from the ground up, read these 48 pages in order. The foundations come first. The path takes the proof Proof of unique readability by counting brackets.
- Alphabet concept
- Arity concept
- Boolean function concept
- Countermodel concept
- Effectively decidable set concept
- Formal language concept
- Function concept
- Induction on well-formed formulas concept
- Proposition concept
- Propositional letter concept
- Set concept
- String concept
- Tuple concept
- Signature concept
- Logical connective definition
- Conjunction definition
- Disjunction definition
- Material implication definition
- Principle of bivalence concept
- Predicate concept
- Biconditional definition
- Term concept
- Negation concept
- Negation definition
- Atomic formula concept
- Truth table concept
- Material implication concept
- Conjunction concept
- Disjunction concept
- Biconditional concept
- Universal quantifier concept
- Logical connective concept
- Existential quantifier concept
- Well-formed formula concept
- Propositional formula definition
- Propositional formula concept
- Formal system concept
- Proof of unique readability by counting brackets proof
- Unique readability theorem statement
- Truth valuation concept
- Logical consequence concept
- Rule of inference concept
- Modus ponens concept
- Mathematical proof concept
- Deductive, inductive and abductive reasoning concept
- Heuristics in mathematics concept
- Working backwards concept
- Measuring 6 liters with jugs of 4 and 9 liters, found by working backwards example
Further reading
About this page
| Tag | CJJZX90P2M |
|---|---|
| URI | m2://CJJZX90P2M |
| Kind | example |
| Writing | W0 stub |
| MSC | 00A35, 00A08 |
| Instance of | Working backwards |
| Part of | Heuristics of discovery |
| Uses | Working backwards |
| Changed | 23 November 2026, first written 17 November 2026 |
Markdown · JSON · Edit on GitHub
What this page needs for W1
- an inventory row: the row of the inventory that the node accounts for (0 of 1)
The writing levels say how complete the text of a page is. They do not measure its truth.
History
Each change to this page, from its provenance log. A change by an agent names its run.
| Date | Change | Field | By |
|---|---|---|---|
| 2026-11-17 | add | the whole node | tamnd |
| 2026-11-23 | change | the section Example | tamnd |
| 2026-11-23 | change | the explanation L1 | tamnd |
| 2026-11-23 | change | the explanation L2 | tamnd |
| 2026-11-23 | change | the section Remarks | tamnd |
| 2026-11-23 | change | the field name | tamnd |
What links here
No page links to this page yet.