--- id: pycosat version: "0.6.6" license: MIT license_treatment: permissive maintenance: active --- # pycosat — bindings to picosat (a SAT solver) License: permissive · Maintenance: active · Downloads: 241.6K/mo ## 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 above — 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 pip install pycosat uv add pycosat 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: unspecified - Install friction: high - Maintenance: active - Downloads: 241.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags SAT solver python, boolean satisfiability solver, constraint satisfaction python, picosat bindings, CNF formula solver, logic puzzle solver, sat-solver, constraint-satisfaction, c-extension [View on SkillFed](https://skillfed.io/packages/pycosat) · [View on PyPI](https://pypi.org/project/pycosat/)