...
Clausal Language (ver. 5.81.20, by P.J. Voda, J. Komara, J. Kluka)
Module  Ex01b

Included module  Standard

Included module  Mtex

Included module  Mtexrc

Included module  Mauxb

Remark 

Literature.

  • [1] J. Komara. Recursive Functions. Downloadable lecture notes available through the web page of the course.

  • [2] J. Komara and P. J. Voda. Lecture Notes in Theory of Computability. 2001.

  • [3] J. Komara and P. J. Voda. Metamathematics of Computer Programming. 2001.

  • [4] I. Korec. Úvod do teórie algoritmov. Skriptá MFF UK, 1981.


Remark 

Remark. The abbreviation p.r. stands for primitive recursive.


Remark 

Chapter. Primitive Recursive Functions.


Remark 

Section. Primitive Recursive Functions.


Remark 

Basic primitive recursive functions. See also the module Maux*.


Remark 

Composition.


Remark 

Primitive recursion.


Remark 

Primitive recursive functions.


Remark 

Example. Find a p.r. derivation of the ternary function

h (x,z,y) =z+1

Function  H_plus  / 3 displayed by Tex_f3_h as  h ( #1 , #2 , #3 )
h ( x , z , y ) =?

Remark 

Addition is primitive recursive. (1 point) Find a p.r. derivation of the addition function x+y .

Hint. Note that

0+y=y x+1+y=x+y+1

Function  Plus  / 2 displayed by Tex_f2_n_plus as  #1 + #2
x + y =?

Remark 

Subsection. Exercises.


Remark 

Exercise. Find a p.r. derivation of the multiplication function xy .

Hint. Note that

0y=0 (x+1) y=xy+y

Function  Times  / 2 displayed by Tex_f2_n_times as  #1 #2
x y =?

Remark 

Exercise. (1 point) Find a p.r. derivation of the exponentiation function xy .

Hint. Recall that

x0 =1 x y+1 =x xy

Rewrite the recurrences for the binary function

f (y,x) = xy

Function  Exp1  / 2 displayed by Tex_f2_f as  f ( #1 , #2 )
f ( y , x ) =?

Function  Exp  / 2 displayed by Tex_f2_n_exp as  #1 #2
x y =?

Remark 

Subsection. Additional Problems.


Remark 

Exercise. (1 bonus point) Find a 'short' p.r. derivation of the constant function

C256 (x) =256

Function  C256
C256 ( x ) =?

Remark 

Exercise. Find a p.r. derivation of the summation function i=0 n i .

Hint. Recall that

i=0 0 i =0 i=0 n+1 i = i=0 n i +n+1

Rewrite the recurrences for the binary function

f (n,m) = i=0 n i

with the dummy second argument.


Function  Sum1  / 2 displayed by Tex_f2_f as  f ( #1 , #2 )
f ( n , m ) =?

Function  Sum displayed by Tex_f1_n_sum as  i=0 #1 i
i=0 n i =?

Remark 

Exercise. Find a p.r. derivation of the factorial function n! .

Hint. Recall that

0! =1 (n+1) ! = (n+1) n!

Rewrite the recurrences for the binary function

f (n,m) = n!

with the dummy second argument.


Function  Fact1  / 2 displayed by Tex_f2_f as  f ( #1 , #2 )
f ( n , m ) =?

Function  Fact displayed by Tex_f1_n_fact as  #1 !
n ! =?

Remark 

Exercise. Find a p.r. derivation of the predecessor function x -. 1 .

Hint. Note that

0 -. 1=0 x+1 -. 1=x

Rewrite the recurrences for the binary function

f (x,y) =x -. 1

with the dummy second argument.


Function  Pred1  / 2 displayed by Tex_f2_f as  f ( #1 , #2 )
f ( x , y ) =?

Function  Pred displayed by Tex_f1_rec_pred as  #1 1
x 1=?

Remark 

Exercise. (1 bonus point) Find a p.r. derivation of the modified subtraction function x -. y .

Hint. Note that

x -. 0=x x -. (y+1) =x -. y -. 1

Rewrite the recurrences for the binary function

f (y,x) =x -. y

Function  Minus1  / 2 displayed by Tex_f2_f as  f ( #1 , #2 )
f ( y , x ) =?

Function  Minus  / 2 displayed by Tex_f2_n_minus as  #1 #2
x y =?

Query:


Results:

Heap used: 356464 free: 133859912
Time used: 0:0:0:44