TimeType MonaAutomataDotWalker::_constructAutomaton(ASTForm* form) { DFA *monaAutomaton = nullptr; try { DFA *temp = nullptr; size_t monaStates = 0, minimizedStates = 0; toMonaAutomaton(form, monaAutomaton, false); assert(monaAutomaton != nullptr); monaStates = monaAutomaton->ns; temp = dfaCopy(monaAutomaton); dfaUnrestrict(temp); monaAutomaton = dfaMinimize(temp); minimizedStates = monaAutomaton->ns; // Clean up dfaFree(monaAutomaton); monaAutomaton = nullptr; /*dfaFree(temp); temp = nullptr;*/ return std::make_pair(minimizedStates, monaStates); } catch (std::exception &e) { if(monaAutomaton != nullptr) { dfaFree(monaAutomaton); } return std::make_pair(0, 0); } }
DFA *dfa_Prefix(DFA *M, int c1, int c2, int var, int* indices) //Output M' so that L(M')={w| w'\in \Sigma*, ww' \in L(M), c_1 <= |w|<=c_2 } { int i, sink; DFA *M1 = dfaSigmaC1toC2(c1, c2, var, indices); DFA *M2 = dfaCopy(M); //dfaPrintVerbose(M2); sink = find_sink(M); for(i=0; i<M2->ns; i++){ if(i!= sink) M2->f[i]=1; } //dfaPrintVerbose(M2); DFA *result = dfa_intersect(M2, M1); //dfaPrintVerbose(result); dfaFree(M1); dfaFree(M2); return dfaMinimize(result); }//end of prefix