BiTape: Bidirectionally infinite TM tape representation using StackTape #
This file defines BiTape, a tape representation for Turing machines
in the form of an List of Option values,
with the additional property that the list cannot end with none.
Design #
Note that Mathlib has a Tape type, but it requires the alphabet type to be inhabited,
and considers the ends of the tape to be filled with default values.
This design requires the tape elements to be Option values, and ensures that
Lists of the base alphabet, rendered directly onto the tape by mapping over some,
will not collide.
Main definitions #
BiTape: A tape with a head symbol and left/right contents stored asStackTapeBiTape.move: Move the tape head left or rightBiTape.write: Write a symbol at the current head positionBiTape.space_used: The space used by the tape
Equations
- Turing.BiTape.instInhabited = { default := Turing.BiTape.nil }
Equations
- Turing.BiTape.instEmptyCollection = { emptyCollection := Turing.BiTape.nil }
Given a List of Symbols, construct a BiTape by mapping the list to some elements
and laying them out to the right side,
with the head under the first element of the list if it exists.
Equations
- Turing.BiTape.mk₁ [] = ∅
- Turing.BiTape.mk₁ (h :: t) = { head := some h, left := ∅, right := Turing.StackTape.map_some t }
Instances For
Move the head to the left or right, shifting the tape underneath it.
Equations
Instances For
Optionally perform a move, or do nothing if none.
Equations
- x✝.optionMove none = x✝
- x✝.optionMove (some d) = x✝.move d