Documentation

Atlas.TheoryOfComputation.code.LogSpace

Base-2 logarithm on , used as the canonical space bound for the class L = SPACE(log n).

Instances For
    structure LogSpace.LogSpaceConfig (Q Γ : Type) :

    A log-space Turing machine configuration (q, p_1, p_2, t) consisting of the current state, the input-tape head position p_1, the work-tape head position p_2, and the contents t of the work tape.

    • state : Q
    • inputHeadPos :
    • workHeadPos :
    • workTape : Γ
    Instances For

      The type of log-space configurations restricted so that the input head lies in Fin n, the work head lies in Fin s, and the work tape is encoded as a function Fin s → Γ. This is a finite type whenever Q and Γ are.

      Instances For
        @[implicit_reducible]
        noncomputable instance LogSpace.BoundedLogSpaceConfig.fintype (Q Γ : Type) [Fintype Q] [Fintype Γ] (n s : ) :

        BoundedLogSpaceConfig Q Γ n s is a finite type, inherited from the product structure of its components.

        Convert an ordinary Turing-machine configuration into the log-space configuration view by taking the input head position to be |c.headPos|, initializing the work head to 0, and copying the tape as the work tape.

        Instances For
          def LogSpace.InL {Γ : Type} (A : Set (List Γ)) :

          The complexity class L = SPACE(log n): A ∈ L iff A is decided by some deterministic TM in space O(log n).

          Instances For
            def LogSpace.InNL {Γ : Type} (A : Set (List Γ)) :

            The complexity class NL = NSPACE(log n): A ∈ NL iff A is decided by some nondeterministic TM in space O(log n).

            Instances For
              def LogSpace.InCoNSPACE {Γ : Type} (f : ) (A : Set (List Γ)) :

              coNSPACE(f): A ∈ coNSPACE(f) iff the complement of A lies in NSPACE(f).

              Instances For
                def LogSpace.InCoNL {Γ : Type} (A : Set (List Γ)) :

                The class coNL = coNSPACE(log n): A ∈ coNL iff Aᶜ ∈ NL.

                Instances For

                  IsAtLeastLog f asserts that f grows at least as fast as log₂, i.e. log₂ n ≤ f n for every n. This is the standard hypothesis under which Immerman–Szelepcsényi gives NSPACE(f) = coNSPACE(f).

                  Instances For

                    Immerman–Szelepcsényi Theorem. For any space bound f with f(n) ≥ log₂ n, the class NSPACE(f) is closed under complementation: if A ∈ NSPACE(f) then Aᶜ ∈ NSPACE(f).

                    theorem LogSpace.nspace_eq_conspace {Γ : Type} (f : ) (hf : IsAtLeastLog f) (A : Set (List Γ)) :

                    NSPACE(f) = coNSPACE(f) for any f ≥ log₂, an immediate consequence of Immerman–Szelepcsényi applied to both A and Aᶜ.

                    theorem LogSpace.nl_eq_conl {Γ : Type} (A : Set (List Γ)) :

                    NL = coNL (Immerman–Szelepcsényi specialized to f = log₂).

                    inductive LogSpace.BoundedReachable {V : Type u_1} (G : VVProp) :
                    VVProp

                    BoundedReachable G d s t holds when t is reachable from s in the graph G using at most d edge steps. The weaken constructor pads a d-step path into a (d+1)-step path, ensuring monotonicity in d.

                    Instances For
                      def LogSpace.reachableSet {V : Type u_1} (G : VVProp) (d : ) (s : V) :
                      Set V

                      The set of vertices reachable from s in G within at most d steps.

                      Instances For
                        noncomputable def LogSpace.reachableCount {V : Type u_1} (G : VVProp) (d : ) (s : V) :

                        The count c_d = |reachableSet G d s| of vertices reachable from s within d steps. In the Immerman–Szelepcsényi proof this is the quantity computed inductively by an NL machine.

                        Instances For
                          theorem LogSpace.nl_config_compute {NLComputes_cd NLDecides_pathd : Prop} (thm_cd_to_pathd_succ : ∀ (d : ), NLComputes_cd dNLDecides_pathd (d + 1)) (counting_to_cd : ∀ (d : ), NLDecides_pathd dNLComputes_cd d) (d : ) (h : NLComputes_cd d) :
                          NLComputes_cd (d + 1)

                          Inductive step in the Immerman–Szelepcsényi argument: given an NL procedure for computing c_d, one can build an NL procedure for deciding the distance-(d+1) path predicate, from which an NL procedure for c_{d+1} is obtained. This packages those two abstract steps into the successor case.

                          theorem LogSpace.step_eq_of_isHaltConfig {Q Γ : Type} [DecidableEq Q] (M : TuringMachine.TM Q Γ) (c : TuringMachine.Config Q Γ) (h : M.isHaltConfig c) :
                          M.step c = c

                          If c is a halting configuration of M, then M.step c = c: halting configurations are fixed points of the transition function.

                          theorem LogSpace.run_eq_of_isHaltConfig {Q Γ : Type} [DecidableEq Q] (M : TuringMachine.TM Q Γ) (c : TuringMachine.Config Q Γ) {n m : } (hn : n m) (h : M.isHaltConfig (M.run c n)) :
                          M.run c m = M.run c n

                          Once M has halted by step n, running it further does nothing: M.run c m = M.run c n for every m ≥ n.

                          theorem LogSpace.isHaltConfig_mono {Q Γ : Type} [DecidableEq Q] (M : TuringMachine.TM Q Γ) (c : TuringMachine.Config Q Γ) {n m : } (hn : n m) (h : M.isHaltConfig (M.run c n)) :
                          M.isHaltConfig (M.run c m)

                          Monotonicity of halting: if M is in a halting configuration after n steps and n ≤ m, then it is also in a halting configuration after m steps.

                          theorem LogSpace.space_bounded_decider_poly_time {Q Γ : Type} [DecidableEq Q] [Fintype Q] [Fintype Γ] (M : TuringMachine.TM Q Γ) (g : ) (hSpace : SpaceComplexity.TMRunsInSpace M g) :
                          ∃ (t : ) (K : ), M.runsInTime t 0 < K ∀ (n : ), t n K * 2 ^ (K * g n)

                          A deterministic TM running in space g(n) must halt within O(2^{O(g(n))}) steps, since otherwise some configuration would repeat and the machine would loop. Concretely there exist a time bound t and a constant K > 0 with M.runsInTime t and t n ≤ K · 2^(K · g n).

                          theorem LogSpace.dtm_simulates_ntm {Q Γ : Type} [DecidableEq Q] (M : SpaceComplexity.NTM Q Γ) (g : ) (hM_space : M.RunsInSpace g) :
                          ∃ (Q' : Type) (x : Fintype Q') (x : DecidableEq Q') (T : TuringMachine.TM Q' Γ), T.language = M.language T.isDecider ∃ (K : ), 0 < K T.runsInTime fun (n : ) => K * 2 ^ (K * g n)

                          Simulation of a space-g NTM by a deterministic TM with time O(2^{O(g)}): searching the configuration graph of an NTM whose space usage is g can be done deterministically in time exponential in g.

                          theorem LogSpace.nspace_bounded_decider_poly_time {Q Γ : Type} [DecidableEq Q] (M : SpaceComplexity.NTM Q Γ) (g : ) (hSpace : M.RunsInSpace g) :
                          ∃ (Q' : Type) (x : Fintype Q') (x : DecidableEq Q') (T : TuringMachine.TM Q' Γ) (t : ) (K : ), T.decides M.language T.runsInTime t 0 < K ∀ (n : ), t n K * 2 ^ (K * g n)

                          Packaging of dtm_simulates_ntm: every space-g NTM is decided by a deterministic TM in time K · 2^(K · g n) for some constant K > 0. This is the key tool behind NL ⊆ P (and more generally NSPACE(g) ⊆ DTIME(2^{O(g)})).

                          theorem LogSpace.l_subset_p {Γ : Type} [Fintype Γ] (A : Set (List Γ)) (h : InL A) :

                          L ⊆ P. Every language decidable in deterministic log-space is also decidable in deterministic polynomial time. The proof combines space_bounded_decider_poly_time (giving a time bound of K · 2^(K · g n)) with the bound g n ≤ c · log₂ n from the log-space hypothesis, yielding a polynomial time bound K · n^(K · c + 1).