Finding DFA: Hint to Construct NFA for ((0∪1)*10* ∪ 0)

  • MHB
  • Thread starter evinda
  • Start date
  • Tags
    Dfa
In summary, the conversation discusses constructing a DFA that recognizes the language $((0 \cup 1)^{\ast} 1 0^{\ast}) \cup 0$. Several difficulties are encountered in converting an NFA to a DFA, and the group discusses various steps and strategies to accomplish this task. They also consider the possibility of merging some states to simplify the DFA.
  • #1
evinda
Gold Member
MHB
3,836
0
Hello! (Wave)

I want to construct a dfa that recognizes the language $((0 \cup 1)^{\ast} 1 0^{\ast}) \cup 0$.

I have thought of the following NFA:

View attachment 5833

But I am facing difficulties on converting this to a NFA. Could you give me a hint how we could do this?
 

Attachments

  • nfad.png
    nfad.png
    2.4 KB · Views: 100
Physics news on Phys.org
  • #2
evinda said:
Hello! (Wave)

I want to construct a dfa that recognizes the language $((0 \cup 1)^{\ast} 1 0^{\ast}) \cup 0$.

I have thought of the following NFA:
But I am facing difficulties on converting this to a NFA. Could you give me a hint how we could do this?

Hey evinda! (Smile)

Once we've started recognizing $(0 \cup 1)^{\ast}$, we're too late to match the $0$ at the end.
As it is now we might match for instance $00$, which is not supposed to be accepted. :eek:

So I think we need to split the first state into 2 states, and put a new start state before them.
One for the $(0 \cup 1)^{\ast}$ part, and another for the $0$-at-the-end part. (Sweating)
 
  • #3
I like Serena said:
Hey evinda! (Smile)

Once we've started recognizing $(0 \cup 1)^{\ast}$, we're too late to match the $0$ at the end.
As it is now we might match for instance $00$, which is not supposed to be accepted. :eek:

So I think we need to split the first state into 2 states, and put a new start state before them.
One for the $(0 \cup 1)^{\ast}$ part, and another for the $0$-at-the-end part. (Sweating)

So you mean that the following nfa would recognize the language?

View attachment 5834
 

Attachments

  • nfa2.png
    nfa2.png
    2.7 KB · Views: 96
  • #4
evinda said:
So you mean that the following nfa would recognize the language?

Yep. (Nod)
 
  • #5
I like Serena said:
Yep. (Nod)

And how can we convert this to a dfa?
 
  • #6
evinda said:
And how can we convert this to a dfa?

How about following the procedure to make such a conversion? (Wondering)
 
  • #7
We should label each of the states with, say, $q_0, q_1, q_2, q_3$.
Then we'll create new states, starting with the starting state.
From there we need to create a new state that is associated with the set of states we can reach when we read $0$.
And another state that is associated with the set of states we can reach when we read $1$.
After that we should repeat until we have our DFA. (Nerd)

So the first new state is $Q_0=\{q_0\}$.
From there we get $Q_1=\{q_1, q_3\}$ that we can reach with $0$.
And $Q_2=\{q_1, q_2\}$ that we can reach with $1$. (Thinking)
 
  • #8
I like Serena said:
We should label each of the states with, say, $q_0, q_1, q_2, q_3$.
Then we'll create new states, starting with the starting state.
From there we need to create a new state that is associated with the set of states we can reach when we read $0$.
And another state that is associated with the set of states we can reach when we read $1$.
After that we should repeat until we have our DFA. (Nerd)

So the first new state is $Q_0=\{q_0\}$.
From there we get $Q_1=\{q_1, q_3\}$ that we can reach with $0$.
And $Q_2=\{q_1, q_2\}$ that we can reach with $1$. (Thinking)

We can reach $q_2$ after having read $\epsilon, 0 \text{ or } 1$ and $1$.
Why is it included at $Q_2$ ? So doesn't it contain all the states that could be reached after having read once $1$ ?

Then, do we set as $Q_3$ the set of states that can be reached from $q_1$ or $q_3$ by reading 0 and as $Q_4$ the set of states that can be reached from $q_1$ or $q_2$ by reading 1?

