Complexity of Counting Lecture 20 #P 1 FP 2 FP Turing Machines - - PowerPoint PPT Presentation

complexity of counting
SMART_READER_LITE
LIVE PREVIEW

Complexity of Counting Lecture 20 #P 1 FP 2 FP Turing Machines - - PowerPoint PPT Presentation

Complexity of Counting Lecture 20 #P 1 FP 2 FP Turing Machines computing a (not necessarily Boolean) function of the input 2 FP Turing Machines computing a (not necessarily Boolean) function of the input Writes the output on an output


slide-1
SLIDE 1

Complexity of Counting

Lecture 20 #P

1

slide-2
SLIDE 2

FP

2

slide-3
SLIDE 3

FP

Turing Machines computing a (not necessarily Boolean) function of the input

2

slide-4
SLIDE 4

FP

Turing Machines computing a (not necessarily Boolean) function of the input Writes the output on an output tape

2

slide-5
SLIDE 5

FP

Turing Machines computing a (not necessarily Boolean) function of the input Writes the output on an output tape FP: class of efficiently computable functions

2

slide-6
SLIDE 6

FP

Turing Machines computing a (not necessarily Boolean) function of the input Writes the output on an output tape FP: class of efficiently computable functions Computed by a TM running in polynomial time

2

slide-7
SLIDE 7

Counting Problems

3

slide-8
SLIDE 8

Counting Problems

Counting: Functions of the form “number of witnesses”

3

slide-9
SLIDE 9

Counting Problems

Counting: Functions of the form “number of witnesses” #R(x) = |{w: R(x,w)=1}|

3

slide-10
SLIDE 10

Counting Problems

Counting: Functions of the form “number of witnesses” #R(x) = |{w: R(x,w)=1}| e.g: Number of subgraphs of a given graph with some property (trees, cycles, spanning trees, cycle covers, etc.)

3

slide-11
SLIDE 11

Counting Problems

Counting: Functions of the form “number of witnesses” #R(x) = |{w: R(x,w)=1}| e.g: Number of subgraphs of a given graph with some property (trees, cycles, spanning trees, cycle covers, etc.) e.g.: Number of satisfying assignments to a boolean formula

3

slide-12
SLIDE 12

Counting Problems

Counting: Functions of the form “number of witnesses” #R(x) = |{w: R(x,w)=1}| e.g: Number of subgraphs of a given graph with some property (trees, cycles, spanning trees, cycle covers, etc.) e.g.: Number of satisfying assignments to a boolean formula e.g.: Number of inputs less than x (lexicographically) that are in a language L

3

slide-13
SLIDE 13

#P

4

slide-14
SLIDE 14

#P

Class of functions of the form number of witnesses for an NP language

4

slide-15
SLIDE 15

#P

Class of functions of the form number of witnesses for an NP language #R(x) = |{w: R(x,w)=1}|, where R is a polynomial time relation

4

slide-16
SLIDE 16

#P

Class of functions of the form number of witnesses for an NP language #R(x) = |{w: R(x,w)=1}|, where R is a polynomial time relation e.g.: #SPANTREE(G) = number of spanning trees in a graph G

4

slide-17
SLIDE 17

#P

Class of functions of the form number of witnesses for an NP language #R(x) = |{w: R(x,w)=1}|, where R is a polynomial time relation e.g.: #SPANTREE(G) = number of spanning trees in a graph G e.g.: #CYCLE(G) = number of simple cycles in a directed graph G

4

slide-18
SLIDE 18

#P

Class of functions of the form number of witnesses for an NP language #R(x) = |{w: R(x,w)=1}|, where R is a polynomial time relation e.g.: #SPANTREE(G) = number of spanning trees in a graph G e.g.: #CYCLE(G) = number of simple cycles in a directed graph G e.g.: #SAT(φ) = number of satisfying assignments of φ

4

slide-19
SLIDE 19

#P

Class of functions of the form number of witnesses for an NP language #R(x) = |{w: R(x,w)=1}|, where R is a polynomial time relation e.g.: #SPANTREE(G) = number of spanning trees in a graph G e.g.: #CYCLE(G) = number of simple cycles in a directed graph G e.g.: #SAT(φ) = number of satisfying assignments of φ Easy to see: FP ⊆ #P [Exercise]

