II. Recursive Function Yuxi Fu BASICS, Shanghai Jiao Tong - - PowerPoint PPT Presentation

ii recursive function
SMART_READER_LITE
LIVE PREVIEW

II. Recursive Function Yuxi Fu BASICS, Shanghai Jiao Tong - - PowerPoint PPT Presentation

II. Recursive Function Yuxi Fu BASICS, Shanghai Jiao Tong University Hilberts Program The epochal address of David Hilbert (23Jan.1862-14Feb.1934) to the International Congress of Mathematicians (Paris, 1900): 1. Consistency of the Axioms of


slide-1
SLIDE 1
  • II. Recursive Function

Yuxi Fu

BASICS, Shanghai Jiao Tong University

slide-2
SLIDE 2

Hilbert’s Program

The epochal address of David Hilbert (23Jan.1862-14Feb.1934) to the International Congress of Mathematicians (Paris, 1900):

  • 1. Consistency of the Axioms of Arithmetic.

This is the second among Hilbert’s 23 problems published in 1900 (ten were announced in the Paris Congress).

  • 2. Entscheidungsproblem (decision problem) of first order logic.

Yuxi Fu

  • II. Recursive Function

1 / 49

slide-3
SLIDE 3

  • del’s Incompleteness Theorem

Hilbert retired in 1930, and gave a special speech to the annual meeting of the Society of German Scientists and Physicians in his birth place, K¨

  • nigsberg.

It was in this occasion he made his famous remark ”Wir m¨ ussen wissen. Wir werden wissen.” Kurt G¨

  • del (28April.1906-14Jan.1978), a young man from Vienna

and one year past his PhD, announced his Incompleteness Theorem in a roundtable discussion at the Conference on Epistemology held jointly with the Society meetings. (one day before Hilbert’s speech!)

Yuxi Fu

  • II. Recursive Function

2 / 49

slide-4
SLIDE 4

History of Recursion Theory

  • del’s remarkable idea is the arithmetization of syntax.

He used primitive recursive functions to do encoding. In 1931 G¨

  • del was aware of the Ackermann function.

By taking a suggestion from Herbrand, he developed in 1934 a formal system of Herbrand-G¨

  • del recursive functions.

Kleene (5Jan.1909-25Jan.1994) introduced in 1936 the µ-recursive functions, based on the system of the primitive recursive functions and an unbounded search operator.

Yuxi Fu

  • II. Recursive Function

3 / 49

slide-5
SLIDE 5

Synopsis

  • 1. Primitive Recursive Function
  • 2. Ackermann Function
  • 3. Recursive Function

Yuxi Fu

  • II. Recursive Function

4 / 49

slide-6
SLIDE 6
  • 1. Primitive Recursive Function

Yuxi Fu

  • II. Recursive Function

5 / 49

slide-7
SLIDE 7

Recursion Theory offers a mathematical model for the study of effective calculability.

◮ All effective objects can be encoded by natural numbers. ◮ All effective procedures can be modeled by functions from

numbers to numbers.

Yuxi Fu

  • II. Recursive Function

6 / 49

slide-8
SLIDE 8

Initial Function

  • 1. The zero function 0 def

= λx1 . . . λxn.0.

  • 2. The successor function s(x) def

= λx.x+1.

  • 3. The projection function Un

i (x1, . . . , xn) def

= λx1 . . . λxn.xi.

Yuxi Fu

  • II. Recursive Function

7 / 49

slide-9
SLIDE 9

Composition

Suppose f (y1, . . . , yk) is a k-ary function and g1( x), . . . , gk( x) are n-ary functions, where x abbreviates x1, . . . , xn. The composition function h( x) is defined by h( x) = f (g1( x), . . . , gk( x)),

Yuxi Fu

  • II. Recursive Function

8 / 49

slide-10
SLIDE 10

Recursion

Suppose that f ( x) is an n-ary function and g( x, y, z) is an (n+2)-ary function. The recursion function h( x) is defined by h( x, 0) = f ( x), (1) h( x, y + 1) = g( x, y, h( x, y)). (2) Clearly there is a unique function that satisfies (1) and (2).

Yuxi Fu

  • II. Recursive Function

9 / 49

slide-11
SLIDE 11

Primitive Recursive Recursion

The set of primitive recursive function is the least set generated from the initial functions, composition and recursion.

Yuxi Fu

  • II. Recursive Function

10 / 49

slide-12
SLIDE 12

Dummy Parameter

  • Proposition. Suppose that f (y1, . . . , yk) is a primitive recursive

and that xi1, . . . , xik is a sequence of k variables from x1, . . . , xn (possibly with repetition). Then the function h given by h(x1, . . . , xn) = f (xi1, . . . , xik) is primitive recursive.

Proof.

h( x) = f (Un

i1(

x), . . . , Un

ik(

x)).

Yuxi Fu

  • II. Recursive Function

11 / 49

slide-13
SLIDE 13

Basic Arithmetic Function

x + y: x + 0 = x, x + (y + 1) = (x + y) + 1. xy: x0 = 0, x(y + 1) = xy + x. xy: x0 = 1, xy+1 = xyx.

Yuxi Fu

  • II. Recursive Function

12 / 49

slide-14
SLIDE 14

Basic Arithmetic Function

x ˙ −1: 0 ˙ −1 = 0, (x + 1) ˙ −1 = x. x ˙ −y def = x − y, if x ≥ y, 0,

  • therwise. :

x ˙ −0 = x, x ˙ −(y + 1) = (x ˙ −y) ˙ −1.

Yuxi Fu

  • II. Recursive Function

13 / 49

slide-15
SLIDE 15

Basic Arithmetic Function

sg(x) def = 0, if x = 0, 1, if x = 0. : sg(0) = 0, sg(x + 1) = 1. sg(x) def = 1, if x = 0, 0, if x = 0. : sg(x) = 1 ˙ −sg(x).

Yuxi Fu

  • II. Recursive Function

14 / 49

slide-16
SLIDE 16

Basic Arithmetic Function

|x − y| = (x ˙ −y) + (y ˙ −x). x!: 0! = 1, (x + 1)! = x!(x + 1). min(x, y) = x ˙ −(x ˙ −y). max(x, y) = x + (y ˙ −x).

Yuxi Fu

  • II. Recursive Function

15 / 49

slide-17
SLIDE 17

Basic Arithmetic Function

rm(x, y) def = the remainder when y is devided by x: rm(x, y + 1)

def

= rm(x, y) + 1 if rm(x, y) + 1 < x, 0,

  • therwise.

The recursive definition is given by rm(x, 0) = 0, rm(x, y + 1) = (rm(x, y) + 1)sg(x ˙ −(rm(x, y) + 1)).

Yuxi Fu

  • II. Recursive Function

16 / 49

slide-18
SLIDE 18

Basic Arithmetic Function

qt(x, y) def = the quotient when y is devided by x: qt(x, y + 1)

def

= qt(x, y) + 1, if rm(x, y) + 1 = x, qt(x, y), if rm(x, y) + 1 = x. The recursive definition is given by qt(x, 0) = 0, qt(x, y + 1), = qt(x, y) + sg(x − (rm(x, y) + 1)).

Yuxi Fu

  • II. Recursive Function

17 / 49

slide-19
SLIDE 19

Basic Arithmetic Function

div(x, y) def = 1, if x divides y, 0,

  • therwise.

: div(x, y) = sg(rm(x, y)).

Yuxi Fu

  • II. Recursive Function

18 / 49

slide-20
SLIDE 20

Bounded Sum and Bounded Product

Bounded sum:

  • y<0

f ( x, y) = 0,

  • y<z+1

f ( x, y) =

  • y<z

f ( x, y) + f ( x, z). Bounded product:

  • y<0

f ( x, y) = 1,

  • y<z+1

f ( x, y) = (

  • y<z

f ( x, y)) · f ( x, z).

Yuxi Fu

  • II. Recursive Function

19 / 49

slide-21
SLIDE 21

Bounded Sum and Bounded Product

By composition the following functions are also primitive recursive if k( x, w) is primitive recursive:

  • z<k(

x, w)

f ( x, z) and

  • z<k(

x, w)

f ( x, z).

Yuxi Fu

  • II. Recursive Function

20 / 49

slide-22
SLIDE 22

Bounded Minimization Operator

Bounded search: µz<y(f ( x, z) = 0)

def

= the least z < y, such that f ( x, z) = 0; y, if there is no such z.

Yuxi Fu

  • II. Recursive Function

21 / 49

slide-23
SLIDE 23

Bounded Minimization Operator

Bounded search: µz<y(f ( x, z) = 0)

def

= the least z < y, such that f ( x, z) = 0; y, if there is no such z. Proposition. If f ( x, z) is primitive recursive, then so is µz<y(f ( x, z) = 0).

Proof.

µz<y(f ( x, z) = 0) =

v<y( u<v+1 sg(f (

x, u))).

Yuxi Fu

  • II. Recursive Function

21 / 49

slide-24
SLIDE 24

Bounded Minimization Operator

If f ( x, z) and k( x, w) are primitive recursive functions, then so is the function µz<k( x, w)(f ( x, z) = 0).

Yuxi Fu

  • II. Recursive Function

22 / 49

slide-25
SLIDE 25

Primitive Recursive Predicate

Suppose M(x1, . . . , xn) is an n-ary predicate of natural numbers. The characteristic function cM( x), where x = x1, . . . , xn, is cM(a1, . . . , an) = 1, if M(a1, . . . , an) holds, 0, if otherwise. The predicate M( x) is primitive recursive if cM is primitive recursive.

Yuxi Fu

  • II. Recursive Function

23 / 49

slide-26
SLIDE 26

Closure Property

  • Proposition. The following statements are valid:

◮ If R(

x) is a primitive recursive predicate, then so is ¬R( x).

◮ If R(

x), S( x) are primitive recursive predicates, then the following predicates are primitive recursive:

◮ R(

x) ∧ S( x);

◮ R(

x) ∨ S( x).

◮ If R(

x, y) is a primitive recursive predicate, then the following predicates are primitive recursive:

◮ ∀z < y.R(

x, z);

◮ ∃z < y.R(

x, z).

Proof.

For example c∀z<y.R(

x,z)(

x, y) =

z<y cR(

x, z).

Yuxi Fu

  • II. Recursive Function

24 / 49

slide-27
SLIDE 27

Definition by Case

Suppose that f1( x), . . . , fk( x) are primitive recursive functions, and M1( x), . . . , Mk( x) are primitive recursive predicates, such that for every x exactly one of M1( x), . . . , Mk( x) holds. Then the function g( x) given by g( x) =          f1( x), if M1( x) holds, f2( x), if M2( x) holds, . . . fk( x), if Mk( x) holds. is primitive recursive.

Proof.

g( x) = cM1( x)f1( x) + . . . + cMk( x)fk( x).

Yuxi Fu

  • II. Recursive Function

25 / 49

slide-28
SLIDE 28

More Arithmetic Function

  • Proposition. The following functions are primitive recursive.

(i) D(x) = the number of divisors of x; (ii) Pr(x) = 1, if x is prime, 0, if x is not prime. ; (iii) px = the x-th prime number; (iv) (x)y =    k, k is the exponent of py in the prime factorisation of x, for x, y > 0, 0, if x = 0 or y = 0. .

Yuxi Fu

  • II. Recursive Function

26 / 49

slide-29
SLIDE 29

More Arithmetic Function

Proof.

(i) D(x) =

y<x+1 div(y, x).

(ii) Pr(x) = sg(|D(x) − 2|). (iii) px can be recursively defined as follows: p0 = 0, px+1 = µz < (2 + px!)

  • 1 ˙

−(z ˙ −px)Pr(z) = 0

  • .

(iv) (x)y = µz<x(div(pz+1

y

, x) = 0).

Yuxi Fu

  • II. Recursive Function

27 / 49

slide-30
SLIDE 30

Encoding a Finite Sequence

Suppose s = (a1, a2, . . . , an) is a finite sequence of numbers. It can be coded by the following number b = pa1+1

1

pa2+1

2

. . . pan+1

n

. Then the length of s can be recovered from µz<b((b)z+1 = 0), and the i-th component can be recovered from (b)i ˙ −1.

Yuxi Fu

  • II. Recursive Function

28 / 49

slide-31
SLIDE 31

Not all Computable Functions are Primitive Recursive

Using the fact that all primitive recursive functions are total, a diagonalisation argument shows that non-primitive recursive computable functions must exist. The same diagonalisation argument applies to all finite axiomatizations of computable total function.

Yuxi Fu

  • II. Recursive Function

29 / 49

slide-32
SLIDE 32
  • 2. Ackermann Function

Yuxi Fu

  • II. Recursive Function

30 / 49

slide-33
SLIDE 33

Ackermann Function

The Ackermann function [1928] is defined as follows: ψ(0, y) ≃ y + 1, ψ(x + 1, 0) ≃ ψ(x, 1), ψ(x + 1, y + 1) ≃ ψ(x, ψ(x + 1, y)). The equations clearly define a total function.

Yuxi Fu

  • II. Recursive Function

31 / 49

slide-34
SLIDE 34

Ackermann Function is Monotone

The Ackermann function is monotone: ψ(n, m) < ψ(n, m + 1), ψ(n, m) < ψ(n + 1, m). The Ackermann function grows faster on the first parameter: ψ(n, m + 1) ≤ ψ(n + 1, m) ψ(n, m) + C is dominated by ψ(J, m) for some large enough J: ψ(n, m) + ψ(n′, m) < ψ(max(n, n′) + 4, m), ψ(n, m) + m < ψ(n + 4, m).

Yuxi Fu

  • II. Recursive Function

32 / 49

slide-35
SLIDE 35

Ackermann Function Grows Fast

  • Lemma. Let f (

x) be a k-ary primitive recursive function. Then there exists some J such that for all n1, . . . , nk we have that f (n1, . . . , nk) < ψ(J,

k

  • i=1

nk).

Proof.

The proof is by structural induction. (i) f is one of the initial functions. In this case take J to be 1.

Yuxi Fu

  • II. Recursive Function

33 / 49

slide-36
SLIDE 36

Ackermann Function Grows Fast

(ii) f is the composition function h(g1( x), . . . , gm( x)). Then f ( n) = h(g1( n), . . . , gm( n)) < ψ(J0,

m

  • i=1

gi( n)) < ψ(J0,

m

  • i=1

ψ(Ji,

k

  • j=1

nj)) < ψ(J0, ψ(J∗,

k

  • j=1

nj)) < ψ(J∗, ψ(J∗ + 1,

k

  • j=1

nj)) = ψ(J∗ + 1,

k

  • j=1

nj + 1) ≤ ψ(J∗ + 2,

k

  • j=1

nj). Now set J = J∗ + 2.

Yuxi Fu

  • II. Recursive Function

34 / 49

slide-37
SLIDE 37

Ackermann Function Grows Fast

Suppose f is defined by the recursion: f ( x, 0) ≃ h( x), f ( x, y + 1) ≃ g( x, y, f ( x, y)). Then h( n) < ψ(Jh, n) and g( n, m, p) < ψ(Jg, n + m + p). It is easy to prove f (n1, . . . , nk, m) < ψ(J,

k

  • i=1

nk + m) by induction on m.

  • Yuxi Fu
  • II. Recursive Function

35 / 49

slide-38
SLIDE 38

Faster than any Primitive Recursive Function

Now suppose ψ(x, y) was primitive recursive. By composition ψ(x, x) would be primitive recursive. According to the Lemma ψ(n, n) < ψ(J, n) for some J and all n, which would lead to the contradiction ψ(J, J) < ψ(J, J).

Yuxi Fu

  • II. Recursive Function

36 / 49

slide-39
SLIDE 39

Faster than any Primitive Recursive Function

The Ackermann function grows faster than every primitive recursive function.

Yuxi Fu

  • II. Recursive Function

37 / 49

slide-40
SLIDE 40
  • 3. Recursive Function

Yuxi Fu

  • II. Recursive Function

38 / 49

slide-41
SLIDE 41

Minimization Operator, or Search Operator

Minimization function, or µ-function, or search function: µy(f ( x, y) = 0) ≃        the least y such that f ( x, y) is defined for all z ≤ y, and f ( x, y) = 0, undefined if otherwise. Here ≃ is the computational equality.

Yuxi Fu

  • II. Recursive Function

39 / 49

slide-42
SLIDE 42

Minimization Operator, or Search Operator

Minimization function, or µ-function, or search function: µy(f ( x, y) = 0) ≃        the least y such that f ( x, y) is defined for all z ≤ y, and f ( x, y) = 0, undefined if otherwise. Here ≃ is the computational equality. The recursion operation is a well-founded going-down procedure. The search operation is a possibly divergent going-up procedure.

Yuxi Fu

  • II. Recursive Function

39 / 49

slide-43
SLIDE 43

Recursive Function

The set of recursive functions is the least set generated from the initial functions, composition, recursion and minimization.

Yuxi Fu

  • II. Recursive Function

40 / 49

slide-44
SLIDE 44

Decidable Predicate

A predicate R( x) is decidable if its characteristic function cR( x)

def

= 1, if R( x) is true, 0,

  • therwise.

is a recursive function.

Yuxi Fu

  • II. Recursive Function

41 / 49

slide-45
SLIDE 45

Decidable Predicate

A predicate R( x) is decidable if its characteristic function cR( x)

def

= 1, if R( x) is true, 0,

  • therwise.

is a recursive function. The predicate R( x) is partially decidable if its partial characteristic function χR( x)

def

= 1, if R( x) is true, ↑,

  • therwise.

is a recursive function.

Yuxi Fu

  • II. Recursive Function

41 / 49

slide-46
SLIDE 46

Closure Property

  • Proposition. The following statements are valid:

◮ If R(

x) is decidable, then so is ¬R( x).

◮ If R(

x), S( x) are (partially) decidable, then the following predicates are (partially) decidable:

◮ R(

x) ∧ S( x);

◮ R(

x) ∨ S( x).

◮ If R(

x, y) is (partially) decidable, then the following predicates are (partially) decidable:

◮ ∀z < y.R(

x, y);

◮ ∃z < y.R(

x, y).

Yuxi Fu

  • II. Recursive Function

42 / 49

slide-47
SLIDE 47

Definition by Cases

Suppose f1( x), . . . , fk( x) are recursive and M1( x), . . . , Mk( x) are partially decidable. For every x at most one of M1( x), . . . , Mk( x)

  • holds. Then the function g(

x) given by g( x) ≃          f1( x), if M1( x) holds, f2( x), if M2( x) holds, . . . fk( x), if Mk( x) holds. is recursive.

Yuxi Fu

  • II. Recursive Function

43 / 49

slide-48
SLIDE 48

Minimization via Decidable Predicate

Suppose R(x, y) is a partially decidable predicate. The function g(x) = µyR( x, y) = the least y such that R( x, y) holds, if there is such a y, undefined,

  • therwise.

is recursive.

Proof.

g( x) = µy(sg(χR( x, y)) = 0).

Yuxi Fu

  • II. Recursive Function

44 / 49

slide-49
SLIDE 49

Comment

The µ-operator allows one to define partial functions.

Yuxi Fu

  • II. Recursive Function

45 / 49

slide-50
SLIDE 50

Comment

The µ-operator allows one to define partial functions. The diagonalisation argument does not apply to the set F of recursive functions.

Yuxi Fu

  • II. Recursive Function

45 / 49

slide-51
SLIDE 51

Comment

The µ-operator allows one to define partial functions. The diagonalisation argument does not apply to the set F of recursive functions. Using the µ-operator, one may define total functions that are not primitive recursive.

Yuxi Fu

  • II. Recursive Function

45 / 49

slide-52
SLIDE 52

Minimization Operator is a Search Operator

It is clear from the above proof why the minimization operator is sometimes called a search operator.

Yuxi Fu

  • II. Recursive Function

46 / 49

slide-53
SLIDE 53

Definable Function

A function is definable if there is a recursive function calculating it.

Yuxi Fu

  • II. Recursive Function

47 / 49

slide-54
SLIDE 54

Ackermann Function is Recursive

  • Proposition. The Ackermann function is recursive.

Proof.

A finite set S of triples is said to be suitable if the followings hold: (i) if (0, y, z) ∈ S then z = y + 1; (ii) if (x + 1, 0, z) ∈ S then (x, 1, z) ∈ S; (iii) if (x + 1, y + 1, z) ∈ S then ∃u.((x + 1, y, u)∈S ∧ (x, u, z)∈S). A triple (x, y, z) can be coded up by 2x3y5z. A set {u1, . . . , uk} can be coded up by pu1 · · · puk. Let R(x, y, v) be “v is a legal code and ∃z < v.(x, y, z)∈Sv”. The Ackermann function ψ(x, y) ≃ µz((x, y, z)∈SµvR(x,y,v)).

Yuxi Fu

  • II. Recursive Function

48 / 49

slide-55
SLIDE 55

Do recursive functions capture all computable functions?

Yuxi Fu

  • II. Recursive Function

49 / 49

slide-56
SLIDE 56

Do recursive functions capture all computable functions? G¨

  • del himself wasn’t very sure about it in 1934.

Yuxi Fu

  • II. Recursive Function

49 / 49