Busy beaver
In theoretical computer science, the busy beaver game aims to find a terminating program of a given size that either produces the most output possible, or runs for the longest number of steps. Since an endlessly looping program producing infinite output or running for infinite time is easily conceived, such programs are excluded from the game. Rather than traditional programming languages, the programs used in the game are n-state Turing machines, one of the first mathematical models of computation.
Turing machines consist of an infinite tape, and a finite set of states which serve as the program's "source code". Producing the most output is defined as writing the largest number of 1s on the tape, also referred to as achieving the highest score, and running for the longest time is defined as taking the longest number of steps to halt. The n-state busy beaver game consists of finding the longest-running or highest-scoring Turing machine which has n states and eventually halts. Such machines are assumed to start on a blank tape, and the tape is assumed to contain only zeros and ones. The objective of the game is to program a set of transitions between states aiming for the highest score or longest running time while making sure the machine will halt eventually.
An n-th busy beaver, BB-n or simply "busy beaver" is a Turing machine that wins the n-state busy beaver game. Depending on definition, it either attains the highest score, or runs for the longest time, among all other possible n-state competing Turing machines.
Deciding the running time or score of the nth busy beaver is noncomputable. In fact, both the functions Σ and S eventually become larger than any computable function. This has implications in computability theory, the halting problem, and complexity theory. The concept of a busy beaver was first introduced by Tibor Radó in his 1962 paper, "On Non-Computable Functions".
One of the most consequential aspects of the busy beaver game is that, if it were possible to compute the functions Σ and S for all n, then this would resolve all mathematical conjectures which can be encoded in the form "does halt". For example, there is a 25-state Turing machine that checks Goldbach's conjecture for each number and halts on a counterexample; if this machine did not halt after running for S steps, then it must run forever, resolving the conjecture. Many other problems, including the Riemann hypothesis and the consistency of ZF set theory, can be expressed in a similar form, where at most a countably infinite number of cases need to be checked.
Technical definition
The n-state busy beaver game, introduced in Tibor Radó's 1962 paper, involves a class of Turing machines, each member of which is required to meet the following design specifications:"Running" the machine consists of starting in the starting state, with the current tape cell being any cell of a blank tape, and then iterating the transition function until the Halt state is entered. If and only if the machine eventually halts, then the number of 1s finally remaining on the tape is called the machine's score. The n-state busy beaver game is therefore a contest, depending on definition to find such an n-state Turing machine having the largest possible score or running time.
Example
The rules for one 1-state Turing machine might be:- In state 1, if the current symbol is 0, write a 1, move one space to the right, and transition to state 1
- In state 1, if the current symbol is 1, write a 0, move one space to the right, and transition to HALT
Functions
In his original 1962 paper, Radó defined two functions related to the busy beaver game: the score function Σ and the shifts function S. Both take a number of Turing machine states and output the maximum score attainable by a Turing machine of that number of states by some measure. The score function Σ gives the maximum number of 1s an -state Turing machine can output before halting, while the shifts function S gives the maximum number of shifts that an -state Turing machine can undergo before halting. He proved that both of these functions were noncomputable, because they each grew faster than any computable function. The function BB has been defined to be either of these functions, so that notation is not used in this article.A number of other uncomputable functions can also be defined based on measuring the performance of Turing machines in other ways than time or maximal number of ones. For example:
- The function is defined to be the maximum number of contiguous ones a halting Turing machine can write on a blank tape. In other words, this is the largest unary number a Turing machine of n states can write on a tape.
- The function is defined to be the maximal number of tape squares a halting Turing machine can read before halting. This includes the starting square, but not a square that the machine only reaches after the halt transition, because that square does not influence the machine's behaviour. This is the maximal space complexity of an n-state Turing machine.
Score function Σ
The score function quantifies the maximum score attainable by a busy beaver on a given measure. This is a noncomputable function, because it grows asymptotically faster than any computable function.The score function,, is defined so that is the maximum attainable score among all halting 2-symbol -state Turing machines of the above-described type, when started on a blank tape.
It is clear that is a well-defined function: for every n, there are at most finitely many n-state Turing machines as above, up to isomorphism, hence at most finitely many possible running times.p. 880
According to the score-based definition, any n-state 2-symbol Turing machine M for which is called a busy beaver. For each n, there exist at least 4! n-state busy beavers.
Non-computability
Radó's 1962 paper proved that if is any computable function, then Σ > f for all sufficiently large n, and hence that Σ is not a computable function.Moreover, this implies that it is undecidable by a general algorithm whether an arbitrary Turing machine is a busy beaver.
Even though Σ is an uncomputable function, there are some small n for which it is possible to obtain its values and prove that they are correct. It is not hard to show that Σ = 0, Σ = 1, Σ = 4, and with progressively more difficulty it can be shown that Σ = 6, Σ = 13 and Σ = 4098. Σ has not yet been determined for any instance of n > 5, although lower bounds have been established.
Complexity and unprovability of Σ
A variant of Kolmogorov complexity is defined as follows: The complexity of a number n is the smallest number of states needed for a BB-class Turing machine that halts with a single block of n consecutive 1s on an initially blank tape. The corresponding variant of Chaitin's incompleteness theorem states that, in the context of a given axiomatic system for the natural numbers, there exists a number k such that no specific number can be proven to have complexity greater than k, and hence that no specific upper bound can be proven for Σ. As mentioned in the cited reference, for any axiomatic system of "ordinary mathematics" the least value k for which this is true is far less than 10⇈10; consequently, in the context of ordinary mathematics, neither the value nor any upper-bound of Σ can be proven.Maximum shifts function ''S''
In addition to the function Σ, Radó introduced another extreme function for Turing machines, the maximum shifts function, S, defined as follows:- = the number of shifts M makes before halting, for any,
- = the largest number of shifts made by any halting n-state 2-symbol Turing machine.
Radó showed that S is noncomputable for the same reason that Σ is noncomputable – it grows faster than any computable function. He proved this simply by noting that for each n, S ≥ Σ. Each shift may write a 0 or a 1 on the tape, while Σ counts a subset of the shifts that wrote a 1, namely the ones that had not been overwritten by the time the Turing machine halted; consequently, S grows at least as fast as Σ, which had already been proved to grow faster than any computable function.
The following connection between Σ and S was used by Lin & Radó to prove that Σ = 6 and that S=21: For a given n, if S is known then all n-state Turing machines can be run for up to S steps, at which point any machine that has not yet halted will never halt. At that point, by observing which machines have halted with the most 1s on the tape, one obtains from their tapes the value of Σ. The approach used by Lin & Radó for the case of n = 3 was to conjecture that S = 21, then to simulate all the essentially different 3-state machines for up to 21 steps. They found 26,073 machines that halted, including one that halted only after 21 steps. By analyzing the behavior of the machines that had not halted within 21 steps, they succeeded in showing that none of those machines would ever halt, most of them following a certain pattern. This proved the conjecture that S = 21, and also determined that Σ = 6, which was attained by several machines, all halting after 11 to 14 steps.
In 2016, Adam Yedidia and Scott Aaronson obtained the first upper bound on the minimum n for which S is unprovable in ZFC. To do so they constructed a 7910-state Turing machine whose behavior cannot be proven based on the usual axioms of set theory, under reasonable consistency hypotheses. Stefan O'Rear then reduced it to 1919 states, with the dependency on the stationary Ramsey property eliminated, and later to 748 states. In July 2023, Riebel reduced it to 745 states. Further improvements are reported on the .
Proof for uncomputability of ''S''(''n'') and Σ(''n'')
Suppose that S is a computable function and let EvalS denote a TM, evaluating S. Given a tape with n 1s it will produce S 1s on the tape and then halt. Let Clean denote a Turing machine cleaning the sequence of 1s initially written on the tape. Let Double denote a Turing machine evaluating function n + n. Given a tape with n 1s it will produce 2n 1s on the tape and then halt.Let us create the composition Double | EvalS | Clean and let n0 be the number of states of this machine. Let Create_n0 denote a Turing machine creating n0 1s on an initially blank tape. This machine may be constructed in a trivial manner to have n0 states. Let N denote the sum n0 + n0.
Let BadS denote the composition Create_n0 | Double | EvalS | Clean. Notice that this machine has N states. Starting with an initially blank tape it first creates a sequence of n0 1s and then doubles it, producing a sequence of N 1s. Then BadS will produce S 1s on tape, and at last it will clear all 1s and then halt. But the phase of cleaning will continue at least S steps, so the time of working of BadS is strictly greater than S, which contradicts to the definition of the function S.
The uncomputability of Σ may be proved in a similar way. In the above proof, one must exchange the machine EvalS with EvalΣ and Clean with Increment — a simple TM, searching for a first 0 on the tape and replacing it with 1.
The uncomputability of S can also be established by reference to the blank tape halting problem. The blank tape halting problem is the problem of deciding for any Turing machine whether or not it will halt when started on an empty tape. The blank tape halting problem is equivalent to the standard halting problem and so it is also uncomputable. If S was computable, then we could solve the blank tape halting problem simply by running any given Turing machine with n states for S steps; if it has still not halted, it never will. So, since the blank tape halting problem is not computable, it follows that S must likewise be uncomputable.
Uncomputability of space(n) and num(n)
Both and functions are uncomputable. This can be shown for by noting that every tape square a Turing machine writes a one to, it must also visit: in other words,. The function can be shown to be incomputable by proving, for example, that : this can be done by designing an -state Turing machine which simulates the n-state space champion, and then uses it to write at least contiguous ones to the tape.Generalizations
Analogs of the shift function can be simply defined in any programming language, given that the programs can be described by bit-strings, and a program's number of steps can be counted. For example, the busy beaver game can also be generalized to two dimensions using Turing machines on two-dimensional tapes, or to Turing machines that are allowed to stay in the same place as well as move to the left and right. Alternatively a "busy beaver function" for diverse models of computation can be defined with Kolmogorov complexity. This is done by taking to be the largest integer such that, where is the length of the shortest program in that outputs : is thereby the largest integer a program with length or less can output in.The longest running 6-state, 2-symbol machine which has the additional property of reversing the tape value at each step produces 1s after steps. So for the Reversal Turing Machine class, SRTM ≥ and ΣRTM ≥. Likewise we could define an analog to the Σ function for register machines as the largest number which can be present in any register on halting, for a given number of instructions.
Different numbers of symbols
A simple generalization is the extension to Turing machines with m symbols instead of just two. For example, a trinary Turing machine with m = 3 symbols would have the symbols 0, 1, and 2. The generalization to Turing machines with n states and m symbols defines the following generalized busy beaver functions:- Σ: the largest number of non-zeros printable by an n-state, m-symbol machine started on an initially blank tape before halting, and
- S: the largest number of steps taken by an n-state, m-symbol machine started on an initially blank tape before halting.
Nondeterministic Turing machines
The problem can be extended to nondeterministic Turing machines by looking for the system with the most states across all branches or the branch with the longest number of steps. The question of whether a given NDTM will halt is still computationally irreducible, and the computation required to find an NDTM busy beaver is significantly greater than the deterministic case, since there are multiple branches that need to be considered. For a 2-state, 2-color system with p cases or rules, the table to the right gives the maximum number of steps before halting and maximum number of unique states created by the NDTM.Applications
Open mathematical problems
In addition to posing a rather challenging mathematical game, the busy beaver functions Σ and S offer an entirely new approach to solving pure mathematics problems. Many open problems in mathematics could in theory, but not in practice, be solved in a systematic way given the value of S for a sufficiently large n. Theoretically speaking, the value of S encodes the answer to all mathematical conjectures that can be checked in infinite time by a Turing machine with less than or equal to n states.Consider any conjecture: any conjecture that could be disproven via a counterexample among a countable number of cases. Write a computer program that sequentially tests this conjecture for increasing values. In the case of Goldbach's conjecture, we would consider every even number ≥ 4 sequentially and test whether or not it is the sum of two prime numbers. Suppose this program is simulated on an n-state Turing machine. If it finds a counterexample, it halts and indicates that. However, if the conjecture is true, then our program will never halt.
Now, this program is simulated by an n-state Turing machine, so if we know S we can decide whether or not it will ever halt by simply running the machine that many steps. And if, after S steps, the machine does not halt, we know that it never will and thus that there are no counterexamples to the given conjecture. This would prove the conjecture to be true. Thus specific values for S could be, in theory, used to systematically solve many open problems in mathematics.
However, current results on the busy beaver problem suggest that this will not be practical for two reasons:
- It is extremely hard to prove values for the busy beaver function. Every known exact value of S was proven by enumerating every n-state Turing machine and proving whether or not each halts. One would have to calculate S by some less direct method for it to actually be useful.
- The values of S and other busy beaver functions get very large, very quickly. While the value of S is only 47,176,870, the value of S is more than 10⇈10000000, or in tetration notation,, which is equal to with a tower of 10 million tens. A greater lower bound for S is, i.e. 2 tetrated to the 2 tetrated to the 2 tetrated to the 9 which is at least 2 pentated to the 5. The value of S, which is the number of steps the current program for the Goldbach conjecture would need to be run to give a conclusive answer, is incomprehensibly huge, and not remotely possible to write down, much less run a machine for, in the observable universe.
Consistency of theories
Another property of S is that no arithmetically sound, computably axiomatized theory can prove all of the function's values. Specifically, given a computable and arithmetically sound theory, there is a number such that for all, no statement of the form can be proved in. This implies that for each theory there is a specific largest value of S that it can prove. This is true because for every such, a Turing machine with states can be designed to enumerate every possible proof in. If the theory is inconsistent, then all false statements are provable, and the Turing machine can be given the condition to halt if, and only if, it finds a proof of, for example,. Any theory that proves the value of proves its own consistency, violating Gödel's second incompleteness theorem. This can be used to place various theories on a scale, for example the various large cardinal axioms in ZFC: if each theory is assigned as its number, theories with larger values of prove the consistency of those below them, placing all such theories on a countably infinite scale.Notable examples
- A 745-state binary Turing machine has been constructed that halts iff ZFC is inconsistent.
- A 744-state Turing machine has been constructed that halts iff the Riemann hypothesis is false.
- A 43-state Turing machine was constructed that halts iff Goldbach's conjecture is false. This was further reduced to a 27-state machine, then a 25-state machine, and later formally proved and verified in the Lean 4 theorem proving language.
- A 15-state Turing machine has been constructed that halts iff the following conjecture formulated by Paul Erdős in 1979 is false: for all n > 8 there is at least one digit 2 in the base 3 representation of 2n.
- A 6-state Turing machine has been discovered that halts iff repeated applications of starting from 4 ever produces twice as many odd values as even values. It was later named "Antihydra".
Physical Church–Turing thesis
The growth properties of the Busy Beaver function have implications for the behaviour of physical systems, assuming the truth of the physical Church–Turing thesis. If the physical Church–Turing thesis holds, and all physically computable functions are Turing-computable, then no directly measurable physical quantity can grow faster than the Busy Beaver function, as no Turing-computable function can grow faster than it. Simple functions of would also impose a lower limit on growth rates, as well as upper and lower bounds on rates of convergence.Known results
Lower bounds
Green machines
In 1964 Milton Green developed a lower bound for the 1s-counting variant of the busy beaver function that was published in the proceedings of the 1964 IEEE symposium on switching circuit theory and logical design. Heiner Marxen and Jürgen Buntrock described it as "a non-trivial lower bound". This lower bound can be calculated but is too complex to state as a single expression in terms of n. This was done with a set of Turing machines, each of which demonstrated the lower bound for a certain. When the method givesIn contrast, the best current lower bound on is, where each is Knuth's up-arrow notation. This represents, an exponentiated chain of 15 tens. The value of is probably much larger than that.
Green's lower bound was shown by a recursive construction of a series of Turing machines, each of which was made of a smaller one with two additional states that repeatedly applied the smaller machine to the input tape. Defining the value of the -state busy-beaver competitor on a tape containing ones to be, the recursion relations are as follows:
This leads to two formulas for calculating the lower bound given by the th machine:
Green's lower bound can also be related to the Ackermann function. In particular,
for all positive integers.
Relationships between busy beaver functions
Trivially, because a machine that writes ones must take at least steps to do so. It is possible to give a number of upper bounds on the time with the number of ones :By defining to be the maximum number of ones an -state Turing machine is allowed to output contiguously, rather than in any position, it is possible to show that
Ben-Amram and Petersen, 2002, also give an asymptotically improved bound on. There exists a constant such that for all,
Exact values and lower and upper bounds
The following table lists the exact values and some known lower bounds for S, Σ, and several other busy beaver functions. In this table, 2-symbol Turing machines are used. Entries listed as "?" are at least as large as other entries to the left, and no larger than entries above them ≥ space ≥ Σ ≥ num). So, space is known to be greater than 25, as space ≥ Σ and Σ > 25. is an upper bound for space, because S = and S ≥ space. 4098 is an upper bound for num, because Σ = 4098 and Σ ≥ num. The last entry listed as "?" is num, because Σ > 25, but Σ ≥ num, same for num.| Function | 2-state | 3-state | 4-state | 5-state | 6-state | 7-state |
| S | 6 | 21 | 107 | > 25 | > 223 | |
| space | 4 | 7 | 16 | 12289 | > 25 space ≥ Σ | > 223 |
| Σ | 4 | 6 | 13 | 4098 | > 25 | > 223 |
| num | 4 | 6 | 12 | ≤ 4098 | ? | ? |
The 5-state busy beaver was discovered by Heiner Marxen and Jürgen Buntrock in 1989, but only proved to be the winning fifth busy beaver in 2024 using a proof in Rocq.
List of busy beavers
These are tables of rules for Turing machines that generate Σ and S, Σ and S, Σ, Σ and S, Σ and S, and the best known lower bound for Σ and S.In the tables, columns represent the current state and rows represent the current symbol read from the tape. Each table entry is a string of three characters, indicating the symbol to write onto the tape, the direction to move, and the new state. The halt state is shown as H.
Each machine begins in state A with an infinite tape that contains all 0s. Thus, the initial symbol read from the tape is a 0.
Result key:
| A | |
| 0 | 1RH |
| 1 |
Result: 0 0 0
| A | B | |
| 0 | 1RB | 1LA |
| 1 | 1LB | 1RH |
Result: 0 0 1 1 1 0 0
| A | B | C | |
| 0 | 1RB | 0RC | 1LC |
| 1 | 1RH | 1RB | 1LA |
Result: 0 0 1 1 1 1 0 0.
This is one of several nonequivalent machines giving six 1s. Unlike the previous machines, this one is a busy beaver for Σ, but not for S.
| A | B | C | D | |
| 0 | 1RB | 1LA | 1RH | 1RD |
| 1 | 1LB | 0LC | 1LD | 0RA |
Result: 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0
| A | B | C | D | E | |
| 0 | 1RB | 1RC | 1RD | 1LA | 1RH |
| 1 | 1LC | 1RB | 0LE | 1LD | 0LA |
Result: 4098 "1"s with 8191 "0"s interspersed in 47,176,870 steps.
Note in the image to the right how this solution is similar qualitatively to the evolution of some cellular automata.
| A | B | C | D | E | F | |
| 0 | 1RB | 1RC | 1LD | 1RA | 0LD | 1RA |
| 1 | 1RA | 1RH | 0RF | 0LE | 1RC | 0RE |
Result: more than 2↑↑↑5 "1"s in more than 2↑↑↑5 steps, where 2↑↑↑5 = 2↑↑2↑↑2↑↑2↑↑2 and ↑↑ represents tetration.