Or have I understood it wrong? (Thinking)
 
  • #9
evinda said:
We can reach $q_2$ after having read $\epsilon, 0 \text{ or } 1$ and $1$.
Why is it included at $Q_2$ ? So doesn't it contain all the states that could be reached after having read once $1$ ?

We can also reach $q_2$ after $\epsilon, 1$, without reading a $0$ or $1$ in between. (Thinking)
Then, do we set as $Q_3$ the set of states that can be reached from $q_1$ or $q_3$ by reading 0 and as $Q_4$ the set of states that can be reached from $q_1$ or $q_2$ by reading 1?

Or have I understood it wrong? (Thinking)

First off, $Q_2$ should be a final state, since we can stop there.
And indeed, $Q_3$ would be the state after reading $0$ from $Q_1$ representing $q_1$ or $q_3$.
Logically $Q_4$ would be the state after reading $1$ from $Q_1$ representing $q_1$ or $q_3$.
And $Q_5, Q_6$ after reading $0$ respectively $1$ from $Q_2$ representing $q_1$ or $q_2$.

When we define $Q_2,Q_3,Q_4,Q_5$, we can see if we can merge some of them without losing anything. (Thinking)
 
  • #10
I like Serena said:
We can also reach $q_2$ after $\epsilon, 1$, without reading a $0$ or $1$ in between. (Thinking)

Oh yes, that's right... (Smile)

I like Serena said:
First off, $Q_2$ should be a final state, since we can stop there.
And indeed, $Q_3$ would be the state after reading $0$ from $Q_1$ representing $q_1$ or $q_3$.
Logically $Q_4$ would be the state after reading $1$ from $Q_1$ representing $q_1$ or $q_3$.
And $Q_5, Q_6$ after reading $0$ respectively $1$ from $Q_2$ representing $q_1$ or $q_2$.

When we define $Q_2,Q_3,Q_4,Q_5$, we can see if we can merge some of them without losing anything. (Thinking)
So we have the following, right?

$$Q_0=\{q_0\} \\ Q_1=\{ q_1, q_3\} \\ Q_2=\{ q_1, q_2\} \\ Q_3= \{ q_1 \} \\ Q_4=\{ q_1, q_2\} \\ Q_5=\{ q_1, q_2\} \\ Q_6=\{ q_1, q_2\}$$

How can we check if we can merge some of the states without losing anything? (Thinking)
 
  • #11
evinda said:
Oh yes, that's right... (Smile)

So we have the following, right?

$$Q_0=\{q_0\} \\ Q_1=\{ q_1, q_3\} \\ Q_2=\{ q_1, q_2\} \\ Q_3= \{ q_1 \} \\ Q_4=\{ q_1, q_2\} \\ Q_5=\{ q_1, q_2\} \\ Q_6=\{ q_1, q_2\}$$

How can we check if we can merge some of the states without losing anything? (Thinking)

Yep. (Nod)

Additionally, $Q_1, Q_2, Q_4, Q_5, Q_6$ are all states where we can stop - final states.
But $Q_3$ is not a final state.

$Q_4, Q_5, Q_6$ are completely identical to $Q_2$.
That is, the all refer to the same set of states $\{q_1, q_2\}$, and they are all final states.
So we can remove them and redirect the arrows pointing to them to $Q_2$. (Thinking)

Now where can we go from $Q_3$? (Wondering)
 
  • #12
I like Serena said:
Yep. (Nod)

Additionally, $Q_1, Q_2, Q_4, Q_5, Q_6$ are all states where we can stop - final states.
But $Q_3$ is not a final state.

$Q_4, Q_5, Q_6$ are completely identical to $Q_2$.
That is, the all refer to the same set of states $\{q_1, q_2\}$, and they are all final states.
So we can remove them and redirect the arrows pointing to them to $Q_2$. (Thinking)

Now where can we go from $Q_3$? (Wondering)

By reading $0$ we can go to $\{q_1\}$ and by reading $1$ we go to $Q_2$, right? (Thinking)
 
  • #13
evinda said:
By reading $0$ we can go to $\{q_1\}$ and by reading $1$ we go to $Q_2$, right? (Thinking)

