Uploaded by Khristine Granil

BS MS Thesis Graph Theory of Sudoku

advertisement
GRAPH THEORY OF SUDOKU
A REPORT
submitted in partial fulfillment of the requirements
for the award of the dual degree of
Bachelor of Science - Master of Science
in
MATHEMATICS
by
CHIRAAG RAMESH LALA
(08009)
DEPARTMENT OF MATHEMATICS
INDIAN INSTITUTE OF SCIENCE EDUCATION AND
RESEARCH BHOPAL
BHOPAL - 462023
April 2013
i
CERTIFICATE
This is to certify that Chiraag Ramesh Lala, BS-MS (Mathematics),
has worked on the project entitled ‘Graph Theory of Sudoku’ under my
supervision and guidance. The content of the project report has not been
submitted elsewhere by him/her for the award of any academic or professional
degree.
April 2013
IISER Bhopal
Committee Member
Dr. Anandateertha Mangasuli
Signature
Date
ii
DECLARATION
I hereby declare that this project report is my own work and due acknowledgement has been made wherever the work described is based on the findings
of other investigators. I also declare that I have adhered to all principles of
academic honesty and integrity and have not misrepresented or fabricated or
falsified any idea/data/fact/source in my submission.
April 2013
IISER Bhopal
Chiraag Ramesh Lala
iii
ACKNOWLEDGEMENT
I would like to thank the following for helping me get this project report
from a figment in my brain into the tangible copy that it is:
My guide Dr. Anandateertha Mangasuli, for presenting me this opportunity to study (and enjoy) this topic I am so passionate about and for his
prescient guidance in affirming my thoughts as I worked on this study and
correcting me if I was wrong. I also thank him for having unwittingly shaped
my mind making me a more coherent and rational thinker and finally for
tolerating me, my behavior and my numerous incessant presentations;
Professor Agnes M. Herzberg and Professor M. Ram Murty for their fabulous paper that inspired this project;
Professor Manindra Agrawal for his guidance in a short study project that
found a small but unique application in this project;
Mrs. Sreeja Purushotham, my most beloved Mathematics teacher, and all
my teachers for the lessons they have taught;
My father, my mother and my brother for their unending support and love
and for soothing me and providing me the strength to endure through all my
predicaments;
Arghyadeep Dash for helping me with the diagrams.
Football for all the fascinating ideas and insights that struck me while playing, watching and dreaming it.
Chiraag Ramesh Lala
iv
ABSTRACT
This project aims to study and contribute to a clear and rigorous understanding of mathematics behind the popular number placement puzzle Sudoku. Sudoku puzzle consists of a 9 × 9 grid of 81 cells (or slots) with
some cells already filled with digits from 1 to 9. The objective of the puzzle
is to fill the rest of the grid with digits from 1 to 9 such that no digit repeats
within any row, column and specified 3 × 3 blocks. For anyone trying to
solve a Sudoku puzzle, several questions arise naturally. To cite a few: for
a given puzzle, does a solution exist? If the solution exists, is it unique?
If the solution is not unique, how many solutions are there? Moreover, is
there a systematic way of determining all the solutions? How many puzzles
are there with a unique solution? What is the minimum number of initial
entries that can be specified in a single puzzle in order to ensure a unique
solution? This project attempts to answer such interesting and intriguing
questions. Many of the above questions have been addressed in the paper
Sudoku Squares and Chromatic Polynomials by Agnes M. Herzberg and M.
Ram Murty published in Notices of the American Mathematical Society Volume 54 Issue 6 in June/July 2007. [5]
This project report provides a detailed study of Agnes M. Herzberg and
M. Ram Murty’s paper filling all its gaps and in the process gives an elaborate
introduction to all mathematical concepts encountered. Since Sudoku is a
special case of a general graph theoretic problem (as will be shown in the
report), concepts and insights involving graph theory are emphasized using
Frank Harary’s book on Graph Theory [4]. In addition some applications of
these concepts are demonstrated.
v
LIST OF SYMBOLS OR
ABBREVIATIONS
|
Such that
{}
Set
∞
Infinity
φ
Null Set
⊆
Subset of
⊂
Proper Subset of
|set|
Cardinality of set
N
Set of all Natural Numbers
Z
Group of all Integers
R
Real Number Field
⇒
Implies
⇔
If and only if
∈
Belongs to
∩
Intersection
∪
Union
<
Less than
≤
Less than or equal to
>
Greater than
≥
Greater than or equal to
bxc
Greatest integer less than or equal to x
i.e.
That is
∀
For all
CONTENTS
Certificate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
i
Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ii
Acknowledgement . . . . . . . . . . . . . . . . . . . . . . . . . . . .
iii
Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
iv
List of Symbols or Abbreviations . . . . . . . . . . . . . . . . . .
v
1. Sudoku - A Graph Theoretic Problem .
1.1 What is a Graph? . . . . . . . . . . . . .
1.2 What is Sudoku? . . . . . . . . . . . . .
1.3 Graph of Sudoku . . . . . . . . . . . . .
1.4 Graph Colouring and Chromatic Number
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 1
. 1
. 4
. 12
. 14
2. Chromatic Polynomial of Sudoku . . . . .
2.1 Chromatic Function . . . . . . . . . . . . .
2.2 Chromatic Function is a Polynomial . . . .
2.3 Chromatic Polynomial of a Sudoku Puzzle
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
18
18
21
31
3. Sudoku Enumeration . . . .
3.1 Sudoku Squares of Rank 2
3.2 Three Famous Theorems .
3.3 Number of Latin Squares .
3.4 Number of Filled Sudokus
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
36
37
44
48
52
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Contents
vii
Appendix
60
.1 Counting Principle . . . . . . . . . . . . . . . . . . . . . . . . 61
.2 Polynomial . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
1. SUDOKU - A GRAPH
THEORETIC PROBLEM
Graph Theory is the study of graphs which are mathematical structures used
to model pairwise relations between objects from a certain collection. Graphs
are among the most ubiquitous models of both natural and human-made
structures. It’s study has had wide spread ramifications due to applications
in many other fields of study like Physics, Chemistry, Computer Science, Social Science, Linguistics, Biology, Cartography, Engineering etc. and within
Mathematics as well.
Graphs can also be used to model many puzzle games like Sudoku. Sudoku is a puzzle game that has become very popular as many newspapers
carry it as a daily feature. It is a number placement puzzle which involves
completely filling a 9 × 9 grid with numbers from 1 to 9 satisfying certain
conditions. In this chapter, mathematical model of the Sudoku Puzzle game
is introduced using graphs.
1.1
What is a Graph?
Definition 1.1. An ordered pair of a finite non-empty set V and a prescribed
set E of unordered pairs of distinct elements of V is defined to be a graph.
Mathematically, G = (V, E) is a graph if
|V | < ∞, V 6= φ and E ⊆ {{u, v}|u, v ∈ V and u 6= v} .
Definition 1.2. Let G = (V, E) be a graph. An element of V is called a
1. Sudoku - A Graph Theoretic Problem
2
vertex and an element of E is called an edge of the graph G. Vertices a
and b are said to be adjacent, denoted as a adjV b, if {a, b} is a edge in E.
Distinct edges x and y are said to be adjacent, denoted as x adjE y, if they
share a common vertex (that is x ∩ y 6= φ). A vertex a and an edge x of
graph G are said to be incident to each other, denoted as a incG x (or x incG
a), if a ∈ x. A graph with p number of vertices and q number of edges is
called a (p, q) graph. So G = (V, E) is a (|V |, |E|) graph, where | | represents
cardinality.
Remark 1.3. Graphs can be visualized with their diagramatic representations. Let G = (V, E) be a graph. Represent the vertices in V by distinct
geometric points in the plane. Label the points by the name of the vertex
they represent. Draw a line segment (could be a curve) connecting two points
labeled u and v if u adjV v. Label the line as {u, v}, thus representing the
edge {u, v} ∈ E. This way we get a diagramatic representation of G.
A (4, 5) graph G = ({a, b, c, d}, {{a, b}, {a, c}, {b, c}, {b, d}, {c, d}})
{a,c}
{a,b}
{b,c}
{b,d}
{c,d}
1. Sudoku - A Graph Theoretic Problem
3
Remark 1.4. Diagramatic representation of graphs is just a means to visualize graphs. There cannot be multiple lines joining the same two points or
a line starting and ending at the same point (no loops) in a graph.
Example 1.5. Some standard graphs.
A (p, 0) Isolated Graph, denoted Ip , is the graph ({v1 , v2 , ..., vp }, φ).
A (p, p − 1) Path Graph, denoted Pp , is the graph
({v1 , v2 , ..., vp }, {{v1 , v2 }, {v2 , v3 }, ..., {vp−1 , vp }}).
A (p, p) Cycle Graph, denoted Cp , is the graph
({v1 , v2 , ..., vp }, {{v1 , v2 }, {v2 , v3 }, ..., {vp−1 , vp }, {vp , v1 }}).
A (p, p2 /2 − p/2) Complete Graph, denoted Kp , is the graph
({v1 , v2 , ..., vp }, {{vi , vj }|i, j ∈ {1, 2, ..., p} and i 6= j}).
A (m + n, mn) Complete Bipartite Graph, denoted Km,n , is the graph
({v1 , ..., vm , u1 , ..., un }, {{vi , uj }|i ∈ {1, 2, ..., m}, j ∈ {1, 2, ..., n}}).
Definition 1.6. Let G1 = (V1 , E1 ) and G2 = (V2 , E2 ) be two graphs. If
V2 ⊆ V1 and E2 ⊆ E1 then G2 is said to be a subgraph of G1 . If in addition
V2 = V1 then G2 is called a spanning subgraph of G1 . If G2 is a subgraph of
G1 with maximum number of edges that is E2 = {{a, b}| a, b ∈ V2 , a 6= b}∩E1
then G2 is called an induced subgraph of G1 .
The only subgraph which is both spanning subgraph and induced subgraph
of a graph G is G itself.
Definition 1.7. Let G1 = (V1 , E1 ) and G2 = (V2 , E2 ) be two graphs. G1 is
said to be isomorphic to G2 , denoted as G1 ∼
= G2 , if there exists a bijection
f : V1 → V2 such that {a, b} ∈ E1 if and only if {f (a), f (b)} ∈ E2 .
1. Sudoku - A Graph Theoretic Problem
4
Two isomorphic graphs (G1 ∼
= G2 by bijection f ) are the same upto renaming
of vertices where f denotes the renaming.
Definition 1.8. Let G = (V, E) be a graph. Degree of a vertex v ∈ V ,
denoted degG (v), is the number of edges in E incident to v. If degG (v) = r,
for all v ∈ V , then G is said to be a regular graph of degree r.
Theorem 1.9. Let G = (V, E) be a graph with q edges then
X
degG (v) = 2q .
v∈G
Proof. Proof by Induction on q.
If q = 0 then we get Isolated graph where degree of each vertex is 0. Hence
formula holds.
Assume that the Theorem statement is true for q = l − 1, where l > 0. Let
G = (V, E) be an arbitrary (p, l) graph. So ∃ an edge {u, v} ∈ E. Remove
this edge from graph G. We get the subgraph G∗ = (V, E \ {{u, v}}) of
P
G. By induction hypothesis v∈G∗ degG∗ (v) = 2(l − 1). Since degG (v) =
degG∗ (v) + 1, degG (u) = degG∗ (u) + 1 and degree of remaining vertices is
P
P
unchanged, therefore w∈G degG (w) = ( w∈G∗ degG∗ (w)) + 2 = 2l.
Remark 1.10. A regular graph of degree r having p vertices has pr/2 edges.
1.2
What is Sudoku?
Definition 1.11. A cell is a unit square in R2 plane which can contain at
most one integer in its interior. An integer that a cell contains is called the
entry of that cell. If a cell contains an entry then it is called a filled cell,
else it is called an empty cell.
1. Sudoku - A Graph Theoretic Problem
5
7
Empty Cell
F illed cell
Definition 1.12. An m × n grid is an array of mn cells consisting m rows
and n columns (m, n ∈ N). The cell in the ith row and j th column of a
m × n grid G with i ∈ {0, 1, 2, ..., m − 1} and j ∈ {0, 1, 2, ..., n − 1} is denoted as (i, j)G or simply (i, j) if the grid being referred to is understood.
Note that we are starting the numbering of the rows and columns from 0
onwards. The ith row of m × n grid G, denoted as RG (i), is the set of cells
{(i, j)G | j ∈ {0, 1, 2, ..., n − 1}} and the j th column of G, denoted as CG (j)
is the set of cells {(i, j)G | i ∈ {0, 1, 2, ..., m − 1}}.
Given a m × n grid G, the entry in the cell (i, j)G with i ∈ {0, 1, 2, ..., m − 1}
and j ∈ {0, 1, 2, ..., n − 1} is denoted by E(i, j)G . If (i, j)G is a empty cell
then define E(i, j)G = φ.
1. Sudoku - A Graph Theoretic Problem
6
F or instance a 3 × 7 grid G
CG(0)
1
2
3
4
5
CG(6)
RG(0)
RG(1)
(1,4)G
RG(2)
Definition 1.13. A Sudoku grid of rank n is a n2 × n2 grid denoted
as Xn . It consists of n2 disjoint n × n grids. These n × n grids are called
subgrids or blocks of the Sudoku grid of rank n. These blocks, denoted
as BXn (i, j) with i, j ∈ {0, 1, ..., n − 1}, are collection of specific cells of Xn
where BXn (i, j) = {(p, q)Xn |bp/nc = i, bq/nc = j}. (For a real number x,
bxc denotes the greatest integer smaller than or equal to x.) The collection
of blocks {BXn (i, j)| j ∈ {0, 1, 2, ..., n − 1} is called the ith band of Sudoku
grid Xn . Similarly the collection of blocks {BXn (i, j)| i ∈ {0, 1, 2, ..., n − 1}
is called the j th strip of Xn . Xn has n bands and n strips.
1. Sudoku - A Graph Theoretic Problem
7
Sudoku grid of rank 2 consists 4 blocks, 2 bands and 2 strips.
X2 =
BX (0,0)
0th band
2
BX (1,0)
BX (1,1)
0th strip
1st strip
2
2
1st band
Each block is a 2 × 2 grid.
Definition 1.14. A Sudoku puzzle of rank n is a Sudoku grid of rank
n which may contain some filled cells with entries from the set {1, 2, ..., n2 }
such that any two distinct filled cells containing the same entry are not in
the same column, row and block.
Mathematically, if ∀i, i∗ , j, j ∗ ∈ {0, 1, ..., n2 − 1} we get,
(1) E(i, j)Xn ∈ {φ, 1, 2, ..., n2 }, i.e. either cells are empty or filled by entries from 1 to n2 .
(2) E(i, j)Xn = E(i∗ , j ∗ )Xn 6= φ with (i, j) 6= (i∗ , j ∗ )
=⇒ i 6= i∗ , j 6= j ∗ and BXn (i, j) 6= BXn (i∗ , j ∗ );
i.e. no repetition of integer in same row, column and block.
then Xn is a Sudoku Puzzle of rank n.
1. Sudoku - A Graph Theoretic Problem
8
Definition 1.15. A Sudoku puzzle G of rank n is said to be a Filled Sudoku of rank n if all its cells are filled with integers from 1 to n2 satisfying
the conditions in the above Definition 1.14.(No repetition of integers in same
row, column and block.) G is called an Empty Sudoku of rank n if all its
cells are empty, i.e. it is just the n2 × n2 grid Xn with no entries.
Sudoku Puzzle of rank 2
1
2
2
1
2
1
1
Filled Sudoku of rank 2
1
4
2
3
3
2
4
1
2
3
1
4
4
1
3
2
1. Sudoku - A Graph Theoretic Problem
9
Definition 1.16. Let a, b, n ∈ Z (the set of integers).
a = b(mod n) means a − b is a multiple of n, that is a − b = nm for some
m ∈ Z.
Theorem 1.17. If a ∈ Z and d ∈ N (set of natural numbers), then there
exists a unique integer b ∈ {0, 1, 2, ..., d − 1} such that a = b(mod d). Denote
this unique integer b as Rem(a, d).
Proof. From definition of greatest integer function we get,
ba/dc ≤ a/d < ba/dc + 1. Call ba/dc as integer c. It follows that
cd ≤ a < cd + d
Define
b = a − cd
then b ∈ {0, 1, 2, ...d − 1} from the above inequality and a = b(mod d).
This proves existence. Uniqueness of b follows from the fact that if p, q ∈
{0, 1, 2, ..., d − 1} with p = q(mod d) then p = q (because if not, without loss
of generality let p > q, then p − q is divisible by d and p − q ∈ {1, 2, ..., d − 1} :
a contradiction).
Theorem 1.18. A Filled Sudoku of rank n exists for every n ∈ N.
Proof. For all i ∈ {0, 1, ..., n2 − 1}, write i = ti n + di with both di and ti ∈
{0, 1, ..., n − 1}.
Define the entry in (i, j)Xn cell to be E(i, j)Xn = Rem((di n+ti +ntj +dj ), n2 ).
Entries in distinct cells of the same row are distinct because,
E(i, j)Xn = E(i, j ∗ )Xn
⇒ ntj + dj = ntj ∗ + dj ∗ (mod n2 )
⇒ j = j ∗.
Similarly entries in distinct cells of a same column are distinct. Entries in
distinct cells of same block are distinct because, (i, j)Xn and (i∗ , j ∗ )Xn lie in
the same block ⇒ [i/n] = [i∗ /n] and [j/n] = [j ∗ /n]
⇒ ti + ntj = ti∗ + ntj ∗ (mod n2 )
1. Sudoku - A Graph Theoretic Problem
10
⇒ ti + ntj = ti∗ + ntj ∗ since all ti , ti∗ , tj , tj ∗ ∈ {0, 1, ..., n2 − 1}
⇒ ti + ntj = ti∗ + ntj ∗ (mod n)
⇒ ti = ti∗ (mod n)
⇒ ti = ti∗ ⇒ tj = tj ∗ .
⇒ (i, j) = (i∗ , j ∗ )
Thus we get a Filled Sudoku of rank n, for arbitrary n ∈ N.
Definition 1.19. A Filled Sudoku of rank n, say F P , is said to be a solution
of Sudoku puzzle P of rank n if entry of every filled cell (i, j)P of P is equal
to the entry of the same cell (i, j)F P in F P . Mathematically,
if ∀i, j ∈ {0, 1, ..., n2 − 1}; E(i, j)P 6= φ =⇒ E(i, j)P = E(i, j)F P
then filled Sudoku F P is called a solution of the Sudoku Puzzle P .
In other words, F P is a solution of P if it preserves the initial entries given
in P . For instance the Filled Sudoku of rank 2 shown on page 8 is solution
of the Sudoku puzzle of rank 2 on the same page.
Definition 1.20. Latin Square of rank n is a n × n grid of filled cells
consisting entries from {1, 2, ..., n} such that any two cells consisting same
entry do not lie in the same column and row.
Mathematically, let L be a n × n grid. If ∀i, i∗ , j, j ∗ ∈ {0, 1, ..., n − 1} we get,
(1) E(i, j)L ∈ {1, 2, ..., n}, i.e. all cells are filled and
(2) E(i, j)L = E(i∗ , j ∗ )L with (i, j) 6= (i∗ , j ∗ ) =⇒ i 6= i∗ , j 6= j ∗ (No repetition of digits in rows and columns)
then L is a latin square.
Remark 1.21. (1) Set of all Filled Sudokus of rank n ⊂ Set of all Sudoku
puzzles of rank n.
1. Sudoku - A Graph Theoretic Problem
11
(2) Set of all Filled Sudokus of rank n ⊂ Set of all Latin Squares of rank n2 .
Reason: For (1). Filled Sudokus satisfy all conditions to be a Sudoku puzzle.
Sudoku grid with each cell empty is also a Sudoku puzzle but it is not a
Filled Sudoku, hence the proper subset in statement (1)
For (2). Filled Sudoku of rank n satisfies the conditions to be a Latin Square
of rank n2 . Consider a n2 × n2 grid G where E(i, j)G = Rem(i + j, n2 ), ∀i, j ∈
{0, 1, ..., n2 − 1}. G is a Latin Square but not a Filled Sudoku. Thus we get
the proper subset in statement (2).
1
4
2
5
4
8
3
1
3
9
4
5
7
2
1
8
6
Fig. 1.1: A Sudoku puzzle, call it S, of rank 3 with 17 filled cells.
1. Sudoku - A Graph Theoretic Problem
6
9
3
7
8
4
5
1
2
4
8
7
5
1
2
9
3
6
1
2
5
9
6
3
8
7
4
9
3
2
6
5
1
4
8
7
5
6
8
2
4
7
3
9
1
7
4
1
3
9
8
6
2
5
3
1
9
4
7
5
2
6
8
8
5
6
1
2
9
7
4
3
2
7
4
8
3
6
1
5
9
12
Fig. 1.2: A solution of Sudoku Puzzle S.
Definition 1.22. Sudoku is a game in which a Sudoku Puzzle is given and
the objective is to find a solution of that Sudoku puzzle. For instance, Figure
1.1. is a given Sudoku puzzle and the objective is to find its solution (Fig.
1.2).
1.3
Graph of Sudoku
Definition 1.23. Let Xn be a Sudoku grid of rank n. Graph of Xn , denoted
as GXn , is (V, E) where V = {(i, j)Xn |i, j ∈ {0, 1, ..., n2 −1}} is set of all cells
1. Sudoku - A Graph Theoretic Problem
13
of Xn and E = {{(i, j)Xn , (i∗ , j ∗ )Xn }|(i, j)Xn 6= (i∗ , j ∗ )Xn and either i = i∗ or
j = j ∗ or bi/nc = bi∗ /nc, bj/nc = bj ∗ /nc}.
In other words, cells of Sudoku grid form the vertices of its graph and two
cells are adjacent if they are either in the same row or column or block of Xn .
Theorem 1.24. Let GXn = (V, E) be graph of Sudoku grid Xn , then GXn
is a regular (n4 , 3n6 /2 − n5 − n4 /2) graph of degree 3n2 − 2n − 1.
Proof. V = {(i, j)Xn |i, j ∈ {0, 1, ..., n2 − 1}}. i and j can take n2 possible
values each. By counting principle (Appendix 1), |V | = n2 × n2 = n4 .
Consider an arbitrary vertex (io , jo )Xn ∈ V. It is adjacent to other cells (vertices) in the row RXn (io )\{(io , jo )Xn } = {(io , j)Xn |j ∈ {0, 1, ..., n2 −1}\{jo }},
column CXn (jo )\{(io , jo )} = {(i, jo )Xn |i ∈ {0, 1, ..., n2 −1}\{io }} and remaining vertices of the block BXn (bio /nc, bjo /nc). We get n2 − 1 adjacent vertices
each from RXn (io ) \ {(io , jo )Xn } and CXn (jo ) \ {(io , jo )} and (n − 1)(n − 1)
left out vertices in the block (counted by Counting Principle, Appendix 1.).
Therefore
degGXn ((io , jo )) = n2 − 1 + n2 − 1 + ((n − 1)(n − 1)) = 3n2 − 2n − 1 .
Since the vertex is arbitrary, therefore GXn is regular graph of degree 3n2 −
P
2n − 1. By Theorem 1.09 ( v∈G degG (v) = 2q) and Remark 1.10 (A regular
graph of degree r having p vertices has pr/2 edges) we get the required result.
Remark 1.25. By above Theorem 1.30.
Graph of Sudoku grid of rank 3 is a (81, 810) regular graph of degree 20.
1. Sudoku - A Graph Theoretic Problem
1.4
14
Graph Colouring and Chromatic
Number
Definition 1.26. Given a graph G = (V, E), a function f : V −→ {1, 2, ..., λ}
is called a λ−colouring of G. If U is a non-empty subset of V (U ⊂ V and
U 6= φ) then a function g : U −→ {1, 2, ..., β} is called a β−partial colouring of G. f (v) is called the colour of v in the colouring f of G. These
functions, as the name suggest, indeed represent colouring (in literal sense)
of the diagramatic representation of a graph where vertices can be thought
to be coloured or labelled by at most λ colours in a λ−colouring.
F or the graph below let f be a 3 − partial colouring such that
f (v1 ) = f (v2 ) = 1 (red colour),
f (v3 ) = f (v4 ) = 2 (blue colour),
f (v5 ) = 3 (green colour)
V1
V3
V5
V2
V4
V6
and v6 is uncoloured.
Remark 1.27. (1) Total number of λ−colourings of G is λ|V | and Total
number of λ−partial colourings of G is (λ + 1)|V | − 1. (2) Any λ−colouring
(or partial colouring) is also a (λ+n)−colouring (or partial colouring) ∀n ≥ 0.
Reason: For (1). Each vertex can be coloured in λ possible ways in λ−colouring.
By Counting Principle (Appendix 1), we get λ|V | .
In λ−partial colouring, each vertex can be coloured in λ possible ways or
1. Sudoku - A Graph Theoretic Problem
15
be uncoloured thus having λ + 1 possibilities. The case where no vertex is
coloured has to be avoided. Thus we get (λ + 1)|V | − 1.
For (2). A function f : V → {1, 2, ..., λ} can also be seen as f : V →
{1, 2, ..., λ, λ+1, ..., λ+n} where inverse set f −1 (λ+k) = φ, ∀k ∈ {1, 2, ..., n}.
Definition 1.28. A λ−colouring (or partial colouring) f of a graph G =
(V, E) is said to be proper if f (u) 6= f (v) whenever u adjV v. In other
words adjacent vertices are not coloured the same.
Definition 1.29. Let G = (V, E) be a graph. If there exists an integer λ
such that there is a proper λ−colouring of G and there does not exist any
proper n−colouring of G for all n < λ, then λ is called the Chromatic
number of G denoted by χ(G).
Remark 1.30. For a graph G = (V, E), χ(G) ≤ |V |. Also χ(Kn ) = n, where
Kn is the complete graph on n vertices.
Reason: Without loss of generality, let V = {v1 , v2 , ..., vp }. The colouring
f of G, defined as f (vi ) = i, ∀i ∈ {1, 2, ..., p}, is proper. So χ(G) ≤ |V |. In a
complete graph, any two distinct vertices are adjacent. So a proper colouring
of G is injective, hence χ(Kn ) = n.
Theorem 1.31. If G∗ is a subgraph of a graph G, then their chromatic
numbers satisfy the following inequality
χ(G∗ ) ≤ χ(G) .
Proof. Let fG be a proper χ(G) colouring of G = (V, E). Let G∗ = (V ∗ , E ∗ ).
The colouring g : V ∗ −→ V , such that g(v) = fG (v), ∀v ∈ V ∗ , is a proper
χ(G)−colouring of G∗ . By Definition 1.35. of Chromatic number, χ(G∗ )
cannot be greater than a number λ if a proper λ−colouring of G∗ exists.
1. Sudoku - A Graph Theoretic Problem
16
Theorem 1.32. Chromatic number of the graph of Sudoku grid of rank n is
n2 , that is,
χ(GXn ) = n2 .
Proof. The induced subgraph of all the vertices representing cells in a row
of the Sudoku grid is a complete graph. In particular the graph of row
RXn (0) which is (RXn (0), E), where RXn (0) = {(0, j)Xn |j ∈ {0, 1, ..., n2 − 1}
and E = {{u, v}| u, v ∈ RXn , u 6= v}, is a complete subgraph of GXn . By
Remark 1.36. and Theorem 1.37,
n2 = χ((U, EU )) ≤ χ(GXn ) .
From Definition 1.19. of Filled Sudoku and Definition 1.29. of Graph of
Sudoku grid, a Filled Sudoku of rank n represents a proper n2 −colouring of
GXn . By Theorem 1.23., ∃ a Filled Sudoku F G of rank n. Let GXn = (V, E).
Then f : V −→ {1, 2, ..., n2 }, where f ((i, j)GXn ) = E(i, j)F G , is a proper
n2 −colouring of GXn so
χ(GXn ) ≤ n2 .
Hence done.
Definition 1.33. Let f be a proper χ(G)−partial colouring of a graph
G = (V, E) defined on a subset U of V . If F is a proper χ(G)−colouring of
G such that f (u) = F (u), for all u ∈ U , then it is said to be a solution of
proper partial colouring f .
Definition 1.34. Given a proper χ(G)−partial colouring of a graph G, finding its solution is a graph theoretic problem called colouring problem.
A Sudoku puzzle P of rank n, graph theoretically, is identical to the pair
(GXn , f ) where GXn is graph of Sudoku grid (Definition 1.29.) and f defined
in terms of entries of filled cells in Sudoku puzzle as f (i, j)GXn = E(i, j)P is
the proper χ(GXn ) = n2 −partial colouring. Entries of P are the colours of
1. Sudoku - A Graph Theoretic Problem
17
f . Finding a solution of P is to find a Filled Sudoku FS that preserves the
entries of P. Finding a solution of (GXn , f ) is to find (GXn , g) where g is a
proper n2 −colouring that preserves the colouring of f where entries of FS
are colours of g.
Thus Sudoku is a special case of Colouring Problem (of finding solutions to proper partial colourings of GXn graph only).
Let 1 = Red, 2 = Blue, 3 = Green and 4 = Y ellow. Solving a Sudoku
puzzle of rank 2 is same as solving the proper partial colouring of GX2 as
shown below.
1
3
4
2
1
3
2
4
2
4
1
3
3
1
4
2
4
2
3
1
2. CHROMATIC POLYNOMIAL OF
SUDOKU
The objective of Sudoku game is to find a solution to a given Sudoku Puzzle.
Existence (along with uniqueness) or non-existence of solution(s) depends
entirely on the initial entries already present in the puzzle. The total number of solutions to a Sudoku puzzle can be computed using a function called
the Chromatic Polynomial that relies on these initial entries. It is a very
strong tool that can be used to analyse Sudoku puzzles. Although finding
this function for a given Sudoku puzzle is not easy, certain properties that it
possesses can be derived. These general properties of Chromatic polynomials
can then be used to derive some interesting insights into the Puzzle.
The Chromatic polynomials of Sudoku puzzles originates from the notion
of proper colourings of a graph which was covered in chapter 1. This chapter
introduces Chromatic polynomials of Sudoku and proves some of its properties which will be used to draw a couple of interesting conclusions about
Sudoku.
2.1
Chromatic Function
Definition 2.1. A function f : U (⊆ R) −→ V (⊆ R) is said to be
monotonic increasing if x < y ⇒ f (x) ≤ f (y),
monotonic strictly increasing if x < y ⇒ f (x) < f (y),
monotonic decreasing if x < y ⇒ f (x) ≥ f (y)
and monotonic strictly decreasing if x < y ⇒ f (x) > f (y).
2. Chromatic Polynomial of Sudoku
19
Definition 2.2. Chromatic function of a graph G = (V, E) is a function
denoted ρG , where ρG : N −→ N ∪ {0} such that
ρG (λ) = |{proper λ − colourings of G}|
= T otal number of proper λ − colourings of G .
Remark 2.3. Let G be a graph. It follows from the definition of Chromatic
number (Definition 1.29.) that the chromatic function ρG is a monotonic increasing function since a proper λ−colouring is also a proper λ+n−colouring
(Remark 1.27.) and ρG (χ(G) − 1) = 0 and ρG (χ(G)) ≥ 1. Chromatic function of a graph can be further generalized for a partially coloured graph as
described in the following definition.
Definition 2.4. Let G = (V, E) be a graph with a β−partial colouring
f defined on U (⊆ V ). Chromatic function of graph G with partial
colouring f is a function denoted ρG,f , where ρG,f : N −→ N ∪ {0} such
that
ρG,f (λ) = |{g| g is a proper λ − colouring of G and g(u) = f (u) ∀u ∈ U }|
= N umber of proper λ − colourings of G that preserve the colouring by f.
Remark 2.5. Let f be a β−partial colouring of a graph G. ρG is a special
case of ρG,f where f can be thought to be a null function, that is it does
not colour any vertex. ρG,f is also a monotonic increasing function because a
proper λ−colouring is also a proper λ + n−colouring (Remark 1.27.). Moreover, from definition of Chromatic number (Definition 1.27.) and the above
2. Chromatic Polynomial of Sudoku
20
definition of Chromatic function of G with partial colouring f , we get
λ < min{χ(G), β} =⇒ ρG,f (λ) = 0 .
Example 2.6. Chromatic function of complete graph Kn , found using Counting Principle (Appendix .1), is
ρKn (λ) = λ(λ − 1)...(λ − n + 1) .
because there are λ ways to colour the first vertex then λ − 1 ways to colour
the next and so on till there are only λ − n + 1 ways to colour the last vertex
given that the remaining n − 1 vertices are already coloured.
Similarly, for m < n, if exactly m vertices of Kn are properly coloured then
chromatic function for this proper m−partial colouring, call it fm , also found
using Counting Principle (Appendix .1), is
ρKn ,fm (λ) = λ(λ − 1)...(λ − n + m + 1) .
These functions are polynomials in λ with integer coefficients of degree equal
to the number of uncoloured vertices of Kn . In addition, these are monic
polynomials as leading coefficient (coefficient of the term of highest degree) is
1. (For more details on polynomials refer Appendix .2) Similarly, Chromatic
function for Path graphs, Cycle graphs, Isolated graphs, Bipartite graph and
their proper partial colourings, which can be computed easily, are also seen
to be polynomials that satisfy the above properties. This motivates the next
section.
2. Chromatic Polynomial of Sudoku
2.2
21
Chromatic Function is a Polynomial
Definition 2.7. Consider two distinct elements a and b in the set V . The
set V |a=b , called the quotient of V by the identification a = b, is the
set (V \ {a, b}) ∪ {ab}. Note from the set V the two elements a and b are
removed and replaced by a new element ab. For instance if V = {a, b, c, d, e}
then V |c=e = {a, b, d, ce} with cardinality |V | = |(V |a=b )| + 1.
Definition 2.8. Let G = (V, E) be a graph and e = {a, b} be an edge in
E. Edge contraction of graph G by edge e, denoted as G/e, is the graph
obtained from G by identifying the two vertices a and b to be the same and
removing any multiple edges and loops. Mathematically,
G/e = (V |a=b , {{x, y} ∈ E| x, y ∈
/ {a, b}} ∪ {{x, ab}|{x, a} or {x, b} ∈ E}).
A graph G∗ is said to be a contraction of a graph G if G∗ can be obtained by a finite sequence of edge contractions of G. Mathematically, if
G∗ = (...(((G/e1 )/e2 )/e3 )/...)/en then it is a contraction of G.
Definition 2.9. A Partially Ordered Set, called P OSET , is a pair (P, ≤)
where P is a set and ≤ is a partial ordering (binary relation) on P that
satisfies the following conditions: (a) x ≤ x, ∀x ∈ P ; (b) x ≤ y and
y ≤ x ⇒ x = y; (c) x ≤ y and y ≤ z ⇒ x ≤ z. In addition if P is a
finite set then (P, ≤) is called a finite POSET.
Example 2.10. Let P be the set of all contractions of a graph G. For graphs
G1 = (V1 , E1 ) and G2 = (V2 , E2 ) ∈ P , define order G1 ≤P G2 if either G1 is
a contraction of G2 or G1 = G2 . Then the pair (P, ≤P ) is a finite POSET.
Reason: A graph, by Definition 1.1, has finitely many vertices and edges
so it will have finitely many contractions making P a finite set. For all
2. Chromatic Polynomial of Sudoku
22
G∗ ∈ P , it follows from Definition of ≤P that G∗ ≤P G∗ since G∗ = G∗ . Also
if G1 ≤P G2 and G2 ≤P G1 then G1 = G2 because if not then by Definition
2.7. and 2.8. we get |V1 | < |V2 | and |V2 | < |V1 |, a contradiction. So ≤P
satisfies second condition of being a partial order. Moreover, if G1 ≤P G2
and G2 ≤P G3 then for some n1 , n2 ∈ N, G2 = (...((G3 /e1 )/e2 )/...)/en1 and
G1 = (...((G2 /en1 +1 )/en1 +2 )/...)/en1 +n2 . So G1 = (...((G3 /e1 )/e2 )/...)/en1 +n2
is a contraction of G3 , hence proving that ≤P satisfies the third condition of
being a partial order as well.
The above example can be generalized further to a partially coloured graph.
Example 2.11. Let f be a partial colouring, of a graph G = (V, E), defined
on a subset U of V . Call an edge e = {a, b}(∈ E) to be a removable edge
of (G, f ) if either a or b ∈
/ U . Case (1): Both a and b do not lie in U , then
f is a partial colouring of the contraction G/e as well, call it g . Case (2):
Without loss of generality, let a ∈ U and b ∈
/ U , then define partial colouring
g on U |a=b as g(ab) = f (a) and g(v) = f (v), ∀v ∈ U \ {a}. In either case,
partial colouring g of contraction G/e preserves the colouring of f on vertices
in U . Rename the vertex ab(∈ G/e) to a then g = f . So upto renaming of
vertices the partial colouring of a graph and the derived partial colouring of
a removable edge contraction of that graph are the equal
Here G/e is the edge contraction of G by a removable edge e and g is the partial colouring of G/e that preserves the colouring of f , then the pair (G/e, g)
is called a removable edge contraction of (G, f ). For instance, consider the
graph G and a partial colouring f as shown on the next page.
2. Chromatic Polynomial of Sudoku
e2
uncoloured
e1
23
uncoloured
Fig. 2.1: (G,f)
The two separate cases of removable edge contractions of the above partially
coloured graph (G, f ) is demonstrated on the next page.
2. Chromatic Polynomial of Sudoku
G
e1
G
24
e2
Fig. 2.2: Case (1): G/e1 obtained by contracting an edge with uncoloured
endpoints. Case (2): G/e2 obtained by contraction of an edge
with one coloured endpoint.
(G∗ , g ∗ ) is called a special contraction of (G, f ) if the former can be obtained
from the latter by a finite sequence of removable edge contractions. But since
upto renaming of vertices g ∗ = f , so we shall write (G∗ , g ∗ ) as (G∗ , f ).
Let P ∗ be the set of all special contractions of a graph G with partial colouring f and just as in previous Example 2.10, define partial order G1 ≤P ∗ G2
if either (G1 , f ) is a special contraction of (G2 , f ) or (G1 , f ) = (G2 , f ). Since
any graph has finite number of vertices and edges therefore the pair (P ∗ , ≤P ∗ )
is also a finite POSET.
2. Chromatic Polynomial of Sudoku
25
For instance consider the complete graph K3 = ({a, b, x}, {{a, b}, {b, x}, {a, x}})
with a proper 2-partially colouring f such that f (a) = 1 and f (b) = 2.
a
(K3,f) =
b
x
Fig. 2.3: (K3 , f )
All the special contractions of (K3 , f ) other than itself are (({ax, b}, {{ax, b}}), g)
and (({a, bx}, {{a, bx}}), h) where g(ax) = f (a) = 1, g(b) = f (b) = 2,
h(a) = f (a) = 1 and h(bx) = f (b) = 2 as shown on the next page. Notice
upto renaming of vertices both g and h are same as f .
2. Chromatic Polynomial of Sudoku
a
26
ax
b
bx
Fig. 2.4: Special contractions of (K3 , f ) (Fig. 2.3.)
Definition 2.12. Given a finite POSET (P, ≤), the Mobius function denoted
as µ : P × P → Z is defined recursively as follows,
µ(x, x) = 1,
∀x ∈ P
and
X
µ(x, y) = 0,
if x 6= z.
x≤y≤z
Without going deep into the theory of Mobius functions, assume that the
Mobius function is well defined. The main theorem in this theory is the Mobius Inversion Theorem that is stated below without proof.
2. Chromatic Polynomial of Sudoku
27
Theorem 2.13. Let (P, ≤) be a finite POSET and f : P → C be any complex
valued function, then
X
g(y) =
f (x),
x≤y
if and only if
f (y) =
X
µ(x, y)g(x)
x≤y
Theorem 2.14. If G = (V, E) is a (n, q) graph and f is a proper β−partial
colouring of m(≤ n) vertices using all β colours, then Chromatic function
ρG,f (in λ) of the partially coloured graph (G, f ) is a monic polynomial in λ
(i.e. coefficient of the term of highest order is 1) of degree n − m with integer
coefficients for (λ ≥ β).
Proof. Define set P to be the collection of all special contractions of (G, f )
and ≤P be the natural ordering using removable edge contractions as demonstrated in Example 2.11. So (P, ≤P ) is a finite POSET. Let f be defined on
the set U (⊆ V ).
A special contraction of (G, f ) is said to be minimal if it cannot be contracted any further by a removable edge contraction. So a minimal special
contraction does not have a removable edge. This makes the minimal special
contraction unique because it will contain only the coloured vertices and nonremovable edges. In fact upto renaming of vertices and edges, the minimal
contraction is isomorphic to the induced subgraph denoted Gm = (Vm , Em ) of
the graph G where Vm = {set of vertices coloured by f } = U and Em = {set
of edges in G having both endpoints coloured by f } = E ∩{{x, y}|x, y ∈ Vm }.
i.e. Gm is the graph of colured vertices of G with adjacencies among the vertices preserved.
2. Chromatic Polynomial of Sudoku
28
For instance consider the graph with partial colouring as given below on
left side. Its unique minimal special contraction is shown on the right.
a
c
a
b
c
b
Fig. 2.5: Obtaining Gm - the unique minimal special contraction of a partially coloured graph (G, f ).
Thus Gm is a graph with f as its colouring.
Let (G∗ , f ) be an arbitrary element of P where G∗ = (V ∗ , E ∗ ), V ∗ contains U as a subset. Let Sλ (G∗ , f ) be the set of all λ−colourings (need not
2. Chromatic Polynomial of Sudoku
29
be proper) of G∗ with the specified colouring by f of the set U preserved, i.e.
Sλ (G∗ , f ) = {g| g is a λ − colouring of G∗ and g(v) = f (v), ∀v ∈ U }
and Pλ (G∗ , f ) be the set of all proper λ−colourings of G∗ with the specified
colouring by f on the set U preserved, i.e.
PG∗ ,f (λ) = {g| g is a proper λ−colouring of G∗ and g(u) = f (u), ∀u ∈ U } .
We know,
ρG∗ ,f (λ) = |Pλ (G∗ , f )|.
In addition define,
qG∗ ,f (λ) = |Sλ (G∗ , f )| .
By counting principle, qG∗ ,f (λ) = λnumber
of uncoloured vertices of G∗
= λ|V
∗ |−m
.
If λ ≥ β, then given any function g which is λ−colouring of G such that
g(v) = f (v) ∀v ∈ U , i.e. (G, g) ∈ Sλ (G, f ), then (G, g) can be reduced by
contraction to a unique graph (G∗ , g ∗ ) such that g ∗ is a proper λ−colouring of
G∗ that preserves the colouring of f , i.e. (G∗ , g ∗ ) ∈ Pλ (G∗ , f ). This (G∗ , g ∗ )
is obtained by the following procedure:
(1): If g is a proper colouring of G then (G∗ , g ∗ ) is same as (G, g).
(2)If g is not a proper colouring then ∃ adjacent vertices, say a and b, in G
which are coloured the same by g. So {a, b} is a removable edge in (G, f ) as f
is a proper partial colouring. Take the removable edge contraction G/{a, b}
along with the colouring on it that preserves the colouring of g, call it (Go , go ).
Repeat the above procedure on (Go , go )until we reach a special contraction
of G which is properly coloured. Define this properly coloured special contraction to be (G∗ , g ∗ ).
2. Chromatic Polynomial of Sudoku
30
For instance, the following diagram demonstrates the procedure of constructing properly coloured (G∗ , g ∗ ) of the (not proper-)coloured (G, g)
e1
a
e2
c
= (G,g)
b
a
= ((G,e1)/e2, g*)
c
b
Fig. 2.6: Here G∗ = (G/e1 )/e2
The above procedure is reversible, in the sense that, given an arbitrary
(G∗ , g ∗ ) where G∗ is a special contraction of proper partially coloured (G, f )
and g ∗ ∈ Pλ (G∗ , f ) then we can recover the unique (G, g) such that g ∈
Sλ (G∗ , f ) by retracing the above steps. This shows that the above procedure
2. Chromatic Polynomial of Sudoku
31
gives a bijective function
F : Sλ (G, f ) −→ ∪G∗ ∈P Pλ (G∗ , f )
such that F (g) = g ∗ by the procedure demonstrated above. This way we get,
qG,f (λ) = λ|V |−m =
X
ρG∗ ,f (λ) .
(G∗ ,f )≤P (G,f )
By Mobius inversion theorem we conclude
ρG,f (λ) =
X
(G∗ ,f )≤P (G,f )
X
µ(G∗ , G)qG∗ ,f (λ) =
µ(G∗ , G)λ|V
∗ |−m
(G∗ ,f )≤P (G,f )
where V ∗ is the set of vertices of G∗ . Thus characteristic function, as seen
above, is a polynomial of degree |V | − m with integer coefficients. It is a
monic polynomial because the only special contraction of (G, f ) with |V |
vertices is (G, f ) itself and µ(G, G) = 1.
2.3
Chromatic Polynomial of a Sudoku
Puzzle
Recall,
From Definition 1.23. GXn is the graph of the n × n Sudoku grid Xn . A
Sudoku Puzzle of rank n consists of a partially filled n2 × n2 Sudoku grid
with entries from the set {1, 2, ..., n2 } satisfying the conditions as defined
in Definition 1.20. (The conditions being that an integer does not repeat
within any row, column and specified blocks). This partial filling of cells of
the Sudoku grid is represented by a proper n2 −partial colouring f of graph
GXn , where f ((i, j)vertex ) = entry in cell(i, j) = E(i, j). The Sudoku puzzle
itself can be denoted a (GXn , f ). So, in graph theoretic sense, the objective
of Sudoku is to find a n2 −colouring of the graph GXn that preserves the
colouring of f , i.e. to find (GXn , g) where g is a proper n2 −colouring of
2. Chromatic Polynomial of Sudoku
32
GXn such that g(v) = f (v), ∀v ∈ domain of f . It follows from Definition2.4. and from this graph theory model of Sudoku that,
number of solutions of a Sudoku P uzzle (GXn , f ) = ρGXn ,f (n2 )
where ρGXn ,f is the chromatic polynomial of graph GXn with the proper
partial colouring f . Chromatic polynomials, if known, are very useful tools
to analyze Sudoku Puzzles. For instance, chromatic polynomial of the empty
Sudoku grid of rank n, if discovered, would gives us the total number of filled
Sudokus of rank n, i.e
ρGXn (n2 ) .
However finding the precise chromatic polynomial for Sudoku puzzles is not
an easy task.
The conventional Sudoku Puzzle games that commonly feature in newspapers are of rank 3. Let f denote the initial entries in the Sudoku grid X3 , in
other words, let f be a proper 9−partial colouring of GX3 . Then ρGX3 ,f (9)
is the number possible solutions.
Unsolvable Sudokus are the ones for which
ρGX3 ,f (9) = 0 .
Solvable Sudokus are the one for which
ρGX3 ,f (9) > 0 .
The Sudoku puzzles in puzzle books and newspapers, open for people to
solve, are meant to be uniquely solvable (unless due to some error by the
puzzle maker). So special care is taken in making the Sudoku puzzles, i.e. in
defining the initial entries f , such that
ρGX3 ,f (9) = 1 .
This motivates us ask: What are the properties of the initial entries of the
2. Chromatic Polynomial of Sudoku
33
uniquely solvable Sudoku Puzzle?
Although explicit chromatic polynomials of Sudoku puzzles are unknown,
the general properties that these polynomials are known to possess could
be used to derive some properties of the initial entries. For instance the
following Theorem.
Theorem 2.15. Any Sudoku puzzle of rank n will have a unique solution
only if it begins with at least n2 − 1 digits/colours.
Proof. We will use properties of Chromatic function derived in Theorem 2.14.
to prove this result.
Consider the graph theory model of Sudoku puzzle: (GXn , f ) where f specifies the initial entries (that is, f is a proper partial colouring of graph of
Sudoku grid GXn (of rank n)). Let (GXn , f ) be uniquely solvable with its
unique solution being (GXn , g) where g is a proper colouring that preserves
the colouring of f . Since chromatic number of GXn is χ(GXn ) = n2 (Theorem 1.38.) therefore g uses n2 colours.
Suppose that f uses only d(≤ n2 − 2) colours. It is therefore a coloring
of t vertices of GXn where 0 ≤ t < n2 − 2. So at least two vertices in
GXn are uncoloured by f . It follows from Theorem 2.14., that the chromatic function ρGXn ,f is a monic polynomial of degree ≥ 2. Moreover,
ρGXn ,f (λ) = 0, ∀λ ∈ {d, d + 1, d + 2, ..., n2 − 1 = χ(GXn ) − 1}. So by
repeated application of Theorem .18. in Appendix 2., we get,
ρGXn ,f (λ) = (λ − d)(λ − (d − 1))...(λ − (n2 − 1))q(λ)
where q(λ) is some polynomial with integer coefficients.
Note that q(λ) ∈ Z, ∀λ ∈ Z ..........................(A)
Put λ = n2 (= χ(GXn )), we get,
ρGXn ,f (n2 ) = (n2 − d)!q(n2 ) .
2. Chromatic Polynomial of Sudoku
34
As by theorem hypothesis a unique solution of (GXn , f ) exists, therefore
ρGXn ,f (n2 ) = 1 .
But as d is assumed to be ≤ n2 − 2 therefore (n2 − d)! ≥ 2. This along with
the fact that q(n2 ) is integer (from (A)) implies
ρGXn ,f (λ) = (n2 − d)!g(n2 ) 6= 1 .
Thus a contradiction, hence proving the theorem.
8
7
6
2
4
3
6
2
1
5
8
8
5
3
7
1
4
Fig. 2.7: A Sudoku puzzle, call it S, of rank 3 that begins with 8 digits
(colours) and 17 entries.
2. Chromatic Polynomial of Sudoku
4
8
7
1
9
5
3
2
6
5
1
3
2
6
4
9
8
7
9
2
6
3
8
7
1
5
4
6
4
5
7
3
8
2
9
1
1
9
8
5
2
6
4
7
3
7
3
2
4
1
9
8
6
5
2
6
4
8
7
1
5
3
9
8
5
9
6
4
3
7
1
2
3
7
1
9
5
2
6
4
8
Fig. 2.8: Unique Solution of Sudoku Puzzle S.
35
3. SUDOKU ENUMERATION
Filled Sudoku of rank n is a Latin Square of rank n2 (Remark 1.21.). But
to what extent? Digits do not repeat within any row and column in a Latin
Square. In Filled Sudoku (from now on referred as Sudoku Square) digits do
not repeat in any row and column (just like Latin Squares) but in addition,
the digits do not repeat within the specified blocks as well. What intrigues
here is how does this extra condition contribute?
A good way to measure the extent to which the above extra condition contributes will be to count total number of Sudoku Squares and Latin Squares
and then compare these two numbers. This involves the problem of enumeration of Sudoku Squares.
There are two parts to the above problem; (1) Counting (or approximating)
total number of Sudoku Squares and (2) Classification of Sudoku Squares.
Observe that given a Sudoku Square, call it S, we can generate new Sudoku
Squares simply by permutation of digits in S. The new Sudoku Squares thus
generated are similar to S up to renaming of digits. This similarity relation
(and few other relations) between Sudoku Squares is used for Classification.
Both parts of Sudoku enumeration problem use combinatorial enumeration
techniques as will be demonstrated in this chapter. The results we obtain
from these techniques may then be used to reveal new interesting insights
about Sudoku Puzzles.
3. Sudoku Enumeration
3.1
37
Sudoku Squares of Rank 2
Definition 3.1. Let S be a Sudoku Square of rank n. If a Sudoku square H
can be obtained from S by permutation of digits in S then S and H are said
to be equivalent up to permutation of digits, denoted as H∼
=p S.
1
2
3
4
3
4
1
2
2
1
4
3
4
3
2
1
Fig. 3.1: Sudoku Square S.
2
4
3
1
3
1
2
4
4
2
1
3
1
3
4
2
Fig. 3.2: Sudoku Square H.
H∼
=p S because H is obtained from S by permutation
1→2
2→4
3→3
4 → 1.
3. Sudoku Enumeration
38
Remark 3.2. Digits in a Sudoku Square are merely symbols. So permutation of digits is not changing the puzzle, in the sense that if we have a
Sudoku Puzzle P having solution Q and Puzzle R equivalent to P by some
permutation of symbols σ, then Sudoku Square T obtained from Q by same
permutation σ is a solution of R.
1
2
4
3
Fig. 3.3: Sudoku Puzzle P.
2
4
1
3
Fig. 3.4: Sudoku Puzzle R.
Observe that R∼
=p P (above) by a permutation σ and that a solution of R
can be obtained by same permutation σ from solution of P (and vice versa).
So,
N umber of solutions of R = N umber of solutions of P .
3. Sudoku Enumeration
39
We are interested to know all such relations between two puzzles R and P
that preserve the above equality. Those relations, apart from equivalence up
to permutation of digits, are the following:(1) equivalence up to rotation
(2) equivalence up to reflection
(3) equivalence up to permutation of rows within a band
(4) equivalence up to permutation of columns within a strip
Definition 3.3. Let S be a Sudoku Square of rank n. If a Sudoku square
H can be obtained by rotating whole of S clockwise or anti-clockwise then S
and H are said to be equivalent up to rotation, denoted as H∼
=rot S.
2
4
3
1
Fig. 3.5: Sudoku Puzzle P.
1
2
4
3
Fig. 3.6: Sudoku Puzzle R.
R∼
=rot P because R is obtained by 90o rotation of P in clockwise
sense
3. Sudoku Enumeration
40
Definition 3.4. Let S be a Sudoku Square of rank n. If a Sudoku square H
can be obtained by reflection of whole of S about any horizontal line or vertical line then S and H are said to be equivalent up to reflection, denoted
as H∼
=ref S.
2
4
3
1
Fig. 3.7: Sudoku Puzzle P.
1
3
4
2
Fig. 3.8: Sudoku Puzzle R.
R∼
=ref P because R is obtained by reflection of P about x-axis.
Recall bands and strips of Sudoku grid (Definition 1.13. on page 6).
Definition 3.5. Let S be a Sudoku Square of rank n. If a Sudoku square H
can be obtained by permuting rows within a specified band of S, then S and
H are said to be equivalent up to permutation of rows within a band
(Definition 1.13.), denoted as H∼
=b S.
3. Sudoku Enumeration
41
2
4
3
1
Fig. 3.9: Sudoku Puzzle P.
4
2
3
1
Fig. 3.10: Sudoku Puzzle R.
R∼
=b P because R is obtained by exchanging rows in the upper
band of P.
Definition 3.6. Let S be a Sudoku Square of rank n. If a Sudoku square H
can be obtained by permuting columns within a specified strip of S, then S
and H are said to be equivalent up to permutation of columns within
a strip (Definition 1.13.), denoted as H∼
=s S.
Definition 3.7. Let S be a Sudoku Square of rank n. If a Sudoku square
H can be obtained by a finite sequence of transformations as described in
above definitions (Definitions 3.1, 3.3, 3.4, 3.5, 3.6) like permutation of digits, rotation, reflection and permutation of rows within a band and columns
within a strip or any combination of these transformations then S and H are
said to be equivalent, denoted as H∼
=S.
3. Sudoku Enumeration
42
2
4
3
1
Fig. 3.11: Sudoku Puzzle P.
2
4
3
1
Fig. 3.12: Sudoku Puzzle R.
R∼
=b P because R is obtained by exchanging columns in the right
hand side strip of P.
Remark 3.8. By combinatorial computation techniques, we get 2 types of
Filled Sudoku (Sudoku Square) of rank 2: Symmetric (S) and Antisymmetric
(A) Sudoku Squares such that given any Filled Sudoku F of rank 2,
then either F∼
=S or F∼
=A but not both. In other words, given any
Sudoku Square it can be obtained from either S or A (but not both) through
combination of permutation of digits, rotation, reflection and permutation of
rows (columns) within band (strip).
3. Sudoku Enumeration
1
2
3
4
3
4
1
2
2
1
4
3
4
3
2
1
43
Fig. 3.13: Symmetric Sudoku Square S.
1
2
3
4
3
4
2
1
2
1
4
3
4
3
1
2
Fig. 3.14: Anti-symmetric Sudoku Square A.
Remark 3.9. Observe that both Symmetric and Anti-symmetric Sudoku
Squares have same entries in 12 common cells.
1
3
2
4
2 3 4
4
1 4 3
3
Fig. 3.15: Common entries of A and S
The Symmetric and the Anti-symmetric Sudoku Squares lead to classification of Sudoku squares into two classes.
Set of Sudoku Squares equivalent to Symmetric Sudoku Square S is denoted
as [S].
3. Sudoku Enumeration
44
Set of Sudoku Squares equivalent to Anti-symmetric Sudoku Square A is denoted as [A].
It follows from Remark 3.8. that
[S] ∪ [A]is the space of all Sudoku Squares of Rank 2 and
[S] ∩ [A] = φ .
If a Sudoku Puzzle has just 3 entries to begin with then it can be shown
that the three entries can be arranged to filled cells as shown in Fig. 3.15 by
permutation of digits, rotation, reflection and permutation of rows (columns)
within a band (strip). But Sudoku Puzzle in Fig. 3.15 has multiple solutions,
namely the Symmetric and Anti-symmetric Sudoku Squares. This gives us
the following result.
Theorem 3.10. A Sudoku puzzle of rank 2 having a unique solution must
begin with at least 4 initial entries. (Proof idea discussed in the above paragraph.)
3.2
Three Famous Theorems
Definition 3.11. Permanent of a n × n square matrix A = (aij ), denoted
as per(A), is the sum
X
a1σ(1) a2σ(2) ....anσ(n)
σ∈Sn
where Sn is the set of all permutations on n symbols.
It follows from the definition that if A is a n × n and c is a constant then
per(cA) = cn per(A) .
Definition 3.12. A n × n square matrix A = (aij ) is said to be doubly
stochastic if both row sum and column sum are equal to 1. Mathematically,
3. Sudoku Enumeration
45
∀i, j ∈ {1, 2, ..., n}
ith
o row sum =
Pn
ai o j = 1
joth column sum =
Pn
aijo = 1 .
j=1
i=1
Matrix A is said to be just stochastic if all the row sums are equal to 1.
In 1926 B. L. van der Waerden suggested the problem of determining
the minimal permanent among all n × n doubly stochastic matrices. He
conjectured the statement of the following theorem which was later proved
in 1981 by D.I. Falikman [3] and G.P. Egoritsjev [2].
Theorem 3.13. Denote the set of all n × n doubly stochastic matrices with
non-negative real entries as Dn . Then for all A ∈ Dn
per(A) ≥ n!/nn
Equality is attained for the matrix












1/n 1/n . . . 1/n

1/n 1/n . . . 1/n 

.
.
. 


.
.
. 

.
.
. 

1/n 1/n . . . 1/n n×n
Falikman’s proof can be seen in [3] and Egoritsjev’s proof can be seen in [2].
In 1967 H. Minc conjectured the statement of the following theorem which
was proved in 1973 by L.M. Bregman.[1]
Theorem 3.14. If A = (aij ) is n × n (0, 1) matrix, i.e. aij ∈ {0, 1}, ∀i, j ∈
3. Sudoku Enumeration
46
{1, 2, ..., n}, with ith -row sum ri , then
n
Y
per(A) ≤
(ri !)1/ri .
i=1
Proof can be seen in Bregman’s article [1].
Definition 3.15. Let A1 , A2 , ..., An be subsets of the set {1, 2, ..., n}. If for
all i ∈ {1, 2, ..., n}, ∃ an ai ∈ Ai such that the collection {a1 , a2 , ..., an } =
{1, 2, ..., n} then the ordered collection (a1 , a2 , ..., an ) is called a system of
distinct representatives, written as sdr in short, of the ordered collection
(A1 , A2 , ..., An ).
It follows, clearly, that ai = aj if and only if i = j.
A result called the Marriage Theorem tells us exactly when it is possible to have a system of distinct representatives. Let us work towards an
understanding of this result.
Theorem 3.16. Marriage Theorem
Let A1 , A2 , ..., An be subsets of the set {1, 2, ..., n}. A system of distinct representatives of (A1 , A2 , ..., An ) if and only if ∀ subsets S of {1, 2, ..., n},
| ∪i∈S Ai | ≥ |S|.
Proof. ”⇒ ”
Let (a1 , a2 , ..., an ) be a sdr of (A1 , A2 , ..., An ) and S be any subset of {1, 2, ..., n}.
As elements of the above sdr are distinct, we get |S| = |∪i∈S {ai }| ≤ |∪i∈S Ai |.
”⇐”
We will proceed by induction on n where is the number of subsets in (A1 , A2 , ..., An )
which are subsets of {1, 2, ..., n}.
If n=1, then the converse statement of the theorem trivially holds true because the only option is A1 = {1}. Let p > 1. Assume the converse statement
is true for all n < p.
3. Sudoku Enumeration
47
It suffices to show that the converse statement is true for n = p. Without
loss of generality, let A1 be the set with least number of elements out of the
sets A1 , A2 , ..., and Ap . Define Ti = {i + 1, i + 2, ..., p}, ∀i ∈ {0, 1, 2, ..., p − 1}
and Tp = φ. By hypothesis for the converse theorem statement
p = |T0 | ≤ |A1 ∪ A2 ∪ ... ∪ Ap | ≤ |{1, 2, ..., p}| = p,
so | ∪pi=1 Ai | = p
and n − 1 = |T1 | ≤ |A2 ∪ A3 ∪ ... ∪ Ap | ≤ |{1, 2, ..., p}| = p,
so | ∪pi=2 Ai | = p or p − 1.
If | ∪pi=2 Ai | = p − 1 then ∃ an element a1 ∈ A1 such that a1 ∈
/ ∪pi=2 Ai .
If | ∪pi=2 Ai | = p then ∃ an element a1 ∈ A1 such that there are p − 1 elements
other than a1 in A2 ∪ A3 ∪ ... ∪ An , i.e. {1, 2, ..., n} \ {a1 } ⊂ ∪pi=2 Ai .
In either case,
∃ an element a1 in A1 such that (A2 ∪ A3 ∪ ... ∪ An ) \ {a1 } = {1, 2, .., p} \ {a1 }.
Now the ordered sets (A2 \ {a1 }, A3 \ {a1 }, ..., Ap \ {a1 }) satisfies the hypothesis of the converse statement of the theorem because each set A2 , A3 , ..., Ap
had more elements than A1 .
So by induction hypothesis (A2 \ {a1 }, A3 \ {a1 }, ..., Ap \ {a1 }) has an sdr
call it (a2 , a3 , ..., ap ). This together with {a1 } gives us (a1 , (a2 , a3 , ..., ap ))
which is a sdr of (A1 , A2 , ..., An ). Thus the result.
Definition 3.17. Let A1 , A2 , ..., An be subsets of the set {1, 2, ..., n}. A n×n
matrix H = (hij , where hij = 1 if i ∈ Aj and 0 otherwise, is called Hall matrix of the ordered collection (A1 , A2 , ..., An ).
Example 3.18. Let A1 = {1, 2}, A2 = {2, 4}, A3 = {1, 2, 3} and A4 =
3. Sudoku Enumeration
48
{3}, then its hall matrix is






1
1
0
0
0
1
0
1
1
1
1
0
0
0
1
0






4×4
Theorem 3.19. If A1 , A2 , ..., An are subsets of the set {1, 2, ..., n} then total
number of systems of distinct representatives of (A1 , A2 , ..., An ) is equal to
per(H), where H is the Hall matrix of (A1 , A2 , ..., An ).
Proof. Let the H = (hij ). In the evaluation of per(H), the product corresponding to a particular permutation σ that is h1σ(1) h2σ(2) ....hnσ(n) is 1 precisely when i ∈ Aσ(i) for all i ∈ {1, 2, ..., n}, otherwise the product equals to 0.
So the permanent counts the number of permutations σ for which i ∈ Aσ(i)
for all i ∈ {1, 2, ..., n}. But i ∈ Aσ(i) for all i is equivalent with σ−1 (i) ∈ Aσ(i)
for all i which means precisely that (σ −1 (1), σ −1 (2), ..., σ −1 (n)) is a sdr for
(A1 , A2 , ..., An ). So each such permutation σ gives an sdr of (A1 , A2 , ..., An ).
Thus the number of ways to select an sdr for A is at least equal to per(H).
Now, any sdr, say (y1 , y2 , ..., yn ) of (A1 , A2 , ..., An ) arises from such a permutation, since its elements y1 , y2 , ..., yn are all different and they are in
{1, 2, .., n}. Hence per(H) is at least equal to the number of ways to select
an sdr of (A1 , A2 , ..., An ).
Hence the result.
3.3
Number of Latin Squares
2
Theorem 3.20. Number of Latin Squares of rank n is at least (n!)2n /nn
3. Sudoku Enumeration
49
Proof. Consider an empty n × n grid. Recall from definition of Latin square
that an entry does not repeat in any row, i.e. E(io , j) = E(io , k) if and only
if j = k. So by Counting Principle (Appendix 1.)
the number of ways of f illing the 0th row R0 = n! .
Note that the row is filled in a way that it satisfies the conditions of being a
row of latin square.
Assume for some k ∈ {1, 2, ..., n − 1}, the starting k rows R0 , R1 , ..., Rk−2
and Rk−1 are already filled such that the k × n filled grid formed by these
rows satisfies the Latin Square conditions, i.e. digits do not repeat in a row
or column. Let (k, j) be an arbitrary cell in the (k)th row and it cannot have
an entry which has already occurred in the same column in which (k, j) cell
lies. Define Aj to be subset of {1, 2, ..., n} containing all elements that can
be filled in (k, j) cell without repetition of digits in the column. So
Aj = {1, 2, ..., n} \ {E(0, j), E(1, j), ..., E(k − 1, j)}, ∀j ∈ {0, 1, ..., n − 1} .
Aj is constructed by removing the elements that have already occurred in
the j th column. Elements in all cells above (k, j), as shown on the next page.
Lets assume we fill the row Rk in a way that it satisfies the Latin square
conditions (i.e. no digit repeats in any row and column) then
(E(k, 0), E(k, 1), ..., E(k, n − 1)) is a sdr of (A0 , A1 , ..., An−1 ). On the other
hand any sdr (a0 , a1 , ..., an−1 ) of (A0 , A1 , ..., An−1 ) can also be used to fill the
Rk satisfying Latin square condition by defining E(k, j) = aj . So
number of ways of f illing Rk = N umber of sdr0 s of (A0 , A1 , ..., An−1 ) .
Let H be the hall matrix of (A0 , A1 , ..., An−1 ). By Theorem 3.19.,
number of ways of f illing Rk = per(H) .
3. Sudoku Enumeration
50
j
k
(k,j)
Fig. 3.16: Entries to be Excluded from Cells above the (k,j) cell
Row sum of each row of Hall matrix H = n − k. This follows from the
fact that each Aj (∀j ∈ {0, 1, 2, ..., n − 1}) has n − k elements. Similarly
Column sum of each column of H is n − k. Thus the matrix H/(n − k) is
a doubly stochastic matrix with non-negative entries. By Theorem 3.13. we
get, per(H/(n − k)) ≥ n!/nn ⇒ per(H) ≥ (n − k)n n!/nn . So,
number of ways of f illing Rk ≥ (n − k)n n!/nn .
3. Sudoku Enumeration
51
By Counting Principle (Appendix 1.),
number of Latin Squares ≥
n−1
Y
(n − k)n n!/nn
k=0
= (n!)n nn (n − 1)n ...(1)n /(nn )n
2)
= (n!)n (n!)n /n(n
2
= (n!)2n /nn .
Definition 3.21. Big O
A function defined on the set of Natural numbers N is said to be of the order
of g(n), denoted as O(g(n)) where g(n) is another function on Natural numbers, if |f (n)/g(n)| is a bounded function, i.e. |f (n)/g(n)| < M, for some
positive real number M and ∀n ∈ N.
Let f (n) = O(g(n)). Big O indicates that if the function f (n) tends to
∞ (or −∞) then it approaches slower than some constant multiple of g(n)
since |f (n)| < M |g(n)| for some real number M .
Theorem 3.22. Stirling formula
log(n!) = n(log(n)) − n + (1/2)log(n) + O(1)
. O(1) represents some bounded function.
Theorem 3.23. Number of Latin Squares of rank n2 is greater than
4
n2n /e2n
4 +O(n2 log(n))
.
Proof. By Theorem 3.20, Number of Latin squares of rank n2 is at least
3. Sudoku Enumeration
2
52
4
(n2 !)2n /n2n . By Stirling formula,
2
log(n2 !)2n
= 2n2 [n2 log(n2 ) − n2 + (log(n2 ))/2 + O(1)]
= 2n2 [2n2 log(n) + log(n) − n2 + O(1)]
= 4n4 log(n) + 2n2 log(n) − 2n4 + O(n2 )
since 2n2 O(1) = O(n2 ).
So
2
4
2
log((n2 !)2n /n2n )
4
= log((n2 !)2n ) − log(n2n )
= [4n4 log(n) + 2n2 log(n) − 2n4 + O(n2 )] − 2n4 log(n)
= 2n4 log(n) − 2n4 + 2n2 log(n) + O(n2 )
4
= log(n2n ) − 2n4 + O(n2 log(n))
since 2n2 log(n) + O(n2 ) = O(n2 log(n)).
2
4
2n4 )−2n4 +O(n2 log(n))
Hence (n2 !)2n /n2n = elog(n
proved.
3.4
4
4 +O(n2 log(n))
= n2n /e2n
. Hence
Number of Filled Sudokus
Theorem 3.24. Number of Filled Sudokus of rank n is less than
4
n2n
e2.5n4 +O(n3 log(n))
.
Proof. Consider an empty Sudoku grid of rank n.
N umber of ways of f illing the f irst row R0 , denoted N (R0 ) = n2 ! .
Take an arbitrary cell (1, j) in the second row R1 , then we have n2 − n
possibilities to fill this cell since we already used n digits in the first row of
the corresponding block in which the cell lies. Define Aj to be the possible
3. Sudoku Enumeration
53
entries for the (1, j) cell, the set of possible entries. Let H be the Hall matrix
of (A0 , A1 , ...An2 −1 ). So by Theorem 3.17. number of ways of filling the
second row is equal to per(H). Note that each row sum of the Hall matrix H
Q 2
2
we have got is n2 −n. So by Theorem 3.13, per(H) ≤ ni=1 ((n2 −n)!)1/n −n =
2
2
((n2 − n)!)n /n −n . Let N (Ri ) be the number of ways of filling the ith row.
So,
2 /n2 −n
N umber of ways of f illing the second row R1 = N (R1 ) ≤ ((n2 −n)!)n
.
Similarly, for remaining rows in the first strip, i.e. rows R2 , R3 , ..., till Rn−1 ,
N (R2 ) ≤ ((n2 − 2n)!)n
2 /n2 −2n
N (R3 ) ≤ ((n2 − 3n)!)n
2 /n2 −3n
.
.
.
.
.
2 /n2 −(n−1)n
N (Rn−1 ) ≤ ((n2 − (n − 1)n)!)n
.
However as we enter the first row of the second strip the above technique
does not work because the block in which these cells lie are empty. Here
the method of constructing the set of possible entries of the cell is different.
Consider a cell (n, j) in (n + 1)st row Rn . It cannot have the n entries that
have already been entered in the column in which (n, j) cell belongs. Define
Bj to be set of possible entries for (n, j) cell. So |Bj | = n2 − n. Again
constructing the Hall matrix of (B0 , B1 , ..., Bn2 −n ) and using Theorem 3.17.
and 3.13., we get
2 /n2 −n
N umber of ways of f illing the (n+1)st row Rn = N (Rn ) ≤ ((n2 −n)!)n
Notice that the upper bound of the number of ways of filling a row depends
on the choice of the set of possible entries. So far we have shown two ways
of constructing the set of possible entries for a cell:-
.
3. Sudoku Enumeration
54
(1) Block method: From {1, 2, ...., n2 } we eliminate entries that have already occurred in the block in which the cell C lies. Call the block in which
cell C lies to be B and assume C is in the k th row of that block B. Let Bk
be the set of all entries in the block B, which happen to be the entries in the
first k − 1 rows of the block B. This way the set of possible entries for the
cell C is equal to {1, 2, ..., n2 } \ Bk which has exactly n2 − (k − 1)n digits.
Cells above C
in its block
Cell C
3. Sudoku Enumeration
55
(2) Column method: From {1, 2, ...., n2 } we eliminate entries that have
already occurred in the column in which the cell C lies. Call the column in
which cell C lies to be Col and assume cell C lies in the rth row of Col. Let
Colr be the set of all entries already present in the column Colr m which
happens to be precisely the entries in first r − 1 rows of Colr . This way the
set of possible entries for the cell C is equal to {1, 2, ..., n2 } \ Bk which has
exactly n2 − (r − 1) digits.
Notice that smaller the set of possible entries then more accurate (i.e.
smaller) is the upper bound for N (Ri ), ∀i ∈ {1, 2, ..., n2 − 1}. Thus to find
a reasonably small and most accurate upper bound for the number of Filled
Sudokus, we need to choose that method, out of Block and Column methods,
which gives us the set of possible entries for a given cell to be of the smallest
cardinality.
Consider the ith band of the Sudoku grid for some i ∈ {1, 2, ..., n}. It consists of rows R(i−1)n+1 , R(i−1)n+2 , R(i−1)n+3 , ..., till R(i−1)n+n (= Rin ). For cells
in the first i rows in the ith band, set of possible entries of the cell found
using the Column method has lesser digits than the set of possible entries
of the cell found using the Block method. On the other hand, for cells in
the last n − i rows of the ith band, set of possible entries of the cell found
using Block method has lesser digits than the set of possible entries of the
cell found using the Column method.
For instance, in a Sudoku grid of rank 3, consider the cells (4, j) and (5, j ∗ ),
both in the second band. Set of possible entries for cell (4, j) using Column
method will have 5 elements < 6 which is the number of elements of the set
of possible entries constructed using Block method. On the other hand the
set of possible entries for cell (5, j ∗ ) using Column method has 4 elements >
3 which is the number of elements of the set of possible entries constructed
using Block method. Notice R4 is the second row of the second band.
So in the ith band of the Sudoku grid of rank n consisting of rows
R(i−1)n+1 , R(i−1)n+2 , R(i−1)n+3 , ..., till R(i−1)n+n (= Rin ), use column method in
rows R(i−1)n+1 , R(i−1)n+2 , ..., till R(i−1)n+i
3. Sudoku Enumeration
56
and block method in R(i−1)n+i+1 , R(i−1)n+i+2 , ..., till R(i−1)n+n to come up with
the sets of possible entries for cells in that row.
R4 (column method) →
///////
///////
///////
///////
///////
///////
///////
///////
///////
/////////////
/
−−
| |
−−
\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\\\\
−−
| |
← R5 (block method)
−−
Fig. 3.17: Possible entries = {1, 2, ..., 9} \ {entries in the shaded cells}.
3. Sudoku Enumeration
57
Then finding corresponding Hall matrix and applying theorem 3.14 and
3.17, we compute upper bound for the number of ways of filling these rows.
We get,
2
2
N (R(i−1)n+1 ) ≤ ((n2 − (i − 1)n)!)n /n −(i−1)n
2 /n2 −(i−1)n−1
N (R(i−1)n+2 ) ≤ ((n2 − (i − 1)n − 1)!)n
.
.
.
2 /n2 −(i−1)n−i+1
N (R(i−1)n+i ) ≤ ((n2 − (i − 1)n − i + 1)!)n
N (R(i−1)n+i+1 ) ≤ ((n2 − in)!)n
2 /n2 −in
2 /n2 −(i+1)n
N (R(i−1)n+i+2 ) ≤ ((n2 − (i + 1)n)!)n
.
.
.
N (Rin ) ≤ ((n2 − (n − 1)n)!)n
2 /n2 −(n−1)n
= (n!)n .
Now by counting principle, total number of Filled Sudoku’s is bounded above
Q 2
by nj=0−1 N (Ri ) ≤ the following
n
Y
n2
2
2 −(i−1)n
n
[(n − (i − 1)n)!]
i=1
n2
×[(n2 − [(i − 1)n + 1])!] n2 −[(i−1)n+1]
n2
× · · · × [(n2 − [(i − 1)n + i])!] n2 −[(i−1)n+i]
n2
×[(n2 − in)!] n2 −in
n2
× · · · × [(n2 − (n − 1)n)!] n2 −(n−1)n
Call the right hand side of above inequality as RHS.
3. Sudoku Enumeration
58
By using the Stirling formula and the computational technique as demonstrated in the proof of Theorem 3.23. we can show that
RHS ≤
n2n
4
e2.5n4 +O(n3 log(n))
.
Example 3.25. Consider a Sudoku grid of rank 3.
M ethod to be used
N umber of ways to f ill the rows
Column →
N (R0 ) = 9!
Block →
N (R1 ) ≤ 6!9/6
Block →
N (R2 ) ≤ 3!9/3
Column →
N (R3 ) ≤ 6!9/6
Column →
N (R4 ) ≤ 5!9/5
Block →
N (R5 ) ≤ 3!9/3
Column →
N (R6 ) ≤ 3!9/3
Column →
N (R7 ) ≤ 2!9/2
Column →
N (R8 ) = 1
As mentioned in the above proof, to calculate the upper bound of the
3. Sudoku Enumeration
59
number of ways of filling the rows of Sudoku grid, we will use either column
method or block method that helps in calculating a more accurate (smaller)
upper bound.
For rows R1 , R2 and R5 we use the block method.
For rows R3 , R4 , R6 , R7 and R8 , we use column method
For the starting row, using either column or block method, we get the same
result: N (R0 ) ≤ 9!
For other rows it is
9
N (R1 ) ≤ 6! 6 ,
9
N (R5 ) ≤ 3! 3 ,
9
9
N (R2 ) ≤ 3! 3 ,
9
N (R6 ) ≤ 3! 3 ,
N (R3 ) ≤ 6! 6 ,
9
N (R7 ) ≤ 2! 2 ,
9
N (R4 ) ≤ 5! 5 ,
9
N (R8 ) ≤ 1! 1 = 1 .
Thus, by Counting Principle Appendix 1., the total number of Sudoku squares
(Filled Sudokus) is ≤ Product of RHS of all the above inequalities which is
9
9
(9!) × ((6!)3 ) × ((3!)9 ) × ((2!) 2 ) × ((5!) 5 ) = 1.7071945 × 1026
Theorem 3.26. Let
pn =
number of Sudoku squares of rank n
number of Latin squares of rank n2
then
pn ≤
1
e0.5n4 +O(n3 log(n))
.
So pn −→ 0 as n −→ ∞.
Proof. It follows from Theorem 3.23. and 3.24.
This tells us that number of Sudoku squares (rank n) is substantially
smaller than the number of Latin square (rank n2 ) for larger and larger n.
APPENDIX
Appendix
.1
61
Counting Principle
In combinatorics, the counting principle (a.k.a. the fundamental principle
of counting), stated simply, is the idea that if there are n ways of doing
some task A and for each of those ways there are m ways doing another
task B, then the total number of ways of performing both the actions is nm.
Mathematically,
let S1 and S2 be two f inite sets then
|S1 × S2 | = |S1 ||S2 | .
Example .27. Task A: Choose location of travel.
Assume the possible ways are to go North, South, East or West.
Task B: Choose mode of travel.
Assume the possible ways for each location are to travel by road, rail or air.
Total number of possible outcomes are 4 × 3 = 12
(1) Travel north by road
(2) Travel north by rail
(3) Travel north by air
(4) Travel south by road
(5) Travel south by rail
(6) Travel south by air
(7) Travel east by road
(8) Travel east by rail
(9) Travel east by air
(10) Travel west by road
(11) Travel west by rail
(12) Travel west by air
Appendix
.2
62
Polynomial
Definition .28. A (complex or real) polynomial in variable x is a function
of the form
p(x) =
n
X
ai xi = an xn + an−1 xn−1 + ... + a1 x + a0 , f or some n ∈ N
i=0
where ai are are complex or real constants called the coefcients of the polynomial.
If am 6= 0 and for all i > m we have ai = 0 then p(x) is said to be a
polynomial of degree n. If all ai = 0, ∀i ∈ {0, 1, 2, ..., n} then p(x) is called
a zero polynomial. A polynomial of degree n is said to be monic if an = 1.
A number x0 is called a root of p(x) if p(x0 ) = 0.
Theorem .29. Fundamental Theorem of Algebra
Let p(x) be a non-zero polynomial of degree n with complex coefcients. Then
p(x) has n roots, when repeated roots are counted up to their multiplicity.
[reference to be added]
Theorem .30. Let P (x) and Q(x) be two monic polynomials, and assume
that there exists an integer m such that P (λ) = Q(λ) for all integers λ with
λm. Then P (x) = Q(x).
Proof. Assume there exists Q(x) which equals P (x) for all λm. Assume that
the maximum of the degrees of P (x) and Q(x) is n. Then (P − Q)(x) is a
polynomial of degree n with an innite number of roots. This contradicts the
Fundamental Theorem of Algebra.
Theorem .31. Let p(x) be a nonzero polynomial of degree n with integer
coefcients and a be an integer root of p(x). Then p(x) = (x − a)q(x), where
q(x) is a polynomial of degree n − 1 and has integer coefcients.
Appendix
63
Proof. We will do this by induction on n which is the degree of p(x). Assume
that an is the leading coefcient of p(x).
If n = 1, then p(x)/an p(x) and x − a are two monic polynomials with the
same roots (since both have one root). By above theorem, p(x)/an = x − a,
so we may choose q(x) = an , which clearly satises the conditions.
For n > 1, assume the theorem statement is true for all polynomials with
degree n∗ < n. Let p∗ (x) = p(x) − an xn−1 (x − a). Since an xn−1 (x − a)
is a polynomial of degree n with an as its leading coefcient, and it has all
integer coefcient, we have that p∗ (x) has integer coefcients and the degree
of p∗ (x) is some n∗ , where n∗ < n. Also, p∗ (a) = p(a) − (an an−1 )(0) = 0.
Therefore by the induction hypothesis there is a polynomial q ∗ (x) that has
degree n∗ − 1 ≤ n − 2 that has integer coefcients and p∗ (x) = (x − a)q ∗ (x).
Therefore
p(x) = q ∗ (x)(x − a) + an xn−1 (x − a) = (x − a)(an xn−1 + q ∗ (x)),
and choosing
q(x) = an xn−1 + q ∗ (x),
we have a q(x) a polynomial of degree n − 1 with all integer roots. This
proves theorem.
BIBLIOGRAPHY
[1] L. M. Brègman. Certain properties of nonnegative matrices and their
permanents. Dokl. Akad. Nauk SSSR, 211:27–30, 1973.
[2] G. P. Egoritsjev. Solution of van der waerdens permanent conjecture.
Advances in Math., 42:731–740, 1981.
[3] D. I. Falikman. Proof of the van der Waerden conjecture on the permanent of a doubly stochastic matrix. Mat. Zametki, 29(6):931–938, 957,
1981.
[4] Frank Harary. Graph theory. Naraosa Publishing House, 2001.
[5] Agnes M. Herzberg and M. Ram Murty. Sudoku squares and chromatic
polynomials. Notices Amer. Math. Soc., 54(6):708–717, 2007.
Download