9b Recursive Functions 13'1 - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

9b Recursive Functions 13'1

Description:

'Any interesting consistent system must be incomplete; that is, it must contain ... using David Hannay's 'Stupid Bit Trick' (c.f. David Letterman's 'Stupid Pet Trick' ... – PowerPoint PPT presentation

Number of Views:117
Avg rating:3.0/5.0
Slides: 32
Provided by: daveh5
Category:

less

Transcript and Presenter's Notes

Title: 9b Recursive Functions 13'1


1
9b Recursive Functions 13.1
  • Gödel's Incompleteness Theorem
  • Zero, Successor, Projector Functions
  • Functional Composition
  • Primitive Recursion Simulator
  • Proving Functions are Primitive Recursive
  • Ackermann's Function
  • m-Recursion

2
Gödel's Incompleteness Theorem
  • Any interesting consistent system must be
    incomplete that is, it must contain some
    unprovable propositions.
  • Hierarchy of Functions
  • Primitive-Recursive Functions
  • Recursive (?-recursive) Functions
  • Interesting well-defined Functions but
    "unprovable"
  • BB Function

3
Primitive Recursive Functions
  • Defined over the domain I set of all
    non-negative integers
  • or domain II.
  • or domain III, etc.
  • Definition Functions are said to be Primitive
    Recursive if they can be built
  • from the basic functions (zero, successor, and
    projection)
  • using functional composition and/or primitive
    recursion.

4
Zero, Successor, Projector Functions
  • 1. Zero function z(x) 0, for all x ? I
  • 2. Successor function s(x) x1
  • 3. Projector functions p1(x1,x2) x1,
    p2(x1,x2)x2

5
Functional Composition
  • f(x,y) h(g1(x,y),g2(x,y))
  • from previously defined functions g1, g2, and h
  • e.g. min(x,y) lt(x,y)x geq(x,y)y
  • h(x,y) add(x,y)
  • g1(x,y) mult(lt(x,y),p1(x,y))
  • h mult(), g1lt(), g2p1()
  • g2(x,y) mult(geq(x,y),p2(x,y))
  • h mult(), g1geq(), g2p2()

6
Primitive Recursion
  • f(x,0) g1(x)
  • f(x,y1) h(g2(x,y),f(x,y))
  • Note Last argument defined at zero and y1 only
  • e.g. exp(x,0) 1 exp(x,n1) x exp(x,n)
  • g1(x) s(z(x))
  • h(x,y) mult(x,y)
  • g2(x,y) p1(x,y)

7
Constants are Primitive Recursive
  • 2 s(s(z(x)))
  • 3 s(s(s(z(x))))
  • 5 s(s(s(s(s(z(x))))))

8
Addition Multiplication
  • add(x,0) xadd(x,y1) s(add(x,y))
  • mult(x,0) 0mult(x,y1) add(x,mult(x,y))
  • Tracing the recursion on the SIMULATOR

9
Factorial Exponentiation
  • fact(0) 1fact(n1) mult(s(n),fact(n))
  • exp(x,0) 1exp(x,n1) mult(x,exp(x,n))

10
Test for Zero(Logical Complement)
  • test(0) 1test(x1) 0

11
Subtraction
  • pred(0) 0pred(x1) x
  • monus(x,0) x // called subtr in
    textmonus(x,y1) pred(monus(x,y))
  • absdiff(x,y) monus(x,y) monus(y,x)

12
Relational Operators
  • equal(x,y) test(absdiff(x,y))
  • geq(x,y) test(monus(y,x))
  • leq(x,y) test(monus(x,y))
  • gt(x,y) test(leq(x,y))
  • lt(x,y) test(geq(x,y))

13
Minimum Maximumusing David Hannay's "Stupid
Bit Trick"(c.f. David Letterman's "Stupid Pet
Trick")
  • min(x,y) lt(x,y)x geq(x,y)y
  • max(x,y) geq(x,y)x lt(x,y)y

14
Division
  • remaind(numerator,denominator)
    rem(denominator,numerator)
  • rem(x,0) 0rem(x,y1) s(rem(x,y))test(equal(x
    ,s(rem(x,y))))
  • div(numerator,denominator) dv(denominator,numera
    tor)
  • dv(x,0) 0dv(x,y1) dv(x,y)
    test(remaind(y1,x))

15
Test for Prime
  • numdiv(x) divisors_leq(x,x)
  • divisors_leq(x,0) 0divisors_leq(x,y1)
    divisors_leq(x,y) test(remaind(x,y1))
  • is_prime(x) equal(numdiv(x),2)

16
Square Root
  • sqrt(0) 0
  • sqrt(x1) sqrt(x) equal(x1,(s(sqrt(x))s(sqrt
    (x))))

17
a ? b mod c
  • congruent(a,b,c) equal(remaind(a,c),remaind(b,c)
    )

18
Greatest Common Divisor(cant use Euclidean
Algorithmnot P.R.)
  • gcd(a,0) agcd(a,b1) find_gcd(a,b1,b1)
  • find_gcd(a,b,0) 1find_gcd(a,b,c1)
    (c1)test_rem(a,b,c1) find_gcd(a,b,c)test(
    test_rem(a,b,c1))
  • test_rem(a,b,c) test(remaind(a,c))test(re
    maind(b,c))

19
Ackermann's Function
  • Ackermann(x,y) A(x,y)
  • A(0,y) s(y)
  • A(x1,0) A(x,1)
  • A(x1,y1) A(x,A(x1,y))

20
Ackermann's Function is NOT Primitive Recursive
  • Compute Ack(3,1) on Simulator Trace level 24
  • Just because it is not defined using the
    "official" rules of primitive recursion is not a
    proof that it IS NOT primitive recursive.
  • Perhaps there is another definition that uses
    primitive recursion. (NOT!) Proof is beyond the
    scope of this course

21
"Meaning" of Ackermann's Function(addition,
multiplication, exponentiation, tetration)
22
m -Recursion
  • sqrt(x) my(yyx) // this is a partial
    function
  • sqrt(x) my(s(y)s(y) gt x) // now it is
    total
  • Note that m-recursion allows for partial
    functions just as do Turing machines