4

slide-20
SLIDE 20

#P vs. NP

5

slide-21
SLIDE 21

#P vs. NP

#R(x) = |{w: R(x,w)=1}|, were R is a polynomial time relation

5

slide-22
SLIDE 22

#P vs. NP

#R(x) = |{w: R(x,w)=1}|, were R is a polynomial time relation To compute a function in #P: compute #R(x)

5

slide-23
SLIDE 23

#P vs. NP

#R(x) = |{w: R(x,w)=1}|, were R is a polynomial time relation To compute a function in #P: compute #R(x) To decide a language in NP: check if #R(x) > 0

5

slide-24
SLIDE 24

#P vs. NP

#R(x) = |{w: R(x,w)=1}|, were R is a polynomial time relation To compute a function in #P: compute #R(x) To decide a language in NP: check if #R(x) > 0 #P “harder” than NP

5

slide-25
SLIDE 25

#P vs. NP

#R(x) = |{w: R(x,w)=1}|, were R is a polynomial time relation To compute a function in #P: compute #R(x) To decide a language in NP: check if #R(x) > 0 #P “harder” than NP If #P = FP, then P = NP

5

slide-26
SLIDE 26

#P vs. NP

#R(x) = |{w: R(x,w)=1}|, were R is a polynomial time relation To compute a function in #P: compute #R(x) To decide a language in NP: check if #R(x) > 0 #P “harder” than NP If #P = FP, then P = NP How much harder?

5

slide-27
SLIDE 27

How hard is it to count?

6

slide-28
SLIDE 28

How hard is it to count?

Not hard for some problems

6

slide-29
SLIDE 29

How hard is it to count?

Not hard for some problems e.g.: #SPANTREE(G) = number of spanning trees in a graph G

6

slide-30
SLIDE 30

How hard is it to count?

Not hard for some problems e.g.: #SPANTREE(G) = number of spanning trees in a graph G Kirchhoff's theorem: evaluating a simple determinant gives the answer

6

slide-31
SLIDE 31

How hard is it to count?

Not hard for some problems e.g.: #SPANTREE(G) = number of spanning trees in a graph G Kirchhoff's theorem: evaluating a simple determinant gives the answer Hard for counting witnesses of NP-complete languages: e.g. #SAT (unless P=NP)

6

slide-32
SLIDE 32

How hard is it to count?

Not hard for some problems e.g.: #SPANTREE(G) = number of spanning trees in a graph G Kirchhoff's theorem: evaluating a simple determinant gives the answer Hard for counting witnesses of NP-complete languages: e.g. #SAT (unless P=NP) Hard for some other problems too

6

slide-33
SLIDE 33

How hard is it to count?

Not hard for some problems e.g.: #SPANTREE(G) = number of spanning trees in a graph G Kirchhoff's theorem: evaluating a simple determinant gives the answer Hard for counting witnesses of NP-complete languages: e.g. #SAT (unless P=NP) Hard for some other problems too If #CYCLE ∈ FP, then P=NP

6

slide-34
SLIDE 34

#CYCLE ∈ FP ⇒ P=NP

7

slide-35
SLIDE 35

#CYCLE ∈ FP ⇒ P=NP

Reduce HAMILTONICITY to #CYCLE: Given G, to construct G’ such that #CYCLE(G’) is “large” iff G has a Hamiltonian cycle

7

slide-36
SLIDE 36

#CYCLE ∈ FP ⇒ P=NP

Reduce HAMILTONICITY to #CYCLE: Given G, to construct G’ such that #CYCLE(G’) is “large” iff G has a Hamiltonian cycle Replace each edge in G by a gadget such that each cycle in G becomes “many” cycles in G’

7

slide-37
SLIDE 37

#CYCLE ∈ FP ⇒ P=NP

Reduce HAMILTONICITY to #CYCLE: Given G, to construct G’ such that #CYCLE(G’) is “large” iff G has a Hamiltonian cycle Replace each edge in G by a gadget such that each cycle in G becomes “many” cycles in G’ Longer the cycle in G, more the cycles in G’ it results in

7

slide-38
SLIDE 38

#CYCLE ∈ FP ⇒ P=NP

Reduce HAMILTONICITY to #CYCLE: Given G, to construct G’ such that #CYCLE(G’) is “large” iff G has a Hamiltonian cycle Replace each edge in G by a gadget such that each cycle in G becomes “many” cycles in G’ Longer the cycle in G, more the cycles in G’ it results in A single n-long cycle in G will result in more cycles in G’ than produced by all shorter cycles in G put together

7

slide-39
SLIDE 39

#CYCLE ∈ FP ⇒ P=NP

Reduce HAMILTONICITY to #CYCLE: Given G, to construct G’ such that #CYCLE(G’) is “large” iff G has a Hamiltonian cycle Replace each edge in G by a gadget such that each cycle in G becomes “many” cycles in G’ Longer the cycle in G, more the cycles in G’ it results in A single n-long cycle in G will result in more cycles in G’ than produced by all shorter cycles in G put together At most nn-1 shorter cycles in G

7

slide-40
SLIDE 40

#CYCLE ∈ FP ⇒ P=NP

Reduce HAMILTONICITY to #CYCLE: Given G, to construct G’ such that #CYCLE(G’) is “large” iff G has a Hamiltonian cycle Replace each edge in G by a gadget such that each cycle in G becomes “many” cycles in G’ Longer the cycle in G, more the cycles in G’ it results in A single n-long cycle in G will result in more cycles in G’ than produced by all shorter cycles in G put together At most nn-1 shorter cycles in G t-long cycle in G → (2m)t = nnt cycles in G’ (m := n log n)

7

slide-41
SLIDE 41

#CYCLE ∈ FP ⇒ P=NP

Reduce HAMILTONICITY to #CYCLE: Given G, to construct G’ such that #CYCLE(G’) is “large” iff G has a Hamiltonian cycle Replace each edge in G by a gadget such that each cycle in G becomes “many” cycles in G’ Longer the cycle in G, more the cycles in G’ it results in A single n-long cycle in G will result in more cycles in G’ than produced by all shorter cycles in G put together At most nn-1 shorter cycles in G t-long cycle in G → (2m)t = nnt cycles in G’ (m := n log n) HAMILTONICITY(G) ⇔ #CYCLES(G) ≥ nn^2

7

slide-42
SLIDE 42

#P vs. PP

8

slide-43
SLIDE 43

#P vs. PP

Recall PP: x in L if for at least half the strings w (of some length) we have R(x,w)=1

8

slide-44
SLIDE 44

#P vs. PP

Recall PP: x in L if for at least half the strings w (of some length) we have R(x,w)=1 i.e., checking the most significant bits of #R

8

slide-45
SLIDE 45

#P vs. PP

Recall PP: x in L if for at least half the strings w (of some length) we have R(x,w)=1 i.e., checking the most significant bits of #R Recall: We already saw NP ⊆ PP

8

slide-46
SLIDE 46

#P vs. PP

Recall PP: x in L if for at least half the strings w (of some length) we have R(x,w)=1 i.e., checking the most significant bits of #R Recall: We already saw NP ⊆ PP PP as powerful as #P (and vice versa)

8

slide-47
SLIDE 47

#P vs. PP

Recall PP: x in L if for at least half the strings w (of some length) we have R(x,w)=1 i.e., checking the most significant bits of #R Recall: We already saw NP ⊆ PP PP as powerful as #P (and vice versa) #P ⊆ FPPP [exercise] (and PP ⊆ P#P [why?])

8

slide-48
SLIDE 48

#P vs. PP

Recall PP: x in L if for at least half the strings w (of some length) we have R(x,w)=1 i.e., checking the most significant bits of #R Recall: We already saw NP ⊆ PP PP as powerful as #P (and vice versa) #P ⊆ FPPP [exercise] (and PP ⊆ P#P [why?]) So if PP = P, then #P = FP (and vice versa)

8

slide-49
SLIDE 49

#P completeness

9

slide-50
SLIDE 50

#P completeness

f ∈ #P is #P-complete if any g ∈ #P can be Cook-reduced to f

9

slide-51
SLIDE 51

#P completeness

f ∈ #P is #P-complete if any g ∈ #P can be Cook-reduced to f

Allows multiple

  • racle calls.

Alternately, allow

  • nly one call

9

slide-52
SLIDE 52

#P completeness

f ∈ #P is #P-complete if any g ∈ #P can be Cook-reduced to f From parsimonious reduction of g’ s NP problem to an NP-complete problem (w.r.t Karp-reductions)

Allows multiple

  • racle calls.

Alternately, allow

  • nly one call

9

slide-53
SLIDE 53

#P completeness

f ∈ #P is #P-complete if any g ∈ #P can be Cook-reduced to f From parsimonious reduction of g’ s NP problem to an NP-complete problem (w.r.t Karp-reductions) #SAT is #P-complete

Allows multiple

  • racle calls.

Alternately, allow

  • nly one call

9

slide-54
SLIDE 54

#P completeness

f ∈ #P is #P-complete if any g ∈ #P can be Cook-reduced to f From parsimonious reduction of g’ s NP problem to an NP-complete problem (w.r.t Karp-reductions) #SAT is #P-complete Other #P-complete problems whose decision problems are in P

Allows multiple

  • racle calls.

Alternately, allow

  • nly one call

9

slide-55
SLIDE 55

#P completeness

f ∈ #P is #P-complete if any g ∈ #P can be Cook-reduced to f From parsimonious reduction of g’ s NP problem to an NP-complete problem (w.r.t Karp-reductions) #SAT is #P-complete Other #P-complete problems whose decision problems are in P Permanent (for binary matrices) is #P-complete

Allows multiple

  • racle calls.

Alternately, allow

  • nly one call

9

slide-56
SLIDE 56

Permanent

10

slide-57
SLIDE 57

Permanent

Permanent of a square matrix A

10

slide-58
SLIDE 58

Permanent

Permanent of a square matrix A If A is binary (0,1 entries): perm(A) = number of perfect matchings in a bipartite graph BA whose adjacency matrix is A

10

slide-59
SLIDE 59

Permanent

Permanent of a square matrix A If A is binary (0,1 entries): perm(A) = number of perfect matchings in a bipartite graph BA whose adjacency matrix is A Note: finding if there exists a perfect matching is in P (using network flow)

10

slide-60
SLIDE 60

Permanent

Permanent of a square matrix A If A is binary (0,1 entries): perm(A) = number of perfect matchings in a bipartite graph BA whose adjacency matrix is A Note: finding if there exists a perfect matching is in P (using network flow) Algebraically: perm(A) = Σσ Πi Ai,σ(i) where σ are permutations

10

slide-61
SLIDE 61

Permanent

Permanent of a square matrix A If A is binary (0,1 entries): perm(A) = number of perfect matchings in a bipartite graph BA whose adjacency matrix is A Note: finding if there exists a perfect matching is in P (using network flow) Algebraically: perm(A) = Σσ Πi Ai,σ(i) where σ are permutations Note: Similar to determinant (which is in FP)

10

slide-62
SLIDE 62

Permanent

Permanent of a square matrix A If A is binary (0,1 entries): perm(A) = number of perfect matchings in a bipartite graph BA whose adjacency matrix is A Note: finding if there exists a perfect matching is in P (using network flow) Algebraically: perm(A) = Σσ Πi Ai,σ(i) where σ are permutations Note: Similar to determinant (which is in FP) Permutations are cycle covers of complete directed graph

10

slide-63
SLIDE 63

Permanent

Permanent of a square matrix A If A is binary (0,1 entries): perm(A) = number of perfect matchings in a bipartite graph BA whose adjacency matrix is A Note: finding if there exists a perfect matching is in P (using network flow) Algebraically: perm(A) = Σσ Πi Ai,σ(i) where σ are permutations Note: Similar to determinant (which is in FP) Permutations are cycle covers of complete directed graph Weight of a cycle cover σ, W(σ) = Πi Ai,σ(i)

10

slide-64
SLIDE 64

Permanent

Permanent of a square matrix A If A is binary (0,1 entries): perm(A) = number of perfect matchings in a bipartite graph BA whose adjacency matrix is A Note: finding if there exists a perfect matching is in P (using network flow) Algebraically: perm(A) = Σσ Πi Ai,σ(i) where σ are permutations Note: Similar to determinant (which is in FP) Permutations are cycle covers of complete directed graph Weight of a cycle cover σ, W(σ) = Πi Ai,σ(i) Perm(A) = Σσ W(σ) over all cycle covers σ of directed graph GA (with edge-weights from A)

