










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











1 - Introduction: Sudoku is a widely popular logic-based number puzzle that consists of a 9×9 grid, subdivided into 3×3 subgrids. The objective is to fill the grid so that each row, column, and subgrid contains the numbers 1 to 9 exactly once. Due to its structured constraints, Sudoku can be transformed into a Boolean Satisfiability (SAT) problem , where each cell's value is represented as a Boolean variable in a logical formula to find a truth assignment that satisfies all logical constraints—ensuring that each row, column, and subgrid obeys Sudoku rules. This allows Sudoku to be tackled using SAT solvers. While deterministic SAT-solving techniques could be applied in this problem, they can be inefficient for large-scale instances. As an alternative approach, probabilistic algorithms such as WalkSAT utilizes randomized local search and iteratively flips variable assignments to satisfy more clauses while incorporating random moves to escape local optima to achieve more practical results. By modeling WalkSAT’s execution as a Markov Chain , the analyze of its behavior using Random Walk theory is applied, where each state represents a potential Sudoku assignment and each transition corresponds to a probabilistic modification of the solution.
2 - Problem Statement Rule 1: A Sudoku puzzle is represented by a 9×9 grid, which comprises nine 3×3 sub-grids (also called boxes). Some of the entries in the grid are filled with numbers from 1 to 9, whereas other entries are left blank. Rule 2: A Sudoku puzzle is solved by assigning numbers from 1 to 9 to the blank entries such that every row, every column, and every 3×3 sub-grid contains each of the nine possible numbers. In this problem, we will consider Sudoku puzzles with these properties: Property 1 Sudoku puzzles that have only one solution. Property 2 Sudoku puzzles that can be solved with only reasoning, i.e., with no search. To illustrate how to solve a Sudoku puzzle, let us consider entry (a) in the left-hand grid of Figure 2.
b-Sudoku Constraints as CNF Clauses: The constraints to be added to our SAT encoding refer to each entry, each row, each column and each 3x3 sub-grid, as illustrated in Figure 3. We may either use the minimal or the extended encoding, but given the context of our use case— which involves modeling WalkSAT's execution as a Markov Chain and analyzing its behavior using Random Walk theory, we tend to adopt the extended encoding to ensure a well-defined constraint structure. The extended encoding consists of the following logical constraints: 1.Each cell contains exactly one number:
2.Each number appears exactly once per row:
In the context of our use case, WalkSAT treats the Sudoku puzzle as a SAT instance, where each variable represents a cell's assignment and each clause enforces a Sudoku constraint (row, column, and subgrid rules). The algorithm randomly explores possible assignments, continuously flipping variables until a valid Sudoku solution is found or a stopping condition is met. WalkSAT algorithm for Sudoku is considered random walk on a Markov chain where each state represents a Sudoku grid with a certain number of unsatisfied constraints with:
- States: Each state represents a partially completed Sudoku grid, which includes the current assignments for all cells in the grid, and contains number of constraint violations ( valid Sudoku solution would have 0 constraint violations , with: S 0 is the initial state with a random Sudoku grid. Sn is the final solution state, where all constraints are satisfied (no violations). - Actions (Transitions): At each state, the WalkSAT algorithm picks an unsatisfied clause (a constraint violation) and flips the value of a variable by changing the number in one of the grid cells), considered transition from one state to another.
The recurrence relation for E[Ni] is: where:
pE[Ni+ 1 ] represents the expected steps if a greedy move is taken. qE[Ni− 1 ] represents the expected steps if a random move is taken. Where: α=p/q Time Complexity Analysis: The complexity of WalkSAT depends on the value of p:
- When p<1/2: The expected time grows exponentially with the problem size n, giving us: 4 - Implementation:
6 - Results: