Documentation

CslibFrontier.Computability.Complexity.Classes.Hierarchy.Space

The space hierarchy theorem #

Cslib.Complexity.DSPACE is defined in Classes.Space.Basic, and Cslib.Complexity.SpaceConstructible in Classes.Constructible. Their generic APIs and the concrete L and PSPACE characterizations do not depend on this hierarchy theorem.

The space hierarchy theorem #

Cslib.Complexity.spaceDiagonal G runs the machine described at the start of its input x, when the description is tiny (Cslib.Complexity.Diagonal.tinyDesc), on x with the universal machine within a space budget (Turing.MultiTapeTM.Universal.budgetedUniversal): for 2 ^ G n steps, with the configurations of the simulation encoded within G n bits. It negates the verdict, and answers false on other inputs. The budgeted universal machine is the in-place universal run with a budget test at the end of each pass, within space linear in the description, the budget and the lengths of the clock and of n in binary (Turing.MultiTapeTM.Universal.budgetSpace_le).

The diagonal does not hold its input. A tiny description has at most log₂ (log₂ n + 1) bits, so it is decoded in logarithmic space (Cslib.Complexity.Diagonal.computableInLogSpace_decodeDesc_tinyCut), and the input of the universal machine (the description, the symbols of x, the clock and the budget) is recomputed on demand in logarithmic space from x, never charged. So the diagonal takes space O(G n + log n) (Cslib.Complexity.computableInTimeAndSpace_spaceDiagonal) and decides a problem in DSPACE G when log₂ n ≤ G n (Cslib.Complexity.setOf_spaceDiagonal_mem_DSPACE).

Let a machine decide the same problem within space c₁ * f n + c₂, where every c * f n + c is eventually below G n, and let 4 * log₂ n ≤ G n. It halts within its number of configurations, (n + 2) * 2 ^ O(f n), which is below the clock 2 ^ G n. The configurations of its simulation take O(f n + log n) bits, with a factor linear in its description: the overhead of the universal machine is a constant factor for each simulated machine, eventually within the budget (Cslib.Complexity.Diagonal.eventually_cfgSpaceBound_le). So on its own description, padded to a doubly exponential length where it is tiny, the diagonal answers the negation of its answer (Cslib.Complexity.setOf_spaceDiagonal_notMem_DSPACE). Hence the space hierarchy theorem Stearns, Hartmanis and Lewis, Sipser, Theorem 9.3, Arora and Barak, Theorem 4.8:

The gap f = o(g) and the lower bound log n ≤ g n are the textbook ones. The nondeterministic space hierarchy, under the same hypotheses, is in CslibFrontier.Computability.Complexity.Classes.Hierarchy.NondeterministicSpace.

Main definitions #

Main results #

References #

The padded diagonal argument follows the time hierarchy theorem (CslibFrontier.Computability.Complexity.Classes.Hierarchy.Time), here on Christian Reitwiessner's in-place universal interpreter within a space budget.

The diagonal within a space budget #

The diagonal within space G. On a word x of length n whose framed description is tiny (Cslib.Complexity.Diagonal.tinyDesc), run the described machine on x, under the coding Turing.MultiTapeTM.Universal.eBit of bits, for 2 ^ G n steps within the budget of G n bits for the encoded configurations of the simulation (Turing.MultiTapeTM.Universal.budgetedUniversal), and return false exactly when it has halted with output [true]; answer false on other words.

The diagonal within space G is computable within space O(G n + log n), for a space-constructible G. The tiny description, decoded, and the symbols of the input are computed in logarithmic space, and the clock 2 ^ G n in binary and the budget G n in unary within space O(G n); this input of the budgeted universal machine is recomputed on demand, not stored. The budgeted universal run takes space linear in the description, the budget and the lengths of the clock and of n in binary (Turing.MultiTapeTM.Universal.budgetSpace_le), and the tininess test logarithmic space.

The diagonal within space G decides a problem in DSPACE G, for a space-constructible G with log₂ n ≤ G n.

