skillfed

pycosat

bindings to picosat (a SAT solver)

pycosat v0.6.6 241.6K downloads/30d#8,873 on PyPI194
Permissive license MIT Active released

What it is and what it does

pycosat wraps PicoSAT, a mature C-based SAT solver, into Python bindings that run at the C level. When you import pycosat, the solver becomes part of your Python process, avoiding subprocess overhead. The package includes the picosat source code (from picosat-965.tar.gz) so no external installation is needed, but compilation during install is required.

You represent constraint problems as clauses—lists of integers where the sign indicates negation and the absolute value identifies a variable. The main API consists of `solve()`, which returns a single satisfying assignment or "UNSAT"/"UNKNOWN", and `itersolve()`, which yields all solutions as an iterator. Both support propagation limits, variable counts, and verbosity control. This makes it suitable for problems like configuration validation, logic puzzles, and constraint-based reasoning where you need to find or enumerate satisfying assignments.

Use it for:

  • Solve constraint satisfaction problems like Sudoku or logic puzzles by encoding them as CNF clauses and finding valid variable assignments.
  • Enumerate all possible solutions to a satisfiability problem using itersolve() to explore solution spaces efficiently.
  • Validate software configurations or dependency constraints by encoding them as logical clauses and checking satisfiability.
  • Build automated reasoning or planning systems that need to find variable assignments satisfying a set of logical constraints.
  • Prototype SAT-based algorithms without the overhead of calling an external solver process.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides efficient Python bindings to PicoSAT, a C-based Boolean satisfiability (SAT) solver, allowing you to solve constraint satisfaction problems by finding variable assignments that satisfy logical clauses.

Yes, if you need a lightweight SAT solver integrated directly into Python and are willing to compile a C extension. The package is mature, actively maintained, permissively licensed, and has no known vulnerabilities. High install friction due to compilation is the main trade-off; avoid it if you prefer pure-Python dependencies or already have a preferred SAT solver.

Install

pycosat on PyPI

pip

pip install pycosat

uv

uv add pycosat

poetry

poetry add pycosat

Installing pycosat

Before you install

High install friction: the package requires compilation from source (C extension). Maintenance is active with recent commits, but the latest release is over two years old, which may indicate a stable but not actively developed state.

License in practice

MIT license is permissive and places no significant restrictions on use, modification, or redistribution in commercial or private projects.

Quickstart

import pycosat
cnf = [[1, -5, 4], [-1, 5, 3, 4], [-3, -4]]
solution = pycosat.solve(cnf)
print(solution)  # [1, -2, -3, -4, 5]

# Or iterate over all solutions
for sol in pycosat.itersolve(cnf):
    print(sol)

Requires a C compiler and build tools to compile the C extension during installation. The picosat source is bundled, but compilation is necessary.

Verify before relying

  • Whether the package is actively maintained or in maintenance-only mode given the two-year gap since the last release.
  • Performance characteristics compared to other SAT solvers for large-scale problems.
  • Whether propagation limits and verbosity options are sufficient for typical use cases.

Package facts

License MIT (permissive)
Python support not specified
Install friction high — source build required
Runtime dependencies none
Maintenance actively maintained — 1,046 days since the last release
Last repo commit
First released
Downloads 241,612/month — #8,873 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pycosat-0.6.6.tar.gz

Development Status :: 6 - MatureIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: CProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Utilities

Tags

SAT solver pythonboolean satisfiability solverconstraint satisfaction pythonpicosat bindingsCNF formula solverlogic puzzle solver
sat-solverconstraint-satisfactionc-extension

More Utilities packages