Search code examples
finite-automataautomataautomata-theory

Define strings and draw language


The language of all strings defined over Σ = {A, B, C} that begins with B, ends with A and having minimum length of 3 and also draw finite automata for the language.

Please explain this in the regular expression way and language diagram. The language of all strings defined over Σ = {X, Y, Z} with Y as the third letter and Z being the second last letter


Solution

  • s -> Bx

    x -> Ay | By | Cy

    y -> Ay | By | Cy | A

    It is not too difficult to draw the finite automaton. The small letters are the states, the capital letters are the input symbols.

    State "s" is the start state.

    From there the word is started with B and ends in state "x".

    From "x" the input can be A or B or C and leads to state "y".

    From "y" the input can be A or B or C and the lead back to "y". The input C is particular because it can/must be the last symbol of the word. So A simply ends in a finish state (which is not explicitly mentioned in the rules).

    The automaton would look like this:

    Finite automaton for above language

    The regular expression that recognizes the discussed language is as follows:

    B[ABC][ABC]*A - or shorter - B[ABC]+A

    In this case it was simple (especially the first regular expression) to see the correspondence between the automaton and the regular expression.


    Divyesh's answer is almost correct also, he drew a deterministic automaton. You just have to remove the transition to q4 and it's ok.