✓
Passing This code compiles and runs correctly.
Code
// PIN (recursion-unroll pass, challenge 035 leg — CONTROL): tak is
// excluded under the v1 predicate. Its 4 self-call sites permute which
// caller param decreases into which callee position, and the dependent
// `tak(t1,t2,t3)` site has NO affine-decreasing argument at all — no
// common measure exists, and s=4 would explode G(D) anyway. The pass must
// refuse: the emitted shape stays the flat segment machine —
// `__koru_seg_eval` present, exactly 1 `tak_event.handler(` site (the
// external call), no substituted guards.
import std/io
pub tor tak { x: i64, y: i64, z: i64 } -> i64
tak = if(x > y)
| then |> tak(x: x - 1, y, z): t1 |> tak(x: y - 1, y: z, z: x): t2 |> tak(x: z - 1, y: x, z: y): t3 |> tak(x: t1, y: t2, z: t3): v -> v
| else -> z
tak(x: 3, y: 2, z: 1): r |> std/io:print.ln("{{ r:d }}")
Actual
2
Expected output
2
Flows
subflow ~tak click a branch to expand · @labels scroll to their anchor
if (x > y)
flow ~tak click a branch to expand · @labels scroll to their anchor
tak (x: 3, y: 2, z: 1)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# Pin (CONTROL): tak-shaped recursion must NOT be unrolled — no param
# decreases on every self-call site (args permute across positions and the
# dependent call has none). The emitted shape stays the flat segment
# machine: __koru_seg_eval present and exactly 1 `tak_event.handler(` site
# — the external call. If the pass fired, inline_body would bypass segment
# lowering and the census would change.
set -e
if ! grep -q '__koru_seg_eval' output_emitted.zig; then
echo "FAIL: __koru_seg_eval absent — tak did not keep the segment-machine lowering (pass may have transformed it)"
exit 1
fi
sites=$(grep -o 'tak_event\.handler(' output_emitted.zig | wc -l | tr -d ' ')
if [ "$sites" -ne 1 ]; then
echo "FAIL: expected baseline 1 tak_event.handler( site under segment lowering, found $sites — tak was transformed"
exit 1
fi