Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.Tape

Polynomial-time operations on finite tape storage #

The operations of cslib's existing tapes are certified in plain polynomial time (Turing.MultiTapeTM.ComputableInPolyTime) by composition of list, option and pair operations. They charge the complete stored tapes and accept any symbol encoding, including infinite or empty alphabets. Finite-control interpreters can use these rules without building new tape machines.

Main results #

References #

Adapts Computability/Probabilistic/Tape.lean from the cslib crypto branch at 5ff69ca93402e7c947208dc56396d6d86203ccd8 to plain polynomial time, using arbitrary symbol encodings instead of fixed finite tags.

Reading the stored list is a change of view of the same encoded bits.

Reading a stack head decodes the first cell, with a blank default.

Removing a stack head is the list-tail operation.

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

Prepend a cell without requiring a default symbol or case analysis over the alphabet.

Map symbols to occupied cells with the list map.

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

Assemble a tape from its computed head and two sides.

Read the current cell of a computed tape.

theorem Turing.MultiTapeTM.ComputableInPolyTime.biTape_write {Symbol α : Type} {input : α ↪ List Bool} {enc : Symbol ↪ List Bool} {tape : α → Cslib.Turing.BiTape Symbol} {symbol : α → Option Symbol} (htape : ComputableInPolyTime tape input (encBiTape enc)) (hsymbol : ComputableInPolyTime symbol input (encOption enc)) :
ComputableInPolyTime (fun (a : α) => (tape a).write (symbol a)) input (encBiTape enc)

Write a computed optional symbol, including blank erasure.

theorem Turing.MultiTapeTM.ComputableInPolyTime.biTape_step {Symbol α : Type} {input : α ↪ List Bool} {enc : Symbol ↪ List Bool} (action : Option (Option Symbol) × SignType) {tape : α → Cslib.Turing.BiTape Symbol} (htape : ComputableInPolyTime tape input (encBiTape enc)) :
ComputableInPolyTime (fun (a : α) => (tape a).step action) input (encBiTape enc)

Execute a fixed native action, charging the full encoded tape.

Loading a list constructs a head and two stacks with no default symbol.