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