Math 2.0

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 44 liters, a jug that holds exactly 99 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 66 liters in the large jug.

We write a state as a pair (s,ℓ)(s, \ell), where ss is the amount in the small jug and ℓ\ell the amount in the large jug, and the start is (0,0)(0, 0). We use working backwards: from the goal, we ask at each stage which state comes just before.

  1. The goal is ℓ=6\ell = 6. A full large jug holds 9=6+39 = 6 + 3 liters, so 66 liters remain if exactly 33 liters are poured out of a full large jug.
  2. A pour into the small jug stops when the small jug is full. So exactly 33 liters flow when the small jug already holds 4−3=14 - 3 = 1 liter, and the state before is (1,9)(1, 9).
  3. The state (1,9)(1, 9) comes from (1,0)(1, 0) by filling the large jug.
  4. The state (1,0)(1, 0) comes from (0,1)(0, 1) by pouring the large jug into the small jug.
  5. A full large jug holds 9=4+4+19 = 4 + 4 + 1 liters. Two pours into the empty small jug, with the small jug emptied in between, leave 11 liter, so (0,1)(0, 1) comes from (0,9)(0, 9).
  6. The state (0,9)(0, 9) 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.

  1. Fill the large jug: (0,0)→(0,9)(0, 0) \to (0, 9).
  2. Pour the large jug into the small jug, which moves 44 liters: (0,9)→(4,5)(0, 9) \to (4, 5).
  3. Empty the small jug: (4,5)→(0,5)(4, 5) \to (0, 5).
  4. Pour the large jug into the small jug: (0,5)→(4,1)(0, 5) \to (4, 1).
  5. Empty the small jug: (4,1)→(0,1)(4, 1) \to (0, 1).
  6. Pour the large jug into the small jug, which moves 11 liter: (0,1)→(1,0)(0, 1) \to (1, 0).
  7. Fill the large jug: (1,0)→(1,9)(1, 0) \to (1, 9).
  8. Pour the large jug into the small jug, which moves 33 liters: (1,9)→(4,6)(1, 9) \to (4, 6).

The large jug holds 66 liters after 88 moves.

Remarks

The forward search from (0,0)(0, 0) branches at every state, and most branches do not lead to 66 liters. The backward search starts from one fact about the goal, 9−3=69 - 3 = 6, and each step reduces the goal to a smaller one, such as "have 11 liter in the small jug". A breadth-first search over the 2626 states that can be reached from (0,0)(0, 0) confirms that 88 moves is the least possible number.

The answer depends on the sizes of the jugs. With jugs of 44 and 99 liters, the large jug can hold every whole number of liters from 00 to 99, which agrees with gcd⁡(4,9)=1\gcd(4, 9) = 1. With jugs of 44 and 66 liters, the amount 55 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 11 liter with jugs of 33 and 55 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 11 liter when 22 liters flow, so the large jug held 5−2=35 - 2 = 3 liters, and the state before is (3,3)(3, 3). That state comes from (0,3)(0, 3) by filling the small jug, which comes from (3,0)(3, 0) by a pour, which comes from the start by filling the small jug. The forward check is (0,0)→(3,0)→(0,3)→(3,3)→(1,5),(0, 0) \to (3, 0) \to (0, 3) \to (3, 3) \to (1, 5), so the small jug holds 11 liter after 44 moves.

This is the typical use: write the target as a combination of the capacities, such as 6=2⋅9−3⋅46 = 2 \cdot 9 - 3 \cdot 4 or 1=2⋅3−51 = 2 \cdot 3 - 5, 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.

  1. Alphabet concept
  2. Arity concept
  3. Boolean function concept
  4. Countermodel concept
  5. Effectively decidable set concept
  6. Formal language concept
  7. Function concept
  8. Induction on well-formed formulas concept
  9. Proposition concept
  10. Propositional letter concept
  11. Set concept
  12. String concept
  13. Tuple concept
  14. Signature concept
  15. Logical connective definition
  16. Conjunction definition
  17. Disjunction definition
  18. Material implication definition
  19. Principle of bivalence concept
  20. Predicate concept
  21. Biconditional definition
  22. Term concept
  23. Negation concept
  24. Negation definition
  25. Atomic formula concept
  26. Truth table concept
  27. Material implication concept
  28. Conjunction concept
  29. Disjunction concept
  30. Biconditional concept
  31. Universal quantifier concept
  32. Logical connective concept
  33. Existential quantifier concept
  34. Well-formed formula concept
  35. Propositional formula definition
  36. Propositional formula concept
  37. Formal system concept
  38. Proof of unique readability by counting brackets proof
  39. Unique readability theorem statement
  40. Truth valuation concept
  41. Logical consequence concept
  42. Rule of inference concept
  43. Modus ponens concept
  44. Mathematical proof concept
  45. Deductive, inductive and abductive reasoning concept
  46. Heuristics in mathematics concept
  47. Working backwards concept
  48. Measuring 6 liters with jugs of 4 and 9 liters, found by working backwards example

Further reading

  1. Web https://en.wikipedia.org/wiki/Water_pouring_puzzle, lead section
  2. Book isbn:9780691164076
About this page
TagCJJZX90P2M
URIm2://CJJZX90P2M
Kindexample
WritingW0 stub
MSC00A35, 00A08
Instance ofWorking backwards
Part ofHeuristics of discovery
UsesWorking backwards
Changed23 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.

The changes to this page, the oldest first
DateChangeFieldBy
2026-11-17addthe whole nodetamnd
2026-11-23changethe section Exampletamnd
2026-11-23changethe explanation L1tamnd
2026-11-23changethe explanation L2tamnd
2026-11-23changethe section Remarkstamnd
2026-11-23changethe field nametamnd

What links here

No page links to this page yet.