Induction on String? (automata related)

204 Views Asked by At

Honestly, all I know about mathematical induction is as follow:

  1. prove $P(0)$ - base step

  2. for all $n \ge 1$, prove $(P(n − 1) \rightarrow P(n))$ - inductive step

Prove the following claim by induction on $n$

Claim: For all $n\ge 0$, if $L$ is a language that contains exactly $n$ different strings, then $L$ is regular.

I am currently trying to solve the problem above, but I just can't. I'm just new to this kind of thing, I have no idea and I cannot also infer anything from my little knowledge alone.

I don't know how to start it and I also don't know how can I apply my little knowledge described above into that problem.

Thank you very much if you can help me on above problem with careful explanation.

1

There are 1 best solutions below

0
On BEST ANSWER

As @G.Sassatelli pointed out, regular languages are closed under (finite) union. To see this, let $L_1$ and $L_2$ be two regular languages, and let $R_1$ be a regular expression for $L_1$ and $R_2$ be a regular expression for $L_2$. Then $R_1 + R_2$ is a regular expression for $L_1 \cup L_2$. Alternatively, using NFAs rather than regular expressions, if $M_1$ is an NFA that accepts $L_1$ and $M_2$ is an NFA that accepts $L_2$, then the NFA obtained by introducing a new start state which has an $\epsilon$-transition to the start state of both $M_1$ and $M_2$ will accept $L_1 \cup L_2$.

With this in mind, we can prove your claim by induction on the number of different strings $n$.

If $n = 0$, then an NFA with one state which is the start state and no accept state will accept $L$.

Now assume that $L$ contains $n$ different strings and is regular (and let $M$ be an NFA which accepts $L$). Then if we add one more string $s = s_1s_2 \dots s_l$ to $L$, we can construct an NFA $M_s$ which accepts the language consisting of $s$ simply by having a start state and one additional state for each symbol in the string, and from the start state there will be an $s_1$-transition to the next state, and from that state an $s_2$-transition to the next state, and so on until we have an $s_l$-transition to an accepting state. Now, from the previous discussion, we can construct an NFA from $M$ and $M_s$ which accepts $L \cup \{s\}$.