Skip to main content

Library to create and check finite and infinite state transition systems

Project description

PyVmt: a python library to interact with transition systems

PyVmt is an extension of PySmt providing classes and operators to create and check finite and infinite state transition systems.

It offers a Model class which stores the data of a transition system:

  • state variables
  • input variables
  • init constraints
  • trans constraints
  • properties to be tested

All the variables used within the model have to be declared using one of the available methods, the Next version of each variable can be produced by wrapping the formula containing it within the Next operator.

Serialization, parsing, and model checking

The model class can be serialized to VMT-LIB and can be instantiated from an existing VMT-LIB script using the read function. The VMT-LIB script can be converted using one of the available tools, or can be used directly with a solver that supports it.

PyVmt offers an interface to interact directly with installed solvers, testing properties of several types:

  • invar properties, in the form G(formula)
  • live properties, in the form F(G(formula))
  • ltl properties

The result from model checking tells if the system is safe or unsafe, and stores the data that was returned by the model checker.

If the property is unsafe the model checker may return a counterexample containing a trace with a finite or infinite number of steps. The trace can be analyzed directly by checking the assignments, and evaluating a formula over a step, with the possibility to use the Next operator.

It is also possible to serialize the steps to VMT-LIB.

Installation

To install the package run python3 -m pip install pyvmt.

Configuration

PyVmt currently supports 3 solvers:

To use any of these solvers, download or build their latest stable release. The support for nuXmv is currently in development.

After installing the solver you want to use, you must then configure an environment variable containing the path to the executable:

  • PYVMT_IC3IA_PATH containing the path to the ic3ia executable
  • PYVMT_EUFORIA_PATH containing the path to the EUForia executable
  • PYVMT_NUXMV_PATH containing the path to the nuXmv executable

For example you may add to ~/.bashrc the following lines:

export PYVMT_IC3IA_PATH="${HOME}/.vmt-solvers/ic3ia/ic3ia"
export PYVMT_EUFORIA_PATH="${HOME}/.vmt-solvers/EUForia/EUForia"
export PYVMT_NUXMV_PATH="${HOME}/.vmt-solvers/nuXmv/nuXmv"

And place the solver executables at the specified paths.

Usage

This simple example shows a transition system containing a state variable called 'a' which is initialized at 0 and incremented at each step by 1. A solver is called to check if the variable always stays below the value of 5.

from pyvmt.model import Model
from pyvmt.solvers.ic3ia import Ic3iaSolver
from pyvmt.shortcuts import Next
from pysmt.shortcuts import Equals, Int, Plus, INT, LT

model = Model()
# the state variable needs to be declared before being used within the model
a = model.create_state_var('a', INT)

# add some constraints to initialization and evolution of the model
model.add_init(Equals(a, Int(0)))
model.add_trans(Equals(Next(a), Plus(a, Int(1))))

# add some property to check, and run the solver
prop = LT(a, Int(5))
prop_idx = model.add_invar_property(prop)
solver = Ic3iaSolver(model)
res = solver.check_property_idx(prop_idx)
assert res.is_unsafe()
assert res.has_trace()

# print the counterexample
print("Found a counterexample to invar prop", prop)
for step in res.get_trace().get_steps():
    print(a, '=', step.get_assignment(a))

Using the formula manipulation functionalities offered by PySmt it is possible to create configurable transition systems programmatically depending on parameters, the ferryman example shows how this can be used.

Other features

Some of the other things that you can do with PyVmt include:

  • merging transitions systems by means of synchronous composition
  • renaming a transition system's variables by adding or changing a prefix/suffix, or with a customized callback function
  • wrap complex formulae with the Next operators to form Next state formulae, then push the Next operators to the leaves containing the state variables
  • check if a formula contains LTL or Next operators

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvmt-0.0.4.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvmt-0.0.4-py3-none-any.whl (50.1 kB view details)

Uploaded Python 3

File details

Details for the file pyvmt-0.0.4.tar.gz.

File metadata

  • Download URL: pyvmt-0.0.4.tar.gz
  • Upload date:
  • Size: 35.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for pyvmt-0.0.4.tar.gz
Algorithm Hash digest
SHA256 88624d448ee7c9cb4fa2a0dc5a5f6c0a145f2f9f7d006fbb9b7957b839c2d969
MD5 12855ceef3459c4fa5c5473d394797fb
BLAKE2b-256 5f02a72dd8a05545976d1fff950bc52879412938c69dac0f913714bbdc62f7b4

See more details on using hashes here.

File details

Details for the file pyvmt-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pyvmt-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 50.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for pyvmt-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fcfc777b5ac9a432f87d475284d41e345617984ccd56f507665f9231b67b22bf
MD5 ecefd0628f8bf6f1fa0fbccbc6cb8ba8
BLAKE2b-256 6e3531a25fce63f9e1bc8c5d794b6ddbbc2e0a828fd9874e2eb8fcaaca72a155

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page