Enumerator printing out strings from a language

272 Views Asked by At

Write down the algorithm of an enumerator that prints out EXACTLY ONCE every string in the language L = {7m+ 2 |

m ∈ N} over the alphabet A = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}.

In regards, to the enumerator, it prints out L when L accepts. How is the alphabet connected to the language, is it the input into the language? or is it the output from the language?

1

There are 1 best solutions below

3
On BEST ANSWER

So, the algorithm asks you to list out every number of the form $L = \{7m + 2 ~\vert~ m \in \mathbb N\}$.

Note that since we should just print each number once, let's check if by iterating over the different values of $m$, if we can get the same number.

\begin{align*} 7a + 2 = 7b + 2 \\ 7 (a - b) = 0 \\ a = b \end{align*}

That is, if $(7a + 2 = 7b + 2)$, then $(a = b)$. So, we can literally enumerate all numbers and be guaranteed that we won't repeat values.

If you know how to read python, the algorithm would be:

def listL():
    i = 0
    while True:
        print(7 * i  + 2)
        i += 1