All Projects → pysmt → Pysmt

pysmt / Pysmt

Licence: apache-2.0
pySMT: A library for SMT formulae manipulation and solving

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pysmt

Stp
Simple Theorem Prover, an efficient SMT solver for bitvectors
Stars: ✭ 341 (-3.12%)
Mutual labels:  verification, smt
Sat smt by example
"SAT/SMT by example" free ebook
Stars: ✭ 339 (-3.69%)
Mutual labels:  verification, smt
Liquidhaskell
Liquid Types For Haskell
Stars: ✭ 863 (+145.17%)
Mutual labels:  verification, smt
Fstar
A Proof-oriented Programming Language
Stars: ✭ 2,171 (+516.76%)
Mutual labels:  verification, smt
Stainless
Verification framework and tool for higher-order Scala programs
Stars: ✭ 241 (-31.53%)
Mutual labels:  verification, smt
Alive2
Automatic verification of LLVM optimizations
Stars: ✭ 199 (-43.47%)
Mutual labels:  verification, smt
Sbv
SMT Based Verification in Haskell. Express properties about Haskell programs and automatically prove them using SMT solvers.
Stars: ✭ 125 (-64.49%)
Mutual labels:  verification, smt
clpsmt-miniKanren
CLP(SMT) on top of miniKanren
Stars: ✭ 31 (-91.19%)
Mutual labels:  constraints, smt
Smack
SMACK Software Verifier and Verification Toolchain
Stars: ✭ 305 (-13.35%)
Mutual labels:  verification, smt
Swiftqueue
Job Scheduler for IOS with Concurrent run, failure/retry, persistence, repeat, delay and more
Stars: ✭ 276 (-21.59%)
Mutual labels:  constraints
Stevia
🍃 Concise Autolayout code
Stars: ✭ 3,182 (+803.98%)
Mutual labels:  constraints
Tool lists
Links to tools by subject
Stars: ✭ 270 (-23.3%)
Mutual labels:  verification
Concuerror
Concuerror is a stateless model checking tool for Erlang programs.
Stars: ✭ 277 (-21.31%)
Mutual labels:  verification
Prusti Dev
A static verifier for Rust, based on the Viper verification infrastructure.
Stars: ✭ 302 (-14.2%)
Mutual labels:  verification
Cupcake
An easy way to create and layout UI components for iOS (Swift version).
Stars: ✭ 273 (-22.44%)
Mutual labels:  constraints
Wpf Math
.NET library for rendering mathematical formulae using the LaTeX typsetting style, for the WPF framework
Stars: ✭ 339 (-3.69%)
Mutual labels:  formula
Seahorn
SeaHorn Verification Framework
Stars: ✭ 270 (-23.3%)
Mutual labels:  verification
Gophersat
gophersat, a SAT solver in Go
Stars: ✭ 300 (-14.77%)
Mutual labels:  constraints
Verifier
Package verifier provides simple defensive programing primitives.
Stars: ✭ 264 (-25%)
Mutual labels:  verification
Jace
Jace.NET is a calculation engine for the .NET platform.
Stars: ✭ 296 (-15.91%)
Mutual labels:  formula

=========================== pySMT: a Python API for SMT

.. image:: https://dev.azure.com/micheliandrea/PySMT/_apis/build/status/pysmt.pysmt?branchName=master :target: https://dev.azure.com/micheliandrea/PySMT/_build/latest?definitionId=1&branchName=master :alt: Build Status

.. image:: https://coveralls.io/repos/github/pysmt/pysmt/badge.svg :target: https://coveralls.io/github/pysmt/pysmt :alt: Coverage

.. image:: https://readthedocs.org/projects/pysmt/badge/?version=latest :target: https://pysmt.readthedocs.io/en/latest/ :alt: Documentation Status

.. image:: https://img.shields.io/pypi/v/pysmt.svg :target: https://pypi.python.org/pypi/pySMT/ :alt: Latest PyPI version

.. image:: https://img.shields.io/pypi/l/pysmt.svg :target: /LICENSE :alt: Apache License

.. image:: https://img.shields.io/badge/Browse%20the%20Archive-Google%20groups-orange.svg :target: https://groups.google.com/d/forum/pysmt :alt: 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...

.. image:: https://cdn.rawgit.com/pysmt/pysmt/master/docs/architecture.svg :alt: PySMT Architecture Overview

Usage

.. code:: python

from pysmt.shortcuts import Symbol, And, Not, is_sat

varA = Symbol("A") # Default type is Boolean varB = Symbol("B") f = And(varA, Not(varB)) f (A & (! B)) is_sat(f) True g = f.substitute({varB: varA}) g (A & (! A)) is_sat(g) False

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?

.. code:: python

from pysmt.shortcuts import Symbol, And, GE, LT, Plus, Equals, Int, get_model from pysmt.typing import INT

hello = [Symbol(s, INT) for s in "hello"] world = [Symbol(s, INT) for s in "world"] letters = set(hello+world) domains = And([And(GE(l, Int(1)), LT(l, Int(10))) for l in letters])

sum_hello = Plus(hello) # n-ary operators can take lists sum_world = Plus(world) # as arguments problem = And(Equals(sum_hello, sum_world), Equals(sum_hello, Int(25))) formula = And(domains, problem)

print("Serialization of the formula:") print(formula)

model = get_model(formula) if model: print(model) else: print("No solution found")

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.

.. code:: python

from pysmt.shortcuts import Portfolio, Symbol, Not

x, y = Symbol("x"), Symbol("y") f = x.Implies(y)

with Portfolio(["cvc4", "yices", ("msat", {"random_seed": 1}), ("msat", {"random_seed": 17}), ("msat", {"random_seed": 42})], logic="QF_UFLIRA", incremental=False, generate_models=False) as s: s.add_assertion(f) s.push() s.add_assertion(x) res = s.solve() v_y = s.get_value(y) print(v_y) # TRUE

 s.pop()
 s.add_assertion(Not(y))
 res = s.solve()
 v_x = s.get_value(x)
 print(v_x) # FALSE

Using other SMT-LIB Solvers

.. code:: python

from pysmt.shortcuts import Symbol, get_env, Solver from pysmt.logics import QF_UFLRA

name = "mathsat-smtlib" # Note: The API version is called 'msat'

Path to the solver. The solver needs to take the smtlib file from

stdin. This might require creating a tiny shell script to set the

solver options.

path = ["/tmp/mathsat"] logics = [QF_UFLRA,] # List of the supported logics

Add the solver to the environment

env = get_env() env.factory.add_generic_solver(name, path, logics)

The solver name of the SMT-LIB solver can be now used anywhere

where pySMT would accept an API solver name

with Solver(name=name, logic="QF_UFLRA") as s: print(s.is_sat(Symbol("x"))) # True

Check out more examples in the examples/ directory </examples>_ and the documentation on ReadTheDocs <http://pysmt.readthedocs.io>_

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 </examples/generic_smtlib.py>_

For more information, refer to online documentation on ReadTheDocs <http://pysmt.readthedocs.io>_

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 | z3 | z3 | Yes | Yes | +------------------+-----------+--------------------------------+-------------+------------------------+------------+--------------+ | 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| | 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 [email protected]m (Browse the Archive <https://groups.google.com/d/forum/pysmt>_).

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

.. code::

@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} }

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].