Polynomial-time computable functions are closed under composition
ProvedPvsNP.isPolyTime_compLet , , be types equipped with canonical bitstring encodings, and let and be computable in polynomial time by two-stack Turing machines with respect to those encodings. Then the composite is computable in polynomial time as well.
The intended construction is the standard one: run the machine for on the input, copy its output stack to the input stack of the machine for , and run the machine for . The composed machine can be realised as a single two-stack machine with one stack for each stack of the two component machines. For the time bound, note that a machine writes at most one symbol per step, so on input the intermediate string has length at most , where is the polynomial time bound of the first machine; the total running time is therefore bounded by
which is again a polynomial in since polynomials with natural-number coefficients are closed under composition, sums and products.
This closure property is the basic workhorse of polynomial-time complexity theory: it underlies the fact that is closed downwards under polynomial-time many-one (Karp) reductions, and hence every completeness argument.
import Definitions.Def_PvsNP_complexity_classes
namespace PvsNP
theorem isPolyTime_comp {α β γ : Type} [BitstringEncoding α] [BitstringEncoding β]
[BitstringEncoding γ] (f : α → β) (g : β → γ) (hf : IsPolyTime f) (hg : IsPolyTime g) :
IsPolyTime (g ∘ f) := by sorry
end PvsNP