Exercise

Prove the Two Definitions of NP Equivalent

Convert between nondeterministic polynomial time and polynomially bounded certificates.

Assignment sources

Semester A 2026 assignmentsOfficial assignmentexercise2.pdfQ4–Q5Authoritative course artifact
Noy 2025 high-quality exam preparation and community solutionsCommunity solutionפתרון מטלה 2 - סיבוכיות.pdfAssignment 2High-quality preparation and community solution — not official

Problem

Prove that a language LL is decided by a nondeterministic polynomial-time TM if and only if there are a polynomial pp and deterministic polynomial-time verifier VV such that

x∈L  ⟺  ∃y, ∣y∣≤p(∣x∣) and V(x,y)=1.x\in L\iff \exists y,\ |y|\le p(|x|)\ \text{and}\ V(x,y)=1.

Track certificate length and total verification time in both directions.

Prerequisites

Know the unit definitions and how resources are measured against encoded input length. Distinguish a conditional theorem, a reduction, and an algorithm.

Hint 1

Encode one nondeterministic choice per simulated step.

Hint 2

Reject certificates that do not describe a legal accepting computation.

Hint 3

In the reverse direction, guess exactly a polynomially padded certificate, then run VV.

Full solution

Assume first that a nondeterministic TM NN decides LL and every branch halts within q(n)q(n) steps. Because the transition relation is finite, each step has at most a constant bb possible choices. Encode a branch by a string yy of q(n)⌈log⁡b⌉q(n)\lceil\log b\rceil bits, padding after early halting. Define V(x,y)V(x,y) to simulate N(x)N(x) deterministically, using successive blocks of yy to select transitions. Reject if a block names no legal transition, if the simulated branch rejects, or if it has not accepted by the clock.

The certificate length is O(q(n))O(q(n)), hence polynomial. A straightforward deterministic simulation of q(n)q(n) steps is polynomial in ∣x∣+∣y∣|x|+|y|; even a polynomial model-conversion overhead remains polynomial. There is an accepting branch of N(x)N(x) exactly when some choice string drives the simulation to acceptance. Therefore

x∈L  ⟺  ∃y V(x,y)=1.x\in L\iff\exists y\ V(x,y)=1.

Conversely, suppose VV and pp satisfy the verifier definition, with VV running in time r(∣x∣+∣y∣)r(|x|+|y|). Construct an NTM NN that, on input xx, nondeterministically writes a certificate of length at most p(∣x∣)p(|x|) and then runs V(x,y)V(x,y). One convenient fixed-length implementation guesses p(n)p(n) symbols including a padding symbol, verifies canonical padding, and interprets the prefix as yy. Guessing costs O(p(n))O(p(n)) and verification costs at most r(n+p(n))r(n+p(n)), a polynomial in nn. Every branch halts.

If x∈Lx\in L, a valid witness exists and one branch guesses it, so NN accepts. If x∉Lx\notin L, no witness makes VV accept, so every branch rejects. Thus NN decides LL nondeterministically in polynomial time.

The quantifiers matter. NP requires existence of one accepting branch or certificate for yes-instances and rejection of all branches for no-instances. It does not require a unique witness, and the verifier need not find a witness. Also, the polynomial bound must be in ∣x∣|x|, not in the numerical value encoded by xx. Finally, a verifier must halt on every pair (x,y)(x,y), including malformed or overlong certificates; these may simply be rejected.

Checkpoints

Check both logical directions, halting of every relevant branch, and that output length and construction time are polynomial in the encoded input length.

Common mistakes

  • Using the entire computation tableau when a choice string suffices without bounding it.
  • Saying a no-instance has one rejecting branch instead of all branches rejecting.
  • Letting verification time be polynomial in the numeric value of the input.
Guided construction

Nondeterministic computation tree

Step 1 of 7
φ =(x₁ ∨ ¬x₂)∧(x₂ ∨ x₃)
Binary nondeterministic computation treeThe verifier guesses three assignment bits. Eight leaves check the formula, and the path 110 reaches an accepting leaf.ε
legal binary choice

Sources and verification

  • Merged summary, pp. 40-42
  • 2026 transcript 8
  • Sipser 3e, sec. 7.3
  • Arora-Barak draft, sec. 2.1
  • Catalog mapping: data/exercises.json; statements and solutions are independently written; personal submissions are non-authoritative.

Provenance and confidence

The exercise is an original synthesis. Confidence reflects verification of the mathematical claim against the textbook sources listed above; course sources are used only where direct coverage is identified.