Documentation

Complexitylib.Models.TuringMachine.Repetition.Internal.Rewind

Fixed-time rewind correctness for PTM repetition #

This internal module lifts the one-tape fixed-rewind theorem to the complete NTM.repeatAtTime wrapper configuration. A snapshot packages the input tape, all work-tape banks, the real output tape, and the per-tape completion flags. Its deterministic step commutes with one wrapper .rewind transition.

After exactly T + 1 rewind transitions, every active tape is parked at cell one with its contents unchanged, the control enters .finish, and the inactive tapes and real output tape are exactly preserved. Choice bits are arbitrary in this administrative phase.

Main definitions and results #

Pure data advanced during the simultaneous fixed rewind of one repetition bank. The control state and completed-run votes remain external constants.

  • input : Tape

    Shared read-only input tape.

  • work : Fin (k * (n + 1))Tape

    All physical work-tape banks.

  • output : Tape

    Real wrapper output tape, framed throughout rewind.

  • inputDone : Bool

    Whether the input head has already bounced from cell zero.

  • bankDone : Fin (n + 1)Bool

    Per-local-tape bounce flags for the active bank.

Instances For

    A framed tape is off the start marker and satisfies its uniqueness invariant, hence the wrapper's idle action preserves it exactly.

    Equations
    Instances For

      Snapshot well-formedness: input and active tapes satisfy the start-marker invariant, while inactive tapes and real output are parked for exact framing.

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

        Advance every active tape and completion flag by one fixed rewind step.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[simp]
          theorem Complexity.NTM.repeatRewindBankDone_apply {k n : } (work : Fin (k * (n + 1))Tape) (j : Fin k) (done : Fin (n + 1)Bool) :
          repeatRewindBankDone (fun (i : Fin (k * (n + 1))) => (work i).read) j done = fun (i : Fin (n + 1)) => repeatRewindDone (done i) (work (repeatTapeIdx j i)).read

          Pointwise form of repeatRewindBankDone on tape reads.

          def Complexity.NTM.repeatRewindCfg {n k T : } (tm : NTM n) (j : Fin k) (r : Fin (T + 1)) (q : tm.Q) (votes : Fin kBool) (S : RepeatRewindSnapshot n k) :
          Cfg (k * (n + 1)) (tm.RepeatQ k T)

          Embed a rewind snapshot at counter r into the wrapper configuration.

          Equations
          Instances For
            def Complexity.NTM.repeatFinishCfg {n k T : } (tm : NTM n) (j : Fin k) (q : tm.Q) (votes : Fin kBool) (S : RepeatRewindSnapshot n k) :
            Cfg (k * (n + 1)) (tm.RepeatQ k T)

            Embed a completed rewind snapshot in the wrapper's finish state.

            Equations
            Instances For

              The tape component of repeatFixedRewindTapeStep is its guarded movement: writing the current symbol back is cell-preserving under StartInvariant.

              One simultaneous snapshot step preserves snapshot well-formedness.

              Every finite snapshot iteration preserves well-formedness.

              A snapshot step commutes with any number of iterations of itself.

              Snoc form of the snapshot iterator recursion.

              The input tape and flag project to the pure one-tape rewind iterator.

              Each active bank tape and flag project to the pure one-tape iterator.

              theorem Complexity.NTM.repeatRewindSnapshotIter_inactive {k n : } (j : Fin k) (m : ) (S : RepeatRewindSnapshot n k) (i : Fin (k * (n + 1))) (hi : (repeatTapeCoord i).1 j) :

              Snapshot iteration preserves every inactive physical work tape exactly.

              @[simp]

              Snapshot iteration preserves the real output tape exactly.

              theorem Complexity.NTM.repeatAtTime_trace_one_rewind {n k T : } (tm : NTM n) (j : Fin k) (r : Fin (T + 1)) (q : tm.Q) (votes : Fin kBool) (S : RepeatRewindSnapshot n k) (hS : RepeatRewindSnapshot.WellFormed j S) (choice : Fin 1Bool) :
              (tm.repeatAtTime k T).trace 1 choice (tm.repeatRewindCfg j r q votes S) = if hr : r + 1 < T + 1 then tm.repeatRewindCfg j r + 1, hr q votes (repeatRewindSnapshotStep j S) else tm.repeatFinishCfg j q votes (repeatRewindSnapshotStep j S)

              One wrapper rewind transition commutes with one simultaneous snapshot step. The choice bit is arbitrary because the administrative phase ignores it.

              theorem Complexity.NTM.repeatAtTime_trace_rewind_prefix {n k T : } (tm : NTM n) (j : Fin k) (q : tm.Q) (votes : Fin kBool) (S : RepeatRewindSnapshot n k) (hS : RepeatRewindSnapshot.WellFormed j S) (m : ) (hm : m < T + 1) (choices : Fin mBool) :
              (tm.repeatAtTime k T).trace m choices (tm.repeatRewindCfg j 0, q votes S) = tm.repeatRewindCfg j m, hm q votes (repeatRewindSnapshotIter j m S)

              Before the final rewind slot, an m-step wrapper trace agrees exactly with m pure snapshot steps and carries rewind counter m.

              theorem Complexity.NTM.repeatAtTime_trace_rewind_snapshot {n k T : } (tm : NTM n) (j : Fin k) (q : tm.Q) (votes : Fin kBool) (S : RepeatRewindSnapshot n k) (hS : RepeatRewindSnapshot.WellFormed j S) (choices : Fin (T + 1)Bool) :
              (tm.repeatAtTime k T).trace (T + 1) choices (tm.repeatRewindCfg j 0, q votes S) = tm.repeatFinishCfg j q votes (repeatRewindSnapshotIter j (T + 1) S)

              Exactly T + 1 wrapper rewind transitions produce the finish configuration associated with T + 1 simultaneous snapshot steps.

              theorem Complexity.NTM.repeatAtTime_trace_rewind_bound {n k T : } (tm : NTM n) (j : Fin k) (q : tm.Q) (votes : Fin kBool) (C : Cfg (k * (n + 1)) (tm.RepeatQ k T)) (hstate : C.state = RepeatQ.rewind j 0, q votes false fun (x : Fin (n + 1)) => false) (hinv : C.input.StartInvariant) (hactiveInv : ∀ (i : Fin (n + 1)), (C.work (repeatTapeIdx j i)).StartInvariant) (hinputHead : C.input.head T) (hactiveHead : ∀ (i : Fin (n + 1)), (C.work (repeatTapeIdx j i)).head T) (hinactive : ∀ (i : Fin (k * (n + 1))), (repeatTapeCoord i).1 jRepeatParked (C.work i)) (hout : RepeatParked C.output) (choices : Fin (T + 1)Bool) :
              have C' := (tm.repeatAtTime k T).trace (T + 1) choices C; C'.state = RepeatQ.finish j q votes C'.input.head = 1 C'.input.cells = C.input.cells (∀ (i : Fin (n + 1)), (C'.work (repeatTapeIdx j i)).head = 1 (C'.work (repeatTapeIdx j i)).cells = (C.work (repeatTapeIdx j i)).cells) (∀ (i : Fin (k * (n + 1))), (repeatTapeCoord i).1 jC'.work i = C.work i) C'.output = C.output

              Fixed rewind correctness. Starting from rewind counter zero with all completion flags false, T + 1 administrative steps enter .finish, park the input and every active-bank tape at cell one without changing their cells, and preserve every inactive tape and the real output tape exactly.