Why does the stopping problem make it impossible for software to determine the time complexity of the algorithm

I read several articles about big computing and problems with stopping. Obviously, it is impossible to say for ALL algorithms whether they will ever stop, for example:

while(System.in.readline()){ } 

However, what would be great - About such a program? I think this is not defined, for the same reason it is impossible to say if he ever stops. You do not know this.

So ... There are some possible algorithms where you cannot tell if it will ever stop. But if you can’t say big-o, this algorithm is undefined by definition.

Now, to my point, calculate a big part of the software. Why can't you write a program that does this? Because it is either a function or not defined.

In addition, I did not say anything about the programming language. What about a purely functional programming language? Can it be calculated?

+1
time-complexity metaprogramming code-analysis halting-problem
source share
2 answers

Okay, so let's talk about Turing machines (a similar discussion using the Random-Access model could be done, but I accept this for simplicity).

The upper boundary of the time complexity of the TM indicates the order of speed at which the number of transitions of the TM grows in accordance with the size of the input. In particular, if we say that TM executes an algorithm that is O (f (n)) in the worst case for input size n, we say that there exists n0 and c such that for n> n0 T (n) <= cf (n). So far so good.

Now about the Turing machines that they may not stop, that is, they can run forever for some inputs. It is clear that if for some n *> n0 a TM takes an infinite number of steps, then f (n) does not satisfy the condition (with finite n0, c) described in the last paragraph; those. T (N)! = O (f (n)) for any f. OK; if we could confidently say that TM will stop for all inputs of at least n0 length, for some n0 we are free at home. The problem is that this is equivalent to solving the stop problem.

So, we conclude the following: if TM forever stops at the input n> n0, we cannot determine the upper limit of complexity; in addition, the insoluble problem is the algorithmic determination of whether the TM will stop at all inputs more than a fixed finite n0.

+2
source share

The reason the question cannot be answered is the while (System.in.readline ()) {} program, which will stop? "that the input is not specified, so in this particular case the problem is the lack of information, not insolubility.

The problem with stopping is the impossibility of constructing a general algorithm, which, with both the program and the input, can always determine whether this program will end with this input or continue execution forever.

In the problem of stopping, both the program and the input can be arbitrarily large, but they are intended for the end.

In addition, there is no concrete instance of "program + input", which in itself is unsolvable: if a specific instance is specified, it (in principle) can always build an algorithm that analyzes this instance and / or class of instances, and calculates the correct answer.

However, if the problem is unsolvable, then no matter how many times the algorithm expands to correctly analyze additional instances or instance classes, the process will never end: it will always be possible to create new instances, the algorithm will not be able to respond if it is not expanded.

I would say that the large O of while (System.in.readline ()) {} "is equal to O (n), where n is the size of the input (a program can be thought of as a skeleton, for example, a line counting program).

Big O is determined in this case, because for each input of finite size the program stops.

So the question that needs to be asked may be: "Does the program stop at every possible final input that can be provided?"

If this request can be reduced to a stop problem or any other insoluble problem, then it cannot be solved.

It turns out that it can be reduced, as explained here: https://cs.stackexchange.com/questions/41243/halting-problem-reduction-to-halting-for-all-inputs

Undecidability is a property of problems and does not depend on programming languages ​​that are used to create programs running on the same machines. For example, you might think that any program written in a functional programming language can be compiled into machine code, but the same machine code can be created using an equivalent program written in an assembly, therefore, from the point of view of a Turing machine, the functional languages Programming is nothing more than assembly languages.

In addition, unsolvability would not prevent the algorithm from being able to calculate large O for countless (theoretically infinite) number of programs, so any efforts to build an algorithm for this purpose would not necessarily be meaningless.

0
source share

All Articles