Deterministic Automata
A Rust framework for implementing deterministic and mutation automata with arbitrary state complexity.
Overview
This crate provides a generic trait-based framework for creating deterministic and mutation 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
- Dual Paradigms: Both functional (deterministic) and in-place mutation approaches
- Beyond Regular Languages: Support for context-free and other complex language patterns
- Product Constructions: Combine multiple automata with union, intersection, and custom operations
- Interoperability: Seamless integration between deterministic and mutation automata
- 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!;
Mutation Automaton
use ;
;
let counter = Counter;
assert_eq!;
Core Components
Traits
DeterministicAutomatonBlueprint: Functional automaton behavior with immutable state transitionsMutationAutomatonBlueprint: In-place automaton behavior with mutable state updates
Modules
counter_automaton_example: Recognizes the context-free language an bn using counter-based statesproduct_automaton: Product constructions including union and intersection operations for both paradigmseither_automaton: Runtime choice between different automaton types with deterministic/mutation submodulesmutation_automaton: Core mutation automaton types and blanket interoperability implementation
Runtime Execution
DeterministicAutomaton: Runtime instance for functional step-by-step input processingMutationAutomaton: Runtime instance for mutation-based 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.