kr-sat-solver
A built-from-scratch Python-based SAT Solver implementing the DPLL-recursive algorithm. Research and implementations for the Knowledge Representation course at Vrije Universiteit Amsterdam
Science Score: 49.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 1 DOI reference(s) in README -
✓Academic publication links
Links to: acm.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.5%) to scientific vocabulary
Keywords
Repository
A built-from-scratch Python-based SAT Solver implementing the DPLL-recursive algorithm. Research and implementations for the Knowledge Representation course at Vrije Universiteit Amsterdam
Basic Info
Statistics
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
VU Knowledge Representation - SAT solving
This repo contains a group project from the course Knowledge Representation (2024-25) at the Vrije Universiteit Amsterdam (VU). The task was a) to create a Boolean Satisfiability (SAT) solver to resolve Sudoku Puzzles and b) to write a report answering an experimental research question related to the SAT solver.
SAT Solver
We implemented the SAT solver from scratch using the Davis Putnam Logemann-Loveland (DPLL) algorithm. The SAT solver can take any file in Clause Normal Form (CNF) with a constraint satisfaction problem in DIMACS format and returns whether it is satisfiable or unsatisfiable. In case the CNF is satisfiable, a satisfying assignment is also returned. For the purpose of our research, we additionally implemented seven branching heuristics: Random, MOMSf, one-sided and two-sided Jeroslow-Wang, DLIS, DLCS, and a custom-created Human heuristic. We used Sudokus of the classic 9x9 format to test and optimize the heuristics used for this SAT solver. You can find more details on the algorithm and heuristics in the attached report.
Research Experiment
Modern Sudoku puzzles are often created by automated systems. This means that their difficulty is assessed by a program (such as a SAT solver) rather than a human. While both SAT solvers and humans can solve Sudoku puzzles, their approaches are very different. Our research experiment investigated these differences by exploring whether using human-inspired heuristics in the SAT solver would lead to more human-like patterns in the difficulty metrics. For this purpose, we compared difficulty metrics for our SAT solver using all of the implemented heuristics mentioned above with the difficulty experienced by humans in a large Sudoku dataset. While the main findings suggest that human-inspired heuristics in an SAT solver do not lead to more human-like difficulty patterns compared to regular SAT solvers, an interesting outcome was the overall lack of available empirical data on human difficulty in solving Sudoku. Future research is thus encouraged to develop new metrics for measuring human difficulty, to empirically test them on a large number of players, and to allow open access to the resulting data sets.
Getting Started
These instructions will give you a copy of the project up and running on your local machine.
Prerequisites
Requirements for the software and other tools to build, test and push - Python 3.10 or higher
Installing
This codebase was programmed using python 3.10.1. The requirements.txt file contains all the need packages to run the code succesfully.
Download this code base by running the following line in your terminal:
git clone https://github.com/mklblm/KR-SAT-Solver
Install all required packages by running the following line in your terminal:
pip install -r requirements.txt
Running the SAT-solver
Run the SAT-solver by running the following line in terminal, inputing the relevant parameters.
python SAT.py -Sn -Pb inputfile
n = an integer from 1-9 representing the heuristic to run. See the 'heuristics' section below showing which integer represents which heuristc.
b = a boolean indicating whether a visualization of the final assignment should be shown (this only works for 9x9 sudokus).
inputfile = the path to a .cnf file containing problem to solve in DIMACS format.
Heuristics
All heuristics use the same standard DPLL algorithm including tautology solving, pure literal elimination, and unit propagation. The heuristics differ in the way a literal is chosen for branching:
- DPLL (First available literal)
- Random
- DLCS (Dynamic Largest Combined Sum)
- DLIS (Dynamic Largest Individual Sum)
- Jeroslow-Wang one-sided
- Jeroslow-Wang two-sided
- MOMS (Maximum Occurrences in Minimum Size)
- MOMSF (Maximum Occurrences in Minimum Size with a Frequency-based weighting factor)
- Naked multiple (HUMAN)
Example
Below is an example command that can be used to solve a 9x9 sudoku puzzle.
python SAT.py -S1 -PTrue data/sudokus/DIMACS/9x9/sudoku_1_9x9.cnf
An outputfile will be created with the final assignment of all clauses in DIMACS format. A visualization of the solution to the sudoku puzzle will be plotted as well.
Authors
License
This project is licensed under the MIT License - see the LICENSE file for details
Owner
- Name: Mikel Blom
- Login: mklblm
- Kind: user
- Location: Library of 904
- Repositories: 1
- Profile: https://github.com/mklblm
GitHub Events
Total
- Fork event: 1
Last Year
- Fork event: 1
Dependencies
- matplotlib ==3.8.4
- numpy ==1.26.3
- pandas ==2.2.2