aalpy.automata.Dfa
View Source
from aalpy.base import AutomatonState, Automaton class DfaState(AutomatonState): """ Single state of a deterministic finite automaton. """ def __init__(self, state_id): super().__init__(state_id) self.is_accepting = False class Dfa(Automaton): """ Deterministic finite automaton. """ def __init__(self, initial_state: DfaState, states): super().__init__(initial_state, states) def step(self, letter): """ Args: letter: single input that is looked up in the transition table of the DfaState Returns: True if the reached state is an accepting state, False otherwise """ self.current_state = self.current_state.transitions[letter] return self.current_state.is_accepting
View Source
class DfaState(AutomatonState): """ Single state of a deterministic finite automaton. """ def __init__(self, state_id): super().__init__(state_id) self.is_accepting = False
Single state of a deterministic finite automaton.
View Source
def __init__(self, state_id): super().__init__(state_id) self.is_accepting = False
Single state of an automaton. Each state consists of a state id, a dictionary of transitions, where the keys are inputs and the values are the corresponding target states, and a prefix that leads to the state from the initial state.
Args:
state_id(Any): used for graphical representation of the state. A good practice is to keep it unique.
View Source
class Dfa(Automaton): """ Deterministic finite automaton. """ def __init__(self, initial_state: DfaState, states): super().__init__(initial_state, states) def step(self, letter): """ Args: letter: single input that is looked up in the transition table of the DfaState Returns: True if the reached state is an accepting state, False otherwise """ self.current_state = self.current_state.transitions[letter] return self.current_state.is_accepting
Deterministic finite automaton.
View Source
def __init__(self, initial_state: DfaState, states): super().__init__(initial_state, states)
Args:
initial_state (AutomatonState): initial state of the automaton
states (list) : list containing all states of the automaton
View Source
def step(self, letter): """ Args: letter: single input that is looked up in the transition table of the DfaState Returns: True if the reached state is an accepting state, False otherwise """ self.current_state = self.current_state.transitions[letter] return self.current_state.is_accepting
Args:
letter: single input that is looked up in the transition table of the DfaState
Returns:
True if the reached state is an accepting state, False otherwise