Combining deterministic finite automata
Asked Answered
M

3

8

I'm really new to this stuff so I apologize for the noobishness here.

construct a Deterministic Finite Automaton DFA recognizing the following language:

L= { w : w has at least two a's and an odd number of b's}. 

The automate for each part of this (at least 2 a's, odd # of b's) are easy to make separately... Can anyone please explain a systematic way to combine them into one? Thanks.

Moidore answered 3/2, 2013 at 20:17 Comment(0)
S
28

You can use following simple steps to construct combined DFA.

Let Σ = {a1 , a2 , ...,ak }.
1st step: Design DFA for both languages and name their state Q0, Q1, ...

2nd step : Rename every state in both DFA uniquely i.e. rename all states in DFA as Q0, Q1, Q2, Q3 , ... assuming you have started with subscript 0; that means none of the state would have same name.

3rd Step: Construct transition table(δ) by using following steps

   3a. Start state of the combined DFA:
      Take start state of both DFAs(DFA1 and DFA2) and name them as Q[ i , j ] where i and j are the subscript of start state of DFA1 and DFA2 respectively; i.e. Qi is start state of 1st DFA and Qj is start state of 2nd DFA and mark Q[i , j] as start state of combined DFA.

   3b. Map state of both DFAs as
           if δ(Qi,ak) = Qp1 and δ(Qj,ak) = Qp2 , where Qp1 belongs to DFA1 and Qp2 belongs to DFA2 then  δ(Q[ i , j ] , ak) = Q[p1,p2]

   3c. fill entire table while there is any Q[i,j] remaining in transition table.

   3d. Final state of the combined DFA:
      For AND case final state would be all Q[i , j] where Qi and Qj are final state of DFA1 and DFA2 respectively.
      For OR case final state would be all Q[i , j] where either Qi or Qj is the final state of DFA1 and DFA2.

4th step: Rename all Q[i, j] (uniquely) and draw DFA this will be your result.

Example:

L= {w: w has at least two a's and an odd number of b's}.

Step1:
DFA for odd number of b's .

DFA for at least 2 a's.

Step2:
Rename the stae of DFA1
enter image description here

Step3(a,b,c):
Constructed transition table will be as.
table

Step3d:
Since we have to take AND of both DFA so final state would be Q[2,4] , since it contains final state of both DFA .
If we have to take OR of both DFA the final state would be Q[0,4],Q[2,3],Q[1,4],Q[2,4] .
Transition table would like this after adding final state .

final table

Step4:
Rename all states Q[i,j]
Q[0,3] to Q0
Q[1,3] to Q2
Q[0,4] to Q1
Q[2,3] to Q4
Q[1,4] to Q3
Q[2,4] to Q5
So final DFA would will look like as below . table

Sheilasheilah answered 4/12, 2014 at 3:40 Comment(1)
would you also explain what's the science behind this? what's the regex?Roentgenogram
S
0

It's done using the product of two automata.

Supertonic answered 3/2, 2013 at 21:11 Comment(2)
I'm still stuck. Can anyone explain this with words?Moidore
I built the two automata that I can in jflap... how can I combine them into one?Moidore
C
0

The Language L where a are at-least two and b are odd is an regular language. Its DFA is as below:
a_and_odd_b

In this DFA I have combined two DFSs conceptually!

DFA-1 = for odd number of `b`'s (placed vertically three times in diagram)
DFA-2 = for >=  two a           (placed Horizontally two times in diagram)

The DFA is too symptomatic and simple so I believe no need in word that how to combine both DFAs

To draw this DFA you are always keep track how many bs has been come either even or odd. States 0, 2 and 4 means even number of b has been come. So you can divide this DFA in two parts vertically where bottom states at even bs and upper states at odd.

Also String is accepted if odd b hence final state should be in one of state in upper part.

not only number of bs is condition but a should be atleast 2. So you can divide this DFA horizontally in three parts where number of as are 0 at state-0 and 1, as are one at state-2 and 3 and as are 2 at state-4 and 5. After first two as any number of as are allow in string so there is self loop on state q4 and q5.

number of state required is six because, 2 state for odd even b and a s hould be atleast 2 so 3 states a=0, a=1, a=2, hence 2*3 = 6

Cero answered 5/2, 2013 at 11:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.