Documentation

CslibFrontier.Computability.TreeEval.Ary.IterativeCorrect

Correctness of the iterative fan-in-d Cook–Mertz controller #

A call evaluates the existing recursive procedure while preserving its caller's continuation stack. Node access is supplied by a path lookup agreeing with a subtree. In particular, using an existing Ary.Tree as the lookup yields a terminating root call with exactly Ary.procWith's registers. No separate tree or evaluation semantics is introduced.

Main results #

References #

This proves pure control-loop correspondence, not a native implicit-input space theorem. The gate extension is supplied; its implementation and same-input subroutine composition are separate from the control-loop correspondence.

theorem Cslib.TreeEval.Ary.Iter.exists_runFrom_call {K : Type u_2} [Field K] {d b r : ℕ} (hd : 0 < d) (e : (Fin b → Bool) → Fin r → K) (E : Gate d b → (Fin d → Fin r → K) → Fin r → K) (us : List Kˣ) (read : List (Fin d) → Tree.Node d b) {h : ℕ} (T : Tree d b h) (st : List (Frame K d)) (hread : ∀ (P : List (Fin d)), read (path st ++ P) = T.nodeAt P) (S : State K d r) (c : K) (t : Fin (d + 1)) :
∃ (N : ℕ), runFrom hd e E us read { regs := S, stack := st, mode := Mode.call c t } N = { regs := procWith e E us T c t S, stack := st, mode := Mode.ret }

A call on any subtree implemented by the supplied lookup runs the existing recursive procedure and returns to the same continuation stack, from arbitrary global register contents.

theorem Cslib.TreeEval.Ary.Iter.exists_runFrom_root {K : Type u_2} [Field K] {d b r : ℕ} (hd : 0 < d) (e : (Fin b → Bool) → Fin r → K) (E : Gate d b → (Fin d → Fin r → K) → Fin r → K) (us : List Kˣ) {h : ℕ} (T : Tree d b h) (S : State K d r) (c : K) (t : Fin (d + 1)) :
∃ (N : ℕ), runFrom hd e E us T.nodeAt (initialCfg S c t) N = { regs := procWith e E us T c t S, stack := [], mode := Mode.ret }

The complete root call terminates with exactly the recursive procedure's registers.