Math 2.0

Areas Reasoning and proof Heuristics of discovery Example

The backward search for 5 liters with jugs of 4 and 6 liters

Builds on Working backwardsInvariantsParity arguments

Example

With a jug of exactly 44 liters, a jug of exactly 66 liters and unlimited water, can we get exactly 55 liters in one jug? The moves are as in measuring 6 liters with jugs of 4 and 9 liters: fill a jug, empty a jug, or pour one jug into the other until the first is empty or the second is full. A state is a pair (s,ℓ)(s, \ell) of the amounts in the small and the large jug, and the start is (0,0)(0, 0). We try working backwards and see where it misleads.

  1. The goal is ℓ=5\ell = 5. A full large jug holds 6=5+16 = 5 + 1 liters, so we could pour 11 liter out of a full large jug.
  2. A pour moves exactly 11 liter into the small jug when the small jug holds 33 liters, so the new goal is s=3s = 3.
  3. A pour from the large jug into an empty small jug stops at 44 liters or when the large jug is empty. So one way to get s=3s = 3 is to pour a large jug that holds 33 liters into the empty small jug, and the new goal is ℓ=3\ell = 3.
  4. To get ℓ=3\ell = 3 we could pour 33 liters out of a full large jug, so the small jug must hold 11 liter, and the new goal is s=1s = 1.
  5. To get s=1s = 1, either the large jug holds 11 liter and is poured into the empty small jug, or a full small jug pours 33 liters into a large jug that holds 33. Each new goal asks again for an odd amount.

The backward chain moves among the goals "11 liter", "33 liters" and "55 liters", and it never reaches the start (0,0)(0, 0). So working backwards gives no plan. It also gives no proof that no plan exists, because a cleverer backward step might have been missed.

An invariant settles the question.

  1. We claim that in every state that can be reached from (0,0)(0, 0), both amounts are even.
  2. The start (0,0)(0, 0) has both amounts even.
  3. Filling a jug puts 44 or 66 liters in it, and emptying a jug leaves 00, all even.
  4. A pour moves either all the water of the first jug, ss or ℓ\ell, or the free space of the second jug, 4−s4 - s or 6−ℓ6 - \ell. If ss and ℓ\ell are even, each of these amounts is even, so both amounts stay even.
  5. By induction on the number of moves, the claim holds in every reachable state.
  6. The goal needs 55 liters in a jug, and 55 is odd, so no sequence of moves reaches the goal.

Remarks

The example shows a limit of working backwards: it can find a plan, but a failure to find one proves nothing. To show that a goal cannot be reached, we need an argument about all states at once, such as a parity argument.

The invariant also explains why the backward chain kept asking for odd amounts. A computer search over all 5⋅7=355 \cdot 7 = 35 pairs (s,ℓ)(s, \ell) confirms that only 1010 of them can be reached, and each has both amounts even. In general, with jugs of pp and qq liters, the large jug can hold exactly the multiples of gcd⁡(p,q)\gcd(p, q) from 00 up to its size. For jugs of 44 and 66 liters, gcd⁡(4,6)=2\gcd(4, 6) = 2, so the large jug can hold 00, 22, 44 or 66 liters.

Going deeper

For a student

We compare two ways to treat a goal that may be impossible. A backward search lists the states that lead to the goal, and if it is complete and runs out of new states, it proves impossibility, but a search by hand is seldom complete. An invariant is one property, here "both amounts are even", that holds at the start, survives each move, and fails at the goal. For jugs of 66 and 99 liters and the goal of 44 liters, the invariant "both amounts are multiples of 33" works in the same way, since 44 is not a multiple of 33.

This is the typical use: when working backwards keeps returning to the same kind of goal, look for a quantity that every move preserves. Watch out: a short backward search that fails is not a proof, because a missed move could open a path.

Reading path

To understand this page from the ground up, read these 63 pages in order. The foundations come first. The path takes the proofs Proof of unique readability by counting brackets, Proof of the double negation law by a truth table.

  1. Alphabet concept
  2. Arity concept
  3. Boolean function concept
  4. Congruence modulo n concept
  5. Countermodel concept
  6. Effectively decidable set concept
  7. Formal language concept
  8. Function concept
  9. Induction on well-formed formulas concept
  10. Mathematical statement definition
  11. Natural numbers object
  12. Proposition concept
  13. Propositional letter concept
  14. Set concept
  15. String concept
  16. Tuple concept
  17. Signature concept
  18. Logical connective definition
  19. Connectives in mathematical language concept
  20. Conjunction definition
  21. Disjunction definition
  22. Material implication definition
  23. Principle of bivalence concept
  24. Predicate concept
  25. Conditional statements concept
  26. Biconditional definition
  27. Term concept
  28. Negation concept
  29. Negation definition
  30. Atomic formula concept
  31. Quantifiers in mathematical writing concept
  32. Truth table concept
  33. Material implication concept
  34. Conjunction concept
  35. Disjunction concept
  36. Negating mathematical statements concept
  37. Tautology concept
  38. Biconditional concept
  39. Universal quantifier concept
  40. Logical equivalence concept
  41. Logical connective concept
  42. Existential quantifier concept
  43. Well-formed formula concept
  44. Proof of the double negation law by a truth table proof
  45. Propositional formula definition
  46. Propositional formula concept
  47. Double negation law statement
  48. Formal system concept
  49. Proof of unique readability by counting brackets proof
  50. Unique readability theorem statement
  51. Truth valuation concept
  52. Logical consequence concept
  53. Rule of inference concept
  54. Modus ponens concept
  55. Mathematical proof concept
  56. Deductive, inductive and abductive reasoning concept
  57. Proof by contradiction concept
  58. Mathematical induction concept
  59. Heuristics in mathematics concept
  60. Invariants concept
  61. Parity arguments concept
  62. Working backwards concept
  63. The backward search for 5 liters with jugs of 4 and 6 liters example

Further reading

  1. Web https://en.wikipedia.org/wiki/Water_pouring_puzzle, lead section
About this page
Tag33P1SJW98J
URIm2://33P1SJW98J
Kindexample
WritingW0 stub
MSC00A35, 00A08
Not an instance ofWorking backwards (note: working backwards from 5 liters produces only states with an odd amount and never reaches the start, but it cannot show by itself that no plan exists; an invariant proves the impossibility.)
Part ofHeuristics of discovery
UsesWorking backwards, Invariants, Parity arguments
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
2026-11-23changethe field not_instance_oftamnd

What links here

No page links to this page yet.