Documentation

Cslib.Foundations.Data.BiTape

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 #

structure Cslib.Turing.BiTape (Symbol : Type u_1) :
Type u_1

A structure for bidirectionally-infinite Turing machine tapes that eventually take on blank none values

  • head : Option Symbol

    The symbol currently under the tape head

  • left : StackTape Symbol

    The contents to the left of the head

  • right : StackTape Symbol

    The contents to the right of the head

Instances For
    def Cslib.Turing.BiTape.nil {Symbol : Type u_1} :
    BiTape Symbol

    The empty BiTape

    Equations
    Instances For
      @[instance_reducible]
      instance Cslib.Turing.BiTape.instInhabited {Symbol : Type u_1} :
      Inhabited (BiTape Symbol)
      Equations
      @[instance_reducible]
      Equations
      @[simp]
      def Cslib.Turing.BiTape.mk₁ {Symbol : Type u_1} (l : List Symbol) :
      BiTape Symbol

      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
      Instances For
        def Cslib.Turing.BiTape.moveLeft {Symbol : Type u_1} (t : BiTape Symbol) :
        BiTape Symbol

        Move the head left by shifting the left StackTape under the head.

        Equations
        Instances For
          def Cslib.Turing.BiTape.moveRight {Symbol : Type u_1} (t : BiTape Symbol) :
          BiTape Symbol

          Move the head right by shifting the right StackTape under the head.

          Equations
          Instances For
            def Cslib.Turing.BiTape.move {Symbol : Type u_1} (t : BiTape Symbol) :
            Turing.DirBiTape Symbol

            Move the head to the left or right, shifting the tape underneath it.

            Equations
            Instances For
              def Cslib.Turing.BiTape.optionMove {Symbol : Type u_1} :
              BiTape SymbolOption Turing.DirBiTape Symbol

              Optionally perform a move, or do nothing if none.

              Equations
              Instances For
                @[simp]
                theorem Cslib.Turing.BiTape.moveLeft_moveRight {Symbol : Type u_1} (t : BiTape Symbol) :
                @[simp]
                theorem Cslib.Turing.BiTape.moveRight_moveLeft {Symbol : Type u_1} (t : BiTape Symbol) :
                def Cslib.Turing.BiTape.write {Symbol : Type u_1} (t : BiTape Symbol) (a : Option Symbol) :
                BiTape Symbol

                Write a value under the head of the BiTape.

                Equations
                Instances For
                  def Cslib.Turing.BiTape.spaceUsed {Symbol : Type u_1} (t : BiTape Symbol) :

                  The space used by a BiTape is the number of symbols between and including the head, and leftmost and rightmost non-blank symbols on the BiTape.

                  Equations
                  Instances For
                    @[simp]
                    theorem Cslib.Turing.BiTape.spaceUsed_write {Symbol : Type u_1} (t : BiTape Symbol) (a : Option Symbol) :
                    theorem Cslib.Turing.BiTape.spaceUsed_mk₁ {Symbol : Type u_1} (l : List Symbol) :
                    theorem Cslib.Turing.BiTape.spaceUsed_move {Symbol : Type u_1} (t : BiTape Symbol) (d : Turing.Dir) :