Documentation

Complexitylib.Classes.Containments.Internal.PSPACESubsetEXP

PSPACE ⊆ EXP — proof internals #

⚠️ Unreviewed by Bolton

A space-bounded machine has only exponentially many configurations, and a deterministic run visits each at most once before halting, so its halting time is bounded by that count. The machine is unchanged: only the time bound is new.

The counting needs one invariant the space predicate does not state. Cfg.WithinDecisionSpace bounds head positions, not tape contents; but a head that never leaves [0, S] can never write outside it, so every cell beyond the window still holds its initial blank. Windowed records that, and Windowed.step propagates it.

theorem Complexity.Windowed.step {k : } {tm : TM k} {x : List Bool} {S : } {c c' : Cfg k tm.Q} (hw : Windowed x S c) (hstep : tm.step c = some c') (hspace : c.WithinDecisionSpace x.length S) :
Windowed x S c'

A step of a machine whose heads stay inside the window preserves the invariant.

Counting the configurations inside the window #

A halting deterministic run is short #

The deterministic iteration TM.runCfg and its algebra come from Complexitylib.Classes.P.Cobham.Internal.Simulate, where the Cobham simulation already needed them.

theorem Complexity.TM.reaches_runCfg {k : } (tm : TM k) (c : Cfg k tm.Q) (n : ) :
tm.reaches c (tm.runCfg c n)

Every configuration of a run is reachable.

theorem Complexity.TM.runCfg_periodic {k : } (tm : TM k) (c₀ : Cfg k tm.Q) {i d : } (h : tm.runCfg c₀ i = tm.runCfg c₀ (i + d)) (r : ) :
tm.runCfg c₀ (i + r) = tm.runCfg c₀ (i + d + r)

Once a configuration repeats, the run is periodic from that point on.

theorem Complexity.TM.repeat_contradiction {k : } (tm : TM k) (c₀ : Cfg k tm.Q) {t : } (hmin : s < t, ¬tm.halted (tm.runCfg c₀ s)) (hhalt : tm.halted (tm.runCfg c₀ t)) {a b : } (hb : b t) (hlt : a < b) (hab : tm.runCfg c₀ a = tm.runCfg c₀ b) :

A repeat before the first halt is impossible: periodicity would pull a halted configuration back before time t.

theorem Complexity.TM.runCfg_injective_before_halt {k : } (tm : TM k) (c₀ : Cfg k tm.Q) {t : } (hmin : s < t, ¬tm.halted (tm.runCfg c₀ s)) (hhalt : tm.halted (tm.runCfg c₀ t)) :
Function.Injective fun (i : Fin (t + 1)) => tm.runCfg c₀ i

Before the first halt, the configurations of a deterministic run are pairwise distinct.

From a space bound to a time bound #

theorem Complexity.TM.exists_reachesIn {k : } {tm : TM k} {c c' : Cfg k tm.Q} (h : tm.reaches c c') :
∃ (t : ), tm.reachesIn t c c'

Reachability gives a step count.

theorem Complexity.TM.reachesIn_runCfg {k : } (tm : TM k) (c : Cfg k tm.Q) (t : ) :
(∀ s < t, ¬tm.halted (tm.runCfg c s))tm.reachesIn t c (tm.runCfg c t)

Before the first halt, the run is a genuine reachesIn run.

theorem Complexity.TM.windowed_runCfg {k : } {tm : TM k} {L : Language} {f : } (hdec : tm.DecidesInSpace L f) (x : List Bool) (n : ) :
Windowed x (f x.length) (tm.runCfg (tm.initCfg x) n)

Every configuration of a run from the initial configuration is windowed.

def Complexity.TM.spaceTimeBound {k : } (tm : TM k) (f : ) (n : ) :

The exponential configuration bound of a space-f machine.

Equations
Instances For
    theorem Complexity.TM.halt_time_le {k : } {tm : TM k} {L : Language} {f : } (hdec : tm.DecidesInSpace L f) (x : List Bool) {t : } (hmin : s < t, ¬tm.halted (tm.runCfg (tm.initCfg x) s)) (hhalt : tm.halted (tm.runCfg (tm.initCfg x) t)) :

    A space-bounded machine halts within its configuration count.

    theorem Complexity.TM.spaceTimeBound_le_two_pow {k : } (tm : TM k) (f : ) (n : ) :
    tm.spaceTimeBound f n 2 ^ (Fintype.card tm.Q + (n + f n + 2) + 3 * k * (f n + 1) + 3 * (f n + 2))

    The configuration count is at most exponential in the space bound.

    noncomputable def Complexity.TM.boundExp {k : } (tm : TM k) (p : Polynomial ) :

    A polynomial dominating the exponent of the configuration count.

    Equations
    Instances For
      theorem Complexity.TM.spaceTimeBound_le_two_pow_poly {k : } (tm : TM k) (f : ) (p : Polynomial ) (hf : ∀ (n : ), f n Polynomial.eval n p) (n : ) :

      The configuration count is at most 2 to a polynomial.

      The time bound #

      theorem Complexity.TM.decidesInTime_of_decidesInSpace {k : } {tm : TM k} {L : Language} {f : } (hdec : tm.DecidesInSpace L f) :

      A space-bounded decider is a time-bounded decider, with no change of machine: the run halts by the time it would have to repeat a configuration.

      theorem Complexity.TM.eval_le_pow_succ (q : Polynomial ) :
      ∃ (N : ), ∀ (n : ), N nPolynomial.eval n q n ^ (q.natDegree + 1)

      A polynomial is eventually dominated by the next power.

      theorem Complexity.TM.spaceTimeBound_bigO {k : } {tm : TM k} {f : } {m : } (hf : BigO f fun (x : ) => x ^ m) :
      ∃ (j : ), BigO (tm.spaceTimeBound f) fun (n : ) => 2 ^ n ^ j

      The configuration count is exponential.

      PSPACE ⊆ EXP. A polynomial-space decider halts within its configuration count, which is exponential, so the same machine is an exponential-time decider.