Reading $0$ brings us indeed back to $Q_3=\{q_1\}$. (Nod)

Doesn't reading $1$ bring us to a new state $\{q_2\}$? (Wondering)
 
  • #14
I like Serena said:
Doesn't reading $1$ bring us to a new state $\{q_2\}$? (Wondering)

Could you explain to me why? Can't we go from $q_1$ to $q_1$ by reading 1?
 
  • #15
evinda said:
Could you explain to me why? Can't we go from $q_1$ to $q_1$ by reading 1?

My mistake. You were right. Reading $1$ in $\{q_1\}$ brings us to $\{q_1,q_2\}$. (Blush)
 
  • #16
I like Serena said:
My mistake. You were right. Reading $1$ in $\{q_1\}$ brings us to $\{q_1,q_2\}$. (Blush)

(Smile)

So now will we continue with the same procedure? With which criterion do we stop? (Thinking)
 
  • #17
evinda said:
(Smile)

So now will we continue with the same procedure? With which criterion do we stop? (Thinking)

Yep. We stop if we can't get to new states any more. (Wink)
 
  • #18
I think we have the following diagrams now, don't we?

The original NFA we found for $((0∪1)^∗10^∗)∪0$ is:
View attachment 5879

And we got to the DFA:
View attachment 5878

Right? (Wondering)
 

Attachments

  • NFA_TO_DFA_converted.png
    NFA_TO_DFA_converted.png
    10.3 KB · Views: 82
  • NFA_to_DFA_orig.png
    NFA_to_DFA_orig.png
    3.7 KB · Views: 69
  • #19
I like Serena said:
I think we have the following diagrams now, don't we?

The original NFA is:And we got to the DFA:Right? (Wondering)

Yes, right... (Nod)

I like Serena said:
Yep. We stop if we can't get to new states any more. (Wink)

What do you mean? If we have found all the possible subsets of the set of the initial states? (Thinking)
 
  • #20
evinda said:
What do you mean? If we have found all the possible subsets of the set of the initial states? (Thinking)

That's not necessary.
Any of the other possible subsets are not reachable from the start state.
So there is no point to add them to the DFA.

Does the DFA we have now correspond to the language $((0∪1)^∗10^∗)∪0$? (Wondering)
 
  • #21
I like Serena said:
That's not necessary.
Any of the other possible subsets are not reachable from the start state.
So there is no point to add them to the DFA.

So do we write some of the states arbitrarily and check if these recognize the language and otherwise we continue the procedure we were talking about before? Or have I understood it wrong? (Sweating)
I like Serena said:
Does the DFA we have now correspond to the language $((0∪1)^∗10^∗)∪0$? (Wondering)

No, it doesn't. After having read for example $1^{\ast}$ we don't reach necessarily 1. Also I noticed that it doesn't recognize the word 0.
 
  • #22
evinda said:
So do we write some of the states arbitrarily and check if these recognize the language and otherwise we continue the procedure we were talking about before? Or have I understood it wrong? (Sweating)

Not really.
We begin at the start state and we add new states representing the sets of states that can be reached by $0$ respectively $1$. When the only states we can go to are already there, we're done. (Whew)
No, it doesn't. After having read for example $1^{\ast}$ we cannot reach 1. Also I noticed that it doesn't recognize the word 0.

Huh? :confused:

What do you mean that we "cannot reach $1$"?
Which word with $1^{\ast}$ can we not recognize?

Isn't $0$ recognized with $\{q_0\} \overset{0}\to \{q_1,q_3\}$ after which we can stop, since we're in a final state? (Wondering)
 
  • #23
I like Serena said:
Not really.
We begin at the start state and we add new states representing the sets of states that can be reached by $0$ respectively $1$. When the only states we can go to are already there, we're done. (Whew)

How do we know which are the only states where we can go? (Thinking)
I like Serena said:
Huh? :confused:

What do you mean that we "cannot reach $1$"?
Which word with $1^{\ast}$ can we not recognize?

Isn't $0$ recognized with $\{q_0\} \overset{0}\to \{q_1,q_3\}$ after which we can stop, since we're in a final state? (Wondering)

