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 Turing.BiTape (Symbol : Type) :

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 Turing.BiTape.nil {Symbol : Type} :
    BiTape Symbol

    The empty BiTape

    Equations
    Instances For
      @[implicit_reducible]
      instance Turing.BiTape.instInhabited {Symbol : Type} :
      Inhabited (BiTape Symbol)
      Equations
      @[implicit_reducible]
      Equations
      @[simp]
      def Turing.BiTape.mk₁ {Symbol : Type} (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 Turing.BiTape.move_left {Symbol : Type} (t : BiTape Symbol) :
        BiTape Symbol

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

        Equations
        Instances For
          def Turing.BiTape.move_right {Symbol : Type} (t : BiTape Symbol) :
          BiTape Symbol

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

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

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

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

              Optionally perform a move, or do nothing if none.

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

                Write a value under the head of the BiTape.

                Equations
                Instances For
                  def Turing.BiTape.space_used {Symbol : Type} (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 Turing.BiTape.space_used_write {Symbol : Type} (t : BiTape Symbol) (a : Option Symbol) :
                    theorem Turing.BiTape.space_used_mk₁ {Symbol : Type} (l : List Symbol) :
                    theorem Turing.BiTape.space_used_move {Symbol : Type} (t : BiTape Symbol) (d : Dir) :