Inclusion-Exclusion Seminar on exact exponential algorithms Keren Solodkin Based on Chapter 4 in Exact exponential algorithms, Fomin, Kratsch, 2010 (FK) Plan

• The Inclusion-Exclusion Principle • Some Inclusion-Exclusion Algorithms • Computing the Permanent of a Matrix • Directed Hamiltonian Path • Bin Packing • Coverings • Graph Coloring • Polynomial space The Inclusion-Exclusion Principle The Inclusion-Exclusion Principle

• 푄 1 , 푄 2 , … , 푄 푛 properties • 푁 푊 - Objects having none of the properties 푄 푤 for 푤 ∈ 푊 • 푋 - The number of objects having all properties

푋 = ෍ −1 푊 푁 푊 = 푊⊆ 1,2,…,푛 = 푁 − 푁 1 − 푁 2 − ⋯ − 푁 푛 +푁 1,2 + ⋯ + 푁 푛 − 1, 푛 − ⋯ − 푁 1,2, … , 푛 The Inclusion-Exclusion Principle • 푄 1 − 푅퐸퐷, 푄 2 − 퐵퐼퐺 • 푁 ∅ − All objects, 푁 1 − Not red objects • 푁 2 − Not big objects, 푁 1,2 − Neither red or big objects • 푋 − The number of objects having all properties (Red and Big) • 푋 = 푁 ∅ − 푁 1 − 푁 2 + 푁 1,2 = 12 − 7 − 8 + 4 = 1 Some Inclusion-Exclusion Algorithms Computing the Permanent of a Matrix

퐴 = 푎푖푗 , 푖, 푗 ∈ 1, … , 푛 , 푎푖푗 ∈ 0,1 푛

푝푒푟푚 퐴 = ෍ ෑ 푎푖,휋 푖 휋∈푆푛 푖=1

푎11 푎12 푎13 퐴 = 푎21 푎22 푎23 푎31 푎32 푎33

푝푒푟푚 퐴 = a11a22a33 + a11a23a32 + a12a21a33 + a12a23a31 + a13a21a32 + a13a22a31

The trivial algorithm runs in 푂∗ 푛! Counting Perfect Matchings in Bipartite Graphs

• A 푀 of a graph 퐺 = 푉, 퐸 is perfect if 푀 is an edge cover of 퐺

1 a

2 b

3 c

4 d Counting Perfect Matchings in Bipartite Graphs

• 퐺 = 푉, 퐸 - with bipartition 푋, 푌

퐺 1 푥푖, 푦푗 ∈ 퐸 • 퐴 = 푎푖푗 , 푎푖푗 = ቊ 0 표푡ℎ푒푟푤푖푠푒 푛 • ς푖=1 푎푖휋 푖 = 1 • The number of perfect matchings in 퐺 is

푛 퐺 ෍ ෑ 푎푖휋 푖 = 푝푒푟푚 퐴 휋∈푆푛 푖=1 Counting Perfect Matchings in Bipartite Graphs Counting Perfect Matchings in Bipartite Graphs • 퐺 = 푉, 퐸 - Bipartite graph with bipartition 푋, 푌 • 푁 = 푀 ⊆ 퐸 푀 = 푛, ∀푥 ∈ 푋. ∃푦 ∈ 푌. 푥, 푦 ∈ 푀

푥1, 푦1 , 푥2, 푦1 , 푥3, 푦2 , 푥1, 푦1 , 푥2, 푦1 , 푥3, 푦3 ,

푁 = 푥1, 푦1 , 푥2, 푦2 , 푥3, 푦2 , 푥1, 푦1 , 푥2, 푦2 , 푥3, 푦3 ,

푥1, 푦1 , 푥2, 푦3 , 푥3, 푦2 , 푥1, 푦1 , 푥2, 푦3 , 푥3, 푦3 , Counting Perfect Matchings in Bipartite Graphs • 퐺 = 푉, 퐸 - Bipartite graph with bipartition 푋, 푌 • 푁 = 푀 ⊆ 퐸 푀 = 푛, ∀푥 ∈ 푋. ∃푦 ∈ 푌. 푥, 푦 ∈ 푀

• 푀 ℎ푎푠 푄 푗 ↔ ∃푥 ∈ 푋. 푥, 푦푗 ∈ 푀

• 푄 3 : 푥1, 푦1 , 푥2, 푦1 , 푥3, 푦2 , 푥1, 푦1 , 푥2, 푦1 , 푥3, 푦3 ,

