powerpoint presentationlblum/flac/lectures_pdf/lecture18.pdf · powerpoint presentation author: von...

41
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453

Upload: others

Post on 16-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

15-453

Page 2: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

NP-COMPLETENESS II Tuesday April 1

Page 3: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

There are googols of NP-complete languages

Page 4: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

K-CLIQUE

b

a

e

c

d f

g

k-clique = complete subgraph of k nodes

Page 5: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

K-CLIQUE

b

a

e

c

d f

g

k-clique = complete subgraph of k nodes

Page 6: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

CLIQUE = { (G,k) | G is an undirected graph with a k-clique }

Theorem: CLIQUE is NP-Complete

(1) CLIQUE ∈ NP

(2) 3SAT ≤P CLIQUE

Assume a reasonable encoding of graphs (example: the adjacency matrix is reasonable)

Page 7: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

P NP

CLIQUE

3SAT

CLIQUE is NP-Complete

Page 8: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

P NP

CLIQUE

3SAT

CLIQUE is NP-Complete

Page 9: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

3SAT ≤P CLIQUE We transform a 3-cnf formula φ into (G,k) such that

φ ∈ 3SAT ⇔ (G,k) ∈ CLIQUE

The transformation can be done in time that is polynomial in the length of φ

Page 10: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x2) ∧ (¬x1 ∨ ¬x2 ∨ ¬x2) ∧ (¬x1 ∨ x2 ∨ x2)

x1 ¬x1

x1 x2

¬x2 ¬x2

x2 x2

¬x1

k = #clauses

clause

#nodes = 3(# clauses)

Page 11: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x2) ∧ (¬x1 ∨ ¬x2 ∨ ¬x2) ∧ (¬x1 ∨ x2 ∨ x2)

x1 ¬x1

x1 x2

¬x2 ¬x2

x2 x2

¬x1

k = #clauses

clause

#nodes = 3(# clauses)

Page 12: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x2) ∧ (¬x1 ∨ ¬x2 ∨ ¬x2) ∧ (¬x1 ∨ x2 ∨ x2)

x1 ¬x1

x1 x2

¬x2 ¬x2

x2 x2

¬x1

k = #clauses

clause

#nodes = 3(# clauses)

Page 13: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x2) ∧ (¬x1 ∨ ¬x2 ∨ ¬x2) ∧ (¬x1 ∨ x2 ∨ x2)

x1 ¬x1

x1 x2

¬x2 ¬x2

x2 x2

¬x1

k = #clauses

clause

#nodes = 3(# clauses)

Page 14: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x2) ∧ (¬x1 ∨ ¬x2 ∨ ¬x2) ∧ (¬x1 ∨ x2 ∨ x2)

x1 ¬x1

x1 x2

¬x2 ¬x2

x2 x2

¬x1

k = #clauses

clause

#nodes = 3(# clauses)

Page 15: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x2) ∧ (¬x1 ∨ ¬x2 ∨ ¬x2) ∧ (¬x1 ∨ x2 ∨ x2)

x1 ¬x1

x1 x2

¬x2 ¬x2

x2 x2

¬x1

k = #clauses

clause

#nodes = 3(# clauses)

Page 16: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

3SAT ≤P CLIQUE We transform a 3-cnf formula φ into (G,k) such that

φ ∈ 3SAT ⇔ (G,k) ∈ CLIQUE • If φ has m clauses, we create a graph with m

clusters of 3 nodes each, and set k=m • Each cluster corresponds to a clause. • Each node in a cluster is labeled with a literal from

the clause.

• We do not connect any nodes in the same cluster • We connect nodes in different clusters whenever they

are not contradictory

The transformation can be done in time that is polynomial in the length of φ

Page 17: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x1) ∧ (¬x1 ∨ ¬x1 ∨ x2) ∧ (x2 ∨ x2 ∨ x2) ∧ (¬x2 ∨ ¬x2 ∨ x1)

x1

x1

x2

x2

¬x1 ¬x1

¬x2 ¬x2

x1 x2

x2

x1

Page 18: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x1) ∧ (¬x1 ∨ ¬x1 ∨ x2) ∧ (x2 ∨ x2 ∨ x2) ∧ (¬x2 ∨ ¬x2 ∨ x1)

x1

x1

x2

x2

¬x1 ¬x1

¬x2 ¬x2

x1 x2

x2

x1

Page 19: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

VERTEX COVER

b

a

e

c

d

b

a

e

c

d

vertex cover = set of nodes that cover all edges

Page 20: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

VERTEX COVER

b

a

e

c

d

b

a

e

c

d

vertex cover = set of nodes that cover all edges

Page 21: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

VERTEX-COVER = { (G,k) | G is an undirected graph with a k-node vertex cover }

Theorem: VERTEX-COVER is NP-Complete (1) VERTEX-COVER ∈ NP

