✓
Passing This code compiles and runs correctly.
Code
// PIN (recursion-unroll pass, challenge 035 leg — CONTROL): ackermann is
// the dossier's named control. It is hanoi's structural twin — nested
// sibling-fed calls — but NO param decreases on all 3 self-call sites
// (`n==0` arm holds m; else-arm inner call holds m; outer call feeds n an
// unbounded sibling result; the m==0 produce increases n 0->1 is in the
// then-arm, not a call). Lexicographic (m,n) termination is invisible to a
// single-param witness, so the pass must refuse: the emitted shape stays the
// flat segment machine (320_148's pin) — `__koru_seg_eval` present, exactly
// 1 `ack_event.handler(` site (the external call; the impl has zero direct
// self-calls under segment lowering), no substituted guards.
import std/io
pub tor ack { m: i64, n: i64 } -> i64
ack = if(m == 0)
| then -> n + 1
| else |> if(n == 0)
| then |> ack(m: m - 1, n: 1): v -> v
| else |> ack(m, n: n - 1): inner |> ack(m: m - 1, n: inner): v -> v
ack(m: 2, n: 3): r |> std/io:print.ln("{{ r:d }}")
Actual
9
Expected output
9
Flows
subflow ~ack click a branch to expand · @labels scroll to their anchor
if (m == 0)
flow ~ack click a branch to expand · @labels scroll to their anchor
ack (m: 2, n: 3)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# Pin (CONTROL): ackermann-shaped recursion must NOT be unrolled. The pass
# refuses (no param decreases on all 3 self-call sites), so the emitted
# shape stays the flat segment machine: __koru_seg_eval present and exactly
# 1 `ack_event.handler(` site — the external call; the impl carries zero
# direct self-calls under segment lowering. If the pass fired, inline_body
# would bypass segment lowering and the census/guards would change.
set -e
if ! grep -q '__koru_seg_eval' output_emitted.zig; then
echo "FAIL: __koru_seg_eval absent — ackermann did not keep the segment-machine lowering (pass may have transformed it)"
exit 1
fi
sites=$(grep -o 'ack_event\.handler(' output_emitted.zig | wc -l | tr -d ' ')
if [ "$sites" -ne 1 ]; then
echo "FAIL: expected baseline 1 ack_event.handler( site under segment lowering, found $sites — ackermann was transformed"
exit 1
fi
if grep -qE 'm - 1\)?.*== 0|n - 1\)?.*== 0|\(m - 1\) == 0|\(n - 1\) == 0' output_emitted.zig; then
echo "FAIL: parameter-substituted guard present — ackermann was unrolled"
exit 1
fi