푁 = 푥1, 푦1 , 푥2, 푦2 , 푥3, 푦2 , 푥1, 푦1 , 푥2, 푦2 , 푥3, 푦3 ,

푥1, 푦1 , 푥2, 푦3 , 푥3, 푦2 , 푥1, 푦1 , 푥2, 푦3 , 푥3, 푦3 , Counting Perfect Matchings in Bipartite Graphs • 퐺 = 푉, 퐸 - Bipartite graph with bipartition 푋, 푌 • 푁 = 푀 ⊆ 퐸 푀 = 푛, ∀푥 ∈ 푋. ∃푦 ∈ 푌. 푥, 푦 ∈ 푀

• 푀 ℎ푎푠 푄 푗 ↔ ∃푥 ∈ 푋. 푥, 푦푗 ∈ 푀

• 푄 3 : 푥1, 푦1 , 푥2, 푦1 , 푥3, 푦2 , 푥1, 푦1 , 푥2, 푦1 , 푥3, 푦3 ,

푁 = 푥1, 푦1 , 푥2, 푦2 , 푥3, 푦2 , 푥1, 푦1 , 푥2, 푦2 , 푥3, 푦3 ,

푥1, 푦1 , 푥2, 푦3 , 푥3, 푦2 , 푥1, 푦1 , 푥2, 푦3 , 푥3, 푦3 , Counting Perfect Matchings in Bipartite Graphs • 퐺 = 푉, 퐸 - Bipartite graph with bipartition 푋, 푌 • 푁 = 푀 ⊆ 퐸 푀 = 푛, ∀푥 ∈ 푋. ∃푦 ∈ 푌. 푥, 푦 ∈ 푀

• 푀 ℎ푎푠 푄 푗 ↔ ∃푥 ∈ 푋. 푥, 푦푗 ∈ 푀 • 푀 has 푄 1 , … , 푄 푛 ↔ 푀 is a perfect matching of 퐺 푊 • 푋 = σ푊⊆ 1,2,…,푛 −1 푁 푊 Counting Perfect Matchings in Bipartite Graphs 푛 • 푁 푊 = ς푖=1 σ푗∉푊 푎푖푗

• 푁 2 = 푎11 + 푎13 ⋅ 푎21 + 푎23 ⋅ 푎31 + 푎33 = 1 + 0 ⋅ 1 + 1 ⋅ 0 + 1 = 2

• 푁 1,2 = 푎13 ⋅ 푎23 ⋅ 푎33 = 0 ⋅ 1 ⋅ 1

• Not 푄 2 : 푥1, 푦1 , 푥2, 푦1 , 푥3, 푦2 , 푥1, 푦1 , 푥2, 푦1 , 푥3, 푦3 ,

푁 = 푥1, 푦1 , 푥2, 푦2 , 푥3, 푦2 , 푥1, 푦1 , 푥2, 푦2 , 푥3, 푦3 ,

푥1, 푦1 , 푥2, 푦3 , 푥3, 푦2 , 푥1, 푦1 , 푥2, 푦3 , 푥3, 푦3 , Counting Perfect Matchings in Bipartite Graphs

푛 • 푁 푊 = ς푖=1 σ푗∉푊 푎푖푗 푊 • 푋 = σ푊⊆ 1,2,…,푛 −1 푁 푊 퐺 푊 푛 • 푝푒푟푚 퐴 = 푋 = σ푊⊆ 1,2,…,푛 −1 ς푖=1 σ푗∉푊 푎푖푗 푛 • Each of the values ς푖=1 σ푗∉푊 푎푖푗 is computable in polynomial time • Compute the permanent in 푂∗ 2푛 time and polynomial space Directed Hamiltonian Path

• 퐺 = 푉, 퐸 directed and simple graph

• 푉 = 푠, 푡 ∪ 푣1, 푣2, … , 푣푛 Number of Directed Hamiltonian s,t-paths

• 푁 = 푝 = 푠, … , 푡 푝 = 푛 + 1 0,1,2,3,4,5,6 , 0,1,2,1,2,1,6 , • 푁 = … , 0,3,4,5,2,1,6 Number of Directed Hamiltonian s,t-paths

• 푁 = 푝 = 푠, … , 푡 푝 = 푛 + 1

• 푝 has 푄 푖 ↔ 푣푖 ∈ 푝