(2) 3SAT ≤P VERTEX-COVER

Page 22: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

3SAT ≤P VERTEX-COVER We transform a 3-cnf formula φ into (G,k) such that

φ ∈ 3SAT ⇔ (G,k) ∈ VERTEX-COVER

The transformation can be done in time polynomial in the length of φ

Page 23: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x2) ∧ (¬x1 ∨ ¬x2 ∨ ¬x2) ∧ (¬x1 ∨ x2 ∨ x2)

x1

x1 x2

¬x1

x2 x2 ¬x2 ¬x2

¬x1

x1 ¬x1 x2 ¬x2

Variables and negations of variables

clauses

#nodes = 2(#variables) + 3(#clauses)

Page 24: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x2) ∧ (¬x1 ∨ ¬x2 ∨ ¬x2) ∧ (¬x1 ∨ x2 ∨ x2)

x1

x1 x2

¬x1

x2 x2 ¬x2 ¬x2

¬x1

x1 ¬x1 x2 ¬x2

Variables and negations of variables

clauses

#nodes = 2(#variables) + 3(#clauses)

Page 25: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x2) ∧ (¬x1 ∨ ¬x2 ∨ ¬x2) ∧ (¬x1 ∨ x2 ∨ x2)

x1

x1 x2

¬x1

x2 x2 ¬x2 ¬x2

¬x1

x1 ¬x1 x2 ¬x2

Variables and negations of variables

clauses

#nodes = 2(#variables) + 3(#clauses)

Page 26: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x2) ∧ (¬x1 ∨ ¬x2 ∨ ¬x2) ∧ (¬x1 ∨ x2 ∨ x2)

x1

x1 x2

¬x1

x2 x2 ¬x2 ¬x2

¬x1

x1 ¬x1 x2 ¬x2

k = 2(#clauses) + (#variables)

Variables and negations of variables

clauses

Page 27: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x2) ∧ (¬x1 ∨ ¬x2 ∨ ¬x2) ∧ (¬x1 ∨ x2 ∨ x2)

x1

x1 x2

¬x1

x2 x2 ¬x2 ¬x2

¬x1

x1 ¬x1 x2 ¬x2

Variables and negations of variables

clauses

φ satisfiable then put “true” literals on top in vertex cover For each clause, pick a true literal and put other 2 in vertex cover

Page 28: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x2) ∧ (¬x1 ∨ ¬x2 ∨ ¬x2) ∧ (¬x1 ∨ x2 ∨ x2)

x1

x1 x2

¬x1

x2 x2 ¬x2 ¬x2

¬x1

x1 ¬x1 x2 ¬x2

Variables and negations of variables

clauses

φ satisfiable then put “true” literals on top in vertex cover For each clause, pick a true literal and put other 2 in vertex cover

Page 29: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

(x1 ∨ x1 ∨ x1) ∧ (¬x1 ∨ ¬x1 ∨ x2) ∧ (x2 ∨ x2 ∨ x2) ∧ (¬x2 ∨ ¬x2 ∨ x1)

Page 30: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

HAMILTON PATH

s t

Page 31: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

HAMILTON PATH

s t

Page 32: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

HAMPATH = { (G,s,t) | G is an directed graph with a Hamilton path from s to t}

Theorem: HAMPATH is NP-Complete (1) HAMPATH ∈ NP

(2) 3SAT ≤P HAMPATH Proof is in Sipser, Chapter 7.5

Page 33: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM
Page 34: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM
Page 35: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

Case: a2 separator node Only edges entering a2 would be a1 and a3

Case: a3 separator node. Then a1, a2 in same clause pair Only edges entering a2 would be a1, a3, c

If hamiltonian path were not normal:

Page 36: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

UHAMPATH = { (G,s,t) | G is an undirected graph with a Hamilton path from s to t}

Theorem: UHAMPATH is NP-Complete (1) UHAMPATH ∈ NP

(2) HAMPATH ≤P UHAMPATH

Page 37: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM
Page 38: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

SUBSETSUM = { (S, t) | S is multiset of integers and for some Y ⊆ S, we have ∑y∈ Y y = t }

Theorem: SUBSETSUM is NP-Complete (1) SUBSETSUM ∈ NP

(2) 3SAT ≤P SUBSETSUM

Page 39: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM
Page 40: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

HW

Let G denote a graph, and s and t denote nodes. SHORTEST PATH = {(G, s, t, k) | G has a simple path of length < k from s to t } LONGEST PATH = {(G, s, t, k) | G has a simple path of length > k from s to t } WHICH IS EASY? WHICH IS HARD? Justify

Page 41: PowerPoint Presentationlblum/flac/Lectures_pdf/Lecture18.pdf · PowerPoint Presentation Author: von Ahn and Williams Created Date: 4/4/2014 8:02:53 PM

WWW.FLAC.WS