General Recursive Function

From BusyBeaverWiki
Jump to navigation Jump to search

General recursive functions (GRFs), also called µ-recursive functions or partial recursive functions, are the collection of partial functions k that are computable. This definition is equivalent using any Turing complete system of computation. See Wikipedia:general recursive function for background.

Historically it was defined as the smallest class of partial functions k that is closed under composition, recursion, and minimization, and includes zero, successor, and all projections (see formal definitions below). In the rest of this article, this is the formulation that we focus on exclusively. In this way, it can be considered to be a Turing complete model of computation. In fact, it is one of the oldest Turing complete models, first formalized by Kurt Gödel and Jacques Herbrand in 1933, 3 years before λ-calculus and Turing machines.

BBµ(n) is a Busy Beaver function for GRFs:BBμ(n)=max{f()|fGRF0,|f|=n}

where fGRFk means that f:k is a k-ary GRF and |f| is the "structural size" of f (the number of atoms and combinators in the definition, see details below). In other words, it is the largest number computable via a 0-ary function (a constant) with a limited "program" size. It is more akin to the traditional Sigma score for a Turing machine rather than the Step function in the sense that it maximizes over the produced value, not the number of steps needed to reach that value.

Definition

Structure

Define GRFk inductively based on the following construction rules, start with Atoms and combine them using Combinators.

Atoms
  • Zero: k,ZkGRFk is the constant 0 function Zk(x1,,xk)=0
  • Successor: SGRF1 is the successor function S(x)=x+1
  • Projection: 1ik,PikGRFk is a projection function Pik(x1,xk)=xi
Combinators
  • Composition: k,m,hGRFm,g1,gmGRFk,Ck(h,g1,gm)GRFk is the composition or substitution of the gs into h: Ck(h,g1,gm)(x1,xk)=h(g1(x1,xk),gm(x1,xk))
  • Primitive Recursion: k,gGRFk,hGRFk+2,Rk+1(g,h)GRFk+1 is primitive recursion using g as the base case and h as the inductive step.
  • Minimization / Unlimited Search: k,fGRFk+1,Mk(f)GRFk is the µ-operator which allows unlimited search.

The arity superscripts for C, R and M are redundant (except for Ck(h)) and so are sometimes omitted below.

Size

The size of a GRF is the number of atoms and combinators in the definition:

  • |Zk|=|Pik|=|S|=1
  • |C(h,g1,,gm)|=1+|h|+|g1|++|gm|
  • |R(g,h)|=1+|g|+|h|
  • |M(f)|=1+|f|

Primitive Recursion

R models a typical iterative function definition over ℕ.

Base case: Rk(g,h)(0,x2,x3,...,xk)=g(x2,x3,...,xk)

Iterative case (for x1>0): Rk(g,h)(x1,x2,...,xk)=h(x11,v,x2,x3,...,xk) where v=R(g,h)(x11,x2,x3,...,xk).

R can be recursively evaluated following its definition directly or it can be simulated as a bounded for loop like this python code:

# f = R(g,h)
def f(n, *xs):
  acc = g(*xs)
  for k in range(n):
    acc = h(k, acc, *xs)
  return acc

The iterative function h is passed two synthetic args in the front: (k) iteration number (0-indexed) and (acc) "accumulator" from previous iterations.

Both the base and iterative cases can be parameterized by values x2,x3,...,xk.

If you restrict functions to only those constructible with Z, S, P, C, R (no M) then this defines the Primitive Recursive Functions, a subset of the General Recursive Functions that always halt.

Minimization

Mk(f)(x1,...,xk)min{i:f(i,x1,...,xk)=0}

In computational language, when M(f) is evaluated it can be considered to calculate f(i,x1,...,xk) with i=0, then i=1, then i=2 etc. until one of the calls to f returns 0, at which point it returns the value of i which first gave a result of 0. If no first argument causes f to return 0, M(f) doesn't return (this is the only way for a GRF to not halt).

Macros

In order to improve readability we define the following macros. For all fGRF2,gGRF1

Macro arity Definition Size Function
Constant Kk[n] k Kk[0]:=ZkKk[n]:=C(Plus[n],Zk) 2n+1 λx1xk.n
Plus constant Plus[n] 1 Plus[1]:=SPlus[n+1]:=C(S,Plus[n]) 2n1 λx.x+n
Triangular numbers Tri 1 Tri:=R(Z0,R(S,C(Plus[2],P23))) 7 λx.x(x+1)2
Iteration RepSucc[g] 2 RepSucc[g]:=R(S,C(g,P23)) |g|+4 λx y.gx(y+1)
Iteration on first arg RepFirst[f] 2 RepFirst[f]:=R2(S,R3(f,P24)) |f|+4 λx y.(λz.f(z,y))x(y+1)
Diagonalization & Iteration DiagRep[f] 2 DiagRep[f]:=R(S,C(f,P23,P23)) |f|+5 λx y.(λz.f(z,z))x(y+1)
Diagonalization DiagS[f] 1 DiagS[f]:=C(f,S,S) |f|+3 λx.f(x+1,x+1)
Ackermann iteration AckDiag2[n,f] 2 AckDiag2[0,f]:=RepSucc[f]AckDiag2[n+1,f]:=DiagRep[AckDiag2[n,f]] 5n+4+|f|
AckDiag[n,f] 1 AckDiag[n,f]:=DiagS[AckDiag2[n,f]] 5n+7+|f|

