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

  • Context: MHB 
  • Thread starter Thread starter evinda
  • Start date Start date
  • Tags Tags
    Dfa
Click For Summary

Discussion Overview

The discussion revolves around constructing a deterministic finite automaton (DFA) that recognizes the language $((0 \cup 1)^{\ast} 1 0^{\ast}) \cup 0$. Participants explore the process of converting a non-deterministic finite automaton (NFA) into a DFA, addressing various challenges and considerations in the conversion process.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Some participants express difficulties in converting their proposed NFA into a DFA and seek hints on how to proceed.
  • One participant suggests splitting the initial state into two states to better handle the language requirements, indicating that recognizing $(0 \cup 1)^{\ast}$ too early could lead to incorrect acceptance of strings like $00$.
  • Another participant proposes a method for labeling states and creating new states based on the sets of states reachable by reading specific inputs (0 or 1).
  • There is a discussion about the inclusion of certain states in the DFA, with some participants questioning the logic behind the transitions and the finality of certain states.
  • Participants identify that some states are identical and can be merged without losing information, leading to a more efficient DFA.
  • There is a clarification that the process continues until no new states can be reached, and participants discuss the criteria for stopping the conversion process.

Areas of Agreement / Disagreement

Participants generally agree on the steps needed to convert the NFA to a DFA, but there are ongoing discussions about specific transitions and the finality of certain states. Some points remain contested, particularly regarding the merging of states and the criteria for stopping the conversion process.

Contextual Notes

Participants express uncertainty about the exact transitions between states and the implications of merging states. There are also discussions about the reachability of certain subsets from the initial state, indicating that not all possible subsets need to be included in the DFA.

evinda
Gold Member
MHB
Messages
3,741
Reaction score
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: 145
Physics news on Phys.org
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)
 
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: 141
evinda said:
So you mean that the following nfa would recognize the language?

Yep. (Nod)
 
I like Serena said:
Yep. (Nod)

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

How about following the procedure to make such a conversion? (Wondering)
 
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)
 
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)
 
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: 125
  • NFA_to_DFA_orig.png
    NFA_to_DFA_orig.png
    3.7 KB · Views: 107
  • #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)
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 18 ·
Replies
18
Views
3K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
2
Views
2K
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 45 ·
2
Replies
45
Views
4K