Recursive State Automaton
pyformlang.rsa
This module deals with recursive automaton.
References
[1] Alur R., Etessami K., Yannakakis M. (2001) Analysis of Recursive State Machines. In: Berry G., Comon H., Finkel A. (eds) Computer Aided Verification. CAV 2001. Lecture Notes in Computer Science, vol 2102. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-44585-4_18
Available Classes
RecursiveAutomatonA recursive automaton
BoxA constituent part of a recursive automaton
- class pyformlang.rsa.Box(enfa: EpsilonNFA, nonterminal: Symbol | str)[source]
Represents a box for recursive automaton
This class represents a box for recursive automaton
- Parameters:
- enfa
EpsilonNFA A epsilon nfa
- nonterminal
Symbol A nonterminal for epsilon nfa
- enfa
- property dfa
Box’s dfa
- property final_states
The final states
- is_equivalent_to(other)[source]
Check whether two boxes are equivalent
- Parameters:
- other
Box A sequence of input symbols
- other
- Returns:
- are_equivalentbool
Whether the two boxes are equivalent or not
- property nonterminal
Box’s nonterminal
- property start_states
The start states
- class pyformlang.rsa.RecursiveAutomaton(start_box: Box, boxes: AbstractSet[Box])[source]
Represents a recursive automaton
This class represents a recursive automaton.
- classmethod from_ebnf(text, start_nonterminal: Symbol | str = S)[source]
Create a recursive automaton from ebnf (ebnf = Extended Backus-Naur Form)
- Parameters:
- textstr
The text of transform
- start_nonterminal
Symbol| str, optional The start nonterminal, S by default
- Returns:
- rsa
RecursiveAutomaton The new recursive automaton built from context-free grammar
- rsa
- classmethod from_regex(regex: Regex, start_nonterminal: Symbol | str)[source]
Create a recursive automaton from regular expression
- Parameters:
- Returns:
- rsa
RecursiveAutomaton The new recursive automaton built from regular expression
- rsa
- get_box_by_nonterminal(nonterminal: Symbol | str)[source]
Box by nonterminal
- Parameters:
- nonterminal: :class:`~pyformlang.finite_automaton.Symbol` | str
the nonterminal of which represents a box
- Returns:
- box
Box| None box represented by given nonterminal
- box
- is_equals_to(other)[source]
Check whether two recursive automata are equals by boxes. Not equivalency in terms of formal languages theory, just mapping boxes
- Parameters:
- other
RecursiveAutomaton The input recursive automaton
- other
- Returns:
- are_equivalentbool
Whether the two recursive automata are equals or not
- property start_box
The start box