Perception-based constraint solving for sudoku images

Maxime Mulamba, Jayanta Mandi, Ali Irfan Mahmutogullari, Tias GunsConstraints An Int. J 2024 · DOI

Abstract

This paper presents a neuro-symbolic framework for solving Sudoku puzzles directly from real-world images. By integrating a convolutional neural network (CNN) for perception with constraint programming for logical reasoning, the system effectively bridges the "perception-reasoning gap." The approach formulates Sudoku solving as a joint optimization problem, allowing the system to correct its own classifier errors and detect human mistakes in handwritten entries. Experimental results on challenging real-world datasets demonstrate superior accuracy and robustness compared to traditional sequential pipelines.

Introduction

The "perception-reasoning gap" is a fundamental challenge in artificial intelligence. While deep learning excels at pattern recognition (perception), it often struggles with rigid logical rules (reasoning). Conversely, symbolic solvers are logically perfect but cannot process raw sensory data. In a standard sequential pipeline, an Optical Character Recognition (OCR) error in just one of the 81 cells can lead a symbolic solver to conclude that a puzzle is unsatisfiable.

Comparison of a well-formed Sudoku and one containing user mistakes.

This paper proposes a hybrid model where the "eyes" (CNN) and the "brain" (Constraint Solver) interact to find the most likely, logically valid solution. This is particularly important for real-world applications where images may be blurry or contain human errors, such as duplicate digits in a row.

Methods

The proposed framework moves beyond simple sequential processing by adopting a hybrid modeling approach:

  1. Perception Layer (Cell-CNN): Individual cells are classified using a CNN. This modular approach is data-efficient and allows for transfer learning.
  2. Calibration: To prevent the neural network from being overconfident in its errors, Matrix Scaling is used to ensure output probabilities accurately reflect model uncertainty.
  3. Constraint Solving Layer (COP): The problem is formulated as a Constraint Optimization Problem (COP). The objective is to maximize the joint log-likelihood of the grid based on CNN probabilities while strictly adhering to Sudoku's symbolic constraints.
  4. Style-Aware Reasoning: The system classifies digits as either printed (givens) or handwritten (user input). This allows the solver to treat handwritten digits as "wildcards" if they cause logical conflicts, effectively correcting human errors.
The neuro-symbolic architecture integrating a Perception Layer (CNN) with a Constraint Solving Layer.

Results and Discussion

The framework was evaluated on several datasets, including the "Sudoku Assistant App Dataset," which features real-world smartphone photos with perspective distortion and shadows.

  • Error Correction: While a baseline sequential approach failed on over 20% of images due to minor classification errors, the joint inference approach achieved near-perfect accuracy on clean datasets.
  • Robustness to Noise: On the challenging Assistant App dataset, the system achieved a grid accuracy of 96.13%, significantly outperforming other neuro-symbolic methods.
  • Human Error Recovery: In tests where five human errors were intentionally introduced, the style-aware prior allowed the system to maintain a 90% accuracy rate, whereas standard solvers failed completely.

Conclusion

By treating perception as a calibrated input to a constraint optimizer, this research demonstrates a robust method for solving complex, rule-based tasks from raw data. The system's ability to identify and bypass human mistakes highlights the power of integrating logical priors into deep learning frameworks. Future work will focus on improving computational efficiency for real-time mobile applications and exploring weakly-supervised learning techniques.

Summary updated

BibTeX
@article{mulamba2024perception,
  author = {Maxime Mulamba and Jayanta Mandi and Ali Irfan Mahmutogullari and Tias Guns},
  title = {{Perception-based constraint solving for sudoku images}},
  journal = {Constraints An Int. J.},
  year = {2024},
  doi = {10.1007/s10601-024-09372-9},
}
Figure