Counter programs with output #
A counter program (Turing.CounterProgram) emits bits with its emit instructions. This file
records what a run emits: P.ReachesOut w Q s s' out says that the program reaches s' from s
on the input w, passing only through configurations satisfying Q, and emits out on the way.
Reachability without emissions (Turing.CounterProgram.Reaches) through assignments, comparisons
and reads emits nothing (Turing.CounterProgram.Reaches.reachesOut). A counting loop
(Turing.CounterProgram.forCode) emits, in order, what its body emits for each value of the
counter (Turing.CounterProgram.reachesOut_forCode); a loop counting a run of true bits of the
input emits nothing (Turing.CounterProgram.reachesOut_count). A program that reaches a halt,
emitting the encoding of the value of a function, computes the function in logarithmic space if its
registers stay polynomially bounded (Turing.CounterProgram.computableInLogSpace_of_reachesOut):
this is the form of a logarithmic-space transducer.
Main definitions #
Turing.CounterProgram.Active: the configurations at instructions other than halts, with bounded registers.Turing.CounterProgram.ReachesOut: reachability, with the bits emitted on the way.Turing.CounterProgram.forCode: the code of a counting loop.Turing.CounterProgram.blocksCode: a fixed list of blocks at successive labels.
Main results #
Turing.CounterProgram.reachesOut_blocksCode: sequence block outputs and preserve an invariant.Turing.CounterProgram.reachesOut_forCode: a counting loop emits what its body emits for each value of the counter.Turing.CounterProgram.reachesOut_count: a loop counting a run oftruebits of the input.Turing.CounterProgram.computableInLogSpace_of_reachesOut: counter programs with output and polynomially bounded registers compute functions in logarithmic space.
References #
The configurations at instructions other than halts, with all registers at most B.
Instances For
P.ReachesOut w Q s s' out: from s, the program reaches s' on the input w, every
configuration before s' satisfies Q, and the bits emitted before s' are out.
Instances For
A fixed list of blocks emits their words in order and preserves a register invariant. Each block's actual length must agree with its declared length at every starting label. Sequencing inserts no transitions between the supplied block runs. The empty list has a zero-step run; a zero-length block still requires its own reachability proof.
Reachability through assignments, comparisons and reads emits nothing.
Counting loops #
The code of a counting loop, placed at the label b: register u counts from 0 while its
value is less than that of bound, running the body at body for each value; the body continues
at b + 2, and the loop exits to exit.
Instances For
A counting loop emits what its body emits for each value of the counter. The invariant
Inv k holds of the registers when the counter has the value k; it fixes the value N of the
bound and keeps the registers at most B. If the body, run on registers satisfying Inv k for
k < N, continues at b + 2 with the counter unchanged, emitting o k, and the incremented
registers satisfy Inv (k + 1), then the loop exits with registers satisfying Inv N, emitting
o 0 ++ ⋯ ++ o (N - 1).
A read-and-count loop. Label c reads the input at e; on true, label c + 1
increments register u and returns to c, and on anything else the loop exits to exit. The
registers ρ j are those after j increments. If the read is true exactly below n on the
registers ρ j, then from any ρ j with j ≤ n the loop exits with the registers ρ n, emitting
nothing.
Logarithmic space #
Counter programs with output run in logarithmic space. If on every encoded input enc a
the program reaches a halting instruction with final word fin, passing only through
configurations at other instructions with registers at most (n + 1) ^ d, where n is the
length of the input, if the bits emitted on the way followed by fin are encOut (f a), and if
the registers of the halting configuration are at most (n + 1) ^ d too, then f is computable
in logarithmic space.