Skip to main content

A bisiumlation data-aware algorithm for Communicating Finite State Machines with edge assertions (knowledge as a-CFSM)

Project description

Communicating Finite State Machines Bisimulation with edge assertions

An algorithm to decide if two Communicating Finite State Machines (CFSM) with edge assertions, known as Asserted Communicating Finite State Machines (a-CFSM) are bisimilars. You can read about this CFSM extension in "Design-by-Contract for Flexible Multiparty Session Protocols" Section 4.3 (by Lorenzo Gheri, Ivan Lanese, Neil Sayers, Emilio Tuosto, and Nobuko Yoshida).

What does this package do?

This library provides both, a model for creating a-CFSMs and an algorithm for evaluating bisimulation. The main idea behind the algorithm is based on the fact that two automata do not have to coincide in the names of their participants, messages or variables used. Therefore, the algorithm constructs a matching of names as it builds the bisimulation relationship between the evaluated automata (if this is not possible, the automata are not bisimilar). For example, the following two automata would be bisimilar:

Installation

At first, you will need to install z3 and z3-solver as dependencies. You can use pip:

pip install z3-solver cfsm-bisimulation

Usage

The simplest use is to create the two CFSM models that you want to evaluate. We will use the z3 models as a way to construct the constraints.

from cfsm_bisimulation import CommunicatingFiniteStateMachine
from z3 import Int

cfsm_service = CommunicatingFiniteStateMachine(['Client', 'Logger'])
cfsm_service.add_states('p0', 'p1')
cfsm_service.set_as_initial('p0')
cfsm_service.add_transition_between(
    'p0',
    'p1',
    'ClientLogger!log(int x)',
    Int('x') > 0
)

cfsm_provider = CommunicatingFiniteStateMachine(['Customer', 'Service'])
cfsm_provider.add_states('q0', 'q1')
cfsm_provider.set_as_initial('q0')
cfsm_provider.add_transition_between(
    'q0',
    'q1',
    'CustomerService!save(int number)',
    Int('number') > 0
)

To evaluate these automata, you can simply:

relation, matches = cfsm_service.calculate_bisimulation_with(cfsm_provider)

The result of the relation is a set of pairs (state, knowledge) which is in fact not the minimal possible relationship. If you want to obtain the minimum possible relationship between the automata, execute using the option:

relation, matches = cfsm_service.calculate_bisimulation_with(cfsm_provider, minimize=True)

The result of matches is a dictionary with matches for participants, messages and variables. Each value, in turn, is a dictionary with the matches themselves.

relation = {
    (('p0'), ('q0')),
    (('p1', Int('x') > 0), (Int('number') > 0)),
}
matches = {
    'participants': {'Client': 'Customer', 'Logger': 'Service'},
    'messages': {'log(int x)': 'save(int number)'},
    'variables': {'number': 'x'}
}

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/diegosenarruzza/bisimulation. If you are interested in updating or maintaining this package and need more information, please write to me at diegosenarruzza@gmail.com so I can explain in detail the idea behind the code.

License

The package is available as open source under the terms of the Mit License.

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

cfsm-bisimulation-1.0.1.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

cfsm_bisimulation-1.0.1-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file cfsm-bisimulation-1.0.1.tar.gz.

File metadata

  • Download URL: cfsm-bisimulation-1.0.1.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.17

File hashes

Hashes for cfsm-bisimulation-1.0.1.tar.gz
Algorithm Hash digest
SHA256 92108bcf17c7500b5c10bde6cf44d03a0b24b3810822ab4475f762679f353ffe
MD5 7b5fc66db568a5969192354d02a6bb67
BLAKE2b-256 38035c4e590ba290abaa2be38dcba05998cb5d0c07dae61d52f135903a58a563

See more details on using hashes here.

File details

Details for the file cfsm_bisimulation-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for cfsm_bisimulation-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a2adf494091a4656a0a2f67885ff8328d04401234b01d6f3901b550d6239adcc
MD5 cd946aa8c2db10a326f2c05000b59e64
BLAKE2b-256 79e51399d07cd6a85e578aae14c19d6fb03613d87051aebfbcc81878c01fe755

See more details on using hashes here.

Supported by

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