NP-Completeness (2)

Southgiri·2025년 6월 20일

SNUON Algorithm

목록 보기
4/7

Vertex Cover Problem

Vertex Cover Problem

  • A vertex cover of an undirected graph G=(V,E)G=(V,E) is a subset VVV' \sube V such that if (u,v)E(u,v) \in E, then uVu\in V' or vVv \in V' (or both)
    Graph 의 어떤 Edge 이든 edge를 이루는 두 vertex 중 하나는 VV' 에 속함
  • The size of a vertex cover is the number of vertices in it
    • A vertex cover {w,z}\{w,z\} of size 2

Goal: Finding a vertex cover of minimum size in a given graph

Optimization problem \rightarrow Decision problem

  • Input: An undirected graph G=(V,E)G=(V,E) and an integer kk
  • Question: Is there a vertex cover of a given size kk?

Vertex Cover Problem (NPC Proof)

1. NP 인지 증명 (=Polynomial time 으로 verification 가능해야함)

  • kk 개의 edge 집합 VV' 가 주어진다면, edge 가 다 존재하는지 확인
    \rightarrow Polynomial time 으로 확인 가능

2. NP Complete Problem 으로부터 Polynomial time 으로 reduction 가능해야함

  • Clique p\leq_p Vertex Cover
    • Complement of G=(V,E)G=(V,E) is Gˉ=(V,Eˉ)\bar{G}=(V,\bar{E}) where
      Eˉ={(u,v):u,vV,uv\bar{E}=\{(u,v):u,v \in V, u\neq v and (u,v)E}(u,v) \notin E\}
  • Reduction algorithm
    • Input: <G,k><G,k> of the clique problem
    • Compute Gˉ\bar{G} in polynomial time
    • Output: <Gˉ,Vk><\bar{G},|V|-k>
  • The graph GG has a clique of size kk iff the graph Gˉ\bar{G} has a vertex cover of size Vk|V|-k
    • Clique \rightarrow Vertex Cover
    • Suppose that GG has a clique VVV' \sube V with V=k|V'|=k
    • For any edge Eˉ\in \bar{E}
      • At least one of uu or vv does not belong to VV'
      • Equivalently, at least one of uu or vv is in VVV-V' \rightarrow edge (u,v)(u,v) is covered by VVV-V'
    • Every edge of Eˉ\bar{E} is covered by VVV-V'
    • Gˉ\bar{G} 에 존재하는 edge 의 두 vertex 중 적어도 하나는 반드시 clique 에 속하지 않은 vertex 이다.
    • Vertex Cover \rightarrow Clique
    • Suppose that Gˉ\bar{G} has a vertex cover VV,V=VkV' \sube V, |V'|=|V|-k
    • For all u,vVu,v \in V, if (u,v)Eˉ,uV or vV(u,v)\in \bar{E}, u \in V' \text{ or } v \in V'
    • The contrapositive of this implication is
      • For all u,vVu,v \in V, if uVu \notin V' and vVv \notin V', then (u,v)E(u,v) \in E
      • \Rightarrow VVV-V' has a clique with size VV=k|V-V'|=k

Subgraph Isomorphism

Subgraph Isomorphism

  • Isomorphism of graphs GG and HH is a bijection between the vertex sets of GG and HH
    • f:V(G)V(H)f:V(G) \rightarrow V(H)
    • Any two vertices uu and vv of GG are adjacent in GG iff f(u)f(u) and f(v)f(v) are adjacent in HH

Subgraph Isomorphism Problem

  • Input: G1=(V1,E1),G2=(V2,E2)G_1=(V_1, E_1),G_2=(V_2, E_2)
  • Question: Does G=(V,E)G=(V, E) with VV1V \sube V_1, EE1E \sube E_1 exist such that V=V2,E=E2|V|=|V_2|, |E|=|E_2| and
    there is a one to one function f:VV2f:V\rightarrow V_2 satisfying {u,v}E\{u,v\} \in E if {f(u),f(v)}E2\{f(u), f(v)\} \in E_2?
    G1G_1 의 subgraph GGG2G_2 와 isomorphism 인지 찾는 문제

Subgraph Isomorphism Problem (NPC Proof)

1. NP 증명 (=Polynomial time 으로 verification 가능해야함)

  • Given G1=(V1,E1),G2=(V2,E2)G_1=(V_1, E_1), G_2=(V_2, E_2), for G=(V,E)G=(V,E) and ff,
    we can verify that GG is subgraph of G1G_1 and isomorphic to G2G_2 in polynomial time
    • By checking
    • VV1,EE1V \sube V_1, E \sube E_1, V=V2,E=E2|V|=|V_2|, |E|=|E_2|
    • Every {u,v}E2\{u,v\} \in E_2 satisfy {f(u),f(v)}E\{f(u),f(v)\} \in E

