Name | cfsm-bisimulation JSON |
Version |
1.0.1
JSON |
| download |
home_page | |
Summary | A bisiumlation data-aware algorithm for Communicating Finite State Machines with edge assertions (knowledge as a-CFSM) |
upload_time | 2023-11-21 00:48:48 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7 |
license | MIT License Copyright (c) [2023] [Diego Senarruzza] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
bisimulation
cfsm
automaton
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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:
<img src="https://github.com/diegosenarruzza/bisimulation/raw/master/automaton.png">
## Installation
At first, you will need to install `z3` and `z3-solver` as dependencies. You can use pip:
```bash
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.
```py
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:
```py
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:
```py
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.
```py
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](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](https://opensource.org/license/mit/).
Raw data
{
"_id": null,
"home_page": "",
"name": "cfsm-bisimulation",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "bisimulation,cfsm,automaton",
"author": "",
"author_email": "Diego Senarruzza <diegosenarruzza@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/38/03/5c4e590ba290abaa2be38dcba05998cb5d0c07dae61d52f135903a58a563/cfsm-bisimulation-1.0.1.tar.gz",
"platform": null,
"description": "# Communicating Finite State Machines Bisimulation with edge assertions\n\nAn algorithm to decide if two Communicating Finite State Machines (CFSM) with edge assertions,\nknown as _Asserted Communicating Finite State Machines_ (a-CFSM) are bisimilars.\nYou 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*). \n\n\n### What does this package do?\nThis 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). \nFor example, the following two automata would be bisimilar:\n\n<img src=\"https://github.com/diegosenarruzza/bisimulation/raw/master/automaton.png\">\n\n## Installation\n\nAt first, you will need to install `z3` and `z3-solver` as dependencies. You can use pip:\n\n```bash\npip install z3-solver cfsm-bisimulation\n```\n\n## Usage\n\nThe 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.\n```py\nfrom cfsm_bisimulation import CommunicatingFiniteStateMachine\nfrom z3 import Int\n\ncfsm_service = CommunicatingFiniteStateMachine(['Client', 'Logger'])\ncfsm_service.add_states('p0', 'p1')\ncfsm_service.set_as_initial('p0')\ncfsm_service.add_transition_between(\n 'p0',\n 'p1',\n 'ClientLogger!log(int x)',\n Int('x') > 0\n)\n\ncfsm_provider = CommunicatingFiniteStateMachine(['Customer', 'Service'])\ncfsm_provider.add_states('q0', 'q1')\ncfsm_provider.set_as_initial('q0')\ncfsm_provider.add_transition_between(\n 'q0',\n 'q1',\n 'CustomerService!save(int number)',\n Int('number') > 0\n)\n```\n\nTo evaluate these automata, you can simply:\n\n```py\nrelation, matches = cfsm_service.calculate_bisimulation_with(cfsm_provider)\n```\n\nThe 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:\n```py\nrelation, matches = cfsm_service.calculate_bisimulation_with(cfsm_provider, minimize=True)\n```\nThe result of `matches` is a dictionary with matches for `participants`, `messages` and `variables`. Each value, in turn, is a dictionary with the matches themselves.\n```py\nrelation = {\n (('p0'), ('q0')),\n (('p1', Int('x') > 0), (Int('number') > 0)),\n}\nmatches = {\n 'participants': {'Client': 'Customer', 'Logger': 'Service'},\n 'messages': {'log(int x)': 'save(int number)'},\n 'variables': {'number': 'x'}\n}\n```\n\n## Contributing\nBug reports and pull requests are welcome on GitHub at [https://github.com/diegosenarruzza/bisimulation](https://github.com/diegosenarruzza/bisimulation).\nIf 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.\n\n## License\nThe package is available as open source under the terms of the [Mit License](https://opensource.org/license/mit/).\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) [2023] [Diego Senarruzza] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "A bisiumlation data-aware algorithm for Communicating Finite State Machines with edge assertions (knowledge as a-CFSM)",
"version": "1.0.1",
"project_urls": {
"Bug Reports": "https://github.com/diegosenarruzza/bisimulation/issues",
"Homepage": "https://github.com/diegosenarruzza/bisimulation",
"Source": "https://github.com/diegosenarruzza/bisimulation"
},
"split_keywords": [
"bisimulation",
"cfsm",
"automaton"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "79e51399d07cd6a85e578aae14c19d6fb03613d87051aebfbcc81878c01fe755",
"md5": "cd946aa8c2db10a326f2c05000b59e64",
"sha256": "a2adf494091a4656a0a2f67885ff8328d04401234b01d6f3901b550d6239adcc"
},
"downloads": -1,
"filename": "cfsm_bisimulation-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cd946aa8c2db10a326f2c05000b59e64",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 29214,
"upload_time": "2023-11-21T00:48:46",
"upload_time_iso_8601": "2023-11-21T00:48:46.356617Z",
"url": "https://files.pythonhosted.org/packages/79/e5/1399d07cd6a85e578aae14c19d6fb03613d87051aebfbcc81878c01fe755/cfsm_bisimulation-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "38035c4e590ba290abaa2be38dcba05998cb5d0c07dae61d52f135903a58a563",
"md5": "7b5fc66db568a5969192354d02a6bb67",
"sha256": "92108bcf17c7500b5c10bde6cf44d03a0b24b3810822ab4475f762679f353ffe"
},
"downloads": -1,
"filename": "cfsm-bisimulation-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "7b5fc66db568a5969192354d02a6bb67",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 18056,
"upload_time": "2023-11-21T00:48:48",
"upload_time_iso_8601": "2023-11-21T00:48:48.204685Z",
"url": "https://files.pythonhosted.org/packages/38/03/5c4e590ba290abaa2be38dcba05998cb5d0c07dae61d52f135903a58a563/cfsm-bisimulation-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-21 00:48:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "diegosenarruzza",
"github_project": "bisimulation",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "cfsm-bisimulation"
}