For example, in an assignment given to me, we were asked to find out if two regular expressions are equal or not.
(a+b+c)* and ((ab)**c*)*
My question is how is one supposed to do that? If I draw the transition graphs for both and then run a few strings through it and show that both of the TGs are able to accept it, is that a sufficient proof ? If not, how do I do it? Is there a mathematical/axiomatic approach towards this?
Thanks in advance.
EDIT: There is another thing that I'd like to clear which is kind of related to this question. Are the two FAs depicted in the photo below the same?
i.e. Are (1) and (2) in the above picture the same?
Proof: Since L and M are regular, they have regular expressions, say: Let L = L(E) and M = L(F). Then L ∪ M = L(E + F) by the definition of the + operator. If L is a regular language over alphabet Σ then L = Σ∗ \ L is also regular.
Use the constructor function when you know the regular expression pattern will be changing, or you don't know the pattern and are getting it from another source, such as user input.
Though there are some differences from one programming language to another, particularly in the built-in functions that are used to perform the various regular expression operations, the basic ideas underlying regular expressions are mostly the same across all programming languages.
No, if you use standard regular expressions. The reason is that you cannot satisfy the pumping lemma for regular languages.
There is an algorithm to determine whether they are equal:
- Construct NFA-lambdas corresponding to each RE using Kleene's theorem
- Construct DFAs for each using the subset/powerset construction
- (optional) Minimize the DFAs using a standard DFA minimization algorithm.
- Construct DFAs for L(M1) \ L(M2) and L(M2) \ L(M1) using the Cartesian Product Machine construction
- (Optional) Minimize these CPMs.
- Determine whether each one accepts any strings by testing all strings over alphabet E of size no greater than |Q| (works due to the pumping lemma for regular languages)
No novelty or genius is required; you could write a program to do this (although, in practice, using the powerset construction can be unwieldy, and failing to minimize at both steps can be costly, to).
EDIT: Yes, those DFAs are the same. The first is just a shorthand notation for the second.
Two regular expressions R and T are equivalent if the language defined by R (i.e., the set of strings generated by regular expression R) is equal to the language defined by T. To prove equivalences for regular expressions, we use containment proofs from set theory. That is, if S1 is the set of strings generated by regular expression R, and S2 is the set of strings generated by regular expression T, we must prove that S1 ⊆ S2 and S2 ⊆ S1. Both directions are necessary to prove equality of sets.
-- From the lecture notes of CSc 4340 GSU Fall 09 (Dr. Raj Sunderraman)
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