Oh yes, you are right! The automaton recognizes the language $((0 \cup 1)^{\ast}10^{\ast}) \cup 0$... (Blush)
 
  • #24
evinda said:
How do we know which are the only states where we can go? (Thinking)

I don't understand your question. :confused:

Didn't we check at every step what the full set of states was that we could go to from any of the state-sets we had for every input symbol?
 
  • #25
I like Serena said:
I don't understand your question. :confused:

Didn't we check at every step what the full set of states was that we could go to from any of the state-sets we had for every input symbol?

In this case, we do not have a transition function for the desired dfa.
I haven't understood when we can't get to new states... (Worried)
 
  • #26
evinda said:
In this case, we do not have a transition function for the desired dfa.
I haven't understood when we can't get to new states... (Worried)

Sure we do. We've been building the transition function.
Can you list it?
 
  • #27
I like Serena said:
Sure we do. We've been building the transition function.
Can you list it?

Don't we have the following transition function for our initial nfa? Or am I wrong? (Thinking)

$\delta: \begin{matrix}
& 0 & 1 &\epsilon\\
q_0 & \{q_1,q_3\} & \{q_1\} & \{q_1\}\\
q_1 & \{q_1\} & \{q_1, q_2\}& \varnothing\\
q_2 & \{q_2\} & \varnothing& \varnothing\\
q_3 & \varnothing & \varnothing& \varnothing
\end{matrix}$
 
  • #28
evinda said:
Don't we have the following transition function for our initial nfa? Or am I wrong? (Thinking)

$\delta: \begin{matrix}
& 0 & 1 &\epsilon\\
q_0 & \{q_1,q_3\} & \{q_1\} & \{q_1\}\\
q_1 & \{q_1\} & \{q_1, q_2\}& \varnothing\\
q_2 & \{q_2\} & \varnothing& \varnothing\\
q_3 & \varnothing & \varnothing& \varnothing
\end{matrix}$

I think we should have $\delta(q_0,0)=\{q_3\}$ and $\delta(q_0,1)=\varnothing$. (Thinking)
Otherwise it's correct.
 
  • #29
I like Serena said:
I think we should have $\delta(q_0,0)=\{q_3\}$ and $\delta(q_0,1)=\varnothing$. (Thinking)
Otherwise it's correct.

A ok. And in order to use the known procedure do we have to add new states and get rid of the $\epsilon$-transition?
Or am I wrong? (Sweating)
 
  • #30
evinda said:
A ok. And in order to use the known procedure do we have to add new states and get rid of the $\epsilon$-transition?
Or am I wrong? (Sweating)

I don't think so.
We can convert it to states with sets of the original states.
For $\epsilon$-transitions, we just need to draw in additional states that might be reached with an $\epsilon$-transition. (Thinking)
 
  • #31
I like Serena said:
I don't think so.
We can convert it to states with sets of the original states.
For $\epsilon$-transitions, we just need to draw in additional states that might be reached with an $\epsilon$-transition. (Thinking)

I haven't really understood what we have to do... (Worried)

By ignoring the $\epsilon$-transition, we have the following. Right?

$\begin{matrix}
& 0 & 1\\
\{q_0\} & \{q_3\} &\varnothing \\
\{q_3\} & \varnothing & \varnothing
\end{matrix}$

By including the $\epsilon$-transition, we have the following additional transitions:

$q_0 \overset{0,1}{\to} q_1$ and $q_0 \overset{1}{\to} q_3$

So do we have the following transition function?

$\begin{matrix}
& 0 & 1\\
\{q_0\} & \{q_1,q_3\} &\{q_1, q_3\} \\
\{q_3\} & \varnothing & \varnothing
\end{matrix}$Or have I understood it wrong? (Sweating)
 
  • #32
evinda said:
I haven't really understood what we have to do... (Worried)

By ignoring the $\epsilon$-transition, we have the following. Right?

$\begin{matrix}
& 0 & 1\\
\{q_0\} & \{q_3\} &\varnothing \\
\{q_3\} & \varnothing & \varnothing
\end{matrix}$

By including the $\epsilon$-transition, we have the following additional transitions:

