Designing an NFA that accepts binary strings divisible by 5 or 6

Click For Summary

Discussion Overview

The discussion revolves around designing a non-deterministic finite automaton (NFA) that accepts binary strings divisible by either 5 or 6. Participants explore the construction of transition diagrams, the union of two NFAs, and the implications of specific states in the automaton.

Discussion Character

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

Main Points Raised

  • One participant presents a transition diagram for an NFA recognizing binary strings divisible by 5 and seeks assistance in extending it to include divisibility by 6.
  • Another participant confirms the correctness of the NFA for divisibility by 5 and provides a general method for constructing NFAs for numbers divisible by a given integer.
  • A suggestion is made to create a table to clarify how remainders change when adding binary digits, specifically for divisibility by 6.
  • Several participants express confusion about how to combine the NFAs for divisibility by 5 and 6, particularly regarding the construction of a new initial state and the use of ε-transitions.
  • Clarifications are provided on how to properly set up the union of the two NFAs, including the placement of states and transitions.
  • One participant shares their updated NFAs for both divisibility by 5 and 6 and asks for feedback on their overall design.
  • Concerns are raised about the initial state of the automaton and whether it should be accepting, leading to further discussion on the requirements for the initial state in the context of the problem statement.

Areas of Agreement / Disagreement

Participants generally agree on the methods for constructing NFAs for divisibility by 5 and 6, but there is some disagreement regarding the specifics of combining the two NFAs and the role of the initial state in the union automaton.

Contextual Notes

There are unresolved questions about the correct configuration of states and transitions when combining the NFAs, particularly concerning the treatment of the initial state and accepting states.

Lolligirl
Messages
22
Reaction score
0
Hello everyone! I'm trying to make a transition diagram for an NFA that accepts strings that are either divisible by 5 or by 6. Here's the specific question:

Question: Present a transition diagram for an NFA that recognizes the set of binary strings that starts with a 1 and, when interpreted as entering the NFA most to least significant digit, each represents a binary number that is divisible by either five or six. Thus, 101, 110, 1100, 1111 are in the language, but 111, 1011 and 11010 are not.

Here is my divisible by 5 NFA so far:
https://dl.dropboxusercontent.com/u/5778771/Divisibleby5.jpg

But I get lost in the possibilities as soon as I try to make one any higher than this, like one that does divisible by 6, and then thinking of how to combine it with this one! It seems like a mess and I would appreciate some ideas greatly! :D
 
Technology news on Phys.org
Your automaton for divisibility by 5 is correct. In general, to recognize binary numbers divisible by $d$, one needs states $0,\dots,d-1$ corresponding to remainders modulo $d$. The transition function is (the first argument is a state, the second one is an input):
\begin{align}
\delta(q,0)&=2q\text{ mod }d\\
\delta(q,1)&=(2q+1)\text{ mod }d
\end{align}

To construct an automaton recognizing the union of two regular languages, make a new state and add $\varepsilon$-transition to the initial states of the automata recognizing the two languages.
 
Hi Lolligirl!

Can you make a table? (Wondering)

Suppose you already have a number that has a remainder $r$ when divided by 6.
What will the remainder become if you add a $0$ at its end?
And what if you add a $1$ at its end?

I'm thinking of a table like:

$$\text{Remainders when dividing by }6$$
\begin{array}{|c|c|c|}
\hline
r & 2r+0 & 2r+1 \\
\hline
0 & 0 & 1 \\
1 & 2 & 3 \\
2 \\
3 \\
4 \\
5 \\
\hline
\end{array}

If you have such a table, it should become clear what the state machine should look like.
 
I have created a NFA for divisibility by 5 and 6, separately, but am still a bit perplexed on how to union them together. You said, "To construct an automaton recognizing the union of two regular languages, make a new state and add ε-transition to the initial states of the automata recognizing the two languages.", but I don't entirely understand what that means. Does that mean you add a state to the end and link the final states of each to it? Also, when combining the NFA's together, I'm not sure what to do since for the numbers 0-5, there are multiple paths a 1 or 0 will lead you to, and you can only have one 1 and one 0 coming out of each state. Thanks in advance for your help!
 
awesome22 said:
I have created a NFA for divisibility by 5 and 6, separately, but am still a bit perplexed on how to union them together. You said, "To construct an automaton recognizing the union of two regular languages, make a new state and add ε-transition to the initial states of the automata recognizing the two languages.", but I don't entirely understand what that means. Does that mean you add a state to the end and link the final states of each to it? Also, when combining the NFA's together, I'm not sure what to do since for the numbers 0-5, there are multiple paths a 1 or 0 will lead you to, and you can only have one 1 and one 0 coming out of each state. Thanks in advance for your help!

Put the two state machines next to each other.
Remove the 2 arrows that point to the respective initial states.
Create a new initial state.
Connect the new initial state to the original 2 initial states with an $\varepsilon$.

It means that you can take the path from the new initial state to either of the original state machines. You do this without reading anything.
 
Oh my goodness, that's such a good way to look at it, Evgeny! I've seen those formulae before but I didn't realize what they're used for until now. Using your and I like Serena's help, here is my divisible by 6:
https://dl.dropboxusercontent.com/u/5778771/Divisibleby6.jpg

And using my divisible by 5 and divisible by 6, here's my overall NFA:
https://dl.dropboxusercontent.com/u/5778771/Divisibleby5or6.jpg

Do these seem okay at first glance? Would the new 0 state be an accepting state by itself? Thank you both again so much for helping me piece it together! :D
 
Last edited:
Lolligirl said:
Using your and I like Serena's help, here is my divisible by 6:
It looks OK, but I noticed that your problem statement says that strings should start with a 1. Therefore, the state corresponding to remainder 0 should not be initial. Instead, there should be a separate initial state that is not accepting. Since you are allowed to have an NFA, the only outgoing arrow from the initial state should be labeled with 1, and it should go to the state that corresponds to remainder 1.

Lolligirl said:
Would the new 0 state be an accepting state by itself?
No, the new initial state in the automaton that recognizes the union should not be accepting.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
4K
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 21 ·
Replies
21
Views
4K
  • · Replies 4 ·
Replies
4
Views
9K