Deterministic Automata
A Rust framework for implementing deterministic automata with arbitrary state complexity.
Overview
This crate provides a generic trait-based framework for creating deterministic automata that can handle state machines more complex than traditional finite state automata. States can carry arbitrary data, allowing recognition of some patterns beyond regular languages, and multiple automata can be composed using product constructions.
Key Features
- Flexible State Types: States can be any
Clonetype, not limited to simple enums - Generic Alphabets: Input symbols can be any type supporting equality comparison
- Beyond Regular Languages: Support for context-free and other complex language patterns
- Product Constructions: Combine multiple automata with union, intersection, and custom operations
- Type-Safe Error Handling: Comprehensive validation with custom error types
Quick Start
Basic Finite State Automaton
use ;
;
// Usage
let dfa = EndsWithAB;
assert_eq!;
Context-Free Language Recognition
use CounterAutomatonBlueprint;
let blueprint = new;
assert_eq!;
Combining Automata
use BasicUnionAutomatonBlueprint;
let a_blueprint = new;
let b_blueprint = new;
let union = new;
// Accepts strings from either language
assert_eq!;
assert_eq!;
Core Components
DeterministicAutomatonBlueprint Trait
The main trait for defining automaton behavior with associated types for states, alphabet, state classification, and errors.
Provided Examples
counter_automaton_example: Recognizes the context-free language an bn using counter-based statesproduct_automaton: Product constructions including union and intersection operationseither_automaton: Runtime choice between two different automaton blueprint types using a sum type
Runtime Execution
DeterministicAutomaton: Runtime instance for step-by-step input processingBasicStateSort: Simple Accept/Reject state classification
Testing
The crate includes comprehensive integration tests covering:
- Core framework functionality
- All provided automaton implementations
- Product construction operations
- Error handling and edge cases
Run tests with:
Documentation
Generate and view the full documentation:
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Documentation and comprehensive test suite contributions by Claude (Anthropic). All core automata logic and framework design by the original author.