-
Notifications
You must be signed in to change notification settings - Fork 0
Does not actually constitute a proof of Turing completeness #1
Description
I'm glad you like the Meson build system, but this is not really a "proof" of Turing completeness. The mathematical definition of Turing completeness is very specific. It is not "takes a very, very, very long time to get to the result" but instead it ties to the Halting problem. Specifically, determining whether a program will exit for all possible inputs.
To prove that this is not the case, we need to show that we can prove that Meson execution will end in finite time for all possible inputs. If we can, the halting problem for this problem is not undecidable and thus the language is not Turing complete. The proof splits into two parts:
- All statemens that are not
foreachtake one step to execute and executing them will not cause a step that has already been executed to be re-executed. foreachstatements are executed at mostntimes wherenis the size of the array iterated over and since the array can not be altered while iterated over, this operation takes only a finite number of steps.
Therefore it follows that if the Meson build definition being processed has x regular operations, y foreach statements and the largest one of them has z suboperations, an upper bound on the total number of steps is tot = x + y*z. This is finite for all programs of finite size and Meson will terminate after executing a finite number of steps. Thus the system is not Turing complete.
The "flaw" in the original reasoning is this:
most programmers seem to agree that any language that can implement a brainfuck interpretor is turing-complete
This is true, but strictly speaking that script does not implement a Brainfuck interpreter. It implements an interpreter with a finite upper bound on the number of steps it can execute. Those are not Turing complete by the same reasoning as above.
The easier way of making the claim that Meson is Turing complete is that run_command can execute arbitrary programs. But even then the Turing completeness is outside of Meson. Or at least that is my excuse and I'm sticking with it. :)