{"id":15008891,"url":"https://github.com/pysmt/pysmt","last_synced_at":"2025-05-15T05:07:59.132Z","repository":{"id":23976949,"uuid":"27359780","full_name":"pysmt/pysmt","owner":"pysmt","description":"pySMT: A library for SMT formulae manipulation and solving","archived":false,"fork":false,"pushed_at":"2025-05-12T11:48:21.000Z","size":5077,"stargazers_count":592,"open_issues_count":92,"forks_count":137,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-12T12:41:10.512Z","etag":null,"topics":["constraints","formula","python","python-3","satisfiability-modulo-theories","smt","verification"],"latest_commit_sha":null,"homepage":"http://www.pysmt.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pysmt.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-12-01T02:52:26.000Z","updated_at":"2025-05-12T11:48:24.000Z","dependencies_parsed_at":"2024-06-05T10:56:13.706Z","dependency_job_id":"fd6a55f1-fce7-4bd5-a15a-4029c7e851f1","html_url":"https://github.com/pysmt/pysmt","commit_stats":{"total_commits":1215,"total_committers":40,"mean_commits":30.375,"dds":0.5053497942386831,"last_synced_commit":"71c35b0b82f7ea63240218777940bed06a18c60c"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pysmt%2Fpysmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pysmt%2Fpysmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pysmt%2Fpysmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pysmt%2Fpysmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pysmt","download_url":"https://codeload.github.com/pysmt/pysmt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254276447,"owners_count":22043867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["constraints","formula","python","python-3","satisfiability-modulo-theories","smt","verification"],"created_at":"2024-09-24T19:21:29.727Z","updated_at":"2025-05-15T05:07:54.123Z","avatar_url":"https://github.com/pysmt.png","language":"Python","readme":"===========================\npySMT: a Python API for SMT\n===========================\n\n.. image:: https://github.com/pysmt/pysmt/actions/workflows/test.yml/badge.svg\n           :target: https://github.com/pysmt/pysmt/actions\n           :alt: CI Status\n\n.. image:: https://coveralls.io/repos/github/pysmt/pysmt/badge.svg\n           :target: https://coveralls.io/github/pysmt/pysmt\n           :alt: Coverage\n\n.. image:: https://readthedocs.org/projects/pysmt/badge/?version=latest\n           :target: https://pysmt.readthedocs.io/en/latest/\n           :alt: Documentation Status\n\n.. image:: https://img.shields.io/pypi/v/pysmt.svg\n           :target: https://pypi.python.org/pypi/pySMT/\n           :alt: Latest PyPI version\n\n.. image:: https://img.shields.io/pypi/l/pysmt.svg\n           :target: /LICENSE\n           :alt: Apache License\n\n.. image:: https://img.shields.io/badge/Browse%20the%20Archive-Google%20groups-orange.svg\n           :target: https://groups.google.com/d/forum/pysmt\n           :alt: Google groups\n\n\npySMT makes working with **Satisfiability Modulo Theory** simple:\n\n* Define formulae in a *simple*, *intuitive*, and *solver independent* way\n* Solve your formulae using one of the native solvers, or by wrapping\n  any SMT-Lib compliant solver,\n* Dump your problems in the SMT-Lib format,\n* and more...\n\n.. image:: https://cdn.rawgit.com/pysmt/pysmt/master/docs/architecture.svg\n           :alt: PySMT Architecture Overview\n\nUsage\n=====\n\n.. code:: python\n\n   \u003e\u003e\u003e from pysmt.shortcuts import Symbol, And, Not, is_sat\n   \u003e\u003e\u003e\n   \u003e\u003e\u003e varA = Symbol(\"A\") # Default type is Boolean\n   \u003e\u003e\u003e varB = Symbol(\"B\")\n   \u003e\u003e\u003e f = And(varA, Not(varB))\n   \u003e\u003e\u003e f\n   (A \u0026 (! B))\n   \u003e\u003e\u003e is_sat(f)\n   True\n   \u003e\u003e\u003e g = f.substitute({varB: varA})\n   \u003e\u003e\u003e g\n   (A \u0026 (! A))\n   \u003e\u003e\u003e is_sat(g)\n   False\n\n\nA More Complex Example\n----------------------\n\nIs there a value for each letter (between 1 and 9) so that H+E+L+L+O = W+O+R+L+D = 25?\n\n.. code:: python\n\n  from pysmt.shortcuts import Symbol, And, GE, LT, Plus, Equals, Int, get_model\n  from pysmt.typing import INT\n\n  hello = [Symbol(s, INT) for s in \"hello\"]\n  world = [Symbol(s, INT) for s in \"world\"]\n  letters = set(hello+world)\n  domains = And([And(GE(l, Int(1)),\n                     LT(l, Int(10))) for l in letters])\n\n  sum_hello = Plus(hello) # n-ary operators can take lists\n  sum_world = Plus(world) # as arguments\n  problem = And(Equals(sum_hello, sum_world),\n                Equals(sum_hello, Int(25)))\n  formula = And(domains, problem)\n\n  print(\"Serialization of the formula:\")\n  print(formula)\n\n  model = get_model(formula)\n  if model:\n    print(model)\n  else:\n    print(\"No solution found\")\n\n\nPortfolio\n---------\n\nPortfolio solving consists of running multiple solvers in\nparallel. pySMT provides a simple interface to perform portfolio\nsolving using multiple solvers and multiple solver configurations.\n\n.. code:: python\n\n   from pysmt.shortcuts import Portfolio, Symbol, Not\n\n   x, y = Symbol(\"x\"), Symbol(\"y\")\n   f = x.Implies(y)\n\n   with Portfolio([\"cvc5\",\n                   \"yices\",\n                   (\"msat\", {\"random_seed\": 1}),\n                   (\"msat\", {\"random_seed\": 17}),\n                   (\"msat\", {\"random_seed\": 42})],\n                  logic=\"QF_UFLIRA\",\n                  incremental=False,\n                  generate_models=False) as s:\n     s.add_assertion(f)\n     s.push()\n     s.add_assertion(x)\n     res = s.solve()\n     v_y = s.get_value(y)\n     print(v_y) # TRUE\n\n     s.pop()\n     s.add_assertion(Not(y))\n     res = s.solve()\n     v_x = s.get_value(x)\n     print(v_x) # FALSE\n\n\nUsing other SMT-LIB Solvers\n---------------------------\n\n.. code:: python\n\n   from pysmt.shortcuts import Symbol, get_env, Solver\n   from pysmt.logics import QF_UFLRA\n\n   name = \"mathsat-smtlib\" # Note: The API version is called 'msat'\n\n   # Path to the solver. The solver needs to take the smtlib file from\n   # stdin. This might require creating a tiny shell script to set the\n   # solver options.\n   path = [\"/tmp/mathsat\"]\n   logics = [QF_UFLRA,]    # List of the supported logics\n\n   # Add the solver to the environment\n   env = get_env()\n   env.factory.add_generic_solver(name, path, logics)\n\n   # The solver name of the SMT-LIB solver can be now used anywhere\n   # where pySMT would accept an API solver name\n   with Solver(name=name, logic=\"QF_UFLRA\") as s:\n     print(s.is_sat(Symbol(\"x\"))) # True\n\n\n\nCheck out more examples in the `examples/ directory\n\u003c/examples\u003e`_ and the `documentation on ReadTheDocs \u003chttp://pysmt.readthedocs.io\u003e`_\n\nSupported Theories and Solvers\n==============================\n\npySMT provides methods to define a formula in Linear Real Arithmetic\n(LRA), Real Difference Logic (RDL), Equalities and Uninterpreted\nFunctions (EUF), Bit-Vectors (BV), Arrays (A), Strings (S) and their\ncombinations. The following solvers are supported through native APIs:\n\n* MathSAT (http://mathsat.fbk.eu/)\n* Z3 (https://github.com/Z3Prover/z3/)\n* cvc5 (https://cvc5.github.io/)\n* Yices 2 (http://yices.csl.sri.com/)\n* CUDD (http://vlsi.colorado.edu/~fabio/CUDD/)\n* PicoSAT (http://fmv.jku.at/picosat/)\n* Boolector (http://fmv.jku.at/boolector/)\n\nAdditionally, you can use any SMT-LIB 2 compliant solver.\n\nPySMT assumes that the python bindings for the SMT Solver are\ninstalled and accessible from your ``PYTHONPATH``.\n\nInstallation\n============\nYou can install the latest stable release of pySMT from PyPI::\n\n  $ pip install pysmt\n\nthis will additionally install the *pysmt-install* command, that can\nbe used to install the solvers: e.g., ::\n\n  $ pysmt-install --check\n\nwill show you which solvers have been found in your ``PYTHONPATH``.\nPySMT does not depend directly on any solver, but if you want to\nperform solving, you need to have at least one solver installed. This\ncan be used by pySMT via its native API, or passing through an SMT-LIB\nfile.\n\nThe script *pysmt-install* can be used to simplify the installation of the solvers::\n\n $ pysmt-install --msat\n\nwill install MathSAT 5.\n\nBy default the solvers are downloaded, unpacked and built in your home directory\nin the ``.smt_solvers`` folder. Compiled libraries and actual solver packages are\ninstalled in the relevant ``site-packages`` directory (e.g. virtual environment's\npackages root or local user-site). ``pysmt-install`` has many options to\ncustomize its behavior. If you have multiple versions of python in your system,\nwe recommend the following syntax to run pysmt-install: ``python -m pysmt install``.\n\n\n*Note:* This script does not install required\ndependencies for building the solver (e.g., make or gcc) and has been\ntested mainly on Linux Debian/Ubuntu systems. We suggest that you\nrefer to the documentation of each solver to understand how to install\nit with its python bindings.\n\nFor Yices, picosat, and CUDD, we use external wrappers:\n\n- yicespy (https://github.com/pysmt/yicespy)\n- repycudd (https://github.com/pysmt/repycudd)\n- pyPicoSAT (https://github.com/pysmt/pyPicoSAT)\n\nFor instruction on how to use any SMT-LIB complaint solver with pySMT\nsee `examples/generic_smtlib.py \u003c/examples/generic_smtlib.py\u003e`_\n\nFor more information, refer to online `documentation on ReadTheDocs \u003chttp://pysmt.readthedocs.io\u003e`_\n\nSolvers Support\n---------------\n\nThe following table summarizes the features supported via pySMT for\neach of the available solvers.\n\n +------------------+-----------+--------------------------------+-------------+------------------------+------------+--------------+\n | Solver           | pySMT name|  Supported Theories            | Quantifiers | Quantifier Elimination | Unsat Core | Interpolation|\n +==================+===========+================================+=============+========================+============+==============+\n | MathSAT          |  msat     | UF, LIA, LRA, BV, AX           |  No         | msat-fm, msat-lw       | Yes        | Yes          |\n +------------------+-----------+--------------------------------+-------------+------------------------+------------+--------------+\n | Z3               |  z3       | UF, LIA, LRA, BV, AX, NRA, NIA |  Yes        | z3                     | Yes        | No           |\n +------------------+-----------+--------------------------------+-------------+------------------------+------------+--------------+\n | cvc5             |  cvc5     | UF, LIA, LRA, BV, AX, S        |  Yes        | No                     | No         | No           |\n +------------------+-----------+--------------------------------+-------------+------------------------+------------+--------------+\n | Yices            |  yices    | UF, LIA, LRA, BV               |  No         | No                     | No         | No           |\n +------------------+-----------+--------------------------------+-------------+------------------------+------------+--------------+\n | Boolector        |  btor     | UF, BV, AX                     |  No         | No                     | No         | No           |\n +------------------+-----------+--------------------------------+-------------+------------------------+------------+--------------+\n | SMT-Lib Interface|  \u003ccustom\u003e | UF, LIA, LRA, BV, AX           |  Yes        | No                     | No         | No           |\n +------------------+-----------+--------------------------------+-------------+------------------------+------------+--------------+\n | PicoSAT          |  picosat  | [None]                         |  No         | [No]                   | No         | No           |\n +------------------+-----------+--------------------------------+-------------+------------------------+------------+--------------+\n | BDD (CUDD)       |  bdd      | [None]                         |  Yes        | bdd                    | No         | No           |\n +------------------+-----------+--------------------------------+-------------+------------------------+------------+--------------+\n\n\n\n\nLicense\n=======\n\npySMT is released under the APACHE 2.0 License.\n\nFor further questions, feel free to open an issue, or write to\npysmt@googlegroups.com (`Browse the Archive \u003chttps://groups.google.com/d/forum/pysmt\u003e`_).\n\nIf you use pySMT in your work, please consider citing:\n\n.. code::\n\n  @inproceedings{pysmt2015,\n    title={PySMT: a solver-agnostic library for fast prototyping of SMT-based algorithms},\n    author={Gario, Marco and Micheli, Andrea},\n    booktitle={SMT Workshop 2015},\n    year={2015}\n  }\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpysmt%2Fpysmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpysmt%2Fpysmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpysmt%2Fpysmt/lists"}