Documentation

Complexitylib.Models.TuringMachine.UTM.Internal.Interp

Interpreting machine descriptions #

TMDesc.toTM turns a description into an actual single-work-tape machine: states are Fin (2^w + 1) (the extra state 2^w is the "never halts" sentinel produced when decoding a malformed halt field — it is unreachable, since every transition target is reduced mod 2^w), transitions look up the table, and head directions are sanitized to satisfy the ▷ ⇒ move right discipline.

descOfTM extracts a well-formed description from any single-work-tape machine: states are numbered by the canonical Fintype equivalence and the table lists every (state, symbols) combination densely.

Main results #

Interpret a description as a single-work-tape machine. States are Fin (2^w + 1); state 2^w is the never-halting sentinel (reachable only as a malformed qhalt, never as a transition target). Directions are sanitized to satisfy the ▷ ⇒ right discipline.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    noncomputable def Complexity.TM.descAct (M : TM 1) (q : Fin (Fintype.card M.Q)) (si sw so : Γ) :

    The table action of M (with states numbered by stateEquiv) on the key (q, si, sw, so).

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      noncomputable def Complexity.TM.descEntry (M : TM 1) (q : Fin (Fintype.card M.Q)) (si sw so : Γ) :

      The dense table row for key (q, si, sw, so).

      Equations
      • M.descEntry q si sw so = { q := q, si := si, sw := sw, so := so, act := M.descAct q si sw so }
      Instances For
        noncomputable def Complexity.TM.descOfTM (M : TM 1) :

        Extract a description from a single-work-tape machine: states are numbered by the canonical equivalence, the state field width is the state count itself (k < 2^k), and the table densely lists every (state, symbols) combination.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem Complexity.TM.descOfTM_lookup (M : TM 1) (q : Fin (Fintype.card M.Q)) (si sw so : Γ) :
          M.descOfTM.lookup (↑q) si sw so = M.descAct q si sw so

          Looking up an in-range key in the extracted table returns the extracted action.

          noncomputable def Complexity.TM.descCfg (M : TM 1) (c : Cfg 1 M.Q) :

          Configuration embedding into the interpreted description's state space: states are renumbered by stateEquiv (values below card Q < 2^card Q), tapes are unchanged.

          Equations
          Instances For
            theorem Complexity.TM.descOfTM_halted (M : TM 1) (c : Cfg 1 M.Q) :

            Halting is preserved by the embedding.

            The initial configuration embeds correctly.

            Stepping the interpreted description commutes with the configuration embedding.

            theorem Complexity.TM.descOfTM_reachesIn (M : TM 1) {t : } {c c' : Cfg 1 M.Q} (h : M.reachesIn t c c') :

            Multi-step correspondence.

            Extraction fidelity: the interpreted description of a machine decides the same language in exactly the same time.

            theorem Complexity.TM.exists_wf_desc_decidesInTime {L : Language} {T : } (M : TM 1) (h : M.DecidesInTime L T) :
            ∃ (d : TMDesc), d.WF d.toTM.DecidesInTime L T

            Every language decidable by a single-work-tape machine is decidable by an interpreted well-formed description in the same time bound.