Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Internal.KernelStreamTable

Explicit transition tables for streaming folds #

This module assembles the streaming-fold kernel entirely from retained effect-free transition tables. Its correctness theorems use the established tape-transformation specifications; no transition function is recovered from a relation or from the legacy noncomputable assembly.

Main definitions #

Main results #

Run a tidy explicit table between a virtual input work tape and a fresh output work tape.

theorem Turing.MultiTapeMachine.transformsTapes_onWords {k : ℕ} {State : Type} {machine : MultiTapeMachine k Bool State Empty Id} {input output : List Bool} {time space : ℕ} (mark : Bool) (h : machine.toTM.ComputesTidilyInTimeAndSpace input output time space) :
(machine.onWords mark).toTM.TransformsTapes (fun (x : List Bool) (tapes : Fin (k + 1 + 2) → List Bool) => tapes = Function.update (fun (x : Fin (k + 1 + 2)) => []) (Fin.natAdd (k + 1) 0) input) (fun (x : List Bool) (tapes tapes' : Fin (k + 1 + 2) → List Bool) (emitted : List Bool) => tapes' = Function.update tapes (Fin.castAdd 2 (Fin.last k)) output ∧ emitted = []) (time + output.length + 6) (space + 2 * input.length + 2 * output.length + 3 * k + 18)
theorem Turing.MultiTapeMachine.transformsTapes_onWords_extendTapes {k : ℕ} {State : Type} {machine : MultiTapeMachine k Bool State Empty Id} {input output : List Bool} {time space K : ℕ} (mark : Bool) (h : machine.toTM.ComputesTidilyInTimeAndSpace input output time space) {embedding : Fin (k + 1 + 2) ↪ Fin K} {value target : Fin K} (hvalue : embedding (Fin.natAdd (k + 1) 0) = value) (htarget : embedding (Fin.castAdd 2 (Fin.last k)) = target) :
((machine.onWords mark).extendTapes embedding).toTM.TransformsTapes (fun (x : List Bool) (tapes : Fin K → List Bool) => tapes = Function.update (fun (x : Fin K) => []) value input) (fun (x : List Bool) (tapes tapes' : Fin K → List Bool) (emitted : List Bool) => tapes' = Function.update tapes target output ∧ emitted = []) (time + output.length + 6) (space + 2 * input.length + 2 * output.length + 3 * k + 18 + (K - (k + 1 + 2)))

Run a tidy explicit table between two selected tapes, preserving the input and emitting nothing.

def Turing.MultiTapeMachine.streamRound {K : ℕ} {Q EmitState NextState : Type} (reader : MultiTapeTM.InputReader Bool Q) (emitter : MultiTapeMachine K Bool EmitState Empty Id) (nextMachine : MultiTapeMachine K Bool NextState Empty Id) (value next flag : Fin K) (hValueNext : value ≠ next) (hValueFlag : value ≠ flag) (hNextFlag : next ≠ flag) :

Read one token into value, then perform one input-frozen stream round.

theorem Turing.MultiTapeMachine.transformsTapesAt_streamRound {K : ℕ} {Q EmitState NextState : Type} {reader : MultiTapeTM.InputReader Bool Q} {emitter : MultiTapeMachine K Bool EmitState Empty Id} {nextMachine : MultiTapeMachine K Bool NextState Empty Id} {value next flag : Fin K} (hValueNext : value ≠ next) (hValueFlag : value ≠ flag) (hNextFlag : next ≠ flag) (input : List Bool) (position : Fin (input.length + 2)) (hposition : ↑position ≠ 0) (word : List Bool) {emitted nextWord : List Bool} {emitterTime emitterSpace nextTime nextSpace : ℕ} (hEmitter : emitter.toTM.TransformsTapes (fun (x : List Bool) (tapes : Fin K → List Bool) => tapes = Function.update (fun (x : Fin K) => []) value (word ++ (reader.read reader.q₀ (List.drop (↑position - 1) input)).1)) (fun (x : List Bool) (tapes tapes' : Fin K → List Bool) (output : List Bool) => tapes' = tapes ∧ output = emitted) emitterTime emitterSpace) (hNext : nextMachine.toTM.TransformsTapes (fun (x : List Bool) (tapes : Fin K → List Bool) => tapes = Function.update (fun (x : Fin K) => []) value (word ++ (reader.read reader.q₀ (List.drop (↑position - 1) input)).1)) (fun (x : List Bool) (tapes tapes' : Fin K → List Bool) (output : List Bool) => tapes' = Function.update tapes next nextWord ∧ output = []) nextTime nextSpace) :
have read := reader.read reader.q₀ (List.drop (↑position - 1) input); (streamRound reader emitter nextMachine value next flag hValueNext hValueFlag hNextFlag).toTM.TransformsTapesAt (fun (actualInput : List Bool) (actualPosition : Fin (actualInput.length + 2)) (tapes : Fin K → List Bool) => actualInput = input ∧ ↑actualPosition = ↑position ∧ tapes = Function.update (fun (x : Fin K) => []) value word) (fun (x : List Bool) (x_1 : Fin (x.length + 2)) (x_2 : Fin K → List Bool) (finalPosition : Fin (x.length + 2)) (finalTapes : Fin K → List Bool) (output : List Bool) => ↑finalPosition = ↑position + read.2 ∧ finalTapes = Function.update (fun (x : Fin K) => []) value nextWord ∧ output = emitted) (word.length + 1 + (read.2 + 1 + ((word ++ read.1).length + 2)) + (emitterTime + (nextTime + (3 * ((word ++ read.1).length + 1) + (3 * nextWord.length + 10 + 3 * (nextWord.length + 1)))))) ((word ++ read.1).length + 2 + (K - 1) + (emitterSpace + (nextSpace + ((word ++ read.1).length + 1 + K + (4 * nextWord.length + K + 15 + (nextWord.length + 1 + K))))))

One explicit round has the established exact cursor, tape, output, time, and workspace law.

def Turing.MultiTapeMachine.stream {K : ℕ} {Q InitState EmitState NextState FinishState : Type} (reader : MultiTapeTM.InputReader Bool Q) (initializer : MultiTapeMachine K Bool InitState Empty Id) (emitter : MultiTapeMachine K Bool EmitState Empty Id) (nextMachine : MultiTapeMachine K Bool NextState Empty Id) (finalizer : MultiTapeMachine K Bool FinishState Empty Id) (value next flag : Fin K) (hValueNext : value ≠ next) (hValueFlag : value ≠ flag) (hNextFlag : next ≠ flag) :

The complete explicit streaming fold: initialize, iterate, finalize, clean, and rewind input.

theorem Turing.MultiTapeMachine.computesTidily_stream_after {K : ℕ} {Q InitState EmitState NextState FinishState : Type} {reader : MultiTapeTM.InputReader Bool Q} {initializer : MultiTapeMachine K Bool InitState Empty Id} {emitter : MultiTapeMachine K Bool EmitState Empty Id} {nextMachine : MultiTapeMachine K Bool NextState Empty Id} {finalizer : MultiTapeMachine K Bool FinishState Empty Id} {value next flag : Fin K} (hValueNext : value ≠ next) (hValueFlag : value ≠ flag) (hNextFlag : next ≠ flag) (input inputPrefix initialWord finalWord loopOutput finalOutput : List Bool) {initializerTime initializerSpace loopTime loopSpace finalTime finalSpace : ℕ} (hInitializer : initializer.toTM.TransformsTapesAt (fun (actualInput : List Bool) (position : Fin (actualInput.length + 2)) (tapes : Fin K → List Bool) => actualInput = input ∧ ↑position = 1 ∧ tapes = fun (x : Fin K) => []) (fun (x : List Bool) (x_1 : Fin (x.length + 2)) (x_2 : Fin K → List Bool) (position' : Fin (x.length + 2)) (tapes' : Fin K → List Bool) (output : List Bool) => ↑position' = 1 + inputPrefix.length ∧ tapes' = Function.update (fun (x : Fin K) => []) value initialWord ∧ output = []) initializerTime initializerSpace) (hloop : (streamRound reader emitter nextMachine value next flag hValueNext hValueFlag hNextFlag).whileInput.toTM.TransformsTapesAt (fun (actualInput : List Bool) (position : Fin (actualInput.length + 2)) (tapes : Fin K → List Bool) => actualInput = input ∧ ↑position = 1 + inputPrefix.length ∧ tapes = Function.update (fun (x : Fin K) => []) value initialWord) (fun (actualInput : List Bool) (x : Fin (actualInput.length + 2)) (x_1 : Fin K → List Bool) (position' : Fin (actualInput.length + 2)) (tapes' : Fin K → List Bool) (output : List Bool) => actualInput = input ∧ ↑position' = 1 + input.length ∧ tapes' = Function.update (fun (x : Fin K) => []) value finalWord ∧ output = loopOutput) loopTime loopSpace) (hFinal : finalizer.toTM.TransformsTapes (fun (x : List Bool) (tapes : Fin K → List Bool) => tapes = Function.update (fun (x : Fin K) => []) value finalWord) (fun (x : List Bool) (tapes tapes' : Fin K → List Bool) (output : List Bool) => tapes' = tapes ∧ output = finalOutput) finalTime finalSpace) :
(stream reader initializer emitter nextMachine finalizer value next flag hValueNext hValueFlag hNextFlag).toTM.ComputesTidilyInTimeAndSpace input (loopOutput ++ finalOutput) (initializerTime + loopTime + (finalTime + 3 * (finalWord.length + 1) + (input.length + 2))) (initializerSpace + (loopSpace + (finalSpace + (finalWord.length + 1 + K) + K)))

The complete explicit stream table computes tidily with the established exact phase bounds.