sparse madasatrix sudoku
DESCRIPTION
usefulTRANSCRIPT
40 IEEE SIGNAL PROCESSING LETTERS, VOL. 17, NO. 1, JANUARY 2010
Linear Systems, Sparse Solutions, and SudokuPrabhu Babu, Kristiaan Pelckmans, Petre Stoica, Fellow, IEEE, and Jian Li, Fellow, IEEE
Abstract—In this paper, we show that Sudoku puzzles can beformulated and solved as a sparse linear system of equations. Webegin by showing that the Sudoku ruleset can be expressed as anunderdetermined linear system: � , where is of sizeand . We then prove that the Sudoku solution is the sparsestsolution of � , which can be obtained by � norm mini-mization, i.e.��� � s.t. � . Instead of this minimizationproblem, inspired by the sparse representation literature, we solvethe much simpler linear programming problem of minimizing the� norm of , i.e. ��� � s.t. � , and show numerically
that this approach solves representative Sudoku puzzles.
Index Terms—Linear systems, � norm minimization, � normminimization, sparse representation, Sudoku.
I. INTRODUCTION
S UDOKU is a logic-based number-placement puzzle whichis usually solved by hand for fun. For example, a 9 9
Sudoku puzzle may look as in Fig. 1. The initial set of occu-pied cells are called the “clues” of the puzzle. The objective isto fill the empty cells in the puzzle such that the digitsoccur only once in each row, each column and each 3 3 box.There are various computer algorithms available for solving Su-doku based on, e.g., backtracking, brute force search, stochasticsearch, set covering methods, and constraint programming [1],[2]. Recently [3] proposed a Sinkhorn balancing algorithm tosolve the puzzle.
In this paper, we show that the puzzle ruleset can be expressedas an underdetermined linear system. We then prove that theSudoku solution is the sparsest solution of this linear systemand hence it can be obtained by norm minimization. How-ever, solving a norm minimization problem is hard in gen-eral, so we solve the much simpler problem of minimizing the
norm and show numerically that this approach solves repre-sentative Sudoku puzzles. This result establishes a connectionbetween the task of solving Sudoku and the emerging field ofsparse signal representation [4]–[6].
This paper is organized as follows. Section II shows how theruleset of the puzzle can be expressed as an underdeterminedlinear system. Section III proves the main result of the paper that
norm minimization solves Sudoku. In Section IV, we shownumerically that norm minimization solves representative Su-
Manuscript received July 23, 2009; revised August 29, 2009. First publishedSeptember 18, 2009; current version published October 14, 2009. This workwas supported in part by the Swedish Research Council. The associate editorcoordinating the review of this manuscript and approving it for publication wasProf. Kenneth E. Barner.
P. Babu, K. Pelckmans, and P. Stoica are with the Department of InformationTechnology, Uppsala University, Uppsala SE 75105, Sweden (e-mail: [email protected]; [email protected]; [email protected]).
J. Li is with Department of Electrical and Computer Engineering, Universityof Florida, Gainesville, FL 32611 USA (e-mail: [email protected]).
Digital Object Identifier 10.1109/LSP.2009.2032489
Fig. 1. Example of a 9 � 9 Sudoku puzzle.
doku puzzles and briefly mention the conditions for equivalenceof the solutions to the and norm minimization problems.Section V concludes the paper.
II. SUDOKU RULESET AS A LINEAR SYSTEM
Let denote an Sudoku puzzle with a unique solu-tion. As in [3], the content of cell of is denoted by
for , with the cells enumeratedin row order. Let
denote the indicator vector associated with cell , whereis the indicator function that is equal to one when
and zero otherwise. Let denote a vector of sizeconstructed as
...(1)
Taking the 9 9 Sudoku puzzle shown in Fig. 1 as an ex-ample, the four types of constraints that one needs to satisfy tosolve the puzzle are as follows.
• Row constraints: Each row of should comprise all digits.
• Column constraints: Each column of should comprise alldigits .
• Box constraints: Each 3 3 highlighted box of shouldcomprise all digits .
• Cell constraints: Each cell of should be filled.The cell constraints listed above are redundant as any of theother three types of constraints will ensure that all the cells of
are filled. However, we retain them as they will be neededwhen we relax the puzzle problem in the next section. Each ofthe above constraints and the clues can be expressed as linearequality constraints on the elements of . For example for thepuzzle in Fig. 1, the constraint that the first row of shouldcomprise all the digits can be expressed as
...
(2)
1070-9908/$26.00 © 2009 IEEE
BABU et al.: LINEAR SYSTEMS, SPARSE SOLUTIONS, AND SUDOKU 41
where denotes the 9 9 identity matrix and de-notes a matrix of size 9 648 with all elements equal to zero.Similarly the constraint that the first column of should con-tain all digits can be expressed as shown in (3), shownat the bottom of the page.The constraint that the 3 3 box in thetop-left corner of should contain all digits can be ex-pressed as shown in (4), shown at the bottom of the page, where
(5)
The constraint that the first cell should be filled can be ex-pressed as
(6)
i.e.,
(7)
Finally, the clues can also be expressed as linear equality con-straints on . For example, the clue that cell takes the value1 can be expressed as
(8)
i.e.,
(9)
By combining all these constraints, the linear equality con-straints on can be expressed in generic form as
...
(10)
where , , , , and denote the matricesassociated with the different constraints on the elements of .For an puzzle, the size of is given by ,where denotes the number of clues. For the 9 9 puzzle inFig. 1, the size of is 355 729 and hence the linear system(10) is underdetermined and has an infinite number of solutions.However, evidently, not all the solutions of (10) lead to a validSudoku solution. In fact, for a puzzle with a unique solutionthere is only one solution , with the elements of made onlyof 0’s and 1’s. Hereafter, we will call the Sudoku solution.
III. NORM MINIMIZATION
As implied by the above discussion, the Sudoku solutionis sparse, that is it has few nonzero elements. To be more precise
is sparse (i.e. it has elements different from zero, outof elements). Consider the following optimization problem:
(11)
where represents the number of nonzero elements in . Letdenote the solution of .
Proposition: For a puzzle with a unique solution, , wehave that .
Proof: If we show that , the unique solution of , is thesparsest solution of (10), then the theorem is proved. We knowthat . Let us assume that there exists an
...
such that and . This implies that at leastone in should be equal to . But this violatesthe cell constraint that every cell in should be filled, i.e., forany , , where . Thus cannot bea solution to (10); this means that all feasible solutions of (10)must satisfy where the equalityholds only for . For any other , there will be atleast one with and hence is the unique sparsestsolution of (10), i.e. .
Finding the sparsest solution of (10) might not be a hardproblem, as the solution has lot of structure that could be ex-ploited in the search. However, it is not obvious how to ex-ploit this structure, and without doing so solving an normminimization problem is hard in general. Therefore following[4]–[6] we relax the problem and instead solve a simpler normminimization problem.
IV. NORM MINIMIZATION
We determine by solving the problem
(12)
where . Let denote the solution of ;while it is not guaranteed that , similarly to what hap-pens in the sparse representation literature [4]–[6], solves
...(3)
...(4)
42 IEEE SIGNAL PROCESSING LETTERS, VOL. 17, NO. 1, JANUARY 2010
TABLE ICOMPARISON OF LINPRO, SINKHORN [3] AND BINTPROG [2] FOR � � �����'',
� � ��� �'', � � �����'' AND � � �����'' PUZZLES
Fig. 2. Example of a tricky Sudoku puzzle.
most Sudoku puzzles, that is for most puzzles finds thesparsest that solves (10). The algorithm based on is called“Linpro”, as requires solving a linear program [which canbe efficiently done by means of standard software packages (seee.g., [7])].
We have considered numerous Sudoku puzzles of varyinglevels of difficulty in which the puzzles and their designatedlevel of difficulty are given in [8], [9]. In most cases Linprogave the exact Sudoku solution. For example, Linpro success-fully solved 200 puzzles of dimensions 9 9 and 16 16 from[8]. Table I compares the performance of Linpro, the Sinkhornbalancing algorithm (“Sinkhorn”) of [3] and the binary integerprogramming method (“Bintprog”) of [2] for puzzles of fourdifferent levels of difficulty. The puzzles which were used fortesting the different methods in Table I are chosen randomlyfrom [9] and they can be found along with the Matlab code forthe Linpro algorithm in [10]. It is seen from Table I that bothLinpro and Sinkhorn have higher success rates than Bintprog.
Finally, we comment on the equivalence between and. In the context of Sudoku, analyzing the conditions under
which is equivalent to may shed light on the class ofvery hard Sudoku puzzles. For example, Linpro fails to solvethe tricky puzzle shown in Fig. 2 which is mentioned in [3]as one of the puzzles that cannot be solved by Sinkhorn. TheLinpro algorithm successfully completes only 17 cells out of 55empty cells of the puzzle; in other words Linpro fails to find thesparsest solution of the linear system associated with the puzzle.To tackle this problem, following [11], we tried using the it-erative reweighted norm minimization algorithm outlined inTable II; this algorithm solved the puzzle by finding the sparsestsolution of the underlying linear system. The Bintprog methodalso solved the tricky puzzle.
The presently known sufficient conditions on for checkingthe equivalence of and , like the restricted isometry prop-erty (RIP) [5], and Kashin, Garnaev, Gluskin (KGG) inequality[6], do not hold for Sudoku. So analyzing the equivalence of
TABLE IIITERATIVE REWEIGHTED � NORM-MINIMIZATION
ALGORITHM FOR SOLVING SUDOKU
and norm solutions in the context of Sudoku requires novelconditions for sparse recovery. Deriving such conditions is be-yond the scope of this letter.
V. CONCLUSIONS
Inspired by [2] and [3], we showed that the Sudoku rulesetcan be expressed as a linear system of equations. We then provedthat seeking the minimum norm solution of this linear systemwill solve the puzzle. We then finally showed numerically thatthe simpler problem of minimizing the norm of the solutionsolves many representative Sudoku puzzles. Thus this paper il-lustrates an interesting example of how norm minimizationcan be used to solve Sudoku.
ACKNOWLEDGMENT
The authors thank T. K. Moon for providing us with 200 Su-doku puzzles in electronic format and the Matlab codes of [3].
REFERENCES
[1] Wikipedia, Algorithmics of Sudoku—Wikipedia, The Free Encyclo-pedia 2009, [Online; accessed 13-May-2009].
[2] A. Bartlett and A. Langville, “An integer programming model for theSudoku problem,” J, Online Math. Applicat., vol. 8, 2008.
[3] T. K. Moon, J. H. Gunther, and J. Kupin, “Sinkhorn solves Sudoku,”IEEE Trans. Inform. Theory, vol. 55, no. 4, pp. 1741–1746, Apr. 2009.
[4] S. Chen, D. Donoho, and M. Saunders, “Atomic decomposition bybasis pursuit,” SIAM Rev., pp. 129–159, 2001.
[5] E. Candes, J. Romberg, and T. Tao, “Robust uncertainty principles:Exact signal reconstruction from highly incomplete frequency infor-mation,” IEEE Trans. Inform. Theory, vol. 52, no. 2, pp. 489–509, Feb.2006.
[6] Y. Zhang, A Simple Proof for Recoverability of L1-Minimization: GoOver or Under? Rice Univ., Houston, TX, CAAM Tech. Rep. TR05-09,2005.
[7] M. Grant, S. Boyd, and Y. Ye, CVX: Matlab Software for Dis-ciplined Convex Programming [Online]. Available: http://stan-ford.edu/~boyd/cvx
[8] M. Huckvale, The Big Book of Su Doku. London, U.K.: Orion, 2005.[9] Website. [Online]. Available: http://www.websudoku.com/
[10] Website. [Online]. Available: http://www.it.uu.se/katalog/praba420/Codes.rar
[11] E. Candès, M. Wakin, and S. Boyd, “Enhancing sparsity by reweightedl1 minimization,” J. Fourier Anal. Applicat, vol. 14, no. 5, pp. 877–905,2008.