The class P #
A decision problem is a set A : Set α of instances, together with an encoding
enc : α ↪ List Bool of instances as binary words, in the style of
Turing.MultiTapeTM.DecidableInTimeAndSpace. It is in P when a Boolean function deciding
membership is computable in polynomial time (Turing.MultiTapeTM.ComputableInPolyTime) with
respect to enc and the encoding Turing.MultiTapeTM.encBool of answers
Arora and Barak, Definition 1.13. Equivalently, A ∈ P enc when upstream
Turing.MultiTapeTM.DecidableInTimeAndSpace holds within time and space bounded by polynomially
bounded functions of the length of the encoded instance
(Cslib.Complexity.mem_P_iff_exists_decidableInTimeAndSpace), and, as in the textbook
definition, a polynomial time bound alone suffices
(Cslib.Complexity.mem_P_of_decidableInTimeAndSpace).
Mathlib's Turing.TM2ComputableInPolyTime is stated for Mathlib's stack machines; this file
uses cslib's multi-tape machines, which carry the time and space measures the rest of the
development is built on. For machines with finite stack alphabets,
Turing.TM2ComputableInPolyTime.computableInPolyTime in
CslibFrontier.Computability.Machines.Turing.TM2.Recoding transfers Mathlib certificates over
binary
encodings to this notion.
Main definitions #
Cslib.Complexity.P: problems decidable in polynomial time.
Main results #
Cslib.Complexity.mem_P_iff_exists_decidableInTimeAndSpace:Pin terms of upstreamTuring.MultiTapeTM.DecidableInTimeAndSpacewith polynomially bounded time and space.Cslib.Complexity.mem_P_of_decidableInTimeAndSpace: a polynomial time bound alone suffices.Cslib.Complexity.empty_mem_P,Cslib.Complexity.univ_mem_P: the empty and universal problems are inP.Cslib.Complexity.compl_mem_P,Cslib.Complexity.P_eq_preimage_compl_P:Pis closed under complement.
References #
The problems decidable in polynomial time with respect to the encoding enc: A ∈ P enc
when a Boolean function deciding membership in A is computable in polynomial time
Arora and Barak, Definition 1.13.
Instances For
P in upstream terms: A ∈ P enc exactly when some machine with a binary alphabet and
finitely many states decides A within time and space bounded by polynomially bounded functions
of the length of the encoded instance.
A problem that some machine decides within a time bound polynomial in the length of the
encoded instance, with any space bound, is in P, as in the textbook definition.