Lecture 4: 3SAT and Latin Squares. 1 Partial Latin Squares Completable in Polynomial Time

Similar documents
Lecture 2: NP-Completeness

Instructor: Padraic Bartlett. Lecture 2: Schreier Diagrams

Lecture 4: Trees and Art Galleries

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14

Professor: Padraic Bartlett. Lecture 9: Trees and Art Galleries. Week 10 UCSB 2015

Lecture 5: More Examples/Applications of Quasirandom Graphs

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18

Treewidth and graph minors

Reductions and Satisfiability

Exact Algorithms Lecture 7: FPT Hardness and the ETH

Induction Review. Graphs. EECS 310: Discrete Math Lecture 5 Graph Theory, Matching. Common Graphs. a set of edges or collection of two-elt subsets

1. Lecture notes on bipartite matching February 4th,

Lecture 24: More Reductions (1997) Steven Skiena. skiena

1 Variations of the Traveling Salesman Problem

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Algorithms For Inference Fall 2014

Matching Algorithms. Proof. If a bipartite graph has a perfect matching, then it is easy to see that the right hand side is a necessary condition.

Lecture 8: The Traveling Salesman Problem

CS599: Convex and Combinatorial Optimization Fall 2013 Lecture 14: Combinatorial Problems as Linear Programs I. Instructor: Shaddin Dughmi

1. Lecture notes on bipartite matching

Lecture 1: An Introduction to Graph Theory

CS261: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem

Lecture 20: Satisfiability Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY

Graph theory. Po-Shen Loh. June We begin by collecting some basic facts which can be proved via bare-hands techniques.

Adjacent: Two distinct vertices u, v are adjacent if there is an edge with ends u, v. In this case we let uv denote such an edge.

POLYHEDRAL GEOMETRY. Convex functions and sets. Mathematical Programming Niels Lauritzen Recall that a subset C R n is convex if

Characterizations of graph classes by forbidden configurations

CHAPTER 2. Graphs. 1. Introduction to Graphs and Graph Isomorphism

On the Relationships between Zero Forcing Numbers and Certain Graph Coverings

Notes for Recitation 8

AMS /672: Graph Theory Homework Problems - Week V. Problems to be handed in on Wednesday, March 2: 6, 8, 9, 11, 12.

Theorem 3.1 (Berge) A matching M in G is maximum if and only if there is no M- augmenting path.

Mathematical and Algorithmic Foundations Linear Programming and Matchings

Abstract. A graph G is perfect if for every induced subgraph H of G, the chromatic number of H is equal to the size of the largest clique of H.

6c Lecture 3 & 4: April 8 & 10, 2014

Complexity Classes and Polynomial-time Reductions

Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1

The Structure of Bull-Free Perfect Graphs

by conservation of flow, hence the cancelation. Similarly, we have

Matching and Planarity

Lecture 4: Petersen Graph 2/2; also, Friendship is Magic!

CS 217 Algorithms and Complexity Homework Assignment 2

NP-Hardness. We start by defining types of problem, and then move on to defining the polynomial-time reductions.

val(y, I) α (9.0.2) α (9.0.3)

MATH 682 Notes Combinatorics and Graph Theory II

Steven Skiena. skiena

Matchings. Examples. K n,m, K n, Petersen graph, Q k ; graphs without perfect matching. A maximal matching cannot be enlarged by adding another edge.

Kuratowski Notes , Fall 2005, Prof. Peter Shor Revised Fall 2007

15-451/651: Design & Analysis of Algorithms November 4, 2015 Lecture #18 last changed: November 22, 2015

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Sorting lower bound and Linear-time sorting Date: 9/19/17

PCP and Hardness of Approximation

Bipartite Roots of Graphs

Module 7. Independent sets, coverings. and matchings. Contents

TILING RECTANGLES SIMON RUBINSTEIN-SALZEDO

On the Number of Tilings of a Square by Rectangles

Perfect matchings in O(nlogn) time in regular bipartite graph