Champions

We divide the champions tables up by enumeration categories. Starting from the simplest functions and moving to the most general.

Composition Functions

The simplest category are PRFs without Recursion. In other words, only atoms and Composition. All composition functions are equivalent to either Plus[n], C(Plus[n],Pik) or Kk[n]=C(Plus[n],Zk). For BBµ, the only options are K0[n] which is size 2n+1. These can be trivially extended to C0(K0[n]) of size 2n+2. So this proves that BBμ(2n+1),BBμ(2n+2)n. These are the best known champions up to size 13.

Primitive Recursive Functions

We get considerably more complexity by allowing all Primitive Recursive Functions (PRFs). But PRFs are still all guaranteed to be total, are decidable and are all dominated by Ackermann growth functions. They are convenient to enumerate since none diverge, so any holdouts that remain when running limited computations must eventually halt. All PRF champions up to size 13 are simple composition functions as mentioned above. PRFs with R begin at size 14. These represent the best known champions for sizes 21-24, although it seems clear that M(PRF) will surpass these values.

n Max Score Champions Champion Found # Holdouts
13 6 K[6] 0
14 7 C(DiagS[RepSucc[S]], K[2])

C(DiagS[RepSucc[Plus[2]]], K[1])

Shawn Ligocki 10 Apr 2026 0
15 7 K[7] 0
16 10 C(DiagS[RepSucc[Plus[2]]], K[1]) Shawn Ligocki 11 Apr 2026 0
17 15 C(DiagS[DiagRep[RepSucc[S]]], K[1]) Shawn Ligocki 12 Apr 2026 0
18 21 C(DiagS[RepSucc[Tri]], K[1])

C(DiagS[RepFirst[RepSucc[Plus[2]]]], K[1])

Jacob Mandelson 9 Apr 2026 0
19 39 C(DiagS[DiagRep[RepSucc[S]]], K[2]) Shawn Ligocki 12 Apr 2026 0
20 1540 C(DiagS[RepSucc[Tri]], K[2]) Jacob Mandelson 9 Apr 2026 0
21 8,589,934,591 C(DiagS[RepFirst[DiagRep[RepSucc[S]]]], K[1]) Shawn Ligocki 16 May 2026 0
22 >22230 C(DiagS[RepFirst[RepSucc[Tri]]], K[1]) Shawn Ligocki 17 May 2026 11
23 >22281 C(DiagS[RepFirst[DiagRep[RepSucc[S]]]], K[2]) Shawn Ligocki 17 May 2026
24 >2222220 C(DiagS[RepFirst[RepSucc[Tri]]], K[2]) Shawn Ligocki 17 May 2026

M(PRF)

We get another level of complexity by allowing Minimization, but only at the very top level. In other words, all of these GRF are M(f) for some PRF f. We call this M(PRF) or min_prf. This is a convenient set to explore because (1) it is Turing complete, (2) it is a smaller domain and easier to enumerate than full GRF, (3) all small known champions are of this form. All M(PRF) champions up to size 13 are simple composition functions as mentioned above.

n Max Score Champions Champion Found # Holdouts
12 5 C(K[5]) 0
13 ≥ 6 K[6] 51
14 ≥ 32 M0(C1(R2(P11,R3(P12,C4(R2(P11,P13),P24,P14))),P11,S))M0(C1(R2(S,R3(P12,C4(R2(P11,P13),P24,P14))),P11,P11)) Shawn Ligocki 29 Apr 2026 273
15 1953
16 ≥ 47 M(C(R(S,R(P12,R(P23,C(R(S,P13),P35,P25)))),P11,S)) Shawn Ligocki 5 May 2026 10,818
17 ≥ 2090 M0(C1(R2(P11,R3(P12,R4(R3(R2(S,C3(S,P23)),P14),P25))),P11,S)) Shawn Ligocki 8 May 2026 63,333

Full GRF

The final level is full GRF where Minimization is allowed at any level. The only champions currently at this level are hand-constructed GRF designed to surpass Graham's number.

