Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.BigO.Configuration

Finite configuration operations within quadratic time #

The tape and configuration operations used by the step test of views (Turing.MultiTapeNTM.viewStepB) are certified with explicit asymptotic bounds (Turing.MultiTapeTM.ComputableInO). Stack and tape operations, field access, output summaries and work-tape steps are linear in the encoded configuration; only the clamped move of the unary input head compares two unary numbers and costs quadratic time. Every operation uses linear space.

Main results #

The head of a stack, with a blank default, in linear time and space.

Removing the head of a stack, in linear time and space.

theorem Turing.MultiTapeTM.ComputableInO.stackTape_cons {Symbol α : Type} {input : α ↪ List Bool} {enc : Symbol ↪ List Bool} {T₁ S₁ T₂ S₂ : α → ℕ} {symbol : α → Option Symbol} {tape : α → Cslib.Turing.StackTape Symbol} (hsymbol : ComputableInO symbol input (encOption enc) T₁ S₁) (htape : ComputableInO tape input (encStackTape enc) T₂ S₂) :
ComputableInO (fun (a : α) => Cslib.Turing.StackTape.cons (symbol a) (tape a)) input (encStackTape enc) (fun (a : α) => T₁ a + T₂ a) fun (a : α) => S₁ a + S₂ a

Prepend a computed cell to a computed stack, retaining its omission of trailing blanks.

theorem Turing.MultiTapeTM.ComputableInO.biTape_mk {Symbol α : Type} {input : α ↪ List Bool} {enc : Symbol ↪ List Bool} {T₁ S₁ T₂ S₂ T₃ S₃ : α → ℕ} {head : α → Option Symbol} {left right : α → Cslib.Turing.StackTape Symbol} (hhead : ComputableInO head input (encOption enc) T₁ S₁) (hleft : ComputableInO left input (encStackTape enc) T₂ S₂) (hright : ComputableInO right input (encStackTape enc) T₃ S₃) :
ComputableInO (fun (a : α) => { head := head a, left := left a, right := right a }) input (encBiTape enc) (fun (a : α) => T₁ a + (T₂ a + T₃ a)) fun (a : α) => S₁ a + (S₂ a + S₃ a)

Assemble a tape from its computed head and two sides.

theorem Turing.MultiTapeTM.ComputableInO.biTape_head {Symbol : Type} (enc : Symbol ↪ List Bool) :
ComputableInO Cslib.Turing.BiTape.head (encBiTape enc) (encOption enc) (fun (tape : Cslib.Turing.BiTape Symbol) => ((encBiTape enc) tape).length) fun (tape : Cslib.Turing.BiTape Symbol) => ((encBiTape enc) tape).length

Read the current cell of a tape.

theorem Turing.MultiTapeTM.ComputableInO.biTape_left {Symbol : Type} (enc : Symbol ↪ List Bool) :
ComputableInO Cslib.Turing.BiTape.left (encBiTape enc) (encStackTape enc) (fun (tape : Cslib.Turing.BiTape Symbol) => ((encBiTape enc) tape).length) fun (tape : Cslib.Turing.BiTape Symbol) => ((encBiTape enc) tape).length

Extract the stored left side of a tape.

theorem Turing.MultiTapeTM.ComputableInO.biTape_right {Symbol : Type} (enc : Symbol ↪ List Bool) :
ComputableInO Cslib.Turing.BiTape.right (encBiTape enc) (encStackTape enc) (fun (tape : Cslib.Turing.BiTape Symbol) => ((encBiTape enc) tape).length) fun (tape : Cslib.Turing.BiTape Symbol) => ((encBiTape enc) tape).length

Extract the stored right side of a tape.

theorem Turing.MultiTapeTM.ComputableInO.biTape_moveLeft {Symbol : Type} (enc : Symbol ↪ List Bool) :
ComputableInO Cslib.Turing.BiTape.moveLeft (encBiTape enc) (encBiTape enc) (fun (tape : Cslib.Turing.BiTape Symbol) => ((encBiTape enc) tape).length) fun (tape : Cslib.Turing.BiTape Symbol) => ((encBiTape enc) tape).length

Move the head left by the stack operations, in linear time and space.

theorem Turing.MultiTapeTM.ComputableInO.biTape_moveRight {Symbol : Type} (enc : Symbol ↪ List Bool) :
ComputableInO Cslib.Turing.BiTape.moveRight (encBiTape enc) (encBiTape enc) (fun (tape : Cslib.Turing.BiTape Symbol) => ((encBiTape enc) tape).length) fun (tape : Cslib.Turing.BiTape Symbol) => ((encBiTape enc) tape).length

Move the head right by the stack operations, in linear time and space.

theorem Turing.MultiTapeTM.ComputableInO.biTape_step {Symbol : Type} (enc : Symbol ↪ List Bool) (action : Option (Option Symbol) × SignType) :
ComputableInO (fun (tape : Cslib.Turing.BiTape Symbol) => tape.step action) (encBiTape enc) (encBiTape enc) (fun (tape : Cslib.Turing.BiTape Symbol) => ((encBiTape enc) tape).length) fun (tape : Cslib.Turing.BiTape Symbol) => ((encBiTape enc) tape).length

Execute a fixed native tape action, in linear time and space.

The output summary on raw words, in linear time and space.

