Computing functions on CSLib multi-tape machines #
A decider only constrains output cell 1, so the decision simulator
TM.toMultiTape emits that single cell. To compute a function, the simulator
TM.toMultiTapeFun shares its marking, simulation, and rewind phases, but its
final phase copies output cells 1, 2, … to CSLib's output until the first
blank cell. Since both machines agree away from that final state, every lemma
about the shared phases transfers (TM.runFrom_toMultiTapeFun).
Main results #
Complexity.TM.toMultiTapeFun_computesFun— iftmcomputesfwithin timeT, the simulator computesfwithin time3 T + 4and space(2n + 3) (3 T + 5)
theorem
Complexity.TM.toMultiTapeFun_step_eq
{n : ℕ}
{tm : TM n}
{x : List Bool}
{d : tm.SimCfg x}
(h : d.state ≠ some MultiTapeState.verdict)
:
Away from the final state, the two simulators take the same step.
theorem
Complexity.TM.runFrom_toMultiTapeFun
{n : ℕ}
{tm : TM n}
{x : List Bool}
(d : tm.SimCfg x)
(m : ℕ)
(h : ∀ j < m, (Turing.MultiTapeTM.runFrom d j).state ≠ some MultiTapeState.verdict)
:
Runs that avoid the final state agree on the two simulators.
theorem
Complexity.TM.Dumping.step_some
{n : ℕ}
{tm : TM n}
{x : List Bool}
{t : Tape}
{pre : List Bool}
{d : tm.SimCfg x}
(h : tm.Dumping x t pre d)
{b : Bool}
(hb : t.cells t.head = Γ.ofBool b)
:
tm.Dumping x (t.move Dir3.right) (pre ++ [b]) (Turing.MultiTapeTM.step d)
Copying a non-blank output cell.
theorem
Complexity.TM.toMultiTapeFun_computesFun
{n : ℕ}
(tm : TM n)
{f : List Bool → List Bool}
{T : ℕ → ℕ}
(hf : tm.ComputesInTime f T)
:
tm.toMultiTapeFun.ComputesFunInTimeAndSpace (Function.Embedding.refl (List Bool)) (Function.Embedding.refl (List Bool))
f (fun (x : List Bool) => 3 * T x.length + 4) fun (x : List Bool) => simTapes n * (3 * T x.length + 5)
The function simulator computes what tm computes, within time
3 T + 4 and space (2n + 3) (3 T + 5) when tm computes within time T.