Documentation

MIPRE.TM.MultiInput.Deterministic

Deterministic multi-input multi-tape Turing machines #

Defines deterministic Turing machines with i two-way read-only input tapes, w work tapes and one write-only output tape — the machine model of MIP* = RE's normal form verifiers (a decider is a 5-input Turing machine; blueprint def:decider).

This file generalizes the vendored CSLib development (MIPRE.Cslib.Computability.Machines.Turing.MultiTape.Deterministic, upstream Turing.MultiTapeTM) from one input tape to i of them, declaration for declaration and under the same names; Turing.MultiTapeTM is exactly the case i = 1 (the exact correspondence is proved in MIPRE.TM.MultiInput.OneInputEquiv). All conventions are inherited:

Native multiple input tapes (rather than packing several inputs onto one tape by concatenation) keep the paper's per-input time bounds honest: accessing one input never costs time proportional to the lengths of the others. See planning/tm-infrastructure.md (Milestone A) for the design record.

Important declarations #

The resource-bound packaging (ComputesInTimeAndSpace, ComputesFunWithBounds) is in MIPRE.TM.MultiInput.Complexity.

structure Turing.MultiInputTM.TransitionOut (i w : ) (Symbol : Type u_3) (State : Type u_4) :
Type (max u_3 u_4)

The output of the transition function of a multi-input Turing machine.

  • inputMoves : Fin iSignType

    The movement (attempt) of each input head.

  • workActions : Fin wOption (Option Symbol) × SignType

    Actions on the work tapes: optionally a symbol to write and the head movement.

  • outS : Option Symbol

    An optional symbol to output.

  • q' : Option State

    The successor state or none to halt.

