use std::hash::Hash;
use crate::labeled::arbitrary::automaton::LabeledAutomaton;
pub trait DeterministicLabeledAutomaton<Label: Hash + Eq + Clone>: LabeledAutomaton<Label> {
fn initial_state(&self) -> Self::State;
fn transition(&self, state: Self::State, input: &Self::Input) -> Option<Self::State>;
fn run_from(&self, state: Self::State, word: &[Self::Input]) -> Option<Self::State> {
let mut current_state = state;
for input in word {
current_state = self.transition(current_state, input)?;
}
Some(current_state)
}
fn get_label_of_word(&self, word: &[Self::Input]) -> Option<Label> {
let state = self.initial_state();
let Some(last_state) = self.run_from(state, word) else {
return None;
};
self.get_label(last_state)
}
}