Bitcoin: A Total Turing Machine

Today I have released a draft of a paper I started in 2014, “Bitcoin: A Total Turing Machine”. It is available on SSRN. This is an intro. Download it if you want to read more.

We demonstrate that the Bitcoin Script language allows not only for primitive recursion, but in the deployment of an Ackerman function and hence the ability to simply recurse in Bitcoin script, we show that the script system is Turing complete. From this, we introduce a new class of Turing Machine, the PTTM or probabilistic Total Turing machine and note that Bitcoin acts as a decider or Total Turing Machine which allows us to find a NIZKPoK that can act as a TM based verifier to a Non-Interactive Proof that is run on an external and non-associated TM as a proof system. Bitcoin can extend to securely offer contracts such as best fit solutions to common logistic systems and optimisation problems including the Travelling Salesman class of problems and to the optimisation of systems. This can be offered as an open or time bound contract that guarantees payment and can be solved which allowing Pseudonymity of the bidder.

I. Introduction

In this paper, we demonstrate how Bitcoin’s scripting system forms the basis for a special class of Turing Machines called a decider (Sipser, 1996) or alternatively a total Turing machine (Kozen, 1997). This is a class of Turing Machine that halts for every input.

Any program that is Turing complete is by necessity Finite. Although you cannot decide IF a program will halt, any program that is Turing Complete will halt by definition. Any program that does Halt, must by nature have an end less than the infinite as the largest possible program that halts is always (by nature) smaller than the largest set of all programs possible. We can simply deduce from this that all UTMs[A1] (universal Turing Machines) run in finite time (although this time remains unbounded) and we cannot tell in advance if a program is in-fact decidable.

In (Wright, 2016) we demonstrate that the Script system deployed in Bitcoin is formed using the primitive recursive functions (Meyer and Ritchie, 1967). In (Wright, 2017) we extend this [A2] theory to create a toy programming language that is analogous to PL-{GOTO} of Brainerd and Landweber (1974) and hence demonstrate that the script construct is Turing Complete (ignoring the real-world constraints of script limits and size constraints). The simplest use of such a script would be the development of simple decision tree functions. We demonstrate that these can be incorporated using a stochastic component to randomise and fairly distribute the possible outcomes.

The power (and advantages) of such a system [A3] can be greatly extended in the development of extended compilers that take a high-level recursive construct (such as OP_ForLoop[1]) and “unrolling” these. The class of languages expressed in this system mirrors the set of recursive languages. It is known that all primitive recursive functions are total and computable, in this paper we also demonstrate using the Ackermann function that the Bitcoin script constructs include the ability to extend to total computable functions that are not primitive recursive. This demonstrates that Bitcoin can incorporate total computable functions that are simply “recursive” as well as primitive recursive.

The consequence of these results is that the Bitcoin system is not constrained by the original deliberately imposed limitations on the scripting language. From its original conception, the scripting language was intended to enable highly sophisticated functionality beyond simple transfer of value. The omission of a looping construct was designed to prevent DOS (denial of service) attacks infinite loops. Unfortunately, this omission has led to many observers suggesting that bitcoin is ‘not Turing Complete’ and therefore the functions it would be incapable of executing would make it unsuitable as a general-purpose programming system. This assertion is incorrect. The present paper extends an earlier paper (Wright, 2017) that proved bitcoin is for all practical purposes Turing Complete (indeed, as some other observers note, “Turing completeness is theoretical, nothing is Turing complete in practice”[2]). Accordingly, there are no real-life restrictions on its ability to perform sophisticated functionality such as the execution of smart contracts and implementation of DACs (Distributed Autonomous Corporations). In this paper, we examine how bitcoin also meets the requirements for the implementation of related concepts such as Total Turing Machine (TTM) and Probabilistic Total Turing machine (PTTM).

II.Total Turing Machine[A4]

Many misconceptions exist as to the nature of a Turing machine and the capability of such a system. A Turing machine can solve a class of “effectively calculable” functions known as λ-definable functions.

First, we define any Turing complete program to be a program that halts. Whilst it is true that we cannot determine in advance if any particular program will halt for any set of input data, we do know that a program must halt on a system that is Turing complete if it is indeed decidable and that only decidable programs are known to run to completion on a Turing complete system. As such, we know that there is necessarily a point where the decidable program halts.

The result is that all decidable programs must halt within some time bounded finite period. We can also say that no Decidable program will run infinitely on a Turing complete system or that when loaded on a Turing complete system that all decidable programs are finite.

From this, we can deduce that all Turing Complete programs and functions form a subset of the set of all possible programs. The set of all possible programs includes both those that halt on a Turing machine (that are decidable) as well as those that would run infinitely looping without end. We can show that the set of infinite and undecidable programs is not an empty set. It is a simple exercise to construct a program that will run indefinitely on an infinite tape. Such a program, given an infinite time to run will never halt. It is left to the reader to imagine a simple program that will infinitely recurse (i.e. never halts). From this, we now know that the set of all Programs, P(N) must be larger than and contain the set of decidable programs (N).

