Chapter 4: A Universal Program - PowerPoint PPT Presentation

About This Presentation
Title:

Chapter 4: A Universal Program

Description:

Chapter 4: A Universal Program * – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 31
Provided by: uhe8
Learn more at: https://www2.cs.uh.edu
Category:

less

Transcript and Presenter's Notes

Title: Chapter 4: A Universal Program


1
Chapter 4A Universal Program
2
Coding programs
  • Example For our programs P we have variables
    that are arranged in a certain order
  • Y1 X1 Z1 X2 Z2 X3 Z3
  • Similarly labels are ordered
  • A1 B1 C1 D1 E1 A1 B1 C1 D1
  • Definition (V) is the position of a variable or
    label in the given ordering, where V is the label
    or variable.
  • Example (X3) 6
  • (C) 3
  • (X1) (X) 2

3
Coding programs
  • Definition Let I be (labeled or unlabeled)
    instruction of the language L. Thus
  • , where the following points are satisfied
  • If I is unlabeled, then a 0 if I is labeled
    with L, then a (L).
  • If the variable V is mentioned in I, then c
    (V) 1.
  • If the statement in I is either
  • V ? V , then b 0
  • V ? V 1, b 1
  • V ? V 1, b 2
  • If the statement in I is IF V ? 0 GOTO L', then b
    (L') 2

4
Coding programs
  • Reminder from Chapter 3
  • Given the following variable ordering Y X1,
    Z1, X2, Z2
  • Provided the following label ordering A1 B1
    C1 D1 E1 ....
  • We have a program as follows A X
    ? X 1
  • IF X ? 0 GOTO A
  • The instruction numbers for this program are
    thus
  • (I1) lt (A) ,lt 1, (X) - 1gtgt
    lt1, lt 1,1 gtgt lt 1,5 gt 21
  • (I2) lt0,lt (A) 2 , (X) - 1
    gtgt lt0, lt 3 , 1 gtgt lt 0 , 23 gt 46
  • Definition The program P number is then
    calculated as
  • (P) (I1), (I2) , (I3) , ... - 1
  • In the program above (P) 221 346 1

5
Coding programs
  • In order to avoid ambiguity of unlabeled Y ? Y
    instruction, which is lt0,lt0,0gtgt an additional
    rule is imposed
  • The final instruction in a program is not
    permitted to be the unlabeled statement Y ? Y.
  • N.B The program number thus determines a unique
    program, which can reconstructed.
  • Example Given (P) 576 575 1
  • 575 52 231 0 , 0 , 2 , 0 , 0 , 0 , 0 ,
    0 , 1 9 instructions
  • For 2 lt0,1gt lt0,lt1,0gtgt so unlabeled Y ? Y
    1
  • For 1 lt1, 0gt lt1, lt0,0gtgt so labeled A Y
    ? Y
  • For 0 lt0, lt0,0gtgt , this will be unlabeled Y ?
    Y
  • Empty program has the number 0.

6
The Halting Problem
  • Definition For a given y, let P be the program
    such that (P) y. Then HALT(x , y) is true if
    is defined and false if
  • is undefined, so
  • HALT( x , y ) program number y eventually
    halts on input x
  • Theorem HALT( x , x ) is not a computable
    predicate.
  • Proof Construct a program P A IF HALT( X ,
    X ) GOTO A
  • Let (P) y0, then HALT( x, y0)
    HALT( x , x )
  • So we can set xy0, thus HALT (y0,y0)
    HALT(y0,y0)
  • Contradiction!

7
Insolvability of Halting Problem
  • There is no algorithm that, given a program of P
    and an input to that program, can determine
    whether or not the given program will eventually
    halt on the given input (Chapter 4, page 68)
  • Churchs Thesis Any algorithm for computing on
    numbers can be carried out by a program of P.
  • See Golbachs conjecture (every even number
    greater or equal to 4 is the sum of two prime
    numbers) for an example of computable program for
    which it is hard to determine whether it will
    ever halt.

8
Universality
  • Universality Theorem For each n gt 0, where
  • For each n gt0, the function
    is partially computable.
  • Step-Counter Theorem For each n gt 0, the
  • predicate is
    primitive recursive, where

,where (P)y
Program number y halts after t or fewer Steps on
inputs x1, , xn.
9
Normal Form Theorem
  • Normal Form Theorem Let f( x1 ,, xn) be a
    partially computable function. Then there is a
    primitive recursive predicate R( x1, , xn, y )
    such that
  • Theorem A function is computable iff can be
    obtained from the initial functions by a finite
    number of applications of composition, recursion
    and (proper ) minimalization

10
Normal Form Theorem
  • Normal Form Theorem Proof
  • Let y0 be the program number for f(x1,,xn).
  • when the right-hand side of the equation is
    defined, then there exists a number z
  • For any z, the program with number y0 has
    reached a terminal snapshot in r(z) or fewer
    steps and l(z) is in output variable Y.
  • If the right side is undefined, then
    is false for all t i.e.

11
Recursively Enumerable Sets
  • Theorem Let the sets B , C belong to some PRC
    class C. Then so do the sets
  • (prove using predicate union and
    intersection)
  • Theorem Let C be a PRC class, and let B be a
    subset of . Then B belongs to C
    iff
  • Definition The set is called
    recursively enumerable if there is a partially
    computable function g(x) such that

belongs to C
12
Recursively Enumerable Sets
  • If B is a recursive set, then B is recursively
    enumerable.
  • The set B is recursive iff B and are both
    recursively enumerable.
  • If B and C are recursively enumerable sets so are
  • Enumeration Theorem A set B is recursively
    enumerable iff there is an n for which B Wn

13
Recursively Enumerable Sets
  • Definition K is a set of all numbers n such that
    program number n eventually halts on input n.
  • K is recursively enumerable but not recursive.
  • Theorem Let B be a recursively enumerable set.
    Then there is a primitive recursive predicate
    R(x,t) such that

14
Recursively Enumerable Sets
  • Theorem Let S be a nonempty recursively
    enumerable set. Then there is a primitive
    recursive function f(u) such that
  • S f(n) n ? N f(0) , f(1) ,
  • , where S is the range of f.
  • Theorem Let f(x) be a partially computable
    function and let
  • S f(x) f(x) ?
  • , where S is the range. Then S is recursively
    enumerable.

15
Recursively Enumerable Sets
  • Theorem Suppose that , then the
    following statements are all equivalent
  • S is recursively enumerable
  • S is the range of a primitive recursive function
  • S is the range of a recursive function
  • S is the range of a partial recursive function

16
The Parameter Theorem
  • s-m-n Theorem
  • For each n , m gt 0 there is a primitive
    recursive function such
    that

17
The Parameter Theorem
  • s-m-n proof using induction on n.
  • Base case For program P take n 1, then the
    following must be shown to be true
  • should be the number of the
    program with m inputs
  • , which must be the same as
    program number y having m 1 inputs
    .
  • (P) y
  • So will be the number of the
    program, that will provide the variable
    before proceeding with P.

18
The Parameter Theorem
  • s-m-n proof continued
  • The instruction will have
    a number associated with it as follows
    lt0,lt1,2m1gtgt 16m 10
  • Thus may be defined as a primitive
    recursive function
  • Induction step let n k, then

19
Diagonalization and Reducibility
  • Definition Let TOT be the set of all numbers p
    such that p is the number of a program that
    computes a total function f(x) of one variable.
    That is,
  • , where
  • Theorem TOT is not recursively enumerable.

,s
20
Diagonalization and Reducibility
  • Theorem TOT is not recursively enumerable.
  • Proof Assume that TOT is recursively enumerable.
    Then given that , then there is
    a computable function g(x)
  • and let
  • Since g(x) is the number of a program that
    computes a total function, thus h is a computable
    function. Let P be the program that computes h
    and p(P). Then
  • Contradiction!

21
Diagonalization and Reducibility
  • Theorem Suppose A m B, then
  • If B is recursive, then A is recursive.
  • If B is recursively enumerable, then A is as
    well.
  • Definition A set A is m-complete if
  • A is recursively enumerable and
  • For every recursively enumerable set B, B m A

22
Diagonalization and Reducibility
  • If A m B and B m C, then A m C (transitivity)
  • If A is m-complete, B is recursively enumerable
    and A m B then B is m-complete.
  • Definition A B means that A m B and B m A
  • Theorem
  • K and K0 are m-complete
  • K K0
  • Theorem EMPTY is not recursively enumerable,
    where

23
Rice's Theorem
  • Examples
  • ? is the set of computable functions
  • ? is the set of primitive recursive functions
  • ? is the set of partially computable functions
    that are defined for all but a finite number of
    values of x
  • Rices Theorem Let ? be a collection of
    partially computable functions of one variable,
    such that there are functions f(x), g(x) with
    f(x) in ?, g(x) not in ?. Then R? is not
    recursive.
  • Corollary There are no algorithms for testing a
    given program P of the language L to determine
    whether belongs to any of the classes
    described in the above examples.
  • What does it mean? If ? is a non-trivial property
    of functions, then ? is undecidable.

24
Rice's Theorem
  • Proof (using recursion theorem)
  • Let f(x) and g(x) be partially computable
    functions such that
  • f(x) ?
  • g(x) ?
  • Suppose is computable. Let

  • and
  • Then, since
  • - is partially computable.

Iis not recursive
25
Rice's Theorem
Proof (contd) Since is partially
computable, by recursion theorem there is a
number e s.t. As and

Contradiction!
26
  • The Recursion Theorem
  • Recursion Theorem Let g(z, x1, , xm) be a
    partially computable function of m 1 variables.
    Then, there is a number e such that
  • Discussion Given a partially computable
    function g, we must produce a program e that is
    supplied m arguments and one of the implicit
    arguments is its own encoding e.
  • We may attempt to prove the theorem by first
    incrementing a variable e times. But then the
    problem is that the encoding of such a program
    will be larger than e!
  • The program P with (P) e must contain a
    partial description of itself built-in so that
    that it can computer its own encoding e from that
    description.

27
Let Q be the program Z Y g(Z, X1,
X2, , Xm) Now, the program P will consist of
(Q) copies of the instruction Xm1 Xm1 1,
followed by the program Q. After executing the
first (Q) increments as well as the instruction
Z , Z holds the number of the program
consisting of the (Q) copies of the instruction
followed by the program Q (Remember that
as defined in the proof of the
parameter theorem computes the of the program
consisting of (Q) copies of the increment
instruction Xm1 Xm1 1 followed by program
Q). But this is exactly the program P.
28
  • The Recursion Theorem
  • Proof Let g be a partially computable function
    such as
  • is the function in the parameter theorem. Then
    for some z0 and using s-m-n theorem
  • Set v z0 and , then
  • Contradiction!

29
The Recursion Theorem
  • Corollary There is a number e such that for all
    x
  • Proof Let g be a computable function
  • Using the recursion theorem
  • Fixed Point Theorem Let f(z) be a computable
    function. Then there is a number e such that
  • Take g(z, x)

30
Computable functions that are not primitive
recursive
  • The primitive recursive functions are precisely
    the functions from the initial functions (see
    Chapter 3)
  • Theorem The unary primitive recursive functions
    are precisely those obtained from the initial
    functions s(x) x 1, n(x) 0, l(x) , r(x) by
    applying the following three operations on unary
    functions
  • To go from f(x) and g(x) to f(g(x))
  • To go from f(x) and g(x) to lt f(x) , g(x) gt
  • To go from f(x) and g(x) to the function defined
    by the recursion
  • Theorem The function f( x , x ) 1 is a
    computable function that is not primitive
    recursive.
Write a Comment
User Comments (0)
About PowerShow.com