n BBµ(n) Champion Champion Found # Holdouts
93 >fω+1(fω(226))Graham's number Graham() from goodstein.mgrf Racheline and Shawn Ligocki 19 May 2026
...
98 >fωfω3(3)(3)Graham's number Graham() from ack_worm.mgrf Shawn Ligocki 17 May 2026

Analysis of Champions

BBµ(14) ≥ 32

This is the smallest non-trivial champion:

Expression: M(C(R(P(1,1), R(P(2,1), C(R(P(1,1), P(3,1)), P(4,2), P(4,1)))), P(1,1), S))
Arity: 0 | Size: 14 | GRF

=== Sub-expressions ===

a := R(P(1,1), P(3,1))    [arity 2, size 3, PRF, used={1,2}]
  a(0, y) = y
  a(x, _) = x-1

b := R(P(2,1), C(a, P(4,2), P(4,1)))    [arity 3, size 8, PRF, used={1,2}]
    if 0 ≤ x ≤ y: b(x,y) = y-x
    if y+1 ≤ x ≤ 2y+1: b(x,y) = 2y+1-x
  b(x, y) = (y+1) 2^k - 1 - x  (where k is minimal such that this is ≥ 0)

c := R(P(1,1), b)    [arity 2, size 10, PRF, used={1,2}]
  def c(x, y):
    acc = y
    for i in range(x):
      acc = b(i,acc)
    return acc

=== Root ===
d := M(C(c, P(1,1), S))    [arity 0, size 14]
  def d():
    for n in 0..:
      acc = n+1
      for i in range(n):
        while acc < i:
          acc = 2*acc + 1
        acc -= i
      if acc == 0:
        return n
  d() = 32

This GRF subtracts numbers 0 to n-1 from accumulator starting at n+1 with a slightly complex underflow condition (what to do when the number goes negative). It repeats this on increasing n until this process happens to hit exactly 0. It appears to be chaotic. It can be parameterized in a couple of ways by swapping S <-> P(1,1). This parameterization seems to get the luckiest and make it up to n=32 before halting. The other co-champion has the exact same behavior, just by switching when we do S vs P(1,1) for the base case.

Cryptids

So far all Cryptids have been constructed by hand. None found "in the wild" yet.

Hand Constructed Cryptids
Size Problem Authors Ref
49 Brocard's problem aparker, star and Shawn 3 May 2026 brocard.mgrf Discord
56 5x+1 trajectory of 7 Shawn Ligocki 2 May 2026 collatz.mgrf
81 Erdos Ternary Conjecture Shawn Ligocki 28 Apr 2026 erdos.mgrf
139 Antihydra-like problem Jacob Mandelson 8 Apr 2026 Orig (size 141) Size 139

Notable GRF

Unsolved GRFs

  • Size 16: M(C(R(S, R(C(S, P(2,1)), C(R(P(1,1), P(3,1)), P(4,2), P(4,1)))), P(1,1), S))Discord Discord

Solved GRFs

Tetrahedral Divisibility

The GRF M0(C1(R2(S,R3(P12,R4(P13,R5(R4(P33,P15),P26)))),S,S)) (Size 15) halts iff there exists some n ≥ 1 such that n+3 divides Tetr(n)=n(n+1)(n+2)6.[1] aparker[2] and star[3] proved that there is no such n, therefore this GRF diverges.

Chaotic size 15

Expression: M(C(R(P(1,1), R(R(S, P(3,1)), R(R(P(2,2), P(4,1)), P(5,2)))), S, P(1,1)))
Arity: 0 | Size: 15 | GRF

=== Sub-expressions ===

a := R(S, P(3,1))    [arity 2, size 3, PRF, used={1,2}]
  a(0, y) = 1 + y
  a(x, _) = x-1

b := R(P(2,2), P(4,1))    [arity 3, size 3, PRF, used={1,3}]
  b(0, _, z) = z
  b(x, _, _) = x-1

c := R(b, P(5,2))    [arity 4, size 5, PRF, used={1,2,4}]
  c(_, 0, _, w) = w
  c(_, y, _, _) = y-1

d := R(a, c)    [arity 3, size 9, PRF, used={1,2,3}]
  d(x, 0, z) = (1 + z - x) %< (1 + z)
  d(x, y, z) = (y - x - 1) %< (1 + z)

e := R(P(1,1), d)    [arity 2, size 11, PRF, used={1,2}]
M(C(e, S, P(1,1)))    [arity 0, size 15]

Racheline proved this diverges.[4] The key here is that e(n+1, n) = d(n, y, n) for some y (the last step of the recursion) and for all y d(n, y, n) ≠ 0 since:

d(n, 0, n) = 1 d(n, y+1, n) = y+1

Macro Bounds

Let C=1log10(2)3.32

AckDiag[k, S]

