Skip to main content

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.

DOI

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

finite_state_machines-1.2.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

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

finite_state_machines-1.2.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file finite_state_machines-1.2.0.tar.gz.

File metadata

  • Download URL: finite_state_machines-1.2.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.8

File hashes

Hashes for finite_state_machines-1.2.0.tar.gz
Algorithm Hash digest
SHA256 48448cc78c5798c53a0adad0144fbcc62a31499e07b5ba149a69e86ac958b3dd
MD5 f90f95649d6a7798e8932ef9defbf34f
BLAKE2b-256 32d7289bcf4f46554f3daaea77181b81a24ed094eb16a3a100870a55cdaf669f

See more details on using hashes here.

File details

Details for the file finite_state_machines-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: finite_state_machines-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.8

File hashes

Hashes for finite_state_machines-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 766d701091a6b2bd400138f6257df89162e542257e6234409663671c0da5180e
MD5 2f34abf7357a2d4f105067101b37e280
BLAKE2b-256 4cf7948ac3817db2ae96378a300e71b210ebb4d40c365281fc36996be040a67a

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