wk3 - complexity class NP & Karp reductions

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/32

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 2:07 PM on 5/3/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

33 Terms

1
New cards

(x, y) ∈ R

y is a valid solution for x

x = input

y = candidate solution

2
New cards

input solution relation: R ⊆ {0, 1}∗ × {0, 1}∗

an algorithm V verifies R if on input (x, y):

V (x , y ) = 1 ⇐⇒ (x , y ) ∈ R

3
New cards

LR = {x : ∃y (x , y ) ∈ R}

an algorithm A decides LR if on input x:

A(x ) = 1 ⇐⇒ (∃y )(x , y ) ∈ R

4
New cards

efficient verification only make sense if

valid solutions have reasonable size

5
New cards

what would make this relation polynomially bounded

R ⊆ {0, 1} × {0, 1}

if there exists a polynomial p such that for all (x, y) ∈ R:

|y| ≤ p(|x|)

(answers (solutions) are not as long as the input)

6
New cards

a language L is in NP if

there exists a polynomially bounded relation R and a polynomial time verifier V such that:

x ∈ L ⇐⇒ (∃y ) (x , y ) ∈ R

7
New cards

x ∈ L ⇐⇒ (∃y ) (x , y ) ∈ R

what is y

what is V

y is a certificate

V verifies (x, y) in polynomial time

8
New cards

what does NP stand for

Nondeterministic Polynomial Time

9
New cards

a non deterministic algorithm:

- may branch into multiple possible executions

- accepts an input if some execution path accepts

