Sudoku Squares and Chromatic Polynomials Agnes M
Total Page:16
File Type:pdf, Size:1020Kb
Sudoku Squares and Chromatic Polynomials Agnes M. Herzberg and M. Ram Murty he Sudoku puzzle has become a very Recall that a Latin square of rank n is an n × n popular puzzle that many newspapers array consisting of the numbers such that each carry as a daily feature. The puzzle con- row and column has all the numbers from 1 to sists of a 9 × 9 grid in which some of the n. In particular, every Sudoku square is a Latin entries of the grid have a number from square of rank 9, but not conversely because of T the condition on the nine 3 × 3 sub-grids. Figure 1 to 9. One is then required to complete the grid in such a way that every row, every column, and 2 (taken from [6]) shows one such puzzle with every one of the nine 3 × 3 sub-grids contain the seventeen entries given. digits from 1 to 9 exactly once. The sub-grids are shown in Figure 1. 1 4 2 5 4 7 8 3 1 9 3 4 2 5 1 8 6 Figure 2. A Sudoku puzzle with 17 entries. Figure 1. A Sudoku grid. For anyone trying to solve a Sudoku puzzle, several questions arise naturally. For a given puz- zle, does a solution exist? If the solution exists, is Agnes M. Herzberg is professor of mathematics at Queen’s it unique? If the solution is not unique, how many University, Canada. Her email address is herzberg@post. solutions are there? Moreover, is there a system- queensu.ca. atic way of determining all the solutions? How M. Ram Murty is professor of mathematics at Queen’s University, Canada. His email address is murty@mast. many puzzles are there with a unique solution? queensu.ca. What is the minimum number of entries that can Research of both authors is partially supported by Natu- be specified in a single puzzle in order to ensure ral Sciences and Engineering Research Council (NSERC) a unique solution? For instance, Figure 2 shows grants. that the minimum is at most 17. (We leave it to 708 Notices of the AMS Volume 54, Number 6 the reader that the puzzle in Figure 2 has a unique having degree 3n2 − 2n − 1 = (3n + 1)(n − 1). In solution.) It is unknown at present if a puzzle with the case n = 3, X3 is 20-regular and in case n = 2, 16 specified entries exists that yields a unique X2 is 7-regular. solution. Gordon Royle [6] has collected 36,628 The number of ways of coloring a graph G with distinct Sudoku puzzles with 17 given entries. λ colors is well known to be a polynomial in λ of We will reformulate many of these questions degree equal to the number of vertices of G. Our in a mathematical context and attempt to answer first theorem is that given a partial coloring C of them. More precisely, we reinterpret the Sudoku G, the number of ways of completing the coloring puzzle as a vertex coloring problem in graph the- to obtain a proper coloring using λ colors is also ory. This enables us to generalize the questions a polynomial in λ, provided that λ is greater than and view them from a broader framework. We or equal to the number of colors used in C. More will also discuss the relationship between Latin precisely, this is stated as Theorem 1. squares and Sudoku squares and show that the set Theorem 1. Let G be a finite graph with v vertices. of Sudoku squares is substantially smaller than Let C be a partial proper coloring of t vertices of the set of Latin squares. G using d0 colors. Let pG,C (λ) be the number of ways of completing this coloring using λ colors to Chromatic Polynomials obtain a proper coloring of G. Then, pG,C (λ) is a For the convenience of the reader, we recall the monic polynomial (in λ) with integer coefficients of notion of proper coloring of a graph. A λ-coloring degree v − t for λ ≥ d0. of a graph G is a map f from the vertex set of G to {1, 2,...,λ}. Such a map is called a proper coloring We will give two proofs of this theorem. The if f (x) ≠ f (y) whenever x and y are adjacent most direct proof uses the theory of partially or- in G. The minimal number of colors required to dered sets and Möbius functions, which we briefly properly color the vertices of a graph G is called review. A partially ordered set (or poset, for short) the chromatic number of G and denoted χ(G). is a set P together with a partial ordering denoted It is then not difficult to see that the Sudoku by ≤ that satisfies the following conditions: (a) puzzle is really a coloring problem. Indeed, we x ≤ x for all x ∈ P; (b) x ≤ y and y ≤ x implies associate a graph with the 9 × 9 Sudoku grid as x = y; (c) x ≤ y and y ≤ z implies x ≤ z. follows. The graph will have 81 vertices with each We will consider only finite posets. Familiar vertex corresponding to a cell in the grid. Two examples of posets include the collection of sub- distinct vertices will be adjacent if and only if the groups of a finite group partially ordered by set corresponding cells in the grid are either in the inclusion and the collection of positive divisors same row, or same column, or the same sub-grid. of a fixed natural number n partially ordered by Each completed Sudoku square then corresponds divisibility. A less familiar example is given by the to a proper coloring of this graph. We put this following construction. in a slightly more general context. Consider an Let G be a finite graph and e an edge of G. n2 × n2 grid. To each cell in the grid, we associate The graph obtained from G by identifying the two a vertex labeled (i, j) with 1 ≤ i, j ≤ n2. We will vertices joined by e (and removing any resulting say that (i, j) and (i′, j′) are adjacent if i = i′ multiple edges) is denoted G/e and is called the or j = j′ or ⌈i/n⌉ = ⌈i′/n⌉ and ⌈j/n⌉ = ⌈j′/n⌉. contraction of G by e. In general, we say that the (Here, the notation ⌈ · ⌉ means that we round to graph G′ is a contraction of G if G′ is obtained the nearest greater integer.) We will denote this from G by a series of contractions. The set of graph by Xn and call it the Sudoku graph of rank all contractions of a finite graph G can now be n. A Sudoku square of rank n will be a proper partially ordered by defining that A ≤ B if A is a coloring of this graph using n2 colors. A Sudoku contraction of B. puzzle corresponds to a partial coloring and the Given a finite poset P with partial ordering question is whether this partial coloring can be ≤, we define the Möbius function µ : P × P → Z completed to a total proper coloring of the graph. recursively by setting We remark that, sometimes, it is more conve- ≠ µ(x, x) = 1, X µ(x, y) = 0, if x z. nient to label the vertices of a Sudoku graph of x≤y≤z rank n using (i, j) with 0 ≤ i, j ≤ n2 − 1. Then, (i, j) and (i′, j′) are adjacent if i = i′ or j = j′ or The main theorem in the theory of Möbius func- → C [i/n] = [i′/n] and [j/n] = [j′/n], where now [ · ] tions is the following. If f : P is any complex indicates the greatest integer function. That is, [x] valued function and we define means the greatest integer which is less than or g(y) = X f (x), equal to x. x≤y Recall that a graph is called regular if the degree then of every vertex is the same. An easy computation f (y) = X µ(x, y)g(x), shows that Xn is a regular graph with each vertex x≤y June/July 2007 Notices of the AMS 709 and conversely. We refer the reader to [5] for to both x and y, and this number corre- amplification of these ideas. sponds to pG/e,C (λ). Each of G − e and G/e Proof of Theorem 1. We will use the theory of have fewer edges than G. Thus, we may Möbius functions outlined to prove Theorem 1. apply induction and complete the proof in Let (G, C) be given with G a graph and C a proper this case. coloring of some of the vertices. We will say (2) Now suppose that G has one vertex v0 not (G′, C) is a subgraph of (G, C) if G′ is obtained contained in C. If this vertex is not adja- by contracting some edges of G with at most cent to any vertex of C, then G = C ∪ v0, one end-point in C. This gives us a partially which is the disjoint union of C and the ordered set. The minimum contraction would be vertex v0. Thus, we can color v0 using any the vertices of C with the adjacencies amongst of the λ colors. Thus, pG,C (λ) = λ in this them preserved. We will also use the letter C case. If this vertex is adjacent to d vertices to denote this minimum graph in our poset.