• 푄 3 : 0,1,2,3,4,5,6 , 0,1,2,1,2,1,6 , 푁 = … , 0,3,4,5,2,1,6 Number of Directed Hamiltonian s,t-paths

• 푁 = 푝 = 푠, … , 푡 푝 = 푛 + 1

• 푝 has 푄 푖 ↔ 푣푖 ∈ 푝 • 푝 has 푄 1 , … , 푄 푛 ↔ 푝 is a directed Hamiltonian s,t-path 푊 • 푋 = σ푊⊆ 1,2,…,푛 −1 푁 푊 Number of Directed Hamiltonian s,t-paths

푛+1 • 푁 푊 = 퐴퐺\W 푠, 푡 • 푁 3,4,5 • 퐺\W = 0,1,2,6

0 1 0 1 6 0 0 1 1 6 0 0 1 1 0 1 0 0 • 퐴퐺\W = = 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 Number of Directed Hamiltonian s,t-paths

푊 • 푋 = σ푊⊆ 1,2,…,푛 −1 푁 푊 푊 퐺\W 푛+1 = σ푊⊆ 1,2,…,푛 −1 퐴 푠, 푡 푛+1 • Each of the values 퐴퐺\W 푠, 푡 is computable in polynomial time • Compute the number in 푂∗ 2푛 time and polynomial space Finding Hamiltonian Path

• G has Hamiltonian path • If 퐺\ 푒 has no Hamiltonian path → Hamiltonian path must contain 푒 • Run the counting algorithm recursively • The running time is 푂 푚 ⋅ 푝 푛 ⋅ 2푛 • Can be reduced to 푂 log 푛 ⋅ 푝 푛 ⋅ 2푛 Bin Packing

• Bin capacity 퐵 • 푘 available bins • 푛 items • 푠 푖 = The size of item 푖 Bin Packing

• Relaxed feasible solution • Ordered set of 푘 finite lists of elements from 1,2, … , 푛 푝 • for each list 푎1, 푎2, … , 푎푝 , σℎ=1 푠 푎ℎ ≤ 퐵 • each of the elements of 1,2, … , 푛 appears in at least one of the lists Bin Packing

푝 • 푁 = 푆 = 푙1, … , 푙푘 ∀푗. 푙푗 = 푎1, 푎2, … , 푎푝 , σℎ=1 푠 푎ℎ ≤ 퐵 • 푆 has 푄 푖 ↔ ∃푗. 푖 ∈ 푙푗 • 푆 has 푄 1 , … , 푄 푛 ↔ 푆 is a solution 푊 • 푋 = σ푊⊆ 1,2,…,푛 −1 푁 푊 Bin Packing

푊 • 푋 = σ푊⊆ 1,2,…,푛 −1 푁 푊 • Each of the values 푁 푊 is computable in polynomial time • Compute 푋 in 푂∗ 2푛 time and polynomial space Coverings Coverings

• 푈 a set of 푛 elements, 푆 ⊆ 푃 푈 푘 푖=1 푆푖 = 푈ڂ 푆1, 푆2, … , 푆푘 is a 푘-cover of 푈, 푆 if 푆푖 ∈ 푆 and • Count The Number of 푘-covers

• 푐푘 = 푐푘 푈, 푆 푘 • 푁 = 푂 = 푆1, 푆2, … , 푆푘 푆푖 ∈ 푆 , 푁 = 푆 • 푘 = 3

푟푒푑, 표푟푎푛푔푒, 푔푟푒푒푛 , 표푟푎푛푔푒, 푟푒푑, 푔푟푒푒푛 , 푁 = 푟푒푑, 푟푒푑, 푟푒푑 , … , 푔푟푒푒푛, 표푟푎푛푔푒, 푝푢푟푝푙푒 Count The Number of 푘-covers

• 푐푘 = 푐푘 푈, 푆 푘 • 푁 = 푂 = 푆1, 푆2, … , 푆푘 푆푖 ∈ 푆 , 푁 = 푆 푘 푖=1 푆푖ڂ ∋ For u ∈ 푈, 푂 has 푄 푢 ↔ 푢 •

• 푄 푏표푡푡표푚 푟푖푔ℎ푡 : 푟푒푑, 표푟푎푛푔푒, 푔푟푒푒푛 , 표푟푎푛푔푒, 푟푒푑, 푔푟푒푒푛 푁 = , … , 푔푟푒푒푛, 표푟푎푛푔푒, 푝푢푟푝푙푒 Count The Number of 푘-covers

• 푐푘 = 푐푘 푈, 푆 푘 • 푁 = 푂 = 푆1, 푆2, … , 푆푘 푆푖 ∈ 푆 , 푁 = 푆 푘 푖=1 푆푖ڂ ∋ For u ∈ 푈, 푂 has 푄 푢 ↔ 푢 • • 푂 has 푄 푢 for all u ∈ 푈 ↔ 푂 is a 푘-cover of 퐺 푊 • 푐푘 = 푋 = σ푊⊆ 1,2,…,푛 −1 푁 푊 Count The Number of 푘-covers

• 푆 푊 = 푠 ∈ 푆 푠 ∩ 푊 = ∅ • 푁 푊 = 푆 푊 푘

• S 푡표푝 푟표푤 = 푏푙푢푒, 푝푢푟푝푙푒, 푑푎푟푘 푏푙푢푒 • 푁 푡표푝 푟표푤 = 3푘 Count The Number of 푘-covers

• 푆 푊 = 푠 ∈ 푆 푠 ∩ 푊 = ∅

• 푆 푊 = σ푠⊆푈\W 푓 푠 1 푠 ∈ 푆 • 푓 푠 = ቊ 0 표푡ℎ푒푟푤푖푠푒 Count The Number of 푘-covers

• 푆 푊 = σ푠⊆푈\W 푓 푠 1 푠 ∈ 푆 • 푓 푠 = ቊ 0 표푡ℎ푒푟푤푖푠푒 • 푔 푊 = σ 푓(푠) 푖 푢푖+1,…,푢푛 \W⊆푠⊆푈\W • 푔0 푊 = σ푈\W⊆푠⊆푈\W 푓(푠) = 푓 푈\W • 푔푛 푊 = σ∅⊆푠⊆푈\W 푓(푠) = 푆 푊

푔푖−1 푊 푖푓 푢푖 ∈ 푊 • 푔푖 푊 = ቊ 푔푖−1 푊 ∪ 푢푖 + 푔푖−1 푊 표푡ℎ푒푟푤푖푠푒 Count The Number of 푘-covers

푊 푊 푘 • 푐푘 = σ푊⊆ 1,2,…,푛 −1 푁 푊 = σ푊⊆ 1,2,…,푛 −1 푆 푊 • Computation of all 푆 푊 푘 in 푂∗ 2푛 • Compute the number in 푂∗ 2푛 time and exponential space Coverings

• The can be seen as a covering problem • 푘-Cover the set U = 1,2, … , 푛 • 푆 = 푠 ⊆ 푈|푠푢푚 푠 ≤ 퐵 Graph Coloring

• Undirected graph 퐺 = 푉, 퐸 • Assign a color to each • Adjacent vertices have different colors • A color class, is an independent set of 퐺 • 퐼 is the set of all independent sets of 퐺 • given a 푘-cover of V,I it is easy to derive a 푘-coloring of 퐺. • V,I has a 푘-cover ↔ 퐺 has a 푘-coloring Chromatic Number of a Graph

• The chromatic number of a graph 퐺 = 푉, 퐸 is the smallest 푘 for which 푐푘 푉, 퐼 > 0 • We can compute the chromatic number of a graph in time 푂∗ 2푛 and exponential space. Polynomial Space

The number of 푘-covers 푐푘 푈, 푆 can be computed in polynomial space 푛 푛 and σ푗=0 푗 푇푆 푗 time assuming that there is a 푻푺 풋 time and polynomial space algorithm to compute 푺 푾 for 푾 ⊆ 푼, 푾 = 풋 Polynomial Space

푊 푘 • 푐푘 = σ푊⊆ 1,2,…,푛 −1 푆 푊 • Iterate over all 푊 ⊆ 푈 • add the value of −1 푊 푆 푊 푘 to a running total sum • By assumption, there is a polynomial space algorithm to compute 푆 푊 in time 푇푆 푗 for every 푊 ⊆ 푈 with 푊 = 푗 푛 푛 • The total running time is σ푗=0 푗 푇푆 푗 Chromatic Number of a Graph

• Polynomial space 푂 1.2461푛 time algorithm to count the number of independent sets in an 푛-vertex graph by Furer, M., Kasiviswanathan , S.P (2007) • Can compute |S[W]| using this algorithm for 퐺\W in 푂 1.2461푛−푗

푛 푛 푛−푗 푛 • σ푗=0 푗 푂 1.2461 = 푂 2.2461