Is there a way to find out if two arbitrary regular expressions are equivalent? Looks like complex problem to me, but there might be some DFA simplification mechanism or something?
Theorem: For every regular expression, there's an equivalent DFA. Proof: Regular expressions are built up with *, |, concatenation.
ε is a Regular Expression indicates the language containing an empty string. ( L (ε) = {ε}) φ is a Regular Expression denoting an empty language. (
Which one of the following regular expressions is NOT equivalent to the regular expression (a + b + c) *? Explanation: C– (ab)* + c*)* will always give strings with “ab” together. Whereas (a+b+c)* would generate language where a,b,c may not be always together.
Regular expressions and finite automata have equivalent expressive power: For every regular expression R, there is a corresponding FA that accepts the set of strings generated by R. For every FA A there is a corresponding regular expression that generates the set of strings accepted by A.
To test equivalence you can compute the minimal DFAs for the expressions and compare them.
Testability of equality is one of the classical properties of regular expressions. (N.B. This doesn't hold if you're really talking about Perl regular expressions or some other technically nonregular superlanguage.)
Turn your REs to generalised finite automata A and B, then construct a new automaton A-B such that the accepting states of A have null transitions to the start states of B, and that the accepting states of B are inverted. This gives you an automaton that accepts all those strings accepted by A, except for all those accepted by B.
Do the same for B-A, and reduce both to pure FAs. If an FA has no accepting states accessible from a start state then it accepts the empty language. If you can show that both A-B and B-A are empty, you've shown that A = B.
Edit
Heh, I can't believe no one noticed the gigantic error there -- an intentional one, of course :-p
The automata A-B as described will accept those strings whose first half is accepted by A and whose second half is not accepted by B. Building the desired A-B is a slightly trickier process. I can't think of it off the top of my head, but I do know it's well-defined (and likely involves creating states to the represent the products of accepting states in A and non-accepting states in B).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With