The closure library, part VI: the bits of a tree #
The preorder serialization Data.toBits of a tree, as a program (toBitsProg, a
stack-driven traversal after sizeProg) and as a polynomial-time function
(PolyTimeFun.toBits). This is how the describer of the succinct Cook–Levin theorem obtains
the symbol strings of the interpreter machine's fixed input tapes — S d = bits d.toBits —
from the data d (planning/succinct-cook-levin.md, S3).
Body of toBitsProg: the state is cons stack acc, stack a list of pending subtrees
and acc the bits produced so far, reversed. Pop a subtree: nil emits 0; cons a b emits
1 and pushes a then b. Stop with acc when the stack is empty.
Equations
Instances For
The step on a nil subtree: emit 0.
Equations
Instances For
The step on a cons subtree: emit 1 and push the children.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The body of the serialization loop.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The bits of a tree, in polynomial time.
Equations
- One or more equations did not get rendered due to their size.