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 | ✅ 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)
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
Extended hierarchy (pedagogical)
extended.py provides pedagogical variants that lift specific formal
restrictions without changing the class of languages recognised — a direct
illustration of the Church-Turing thesis:
| Class | Extends | Adds | Since |
|---|---|---|---|
ExtendedTuringMachine |
TuringMachine |
n-dimensional, bidirectional tape | v0.0.4 |
ExtendedLBA |
LinearBoundedAutomaton |
n-dimensional bounded tape | v0.0.4 |
ExtendedPushdownAutomaton |
PushdownAutomaton |
Epsilon-transitions, epsilon-closure validate() |
v0.3.0 |
from fsm_tools import ExtendedPushdownAutomaton
# L = { aⁿbⁿ | n ≥ 0 } — the epsilon-transition covers n = 0, which the
# base PushdownAutomaton rejects unconditionally.
epda = ExtendedPushdownAutomaton(name="anbn-eps", stack_alphabet={"A"}, bottom_symbol="Z")
epda.add_terminals("a", "b")
epda.set_register("q0")
epda.add_non_terminals("q1", "q2")
epda.add_transition("q0", "a", "Z", "q0", ["A", "Z"])
epda.add_transition("q0", "a", "A", "q0", ["A", "A"])
epda.add_transition("q0", "b", "A", "q1", [])
epda.add_transition("q1", "b", "A", "q1", [])
epda.add_transition("q1", "b", "Z", "q2", [])
epda.add_transition("q0", None, "Z", "q2", ["Z"]) # epsilon: accept n = 0
epda.validate([]) # True
epda.validate(["a", "b"]) # True
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fsm_tools-0.3.0.tar.gz.
File metadata
- Download URL: fsm_tools-0.3.0.tar.gz
- Upload date:
- Size: 108.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
735974622bf6738c8c0ffb0936008ac05855089a00e800241df968aa21ad8644
|
|
| MD5 |
a6b848fac1a64b2c2ab6372e3dff6f0d
|
|
| BLAKE2b-256 |
07ab90ac6815dbd5d753734428e8f7fe7f1850406d12b31b0b89b59d3343d9ef
|
Provenance
The following attestation bundles were made for fsm_tools-0.3.0.tar.gz:
Publisher:
ci-publish-pypi.yml on biface/automata
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fsm_tools-0.3.0.tar.gz -
Subject digest:
735974622bf6738c8c0ffb0936008ac05855089a00e800241df968aa21ad8644 - Sigstore transparency entry: 2741158426
- Sigstore integration time:
-
Permalink:
biface/automata@724a3675aaf195b4ff00633231f7a027e291a5a7 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/biface
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-publish-pypi.yml@724a3675aaf195b4ff00633231f7a027e291a5a7 -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file fsm_tools-0.3.0-py3-none-any.whl.
File metadata
- Download URL: fsm_tools-0.3.0-py3-none-any.whl
- Upload date:
- Size: 57.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1745068ff7d364fc984036b13ec08293eb35eb1b662fee484288e3c8e330e2b0
|
|
| MD5 |
d5ac6444193ac83913032e8281a7a17d
|
|
| BLAKE2b-256 |
851625020148659061be9b9e27d37feee9019b2dca16979e9e6ae007ff7c8f7d
|
Provenance
The following attestation bundles were made for fsm_tools-0.3.0-py3-none-any.whl:
Publisher:
ci-publish-pypi.yml on biface/automata
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fsm_tools-0.3.0-py3-none-any.whl -
Subject digest:
1745068ff7d364fc984036b13ec08293eb35eb1b662fee484288e3c8e330e2b0 - Sigstore transparency entry: 2741158588
- Sigstore integration time:
-
Permalink:
biface/automata@724a3675aaf195b4ff00633231f7a027e291a5a7 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/biface
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-publish-pypi.yml@724a3675aaf195b4ff00633231f7a027e291a5a7 -
Trigger Event:
workflow_run
-
Statement type: