Primitive recursive functions and Ackerman function

Ackerman's function is one of the most famous features in Computer Science. It is associated with at least one fundamental result and at least one simply important one. The fundamental result, to put it neatly and incomprehensibly, is as follows: there exists a definite computable function everywhere that is not primitive recursive. An important result is that the forest of disjoint sets (also known as disjoint set union) is very fast .


I really like to study the function of Ackerman, as everything connected with it is very beautiful and elegant. So the fundamental result recorded above is much easier to understand than it might seem.


From the text below you will learn what primitive recursive functions are and how to find out that the Akkerman function does not apply to them. And, of course, this text will convince you that it is an incredibly beautiful design and incredibly beautiful reasoning!


1. Why it may be interesting


The discussion of the relationship between primitive recursive functions and the Ackerman function is an example of solving the standard problem in computability theory: a certain computational model, a certain function are given, and it is necessary to determine whether this function is computable in this model.


Other similar examples are associated, for example, with algorithmic decidability , the equivalence of various computational models (Turing machines, partially recursive functions, normal Markov algorithms, and so on). And through them we are already connected with a completely practical area of ​​definition for the Turing completeness of programming languages, equivalent transformations of program texts and other interesting things.


Ackerman's function seems to have been specially created in order to be an elegant example of solving such problems. You will see this soon.


2. Ackerman function


, « ». , , , .


a0,a1,...,an,... . :


a0(x)=x+1


ai+1(x)=ai[x+2](x)


f[n](x)=f(f(...(f(x))...)) — n, n . , : , x+2 x — x.


, — , .


:


def Foo(number, argument):
    if number == 0:
        return argument + 1

    result = argument
    for i in range(argument + 2):
        result = Foo(number - 1, result)

    return result

ai(x) Foo(i, x).


. -, : ai(x)>x i x. , , a0(x)=x+1>x, a0 .


-, : ai+1(x)>ai(x) i x. , — , . :


ai+1(x)=ai[x+2](x)≥ai[2](x)=ai(ai(x))>ai(x)


,


ai+1(x)≥ai(ai(x))


3. - ()


« ». — . : , , , .


- ? «». - :


  1. , : N u l l ( x 1 , x 2 , . . . , X k ) = 0
  2. : S ( x ) = x + 1
  3. -: P i k ( x 1,x2,...,xk)=xi

. « »:


  • . f — k , g1,g2,...,gk — n , n F: n , k g1,...,gk, f. !

F(x1,...,xn)=f(g1(x1,...,xn),...,gk(x1,...,xn))


  • . f — k , g — k+2 , , :

F(x1,...,xk,0)=f(x1,...,xk)


F(x1,...,xk,y+1)=g(x1,...,xk,y,F(x1,...,xk,y))


, . : , . : , , . , .. , .


, — , , .


.


, . , . , :


Sum(x,0)=P11(x)


Sum(x,y+1)=S(P33(x,y,Sum(x,y)))


— , . , . Sum(x,0)=x, , .. x . P11. , : x,y,Sum(x,y). , P33, .


:


Mult(x,0)=Null(x)


Mult(x,y+1)=Sum(P13(x,y,Mult(x,y)),P33(x,y,Mult(x,y)))


- . , ! , :


Fib0=0
Fib1=1
Fibn+2=Fibn+Fibn+1


, ; , !


, . , F, . , G, , :


F(n)=Fibn
G(n)=Fibn+1


F 0, 1, 1, 2, 3, 5; G, , 1, 1, 2, 3, 5, 8. :
G(n+1)=G(n)+F(n)
F(n+1)=G(n)


:


F(0)=Null()


G(0)=S(Null())


F(y+1)=P12(G(y),F(y))


G(y+1)=Sum(F(y),G(y))


:


def G(x):
    if x == 0:
        return 1
    return G(x - 1) + F(x - 1)

def F(x):
    if x == 0:
        return 0
    return G(x - 1)

, , , , n- - !


4. ,


, - « » . : - k f n, :


f(x1,...,xk)<an(max(x1,...,xk))


— . , , .


, :


Null(x1,...,xk)=0<max(x1,...,xk)+1=a0(max(x1,...,xk))


S(x)=x+1=a0(x)<a1(x)


Pik(x1,...,xk)=xi≤max(x1,...,xk)<a0(max(x1,...,xk))


, , a0 (: , , ). — a0, a1. - , , , .


. : , , , , .


F f,g1,...,gk, aM. , F . :


F(x1,...,xn)=f(g1(x1,...,xn),...,gk(x1,...,xn))<


<aM(max(g1(x1,...,xn),...,gk(x1,...,xn)))<


<aM[max(aM(max(x1,...,xn)),...,aM(max(x1,...,xn)))]


<aM(aM(max(x1,...,xn)))≤aM+1(max(x1,...,xn))


f, gi, k , . aM , aM+1.


F f g, aM.


, , . : f:


F(x1,...,xk,0)=f(x1,...,xk)<aM(max(x1,...,xk))


, , :


F(x1,...,xk,1)=g(x1,...,xk,0,F(x1,...,xk,0))<


<aM(max(x1,...,xk,0,aM(max(x1,...,xk)))<


<aM(aM(max(x1,...,xk))=aM[2](max(x1,...,xk))


F, g. aM: ,


aM(max(x1,...,xk))>max(x1,...,xk,0)


, ,


F(x1,...,xk,y)<aM[y+1](max(x1,...,xk))


,


aM[y+1](max(x1,...,xk))<aM+1(max(x1,...,xk,y))


:


F(x1,...,xk,y)<aM+1(max(x1,...,xk,y))


. , , .


5. ,


, , - aM, . :


A(n)=an(n)


, , : , — . , .


: A -.


, , -. 4 M, A(x)<aM(x) x. , :


A(M+1)=aM+1(M+1)>aM(M+1)


, -. - , ! .


6. ?


, , - , . , . nn. ,


nn...nn


, -. . ny:


Pow(n,0)=S(Null())


Pow(n,y+1)=Mult(P13(n,y,Pow(n,y)),P33(n,y,Pow(n,y)))


nn:


SPow(n)=Pow(P11(n),P11(n))


, . , nnn:


SSPow(n)=Pow(P11(n),SPow(n))


By analogy, we can construct a function in which n raised to the power nfive times, ten times, a hundred times, a million times. Ackerman's function grows faster than any of these functions. That's how fast it grows!

Source: https://habr.com/ru/post/undefined/


All Articles