advanced topics in theoretical computer science
play

Advanced Topics in Theoretical Computer Science Part 3: Recursive - PowerPoint PPT Presentation

Advanced Topics in Theoretical Computer Science Part 3: Recursive functions (2) 5.12.2013 Viorica Sofronie-Stokkermans Universit at Koblenz-Landau e-mail: sofronie@uni-koblenz.de 1 Contents Recapitulation: Turing machines and Turing


  1. Advanced Topics in Theoretical Computer Science Part 3: Recursive functions (2) 5.12.2013 Viorica Sofronie-Stokkermans Universit¨ at Koblenz-Landau e-mail: sofronie@uni-koblenz.de 1

  2. Contents • Recapitulation: Turing machines and Turing computability • Register machines (LOOP, WHILE, GOTO) • Recursive functions • The Church-Turing Thesis • Computability and (Un-)decidability • Complexity • Other computation models: e.g. B¨ uchi Automata, λ -calculus 2

  3. 3. Recursive functions • Introduction/Motivation • Primitive recursive functions �→ P • P = LOOP • µ -recursive functions �→ F µ • F µ = WHILE • Summary 3

  4. Until now 4

  5. Primitive recursive functions Primitive recursion. If the functions g : N k → N and h : N k +2 → N ( k ≥ 0) are primitive recursive, then the following function is also primitive recursive: f : N k +1 → N with f ( n , 0) = g ( n ) f ( n , m + 1) = h ( n , m , f ( n , m )) Notation without arguments: f = PR [ g , h ] Definition (Primitive recursive functions) • Atomic functions: The functions null (0), successor (+1) and projection ( π k (1 ≤ i ≤ k )) are primitive recursive. i • Composition: The functions obtained by composition from primitive recursive functions are primitive recursive. • Primitive recursion: The functions obtained by primitive recursion from pri- mitive recursive functions are primitive recursive. 5

  6. Examples of primitive recursive functions f ( n ) = n + c , for c ∈ N , c ≥ 0 +( n , m ) = n + m ( − 1)( n ) = n − 1 − ( n , m ) = n − m ∗ ( n , m ) = n ∗ m Lemma The set of primitive recursive functions is closed under re-ordering, omitting and repeating of arguments when composing functions. Lemma. Assume f : N k → N is primitive recursive. Then, for every l ∈ N , the function f ′ : N k × N l → N defined for every n ∈ N k and every m ∈ N l by: f ′ ( n , m ) = f ( n ) is primitive recursive. 6

  7. Primitive recursive functions Lemma (Case distinction). If g i , h i (1 ≤ i ≤ r ) are primitive recursive functions, and for every n there exists a unique i with h i ( n ) = 0, then the function f defined by:  g 1 ( n ) if h 1 ( n ) = 0    f ( n ) = . . .   g r ( n ) if h r ( n ) = 0  is primitive recursive. Theorem (Sums and products) If g : N k × N → N is a primitive recursive function then the following functions f 1 , f 2 : N k × N → N are also primitive recursive: � � 0 if m = 0 1 if m = 0 f 1 ( n , m ) = f 2 ( n , m ) = � � i < m g ( n , i ) if m > 0 i < m g ( n , i ) if m > 0 7

  8. Today • More examples • P = LOOP 8

  9. Bounded µ operator Definition. Let g : N k +1 → N be a function. The bounded µ operator is defined as follows:  i 0 if g ( n , i 0 ) = 0    and for all j < i 0 g ( n , j ) � = 0   µ i < m i ( g ( n , i ) = 0) := 0 if g ( n , j ) � = 0 for all 0 ≤ j < m     or m = 0  µ i < m i ( g ( n , i ) = 0) is the smallest i < m such that g ( n , i ) = 0 9

  10. Bounded µ operator Theorem. If g : N k +1 → N is a primitive recursive function then the function f : N k +1 → N defined by: f ( n , m ) = µ i < m i ( g ( n , i ) = 0) is also primitive recursive 10

  11. Bounded µ operator Theorem. If g : N k +1 → N is a primitive recursive function then the function f : N k +1 → N defined by: f ( n , m ) = µ i < m i ( g ( n , i ) = 0) is also primitive recursive Proof: We can define f as follows: f ( n , 0) = 0  0 if m = 0     if g ( n , m ) = f ( n , m ) = 0 ∧ g ( n , 0) � = 0 ∧ m > 0  m  f ( n , m + 1) =      f ( n , m ) otherwise  11

  12. Bounded µ operator Theorem. If g : N k +1 → N is a primitive recursive function then the function f : N k +1 → N defined by: f ( n , m ) = µ i < m i ( g ( n , i ) = 0) is also primitive recursive Proof: We can define f as follows: f ( n , 0) = 0  0 if m = 0     if g ( n , m ) = f ( n , m ) = 0 ∧ g ( n , 0) � = 0 ∧ m > 0  m  f ( n , m + 1) =      f ( n , m ) otherwise  12

  13. Bounded µ operator Theorem. If g : N k +1 → N is a primitive recursive function then the function f : N k +1 → N defined by: f ( n , m ) = µ i < m i ( g ( n , i ) = 0) is also primitive recursive Proof: We can define f as follows: f ( n , 0) = 0  0 if m = 0     if g ( n , m ) = f ( n , m ) = 0 ∧ g ( n , 0) � = 0 ∧ m > 0  m  f ( n , m + 1) = i.e. if g ( n , m ) + f ( n , m )+(1 − g ( n , 0)) + (1 − m ) = 0      f ( n , m ) otherwise  13

  14. Prime number functions Theorem: The following functions are primitive recursive: (1) The Boolean function | : N × N → { 0, 1 } defined by: � 1 if n divides m | ( n , m ) = 0 otherwise (2) The Boolean function prime : N → { 0, 1 } defined by: � 1 if n prime prime( n ) = 0 otherwise (3) The function p : N → N defined by: p ( n ) = p n , the n -th prime number. (4) The function D : N × N → N defined by: D ( n , i ) = k iff k is the power of the i -th prime number in the prime number decomposition of n . D ( n , i ) = max( { j | n mod p ( i ) j = 0 } ) 14

  15. Prime number functions Proof: (1) | : N × N → { 0, 1 } defined by:  1 if n divides m  | ( n , m ) = 0 otherwise  15

  16. Prime number functions Proof: (1) | : N × N → { 0, 1 } defined by:  1 if n divides m  | ( n , m ) = 0 otherwise  E | ( n , m ) = 1 iff z ( n ∗ z = m ) iff � z ≤ m ( n ∗ z − m ) + ( m − n ∗ z ) = 0. 16

  17. Prime number functions Proof: (1) | : N × N → { 0, 1 } defined by:  1 if n divides m  | ( n , m ) = 0 otherwise  E | ( n , m ) = 1 iff z ( n ∗ z = m ) iff � z ≤ m ( n ∗ z − m ) + ( m − n ∗ z ) = 0. | ( n , m ) = 1 − � z ≤ m ( n ∗ z − m ) + ( m − n ∗ z ) 17

  18. Prime number functions Proof: (2) prime : N → { 0, 1 } defined by:  1 if n prime  prime( n ) = 0 otherwise  18

  19. Prime number functions Proof: (2) prime : N → { 0, 1 } defined by:  1 if n prime  prime( n ) = 0 otherwise  A prime( n ) = 1 iff ( n ≥ 2 and y < n ( y = 0 ∨ y = 1 ∨ | ( y , n ) = 0) prime( n ) = 1 − ((2 − n ) + � y < n ( | ( y , n ) ∗ y ∗ (( y − 1) + (1 − y )))) 19

  20. Prime number functions Proof: (3) The function p : N → N defined by: p ( n ) = p n , the n -th prime number. p (0) = 0 and p (1) = 2. p ( n + 1) is the smallest number i which is larger than p ( n ) and is prime. 20

  21. Prime number functions Proof: (3) The function p : N → N defined by: p ( n ) = p n , the n -th prime number. p (0) = 0 and p (1) = 2. p ( n + 1) is the smallest number i which is larger than p ( n ) and is prime. We also have an upper bound for the number i . Recall the proof of the fact that the set of prime numbers is infinite. i ≤ p ( n )! + 1 p ( n + 1) = µ i ≤ p ( n )!+1 i [((1 − prime( i )) + (( p ( n ) + 1) − i )) = 0] 21

  22. Prime number functions Proof: (4) D : N × N → N defined by: D ( n , i ) = k iff k is the power of the i -th prime number in the prime number decomposition of n . D ( n , i ) = max( { j | n mod p ( i ) j = 0 } ) D (0, i ) := 0; | ( p ( i ) j +1 , n ) = 0 } ) D ( n , i ) = min( { j ≤ n | D ( n , i ) = µ j ≤ n j ( | ( p ( i ) j +1 , n ) = 0) 22

  23. 3. Recursive functions • Introduction/Motivation • Primitive recursive functions �→ P • P = LOOP • µ -recursive functions �→ F µ • F µ = WHILE • Summary 23

  24. 3. Recursive functions • Introduction/Motivation • Primitive recursive functions �→ P • P = LOOP • µ -recursive functions �→ F µ • F µ = WHILE • Summary 24

  25. Goal Show that P = LOOP Idea: To show that P ⊇ LOOP we have to show that every LOOP computable function can be expressed as a primitive recursive function. For this, we will encode the contents of arbitrarily many registers in one natural number (used as input for this primitive recursive function). For this encoding we will use G¨ odelisation. We will need to show that G¨ odelisation is primitive recursive. To show that P ⊆ LOOP we have to show that: – all atomic primitive recursive functions are LOOP computable, and – LOOP is closed under composition of functions and primitive recursion. 25

  26. G¨ odelisation To show: G¨ odelisation is primitive recursive Informally: • Coding number sequences as a number • Corresponding decoding function (projection) are primitive recursive 26

  27. G¨ odelisation To show: G¨ odelisierung is primitive recursive Informally: • Coding number sequences as a number • Corresponding decoding function (projection) are primitiv recursive More precise formulation: There exist primitive recursive functions K r : N r → N ( r ≥ 1) D i : N → N (1 ≤ i ≤ r ) with: D i ( K r ( n 1 , . . . , n r )) = n i 27

  28. G¨ odelisation To show: G¨ odelisation is primitive recursive Informally: • Coding number sequences as a number • Corresponding decoding function (projection) are primitive recursive Recall: G¨ odelisation: Coding number sequences as a number Bijection between N r and N : K r : N r → N , defined by: r p ( i ) n i . K r ( n 1 , . . . , n r ) = � i =1 Decoding: The inverses D i : N → N of K r defined by D i ( n ) = D ( n , i ) 28

Recommend


More recommend