Documentation

Complexitylib.Interop.Cslib.FromMultiTape.Defs

Simulating CSLib multi-tape machines on Complexitylib machines #

This file defines a Complexitylib machine (TM k) that simulates a binary CSLib multi-tape machine (Turing.MultiTapeTM k Bool S) with the same number of work tapes. It is the converse direction of Complexitylib.Interop.Cslib.MultiTape.

The simulator bridges the two models as follows.

Main definitions #

Read one of our symbols as a binary CSLib cell: □ and ▷ are blank.

Equations
Instances For

    Store a binary CSLib cell as a writable symbol, with CSLib's blank as □.

    Equations
    Instances For

      Guard a head direction: a head reading ▷ moves right, as TM.δ_right_of_start requires; otherwise it moves in direction d.

      Equations
      Instances For

        What a folded work tape still has to do in phases 1 and 2 of a simulated step.

        • idle : Plan

          Nothing more; the head is in place.

        • out : Plan

          One more move right (a move away from the fold, begun in phase 0).

        • inPos : Plan

          On the nonnegative half, moving toward the fold: one more left move, unless the head bumped into ▷, in which case it crosses the fold.

        • inNeg : Plan

          On the negative half, moving toward the fold: one more left move, then a check for ▷ in phase 2.

        • cross : Plan

          Crossing from CSLib cell 0 to cell -1: one more move right.

        Instances For
          @[instance_reducible]
          Equations
          @[instance_reducible]
          Equations
          • One or more equations did not get rendered due to their size.
          inductive Complexity.FromMultiTape.St (k : ℕ) (S : Type) :

          The simulator's states, for a CSLib machine with k work tapes and state type S. The sign flags say, for each work tape, whether the CSLib head is at a negative position.

          • init {k : ℕ} {S : Type} : St k S

            Move every head off ▷.

          • run {k : ℕ} {S : Type} (q : S) (sign : Fin k → Bool) : St k S

            Phase 0: simulate one step of CSLib state q.

          • mid1 {k : ℕ} {S : Type} (q : S) (sign : Fin k → Bool) (plan : Fin k → Plan) (inDir : Dir3) : St k S

            Phase 1: continue the moves; CSLib is now in state q.

          • mid2 {k : ℕ} {S : Type} (q : S) (sign : Fin k → Bool) (plan : Fin k → Plan) (inDir : Dir3) : St k S

            Phase 2: finish the moves, including the input head move inDir.

          • halt {k : ℕ} {S : Type} : St k S

            CSLib halted.

          Instances For
            def Complexity.FromMultiTape.instDecidableEqSt.decEq {k✝ : ℕ} {S✝ : Type} [DecidableEq S✝] (x✝ x✝¹ : St k✝ S✝) :
            Decidable (x✝ = x✝¹)
            Equations
            Instances For
              def Complexity.FromMultiTape.St.equivSum (k : ℕ) (S : Type) :
              St k S ≃ Unit ⊕ S × (Fin k → Bool) ⊕ S × (Fin k → Bool) × (Fin k → Plan) × Dir3 ⊕ S × (Fin k → Bool) × (Fin k → Plan) × Dir3 ⊕ Unit

              The simulator's states as a sum of finite types.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                @[instance_reducible]
                Equations
                • One or more equations did not get rendered due to their size.

                The input head move made in phase 2 to simulate CSLib input move m, where r is the input symbol read in phase 0. On ▷ the head already moved right in phase 0; elsewhere a right move off the right blank is clamped.

                Equations
                Instances For

                  The symbol written in phase 0 for a CSLib write wr over symbol r.

                  Equations
                  Instances For

                    The symbol written on our output tape over symbol o when CSLib emits e.

                    Equations
                    Instances For

                      The output head move when CSLib emits e: right after each emitted bit.

                      Equations
                      Instances For
                        def Complexity.FromMultiTape.δ {k : ℕ} {S : Type} (M : Turing.MultiTapeTM k Bool S) (q : St k S) (i : Γ) (w : Fin k → Γ) (o : Γ) :
                        St k S × (Fin k → Γw) × Γw × Dir3 × (Fin k → Dir3) × Dir3

                        The simulator's transition function. Every direction is passed through Dir3.guard, so heads on ▷ always move right.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          Guarded directions move right off ▷.

                          The Complexitylib machine simulating the binary CSLib machine M, with one folded work tape per CSLib work tape.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For