Module: Finite Languages (fl)¶
Finite languages and related automata manipulation
Finite languages manipulation
Classes¶
FL¶
- class FL(wordsList=None, Sigma=None)[source]¶
Finite Language Class
- Variables
Words – the elements of the language
Sigma – the alphabet
- MADFA()[source]¶
Generates the minimal acyclical DFA using specialized algorithm
New in version 1.3.3.
See also
Incremental Construction of Minimal Acyclic Finite-State Automata, J.Daciuk, s.Mihov, B.Watson and r.E.Watson
- Return type
- intersection(other)[source]¶
Intersection of FL: a & b
- Parameters
other (FL) – right hand operand
- Raises
FAdoGeneralError – if both arguments are not FL
- multiLineAutomaton()[source]¶
Generates the trivial linear ANFA equivalent to this language
- Return type
- setSigma(Sigma, Strict=False)[source]¶
Sets the alphabet of a FL
Attention
Unless Strict flag is set to True, alphabet can only be enlarged. The resulting alphabet is in fact the union of the former alphabet with the new one. If flag is set to True, the alphabet is simply replaced.
DCFA¶
AFA¶
- class AFA[source]¶
Base class for Acyclic Finite Automata

note: This is just a container for some common methods. Not to be used directly!!
- evalRank()[source]¶
Evaluates the rank map of a automaton
- Returns
pair of sets of states by rank map, reverse delta accessability map
- Return type
- getLeaves()[source]¶
The set of leaves, i.e. final states for last symbols of language words
- Returns
set of leaves
- Return type
ADFA¶
- class ADFA[source]¶
Acyclic Deterministic Finite Automata class

Changed in version 1.3.3.
- addSuffix(st, w)[source]¶
Adds a suffix starting in st
New in version 1.3.3.
Attention
in place transformation
- complete(dead=None)[source]¶
Make the ADFA complete
- Parameters
dead (int) – a state to be identified as dead state if one was not identified yet
- Return type
Attention
The object is modified in place
Changed in version 1.3.3.
- dissMin(witnesses=None)[source]¶
Evaluates the minimal dissimilarity language :param dict witnesses: optional witness dictionay :rtype: FL
New in version 1.2.1.
- level()[source]¶
Computes the level for each state
- Returns
levels of states
- Return type
New in version 0.9.8.
- minDFCA()[source]¶
Generates a minimal deterministic cover automata from a DFA
- Return type
New in version 0.9.8.
See also
Cezar Campeanu, Andrei Päun, and Sheng Yu, An efficient algorithm for constructing minimal cover automata for finite languages, IJFCS
- minimal()[source]¶
Finds the minimal equivalent ADFA
See also
[TCS 92 pp 181-189] Minimisation of acyclic deterministic automata in linear time, Dominique Revuz
Changed in version 1.3.3.
- Returns
the minimal equivalent ADFA
- Return type
- minimalP(method=None)[source]¶
Tests if the DFA is minimal
- Parameters
method – minimization algorithm (here void)
- Return type
Changed in version 1.3.3.
ANFA¶
- class ANFA[source]¶
Acyclic Nondeterministic Finite Automata class

- mergeStates(s1, s2)[source]¶
Merge state s2 into state s1
Note
no attempt is made to check if the merging preserves the language of teh automaton
Attention
the object is modified in place
- moveFinal(st, stf)[source]¶
Unsets a set as final transfering transition to another final :param int st: the state to be ‘moved’ :param int stf: the destination final state
Note
stf must be a ‘last’ final state, i.e., must have no out transitions to anywhere but to a possible dead state
Attention
the object is modified in place
RndWGen¶
Functions¶
sigmaInitialSegment¶
genRndTrieBalanced¶
- genRndTrieBalanced(maxL, Sigma, safe=True)[source]¶
Generates a random trie automaton for a binary language of balanced words of a given leght for max word :param int maxL: length of the max word :param set Sigma: alphabet to be used :param bool safe: should a word of size maxl be present in every language? :return: the generated trie automaton :rtype: ADFA
genRndTrieUnbalanced¶
genRandomTrie¶
- genRandomTrie(maxL, Sigma, safe=True)[source]¶
Generates a random trie automaton for a finite language with a given length for max word :param int maxL: length of the max word :param set Sigma: alphabet to be used :param bool safe: should a word of size maxl be present in every language? :return: the generated trie automaton :rtype: ADFA
genRndTriePrefix¶
- genRndTriePrefix(maxL, Sigma, ClosedP=False, safe=True)[source]¶
Generates a random trie automaton for a finite (either prefix free or prefix closed) language with a given length for max word :param int maxL: length of the max word :param set Sigma: alphabet to be used :param bool ClosedP: should it be a prefix closed language? :param bool safe: should a word of size maxl be present in every language? :return: the generated trie automaton :rtype: ADFA
DFAtoADFA¶
stringToADFA¶
- stringToADFA(s)[source]¶
Convert a canonical string representation of a ADFA to a ADFA :param list s: the string in its canonical order :returns: the ADFA :rtype: ADFA
See also
Marco Almeida, Nelma Moreira, and Rogério Reis. Exact generation of minimal acyclic deterministic finite automata. International Journal of Foundations of Computer Science, 19(4):751-765, August 2008.