10

slide-65
SLIDE 65

Permanent is #P-complete

11

slide-66
SLIDE 66

First will reduce #SAT to permanent of an integer (not binary) matrix

Permanent is #P-complete

11

slide-67
SLIDE 67

First will reduce #SAT to permanent of an integer (not binary) matrix Plan: Given a SAT instance φ with m clauses, build an integer-weighted directed graph Aφ such that perm(Aφ) = 43m . #φ

Permanent is #P-complete

11

slide-68
SLIDE 68

First will reduce #SAT to permanent of an integer (not binary) matrix Plan: Given a SAT instance φ with m clauses, build an integer-weighted directed graph Aφ such that perm(Aφ) = 43m . #φ Almost Karp-reduction (need to rescale)

Permanent is #P-complete

11

slide-69
SLIDE 69

Permanent is #P-complete

12

slide-70
SLIDE 70

Permanent is #P-complete

For each variable add a “variable gadget” and for each clause a “clause gadget”

12

slide-71
SLIDE 71

Permanent is #P-complete

For each variable add a “variable gadget” and for each clause a “clause gadget”

variable gadget: ....

False edge external (true) edges - one per clause

Symbolic description: ... Gadget: clause gadget:

external edges - one per variable

external edges variable gadget clause gadget external edges

[Figures from the textbook]

12

slide-72
SLIDE 72

Permanent is #P-complete

For each variable add a “variable gadget” and for each clause a “clause gadget” Variable: two possible cycle covers of weight 1

  • - uses either all the

true-edges or the false-edge

variable gadget: ....

False edge external (true) edges - one per clause

Symbolic description: ... Gadget: clause gadget:

external edges - one per variable

external edges variable gadget clause gadget external edges

[Figures from the textbook]

12

slide-73
SLIDE 73

Permanent is #P-complete

For each variable add a “variable gadget” and for each clause a “clause gadget” Variable: two possible cycle covers of weight 1

  • - uses either all the

true-edges or the false-edge Clause: any cycle cover has to leave at least

  • ne variable-edge free

variable gadget: ....

False edge external (true) edges - one per clause

Symbolic description: ... Gadget: clause gadget:

external edges - one per variable

external edges variable gadget clause gadget external edges

[Figures from the textbook]

12

slide-74
SLIDE 74

Permanent is #P-complete

13

slide-75
SLIDE 75

Permanent is #P-complete

XOR gadget (with negative edge weights):

13

slide-76
SLIDE 76

Permanent is #P-complete

XOR gadget (with negative edge weights):

u u’ v’ v

`

13

slide-77
SLIDE 77

Permanent is #P-complete

XOR gadget (with negative edge weights): Replacing a pair of edges by an XOR gadget changes total weight of cycle covers using neither or both the edges to 0, and scales total weight of cycle covers using exactly one of them by 4.

u u’ v’ v

`

13

slide-78
SLIDE 78

Permanent is #P-complete

XOR gadget (with negative edge weights): Replacing a pair of edges by an XOR gadget changes total weight of cycle covers using neither or both the edges to 0, and scales total weight of cycle covers using exactly one of them by 4. Final graph

u u’ v’ v

`

13

slide-79
SLIDE 79

Permanent is #P-complete

XOR gadget (with negative edge weights): Replacing a pair of edges by an XOR gadget changes total weight of cycle covers using neither or both the edges to 0, and scales total weight of cycle covers using exactly one of them by 4. Final graph

u u’ v’ v

`

...

variable gadget clause gadget

...... ... ..... ......

c e v

13

slide-80
SLIDE 80

Permanent is #P-complete

XOR gadget (with negative edge weights): Replacing a pair of edges by an XOR gadget changes total weight of cycle covers using neither or both the edges to 0, and scales total weight of cycle covers using exactly one of them by 4. Final graph “XOR” each clause-gadget’ s “variable- edge” with the corresponding edge in a variable-gadget: 3m XOR gadgets

u u’ v’ v