Theorem 2.9: nearest addition algorithm

Lecture 20 : Trees DRAFT

Lecture 1. 1 Notation

CPSC 536N: Randomized Algorithms Term 2. Lecture 10

EMBEDDING INTO l n. 1 Notation and Lemmas

Trail Making Game. Hyun Sung Jun Jaehoon Kim Sang-il Oum Department of Mathematical Sciences KAIST, Daejeon, , Republic of Korea.

Matching Theory. Figure 1: Is this graph bipartite?

Ramsey s Theorem on Graphs

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Algorithms For Inference Fall 2014

Byzantine Consensus in Directed Graphs

Fixed-Parameter Algorithms, IA166

Line Graphs and Circulants

Polynomial-Time Approximation Algorithms

Advanced Combinatorial Optimization September 17, Lecture 3. Sketch some results regarding ear-decompositions and factor-critical graphs.

COMP260 Spring 2014 Notes: February 4th

Problem Set 2 Solutions

Lecture 6: Graph Properties

The External Network Problem

arxiv: v5 [cs.dm] 9 May 2016

Notes for Lecture 24

CS 125 Section #4 RAMs and TMs 9/27/16

9 Bounds for the Knapsack Problem (March 6)

The following is a summary, hand-waving certain things which actually should be proven.

The Square Root Phenomenon in Planar Graphs

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

MC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points

Graph Theory II. Po-Shen Loh. June edges each. Solution: Spread the n vertices around a circle. Take parallel classes.

Lecture 4: examples of topological spaces, coarser and finer topologies, bases and closed sets

Notes for Lecture 20

{ 1} Definitions. 10. Extremal graph theory. Problem definition Paths and cycles Complete subgraphs

Testing Isomorphism of Strongly Regular Graphs

W[1]-hardness. Dániel Marx. Recent Advances in Parameterized Complexity Tel Aviv, Israel, December 3, 2017

Recitation 4: Elimination algorithm, reconstituted graph, triangulation

CMPSCI611: The SUBSET-SUM Problem Lecture 18

Finding a -regular Supergraph of Minimum Order

6. Lecture notes on matroid intersection

The Encoding Complexity of Network Coding

Modules. 6 Hamilton Graphs (4-8 lectures) Introduction Necessary conditions and sufficient conditions Exercises...

Lecture 3: Art Gallery Problems and Polygon Triangulation

Improved Results on Geometric Hitting Set Problems

NP-Completeness. Algorithms

Some Applications of Graph Bandwidth to Constraint Satisfaction Problems

8 NP-complete problem Hard problems: demo

Vertex Cover is Fixed-Parameter Tractable

Paths, Flowers and Vertex Cover

Transcription:

NP and Latin Squares Instructor: Padraic Bartlett Lecture 4: 3SAT and Latin Squares Week 4 Mathcamp 2014 This talk s focus is on the computational complexity of completing partial Latin squares. Our first goal in this talk is to show that for many special classes of partial Latin squares, we can construct completions for these objects in polynomial time. From here, we will prove the fairly surprising claim that completing an arbitrary partial Latin square is an NP-complete task; so while it is easy to complete almost all reasonably-well-behaved families of partial Latin squares, it is remarkably hard to complete any partial Latin square without some constraints on what it can or cannot be. 1 Partial Latin Squares Completable in Polynomial Time In this part, we give a number of families of partial Latin squares can be completed to proper Latin squares in polynomial time. To start, let s consider one of the simplest families to complete: Latin rectangles! Definition. A k n Latin rectangle is a n n partial Latin square, such that every cell in its first k rows is filled, and no cell in its remaining rows is filled. Theorem. Any Latin rectangle can be completed to a Latin square. Furthermore, this completion can be calculated in polynomial time. The proof of this result is essentially an application of a famous result of Hall, called Hall s marriage theorem: Theorem. Take any bipartite graph G with bipartition (V 1, V 2. Suppose that G has the following property: given any i and set S V i, the number of neighbors to elements in S, N(S), is at least as large as the number of elements in S itself. (In symbols: N(S) S. This is called Hall s condition in the literature.) Then G has a perfect matching: i.e. there is some collection M of edges so that every vertex of G shows up in exactly one edge. (In general, a matching is any collection of edges so that every vertex shows up in at most edge; matchings are perfect precisely when they contain every vertex.) We start by proving Hall s marriage theorem: Proof. We proceed via the following algorithm, that takes in any nonperfect matching M and creates a matching M with strictly larger size: 1. Because of Hall s condition, the two sides V 1, V 2 must be the same size. 2. Therefore, if M is not perfect, there must be some starting vertex x 1 V 1 that is not in our matching. 1

3. By Hall s condition, this vertex must have a neighbor x 2 in V 2. Travel to this vertex along our edge. 4. If the vertex x 2 is not in our matching, then we can increase the size of our matching by simply adding in the edge {x 1, x 2 } to our matching. 5. Otherwise, it is in our matching, and there is a third vertex x 3 connected to x 2 by a matching edge, that is not x 1. Travel to x 3. 6. Consider the common neighbors of x 1, x 3. There must be some vertex beyond x 2 that we can reach from one of these vertices, by Hall s condition: take this vertex as our new vertex x 4, and travel to this vertex. Note that this edge is not in our matching. 7. If x 4 is not in our matching, then halt. Otherwise it is; use this observation to travel back to some vertex x 5. Again, note that x 5 is not one of our earlier-reached vertices, because M is a matching. 8. Once again, notice that we must be able to get to some new vertex x 6 from x 5, by the same logic as two steps ago! In other words, we can simply loop the logic of steps 6-7; we will never get stuck on step 6 by Hall s condition, and thus we eventually must halt at step 7, as our graph is finite. What is the output of this algorithm? Well: it is a sequence of vertices that starts from a vertex not in our matching, ends at a vertex not in our matching, and along the way alternates between edges not in our matching and edges in our matching. So: take this alternating path, and switch which edges are and are not in our matching! This creates a matching with one more edge than we started with, and did so in polynomial time (check this in the HW!) Iterating this process creates a perfect matching, as desired. We now use this result to prove our original claim about completing Latin rectangles: Proof. Take our k n Latin rectangle L. Form the following bipartite graph: Vertex set 1: the columns of L. Vertex set 2: the symbols of L. Edges: connect c j to s k if and only if symbol k does not show up in column j. This graph satisfies Hall s condition (why?) Consequently, it has a perfect matching. But what is a perfect matching? Well: it is a way to pair up each column with a different symbol, so that each paired symbol does not occur in that column yet! In other words, this perfect matching corresponds precisely with a potential k +1-th row for our Latin rectangle! Add this as a row: we have now grown our Latin rectangle by one row, in polynomial time. Doing this repeatedly will complete our Latin rectangle to a Latin square, as desired. We list a few additional results here, along these lines: 2

1. (Ryser, 1951.) Suppose that P is a n n partial latin square with the following properties: There is a set of r rows named R, and a set of c columns named C, such that a cell (i, j) is not blank iff i R and j C. If N(k) denotes the total number of times the symbol k is used in our entire square, then N(k) r + c n. Then P can be completed 2. (Smetaniuk, 1981.) Suppose P is a partial latin square with n 1 filled cells. Then P can be completed. 3. (Buchanan, 2007.) Suppose P is a n n partial Latin square consisting of 2 filled rows and columns of P are. Then P can be completed whenever n 6. All of the results above consist of algorithms that complete these squares; all of these algorithms run in polynomial time (with the caveat that I haven t read carefully through Buchanan s 140+ page thesis yet, but it certainly looks like it runs in polynomial time.) 2 Completing Arbitrary Partial Latin Squares Given the above results, it may be surprising that completing an arbitrary partial Latin square is a NP-complete task; after all, every time we consider a specific family of Latin squares, they are all individually completable! However, given yesterday s lecture, this doesn t seem too implausible. Consider our correspondence between triangulated tripartite graphs and Latin squares: rows 1 2 3 columns symbols Under this correspondence, adding cells to our grid corresponds to adding triangles to our graph! Therefore, completing our partial Latin square is equivalent to triangulating the complement of some triangulated tripartite graph: 3

rows 1 2 3 2 columns symbols This correspondence gives us the following reduction for free: Corollary. The problem of completing a partial Latin square reduces to the task of triangulating a graph. However, this is in a sense the wrong direction. We want to show that completing partial Latin squares is hard: in other words, we want to reduce some NP-complete problem, like triangulating graphs, to completing partial Latin squares! To do this, then, we don t want a way to embed Latin squares in graphs; we want a way to embed graphs into Latin squares! If done directly, this is overly difficult; arbitrary graphs are very complicated things. However, if we look at our proof from yesterday, we can notice a few particularly nice properties about the graphs H m,n we dealt with: 1. If we picked n, m to both be multiples of 3, this graph is tripartite! 2. Moreover, if n, m are chosen so that our graph is tripartite, the size of each part is the same. 3. This graph is uniform in other words, given any vertex v in a part V i of these tripartite graphs, the number of edges from this vertex to the i + 1-th part of our graph is the same as the number of edges from this vertex to the i 1-th part of our graph. (I.e. deg i+1 (v) = deg i 1 (v)). 4. These properties are preserved under the gluing operations we defined. (Proofs of these claims are on the homework!) In particular, this means that we can slightly modify our claim from yesterday Theorem. 3SAT reduces to the task of triangulating a uniform tripartite graph on (n, n, n) vertices. This is stronger: i.e. we no longer need an algorithm that triangulates arbitrary graphs to solve 3SAT problems, we just need one that can triangulate uniform tripartite graphs! In turn, this makes our work easier for dealing with Latin squares: we just need a way to turn any uniform tripartite graph into a partial Latin square, such that completions of the corresponding partial Latin square turn into triangulations of the tripartite graph! This is possible, as Colbourn showed in 1984: Theorem. (Colbourn.) Triangulating a uniform tripartite graph is a task that reduces to completing partial Latin squares. 4

Colbourn s proof is a relatively straightforward one, that mostly hinges around combining Hall s marriage theorem with the following concept: Definition. Take any uniform tripartite graph G with parts (R, C, S), where R = {r i } n i=1, C = {c i } n i=1, S = {s i} n i=1. A Latin framework LF (G; x, y, z) is an x y array with the following properties: 1. Each cell of our array is either blank, or contains a symbol from {1,... z}. 2. There are no repeated symbols in any row, column, or symbol. 3. If the edge (r i, c j ) exists in the graph G, then the cell (i, j) in our array is blank; otherwise, it is filled. 4. If the edge (r i, s k ) exists in the graph G, then there is no symbol k in the i-th row of our array. 5. If the edge (c j, s k ) exists in the graph G, then there is no symbol k in the j-th column of our array. Notice that when x = y = z, our framework is a partial Latin square, as it is an x x array filled with blanks and the symbols {1,... x}, with no repeats. Furthermore, this partial Latin square corresponds precisely to the tripartite complement of the graph G: when translated to a graph, its edges are precisely those edges that G does not have. Consequently, any completion of this partial Latin square would correspond to a triangulation of G itself! With this stated, our proof has a fairly natural structure. Take any uniform tripartite graph G. Then: 1. Form a corresponding Latin framework LF (G, x, y, z) in polynomial time. 2. Extend this Latin framework to a larger Latin framework LF (G, w, w, w), for some value w, again in polynomial time. 3. By the above comments, this Latin framework corresponds to a partial Latin square; completing it triangulates our graph G. So, if we had any algorithm for completing a partial Latin square, we could use it here to complete our framework, and thus triangulate G itself. The first step of this is relatively simple. Given a uniform tripartite graph G on (n, n, n) vertices, consider the following n n array: If (r i, c j ) is an edge in G, leave the cell (i, j) blank. Otherwise, fill it with the symbol (i + j mod n) + 1 + n. By construction, this satisfies all of the properties of a LF (G, n, n, 2n), mostly because we added in n additional symbols and are using them as placeholders through our entire array! But hey, it works. So, all we need to do is describe how to go from a LF (G, n, n, 2n) to a LF (G, 2n, 2n, 2n). We do this via the following lemma: 5

Lemma 1. Take any Latin framework L = LF (G; x, y, z) for a uniform tripartite graph G. For any symbol k, let R(k) denote the number of times that k occurs in L, plus the total number of edges in the graph G from s k to the row-set R; this number, in a sense, corresponds to the number of rows that k cannot be used in throughout our Latin framework. Suppose that for every symbol k, we have R(k) x + y z Then we can expand our Latin framework by one column, in a way that preserves the above inequality. In other words, we can extend our Latin framework L to some L = LF (G; x, y + 1, z), such that L and L agree on all of L. Proof. For each row i, define the set S i as the collection S i = {k k / row i, and (r i, s k ) / E(G)}. In other words, S i corresponds to the collection of all symbols k that are possible candidates for the i-th entry in our new y + 1-th column. Notice that each set S i contains precisely z y elements. This is because every cell (r i, c i ) in some row i is either filled (in which case that symbol corresponds to exactly one element that cannot be in our row) or is blank (in which case (r i, c i ) is an edge in G, and therefore because of uniformity there is a corresponding (r i, s k ) that is blocked from occurring in this row as well.) Consequently, the number of possible symbols is exactly the total number of possible symbols, minus the number of cells in our row: i.e. z y. As well, define the set M = {k R(k) = x + y z}. This set corresponds to the symbols in our Latin framework that are close to being used too rarely for our lemma to work. Given these sets, if we want to construct a new column y + 1 for our Latin framework, we need to simply do the following: 1. Pick one element from each S i, so that no element is repeated across all of our choices. (This constructs our new column.) 2. While making these choices, we should insure that we pick all of the elements of M in constructing our new column; this will use each of these symbols in M at least once, and thus preserve the R(k) x + y z property we want our graphs to have. Both of these results are consequences of the following slight modification of Hall s marriage theorem: Theorem. (Hall.) Take any bipartite graph G = (V 1, V 2 ) that satisfies Hall s condition on subsets of V 1 : that is, given any subset S V 1, we have S N(S). Then there is a matching in G that uses all of the vertices in V 1. The proof of the above is identical to the proof we presented for Hall s theorem earlier in these notes! Gven this, consider the following bipartite graph: 6

Vertex set 1: the sets {S i } x i=1. Vertex set 2: the symbols {k} z k=1. Edges: connect S i to k if and only if k S i. A matching of the sets {S i } x i=1 to the symbols then corresponds to a new potential column, which is exactly what we re looking for! Therefore, it suffices to construct such an object, which we can do via Hall s marriage theorem if and only if our graph satisfies Hall s criterion. We check if our construction satisfies Hall s criterion. Take any subset A {S i } x i=1. On one hand, by our discussion above, the degree of each set-vertex S i is z y, because each set contains z y elements. On the other hand, consider any symbol k in our Latin framework; by assumption, it is blocked from occurring in at least R(k) x + y z of the rows of our square. Consequently, there are at most x (x + y z) = z y rows in which k can occur, for any k! In other words, the degree of each symbol-vertex k is at most z y. Therefore, if we have A of the S i s, we have A (z y) edges leaving our set A; if the degree of every symbol-vertex is at most z y, we need at least A symbol-vertices to absorb the A (z y) incoming edges! In other words, our graph satisfies Hall s condition, and thus has a matching using all of the S i s, as desired. This gives us a new column; however, we also need to insure that this new column contains all of the elements of M! We do this through another similar matching exercise. Consider the following graph: Vertex set 1: the set M of symbols. Vertex set 2: the sets {S i } x i=1. Edges: connect k to S i if and only if k S i. We now want a matching of M to the S i s, so that every element of M gets matched to some S i. We do this by again checking Hall s condition. On one hand, we know that by the definition of M, each symbol k M is blocked from occurring in R(k) = x + y z symbols, and thus is in exactly x (x + y z) = z y sets S i. In other words, each symbol k in our graph has degree z y. As discussed before, each set S i in our set contains z y elements, and thus has degree z y in the graph we have constructed here. Therefore, by the exact same logic as before, any subset A of M has A (z y) edges leaving it, and therefore must have at least A neighbors across from it in {S i } x i=1. In other words, Hall s condition holds, and we have a matching! We re now almost done. We have, at this point, the following: A matching from {S i } x i=1 to {1,... z} that uses all of the S i s. A matching from M to {S i } x i=1 that uses all of the M s. What we want is, in a sense, both of these matchings: we want a matching from {S i } x i=1 to {1,... z} that uses all of the S i s, but that also hits all of the M s! Conveniently, this is possible, as the following theorem shows: 7

Theorem. Take any bipartite graph G = (V 1, V 2 ) with matchings M 1, M 2. matching M M 1 M 2 such that the following holds: There is a Every vertex in V 1 M 1 is contained in M, and also Every vertex in V 2 M 2 is contained in M. We prove this theorem here: Proof. Take any such graph G and matchings M 1, M 2. Look at the subgraph of G given by taking the edges/vertices given by M 1 M 2 : this is a graph in which every vertex has degree at most 2, and therefore (because G is bipartite) decomposes into a collection of paths and even cycles. Take any of the connected components H i of M 1 M 2, and do the following: If H i is a cycle, then take every other edge from it and put those in M. Notice that this choice covers every vertex that H i hit, so we are still covering the same sets of vertices that M 1 M 2 covered. Suppose that H i is a path, and moreover contains a vertex in V 1 that is in M 1 and not in M 2. Then our path must start at this vertex! Take all of the M 1 -edges in H 1. This trivially covers all of the vertices in V 1 hit by M 1 ; to see that it also covers all of the V 2 vertices hit by M 2, simply observe that because our path starts in V 1 and travels to V 2 along a M 1 -edge, it must always go from V 2 to V 1 along M 2 -edges, and thus in particular can t end on a V 2 -vertex reached by a M 2 -edge. Identical reasoning to the above tells us that if H i is a path that contains a vertex in V 2 that is in M 2 and not in M 1, taking the M 2 -edges will always work out for us. Because any H i falls into one of the three cases above, we have described how to create a matching with the desired properties. This proves our lemma, as desired. Applying this theorem to the matching M 1 from {S i } x i=1 to {1,... z} and the matching M 2 from M to {S i } x i=1 proves our lemma! So we are done. Furthermore, notice that this lemma can be applied in polynomial time; its steps consist of using Hall to make matchings (doable in polynomial time) and then of combining these matchings (again doable in polynomial time.) From here, our theorem that triangulation reduces to completing a partial Latin square is relatively straightforward. Simply take our tripartite uniform graph G, and turn it into a LF (G; n, n, 2n) as discussed earlier. Apply the lemma above repeatedly to turn it into a LF (G; n, 2n, 2n); then take the transpose of this array, and repeatedly apply the lemma again until we get a LF (G; 2n, 2n, 2n). As discussed earlier, this is precisely a partial Latin square whose complement (interpreted as a tripartite graph) is G. Therefore, if we have any algorithm that can complet partial Latin squares, we can use the above polynomial-time process to use it to triangulate uniform tripartite graphs! This reduces triangulation to completing a partial Latin square, as desired. In particular, notice that this result in conjunction with Wednesday s proof that triangulation is a NPcomplete problem proves that completing an arbitrary Latin square is NP-complete! 8