Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.BlockComputationTree

HPV block computation as an implicit Tree Evaluation instance #

Each interval has one control dependency and three window dependencies per work tape. Their indices strictly decrease. The existing Ary.Tree unfolds those dependencies, with constant source gates padding shorter paths. Its value is exactly the encoded functional block value.

The supplied codec must decode every encoded value correctly. A guard maps every word outside its image to the distinct FAIL value, so the gate is defined on all bit strings. Codec size, native gate computation, input access and space certification are separate obligations.

Main results #

def Turing.MultiTapePTM.BlockComputation.decodeChecked {k b ℓ : ℕ} {State : Type} (encode : Option (View k State b) → Fin ℓ → Bool) (decode : (Fin ℓ → Bool) → Option (View k State b)) (w : Fin ℓ → Bool) :
Option (View k State b)

A checked decoder returns FAIL rather than treating an invalid word as a valid interval view.

theorem Turing.MultiTapePTM.BlockComputation.decodeChecked_encode {k b ℓ : ℕ} {State : Type} (encode : Option (View k State b) → Fin ℓ → Bool) (decode : (Fin ℓ → Bool) → Option (View k State b)) (hdecode : Function.LeftInverse decode encode) (v : Option (View k State b)) :
decodeChecked encode decode (encode v) = v

Valid codewords are unaffected by the validity guard.

theorem Turing.MultiTapePTM.BlockComputation.decodeChecked_invalid {k b ℓ : ℕ} {State : Type} (encode : Option (View k State b) → Fin ℓ → Bool) (decode : (Fin ℓ → Bool) → Option (View k State b)) (w : Fin ℓ → Bool) (hw : ∀ (v : Option (View k State b)), encode v ≠ w) :
decodeChecked encode decode w = none

Every word outside the encoding's image is decoded as FAIL.

def Turing.MultiTapePTM.BlockComputation.child {k q : ℕ} (σ : Schedule k q) :
ℕ → Fin (k * 3 + 1) → ℕ

Child zero is the preceding interval. The remaining children are the last window providers, numbered by work tape and window entry; missing providers are the initial source.

theorem Turing.MultiTapePTM.BlockComputation.child_lt {k q : ℕ} (σ : Schedule k q) (i : ℕ) (hi : 0 < i) (j : Fin (k * 3 + 1)) :
child σ i j < i

Every dependency of a positive index is strictly earlier, including total out-of-range cases.

noncomputable def Turing.MultiTapePTM.BlockComputation.intervalGate {k q : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) (σ : Schedule k q) :
ℕ → (Fin (k * 3 + 1) → Option (View k State b)) → Option (View k State b)

The unencoded interval gate, with a source gate at zero and FAIL beyond the horizon.

noncomputable def Turing.MultiTapePTM.BlockComputation.codeGate {k q ℓ : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) (σ : Schedule k q) (encode : Option (View k State b) → Fin ℓ → Bool) (decode : (Fin ℓ → Bool) → Option (View k State b)) (i : ℕ) :

Decode all children, run the local interval gate, and encode its result.

noncomputable def Turing.MultiTapePTM.BlockComputation.tree {k q ℓ : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) (σ : Schedule k q) (encode : Option (View k State b) → Fin ℓ → Bool) (decode : (Fin ℓ → Bool) → Option (View k State b)) (height root : ℕ) :
Cslib.TreeEval.Ary.Tree (k * 3 + 1) ℓ height

The complete uniform-height Tree Evaluation instance, unfolded without a new tree model.

theorem Turing.MultiTapePTM.BlockComputation.intervalGate_value {k q : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) (σ : Schedule k q) {n : ℕ} (hn : n < q) :
(intervalGate machine input b σ (n + 1) fun (j : Fin (k * 3 + 1)) => value machine input b σ (child σ (n + 1) j)) = value machine input b σ (n + 1)

At an interval inside the horizon, the unencoded gate applied to the values of its children is the interval's value.

theorem Turing.MultiTapePTM.BlockComputation.eval_tree {k q ℓ : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) (σ : Schedule k q) (encode : Option (View k State b) → Fin ℓ → Bool) (decode : (Fin ℓ → Bool) → Option (View k State b)) (hdecode : Function.LeftInverse decode encode) {height root : ℕ} (hroot : root ≤ q) (hheight : root ≤ height) :
(tree machine input b σ encode decode height root).eval = encode (value machine input b σ root)

Unfolding an interval computation preserves its encoded value.

theorem Turing.MultiTapePTM.BlockComputation.nodeAt_tree {k q ℓ : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) (σ : Schedule k q) (encode : Option (View k State b) → Fin ℓ → Bool) (decode : (Fin ℓ → Bool) → Option (View k State b)) (height root : ℕ) (P : List (Fin (k * 3 + 1))) :
(tree machine input b σ encode decode height root).nodeAt P = Cslib.TreeEval.Ary.Descending.lookup (encode (some (initialView machine b))) (child σ) (codeGate machine input b σ encode decode) height root P

The implicit node lookup follows dependency indices along the path.

theorem Turing.MultiTapePTM.BlockComputation.eval_tree_final_eq_some_iff {k q ℓ : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) (σ : Schedule k q) (encode : Option (View k State b) → Fin ℓ → Bool) (decode : (Fin ℓ → Bool) → Option (View k State b)) (hdecode : Function.LeftInverse decode encode) [NeZero b] (v : View k State b) :
(tree machine input b σ encode decode q q).eval = encode (some v) ↔ actualSchedule machine input b = σ ∧ v = trueView machine input b σ q

The final tree returns the encoded true view exactly for the true complete movement guess.

theorem Turing.MultiTapePTM.BlockComputation.eval_tree_final_eq_fail_iff {k q ℓ : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) (σ : Schedule k q) (encode : Option (View k State b) → Fin ℓ → Bool) (decode : (Fin ℓ → Bool) → Option (View k State b)) (hdecode : Function.LeftInverse decode encode) [NeZero b] :
(tree machine input b σ encode decode q q).eval = encode none ↔ actualSchedule machine input b ≠ σ

A wrong movement guess evaluates to the encoded FAIL value.