regexregular-languageautomatadfa

Applying simplification rules to a DFA to derive a regular expression for it


I'm given this deterministic finite automaton (DFA):

enter image description here

I have to construct a regular expression for it. I do not understand one thing in the method described in my handbook.

First of all, we have to construct steps:

Ā  Ā  Ā  šæ1(š“) = {š‘Ž}ā‹…šæ2(š“) āˆŖ {š‘}ā‹…šæ1(š“)

Ā  Ā  Ā  šæ2(š“) = {š‘Ž}ā‹…šæ2(š“) āˆŖ {š‘}ā‹…šæ3(š“)

Ā  Ā  Ā  šæ3(š“) = {š‘Ž}ā‹…šæ2(š“) āˆŖ {š‘}ā‹…šæ1(š“) āˆŖ {Īµ}

Then we write it in mathematical notation:

Ā  Ā  Ā  š‘‹1 = š‘Žš‘‹2 + š‘š‘‹1

Ā  Ā  Ā  š‘‹2 = š‘Žš‘‹2 + š‘š‘‹3

Ā  Ā  Ā  š‘‹3 = š‘Žš‘‹2 + š‘š‘‹1 + 1

Eventually, we substitute. In my book, the šæ3 equation is simplified but I cannot figure out how exactly it was simplified...

Ā  Ā  Ā  š‘‹3 = š‘Žš‘‹2 + š‘š‘‹1 + 1 = š‘‹1 + 1

What logic/rule did they use to simplify šæ3 into š‘‹1 + 1 ?


Solution

  • 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