Reducing DFA’s Section 2.4. Reduction of DFA For any language, there are many DFA’s that accept the language Why would we want to find the smallest? Algorithm:

Presentation on theme: "Reducing DFA’s Section 2.4. Reduction of DFA For any language, there are many DFA’s that accept the language Why would we want to find the smallest? Algorithm:"— Presentation transcript:

Reducing DFA’s Section 2.4

Reduction of DFA For any language, there are many DFA’s that accept the language Why would we want to find the smallest? Algorithm: Finds smallest equivalent DFA

Distinguishable States A state p is indistinguishable from another q if, for all walks w, δ*(p,w)  F implies δ*(q,w)  F and δ*(p,w)  F implies δ*(q,w)  F Otherwise, they are distinguishable

Two Step Algorithm First, mark all pairs of states as distinguishable or indistinguishable Then, merge indistinguishable states into one state for the smaller graph

Mark Algorithm 1.Remove inaccessible states 2.Mark all states in F as distinguishable from those not in F. 3.Repeat until all pairs are marked: For all pairs (p,q) and all symbols (a), if δ(p,a) is distinguishable from δ(q,a), then p is distinguishable from q.

Reduce Algorithm Create a state for each set of indistinguishable states from the Mark algorithm. Rewrite transitions between states. If δ(p,a) = q, then make a transition from the node containing the original p to the node containing the original q and label it a.

Example q0 q1 q2 q3 q4 0 0 0 0 0,1 1 1 1 1 01 q0q1q3 q1q2q4 q2q1q4 q3q2q4

Example 01 q0q1q3 q1q2q4 q2q1q4 q3q2q4 Distinguishable Pairs Final –Nonfinal states (q0,q4) (q1,q4) (q2,q4) (q3,q4)

Example 01 q0q1q3 q1q2q4 q2q1q4 q3q2q4 Distinguishable Pairs: Chart Compare (q0,q4) (q1,q4) (q2,q4) (q3,q4) (q0,q1) (q0,q2) (q0,q3)

Example Distinguishable Pairs: (q0,q4) (q1,q4) (q2,q4) (q3,q4) (q0,q1) (q0,q2) (q0,q3) Indistinguishable Pairs: {q0} {q1, q2,q3} {q4}

Example q0 q1 q2 q3 q4 0 0 0 0 0,1 1 1 1 1 01,2,34 0,11 0

Download ppt "Reducing DFA’s Section 2.4. Reduction of DFA For any language, there are many DFA’s that accept the language Why would we want to find the smallest? Algorithm:"

Similar presentations