FAdo.fl¶
Finite languages and related automata manipulation
Finite languages manipulation
- 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, optional) – a state to be identified as dead state if one was not identified yet
Attention
The object is modified in place
Changed in version 1.3.3.
- 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:
DCFA
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
- Returns:
the minimal equivalent ADFA
- Return type:
See also
[TCS 92 pp 181-189] Minimisation of acyclic deterministic automata in linear time, Dominique Revuz
Changed in version 1.3.3.
- 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:
A set of leaves
- Return type:
- 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
- class BitString(blksz, alphsize, bst=None)[source]¶
Class to represent the bitstring of a block language
- Variables:
blocksize – the size of the block
alphsize – the size of the alphabet
bst – the bitstring representation of the language
- DFAtoADFA(aut)[source]¶
Transforms an acyclic DFA into a ADFA
- Parameters:
aut (DFA) – the automaton to be transformed
- Returns:
the converted automaton
- Return type:
- Raises:
notAcyclic – if the DFA is not acyclic
- class DFCA[source]¶
Deterministic Cover Automata class
- property length¶
The length of the longest word :returns: the length of the longest word :rtype: int
- 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, blksz.Mihov, B.Watson and r.E.Watson
- Return type:
- addWord(word)[source]¶
Adds a word to a FL
- Parameters:
word (string) – word to be added
- Return type:
- diff(other)[source]¶
Difference of FL: a - b
- Parameters:
other (FL) – left hand operand
- Returns:
result of the operation
- Return type:
- Raises:
FAdoGeneralError – if both arguments are not FL
- intersection(other)[source]¶
Intersection of FL: a & b
- Parameters:
other (FL) – left hand operand
- Returns:
result of the operation
- Return type:
- Raises:
FAdoGeneralError – if both arguments are not FL
- multiLineAutomaton()[source]¶
Generates the trivial linear ANFA equivalent to this language
- Returns:
the trivial linear ANFA
- Return type:
- setSigma(Sigma, Strict=False)[source]¶
Sets the alphabet of a FL
- Parameters:
Sigma (string) – alphabet
Strict (bool) – behaviour
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.
- suffixClosedP()[source]¶
Tests if a language is suffix closed
- Returns:
True if language is suffix closed
- Return type:
- toDFA()[source]¶
Generates a DFA recognizing the language
- Returns:
the DFA
- Return type:
New in version 1.2.
- trieFA()[source]¶
Generates the trie automaton that recognises this language
- Returns:
the trie automaton
- Return type:
- union(other)[source]¶
union of FL: a | b
- Parameters:
other (FL) – right hand operand
- Returns:
result of the union
- Return type:
- Raises:
FAdoGeneralError – if both arguments are not FL
- class RndWGen(aut)[source]¶
Word random generator class
New in version 1.2.
- Parameters:
aut (ADFA) – automata recognizing the language
- coBlockDFA(a: DFA, n: int) DFA [source]¶
- Parameters:
- Returns:
accepts the words of length n not accepted by a
- Return type:
New in version 2.1.2.
- firstBlockWords(alpzs: int, nwords: int, blksz: int) ADFA [source]¶
Generates the minimal ADFA that accepts exactly the first nwords (lexicographic order) of a blksz language
- genRandomTrie(maxL, Sigma, safe=True)[source]¶
Generates a random trie automaton for a finite language with a given length for max word
- genRndBitString(b: int, k: int) BitString [source]¶
Generates a random bitstring with alphabet size k and block size b
- 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
- 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
- genRndTrieUnbalanced(maxL, Sigma, ratio, safe=True)[source]¶
Generates a random trie automaton for a binary language of balanced words of a given length for max word
- generateBlockTrie(sz: int, alpsz: int) ADFA [source]¶
Generates a trie for a blksz language
- Parameters:
- Returns:
the automaton
- Return type:
New in version 2.1.3.
- sigmaInitialSegment(Sigma: list, l: int, exact=False) ADFA [source]¶
Generates the ADFA recognizing Sigma^i for i<=l