theorem Turing.MultiTapeTM.ComputableInO.finiteCfg_mk {k : ℕ} {State α : Type} [Finite State] {input : α ↪ List Bool} {word : α → List Bool} {state : α → Option State} {position : (a : α) → Fin ((word a).length + 2)} {work : α → Fin k → Cslib.Turing.BiTape Bool} {output : α → List Bool} {T₁ S₁ T₂ S₂ T₃ S₃ T₄ S₄ T₅ S₅ : α → ℕ} (hword : ComputableInO word input encBits T₁ S₁) (hstate : ComputableInO state input (encFinite (Option State)) T₂ S₂) (hposition : ComputableInO (fun (a : α) => ↑(position a)) input encUnary T₃ S₃) (hwork : ComputableInO work input (encPi (encBiTape encBool)) T₄ S₄) (houtput : ComputableInO output input encBits T₅ S₅) :
ComputableInO (fun (a : α) => { input := word a, state := state a, inputPos := position a, workTapes := work a, output := output a }) input encFiniteCfg (fun (a : α) => T₁ a + (T₂ a + (T₃ a + (T₄ a + T₅ a)))) fun (a : α) => S₁ a + (S₂ a + (S₃ a + (S₄ a + S₅ a)))

Assemble a configuration from its computed components, adding their bounds.

Read the stored input word of a configuration.

theorem Turing.MultiTapeTM.ComputableInO.finiteCfg_state {k : ℕ} {State : Type} [Finite State] :
ComputableInO FiniteCfg.state encFiniteCfg (encFinite (Option State)) (fun (cfg : FiniteCfg k Bool State) => (encFiniteCfg cfg).length) fun (cfg : FiniteCfg k Bool State) => (encFiniteCfg cfg).length

Read the finite control of a configuration.

theorem Turing.MultiTapeTM.ComputableInO.finiteCfg_inputPos {k : ℕ} {State : Type} [Finite State] :
ComputableInO (fun (cfg : FiniteCfg k Bool State) => ↑cfg.inputPos) encFiniteCfg encUnary (fun (cfg : FiniteCfg k Bool State) => (encFiniteCfg cfg).length) fun (cfg : FiniteCfg k Bool State) => (encFiniteCfg cfg).length

Read the unary input-head position of a configuration.

Read the family of work tapes of a configuration.

Read the accumulated output of a configuration.

theorem Turing.MultiTapeTM.ComputableInO.finiteCfg_moveInputPos {k : ℕ} {State : Type} [Finite State] (move : SignType) :
ComputableInO (fun (cfg : FiniteCfg k Bool State) => ↑(moveInputPos cfg.inputPos move)) encFiniteCfg encUnary (fun (cfg : FiniteCfg k Bool State) => ((encFiniteCfg cfg).length + 1) ^ 2) fun (cfg : FiniteCfg k Bool State) => (encFiniteCfg cfg).length

The clamped native move of the unary input head, within quadratic time and linear space: moving right compares the position with the input length.

theorem Turing.MultiTapeTM.ComputableInO.finiteCfg_stepWorkTapes {k : ℕ} {State : Type} [Finite State] (action : Fin k → Option (Option Bool) × SignType) :
ComputableInO (fun (cfg : FiniteCfg k Bool State) (tape : Fin k) => (cfg.workTapes tape).step (action tape)) encFiniteCfg (encPi (encBiTape encBool)) (fun (cfg : FiniteCfg k Bool State) => (encFiniteCfg cfg).length) fun (cfg : FiniteCfg k Bool State) => (encFiniteCfg cfg).length

Execute fixed native actions on all work tapes, in linear time and space.

theorem Turing.MultiTapeTM.ComputableInO.finiteCfg_step {k : ℕ} {State : Type} [Finite State] (action : Action k Bool State) :
ComputableInO (fun (cfg : FiniteCfg k Bool State) => cfg.step action) encFiniteCfg encFiniteCfg (fun (cfg : FiniteCfg k Bool State) => ((encFiniteCfg cfg).length + 1) ^ 2) fun (cfg : FiniteCfg k Bool State) => (encFiniteCfg cfg).length

Execute a fixed native action on a configuration, within quadratic time and linear space.

Summarizing the output of a configuration, in linear time and space.

theorem Turing.MultiTapeTM.ComputableInO.finiteCfg_step_summarizeOutput {k : ℕ} {State : Type} [Finite State] (action : Action k Bool State) :
ComputableInO (fun (cfg : FiniteCfg k Bool State) => (cfg.step action).summarizeOutput) encFiniteCfg encFiniteCfg (fun (cfg : FiniteCfg k Bool State) => ((encFiniteCfg cfg).length + 1) ^ 2) fun (cfg : FiniteCfg k Bool State) => (encFiniteCfg cfg).length

A step of views: a fixed native action followed by the output summary, within quadratic time and linear space (hence with a linear encoded output).

theorem Turing.MultiTapeTM.ComputableInO.length_encFiniteCfg_step_summarizeOutput_le {k : ℕ} {State : Type} [Finite State] (action : Action k Bool State) :
∃ (c : ℕ), ∀ (cfg : FiniteCfg k Bool State), (encFiniteCfg (cfg.step action).summarizeOutput).length ≤ c * ((encFiniteCfg cfg).length + 1)

A step of views has a linearly bounded encoding.

Observe the read-only input of a configuration, including both blank boundary cells, in linear time and space.

Observe all work heads of a configuration as one finite value, in linear time and space.

theorem Turing.MultiTapeTM.ComputableInO.finiteCfg_key {k : ℕ} {State : Type} [Finite State] :
ComputableInO (fun (cfg : FiniteCfg k Bool State) => (cfg.state, cfg.inputSymbol, cfg.workTapeSymbols)) encFiniteCfg (encPair (encFinite (Option State)) (encPair (encFinEnum (Option Bool)) (encFinEnum (Fin k → Option Bool)))) (fun (cfg : FiniteCfg k Bool State) => (encFiniteCfg cfg).length) fun (cfg : FiniteCfg k Bool State) => (encFiniteCfg cfg).length

The finite key of a view: its control, input symbol and work symbols, which select its transitions, in linear time and space.