recursive functions and their turing-computability

Upload: guilherme-pombo

Post on 07-Apr-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/4/2019 Recursive Functions and Their Turing-Computability

    1/30

    Recursive functions and theirTuring-computability

    Abhijit P. Pai

    29th November, 2007

    http://goforward/http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    2/30

    Outline

    Computability notions

    Primitive Recursive Functions Recursive Functions

    Recursive Functions are Turing-Computable

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    3/30

    Computability

    Church-Turing thesis states that Turing Machines form abound on what can be computed.

    The computational equivalence of the following have been

    shown: Turing Machines Recursive functions Post systems Type 0 Grammars

    Calculus

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    4/30

    Terms

    Function: A function from INk to IN for some k 0; (called a

    k-place function). Primitive Recursive function: Class of functions defined by 3

    types of initial functions and two combining rules.

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    5/30

    Initial Functions

    The 0-place zero function from IN0 to IN such that () = 0

    Let k 1 and 1 i k. The ith k-place projection functionki fom IN

    ktoIN such that ki (n1,..., nk) = ni for anyn1,..., nk IN

    The successor function from IN to IN such that(n) = n + 1 for each n IN

    An initial function is ,, or one of the ki

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    6/30

    Notation

    n represents the sequence n1, ..., nk where k 0

    n will also be used to represent the k-tuple (n1,..., nk)

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    7/30

    Combining Rules - Composition

    Let l > 0 and k 0

    Let g be an l-place function

    Let h1,...hl be k-place functions Let f be the k-place function such that for every n INk,

    f(n) = g(h1(n),..., hl(n))

    Then f is said to be obtained from g, h1,...hl by composition

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    8/30

    Combining Rules - Primitive Recursion

    Let k 0, g be a k-place function, h be a (k+2)-placefunction.

    Let f be the (k+1)-place function such that for every n INk,

    f(n, 0) = g(n) and for every n INk and m IN,

    f(n,m + 1) = h(n, m, f(n,m))

    Then f is said to be obtained from g and h by primitive

    recursion

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    9/30

    Primitive Recursive Functions

    A function is primitive recursive if it is an initial function or

    can be generated from the intial functions by some sequenceof composition and primitive recursion.

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    10/30

    Examples

    Constant functions k = 0 : K0

    0

    is , K0j+1

    () = (K0j ()) for each j 0

    k > 0 : Kk+1j (n, 0) = Kkj (n)

    k > 0 : Kk+1j (n,m + 1) = k+2k+2(n,m,K

    k+1j (n,m))

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    11/30

    Examples

    plus(a, m) = a + m plus(a, 0) = 11(a)

    plus(a,m + 1) = h(m, n, plus(a,m)), h = 3

    3 mult(a,m) = a m

    mult(a, 0) = K10 mult(a,m + 1) = h(m, n,mult(a,m)), h = plus(31 ,

    33)

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    12/30

    Why primitive recursive functions couldnt possibly define

    computability

    Each primitive recursive function has a finite encoding

    Generate a list of all possible primitive recursive functions inlexicographic order A

    1, A

    2,A

    3,...

    Let fi be the p.r.f. defined by Ai Consider the 1-place function f such that for every

    n IN, f(n) = fn(n,..., n) + 1

    f is computable. But f must be fi for some i.

    When evaluated with argument i, f and fi differ by 1.

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    13/30

    Unbounded Minimization

    Let k 0 and g be a (k+1)-place function.

    The unbounded minimization of g is that k-place function f

    such that, for any n INk

    ,f(n) = { The least m such that g(n,m) = 0, if such m existsf(n) = { 0 otherwise

    We write f(n) = m[g(n,m) = 0]

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    14/30

    Regular Functions

    A (k+1)-place function g is regular iff, for every n INk,

    there is an m such that g(n,m) = 0.

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    15/30

    Recursive Functions

    A function is recursive iff it can be obtained from, ki , and by: Composition Primitive Recursion Application of Unbounded minimization to regular functions

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    16/30

    Computing Turing Machine Model

    Input surrounded by blank on each side, written on leftmostsquares of tape

    Head is initially at the blank just past the input string The TM M computes f if, for all w , if f(w) = u, then

    (s, #w#) M (h,#u#)

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    17/30

    Turing computability of Recursive functions - SomeTMs

    R# searches for the first blank square to the right of thesquare currently scanned

    L# searches for the first blank square to the left of the squarecurrently scanned

    SL shifts left - #w# to w# SR shifts right - #w# to ##w#

    E (eraser) - #w# to #, where w can be empty

    B (backup) - #u#w# to #w#, u and w can be empty

    k-copier Ck(k 1) - #w1#w2#...#wk# to#w1#w2#...#wk#w1#

    Clk - #w1#w2#...#wk# to#w1#w2#...#wk#w1#w2#...#wl#

    f

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    18/30

    The initial functions are Turing-computable

    is computed by a TM that moves its head one square to theright and halts.

    Initial config: (s, #)

    Final config: (h, ##)

    Th i i i l f i T i bl

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    19/30

    The initial functions are Turing-computable

    ki is computed by EkiBi1

    Eki

    - #w1#w2#...#wk# to #w1#w2#...#wi# Bi1 transforms this to #wi#

    Th i i i l f i T i bl

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    20/30

    The initial functions are Turing-computable

    - A TM which transforms #1

    n

    #(n 0) into #1

    n+1

    #

    C iti i T i t bl

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    21/30

    Composition is Turing-computable

    Composition l > 0, k 0, g an l-place function, h1,...hl k-place functions f, the k-place function such that for every n INk,

    f(n) = g(h1(n),...,hl(n))

    If g, h1...hl are Turing-computable, so is f.

    Let G,H1,..., Hl be TMs that compute g, h1, ..., hl. The function f is computed by the TM

    CkkH1Ckk+1H2...C

    kk+l1HlGB

    k

    CkkH1 - #w1#w2#...#wk# to

    #w1#w2#...#wk#w1#w2#...#wk# to#w1#w2#...#wk#u1# where ui = 1

    hi(n)

    After CkkH1...Ckk+l1Hl, #w1#w2#...#wk#u1#u2#...#ul#

    C iti i T i t bl

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    22/30

    Composition is Turing-computable

    G makes this into #w1#w2#...#wk#v# where v will be

    1f(n)

    Bk makes this into #v#

    P i iti si is T i g t bl

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    23/30

    Primitive recursion is Turing-computable

    Primitive Recursion k 0, g, a k-place function, h, a (k+2)-place function f, the (k+1)-place function s.t. for every n INk,

    f(n, 0) = g(n)

    and for every n INk

    and m IN,f(n,m + 1) = h(n,m, f(n,m))

    If g and h are Turing-computable, so is f.

    Let G and H be TMs that compute g and h

    We write w for w1#w2#...wk

    Primitive recursion is Turing computable

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    24/30

    Primitive recursion is Turing-computable

    Add a left end marker $ to input ($ / G, H) using(SRL

    2#)

    k+1$Rk+1# The tape is now $#w#Im#

    Change tape to$#w#Im1#w#Im2#...#w#I1#w#I0#w# using steps:

    Copy Im to tape 2 Copy w to tape 3 Erase tape 1 to get $# Move right twice to get $## Repeat till tape 2 becomes zero

    Decrement tape 2

    Copy tape 3 to tape 1 Put # in tape 1 Copy tape 2 to tape 1 Put # in tape 1

    Copy tape 3 to tape 1 Put # in tape 1

    Primitive recursion is Turing computable

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    25/30

    Primitive recursion is Turing-computable

    Now G and H compute successive values f(n, i) fori = 0,...,m as:

    $#w#Im1#w#Im2#...#w#I1#w#I0#w#

    to $#w#Im1#w#Im2#...#w#I1#w#I0#v0#

    to $#w#Im1#w#Im2#...#w#I1#v1#

    to $#w#Im1#vm1#

    to $#vm#

    Now remove the $, and the output value is the valuecomputed by f.

    Unbounded Minimization is Turing computable

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    26/30

    Unbounded Minimization is Turing-computable

    g, regular (k+1)-place Turing-computable.

    If f is got from g by unbounded minimization, f isTuring-computable.

    Let G be the TM that computes g, we construct F thatcomputes f, where for all n INk, f(n) = the least m suchthat g(n,m) = 0.

    g regular m exists for every n

    F gets #w1#w2#...#wk#

    Change to #w1#w2#...#wk#I0#

    Create a copy of this.

    Apply G to the copy. If result is nonzero, add one more 1 atthe end of the original and repeat.

    At some point, for #w1#w2#...#wk#Im#, G gives 0.

    Now, eliminate using B 1st k arguments and keep Im on tape.

    Functions with strings as arguments

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    27/30

    Functions with strings as arguments

    Define a function known as the Godel number gn(w) of the

    string w as the number corresponding to the base = ||+ 1encoding of the string.

    If = a, b, c, = 4.

    We fix d1 = a, d2 = b, d3 = c

    gn() = 0 gn(a) = gn(d1) = 1

    gn(ba) = gn(d2d1) = 41 2 + 1 = 9

    We add d0 so that numbers such as correspond to some

    string. Let D = ( d0)

    gn1 is a well defined function from IN to D.

    Functions with strings as arguments

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    28/30

    Functions with strings as arguments

    gn1(0) =

    gn1(1) = d1 = a

    gn

    1

    (3) = d3 = c gn1(4) = d1d0 = ad0 gn1(5) = d1d1 = aa

    ...

    References

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    29/30

    References

    Elements of the Theory of Computation

    Harry R. Lewis Christos H. Papadimitriou

    Thank You

    http://find/http://goback/
  • 8/4/2019 Recursive Functions and Their Turing-Computability

    30/30

    Thank You

    Questions

    http://find/http://goback/