counting change

SICP §1.2.2's counting-change procedure counts the ways to make an amount from a set of coin denominations by splitting on each coin kind in turn. Every call, split, memo-hit, and return below is a recorded step – move the timeline to any step, or change the amount or coins and the whole trace recomputes.

The invariant on display: memoization never changes the value returned, only how many times each (amount, coin-kind) subproblem gets recomputed. Toggle memoization and watch the call count drop while the answer holds steady; the subproblem table (bottom-up, independent of the recursion) is the cross-check that the recursive trace is not just plausible but correct.

The pure trace/replay model lives in wal-sh.tools.counting-change.core (host-neutral .cljc, tested on the JVM with test.check: memoization never changes the value, the recursive trace agrees with the independent bottom-up table, amount 0 is always exactly one way, and a truncated trace still keeps its node ids aligned to their vector positions). The browser adapter is wal-sh.tools.counting-change.browser. Build: gmake tools-cljs; debug in isolation: gmake dev-tool TOOL=counting-change.