DFA confirmation and minimization

Start from the formal

One, first convert the formal form to NFA

The normal form is converted to NFA by the following corresponding law

img

E.g:

img

Second, convert NFA to DFA (subset method)

Three concepts using the subset method:
(1) The ε-closure of the state set: The set of all states that can be reached by any state s in the state set I through any ε arc, defined as the ε-of the state set I Closure, expressed as ε − closure () ε -closure()eclosure()

(2) The a-arc transition of the state set: The set of all states that any state s in the state set I can reach through an a-arc is defined as the a-arc transition of the state set 1, expressed as move(l,a).

(3) The closure a of the arc transition of the state set a: lg = ε − closure (move (l, a)) lg = ε-closure(move(l,a))lg=eclosure(move(l,a))

The above regular expression is converted to NFA:

img

First start from the initial state 0:

[Because each state reaches itself through an ε arc, the closure of ε contains itself]

(1) Find the closure of ε of 0: the state that can be reached through any ε, the set is {0,1,3,4,5,6,7,9}

(2) Find the a-arc conversion of 0: 1 reaches 2 through a-arc, 4 reaches 4 through a-arc, and the rest do not reach a certain state through a-arc, so the set is {2,4}
(3) Find a-arc conversion The closure of: {2,4} can be reached through any ε respectively, the set is {2,4,6,7,9}

(4) Find the b arc transition of 0: 5 passes b to 5, 7 passes b to 8, and the rest do not pass a b arc to reach a certain state, so the set is {5,8}

(5) Find the closure of the b-arc transformation: {5,8} can be reached through any ε respectively, the set is {5,6,7,8,9}
0's ε-closure: {0, 1,3,4,5,6,7,9}
0's a arc conversion: {2,4}
0's a arc conversion ε-closure: {2,4,6,7,9}
0's b Arc conversion: {5,8}
0's b-arc conversion ε-closure: {5,6,7,8,9}
Now make a table:
(1) The number of columns in the table is the number of input characters + 1 , This title is two input characters a and b, so there are 3 columns.
(2) Fill in the ε-closure of the initial state in the first row of the first column (the ε-closure of this question 0), and fill in the ε-closure of the a arc transformation of the initial state in the first row of the second column (this question 0 The ε-closure of the a-arc conversion of the third column, the first row of the third column, and the ε-closure of the b-arc conversion of the initial state (the ε-closure of the b-arc conversion of this question 0)...and so on.
(3) Below the second row of the first column, fill in the set of states that have not appeared after the second column of the previous row. (None of the first row, second column and third column of this question appear in the first column, fill them in the first column)

I I a I_a Ia I b I_b Ib
{0,1,3,4,5,6,7,9} {2,4,6,7,9} {5,6,7,8,9}
{2,4,6,7,9}
{5,6,7,8,9}

The following figure shows the completed table:
[The new method of judging the final state is that the set containing the original final state is the final state. For example, the original final state of this question is 9, so the set containing 9 is the final state, [双圈Represents the final state]; the
new initial state is the initial state as the set containing the original initial state. For example, in this question, the original initial state is 0, so the set containing 0 is the initial state.]

img

Relabel the state set in the table:

img

You can get the following picture:

img

This graph is not a minimized DFA, and it needs to be minimized. But the following DFA minimization re-examples.

3. Minimize DFA

First understand a few concepts:

1. Redundant state: for a state S i S_iSi, If starting from the starting state, it is impossible to reach the changed state Si, then Si is redundant (useless) state.

2. Dead state: For a state Si , for any input symbol a, if it is impossible to reach the end state from it after turning to itself, then Si is called the dead state.

1,2 are called irrelevant states

3. Equivalent state: If Si is a state of an automaton, we denote the set of all symbol strings that can be derived from Si as L(Si).
Suppose there are two states Si and Sj, if there are L (S i) = L (S j) L (Si) = L (Sj)L S i =L ( S j ) , then it is said that Si and Sj are equivalent states.

4. Distinguishable states: the two states Si and Sj in the automaton, if they are not equivalent, they are called distinguishable.

5. Judgment conditions for the equivalence of the two states (Si and Sj):

(1) The states Si and Sj must be in the terminal state or in the non-terminal state at the same time. That is, the terminal state and the non-terminal state are distinguishable.

(2) The states Si and Sj must go to the equivalent state for any input symbol a∈Σ, otherwise Si and Sj are distinguishable.

The simplification algorithm of DFA: For DFA M=(S,Σ,f,S0,Z)
(1) First, initialize the state set of DFA and divide it into Π=(Z,SZ);
(2) Use the following process to Π constructs a new division Π new
for (each group G in Π) do //Each group is a state set
begin
divides G into groups, any two states Si and Sj in G are in the same group, when And only if for any input symbol a in Σ, the a conversion of Si and Sj is in the same group, move(Si,a) ∈Gi, move(Sj,a) ∈Gi. In this way, as long as the a conversion of Si and Sj is in different groups, it means that Si and Sj are distinguishable and can be divided. Replace the original G with the newly completed division of G in Π new.
end; Π := Π new;
(3) Repeat (2) until each state set in Π can no longer be divided (Π new = Π);
(4) Combine equivalent states, in each G, take Any state as a representative, delete other states;
(5) Delete irrelevant states, and the transition from other states to irrelevant states becomes undefined.
For example:

img

①First division: Π0=({2,3,4,5},{0,1})

②In G={2,3,4,5}: f(2,a)=1, f(4,a)=0 (turn to the final state set {0,1}); f(3,a) =3,f(5,a)=5 (turning to the non-final state set {2,3,4,5}), so {2,4} and {3,5} are distinguishable, so Π1=({ 2,4}, {3,5}, {0,1});

③In G={2,4}, f(2,a)=1, f(4,a)=0 (turn to the final state subset), and f(2,b)=3,f(4, b)=5 (turn to non-final state subset {3,5}), so it is indistinguishable, no more division;

④Consider G={3,5}, f(3,a)=3, f(5,a)=5 (turn to non-final state subset {3,5}), f(3,b)=2, f(5,b)=4 (turn to non-final state subset {2,4}), so it is indistinguishable and no more division;

⑤Consider G={0,1}, f(0,a)=f(1,a)=1 (turn to the final state set {0,1}); f(0,b)=2,f(1, b)=4 (turn to non-final state subset {2,4}), so it is indistinguishable, no more division;

⑦ Further investigation, we can find that each subset cannot be divided;

⑧ Eliminate the equivalent state: {0,1} is represented by 0, {2,4} is represented by 2, {3,5} is represented by 3, as shown in the right figure

⑨Remove the irrelevant state, because there is no irrelevant state in DFA M', the following figure is the final result.

img

Guess you like

Origin blog.csdn.net/qq_41870170/article/details/115127610