简体   繁体   中英

how can I simplify a regular expression generated from a DFA

I try to implement the Brzozowski algebraic method using Java, to generate the regular expression of the langage accepted by a given DFA, The expression generated is correct but not simplified.

For example : E|(E)e(e)|(A|(E)e(A))(A|e|(B)e(A))*(B|(B)e(e))|(B|(E)e(B)|(A|(E)e(A))(A|e|(B)e(A))*(E|(B)e(B)))(B|e|(E)e(B)|(A|(E)e(A))(A|e|(B)e(A))*(E|(B)e(B)))*(E|(E)e(e)|(A|(E)e(A))(A|e|(B)e(A))*(B|(B)e(e))) (e = epsilon, E = the empty set)

instead of : (A|B)*AB

The "Transitive closure method" returns nearly the same result.

One of the solutions consists of minimizing the automaton, but i think it's too heavy to generate a simplified regular expression.

also, using Java regular expressions methods to simplify a regular expression is not pretty at all :) .

So, it would be nice to try helping me to find a solution.

Yes, it is possible. Take a look at this Peter Norvig article . Oh! There is a second part . The solution is in python, but you can easily adapt it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM