NP-Completeness (1)

Southgiri·2025년 6월 19일

SNUON Algorithm

목록 보기
3/7

Polynomial time algorithms

  • Inputs of size nn, worst case time is O(nk)O(n^k) for some constant kk
  • All problems cannot be solved in polynomial time

NP-Complete problem

NP-Complete problems

  • Status is unknown
  • No polynomial time algorithm has yet been discovered
    nor has anyone yet been able to prove that no polynomial time algorithm can exist for any one of them

Class P

  • Problems that are solvable in polynomial time O(nk)O(n^k) for some constant kk

Class NP

  • Problems that are verifiable in polynomial time
  • Verifiable?
    • If we were somehow given a certificate of a solution,
      then we could verify that the certificate is correct in polynomial time

Example

  • Hamiltonian cycle
    • Hamiltonian cycle of an undirected graph G=(V,E)G=(V,E) is a simple cycle that contains every vertex in VV
    • Does GG have a Hamiltonian cycle?
    • Certificate is a sequence <v1,v2,,vV><v_1, v_2, \dots, v_{|V|}> of V|V| vertices
    • We could check in polynomial time that (Vi,Vi+1)E(V_i, V_{i+1})\in E for i=1,2,,Vi=1,2,\dots,|V| and (VV,V1)E(V_{|V|}, V_1) \in E

Class P vs Class NP

  • P \sube NP
  • The open question is whether or not P is a proper subset of NP. P=NP?

Class NPC

  • A problem is in NP and is as hard as any problem in NP
  • If any NP-complete problem can be solved in polynomial time,
    then every problem in NP has a polynomial time algorithm
  • When we demonstrate that a problem is NP-complete,
    we are making a statement about how hard it is

How to solve a problem

  • Usually can cast a given optimization problem as a related decision problem by imposing a bound on the value to be optimized
  • What is the shortest path length from uu to vv?
    \Rightarrow Is there a path from uu to vv with length k\leq k?
  • Decision problem is in a sense easier or at least no harder than the optimization problem

Reduction

Reduction

  • Let a decision problem A,BA,B
  • Suppose that we have a procedure that transforms any instance α\alpha of AA into some instance β\beta of BB such that
    • The transformation takes polynomial time
    • The answer for α\alpha is same as the answer for β\beta
  • We call such a procedure a polynomial time reduction algorithm
  • If such a reduction algorithm exist,
    we say AA is reducible to BB and denote it by ApBA\leq_pB

Reduction Algorithm

  • Given an instance α\alpha of AA, use a polynomial time reduction algorithm to transform it to an instance β\beta of BB
  • Run the polynomial-time decision algorithm for BB on β\beta
  • Use the answer for β\beta as the answer for α\alpha
  • If there is no polynomial time algorithm can exist for AA,
    and A polynomial time reduction algorithm exist for transforming instances of AA to instances of BB,
    No Polynomial time algorithm can exist for BB

Reducibility

  • A problem QQ can be reduced to another problem QQ'
    if any instance of QQ can be easily rephrased as an instance of QQ',
    the solution to which provides a solution to the instance of QQ

Example

  • Solving linear equations in an indeterminate xx reduces to the problem of solving quadratic equations
  • Given an instance ax+b=0ax+b=0, we transform it to 0x2+ax+b=00x^2+ax+b=0, whose solution provides a solution to ax+b=0ax+b=0
  • Thus if a problem QQ reduces to another problem QQ',
    then QQ is no harder to solve than QQ'

Definition

A problem AA is NP-Hard

  • If we can solve this problem in polynomial time,
    we can solve all NP problems in polynomial time
    (ApAA'\leq_pA all ANPA' \in NP)

A problem AA is NP-Complete

  • It is in NP
  • It is NP-Hard
    • ApAA'\leq_pA all ANPA' \in NP
    • Alternatively, ApAA'\leq_pA for some known NP-Complete problem AA'
  • If any one is solvable in polynomial time, then they all are
  • Conversely, if any one is not solvable in polynomial time, then none are
  • Once there is any one problem that is proved NP-complete, we can use polynomial time reducibility as a tool to prove other problems to be NP-complete

Example

Circuit-SAT Problem

Circuit-SAT Problem

  • What is the input that makes a true output?

Lemma

  • Circuit satisfiability problem belongs to the class NP, NP-Hard
    \Rightarrow Circuit-SAT problem is NP-Complete

SAT Problem

  • Input: A boolean formula
  • Question: Is there some way to assign truth value to the variables so that the formula evaluates to true?

Lemma

  • SAT problem is NP-Complete

Cook's Theorem

  • SAT is NP-Complete
    • Circuit-SAT p\leq_p SAT

3-CNF-SAT Problem

  • Input: A boolean formula in 3-conjunctive normal form
  • Question: Operations in clause are OR,
    operations outside the clause are AND.

CLIQUE

Clique

  • A clique in an undirected graph G=(V,E)G=(V,E) is a subset VVV' \sube V of vertices,
    each pair of which is connected by an edge in EE
  • A clique is a complete subgraph of GG

Optimization problem

  • Input: An undirected graph G=(V,E)G=(V,E)
  • Question: Find a clique of maximum size in a graph

Decision problem

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

Naive algorithm

  • Check whether a sub-graph of size kk forms a clique
    • Running time is Ω(k2×(Vk))\Omega(k^2 \times \begin{pmatrix} |V| \\ k \end{pmatrix}) which is polynomial if kk is a constant
    • In general, however, kk could be near V/2,|V|/2, \Rightarrow superpolynomial

CLIQUE (NPC proof)

1. Problem is NP

  • Clique \in NP for a given graph G=(V,E)G=(V,E)
    • Use the set VVV' \sube V of vertices in the clique as a certificate of GG
    • Checking whether VV' is a clique can be accomplished in polynomial time
      by checking whether for each pair u,vVu,v \in V', the edge (u,v)(u,v) belong to EE

2. Problem is NP-Hard

  • 3-CNF-SAT p\leq_p CLIQUE (CLIQUE is NP-Hard)
    1. The reduction algorithm begins with an instance of 3-CNF-SAT
    • Logical formula \rightarrow Graph
    • 모든 vertex 연결
      • 자기 자신의 not 인 경우 X
      • 같은 괄호 안의 vertex 끼리 X
      • kk = 3 (괄호의 개수)
    1. Show that this transformation of ϕ\phi into GG is a reduction
    • For each clause Cr=(l1rl2rl3r) in ϕC_r=(l_1^r \lor l_2^r \lor l_3^r) \text{ in } \phi,
      replace a triple of vertices v1r,v2r,v3rv_1^r,v_2^r,v_3^r into VV
    • 3-CNF-SAT \rightarrow CLIQUE
      • Output이 true 이려면 clause 마다 literal 하나씩은 true 이어야함
      • 자신의 not 과는 edge 를 생성하지 않았기 때문에 3-clique 생성됨
    • CLIQUE \rightarrow 3-CNF-SAT
      • 3-clique이 있다는 것은 clause 마다 반드시 하나씩 선택됨
      • 선택된 edge는 vertex와 그의 not 이 존재할 수 없기 때문에 3-CNF-SAT 도 true

0개의 댓글