Let ASk(n):=DiagRepk[RepSucc[S]](n,n)=AckDiag[k,S](n1)

  • AS0(n)=Sn(n+1)=2n+1
  • AS1(n)=AS0n(n+1)=(n+2)2n1
  • AS1(n)>C10n/C (for n2)
  • AS2(n)=AS1n(n+1)>C(10)n(n+1C)>10n[n+1C] (for n2)
  • ASk(n)=ASk1n(n+1)>(10k1)n(n+1) (for k3 and n1)

AckDiag[k, Tri]

Let ATk(n):=DiagRepk[RepSucc[Tri]](n,n)=AckDiag[k,Tri](n1)

  • Tri(n)=n(n+1)2>12n2
  • AT0(n)=Trin(n+1)>2(n+12)2n
  • AT0(2)=21, AT0(3)=1540, AT0(4)>107.42
  • AT0(n)>C1010(n1C)+1 (for n5)
  • AT1(n)=AT0n(n+1)>C(10)2n2(AT0(n+1)C)
  • AT1(2)>1010AT0(3)/C>1010463, AT1(3)>10101010AT0(4)/C>105
  • AT1(n)>102n (for n4)
  • AT2(n)=AT1n(n+1)>(10)n1(AT1(n+1))
  • AT2(2)=AT12(3)>AT1(105)>10105, AT2(3)=AT13(4)>1010108
  • AT2(n)>10(n+1) (for n4)
  • AT3(n)=AT2n(n+1)>(10)n1(AT2(n+1))
  • AT3(2)=AT22(3)>AT2(103)>10103

Pairing Functions

In order to do arbitrary computation, GRF need to be able to store arbitrary data into a single integer (since the R combinator only passes a single accumulator). There are many ways to do that and the Graham champions above accomplish it via custom binary encodings. But the traditional way to store arbitrary data into an integer is to use a pairing function. Thus there is value in finding small pairing/unpairing functions.

We define two APIs here for pairing functions:

  1. A triple of GRF Pair, Left, Right such that for all a,b: Left(Pair(a,b)) = a and Right(Pair(a,b)) = b
  2. A GRF Pair and GRF Macro LRCall[f] such that for all a,b,f: LRCall[f](Pair(a,b)) = f(a,b)

The smallest known pairing functions are:

Smallest Pairing Functions
Macro arity Definition Size Function
Pair 2 Pair:=C(AddS,C(Tri,Add),P12) 20 λxy.(x+y)(x+y+1)2+x+1
Left 1 Left:=C(RMonus,C(TriP,InvTriCeil),Pred) 38 Left(Pair(x,y))=x
Right 1 Right:=C(RMonus,P11,C(Tri,InvTriCeil)) 36 Right(Pair(x,y))=y
LRCall[f2] 1 LRCall[f]:=C(LRpart3[f],InvTriCeil,P11) 59+|f| LRCall[f](Pair(x,y))=f(x,y)

Where these are based on the following definitions:

Macros
Macro arity Definition Size Function
Addition Add 2 Add:=R(P11,C(S,P23)) 5 λxy.x+y
AddXA 3 AddXA:=R(P12,C(S,P24)) 5 λxyz.x+y
AddS 2 AddS:=R(S,C(S,P23)) 5 λxy.x+y+1
Predecesor Pred 1 Pred:=R(Z0,P12) 3 λx.x˙1
Monus RMonus 2 RMonus:=R(P11,C(Pred,P23)) 7 λxy.y˙x
Triangular numbers Tri 1 Tri:=R(Z0,AddS) 7 λx.x(x+1)2
TriP 1 TriP:=R(Z0,Add) 7 TriP(x+1)=Tri(x)
TriPXA 2 TriPXA:=R(Z1,AddXA) 7 TriPXA(x,y)=TriP(x)
Inverting Tri RMonusTri 2 RMonusTri:=C(RMonus,C(Tri,P12),P22) 18 λxy.y˙Tri(x)
InvTriCeil 1 InvTriCeil:=M(RMonusTri) 19 λy.min{x|Tri(x)y}
Combined LRCall RightPiece 3 RightPiece:=R(P22,C(Pred,P24)) 7 λxyz.z˙x
LeftPiece 3 LeftPiece:=C(RMonus,C(S,P23),P13) 12 λxyz.x˙(y+1)
LRpart1[f] 3 LRpart1[f]:=C(f,LeftPiece,RightPiece) 20+|f| λxyz.f(x˙(y+1),z˙x)
LRpart2[f] 3 LRpart2[f]:=C(LRpart1[f],P33,P13,AddXA) 28+|f| λxyz.f(z˙(x+1),x+y˙z)
LRpart3[f] 2 LRpart3[f]:=C(LRpart2[f],TriPXA,P12,P22) 38+|f| λxy.f(y˙(TriP(x)+1),TriP(x)+x˙y)