Skip to content

pysmt/pysmt

Repository files navigation

pySMT: a Python API for SMT

CI Status

Coverage

Documentation Status

Latest PyPI version

Apache License

Google groups

pySMT makes working with Satisfiability Modulo Theory simple:

  • Define formulae in a simple, intuitive, and solver independent way
  • Solve your formulae using one of the native solvers, or by wrapping any SMT-Lib compliant solver,
  • Dump your problems in the SMT-Lib format,
  • and more...

PySMT Architecture Overview

Usage

A More Complex Example

Is there a value for each letter (between 1 and 9) so that H+E+L+L+O = W+O+R+L+D = 25?

Portfolio

Portfolio solving consists of running multiple solvers in parallel. pySMT provides a simple interface to perform portfolio solving using multiple solvers and multiple solver configurations.

Using other SMT-LIB Solvers

Check out more examples in the examples/ directory and the documentation on ReadTheDocs

Supported Theories and Solvers

pySMT provides methods to define a formula in Linear Real Arithmetic (LRA), Real Difference Logic (RDL), Equalities and Uninterpreted Functions (EUF), Bit-Vectors (BV), Arrays (A), Strings (S) and their combinations. The following solvers are supported through native APIs:

Additionally, you can use any SMT-LIB 2 compliant solver.

PySMT assumes that the python bindings for the SMT Solver are installed and accessible from your PYTHONPATH.

Installation

You can install the latest stable release of pySMT from PyPI:

$ pip install pysmt

this will additionally install the pysmt-install command, that can be used to install the solvers: e.g., :

$ pysmt-install --check

will show you which solvers have been found in your PYTHONPATH. PySMT does not depend directly on any solver, but if you want to perform solving, you need to have at least one solver installed. This can be used by pySMT via its native API, or passing through an SMT-LIB file.

The script pysmt-install can be used to simplify the installation of the solvers:

$ pysmt-install --msat

will install MathSAT 5.

By default the solvers are downloaded, unpacked and built in your home directory in the .smt_solvers folder. Compiled libraries and actual solver packages are installed in the relevant site-packages directory (e.g. virtual environment's packages root or local user-site). pysmt-install has many options to customize its behavior. If you have multiple versions of python in your system, we recommend the following syntax to run pysmt-install: python -m pysmt install.

Note: This script does not install required dependencies for building the solver (e.g., make or gcc) and has been tested mainly on Linux Debian/Ubuntu systems. We suggest that you refer to the documentation of each solver to understand how to install it with its python bindings.

For Yices, picosat, and CUDD, we use external wrappers:

For instruction on how to use any SMT-LIB complaint solver with pySMT see examples/generic_smtlib.py

For more information, refer to online documentation on ReadTheDocs

Solvers Support

The following table summarizes the features supported via pySMT for each of the available solvers.

Solver pySMT name Supported Theories Quantifiers Quantifier Elimination Unsat Core Interpolation
MathSAT

msat

UF, LIA, LRA, BV, AX

No

msat-fm, msat-lw Yes Yes
Z3

z3

UF, LIA, LRA, BV, AX, NRA, NIA

Yes

z3 Yes No
CVC4

cvc4

UF, LIA, LRA, BV, AX, S

Yes

No No No
Yices

yices

UF, LIA, LRA, BV

No

No No No
Boolector

btor

UF, BV, AX

No

No No No
SMT-Lib Interface

<custom>

UF, LIA, LRA, BV, AX

Yes

No No No
PicoSAT

picosat

[None]

No

[No] No No
BDD (CUDD)

bdd

[None]

Yes

bdd No No

License

pySMT is released under the APACHE 2.0 License.

For further questions, feel free to open an issue, or write to pysmt@googlegroups.com (Browse the Archive).

If you use pySMT in your work, please consider citing:

@inproceedings{pysmt2015,
  title={PySMT: a solver-agnostic library for fast prototyping of SMT-based algorithms},
  author={Gario, Marco and Micheli, Andrea},
  booktitle={SMT Workshop 2015},
  year={2015}
}