Polynomial Time and the Class P

Context: FIT2014_MOC · decidability is not enoughdecidable says a computer can answer, this note asks whether it can answer before the sun dies; refines the tier regular ⊊ context-free ⊊ decidable by inserting

Quick Revision

  • 🎯 Objective: is polynomial time iff for some fixed decided by some polynomial-time TM, the first formal definition of “efficiently solvable”.
  • 📦 Core Components: time complexity ➔ worst case over inputs of length | polynomial slowdown ➔ why is model-independent | membership ➔ exhibit an algorithm and bound its steps.
  • ⚡ Key Constraint: is fixed and input-independent and are not polynomial; and is undefined unless is a decider, so a recogniser that loops has no time complexity at all.

📝 How It Works

1. Time complexity of a Turing machine

  • Per-input cost the number of steps M takes on input until it halts — one step one transition, not one “operation”.
  • The complexity function, a function of worst case, never average, and maximised over the finitely many inputs of each length.
  • Definedness precondition ➔ the max exists only if halts on every input, i.e. is a decider ().
  • Lecture’s three calibration examplesstrings ending in (sweep right to the blank, step back once) | palindromes (match-and-erase from both ends) | .
  • Every regular language is in ➔ the FA to TM construction of Lecture 18 reads each letter once and never returns ⟹ .

2. The model dependence — and why it evaporates

  • Details that move the constant ➔ number of tape symbols · tape infinite in one or both directions · number of tapes · dimensionality of the tape (1-D, 2-D, …) · whether “stay still” is a legal move.
  • Why a fixed threshold fails ➔ declaring “efficient at most steps” is arbitrary, ties the definition to one machine model, and decays as hardware improves ⟹ the class must be closed under the differences above, and only the polynomial family is.
  • Continuity with FIT1008/FIT1045 ➔ the complexity you already compute for programs also assumed a machine model, usually implicitly; is the version that stops depending on it (see Algorithmic Complexity).

3. Polynomial vs exponential — the growth gap

If you… timeexponential time
grow input by a fixed amount ()time grows by an additive time grows by a fixed multiplicative factor
grow input by a fixed factor ()time time raised to the power
double the machine’s speedfeasible input size fixed factorfeasible input size fixed amount
need inputs twice today’s sizewait years for hardwarewait your current input size

When It Flips: the last two rows are the real argument — under Moore's Law a polynomial algorithm inherits hardware progress ( doublings years buys a doubling of ), an exponential one converts the whole of it into on the input size. Faster machines rescue polynomials, never exponentials.

4. The class

A language is polynomial-time decidable if some polynomial-time TM decides it. is the class of all such languages — historically the first, and still the default, formalisation of tractable.

  • The power is fixed, the machine is not ➔ different members of have wildly different ; what matters is only that some fixed bounds the given machine.
  • History ➔ Alan Cobham (1965), Jack Edmonds (1965), Michael Rabin (1966).
  • Proving membership ➔ give an algorithm and bound its step count by a polynomial; the bound may be loose, since only the existence of some matters.

🧮 Proof Blueprint — is model-independent

Theorem. If can simulate with polynomial slowdown (a computation of taking time costs at most ), and is polynomial time, then simulates in polynomial time. Hence decidable in polynomial time on decidable in polynomial time on .

Strategycompose the two polynomial bounds and read off that a polynomial of a polynomial is a polynomial.

📚 Members of

FamilyLanguages in Certifying algorithm
Wordsstrings ending in · palindromes · · pairs in lexicographic order · matching parenthesessingle or double sweep of the tape
Language classesevery regular language · every context-free language · FA TM sweep; CYK at
Numberscoprime pairs · square numbers · PRIMES (Agrawal–Kayal–Saxena, Annals of Mathematics, 2004) · invertible matricesEuclidean Algorithm; AKS; Gaussian elimination
Graphstrees · balanced binary trees · has an path of length · regular graphs · 2-colourable graphs · Eulerian graphs · planar graphs (advanced)search / degree counting / bipartiteness test
Logic2-SAT — satisfiable CNF with exactly two literals per clause(slide’s challenge; algorithm not given)
  • Where the tiers now sit ➔ regular context-free decidable, each containment proper with a named witness: separates the first, and 2-SAT the second, and the time-bounded Halting Problem, RegExp equivalence, generalised Chess and generalised Go the third.
  • 2-SAT vocabulary ➔ a truth assignment is a function ; an expression is satisfiable iff some assignment makes it True. For , gives False, but gives True ⟹ satisfiable. One bad assignment proves nothing.

⚠️ Common Mistakes

  • 💡 Letting the exponent float ➔ ” for some ” quantifies once per machine, before the input is seen. has a growing exponent and is not polynomial.
  • 💡 Computing for a non-decider ➔ no halting guarantee, no maximum, no time complexity. Establish “decider” before quoting a bound.
  • 💡 Confusing “in ” with “fast” is in and useless in practice; is a robustness-driven abstraction, not a performance promise.
  • 💡 Testing one truth assignment ➔ satisfiability is an claim (Quantifiers (Existential and Universal)). One assignment giving False refutes nothing; one giving True settles it.
  • 💡 Quoting the model ➔ never write “in on a two-tape TM” — the slowdown theorem is precisely what makes the qualifier meaningless.

🧠 Active Recall