(just like how NFA can branch into multiple

10
New cards

NP definition

the class of languages decidable by nondeterministic programs in polynomial time

11
New cards

proof of P ⊆ NP

1. assume L ∈ P and M be an efficient algorithm that decides whether a given input x ∈ L

2. define R = L x {0}

(this means zero is a certificate for every input)

3. it is easy to see R is polynomially bounded

4. the verifier V(x, y): check and accept iff M(x) accepts and y = 0

(in a way, M itself acts as a verifier)

12
New cards

proof of NP ⊆ EXP

(EXP = exponential time complexity class)

1. let L ∈ NP; and V the verifier;

suppose certificates length for input of size n is l(n)

2. construct a solver M(x) to enumerate all possible certificates y ∈ {0, 1} ^ l(n)

and run V(x, y) on each one, if it accepts then the solver accepts

3. M accepts x iff x ∈ L

13
New cards

NP ⊆ EXP brute force idea

- enumerate all possible certificates y of length ≤ p(|x |)

- verify each (x, y) in polynomial time

14
New cards

NP is closed under union theorem

if L1, L2 ∈ NP, then L1 ∪ L2 ∈ NP

15
New cards

formal proof for

if L1, L2 ∈ NP, then L1 ∪ L2 ∈ NP

1. let R1, R2 be polynomially bounded relations

2. let V1, V2 be their polynomial-time verifiers

3. we need a verifier V for L1 ∪ L2 where

on input (x , b ◦ y):

- if b = 0, return V1(x, y)

- otherwise, return V2(x,y)

4. notice that if x ∈/∈ L1 ∪ L2, verifier V never accepts any certificate. otherwise if x ∈ L1, then there must be y1 such that V1(x, y1) accepts; in this case, verifier V accepts the certificate 0 ◦ y1. the case when x ∈ L2 is similar

16
New cards

NP is closed under intersection theorem

if L1, L2 ∈ NP, then L1 ∩ L2 ∈ NP

17
New cards

core idea for a certificate for L1 ∩ L2 ∈ NP

consists of two certificates;

1. a certificate for L1

2. a certificate for L2

both certificates are polynomially bounded

both certificates run in polynomial time

18
New cards

how would you show that NP is closed under complement, what is the issue with it?

to show x is not in L, we would need a certificate of non-existence

in general, such certificates may not exist

19
New cards

difference between class P and class NP

- P can be decided in polynomial time whereas NP can be verified in polynomial time

- P is equivalent to efficient decision

- NP certificates are polynomially bounded

- P is closed under complement, whereas NP closure under complement is unknown

P is efficient computation, NP efficient verification

20
New cards

a language A is Karp-reducible to B if there exists a polynomial-time function f such that:

x ∈ A ⇐⇒ f (x ) ∈ B

use A ≤Karp B to denote this

21
New cards

what do karp reductions show

all constraints of one problem can be expressed inside another problem

solving B implies solving A, preserves YES/NO answers

22
New cards

theoretical power of karp reductions

if A ≤Karp B, then A is no harder than B

- if B ∈ P, then A ∈ P

- if A is "hard" then B is "hard"

reductions define a partial order of computational difficulty

<p>if A ≤Karp B, then A is no harder than B</p><p>- if B ∈ P, then A ∈ P</p><p>- if A is "hard" then B is "hard"</p><p>reductions define a partial order of computational difficulty</p>
23
New cards

practical power of karp reductions

a reduction is an adapter.

translate instances of A into instances of Bm then call a solver for B

a library for B implies a solver for A

<p>a reduction is an adapter.</p><p>translate instances of A into instances of Bm then call a solver for B</p><p>a library for B implies a solver for A</p>
24
New cards

what is the goal of the reduction:

3COL ≤ karp SAT

given a graph G, we construct a boolean formula ϕ such that:

G ∈ 3COL ⇐⇒ ϕ ∈ SAT

(so G is 3 colourable iff ϕ is satisfiable)

25
New cards

given: G ∈ 3COL ⇐⇒ ϕ ∈ SAT

how are the variables of formula ϕ defined

for each vertex v ∈ V(G) and each colour j ∈ {1, 2, 3}, introduce a boolean variable:

x(v, j)

x(v, j) = true iff vertex v is assigned colour j

each vertex has three associates variables

total num of variables is 3|V(G)|

26
New cards

clause to enforce each vertex v ∈ V(G) gets a colour

given: G ∈ 3COL ⇐⇒ ϕ ∈ SAT

Cv = (x(v, 1) ∨ x (v , 2) ∨ x (v , 3))

Cv ensures that vertex v is assigned some colour |D

combine all vertices: (in image)

<p>Cv = (x(v, 1) ∨ x (v , 2) ∨ x (v , 3))</p><p>Cv ensures that vertex v is assigned some colour |D</p><p>combine all vertices: (in image)</p>
27
New cards

clause to enforce adjacent vertices get different colours j ∈ {1, 2, 3}

given: G ∈ 3COL ⇐⇒ ϕ ∈ SAT

for each edge {u, v} ∈ E(G) and colour j ∈ {1, 2, 3} define:

Q{u,v },j = (¬x (u, j) ∨ ¬x (v , j))

Q{u,v },j forbids u and v from both having color j

combine all conflicts: (in image)

<p>for each edge {u, v} ∈ E(G) and colour j ∈ {1, 2, 3} define:</p><p>Q{u,v },j = (¬x (u, j) ∨ ¬x (v , j))</p><p>Q{u,v },j forbids u and v from both having color j</p><p>combine all conflicts: (in image)</p>
28
New cards

final formula of ϕ

given: G ∈ 3COL ⇐⇒ ϕ ∈ SAT

ϕ = C ∧ Q

ϕ is in conjunctive normal form (CNF) with at most three literals per clause (3SAT)

the size of ϕ is O(|V(G)| + |E(G)|)

29
New cards

correctness proof of

a proper 3-colouring -> satisfying assignment

- let σ : V → {1, 2, 3} be a colouring

- define x(v, j) = true iff σ(v) = j

- this satisfies each clause Cv since each vertex gets a colour

- it also satisfies each clause Qe since each edge sees different colours

30
New cards

correctness proof of

a satisfying assignment -> proper 3-colouring

- for each clause Cv define σ(v ) = j if x (v , j) is true

- since each Qu,v is true, we have that σ(v) /= σ(u)

- therefore the colouring is proper

31
New cards

independent set (IS) in a graph

is a set of vertices no two of which are adjacent

32
New cards

what is α(G)

the size of the largest independent set in G

33
New cards

INDSET =

{(G, k) : G has independent set of size k}