FAdo.transducers¶
Finite Tranducer Support
Transducer manipulation.
New in version 1.0.
- class GFT[source]¶
General Form Transducer
- addOutput(sym)[source]¶
Add a new symbol to the output alphabet
There is no problem with duplicate symbols because Output is a Set. No symbol Epsilon can be added
- Parameters:
sym (str) – symbol or regular expression to be added
- codeOfTransducer()[source]¶
Appends into one string the codes of the alphabets and initial and final state sets and the set of transitions
- Return type:
- class NFT[source]¶
Normal Form Transducer.
Transsitions here have labels of the form (s,Epsilon) or (Epsilon,s)
- class SFT[source]¶
Standard Form Tranducer
- Variables:
Output (set) – output alphabet
- addEpsilonLoops()[source]¶
Add a loop transition with epsilon input and output to every state in the transducer.
- addTransitionProductQ(src, dest, ddest, sym, out, futQ, pastQ)[source]¶
Add transition to the new transducer instance.
Version for the optimized product
- addTransitionQ(src, dest, sym, out, futQ, pastQ)[source]¶
Add transition to the new transducer instance.
- delTransition(sti1, sym, symo, sti2, _no_check=False)[source]¶
Remove a transition if existing and perform cleanup on the transition function’s internal data structure.
- deleteState(sti)[source]¶
Remove given state and transitions related with that state.
- Parameters:
sti (int) – index of the state to be removed
- Raises:
DFAstateUnknown – if state index does not exist
- dup()[source]¶
Duplicate of itself :rtype: SFT
Attention
only duplicates the initially connected component
- evalWordP(wp)[source]¶
Tests whether the transducer returns the second word using the first one as input
- evalWordSlowP(wp)[source]¶
Tests whether the transducer returns the second word using the first one as input
Note: original :param tuple wp: pair of words :rtype: bool
- functionalP()[source]¶
Tests if a transducer is functional using Allauzer & Mohri and Béal&Carton&Prieur&Sakarovitch algorithms.
- Return type:
See also
Cyril Allauzer and Mehryar Mohri, Journal of Automata Languages and Combinatorics, Efficient Algorithms for Testing the Twins Property, 8(2): 117-144, 2003.
See also
M.P. Béal, O. Carton, C. Prieur and J. Sakarovitch. Squaring transducers: An efficient procedure for deciding functionality and sequentiality. Theoret. Computer Science 292:1 (2003), 45-63.
Note
This is implemented using nonFunctionalW()
- inIntersection(other)[source]¶
Conjunction of transducer and automata: X & Y.
Note
This is a fast version of the method that does not produce meaningfull state names.
Note
The resulting transducer is not trim.
- inIntersectionSlow(other)[source]¶
Conjunction of transducer and automata: X & Y.
Note
This is the slow version of the method that keeps meaningfull names of states.
- inverse()[source]¶
Switch the input label with the output label.
No initial or final state changed.
- Returns:
Transducer with transitions switched.
- Return type:
- nonFunctionalW()[source]¶
Returns a witness of non funcionality (if is that the case) or a None filled triple
- Returns:
witness
- Return type:
- outIntersection(other)[source]¶
Conjunction of transducer and automaton: X & Y using output intersect operation.
- productInput(other)[source]¶
Returns a transducer (skeleton) resulting from the execution of the transducer with the automaton as filter on the input.
Note
This version does not use stateIndex() with the price of generating some unreachable sates
Changed in version 1.3.3.
- productInputSlow(other)[source]¶
Returns a transducer (skeleton) resulting from the execution of the transducer with the automaton as filter on the input.
Note
This is the slow version of the method that keeps meaningfull names of states.
- reversal()[source]¶
Returns a transducer that recognizes the reversal of the relation.
- Returns:
Transducer recognizing reversal language
- Return type:
- runOnWord(word)[source]¶
Returns the automaton accepting the outup of the transducer on the input word
- Parameters:
word – the word
- Return type:
- setInitial(sts)[source]¶
Sets the initial state of a Transducer
- Parameters:
sts (list) – list of states
- toInNFA()[source]¶
Delete the output labels in the transducer. Translate it into an NFA
- Return type:
- toOutNFA()[source]¶
Returns the result of considering the output symbols of the transducer as input symbols of a NFA (ignoring the input symbol, thus)
- Returns:
the NFA
- Return type:
- concatN(x, y)[source]¶
Concatenation of tuples of words :param x: iterable :param y: iterable :return: iterable
- hypercodeTransducer(alphabet, preserving=False)[source]¶
Creates an hypercode property transducer based on given alphabet
- infixTransducer(alphabet, preserving=False)[source]¶
Creates an infix property transducer based on given alphabet
- isLimitExceed(NFA0Delta, NFA1Delta)[source]¶
Decide if the size of NFA0 and NFA1 exceed the limit.
Size of NFA0 is denoted as N, and size of NFA1 is denoted as M. If N*N*M exceeds 1000000, return False, else return True. If bothNFA is False, then NFA0 should be NFA, and NFA1 should be Transducer. If both NFA is True, then NFA0 and NFA1 are both NFAs.
- outfixTransducer(alphabet, preserving=False)[source]¶
Creates an outfix property transducer based on given alphabet