A library for manipulating finite state machines
Project description
FiniteStateMachines
This is a Python class to perform basic operations on finite state machines, including union, intersection, and minimization.
It can be installed via pip with the command pip install finite_state_machines
.
Usage
>>> from finite_state_machines import FiniteStateMachine as FSM
>>> M = FSM.fsm_for_words_avoiding("000", alphabet=["0","1"])
>>> M.smart_enumeration(10)
[1, 2, 4, 7, 13, 24, 44, 81, 149, 274, 504]
>>> N = FSM.fsm_for_words_avoiding("101", alphabet=["0","1"])
>>> N.smart_enumeration(10)
[1, 2, 4, 7, 12, 21, 37, 65, 114, 200, 351]
>>> M.intersection(N).words_generated(3)
{'001', '010', '011', '100', '110', '111'}
>>> M.intersection(N).smart_enumeration(10)
[1, 2, 4, 6, 9, 13, 19, 28, 41, 60, 88]
>>> M.union(N).smart_enumeration(10)
[1, 2, 4, 8, 16, 32, 62, 118, 222, 414, 767]
If this code was useful to you in your work, please consider citing it. To generate a BibTeX entry (or another format), click the badge below and locate the "Cite As" section.
Questions, comments, and improvements welcome!
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
Built Distribution
Close
Hashes for finite_state_machines-1.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3927a4389168255267c78258d876956300c149c594f3268233fa2581d1614885 |
|
MD5 | d6e28f03f11405eb1033f94ed947c9f8 |
|
BLAKE2b-256 | c57dc35d5e40177b3725f17b020e3d475afa0de9a9df662c97c11cb57042f60f |
Close
Hashes for finite_state_machines-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fa7ab89376198f5cc6ff3de76a26fc105335d3b53cb6520a804bbb94cac9860 |
|
MD5 | d58d2b14cfcba3cb02a6304fb74a21f1 |
|
BLAKE2b-256 | be8a2fdcf51cdec327c87f8626141997b4d01bfe2a47f3b7058b0cc091684e96 |