Documentation

Complexitylib.Models.TuringMachine.UTM.Diagonal

The time-hierarchy diagonalizer diagTM #

The 8-tape machine D := diagTM clk at the heart of the time hierarchy theorem. On input x it:

  1. builds the self-pair pair x x on work tape 7 (pairSelfTM);
  2. decides TerminatedRegion x by a single input scan (termCheckTM); malformed inputs are routed to a fixed 0 output (writeTM Γw.zero);
  3. for well-formed inputs: blanks the verdict cell (blankOutTM), builds the unary clock regTape (g |x|) on work tape 6 (the abstract clock-constructibility witness clk), runs the clocked universal machine on the self-pair (retargetInput clockedUtmTM), and finally negates output cell 1 (negOutTM) — accepting exactly when the simulated machine does not accept within g |x| steps.

Main definitions #

Main results #

Implementation notes #

Two landed specs do not quite fit and are bridged locally:

def Complexity.TM.ClockWitness (tm : TM 8) (C : ) (g : ) :

The body of ClockConstructible, with the machine and constant exposed: tm writes the unary clock regTape (g |x|) on work tape 6 within C * (g |x| + |x| + 1) steps, framing the rest of the diagonalizer's tape layout. See ClockConstructible for the design discussion.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem Complexity.TM.clockConstructible_iff {g : } :
    ClockConstructible g ∃ (tm : TM 8) (C : ), tm.ClockWitness C g

    ClockConstructible is exactly the existential closure of ClockWitness.

    Replace output cell 1 with and halt with the output head parked at cell 1. Mirrors negOutTM exactly (rewind → right to cell 1 → write → halt); unlike writeTM, the input tape and all work tapes are exactly unchanged (readBackWrite writes and idleDir moves).

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      theorem Complexity.TM.blankOutTM_hoareTime {n : } (inp₀ : Tape) (work₀ : Fin nTape) (out₀ : Tape) (B : ) (h0 : out₀.cells 0 = Γ.start) (hns : ∀ (j : ), 1 jout₀.cells j Γ.start) (hB : out₀.head B) (hinp : inp₀.read Γ.start) (hw : ∀ (i : Fin n), (work₀ i).read Γ.start) :
      blankOutTM.HoareTime (fun (inp : Tape) (work : Fin nTape) (out : Tape) => inp = inp₀ work = work₀ out = out₀) (fun (inp : Tape) (work : Fin nTape) (out : Tape) => inp = inp₀ work = work₀ out.cells = Function.update out₀.cells 1 Γ.blank out.head = 1) (B + 3)

      blankOutTM specification (ghost form, exact frames). Starting from pinned tapes inp₀/work₀/out₀ with a well-formed output tape (cell 0 is , no at cells ≥ 1, head ≤ B) and no tape head resting on , blankOutTM halts within B + 3 steps having blanked output cell 1, all other output cells unchanged, output head parked at cell 1, and the input and work tapes exactly unchanged.

      def Complexity.TM.diagTM (clk : TM 8) :
      TM 8

      The time-hierarchy diagonalizer. Build pair x x on tape 7; check TerminatedRegion x (malformed inputs output 0); otherwise blank the verdict cell, build the clock regTape (g |x|) on tape 6 (clk), run the clocked universal machine on the self-pair, and negate output cell 1.

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

        The language the diagonalizer decides: inputs on which it halts with 1 at output cell 1.

        Equations
        Instances For
          def Complexity.TM.diagTime (C : ) (g : ) (n : ) :

          The diagonalizer's running-time bound (a closed form; see diagTime_le_poly for the clean polynomial bound).

          Equations
          Instances For
            theorem Complexity.TM.diagTM_decidesInTime (clk : TM 8) (C : ) (g : ) (hclk : clk.ClockWitness C g) (hg1 : ∀ (n : ), 1 g n) :

            The diagonalizer decides its language in time diagTime C g. For any clock-constructibility witness (clk, C) for g ≥ 1, the machine diagTM clk decides diagLang clk within diagTime C g steps.

            theorem Complexity.TM.diagTM_flips_of_halts (clk : TM 8) (C : ) (g : ) (hclk : clk.ClockWitness C g) (x : List Bool) (hterm : UTMBody.TerminatedRegion x) (T : ) (mcF : Cfg 1 (decodeDesc x).toTM.Q) (hT : T g x.length) (hrun : (decodeDesc x).toTM.reachesIn T ((decodeDesc x).toTM.initCfg x) mcF) (hhalt : (decodeDesc x).toTM.halted mcF) :

            The diagonal flip. On a well-formed input x whose interpreted machine halts within the clock budget at mcF, the diagonalizer accepts x exactly when the interpreted machine does not.

            theorem Complexity.TM.diagTM_flips (clk : TM 8) (C : ) (g : ) (hclk : clk.ClockWitness C g) (hg1 : ∀ (n : ), 1 g n) (x : List Bool) (hterm : UTMBody.TerminatedRegion x) (T : ) (mcF : Cfg 1 (decodeDesc x).toTM.Q) (hT : T g x.length) (hrun : (decodeDesc x).toTM.reachesIn T ((decodeDesc x).toTM.initCfg x) mcF) (hhalt : (decodeDesc x).toTM.halted mcF) :

            Compatibility form of diagTM_flips_of_halts. The positivity hypothesis is not needed for the flip itself, but remains in this public signature for callers of the original theorem.

            theorem Complexity.TM.diagTime_le_poly (C : ) (g : ) (n : ) :
            diagTime C g n (C + 786) * ((n + 1) ^ 2 * (g n + 1))

            Polynomial envelope for the diagonalizer's time bound: diagTime C g n ≤ (C + 786) * ((n + 1)² * (g n + 1)).