pub struct TreeAutomaton {
pub num_states: usize,
pub final_states: HashSet<usize>,
pub transitions: HashMap<(String, Vec<usize>), HashSet<usize>>,
}Expand description
A (bottom-up) tree automaton for recognizing regular tree languages.
States are usize indices. Transitions are of the form
f(q_1, …, q_n) → q meaning: if children of f are in states q_1, …, q_n
then f(…) can be assigned state q.
Fields§
§num_states: usizeNumber of states.
final_states: HashSet<usize>Set of accepting (final) states.
transitions: HashMap<(String, Vec<usize>), HashSet<usize>>Transitions: maps (symbol, child_states) to a set of target states.
Implementations§
Source§impl TreeAutomaton
impl TreeAutomaton
Sourcepub fn add_transition(
&mut self,
symbol: impl Into<String>,
child_states: Vec<usize>,
target: usize,
)
pub fn add_transition( &mut self, symbol: impl Into<String>, child_states: Vec<usize>, target: usize, )
Add a transition: when f is applied to children in states child_states,
allow reaching state target.
Sourcepub fn run(&self, t: &Term) -> HashSet<usize>
pub fn run(&self, t: &Term) -> HashSet<usize>
Run the automaton bottom-up on term t.
Returns the set of states reachable at the root.
Trait Implementations§
Source§impl Clone for TreeAutomaton
impl Clone for TreeAutomaton
Source§fn clone(&self) -> TreeAutomaton
fn clone(&self) -> TreeAutomaton
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TreeAutomaton
impl RefUnwindSafe for TreeAutomaton
impl Send for TreeAutomaton
impl Sync for TreeAutomaton
impl Unpin for TreeAutomaton
impl UnsafeUnpin for TreeAutomaton
impl UnwindSafe for TreeAutomaton
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more