MELJUN CORTES Automata Theory (Automata23)
Upcoming SlideShare
Loading in...5
×
 

MELJUN CORTES Automata Theory (Automata23)

on

  • 139 views

MELJUN CORTES Automata Theory (Automata23)

MELJUN CORTES Automata Theory (Automata23)

Statistics

Views

Total Views
139
Views on SlideShare
139
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

MELJUN CORTES Automata Theory (Automata23) MELJUN CORTES Automata Theory (Automata23) Presentation Transcript

  • MELJUN P. CORTES, MBA,MPA,BSCS,ACS Fall 2008 CSC 3130: Automata theory and formal languages NP-complete problems MELJUN CORTES
  • Polynomial-time reductions • Language L polynomial-time reduces to L’ if there exists a polynomial-time computable map R that takes an instance x of L into instance y of L’ s.t. x ∈ L if and only if y ∈ L’ L (IS) x (G, k) x∈L (G has IS of size k) L’ (CLIQUE) R y (G’, k’) y ∈ L’ (G’ has clique of size k’)
  • The Cook-Levin Theorem Every L ∈ NP reduces to SAT SAT = {f: f is a satisfiable Boolean formula} f = (x1∨x2 ) ∧ (x2 ∨x3 ∨x4) ∧ (x1) is satisfiable x1 = T x2 = F x3 = T x4 = T f = (x1∨x2 ) ∧ (x1) ∧ (x2) is not satisfiable
  • NP-hardness • Language L is NP-hard if every L’ in NP reduces to L • Intuitively, NP-hard means “harder than all of NP” • The Cook-Levin Theorem says SAT NP SAT is NP-hard P
  • NP-complete • L is NP-complete if L is NP-hard and L ∈ NP • Intuitively, NP-complete means “hardest in NP” • Recall that SAT ∈ NP, so SAT is NP-complete SAT If SAT ∈ P, then P = NP NP P
  • Proof of Cook-Levin Theorem Every L ∈ NP reduces to SAT • To prove it, we have to describe a reduction R: w w∈L R Boolean formula f f is satisfiable
  • Proof of Cook-Levin Theorem • All we know about L: It has a poly-time NTM M – Let’s look at computation tableau of M on input w M S w q0 w1 w2 S-th configuration symbol at time T Since M is nondeterministic, there may be many possible tableaus T qacc …
  • Proof of Cook-Levin Theorem S n = length of input w q0 w1 w2 height of tableau is p(n) for some polynomial p T u width is at most p(n) k possible tableau symbols xT, S, u = qacc true, if the (T, S) cell of tableau contains u false, if not … 1 ≤ S ≤ p(n) 1 ≤ T ≤ p(n) 1≤u≤k
  • Proof of Cook-Levin Theorem w w∈L R Boolean formula f f is satisfiable • We will design a formula f such that: variables of f : xT, S, u assignment to xT, S, u way to fill up the tableau satisfying assignment accepting computation tableau f is satisfiable M accepts w
  • Proof of Cook-Levin Theorem xT, S, u = true, if the (T, S) cell of tableau contains u false, if not 1 ≤ S ≤ p(n) 1 ≤ T ≤ p(n) 1≤u≤k • We want to construct (in time poly(n)) a formula f : f(x1, 1, 1, ..., xp(n), p(n), k) = true, if the xs represent a valid accepting tableau false, if not
  • Proof of Cook-Levin Theorem f = fcell ∧ f0 ∧ fmove ∧ facc fcell: f0: S q0 w1 w2 T “Every cell contains exactly one symbol” “The first row is q0w1w2...wk☐...☐” u qacc fmove: “The moves between rows follow the transitions of M” facc: “qacc appears somewhere in the last row” …
  • Proof of Cook-Levin Theorem • Desired meaning fcell: “Every cell contains exactly one symbol” or: “Exactly one of xS, T, 1 ∨ ... ∨ xS, T, k is true” • Implementation: fcell = fcell 1, 1 ∧ ... ∧ fcell p(n), p(n) fcell T, S = (xT, S, 1 ∨ ... ∨ xT, S, k) ∧ (xT, S, 1 ∨ xT, S, 2) ∧ (xT, S, 1 ∨ xT, S, 3) ∧ ... ∧ (xT, S, k-1 ∨ xT, S, k) where at least one symbol no two symbols
  • Proof of Cook-Levin Theorem • Desired meaning f0: “The first row is q0w1w2...wk☐...☐” facc: “qacc appears somewhere in the last row” • Implementation: f0 = x1, 1, q0 ∧ x1, 1, w1 ∧ x1, 1, w2 ∧ ... ∧ x1, p(n),☐ facc = xp(n), 1, qacc ∨ xp(n), 2, qacc ∨ ... ∨ xp(n), p(n), qacc
  • Valid and invalid windows … 6t3t0u0 … … 0t6t0u0 …0 … 6q3t0u0 … … 0k6t0q0 …0 valid window invalid window … 6t3q3u0 … … 0t6a0q7 …0 … 6c3a0t0 … … 0c6a0p0 …0 valid if δ(q3, u) = (q7, a, R) invalid window … 6t3t0u0 … … 0t6t0q3 …0 … 6c3a0t0 … … 0b6a0t0 …0 valid window valid window
  • Proof of Cook-Levin Theorem • Desired meaning fmove: “The moves between rows follow transitions of M” q0 a a b b q3 a b b c q7 b fmove 2, 2 • Implementation: fmove = fmove 1, 1 ∧ ... ∧ fmove p(n)-3, p(n)-3 ∨ qacc (xT, S, a1 ∧ xT, S+1, a2 ∧ xT, S+2, a3 over all valid windows ∧ xT+1, S, a4 ∧ xT+1, S+1, a5 ∧ xT+2, S+1, a6) fmove T, S = a1 a2 a3 a4 a5 a6 …
  • Other NP-complete problems CLIQUE = {(G, k): G is a graph with a clique of k vertices} IS = {(G, k): G is a graph with an independent set of k vertices} VC = {(G, k): G is a graph with a vertex cover of k vertices} CLIQUE, IS and VC are NP-complete SAT NP CLIQUE IS VC
  • Proving NP-hardness • To show L is NP-hard, it is enough to reduce from some L’ we already know is NP-hard – For now we can take L’ = SAT • To show L is NP-complete, we also need to argue that L is in NP – This is usually the easy part roadmap: CLIQUE VC IS 3SAT SAT
  • 3SAT SAT = {f: f is a satisfiable Boolean formula} 3SAT = {f: f is a satisfiable Boolean formula in conjunctive normal form with at most 3 distinct literals per clause} literal: xi or xi CNF: AND of ORs of literals (conjunctive normal form) 3CNF: CNF with ≤3 lit/clause (x2∨(x1∧x2 ))∧(x1∧(x1∨x2 )) gates (x1∨x2 ) ∧ (x2 ∨x3 ∨x4) ∧ (x1) literals clause
  • NP-hardness of 3SAT • Theorem 3SAT is NP-hard • Proof: We describe a reduction R from SAT Boolean formula f f is satisfiable R 3CNF formula f’ f’ is satisfiable
  • Reducing SAT to 3SAT • Example: f = (x2∨(x1∧x2 ))∧(x1∧(x1∨x2 )) x4 x5 x7 x10 AND x8 x9 OR NOT x6 x7 AND AND x3 NOT x2 x1 x2 x4 x5 NOT T T T T F F F F T T F F T T F F T F T F T F T F x7 = x4 ∧ x5 T F F T F T F T OR x1 x1 x2 We give extra variables to every gate (“wire”) (x4∨x5∨x7) ∧(x4∨x5∨x7) ∧(x4∨x5∨x7) ∧(x4∨x5∨x7) (x4∨x5∨x7) (x4∨x5∨x7) (x4∨x5∨x7) (x4∨x5∨x7)
  • Reducing SAT to 3SAT Boolean formula f R 3CNF formula f’ • Step 1: Add variable xn+j for each gate Gj in f • Step 2: Write 3CNF fj for each gate Gj, j = {1, ..., t} • Step 3: Output f’ = fn+1 ∧ fn+2 ∧ ... ∧ ft ∧ xn+t requires that output of f is true
  • Reducing SAT to 3SAT Boolean formula f f is satisfiable R 3CNF formula f’ f’ is satisfiable • Every satisfying assignment of f extends uniquely to a satisfying assignment of f’ • Conversely, every satisfying assignment of f’ must contain a satisfying assignment of f
  • Independent set IS = {(G, k): G is a graph with an independent set of k vertices} • Theorem IS is NP-hard 1 3 2 4 An independent set is a subset of vertices so that no pair is connected {1, 2}, {1, 3}, {4} are independent sets CLIQUE VC IS 3SAT ✓ SAT
  • Reducing 3SAT to IS • Proof: We describe a reduction from 3SAT to IS 3SAT = {f: f is a satisfiable Boolean formula in 3CNF} IS = {(G, k): G is a graph with an independent set of k vertices} 3CNF formula f f is satisfiable R (G, k) G has an independent set of size k
  • Reducing 3SAT to IS • Example: f = (x1∨x2 ) ∧ (x2 ∨x3 ∨x4) ∧ (x1) x2x3x4 x1x2 TT TF FT FF TTT TTF TFT TFF FTT FTF FFT FFF all interconnected x1 T etc. F Put an edge for every inconsistency
  • Reducing 3SAT to IS • Example: f = (x1∨x2 ) ∧ (x2 ∨x3 ∨x4) ∧ (x1) x2x3x4 x1x2 TT TF FF satisfying assignment of f TTT TTF TFT TFF FTT FFT FFF x1 T G edges = inconsistencies IS of size 3 in G x1 = T x2 = F x3 = T x4 = T any IS of size 3 in G satisfying assignment of f
  • Reducing 3SAT to IS 3CNF formula f R (G, k) • G has a vertex for every clause Ci of f and every satisfying assignment of Ci • G has an edge between any two vertices that represent inconsistent assignments • k is the number of clauses in f
  • Reducing 3SAT to IS 3CNF formula f f is satisfiable R (G, k) G has an IS of size k • Every satisfying assignment of f gives an independent set of size k in G • Conversely, from every IS of size k in G we can “extract” a consistent and satisfying assignment of f
  • Vertex cover VC = {(G, k): G is a graph with a vertex cover of size k} • Theorem VC is NP-hard CLIQUE VC 1 3 2 4 A vertex cover is a set of vertices that touches (covers) all edges {2, 4}, {3, 4}, {1, 2, 3} are vertex covers ✓ IS ✓ 3SAT ✓ SAT
  • Reducing IS to VC • Proof: We describe a reduction from IS to VC (G, k) (G’, k’) R G has an IS of size k G’ has a VC of size k’ • Example 1 2 3 4 independent sets ∅, {1}, {2}, {3}, {4}, {1, 3}, {2, 3} vertex covers {2, 4}, {3, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}, {1, 2, 3, 4}
  • Reducing IS to VC • Claim S is an independent set of G if and only if S is a vertex cover of G • Proof S is an independent set of G no edge has both endpoints in S every edge has an endpoint in S S is a vertex cover of G
  • Reducing IS to VC (G, k) R (G’, k’) • Set G’ = G, k’ = n – k (n = number of vertices) G has an IS of size k by previous Claim. G’ has a VC of size k’
  • The ubiquity of NP-complete problems • We saw a few examples of NP-complete problems, but there are many more • A surprising fact of life is that most CS problems are either in P or NP-complete • A 1979 book by Garey and Johnson lists 100+ NP-complete problems