Consider the following DFAs:
DFA 1 | DFA 2 |
| |
The first DFA is the solution to exercise 4.3.4 from Lab4.
5.1.1. Identify a pair of states which are indistinguishable. (Solve the exercise for the 2 given DFAs.)
DFA 1
States 2 and 5 are indistinguishable.
Looking at the DFA we can see that states 2 and 5 both go to state 6 on “1” and to 3 on “0”.
DFA 2
States 1 and 2 are indistinguishable.
Looking at the DFA we can see that states 1 and 2 both go to state 2 on “a” and to 5 on “b”.
5.1.2. Identify a pair of final or non-final states which are distinguishable. The pair must be distinguished by a word different from the empty word. (Solve the exercise for the 2 given DFAs.)
DFA 1
States 4 and 5 are distinguishable because we can accept “1” from 4, but not from 5.
DFA 2
States 0 and 5 are distinguishable because from 0 we can accept word “b”, but not from 5.
5.1.3. Compute the table of indistinguishable states for the DFA. (Solve the exercise for the 2 given DFAs.)
DFA 1
| 1 | 2 | 3 | 4 | 5 |
1 | - | - | - | - | - |
2 | X | - | - | - | - |
3 | | X | - | - | - |
4 | | X | | - | - |
5 | X | | X | X | - |
6 | X | X | X | X | X |
Initially marked pairs of (final, non-final) states:
Predecessors for (6, 1):
Predecessors for (6, 2):
Predecessors for (6, 3):
Predecessors for (6, 4):
Predecessors for (6, 5):
Predecessors for (2, 1):
Predecessors for (5, 1):
Predecessors for (3, 2):
Predecessors for (4, 2):
Predecessors for (5, 3):
Predecessors for (5, 4):
The partitions of undistinguishable states are given by the missing marks:
⇒ The partitions are: {2, 5} and {1, 3, 4}
DFA 2
| 0 | 1 | 2 | 3 | 4 |
0 | - | - | - | - | - |
1 | X | - | - | - | - |
2 | X | | - | - | - |
3 | | X | X | - | - |
4 | X | | | X | - |
5 | X | X | X | X | X |
Initially marked pairs of (final, non-final) states:
Predecessors for (5, 4):
Predecessors for (5, 1):
Predecessors for (3, 1):
Predecessors for (3, 2):
Predecessors for (5, 2):
Predecessors for (3, 4):
Predecessors for (0, 1):
Predecessors for (0, 2):
Predecessors for (0, 4):
Predecessors for (0, 5):
Predecessors for (3, 5):
The partitions of undistinguishable states are given by the missing marks:
⇒ The partitions are: {0, 3} and {1, 2, 4}
5.2.1. Minimise the DFA. (Solve the exercise for the 2 given DFAs.)
DFA 1
DFA 2
5.2.2. How can we algorithmically determine if two minimal DFAs accept the same language?
Another more elegant approach is to use state equivalence. We can treat two (not necessarily minimal) DFAs as one and the same, and compute the (in)distinguishability table over all states, in a single go. Finally, the DFAs accept the same language iff their initial states are indistinguishable.
5.2.3. Determine if the following regexes are equivalent: $ (1\cup\epsilon)(00^*1)^*0^*$ and $ (10\cup 0)^*(01 \cup 1)^*(0 \cup \epsilon)$
The two languages are not equivalent because of word “110” which is accepted by the second regex, but rejected by the first regex.
5.2.4. Remember exercise 3.3.4 from Lab3. Show that the two regexes are equivalent: $ E1 = ((ab^*a)^+b)^* $ and $ E2 = (a(b\mid aa)^*ab)^* $
There are several methods to do this.
1. The first way will be presented in the next seminar. Using closure properties we will prove both the following properties:
2. Check that the initial state of minDfa(E1) is indistinguishable from the initial state of minDfa(E2).
We will solve 2, but we will assume we have already computed minDfa for the 2 regular expressions and got the following DFAs as result:
Obs: We can tell they are the same by looking at them but the computer needs an algorithm to check this equivalence.
| 0 | 1 | 2 | 3 | 4 |
0 | - | - | - | - | - |
1 | X | - | - | - | - |
2 | X | X | - | - | - |
3 | | X | X | - | - |
4 | X | | X | X | - |
5 | X | X | | X | X |
Initially marked pairs of (final, non-final) states:
Predecessors for (0, 1):
Predecessors for (0, 2):
Predecessors for (0, 4):
Predecessors for (0, 5):
Predecessors for (2, 1):
Predecessors for (3, 1):
Predecessors for (5, 1):
Predecessors for (3, 2):
Predecessors for (4, 2):
Predecessors for (4, 3):
Predecessors for (5, 3):
Predecessors for (5, 4):
So, we get 3 sets of indistinguishable states: {0, 3}, {1, 4} and {2, 5}.
Because states 0 and 3, which are initial states in the 2 DFAs, we can conclude that the 2 DFAs accept the same language.
5.2.5. (extra) Apply the Brzozowski minimisation algorithm on DFA 1.
Brzozowski minimisation: minDfa(A) = toDfa(reverse(toDfa(reverse(A))))
Step 2:
toDfa(Reverse(A))
Step 3:
Reverse(toDfa(Reverse(A)))
Step 4:
toDfa(Reverse(toDfa(Reverse(A))))
Now we can do a complete transformation of a regex into a minimal DFA.
To get a better performance, include minDfa conversion in your project.