Any program that is decidable must halt. Consequently, it is bounded in time. We can hence state that for any program P(T) that is decidable and is run on a Turing Complete system that it is required to halt at some point in time. As such, the set of all programs of the form P(T) in the Set (N) that halt for some input must halt in finite time.

It is noted that although we cannot determine if every program is decidable with certainty, we can develop a Total Turing Machine that requires that all programs are “unrolled” and hence are determinable.

J. B. Rosser (1939) wrote extensively concerning “effective computability” as with the perspective that:

“Clearly the existence of CC and RC (Church’s and Rosser’s proofs) presupposes a precise definition of ‘effective’. ‘Effective method’ is here used in the rather special sense of a method each step of which is precisely predetermined and which is certain to produce the answer in a finite number of steps”.

The result is an “effective” method will create a result in the order of an output that is “decided, decisive, or desired effect”, and the system or machine must by nature be “capable of producing a result”.

Turing (1939) defined this state:

“We shall use the expression ‘computable function’ to mean a function calculable by a machine, and let ‘effectively calculable’ refer to the intuitive idea without particular identification with any one of these definitions.”

As we have alluded to above, Turing (1939) based his thesis on the premise that for any effectively calculable function there must exist a computable function. Turing stated this as:

“It was stated … that ‘a function is effectively calculable if its values can be found by some purely mechanical process.’ We may take this literally, understanding that by a purely mechanical process one which could be carried out by a machine. The development … leads to … an identification of computability with effective calculability.”

The result of this is that although all programs need not be finite, all programs that are decidable will halt on a Turing machine. More, we can say that a Turing machine will run all decidable programs and only the set of all decidable programs. The set of programs that run on a Turing machine and halt that are not decidable is a NULL set.

The Bitcoin scripting language[3] is a stack-based language similar to Forth. There are two stacks known as the main stack and the alt stack. Script commands, knowns as ‘OP_CODEs’ operate on the values in the main stack, while the alt stack is used as an additional store of data. The language was deliberately designed to exclude looping constructs to avoid the possibility of DOS attacks, however the language has many features including commands to access and manage values within the main stack (for example, OP_PICK and OP_ROLL). The original list of OP_CODEs was more extensive than is currently available (several commands were disabled by the Core developers), nevertheless bitcoin script remains a simple yet powerful language.

Wolfram’s conjecture that a 2-state 3-symbol Turing Machine is a UTM (Wolfram, 2002, p709) was proven in 2007[4] by Smith (2007). Using the logic in Wright (2017), we can show that the predicate logic system deployed in Bitcoin as a scripting language is equivalent to Wolfram’s (2,3) Turing Machine. With this insight, we see that Bitcoin is functionally a system that is known as a Total Turing Machine[A5] [CSW6] . As is demonstrated by Wright (2017) Bitcoin’s Scripting language can recurse. The language in Bitcoin described in Wright (2017) is more extensible than in Smith (2007). We can thus map directly the conjectures of Smith (2007) onto a system designed using the recursion system (Wright, 2017) within Bitcoin.

The problem is not whether a computer can be built that can run any conceivable decidable program (i.e. that halts). It becomes the problem of determining the most effective means to minimise the size of the decidable program for when a recursive loop structure is “unrolled”. The unrolled program can grow exponentially in size. [A7] For the set of all programs, it is not possible to determine if a program is decidable and will halt or even if a system can run it to completion within the time/space constraints available when run on a standard Turing Machine.

A Total Turing Machine however only accepts input that is defined within a bounded space/time parameter that is constructed and set in advance.

In the same manner, an infinite number of computations can be described by a finite recursive program, even if this program contains no explicit repetitions” (Wirth, 1976).

[1] For details see Patent filing XXX. Other loop constructs include OP_WhileLoop, OP_Case, …

[2] https://www.quora.com/Why-is-Bitcoin-not-Turing-complete

[3] https://en.bitcoin.it/wiki/Script

[4] http://www.nature.com/news/2007/071024/full/news.2007.190.html

[A1]Should this be UTM?

[A2]Extend this theory or this demonstration?

[A3]Are you referring to the advantages of this system?

[A4]This section presents a good theoretical overview on the definition of a Total Turing Machine. In my opinion the references used in this section are relevant.

[A5]In my opinion, this phrase is very difficult to follow. It needs to be reformulated. Also, I suggest adding a reference or a paragraph to introduce Bitcoin Scripting language.

[CSW6] [CSW6]I will get Stef / Antonetta to add a paragraph here

[A7]The problem statement is not clear. Please try to use shorter phrases and to formulate the problem that should be solved clearly.