Splitting flat recursive constructor streams #
A token's arity is its number of directly recursive fields. A tree is its constructor token,
followed by the streams of its children, in field order. RecursiveEncoding.splitTree separates
one complete tree from the following tokens and rejects a stream with missing children.
RecursiveEncoding.isTree additionally rejects trailing tokens.
The native polynomial-time certificate operates on encList encToken, which frames each token
once. It assumes a native certificate for reading the token arity and a fixed maximum arity.
It requires no decoder for the token embedding: its input is a typed token stream. The certificate
does not assert efficient decoding of arbitrary bit words or evaluation of arbitrary recursive
functions.
A complete forest with pending roots, in prefix constructor order.
- nil {τ : Type} {arity : τ → ℕ} : Forest arity 0 []
No roots require no tokens.
- cons {τ : Type} {arity : τ → ℕ} {pending : ℕ} {token : τ} {tokens : List τ} (rest : Forest arity (pending + arity token) tokens) : Forest arity (pending + 1) (token :: tokens)
Reading one root replaces it by the token's recursive children.
The splitter succeeds exactly on a complete prefix forest and its untouched suffix.
Splitting one typed tree has a native polynomial-time certificate, assuming only native arity recognition and a fixed arity bound. The returned prefix and suffix retain the token encoding; arbitrary bit-word decoding is a separate operation.
Native polynomial-time validity checking for a complete typed token stream. No semantic tree decoder or token decoder is required.