Below an example is given to illustrate how solving a problem can be viewed as recognizing a language.
Consider the following problem:
Is the longest distance between two nodes(i.e. the diameter) of a given graph
less than a given integer k ?
Some of the instances of this problem are as shown below:
These problem instances can be represented by a string as follows:
Instance 1: 1,2;(1,2);1
Instance 2: 1,2,3,4;(1,2)(1,3)(1,4)(3,4);2
Instance 3: 1,2,3,4;(1,2)(1,3)(1,4)(2,3)(2,4)(3,4);2
Here the set of nodes, the set of arcs and k are separated by ; in that order in the strings.
The solution to these instances are:
Instance 1: No
Instance 2: No
Instance 3: Yes
There are infinitely many 'Yes' instances and 'No' instances for this problem.
The set of 'Yes' instances is a language and so is the set of 'No' instances.
We can thus see that solving the problem for a given instance is equivalent to
checking
whether or not
the string representing the instance belongs to the language
of 'Yes' instances
of the problem.
That is, the problem solving is the same as
the language recognition. A problem can be solved if and only if the language
of its 'Yes' instances is recognizable(decidable) by a Turing machine.
It is not solvable
if the language is merely accecptable but not recognizable, or even worse if it is not even acceptable.