Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Encodings.RecursiveChild

Extracting children from flat constructor streams #

RecursiveEncoding.child? arity index discards the root token, skips index complete subtrees, and returns the next complete subtree. It returns none on missing or incomplete subtrees. It does not check the root's constructor or declared arity: a generated constructor projection checks its constructor separately before selecting the corresponding recursive field.

For each fixed field index, extraction has a native polynomial-time certificate on encList encToken, assuming native polynomial-time arity recognition and a fixed maximum arity. No token decoder or token inhabitant is assumed. This is extraction on typed token streams, not decoding of arbitrary Boolean words.

def Turing.MultiTapeTM.RecursiveEncoding.child? {τ : Type} (arity : τ → ℕ) (index : ℕ) (tokens : List τ) :

Extract a complete child stream at a fixed zero-based recursive-field index. The root's constructor and arity are not checked; constructor projections supply that check separately.

theorem Turing.MultiTapeTM.RecursiveEncoding.child?_node {τ : Type} {arity : τ → ℕ} (root : τ) (children : List (List τ)) (hchildren : ∀ child ∈ children, Forest arity 1 child) (index : ℕ) (hindex : index < children.length) (suffix : List τ) :
child? arity index (root :: (children.flatten ++ suffix)) = some children[index]

In a valid sequence of child streams, extraction preserves the selected child exactly, independently of any following suffix.

theorem Turing.MultiTapeTM.RecursiveEncoding.child?_polyTime {τ : Type} {encToken : τ ↪ List Bool} {arity : τ → ℕ} (harity : ComputableInPolyTime arity encToken encUnary) {maximum : ℕ} (hmax : ∀ (token : τ), arity token ≤ maximum) (index : ℕ) :
ComputableInPolyTime (child? arity index) (encList encToken) (encOption (encList encToken))

For any fixed recursive-field index, subtree extraction has a native polynomial-time certificate. Token arities need a native certificate and a fixed bound; token decoding is not assumed.