`

...

variable gadget clause gadget

...... ... ..... ......

c e v

13

slide-81
SLIDE 81

Permanent is #P-complete

XOR gadget (with negative edge weights): Replacing a pair of edges by an XOR gadget changes total weight of cycle covers using neither or both the edges to 0, and scales total weight of cycle covers using exactly one of them by 4. Final graph “XOR” each clause-gadget’ s “variable- edge” with the corresponding edge in a variable-gadget: 3m XOR gadgets Each satisfying assignment gives a cycle cover of weight 43m

u u’ v’ v

`

...

variable gadget clause gadget

...... ... ..... ......

c e v

13

slide-82
SLIDE 82

Permanent is #P-complete

14

slide-83
SLIDE 83

Permanent is #P-complete

Can use binary matrix instead of integer matrix

14

slide-84
SLIDE 84

Permanent is #P-complete

Can use binary matrix instead of integer matrix First change to +1/-1 weights (adding vertices)

14

slide-85
SLIDE 85

Permanent is #P-complete

Can use binary matrix instead of integer matrix First change to +1/-1 weights (adding vertices)

3

14

slide-86
SLIDE 86

Permanent is #P-complete

Can use binary matrix instead of integer matrix First change to +1/-1 weights (adding vertices)

3

14

slide-87
SLIDE 87

Permanent is #P-complete

Can use binary matrix instead of integer matrix First change to +1/-1 weights (adding vertices)

3

14

slide-88
SLIDE 88

Permanent is #P-complete

Can use binary matrix instead of integer matrix First change to +1/-1 weights (adding vertices) To replace -1: working modulo M+1 (for say M=2n log n > n!) does not change positive

  • values. M = 2k.

3

14

slide-89
SLIDE 89

Permanent is #P-complete

Can use binary matrix instead of integer matrix First change to +1/-1 weights (adding vertices) To replace -1: working modulo M+1 (for say M=2n log n > n!) does not change positive

  • values. M = 2k.
  • 1 is then M. Replace M by log M edges
  • f weight 2 in series, each further

replaced by +1 weight edges

3

14

slide-90
SLIDE 90

Permanent is #P-complete

Can use binary matrix instead of integer matrix First change to +1/-1 weights (adding vertices) To replace -1: working modulo M+1 (for say M=2n log n > n!) does not change positive

  • values. M = 2k.
  • 1 is then M. Replace M by log M edges
  • f weight 2 in series, each further

replaced by +1 weight edges

3 4

14

slide-91
SLIDE 91

Permanent is #P-complete

Can use binary matrix instead of integer matrix First change to +1/-1 weights (adding vertices) To replace -1: working modulo M+1 (for say M=2n log n > n!) does not change positive

  • values. M = 2k.
  • 1 is then M. Replace M by log M edges
  • f weight 2 in series, each further

replaced by +1 weight edges

3 4

14

slide-92
SLIDE 92

Permanent is #P-complete

Can use binary matrix instead of integer matrix First change to +1/-1 weights (adding vertices) To replace -1: working modulo M+1 (for say M=2n log n > n!) does not change positive

  • values. M = 2k.
  • 1 is then M. Replace M by log M edges
  • f weight 2 in series, each further

replaced by +1 weight edges

3 4

14

slide-93
SLIDE 93

Today

15

slide-94
SLIDE 94

Today

#P

15

slide-95
SLIDE 95

Today

#P Can be hard: even #CYCLE is not in FP (unless P = NP)

15

slide-96
SLIDE 96

Today

#P Can be hard: even #CYCLE is not in FP (unless P = NP) #P ⊆ FPPP (and PP ⊆ P#P)

15

slide-97
SLIDE 97

Today

#P Can be hard: even #CYCLE is not in FP (unless P = NP) #P ⊆ FPPP (and PP ⊆ P#P) #P complete problems

15

slide-98
SLIDE 98

Today

#P Can be hard: even #CYCLE is not in FP (unless P = NP) #P ⊆ FPPP (and PP ⊆ P#P) #P complete problems #SAT

15

slide-99
SLIDE 99

Today

#P Can be hard: even #CYCLE is not in FP (unless P = NP) #P ⊆ FPPP (and PP ⊆ P#P) #P complete problems #SAT Permanent

15

slide-100
SLIDE 100

Today

#P Can be hard: even #CYCLE is not in FP (unless P = NP) #P ⊆ FPPP (and PP ⊆ P#P) #P complete problems #SAT Permanent Next: Toda’ s Theorem: PH ⊆ P#P = PPP

15