$q_0 \overset{0,1}{\to} q_1$ and $q_0 \overset{1}{\to} q_3$

So do we have the following transition function?

$\begin{matrix}
& 0 & 1\\
\{q_0\} & \{q_1,q_3\} &\{q_1, q_3\} \\
\{q_3\} & \varnothing & \varnothing
\end{matrix}$Or have I understood it wrong? (Sweating)

Shouldn't that be:
$q_0 \overset{0,1}{\to} q_1$ and $q_0 \overset{1}{\to} q_2$? (Wondering)Not so fast. (Worried)
Let's start with:
$\begin{matrix}
\delta' & 0 & 1\\
\{q_0\} & \{q_1,q_3\} &\{q_1, q_2\}
\end{matrix}$

Now we've found 2 new states, and we should try and find out where we can go from them, including implicit $\epsilon$-transitions if there are any:
$\begin{matrix}
\delta' & 0 & 1\\
\{q_0\} & \{q_1,q_3\} &\{q_1, q_2\} \\
\{q_1,q_3\} & ? & ? \\
\{q_1,q_2\} & ? & ?
\end{matrix}$

(Thinking)
 
  • #33
I like Serena said:
Shouldn't that be:
$q_0 \overset{0,1}{\to} q_1$ and $q_0 \overset{1}{\to} q_2$? (Wondering)

Oh yes, right... (Blush)

I like Serena said:
Not so fast. (Worried)
Let's start with:
$\begin{matrix}
\delta' & 0 & 1\\
\{q_0\} & \{q_1,q_3\} &\{q_1, q_2\}
\end{matrix}$

Now we've found 2 new states, and we should try and find out where we can go from them, including implicit $\epsilon$-transitions if there are any:
$\begin{matrix}
\delta' & 0 & 1\\
\{q_0\} & \{q_1,q_3\} &\{q_1, q_2\} \\
\{q_1,q_3\} & ? & ? \\
\{q_1,q_2\} & ? & ?
\end{matrix}$

(Thinking)

So we have the following transition function, right?$\begin{matrix}
\delta' & 0 & 1\\
\{q_0\} & \{q_1,q_3\} &\{q_1, q_2\} \\
\{q_1,q_3\} & \{ q_1\} & \{ q_1, q_2\} \\
\{q_1,q_2\} & \{q_1,q_2\} & \{ q_1, q_2\} \\
\{q_1\} & \{ q_1\} & \{ q_1, q_2 \}
\end{matrix}$

And these are all the states that are reachable from the starting state. So we get the following dfa

View attachment 5889

which is the same as we found before, right? (Smile)
 

Attachments

  • ddf.png
    ddf.png
    5.5 KB · Views: 86
  • #34
evinda said:
Oh yes, right... (Blush)
So we have the following transition function, right?$\begin{matrix}
\delta' & 0 & 1\\
\{q_0\} & \{q_1,q_3\} &\{q_1, q_2\} \\
\{q_1,q_3\} & \{ q_1\} & \{ q_1, q_2\} \\
\{q_1,q_2\} & \{q_1,q_2\} & \{ q_1, q_2\} \\
\{q_1\} & \{ q_1\} & \{ q_1, q_2 \}
\end{matrix}$

And these are all the states that are reachable from the starting state. So we get the following dfa
which is the same as we found before, right? (Smile)

Yep! (Nod)

One observation, according to your notes:

http://mathhelpboards.com/attachments/discrete-mathematics-set-theory-logic-15/5765d1469112227-construction-dfa-pr22-jpg

the start state should be $\{q_0, q_1\}$ instead of $\{q_0\}$, although that doesn't really change the DFA. (Nerd)
 
  • #35
I like Serena said:
the start state should be $\{q_0, q_1\}$ instead of $\{q_0\}$, although that doesn't really change the DFA. (Nerd)

Why is it like that? (Thinking)
 

Similar threads

Replies
10
Views
3K
Replies
1
Views
1K
Replies
1
Views
1K
Replies
18
Views
3K
Replies
16
Views
3K
Replies
6
Views
3K
Replies
4
Views
2K
Replies
1
Views
908
Back
Top