Lexical Number Theory

Assume that the strings accepted by the automata below are interpreted as binary numbers .

What is the largest integer n n such that the set of integers accepted by the automata are always divisible by n n ?

Extra Credit: Prove your answer.

Extra Extra Credit: Is it always possible to form such an automata, for any n n ? If not, why not? If yes, how?


The answer is 3.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Let's name the states as follows:

Now, we claim that after scanning a binary string x x , the auomaton is in the state q ( x m o d 3 ) q_{(x \mod 3)} . That'd entail that the accepted strings are 0 ( m o d 3 ) \equiv 0 \pmod 3

We start with two observations:

  • If x x is a string [ 1 ] ^{[1]} , and c { 0 , 1 } c \in \left \{ 0, 1 \right \} , then x c xc is also a string referring to the integer 2 x + c 2x + c . This follows immediately from the definition of binary numbers
  • Consider the transition function δ : Q × Σ Q \delta : Q \times \Sigma^{*} \to Q that takes in a state, a string and moves the automaton to another state. This basically refers to the arrows in the diagram. They are so placed that for any state n { 0 , 1 , 2 } n \in \left \{ 0, 1, 2 \right \} , δ ( q n , c ) = q 2 n + c m o d 3 \delta(q_n,c) = q_{2n + c \mod 3}

The last piece of observation can be proven only through manual verification and is the key to the solution. In fact, the diagram is just a more complex way to represent the above transition function.

The rest of the proof follows from induction

  • Since ϵ \epsilon represents 0, it obeys the desired property.
  • Assume that there is a string x x such that after scanning the binary string x x , the auomaton is in the state q ( x m o d 3 ) q_{(x \mod 3)} . δ ( q 0 , x c ) = δ ( δ ( q 0 , x ) , c ) = δ ( q ( x m o d 3 ) , c ) = q ( 2 ( x m o d 3 ) + c ) m o d 3 = q ( 2 x + c ) m o d 3 = q x c m o d 3 \delta(q_0, xc) = \delta(\delta(q_0,x),c) = \delta(q_{(x \mod 3)},c) \\ = q_{(2 (x \mod 3) + c) \mod 3} = q_{(2x + c) \mod 3} \\ = q_{xc \mod 3}

Thus, for any string x x , the auomaton is in the state q ( x m o d 3 ) q_{(x \mod 3)} . QED


The major trick in the design of the automaton is that the transition function can be defined as δ ( q n , c ) = 2 n + c m o d 3 \delta(q_n,c) = 2n + c \mod 3 .

So yes, we could design automatons to test the divisibility by any natural number d d and in any base b b with a d d state automata with the transition function defined as δ ( q n , c ) = b n + c m o d d \delta(q_n,c) = bn + c \mod d .

Here is an automata that checks divisiblity by 5

This StackOverflow thread explains the principle in more detail.


[1] For simplicity, we choose that the empty string ϵ \epsilon is interpreted as 0

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...