Logarithmic space #
Space is upstream's measure: the number of distinct work-tape cells visited by the heads, summed
over the work tapes. The input is on a read-only tape and is not charged; nor is the write-only,
append-only output. A space bound applies to every computation prefix
(Turing.MultiTapeNTM.RunsInSpace). The logarithmic bounds are c * (Nat.log2 n + 1) on encoded
instances of length n, for a constant c Sipser, Section 8.4.
Cslib.Complexity.L enc consists of the problems decided by a Boolean function computable in
logarithmic space (Turing.MultiTapeTM.ComputableInLogSpace): one deterministic machine with a
binary alphabet and finitely many states halts on every encoded instance with output [true] or
[false] within logarithmic space. Any number of work tapes is allowed; definitions with one
work tape give the same class, since work tapes can be interleaved on one at a constant factor in
space (not formalized here). No time bound is imposed beyond halting; a polynomial one follows
(Cslib.Complexity.L_subset_P). Equivalently (Cslib.Complexity.mem_L_iff), the problem is
decidable within some time and space c₁ * Nat.log2 n + c₂ in the sense of upstream
Turing.MultiTapeTM.DecidableInTimeAndSpace. The local characterization
Cslib.Complexity.mem_L_iff_mem_DSPACE gives exactly DSPACE enc Nat.log2, the shape of the class
L = DSPACE(log₂) of cslib pull request #767 (open), whose classes are indexed by languages
rather than encoded instances.
Cslib.Complexity.NL enc consists of the problems decided by one nondeterministic machine with a
binary alphabet and finitely many states within logarithmic space
(Turing.MultiTapeNTM.DecidesInSpace): every computation prefix on enc a stays within the bound,
every branch halts, and a ∈ A exactly when some computation path halts with output [true]
Sipser, Definition 8.1. No time bound is imposed beyond halting; a polynomial one
follows (Cslib.Complexity.NL_subset_P).
Halting convention. Every branch must halt: on each encoded instance some number of steps
bounds every computation path, though a path may end stuck before it, and then does not accept.
Every upper bound proved here for NL also holds for logspace recognizers, whose branches may run
forever (Turing.MultiTapeNTM.RecognizesInSpace): such a problem is in P
(Cslib.Complexity.mem_P_of_recognizesInSpace). The complement construction also puts it in
NL itself (Cslib.Complexity.mem_NL_of_recognizesInSpace in
CslibFrontier.Computability.Complexity.Classes.LogSpace.Complement), without requiring source
termination.
Cslib.Complexity.LogSpaceReducible encA encB A B asks for a logspace function mapping instances
of A to instances of B, preserving membership Sipser, Section 8.5. By definition
it is the many-one reducibility Cslib.Complexity.ManyOneReducibleBy by logspace functions
(Cslib.Complexity.logSpaceReducible_iff_manyOneReducibleBy); its body is kept as the ∃
statement, so that the admissibility goal of an anonymous constructor is
ComputableInLogSpace f enc encB itself. Logspace reductions compose, and L is closed under
them, because logspace functions compose without storing intermediate values
(Turing.MultiTapeTM.ComputableInLogSpace.comp). Hardness and completeness under them,
Cslib.Complexity.LogSpaceHard and Cslib.Complexity.LogSpaceComplete, are the instances of
Cslib.Complexity.HardUnder and Cslib.Complexity.CompleteUnder for LogSpaceReducible; the
second conjunct of LogSpaceComplete is stated as LogSpaceHard.
Main definitions #
Cslib.Complexity.L: deterministic logarithmic space.Cslib.Complexity.NL: nondeterministic logarithmic space.Cslib.Complexity.LogSpaceReducible: logspace many-one reductions.Cslib.Complexity.LogSpaceHard,Cslib.Complexity.LogSpaceComplete: hardness and completeness under logspace many-one reductions.
Main results #
Cslib.Complexity.mem_L_iff:Lin terms of upstreamDecidableInTimeAndSpace.Cslib.Complexity.mem_L_iff_mem_DSPACE: the specializationDSPACE Nat.log2.Cslib.Complexity.L_subset_NL: a deterministic machine is a nondeterministic machine.Cslib.Complexity.compl_mem_L,Cslib.Complexity.L_eq_preimage_compl_L:Lis closed under complement.Cslib.Complexity.L_subset_P: logarithmic space is within polynomial time.Cslib.Complexity.L_subset_PSPACE,Cslib.Complexity.NL_subset_NPSPACE: logarithmic space is within polynomial space.Cslib.Complexity.LogSpaceReducible.refl,Cslib.Complexity.LogSpaceReducible.trans: logspace reducibility is a preorder.Cslib.Complexity.LogSpaceReducible.mem_L:Lis closed under logspace reductions.Cslib.Complexity.LogSpaceReducible.compl: reductions between complements.Cslib.Complexity.LogSpaceReducible.polyTimeReducible: logspace reductions are polynomial-time reductions.Cslib.Complexity.LogSpaceHard.trans: hardness transfers along logspace reductions.Cslib.Complexity.LogSpaceHard.subset_L: a hard problem inLplaces its source class inL.Cslib.Complexity.LogSpaceComplete.mem_L_iff: a problem complete for a class containingLis inLexactly when the class equalsL, for every encoding.Cslib.Complexity.LogSpaceHard.polyTimeHard: logspace hardness implies polynomial-time hardness.Cslib.Complexity.LogSpaceComplete.polyTimeComplete: completeness under logspace reductions implies completeness under polynomial-time reductions.
References #
The problems decided in logarithmic space with respect to the encoding enc: a Boolean
function deciding membership is computable in logarithmic space
Sipser, Section 8.4.
Instances For
The problems decided by one nondeterministic machine within logarithmic space with respect to
the encoding enc: every computation prefix on enc a visits at most c * (Nat.log2 n + 1)
work-tape cells, where n is the length of enc a, every branch halts, and a ∈ A exactly when
some computation path halts with output [true] Sipser, Definition 8.1.
Instances For
Deterministic logarithmic space is within nondeterministic logarithmic space: a
deterministic machine is a nondeterministic one with one computation path
(Turing.MultiTapeTM.ComputableInTimeAndSpace.exists_decidesInSpace).
Logspace reductions #
A reduces to B in logarithmic space: some f, computable in logarithmic space with
respect to enc and encB, satisfies a ∈ A ↔ f a ∈ B. This is ManyOneReducibleBy for the
maps computable in logarithmic space (logSpaceReducible_iff_manyOneReducibleBy).
Instances For
Logspace reducibility is many-one reducibility by the maps computable in logarithmic space.
Every problem reduces to itself in logarithmic space.
Logspace reductions compose.
A logspace reduction between problems is one between their complements.
Logspace reductions are polynomial-time reductions.
B is hard for the class C under logspace many-one reductions: every problem in C, with
any encoding of its instances, reduces to B in logarithmic space. This is HardUnder for
LogSpaceReducible.
Instances For
B is complete for the class C under logspace many-one reductions: it is in C and every
problem in C reduces to it in logarithmic space. This is CompleteUnder for
LogSpaceReducible (logSpaceComplete_iff_completeUnder), with its second conjunct stated as
LogSpaceHard.
Instances For
Logspace hardness is hardness under LogSpaceReducible.
Logspace completeness is completeness under LogSpaceReducible.
Logspace hardness transfers along a logspace reduction.
A class with a logspace-hard problem in L is contained in L, for every encoding.
A problem complete for a class containing L is in L exactly when the class equals
L, for every encoding of instances. For P and NL this is the L-analogue of
Cslib.Complexity.NPComplete.mem_P_iff.
Hardness under logspace reductions implies hardness under polynomial-time reductions.
Completeness under logspace reductions implies completeness under polynomial-time reductions.