Skip to main content

Python CI codecov PyPI

Lire en français


fsm-tools

A formal Python library for modelling automata in the Chomsky hierarchy.

Overview

fsm-tools provides a rigorous implementation of the four automaton families defined by Chomsky's grammar and language hierarchy:

Type Automaton Language family Status
0 TuringMachine Recursively enumerable ✅ v0.0.4
1 LinearBoundedAutomaton Context-sensitive ✅ v0.0.4
2 PushdownAutomaton Context-free ✅ v0.1.0
3 FiniteStateAutomaton Regular 🔄 planned v0.2.0

Each class is a formal restriction of the one above it — inheriting its structure and constraining it further. The hierarchy is implemented as a strict inheritance chain:

Automaton
└── TuringMachine               (Type 0)
    └── LinearBoundedAutomaton  (Type 1)
        └── PushdownAutomaton   (Type 2)
            └── FiniteStateAutomaton  (Type 3 — planned v0.2.0)

Installation

pip install fsm-tools

Quick start

Turing Machine (Type 0)

from fsm_tools import TuringMachine

tm = TuringMachine(
    name="BinaryIncrement",
    chomsky="Recursively Enumerable",
    axes=1,
    blank_symbol="_",
    movement={"R": [1], "L": [-1]},
    register="q0",
    accept="qAccept",
    reject="qReject",
)

Pushdown Automaton (Type 2)

Recognition of the context-free language L = { aⁿbⁿ | n ≥ 1 }:

from fsm_tools import PushdownAutomaton

pda = PushdownAutomaton(
    name="anbn",
    stack_alphabet={"A"},
    bottom_symbol="Z",
)
pda.add_terminals("a", "b")
pda.set_register("q0")
pda.add_non_terminals("q1", "q2")

pda.add_transition("q0", "a", "Z", "q0", ["A", "Z"])
pda.add_transition("q0", "a", "A", "q0", ["A", "A"])
pda.add_transition("q0", "b", "A", "q1", [])
pda.add_transition("q1", "b", "A", "q1", [])
pda.add_transition("q1", "b", "Z", "q2", [])

pda.validate(["a", "b"])        # True
pda.validate(["a", "a", "b"])   # False

Documentation

Full documentation is available at fsm-tools.readthedocs.io.

Links

License

This project is licensed under the CeCILL-C license. The French version is the legally authoritative reference — see LICENSE.fr.

Download files

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

Source Distribution

fsm_tools-0.2.0.tar.gz (93.8 kB view details)

Uploaded Source

Built Distribution

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

fsm_tools-0.2.0-py3-none-any.whl (49.6 kB view details)

Uploaded Python 3

File details

Details for the file fsm_tools-0.2.0.tar.gz.

File metadata

  • Download URL: fsm_tools-0.2.0.tar.gz
  • Upload date:
  • Size: 93.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for fsm_tools-0.2.0.tar.gz
Algorithm Hash digest
SHA256 18e29bfe203c7f3b4a95ee4991a4938b4b907c676b8a3d55c727dab513b2a6af
MD5 dfc4170580e57b687c22ad296d3c7552
BLAKE2b-256 91ae4d3b8bbc61568e00b088000ba438fbe0a690180d0a28686cbc3472926c0d

See more details on using hashes here.

File details

Details for the file fsm_tools-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: fsm_tools-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 49.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for fsm_tools-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 caf193c2b12defc118abb6e6db94614550437254650864ea2571cad9759c7cbf
MD5 411eda761a886ae4c8560fc085f80053
BLAKE2b-256 c379e931344b42fb9c32e0c9910f3cea9e8e745d8703418a3ef04209ecce6a3a

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.0

2 files

0.0.1.post1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page