4.6.25 · HinglishTheory of Computation

NP-completeness — Cook's theorem (SAT is NP-complete), reduction

2,521 words11 min readRead in English

4.6.25 · Coding › Theory of Computation


KISKE baare mein baat kar rahe hain hum?


Cook's theorem KYUN matter karta hai? (80/20 core)

Woh 20% jo aapko pakka pata hona chahiye: SAT NP-complete. Do hissay:

  1. SAT NP — aasaan. Ek assignment (certificate) diya, usse plug in karo aur ko poly time mein evaluate karo. ✔
  2. SAT is NP-hard — woh deep part jo Cook ne prove kiya: NP ka har language NP, SAT mein reduce hota hai.

Jab (1)+(2) hold ho jaayein, SAT anchor ban jaata hai. Kisi bhi nayi problem ko NP-complete prove karne ke liye bas:

  • Dikhao NP, aur
  • Dikhao koi jaana-maana NP-complete problem , mein reduce hota hai ().

Kyunki transitive hai, plus "sab kuch " se milta hai "sab kuch ."


Cook ne SAT ko NP-hard KAISE prove kiya? (scratch se derivation)

Step 1 — Computation tableau

ko steps tak run karo. Tape kabhi bhi cell se aage nahi jaati. Toh poora run ek grid hai:

cell 0 cell 1 ... cell
time 0 ... ...
time 1 ... ...
...
time

Ek tableau. Har cell mein ek tape symbol hota hai, saath mein hum mark karte hain kahan head hai aur kis state mein hai. Yeh step kyun? ka poora behaviour is finite grid mein capture ho jaata hai — finite ⇒ finitely many Boolean variables se encode ho sakta hai.

Step 2 — Boolean variables

Har tableau position aur har possible content (ek tape symbol, ya "head yahan state mein hai") ke liye define karo Kyun? Yeh dual coding hai: ek physical configuration ↔ ek truth assignment. Variables ki sankhya polynomial. ✔

Hum four types ke clauses AND karke jodte hain:

Moves ke liye window kyun? Turing head ek step mein sirf apne neeche wale cell aur uske neighbours ko affect karta hai. Toh legality ek local property hai: agar har chhota window locally legal hai, toh poora run legal hai. Yahi locality formula size ko polynomial rakhti hai.

Step 4 — Wrap up

  • Total clauses: , har ek constant size ka. banana mein polynomial time leta hai. ✔
  • satisfiable ek legal accepting tableau exist karta hai , ko accept karta hai .

Toh NP ke har NP ke liye. SAT NP ke saath milake: SAT is NP-complete.

Figure — NP-completeness — Cook's theorem (SAT is NP-complete), reduction

