Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Plumbing.CopyBlock

Counted transfer of a local tape block #

Turing.MultiTapeTM.copyBlock copies a block from work tape 0 to work tape 1, using a unary counter on work tape 2. Each nonblank counter cell authorizes one transfer, including a blank source cell, and is erased. All three heads advance together. The first blank counter cell halts the machine without moving a head. The optional erasure mode also clears the source.

The machine has one control state. Its contract allows arbitrary initial head positions and preserves all cells outside the three transferred segments. The counter cell immediately after its segment must be blank; all other exterior contents are arbitrary. Each head visits only its segment and its right boundary. A block of length n takes exactly n + 1 transitions and visits at most 3 * (n + 1) work-tape cells. These are native machine resources, independent of the total stored data.

This is a local block primitive for buffered simulations. It does not by itself implement a buffer layout, its refill schedule, or a logarithmic-overhead universal simulator.

Main definitions #

Main results #

def Turing.MultiTapeTM.copyBlock {Symbol : Type u_1} (erase : Bool) :
MultiTapeTM 3 Symbol Unit

Copy from tape 0 to tape 1 while erasing a unary counter on tape 2. If erase is true, also erase each copied source cell. Physical blanks in the source are copied as blanks; only the counter determines where the block ends.

def Turing.MultiTapeTM.CopyBlock.writeBlock {Symbol : Type u_1} (tape : ℤ → Option Symbol) (start : ℤ) (values : ℤ → Option Symbol) (count : ℕ) :
ℤ → Option Symbol

Replace exactly the cells in [start, start + count) by values, indexed relative to start, preserving the tape everywhere else.

@[simp]
theorem Turing.MultiTapeTM.CopyBlock.writeBlock_zero {Symbol : Type u_1} (tape : ℤ → Option Symbol) (start : ℤ) (values : ℤ → Option Symbol) :
writeBlock tape start values 0 = tape
theorem Turing.MultiTapeTM.CopyBlock.writeBlock_apply {Symbol : Type u_1} (tape : ℤ → Option Symbol) (start : ℤ) (values : ℤ → Option Symbol) {count j : ℕ} (hj : j < count) :
writeBlock tape start values count (start + ↑j) = values ↑j

A cell inside the replacement interval contains its specified value.

theorem Turing.MultiTapeTM.CopyBlock.writeBlock_apply_of_outside {Symbol : Type u_1} (tape : ℤ → Option Symbol) (start : ℤ) (values : ℤ → Option Symbol) (count : ℕ) {z : ℤ} (hz : z < start ∨ start + ↑count ≤ z) :
writeBlock tape start values count z = tape z

Exterior cells are unchanged.

@[simp]
theorem Turing.MultiTapeTM.CopyBlock.writeBlock_at_end {Symbol : Type u_1} (tape : ℤ → Option Symbol) (start : ℤ) (values : ℤ → Option Symbol) (count : ℕ) :
writeBlock tape start values count (start + ↑count) = tape (start + ↑count)
def Turing.MultiTapeTM.CopyBlock.tapes {Symbol : Type u_1} {input : List Symbol} (erase : Bool) (cfg : Cfg 3 Symbol Unit input) (count : ℕ) :
Fin 3 → ℤ → Option Symbol

The tapes after count transfers, before or after the final halting transition.

def Turing.MultiTapeTM.CopyBlock.progress {Symbol : Type u_1} {input : List Symbol} (erase : Bool) (cfg : Cfg 3 Symbol Unit input) (count : ℕ) :
Cfg 3 Symbol Unit input

The configuration after count transfers, still in the running state.

def Turing.MultiTapeTM.CopyBlock.finish {Symbol : Type u_1} {input : List Symbol} (erase : Bool) (cfg : Cfg 3 Symbol Unit input) (count : ℕ) :
Cfg 3 Symbol Unit input

The final configuration: the transferred segments, erased counter, shifted heads and unchanged input position and output.

@[simp]
theorem Turing.MultiTapeTM.CopyBlock.progress_zero {Symbol : Type u_1} {input : List Symbol} (erase : Bool) (cfg : Cfg 3 Symbol Unit input) (hstate : cfg.state = some ()) :
progress erase cfg 0 = cfg
theorem Turing.MultiTapeTM.CopyBlock.runFrom_progress {Symbol : Type u_1} {input : List Symbol} (erase : Bool) (cfg : Cfg 3 Symbol Unit input) (count : ℕ) (hstate : cfg.state = some ()) (hcount : ∀ j < count, cfg.workTapes 2 (cfg.workTapePos 2 + ↑j) ≠ none) :
runFrom cfg count = progress erase cfg count

Each nonblank counter cell permits one native transfer.

theorem Turing.MultiTapeTM.CopyBlock.runFrom_copyBlock {Symbol : Type u_1} {input : List Symbol} (erase : Bool) (cfg : Cfg 3 Symbol Unit input) (count : ℕ) (hstate : cfg.state = some ()) (hcount : ∀ j < count, cfg.workTapes 2 (cfg.workTapePos 2 + ↑j) ≠ none) (hend : cfg.workTapes 2 (cfg.workTapePos 2 + ↑count) = none) :
runFrom cfg (count + 1) = finish erase cfg count

The exact result of transferring a counted block. Only the counter must be nonblank: the copied block may contain any mixture of symbols and physical blanks.

theorem Turing.MultiTapeTM.CopyBlock.haltsAt_copyBlock {Symbol : Type u_1} {input : List Symbol} (erase : Bool) (cfg : Cfg 3 Symbol Unit input) (count : ℕ) (hstate : cfg.state = some ()) (hcount : ∀ j < count, cfg.workTapes 2 (cfg.workTapePos 2 + ↑j) ≠ none) (hend : cfg.workTapes 2 (cfg.workTapePos 2 + ↑count) = none) :
(copyBlock erase).HaltsAt cfg (count + 1)

The first blank counter cell is the halting step, so the running time is exactly count + 1, including when the counter is initially blank.

theorem Turing.MultiTapeTM.CopyBlock.workTapePos_runFrom {Symbol : Type u_1} {input : List Symbol} (erase : Bool) (cfg : Cfg 3 Symbol Unit input) (count : ℕ) (hstate : cfg.state = some ()) (hcount : ∀ j < count, cfg.workTapes 2 (cfg.workTapePos 2 + ↑j) ≠ none) (hend : cfg.workTapes 2 (cfg.workTapePos 2 + ↑count) = none) (time : ℕ) (i : Fin 3) :
(runFrom cfg time).workTapePos i = cfg.workTapePos i + ↑(min time count)

Every visited head position lies in the transferred interval together with its right boundary. The final halting transition visits no additional cell.

theorem Turing.MultiTapeTM.CopyBlock.space_copyBlock_le {Symbol : Type u_1} {input : List Symbol} (erase : Bool) (cfg : Cfg 3 Symbol Unit input) (count : ℕ) (hstate : cfg.state = some ()) (hcount : ∀ j < count, cfg.workTapes 2 (cfg.workTapePos 2 + ↑j) ≠ none) (hend : cfg.workTapes 2 (cfg.workTapePos 2 + ↑count) = none) :
(MultiTapeNTM.RunPath.ofDeterministic (copyBlock erase) cfg (count + 1)).space ≤ 3 * (count + 1)

A native run path for a length-count block visits at most 3 * (count + 1) work-tape cells, independent of the initial heads and of data outside the three touched intervals.