theorem Cslib.Complexity.spaceDiagonal_desc {k : ℕ} {State : Type} [Fintype State] (eS : State ↪ ℕ) (tm : Turing.MultiTapeTM k Bool State) (pad : List Bool) (G : ℕ → ℕ) {b : Bool} (htiny : Diagonal.tinyDesc (Turing.MultiTapeTM.frame (Turing.MultiTapeTM.Universal.eDesc (Turing.MultiTapeTM.Universal.desc eS Turing.MultiTapeTM.Universal.eBit tm)) ++ pad) = true) (hbudget : Turing.MultiTapeTM.Universal.cfgSpace (Turing.MultiTapeTM.Universal.desc eS Turing.MultiTapeTM.Universal.eBit tm) (List.map (⇑Turing.MultiTapeTM.Universal.eBit) (Turing.MultiTapeTM.frame (Turing.MultiTapeTM.Universal.eDesc (Turing.MultiTapeTM.Universal.desc eS Turing.MultiTapeTM.Universal.eBit tm)) ++ pad)) (2 ^ G (Turing.MultiTapeTM.frame (Turing.MultiTapeTM.Universal.eDesc (Turing.MultiTapeTM.Universal.desc eS Turing.MultiTapeTM.Universal.eBit tm)) ++ pad).length) ≤ G (Turing.MultiTapeTM.frame (Turing.MultiTapeTM.Universal.eDesc (Turing.MultiTapeTM.Universal.desc eS Turing.MultiTapeTM.Universal.eBit tm)) ++ pad).length) (hhalt : (Turing.MultiTapeTM.runFrom (tm.initCfg (Turing.MultiTapeTM.frame (Turing.MultiTapeTM.Universal.eDesc (Turing.MultiTapeTM.Universal.desc eS Turing.MultiTapeTM.Universal.eBit tm)) ++ pad)) (2 ^ G (Turing.MultiTapeTM.frame (Turing.MultiTapeTM.Universal.eDesc (Turing.MultiTapeTM.Universal.desc eS Turing.MultiTapeTM.Universal.eBit tm)) ++ pad).length)).Halted) (hout : (Turing.MultiTapeTM.runFrom (tm.initCfg (Turing.MultiTapeTM.frame (Turing.MultiTapeTM.Universal.eDesc (Turing.MultiTapeTM.Universal.desc eS Turing.MultiTapeTM.Universal.eBit tm)) ++ pad)) (2 ^ G (Turing.MultiTapeTM.frame (Turing.MultiTapeTM.Universal.eDesc (Turing.MultiTapeTM.Universal.desc eS Turing.MultiTapeTM.Universal.eBit tm)) ++ pad).length)).output = [b]) :

On a tiny padded description, the diagonal within space G negates the answer of a machine that halts within the clock 2 ^ G n and whose simulated configurations fit within the budget G n.

theorem Cslib.Complexity.setOf_spaceDiagonal_notMem_DSPACE {f G : ℕ → ℕ} (hlog : ∀ (n : ℕ), 4 * n.log2 ≤ G n) (hfG : ∀ (c : ℕ), ∀ᶠ (n : ℕ) in Filter.atTop, c * f n + c ≤ G n) :

The diagonal argument for space. If every c * f n + c is eventually below G n and 4 * log₂ n ≤ G n, the problem of the diagonal within space G is not in DSPACE f. A decider within space O(f) halts within its number of configurations, (n + 2) * 2 ^ O(f n), which is below the clock 2 ^ G n, and the configurations of its simulation take O(f n + log n) bits, eventually within the budget G n; so on its own description, padded to a tiny one beyond these points, the diagonal answers the negation of its answer.

The space hierarchy theorem #

theorem Cslib.Complexity.DSPACE_ssubset_DSPACE {f g : ℕ → ℕ} (hg : SpaceConstructible g) (hlog : ∀ (n : ℕ), n.log2 ≤ g n) (hfg : ∀ (c : ℕ), ∀ᶠ (n : ℕ) in Filter.atTop, c * f n + c ≤ g n) :

The space hierarchy theorem. If g is space-constructible, log₂ n ≤ g n, and every c * f n + c is eventually below g n, then DSPACE f is strictly contained in DSPACE g Sipser, Theorem 9.3 and Corollary 9.4, Arora and Barak, Theorem 4.8. The universal machine simulates within a budget with a constant overhead for each simulated machine, and the diagonal reads its input in place, so both the gap f = o(g) and the lower bound log n ≤ g n are the textbook ones. The diagonal within space 4 * g separates the classes.

⌊log₂ n⌋ ^ (k + 1) eventually dominates every c * ⌊log₂ n⌋ ^ k + c.

Polylogarithmic space has a strict hierarchy: DSPACE (log₂ n ^ (k + 1)) ⊂ DSPACE (log₂ n ^ (k + 2)).

Logarithmic space is strictly within space log² n: L = DSPACE (log₂ n), and the diagonal within space 4 * log₂ n ^ 2 separates them Sipser, Corollary 9.4.

Logarithmic space is strictly within polynomial space: L ⊂ DSPACE (log₂ n ^ 2), which is within PSPACE. This is the deterministic part of Sipser, Corollary 9.6, which separates NL from PSPACE.

(n + 1) ^ (k + 1) eventually dominates every c * n ^ k + c.

Polynomial space has a strict hierarchy: DSPACE (n ^ k) ⊂ DSPACE (n ^ (k + 1)) Sipser, Corollary 9.5. The diagonal within space 4 * (n + 1) ^ (k + 1) separates them.