2. NP Complete Problem 으로부터 Polynomial time 으로 reduction 가능해야함

  • Clique p\leq_p Subgraph Isomorphism
  • Reduction algorithm
    • Input: <G,k><G,k> of the clique problem
    • Generate a complete graph G2G_2 of size kk in polynomial time
    • Output: <G1,G2><G_1, G_2>
  • Clique \rightarrow Subgraph Isomorphism
    • G1G_1kk-clique 을 가진다면 생성된 G2G_2 와 isomorphic한 GG1G \sube G_1 가 존재
    • G1G_1kk-clique 을 가지지 않는다면 생성된 G2G_2 에 대해 어떤 ff도 isomorphism 만족 불가
  • Subgraph Isomorphism \rightarrow Clique
    • GG1G \sube G_1G2G_2와 isomorphic 하다면 G1G_1kk-clique 을 가짐

Hitting Set

Hitting Set

  • Given a set TT and a collection of sets C={S1,S2,,Sn}C=\{S_1, S_2,\dots,S_n\} where each SiS_i is a subset of TT
  • A hitting set HH is a subset of TT which intersects all sets in the collection with at least one element
    • for all i{1,2,,n}i \in \{1,2,\dots,n\}, we have HSi0H \cap S_i \neq \cancel{0}
    • e.g.
      • T={1,2,3,4,5}T=\{1,2,3,4,5\}
      • C={{1,2},{1,3},{3,4,5}}C=\{\{1,2\},\{1,3\},\{3,4,5\}\}
      • H={1,3}H=\{1,3\}

Hitting Set Problem

  • Finding a hitting set HH of TT with the minimum size

Optimization problem \rightarrow Decision problem

  • Input: A set TT, a collection of sets C={S1,S2,,Sn}C=\{S_1,S_2,\dots,S_n\}, where each SiS_i is a subset of TT and integer kk
  • Question: Is there a hitting set HH of TT with H=k|H|=k?

Hitting Set Problem (NPC Proof)

1. NP 증명 (=Polynomial time 으로 verification 가능해야함)

  • For the certificate of a hitting set HH, affirms that H=k|H|=k
  • Check HSi0H \cap S_i \neq 0 for i=1,,ni=1,\dots,n

2. NP Complete Problem 으로부터 Polynomial time 으로 reduction 가능해야함

  • Vertex Cover p\leq_p Hitting Set
    • Let <G,k><G,k> be an instance of the vertex cover problem and G=(V,E)G=(V,E)
    • Let T=VT=V and for all (u,v)E(u,v) \in E, add a new set {u,v}\{u,v\} to the collection CC
      • 여기서 SiS_i 사이즈는 2개인 것만
    • Show that there is a hitting set HH of size kk iff if GG has a vertex cover CC of size kk
  • Vertex Cover \rightarrow Hitting Set
    • Suppose there is a vertex CC for GG for size kk
      For each edge (u,v)(u,v) either uCu \in C or vCv \in C
      Setting CC to be HH gives a hitting set of size kk
  • Hitting Set \rightarrow Vertex Cover
    • Suppose there is a hitting set HH of size kk
      Since HH contains at least one endpoint of each edge,
      setting CC to be HH gives a vertex cover of size kk

Subset-Sum

Subset-Sum Problem

  • Input: A finite set SS of positive integers and an integer target t>0t > 0
  • Question: Is there a subset SSS' \sube S whose elements sum to tt?
  • e.g.
    • S={1,2,7,14,49,98,343,686,2409,2793}S=\{1,2,7,14,49,98,343,686,2409,2793\} and t=451t=451
    • S={1,2,7,98,343}S'=\{1,2,7,98,343\}

Subset-Sum (NPC Proof)

