ch:corecursive-definitions: ch:corecursive-definitions
Problem, result, and invariant. Reject mutual head aliases that can cycle before producing an observation, while computing finite prefixes of accepted stream machines. Maintain the invariant that every zero-weight edge decreases a stored topological rank; positive edges are omitted from the zero-cycle search because they discharge a tail demand.
Representation tradeoff. A lazy stream value would use host-language thunks, obscuring which demand forces a step. The companion represents streams as a finite state machine and observations as explicit state transitions. This representation cannot denote every Timpl stream, but it makes each requested head and tail action visible and keeps graph checking separate from observation.
First complete version. Do not write the weighted graph down beside the declarations; derive it from them. Represent a declaration by its head right side — a producer or a head alias — and its tail step. A head alias emits the weight-zero edge and a tail step the weight-one edge, so the two cannot drift apart. Compute a topological rank by one relaxation round per vertex, taking each vertex to one more than the largest rank among its zero-successors. Then verify the stored certificate at every vertex: each zero edge must strictly decrease the rank. That single test is the acyclicity test.
Remaining cases. Add from-0, whose observer answers a requested number of observations rather than consuming a fuel budget. Add the two-state alternating group, which has no zero edge at all, and a three-vertex alias-chain, which has two — without the second fixture the rank table is never exercised on the accepted side. Perform the static alias resolution of the coiterator elaboration on that chain, following zero edges to a producer within the vertex count, and print the resolved heads. Add head-loop with zero edges f->g and g->f, and reconstruct the cycle so that the printed path is computed.
Observable result. The accepted program prints from-0=0,1,2,3, accepts alternating and the alias chain with their ranks, prints the resolved heads of the chain, rejects the named zero cycle, and finishes with All 5 Chapter 124 corpus cases passed.
Two failing versions. Relax the rank table once instead of once per vertex. The mutant still typechecks, but the guarded alias chain now fails its own rank certificate and is rejected with no cycle to show for it — the signature of an incomplete fixed point. Then, separately, drop the strict decrease from the zero-edge certificate; the mutant accepts head-loop and prints two mutually aliasing heads at equal rank.
Acceptance test. Run the four commands in subappendix E.5. Require a passing check, one passing inline test, the exact six-line run transcript, and an empty audit. Replay each mutation, require the named oracle to fail, restore the accepted source, and rerun all commands.
Mathematical boundary. The graph predicate computes the finite criterion of definition 124.6; the prefix is a witness for four finite demands. Neither execution proves theorem 124.10, and a bounded graph search is not a normalization argument for a coinductive calculus.