Instances For
    theorem Turing.MultiInputTM.TransitionOut.ext {i w : } {Symbol : Type u_3} {State : Type u_4} {x y : TransitionOut i w Symbol State} (inputMoves : x.inputMoves = y.inputMoves) (workActions : x.workActions = y.workActions) (outS : x.outS = y.outS) (q' : x.q' = y.q') :
    x = y
    theorem Turing.MultiInputTM.TransitionOut.ext_iff {i w : } {Symbol : Type u_3} {State : Type u_4} {x y : TransitionOut i w Symbol State} :
    structure Turing.MultiInputTM (i w : ) (Symbol : Type u_3) (State : Type u_4) :
    Type (max u_3 u_4)

    A deterministic Turing machine with i two-way read-only input tapes and w work tapes over the alphabet Option Symbol (where none is the blank symbol). Note that it is not required that Symbol or State are finite; finiteness enters only with the canonically coded machines of MIPRE.TM.Code.

    • q₀ : State

      initial state

    • tr (q : State) (inputs : Fin iOption Symbol) (work : Fin wOption Symbol) : TransitionOut i w Symbol State

      transition function, mapping a state, the tuple of symbols under the input heads and the tuple of symbols under the work heads to a movement for each input head, actions on the work tapes, optionally a symbol to output and the successor state

    Instances For

      Configurations #

      This section defines the configurations of a multi-input Turing machine, the step function that lets the machine transition from one configuration to the next, the resulting sequence of configurations and the initial configuration. Input-head movement reuses Turing.moveInputPos from the vendored CSLib file, one input tape at a time.

      structure Turing.MultiInputTM.Cfg (i w : ) (Symbol : Type u_3) (State : Type u_4) (input : Fin iList Symbol) :
      Type (max u_3 u_4)

      The configurations of a multi-input Turing machine are relative to the tuple of inputs of the machine and consist of:

      • an Optional state (or none for the halting state),
      • the position of each input head (shifted by one),
      • the contents of the work tapes,
      • the positions of the work tape heads.
      • state : Option State

        the state of the machine (or none for the halting state)

      • inputPos (j : Fin i) : Fin ((input j).length + 2)

        the position of each input head, shifted by one

      • workTapes : Fin wOption Symbol

        the work tapes

      • workTapePos : Fin w

        the positions of the heads on the work tapes

      Instances For
        theorem Turing.MultiInputTM.Cfg.ext_iff {i w : } {Symbol : Type u_3} {State : Type u_4} {input : Fin iList Symbol} {x y : Cfg i w Symbol State input} :
        theorem Turing.MultiInputTM.Cfg.ext {i w : } {Symbol : Type u_3} {State : Type u_4} {input : Fin iList Symbol} {x y : Cfg i w Symbol State input} (state : x.state = y.state) (inputPos : x.inputPos = y.inputPos) (workTapes : x.workTapes = y.workTapes) (workTapePos : x.workTapePos = y.workTapePos) :
        x = y
        @[instance_reducible]
        instance Turing.MultiInputTM.instInhabitedCfg {a✝ a✝¹ : } {a✝² : Type u_3} {a✝³ : Type u_4} {a✝⁴ : Fin a✝List a✝²} :
        Inhabited (Cfg a✝ a✝¹ a✝² a✝³ a✝⁴)
        Equations
        def Turing.MultiInputTM.Cfg.inputSymbol {i w : } {State : Type u_1} {Symbol : Type u_2} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) (j : Fin i) :
        Option Symbol

        The symbol currently under the head of input tape j.

        Equations
        Instances For
          @[simp]
          theorem Turing.MultiInputTM.inputSymbolInner {i w : } {State : Type u_1} {Symbol : Type u_2} {input : Fin iList Symbol} {cfg : Cfg i w Symbol State input} (j : Fin i) (p : ) (h₁ : (cfg.inputPos j) = 1 + p) (h₂ : p < (input j).length) :
          cfg.inputSymbol j = some (input j)[p]
          def Turing.MultiInputTM.Cfg.inputSymbols {i w : } {State : Type u_1} {Symbol : Type u_2} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) :
          Fin iOption Symbol

          The tuple of symbols under the input heads.

          Equations
          Instances For
            @[simp]
            theorem Turing.MultiInputTM.Cfg.inputSymbols_apply {i w : } {State : Type u_1} {Symbol : Type u_2} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) (j : Fin i) :
            def Turing.MultiInputTM.Cfg.workTapeSymbols {i w : } {State : Type u_1} {Symbol : Type u_2} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) (d : Fin w) :
            Option Symbol

            The symbol read by work tape d.

            Equations
            Instances For
              def Turing.MultiInputTM.step {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) :
              Cfg i w Symbol State input

              The step function corresponding to a MultiInputTM.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def Turing.MultiInputTM.outputSymbol {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) :
                Option Symbol

                The symbol (optionally) output when executing one step starting from configuration cfg.

                Equations
                Instances For
                  def Turing.MultiInputTM.initCfg {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} (input : Fin iList Symbol) :
                  Cfg i w Symbol State input

                  The initial configuration corresponding to a tuple of input strings.

                  Equations
                  Instances For
                    @[simp]
                    theorem Turing.MultiInputTM.step_of_halt {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} {cfg : Cfg i w Symbol State input} (h : cfg.state = none) :
                    step cfg = cfg
                    def Turing.MultiInputTM.configs {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) (t : ) :
                    Cfg i w Symbol State input

                    The sequence of configurations of the Turing machine starting from cfg. If the Turing machine halts, it will stay at the halting configuration.

                    Equations
                    Instances For
                      @[simp]
                      theorem Turing.MultiInputTM.configs_zero {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} {cfg : Cfg i w Symbol State input} :
                      configs cfg 0 = cfg
                      theorem Turing.MultiInputTM.configs_succ_eq_step {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} {cfg : Cfg i w Symbol State input} {t : } :
                      configs cfg (t + 1) = configs (step cfg) t
                      theorem Turing.MultiInputTM.configs_succ_eq_step' {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} {cfg : Cfg i w Symbol State input} {t : } :
                      configs cfg (t + 1) = step (configs cfg t)
                      theorem Turing.MultiInputTM.configs_add {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) (a b : ) :
                      configs cfg (a + b) = configs (configs cfg a) b

                      Running a + b steps equals running b steps from the configuration reached after a.

                      @[simp]
                      theorem Turing.MultiInputTM.configs_of_halts {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) (h : cfg.state = none) {n : } :
                      configs cfg n = cfg

                      The sequence of configurations from a halting state is constant.

                      @[simp]
                      theorem Turing.MultiInputTM.outputSymbol_of_halt {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} {cfg : Cfg i w Symbol State input} (h_halt : cfg.state = none) :
                      theorem Turing.MultiInputTM.workTapePos_step_le {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} (c : Cfg i w Symbol State input) (d : Fin w) :

                      Each work-tape head moves by at most one cell in a single step.

                      Space usage #

                      def Turing.MultiInputTM.visitedByTapeHead {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) (t : ) (d : Fin w) :

                      The set of positions visited by the head of work tape d in the computation starting from configuration cfg up to step t.

                      Equations
                      Instances For
                        def Turing.MultiInputTM.spaceUsedByTape {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) (t : ) (d : Fin w) :

                        The number of work tape cells touched by the head of tape d in the computation starting from configuration cfg up to step t.

                        Equations
                        Instances For
                          def Turing.MultiInputTM.spaceUsed {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) (t : ) :

                          The number of work tape cells touched by a computation starting from configuration cfg up to step t.

                          Equations
                          Instances For
                            @[simp]
                            theorem Turing.MultiInputTM.spaceUsed_zero_tapes_eq_zero {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) (t : ) (h_zero : w = 0) :
                            spaceUsed cfg t = 0

                            A machine without work tapes uses zero space.

                            theorem Turing.MultiInputTM.spaceUsedByTape_le_spaceUsed {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) (t : ) (d : Fin w) :

                            Each tape's space usage is bounded by the total space used.

                            def Turing.MultiInputTM.TransitionRelation {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} (c₁ c₂ : Cfg i w Symbol State input) :

                            The TransitionRelation corresponding to a MultiInputTM i w Symbol State is defined by the step function, which maps a configuration to its next configuration.

                            Equations
                            Instances For
                              def Turing.MultiInputTM.outputString {i w : } {State : Type u_1} {Symbol : Type u_2} {input : Fin iList Symbol} (tm : MultiInputTM i w Symbol State) (cfg₀ : Cfg i w Symbol State input) (t : ) :
                              List Symbol

                              The string output by the Turing machine tm starting in configuration cfg₀, executing for t steps. It is the concatenation of the symbols (optionally) emitted at each of the first t steps.

                              Equations
                              Instances For
                                theorem Turing.MultiInputTM.outputString_succ {i w : } {State : Type u_1} {Symbol : Type u_2} {input : Fin iList Symbol} (tm : MultiInputTM i w Symbol State) (cfg : Cfg i w Symbol State input) (t : ) :
                                tm.outputString cfg (t + 1) = tm.outputString cfg t ++ (outputSymbol (configs cfg t)).toList

                                The output produced in t + 1 steps is the output produced in t steps followed by the symbol (optionally) emitted at step t.

                                theorem Turing.MultiInputTM.outputString_halt {i w : } {State : Type u_1} {Symbol : Type u_2} {input : Fin iList Symbol} (tm : MultiInputTM i w Symbol State) (cfg : Cfg i w Symbol State input) (h_halt : cfg.state = none) (t : ) :
                                tm.outputString cfg t = []

                                From a halting configuration, a machine does not output anything.

                                theorem Turing.MultiInputTM.outputString_add_eq_append {i w : } {State : Type u_1} {Symbol : Type u_2} {input : Fin iList Symbol} (tm : MultiInputTM i w Symbol State) (cfg : Cfg i w Symbol State input) (t₁ t₂ : ) :
                                tm.outputString cfg (t₁ + t₂) = tm.outputString cfg t₁ ++ tm.outputString (configs cfg t₁) t₂
                                theorem Turing.MultiInputTM.outputString_eq_of_halt {i w : } {State : Type u_1} {Symbol : Type u_2} {input : Fin iList Symbol} (tm : MultiInputTM i w Symbol State) (cfg : Cfg i w Symbol State input) {τ t : } (hle : τ t) (hhalt : (configs cfg τ).state = none) :
                                tm.outputString cfg t = tm.outputString cfg τ

                                The output does not change after the machine has halted.

                                theorem Turing.MultiInputTM.relatesInSteps_iff_configs_eq {i w : } {State : Type u_1} {Symbol : Type u_2} {input : Fin iList Symbol} (tm : MultiInputTM i w Symbol State) (cfg₁ cfg₂ : Cfg i w Symbol State input) (t : ) :
                                Relation.RelatesInSteps TransitionRelation cfg₁ cfg₂ t configs cfg₁ t = cfg₂

                                This lemma translates between the relational notion and the iterated step notion. The latter can be more convenient especially for deterministic machines as we have here.

                                def Turing.MultiInputTM.haltsAtStep {i w : } {State : Type u_1} {Symbol : Type u_2} (tm : MultiInputTM i w Symbol State) (input : Fin iList Symbol) (t : ) :

                                The Turing machine tm halts after exactly t steps on input tuple input if its state is none at step t and non-none at step t - 1. Note that every Turing machine has to perform at least one step to halt.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  theorem Turing.MultiInputTM.halting_step_unique {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} {t₁ t₂ : } (h_halts₁ : tm.haltsAtStep input t₁ = true) (h_halts₂ : tm.haltsAtStep input t₂ = true) :
                                  t₁ = t₂

                                  If a Turing machine halts, the time step is uniquely determined.

                                  theorem Turing.MultiInputTM.not_halts_of_repeat_nonhalt {i w : } {State : Type u_1} {Symbol : Type u_2} {tm : MultiInputTM i w Symbol State} {input : Fin iList Symbol} (cfg : Cfg i w Symbol State input) (h_not_halt : cfg.state none) (t : ) (heq : configs cfg (t + 1) = cfg) (t' : ) :

                                  If a deterministic machine repeats a non-halting configuration, it never halts, because the sequence between the two configurations will loop forever. Note that this can be applied to two arbitrary and different time steps t and t + Δ using tm.configs_add.