1. Subset-Sum \in NP

  • For an instance <S,t><S,t>, let the subset SS' be the certificate
  • Checking whether t=sSst=\displaystyle\sum_{s\in S'}s can be verified in polynomial time

2. 3-CNF-SAT p\leq_p Subset-Sum

  • Given 3-CNF formula ϕ\phi over variable x1,x2,,xnx_1,x_2,\dots,x_n with clauses C1,C2,,CkC_1,C_2,\dots,C_k
  • Assumption without loss of generality
  • Reduction algorithm
    • Input:
      • ϕ=C1C2C3C4\phi = C_1 \land C_2 \land C_3 \land C_4
      • C1=(x1¬x2¬x3)C_1=(x_1 \lor \lnot x_2 \lor \lnot x_3)
      • C2=(¬x1¬x2¬x3)C_2=(\lnot x_1 \lor \lnot x_2 \lor \lnot x_3)
      • C3=(¬x1¬x2x3)C_3=(\lnot x_1 \lor \lnot x_2 \lor x_3)
      • C4=(x1x2x3)C_4=(x_1 \lor x_2 \lor x_3)
    • Label each digit position
      • variable: the most significant nn digits
      • clause: the least signifiacant kk digits
    • viv_i and viv_i'
      • xix_i set to 1 if ii is same as viv_i
      • CiC_i set to 1 depending on variables in the clause
    • sjs_j and sjs_j'
      • For each clause CjC_j,
        For sjs_j, there is a 1 in the CjC_j digit and sjs_j' has a 2 in this digit (=slack variables)
        the ohter sjs_j has 0
    • Output:
      • S={1001001,1000110,,1000,,2}S=\{1001001, 1000110, \cdots, 1000, \cdots, 2\}
        Each row becomes SiS_i
      • t=1114444t=1114444
        A 1 in each variable-labeled digit and a 4 in each clause-labeled digit
    • 모든 ii 에 대하여 viv_iviv_i' 중 반드시 하나씩 선택
    • CiC_i 는 1개 이상만 선택되면 됨
  • 3-CNF-SAT \rightarrow Subset-Sum
    • Suppose that ϕ\phi has a satisfying assignment
      <x1=0,x2=0,x3=1><x_1=0, x_2=0, x_3=1>
    • If xi=1x_i=1, then include viv_i in SS'
    • If xi=0x_i=0, then include viv_i' in SS'
    • SS' includes {v1,v2,v3}\{v_1', v_2', v_3\}
    • True 가 되는 assignment 를 가진다면,
      CiC_ivi,viv_i,v_i' 는 둘 중 하나만 선택되어 ttxix_i digit,
      si,sis_i,s_i' 를 통해 ttCiC_i digit 을 만족 가능
  • Subset-Sum \rightarrow 3-CNF-SAT
    • Suppose that there is a subset SSS' \sube S that sums to tt
    • If viSv_i\in S', set xi=1x_i=1
    • If viSv_i'\in S', set xi=0x_i=0
    • Every clause CjC_j, for j=1,,kj=1,\dots, k is satisfied by this assignment
  • By the subset SS' (yellow) matches to the tt, every CjC_j set to 1

Partition

Partition Problem

  • Input: A finite set SS of numbers
  • Question: Can the numbers in SS be partitioned into two sets S1S_1 and S2=SS1S_2=S-S_1 such that Summation of S1S_1 and S2S_2 are equal
  • e.g.
    • S={1,2,7,10}S=\{1,2,7,10\}
    • S1={1,2,7},S2={10}S_1=\{1,2,7\},S_2=\{10\}

Partition Problem (NPC Proof)

1. Partition \in NP

  • For a set SS, let the subsets S1S_1 and S2=SS1S_2=S-S_1 be the certificate
  • Checking whether summation can be accomplished by a verficiation in polynomial time

2. Subset-Sum p\leq_p Partition

  • Reduction algorithm
    • Input: <S,t><S,t> of the subset-sum problem
    • S=S{2a,3a,4a+2t},a=(ΣxSx)S'=S \cup \{2a,3a,4a+2t\}, a=(\Sigma_{x \in S}x)
    • Output: <S>(ΣxS,x=10a+2t)<S'>(\Sigma_{x \in S},x=10a+2t)
  • If there is BB' that ΣxBx=t\Sigma_{x\in B'}x=t, make C=B{2a,3a}C'=B' \cup \{2a,3a\}
    • ΣxCx=t+2a+3a=5a+t\Sigma_{x\in C'}x=t + 2a+3a=5a+t
    • Σx(SC)x=10a+2tΣxCx=5a+t\Sigma_{x\in (S'-C')}x=10a+2t-\Sigma_{x \in C'}x=5a+t
    • Therefore, partition exists
  • Subset-Sum \rightarrow Partition
    • 만약 합이 tt 인 set ASA \sube S 가 존재한다면 A{2a,3a}A \cup \{2a,3a\} 로 partiton 가능
  • Partition \rightarrow Subset-Sum
    • 4a+2t4a+2t2a,3a2a, 3a 와 같은 집합이 될 수 없음
    • 4a+2t4a+2t 와 같이 partition 되는 집합의 합은 ata-t
      반대 set 은 2a+3a=5a2a+3a=5a \rightarrow 나머지 부분집합의 합이 tt 이어야함
    • 따라서 SS' 의 원소 중에서 합이 tt인 부분집합이 존재

0개의 댓글