regex – Applying simplification rules to a DFA to derive a regular expression for it
It is quite straightforward once you see it:
The equation of π1 is right there inside the equation of π3:
Β Β Β π1 = ππ2 + ππ1
Β Β Β π3 = ππ2 + ππ1 + 1
Note how the right-hand side of the first equation occurs also in the last equation, so in the last equation you can replace it with π1, giving you:
Β Β Β π3 = π1 + 1
Another way to see is it is to subtract the first equation from the last one (each side of the equation), which gives
Β Β Β π3 β π1 = 1
…and after you move the negative term to the other side, you have the expected result.
Continuation
After this step, we have:
Β Β Β π1 = ππ2 + ππ1
Β Β Β π2 = ππ2 + ππ3
Β Β Β π3 = π1 + 1
and the simplification can continue further. In the second equation we can substitute π3 with its simplified definition, and omit that latter definition:
Β Β Β π1 = ππ2 + ππ1
Β Β Β π2 = ππ2 + ππ1 + π
And again we find a similar situation: the righthand side of the first equation occurs in the second one, so we can simplify the second equation:
Β Β Β π1 = ππ2 + ππ1
Β Β Β π2 = π1 + π
In a next step we can substitute that simplified definition of π2 into the first equation:
Β Β Β π1 = ππ1 + ππ + ππ1
This simplifies to:
Β Β Β π1 = (π+π)π1 + ππ
And applying Arden’s rule this can be written using the Kleene star as:
Β Β Β πΏ1(π΄) = (π+π)*ππ
In words: any sequence of the symbols π and π that ends in ππ.
As a side note: in a programming environment, in regex syntax, you would write it as:
[ab]*ab
Read more here: Source link
