Documentation

Complexitylib.Classes.Containments.Internal.PPLayout

The counting machine's tape layout #

⚠️ Unreviewed by Bolton

Placing the simulation with TM.placeWorkTM 0 m fixes where every tape sits: the simulated machine's k tapes come first, then its choice tape — which is the loop's counter — then the loop's own registers, and last the tape TM.retargetOutput sends the verdict to.

Six registers are needed: the two tallies, the horizon to compare the count against, a scratch cell for that comparison, a permanently blank tape to blank the verdict slot from, and the unary register that drives the wipe.

Main results #

@[reducible, inline]

The counting machine's tape count: the simulation's k + 1, six registers, and the tape the verdict is written to.

Equations
Instances For

    The counter, which is also the simulation's choice tape.

    Equations
    Instances For

      The accepting tally.

      Equations
      Instances For

        The rejecting tally.

        Equations
        Instances For

          The horizon the counter is compared against.

          Equations
          Instances For

            Scratch space for that comparison.

            Equations
            Instances For

              A permanently blank tape, read whenever the verdict slot must be blanked.

              Equations
              Instances For

                The unary register that drives the wipe.

                Equations
                Instances For

                  The tape the simulation's output is redirected to.

                  Equations
                  Instances For
                    theorem Complexity.NTM.vIdx_eq_last (k : ) :
                    vIdx k = Fin.last (0 + (k + 1) + 6)

                    The simulated machine's own work tapes: everything strictly left of the counter.

                    Equations
                    Instances For
                      @[simp]
                      theorem Complexity.NTM.mem_simTapes_iff (k : ) (j : Fin (bodyTapes k)) :
                      j simTapes k j < k

                      A counter tape holding zero is the blank tape, and so is a unary register holding zero. The machine's initial configuration therefore already carries both, which is what a prologue can start from.

                      A unary register of T ones is the binary numeral 2 ^ T - 1. The two encodings agree cell for cell: regCells writes 1 in cells 1 … T and blanks beyond, and so do the bits of 2 ^ T - 1. This is what lets the prologue produce the horizon 2 ^ T with a single increment, instead of a doubling loop.

                      theorem Complexity.NTM.cIdx_lt_aIdx (k : ) :
                      (cIdx k) < (aIdx k)

                      The registers are pairwise distinct, and none of them is one of the simulation's tapes.

                      The resting contents of every tape the tally state does not name. The horizon sits on NTM.nIdx and the wipe's unary register on NTM.regIdx; everything else rests blank.

                      Equations
                      Instances For
                        theorem Complexity.NTM.bodyRest_other (k N H : ) (j : Fin (bodyTapes k)) (hn : j nIdx k) (hr : j regIdx k) :
                        theorem Complexity.NTM.bodyRest_head (k N H : ) (j : Fin (bodyTapes k)) :
                        (bodyRest k N H j).head = 1
                        theorem Complexity.NTM.bodyIdx_ne (k : ) :
                        (cIdx k) = k (aIdx k) = k + 1 (rIdx k) = k + 2 (nIdx k) = k + 3 (resIdx k) = k + 4 (zIdx k) = k + 5 (regIdx k) = k + 6 (vIdx k) = k + 7

                        The named registers are distinct from each other and from the simulation's tapes.

                        The tapes the body wipes on its way out: the simulated machine's own, and the tape its verdict was written to.

                        Equations
                        Instances For
                          @[simp]
                          theorem Complexity.NTM.mem_wipeTargets_iff (k : ) (j : Fin (bodyTapes k)) :
                          j wipeTargets k j < k j = vIdx k