Why are every finite language decidable?

18.2k Views Asked by At

I don't understand why every finite language is decidable. For example, if I have an infinite set of strings L over an alphabet E, why is there a Turing Machine M that decides L? I understand the definition of decidable; however, why is every finite language decidable? Does there every exist a finite language that is not accepted?

EDIT: Any proof on this that I can go through is also appreciated

2

There are 2 best solutions below

4
On

In a finite language there will be a maximal length of any string in the language -- call it $n$.

There are finitely many possible strings of at most $n$ symbols. Construct a Turing machine with a state for each of those strings. As long as the state corresponds to a string of less than $n$ symbols it will move right and switch to a state that encodes the prefix of the input it has seen up until now.

When it is in a state that corresponds to a full length-$n$ string, the machine will halt and accept if the string it saw is in the language and it's currently reading a blank square; otherwise it will reject.

0
On

Here are two short proofs to answer your questions:

Given a finite language we know that there are a finite number of strings in it and that these strings are of finite length. Therefore we can describe this language by either a DFA or a regular expression. Regular expressions and DFAs describe regular languages which are a subset of decidable languages, hence decidable. $\Box$

In regard to your second question, we know that DFAs are closed under complement and decidable eg switch accept and reject states. Since we can express finite languages as DFAs, finite languages are closed under complement and are decidable. $\Box$