✓
Passing This code compiles and runs correctly.
Code
// PIN (recursion-unroll pass, challenge 035 leg): recursion with no
// designated decreasing parameter must REFUSE — silently, unchanged. Each
// self-call site decrements a DIFFERENT param (`n` on site A, `k` on site
// B); no single param decreases on every site, so the termination witness
// fails even though the program terminates (nested-if bases cover both
// params). Baseline: 3 `fnd_event.handler(` sites (2 self + 1 main), no
// substituted guards, correct output. This is the pure-shape refusal — no
// effects involved.
import std/io
pub tor fnd { n: i64, k: i64 } -> i64
fnd = if(n < 2)
| then -> k
| else |> if(k < 0)
| then -> 0
| else |> fnd(n: n - 1, k): a |> fnd(n, k: k - 1): b -> a + b
fnd(n: 4, k: 3): r |> std/io:print.ln("{{ r:d }}")
Actual
15
Expected output
15
Flows
subflow ~fnd click a branch to expand · @labels scroll to their anchor
if (n < 2)
flow ~fnd click a branch to expand · @labels scroll to their anchor
fnd (n: 4, k: 3)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# Pin: recursion where no single param decreases on EVERY self-call site
# (alternating n/k decrements) must NOT be unrolled — the emitted shape
# stays at the baseline 3 `fnd_event.handler(` sites (2 self + 1 main) with
# no parameter-substituted guards. Refusal is silent: the program still
# runs and prints correctly.
set -e
sites=$(grep -o 'fnd_event\.handler(' output_emitted.zig | wc -l | tr -d ' ')
if [ "$sites" -ne 3 ]; then
echo "FAIL: expected baseline 3 fnd_event.handler( sites, found $sites — non-decreasing-param recursion was transformed"
exit 1
fi
if grep -qE 'n - 1\)?.*< 2|k - 1\)?.*< 0|\(n - 1\) < 2|\(k - 1\) < 0' output_emitted.zig; then
echo "FAIL: parameter-substituted guard present — non-decreasing-param recursion was unrolled"
exit 1
fi