23
m Recursive Definition ofnth_prime
  • nth_prime(0) 2nth_prime(n1)
    find_prime(nth_prime(n))
  • find_prime(x) my(and(less(x,y),is
    _prime(y)))

24
m -Recursive Functions Equivalent to T.M.
Computable Functions
  • TM for z(x)
  • TM for s(x)
  • TM for p1(x,y), p2(x,y)
  • TM for functional composition
  • TM for primitive recursion
  • TM for m-recursion
  • Proof in other direction is beyond the scope of
    the course...

25
In-Class ExercisePrimitive-Recursive Functions
  • Work in groups of 2 or 3
  • Answers on next slide (no peeking)
  • a) Using only initial functions, show that
    nth_odd(x) is primitive recursive.
  • b) Using any functions defined in class, show
    that median(x,y,z) is primitive recursive.
  • c) Using any functions defined in class, show
    that perfect(x) is primitive recursive.
  • sum of all factors (including 1, not including x)
    x
  • e.g. 6 (123) and 28 (124714) are
    perfect
  • First group done with all 3 put a) on board, etc.

26
9x Recursive Recursively Enumerable 11.1
  • Enumeration Procedure Countable Sets
  • Recursively Enumerable Languages
  • Recursive Languages
  • Existence of Languages that are not Rec.
    Enumerable
  • A Language that is Rec. Enumerable but not
    Recursive

27
Countable Sets
  • Countable if it can be put into a 1-to-1
    correspondence with the positive integers
  • You should already be familiar with the
    enumeration procedure for the set of RATIONAL
    numbers diagonalization, page 278
  • Quick review
  • You should already be familiar with the fact (and
    proof) that the REAL numbers are NOT countable
  • Quick review

28
Recursively Enumerable Languages
  • A language is said to be recursively enumerable
    if there exists a Turing machine that accepts it.
  • That is, if the accepting machine is started on a
    word in the language, it will halt in qf
  • This says nothing about what the machine will do
    if it is presented with a word that is not in the
    language
  • (i.e. whether it halts in a non-final state or
    loops)

29
Recursive Languages
  • A language, L, is recursive if there exists a
    Turing machine that accepts L and halts on every
    w in ?
  • That is, there exists a membership decision
    procedure for L

30
Existence of Languages that are not Recursively
Enumerable
  • Let S be an infinite countable set. Then its
    powerset 2S is not countable. Theorem 11.1
  • Proof by diagonalization page 278
  • Recall the fact that the REAL numbers are not
    countable
  • For any nonempty ?, there exist languages that
    are not recursively enumerable.
  • Every subset of ? is a language. Therefore there
    are exactly 2? languages.
  • However, there are only a countable number of
    Turing machines. Therefore there exist more
    languages than Turing machines to accept them.

31
Recursively Enumerablebut not Recursive
  • We can list all Turing machines that eventually
    halted on a given input tape (say blank)
  • Recall the enumeration procedure for TMs from
    last period.
  • Once a string of 0s and 1s was verified as a
    valid TM, we would simply run it (while
    non-deterministically continuing to list other
    machines). Note how long this would take!
  • A halt on the part of the simulation (recall the
    Universal Turing Machine) would trigger adding
    the TM in question to the list of those that
    halted. (copying it to another tape?)
  • However, we cannot determine (and always halt)
    whether or not a given TM will halt on a blank
    tape
  • Stay tuned for the unsolvability of the Halting
    Problem...
Write a Comment
User Comments (0)
About PowerShow.com