Reductions "sahi direction" mein KYUN jaate hain (sabse #1 confusion)

B ko NP-hard prove karne ke liye, ek jaane-maane-hard ko B mein reduce karo: ek banao jisme .


Common mistakes (Steel-manned)


Active recall

Recall Khud test karo (jawaab chhupa ke)
  • "X is NP-complete" ke liye kya do cheezein prove karni hain? → NP aur NP-hard hai.
  • B ko NP-hard prove karne ki direction? → known NPC ( se B mein reduce karo).
  • Cook's reduction mein Boolean variables kya encode karte hain? → har time step par har tableau cell ka content.
  • Move-clause sirf window par kyun hai? → head changes local hote hain, toh legality locally checkable hai.
  • SAT NP — certificate kya hai? → ek truth assignment; evaluate karke verify karo.
NP ka matlab aur definition kya hai
Nondeterministic Polynomial — "yes" instances ka ek certificate poly time mein verifiable hota hai.
NP-complete ki definition
Ek problem jo NP mein bhi hai aur NP-hard bhi.
NP-hard ki definition
NP ka har problem usmein polynomial time mein reduce hota hai (NP ke sabse mushkil ke barabar).
Cook's theorem batao
SAT (Boolean satisfiability) NP-complete hai.
SAT ko NP-complete prove karne ke do parts
(1) SAT ∈ NP via ek assignment evaluate karke; (2) SAT is NP-hard by NP ke har language ko SAT mein reduce karke.
Cook's reduction ka core idea
Ek nondeterministic TM ke accepting computation tableau ko ek Boolean formula ke roop mein encode karo jo satisfiable ho tabhi jab machine accept kare.
Cook's proof mein variables x_{i,j,s} ka matlab
Tableau ka cell (i,j) time i par, position j par content s contain karta hai (true/false).
Cook's formula mein chaar clause groups
cell (exactly one content), start (sahi initial row), accept (koi accepting state appear ho), move (har 2×3 window ek legal transition hai).
Move-clauses local windows par kyun hain
TM head ek step mein sirf ek cell aur uske neighbours ko affect karta hai, toh legality ek local property hai.
A ≤_p B ka matlab
Poly-time f aisa ki x∈A ⟺ f(x)∈B; B kam se kam A jitna mushkil hai.
B ko NP-hard prove karne ke liye kis direction mein reduce karo
Ek known NP-complete A ko B MEIN reduce karo (A ≤_p B), ulta nahi.
B ko SAT mein reduce karna hardness ke liye kyun galat hai
Yeh sirf dikhata hai B SAT se zyada mushkil nahi, yeh nahi ki B hard hai.
Reduction 3-SAT ≤_p Independent Set: clause gadget
3 vertices ka ek triangle (ek literal per), har clause se ≤1 choose karne ko force karta hai.
Reduction 3-SAT ≤_p IS: consistency edges
Complementary literals x aur ¬x ke beech edges taaki contradictory choices forbidden ho.
3-SAT ≤_p IS mein target size k kya hai
k = clauses ki sankhya m.
Kya P ⊆ NP hai
Haan — jo bhi poly time mein solvable hai woh trivially poly time mein verifiable bhi hai.
≤_p transitivity kyun matter karta hai
Yeh nayi NP-completeness proofs ko ek anchor (SAT) se chain karne deta hai instead of NP ke poore ko re-reduce karne ke.
Recall Feynman: 12-saal ke bacche ko samjhao

Socho ek giant lock factory hazaaron alag-alag tricky locks (mushkil puzzles) banati hai. Cook ne ek special master key (SAT) dhundhi jo factory ke saare locks khol sakti hai. Toh agar aap kabhi is master key ko super-fast copy karne ka tarika invent karo, toh turant saare locks khul jaate hain. Aur yeh prove karne ke liye ki koi nayi lock bhi super-tricky hai, bas dikhao "yeh nayi lock master key jaisi act kar sakti hai" — matlab woh bhi tricky hai. Master key banane ki trick thi ki ek guessing-robot ke puzzle solve karne ke poore step-by-step diary ko ek giant true/false riddle ke roop mein likhna: riddle tabhi solve hota hai jab robot jeet sakta hai.


Connections

  • P vs NP problem — Cook's theorem is sahare sawaal ki neenv hai.
  • Polynomial-time reduction — woh tool jo hardness propagate karta hai.
  • 3-SAT — restricted SAT, clause splitting se bhi NP-complete.
  • Karp's 21 NP-complete problems — SAT se reductions ki pehli wave.
  • Turing machine / Nondeterministic Turing machine — tableau mein encode hone wala computation model.
  • Independent Set / Vertex Cover / Clique — classic graph NP-complete trio.
  • Verifier definition of NP — "SAT ∈ NP" ke liye use hone wala certificate view.

Concept Map

subset of

both in NP and

inside

every NP problem reduces to it

proves

is

encoded as formula

clauses build

transitive property

reduces to

shown

P poly-time solvable

NP poly-time verifiable

NP-hard

NP-complete

SAT satisfiability

Poly reduction A leq_p B

Cook's theorem

Computation tableau

NTM run in p of n steps

New problem B