Skip to main content

Bridging deep learning and logical reasoning using a differentiable satisfiability solver

Project description

SATNet • PyPi colab License

Bridging deep learning and logical reasoning using a differentiable satisfiability solver.

This repository contains the source code to reproduce the experiments in the ICML 2019 paper SATNet: Bridging deep learning and logical reasoning using a differentiable satisfiability solver by Po-Wei Wang, Priya L. Donti, Bryan Wilder, and J. Zico Kolter.

What is SATNet

SATNet is a differentiable (smoothed) maximum satisfiability (MAXSAT) solver that can be integrated into the loop of larger deep learning systems. This (approximate) solver is based upon a fast coordinate descent approach to solving the semidefinite program (SDP) associated with the MAXSAT problem.

How SATNet works

A SATNet layer takes as input the discrete or probabilistic assignments of known MAXSAT variables, and outputs guesses for the assignments of unknown variables via a MAXSAT SDP relaxation with weights S. A schematic depicting the forward pass of this layer is shown below. To obtain the backward pass, we analytically differentiate through the SDP relaxation (see the paper for more details).

Forward pass

Overview of experiments

We show that by integrating SATNet into end-to-end learning systems, we can learn the logical structure of challenging problems in a minimally supervised fashion. In particular, we show that we can:

  • Learn the parity function using single-bit supervision (a traditionally hard task for deep networks)
  • Learn how to play 9×9 Sudoku (original and permuted) solely from examples.
  • Solve a "visual Sudoku" problem that maps images of Sudoku puzzles to their associated logical solutions. (A sample "visual Sudoku" input is shown below.)


Via pip

pip install satnet

From source

git clone
cd SATNet && python install

Package Dependencies

conda install -c pytorch tqdm

The package also depends on the nvcc compiler. If it doesn't exist (try nvcc from commandline), you can install it via

conda install -c conda-forge cudatoolkit-dev

Via Docker image

cd docker
sh ./
sh ./

Running experiments

Jupyter Notebook and Google Colab

Jupyter notebook and Google Colab

Run them manually

Getting the datasets

The Sudoku dataset and Parity dataset can be downloaded via

wget -cq && unzip -qq
wget -cq && unzip -qq

Sudoku experiments (original, permuted, and visual)

python exps/
python exps/ --perm
python exps/ --mnist --batchSz=50

Parity experiments

python exps/ --seq=20
python exps/ --seq=40

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

satnet-0.1.4.tar.gz (10.3 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page