1. Trang chủ
  2. » Công Nghệ Thông Tin

Bài giảng Lý thuyết tính toán: Chương 5 - PGS.TS. Phan Huy Khánh

6 7 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 6
Dung lượng 174,8 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Chương 5 của bài giảng Lý thuyết tính toán giới thiệu về hàm đệ quy. Chương này trình bày một số nội dung cơ bản như sau: Gödel''s incompleteness theorem; zero, successor, projector functions; functional composition; primitive recursion; proving functions are primitive recursive, Ackermann''s function. Mời các bạn cùng tham khảo.

Trang 1

Lý thuyết tính toán

(Theory of Computation)

Lý thuyết tính toán

(Theory of Computation)

PGS.TS Phan Huy Khánh

khanhph@vnn.vn

Chương 5 Hàm đệ quy

Chương 5

2/32

Recursive Function Theory

 Gödel's Incompleteness Theorem

 Zero, Successor, Projector Functions

 Functional Composition

 Primitive Recursion

 Proving Functions are Primitive Recursive

 Ackermann's Function

3/32

Maths Functions

An example function:

We need a way to define functions

We need a set of basic functions

N

3

N 10

f(n) = n 2 + 1 f(3) = 10

4/32

Computation

 Get N a set of Natural Numbers :

N= { 0, 1, 2, …}

 Building the functions on N For examples :

x + y

x * y

xy

x2+ y2

are computable functions

Complicated Functions

x  ( y + z)

 is complicated functionsfrom the addition and

multiplication function

 is computable:

there is a sequence of operations

of the additionand the multiplication

Attention :

There are also many functions that are not composed

from the basis functions

Factorial function:

n! = n  (n-1)  (n-2)  …  2  1

is computable:

there is a sequence of multiplication operations

The factorial function is not alone the composition of the addition and multiplication operations

The number of multiplication oprations depends onn

Function is computable

Trang 2

Factorial functionis a recursive definition:

(n + 1) ! = (n + 1)  n !

Uses the recursivity to define some functions

f(n + 1)

is defined from:

f(n)

Start at : f(0)

Recursivity

8/32

Function is computable Why is computable?

 Basic primitive recursive functions:

 Computation on the natural number N

 Primitive Recursive Function:

 Any function built from the basic primitive recursive functions

9/32

Computable functions

Basic set of Recursive primitive functions

Primitive Recursive Functions :

Mechanism for composition of functions

Some can have any arity (unary, binary, …)

f(n1, n2, …, nm), m  1

10/32

Gödel's Incompleteness Theorem

 “Any interesting consistent system must be incomplete;

that is, itmust contain some unprovable propositions”

 Hierarchy of Functions

1.Primitive-Recursive Functions

2.Recursive (-recursive) Functions

3.Interesting well-defined Functions but "unprovable"

BB Function

Primitive Recursive Functions

Defined over the domain I= set of all non-negative

integers

 or domain I×I

 or domain I×I×I, etc

Definition:

Functionsare said to be Primitive Recursive

ifthey can be built

 from the basic functions (zero, successor, andprojection)

 using functional composition and/or primitive recursion

Zero, Successor, Projector Functions

Zerofunction:

z(x) = 0, forall x I

Successorfunction:

s(x) = x+1

Projectorfunctions:

p1(x1, x2) = x1

p2(x1, x2) = x2

Trang 3

Example of Primitive Recursives

Constants are Primitive Recursive:

2 = s(s(z(x)))

3 = s(s(s(z(x))))

5 = s(s(s(s(s(z(x))))))

Addition & Multiplication

 add(x, 0) = x

add(x, y+1) = s(add(x, y))

 mult(x, 0) = 0

mult(x, y+1) = add(x, mult(x, y))

14/32

Subtraction

pred(0) = 0 pred(x+1) = x

monus(x, 0) = x // called subtrin text monus(x, y+1) = pred(monus(x, y))

absdiff(x, y) = monus(x, y) + monus(y, x)

15/32

Other Primitive Recursive Functions

Factorial & Exponentiation

 fact(0) = 1

fact(n+1) = mult(s(n), fact(n))

 exp(x, 0) = 1

exp(x, n+1) = mult(x, exp(x, n))

Test for Zero (Logical Complement)

 test(0) = 1

test(x+1) = 0

16/32

Operators

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))

Minimum & Maximum

 min(x, y) = lt(x, y)*x + geq(x, y)*y

 max(x, y) = geq(x, y)*x + lt(x, y)*y

Division

 remaind(numerator, denominator) = rem(denominator, numerator)

 rem(x, 0) = 0

rem(x, y+1) = s(rem(x, y))*test(equal(x, s(rem(x, y))))

 div(numerator, denominator) = dv(denominator, numerator)

 dv(x, 0) = 0

dv(x, y+1) = dv(x, y) + test(remaind(y+1, x))

Square Root

 sqrt(0) = 0

 sqrt(x+1) = sqrt(x) +

equal(x+1, (s(sqrt(x))*s(sqrt(x))))

Test for Prime

 numdiv(x) = divisors_leq(x, x)

 divisors_leq(x, 0) = 0 divisors_leq(x, y+1)

= divisors_leq(x, y) + test(remaind(x, y+1))

 is_prime(x) = equal(numdiv(x), 2)

{ a  b mod c }

 congruent(a, b, c)

= equal(remaind(a, c), remaind(b, c))

Trang 4

Greatest Common Divisor

(can’t use Euclidean Algorithm—not P.R.)

gcd(a, 0) = a

gcd(a, b+1) = find_gcd(a, b+1, b+1)

find_gcd(a, b, 0) = 1

find_gcd(a, b, c+1) =

(c+1)*test_rem(a, b, c+1) +

find_gcd(a, b, c)*test(test_rem(a, b, c+1))

test_rem(a, b, c) =

test(remaind(a, c))*test(remaind(b, c))

20/32

Functional Composition

f(x, y) = h(g1(x, y), g2(x, y))

from previously defined functions g1, g2, andh

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(), g1=lt(), g2=p1()

g2(x, y) = mult(geq(x, y), p2(x, y))

h = mult(), g1=geq(), g2=p2()

21/32

Primitive Recursion

Composition:

 f(x, 0) = g1(x)

 f(x, y+1)= h(g2(x, y), f(x, y)

Note: Last argument defined at zero and y+1 only

e.g.:

 exp(x, 0) = 1

exp(x, n+1) = x * exp(x, n)

 g1(x) = s(z(x))

 h(x, y) = mult(x, y)

 g2(x, y) = p1(x, y)

22/32

Ackermann's Function

We can actually give an example of a total Turing-computable function that is not primitive recursive, namely Ackermann’s function:

 A(0, n) = n+1

 A(m+1, 0) = A(m, 1)

 A(m+1, n+1) = A(m, A(m+1, n))

For example,

 A(0, 0) = 1

 A(0, 1) = 2

 A(1, 1) = A(0, A(1, 0)) = A(0, A(0, 1))

 = A(0, 1) + 1 = 3

Ackermann's Function

Theorem

there is some m such that f(m) < A(m, m)

 So A cannot be primitive recursive itself

Ackermann's Function

 Ackermann's Function is NOT Primitive Recursive

 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…

Trang 5

"Meaning" of Ackermann's Function

(addition, multiplication, exponentiation, tetration)

A(1,0)  2; A(1,1)  3; A(1,2 )  4; A(1,n)  2  (n  3) 3

A(2, 0)  3; A(2,1)  5; A(2,2)  7; A(2, n)  2 *(n  3)  3

A(3,0)  5; A(3,1)  13; A(3,2)  29; A(3,3)  61; A(3, 4)  125; A(3,n)  2 n3 3

A( 4, 0)  13; A(4,1)  65531; A( 4, 2)  2

65534

 3; A(4, n) 22

2

2

2{n  3 times}

 3

26/32

Rates of growth

Ackerman’s function and friends

Iterated exponentials Exponential functions

A(m.n)

3 nn!

Polynomial functions

n 3 +3n 2 +2n+1

2n+5

n n

nn n

Growth of Ackerman’s function:

A(0, n) = n+1 ; A(1, n) = n+2 ; A(2, n) = 2n+3 A(3, n) = 2n + 3– A(4, n) = 2 -3 withn powers of 2

27/32

Countable Sets

Countable if it can be put into a 1-to-1 correspondence

withthe positive integers

You should already be familiar with the enumeration

procedure for the set of RATIONAL numbers

[diagonalization, page278]

 Quick review…

You should already be familiar with the fact (and proof)

thatthe REAL numbers are NOTcountable

 Quick review…

28/32

Recursively Enumerable Languages

A language is said to be recursively enumerable

ifthere exists a Turing machine that accepts it

 That is, ifthe accepting machine is started on a word

inthe language, itwill halt in qf

This says nothing about what the machine will do

ifit is presented with a word that is not in the language

 (i.e whether it halts in a non-final state or loops)

Recursive Languages

A language, L, isrecursive if there exists a Turing machine

that accepts L and haltson everyw in +

That is, thereexists a membership decision procedurefor L

Existence of Languages that are not Recursively Enumerable

 Let S be an infinite countable set Thenits powerset2Sis not countable

 Proof by diagonalization

 Recall the fact that the REAL numbers are not countable

For any nonempty , thereexist languages that are not recursively enumerable

 Every subset of * is a language Thereforethere are exactly 2 languages

 However, thereare only a countable number of Turing machines

Thereforethere exist more languages than Turing machines

to accept them

Trang 6

Recursively Enumerable but not Recursive

We can list all Turing machines that eventually halted

ona given input tape (say blank)

 Recall the enumeration procedure for TM’s from last period

 Once a string of 0’s and 1’s was verified as a valid TM,

wewould 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, wecannot determine (and always halt)

whetheror not a given TM will halt on a blank tape

 Stay tuned for the unsolvability of the Halting Problem

32/32

The hierarchy of functions

Recall that a function f :

Nk  N is total if f is defined on every input from Nk

and is partial if we don’t insist that it has to be total

All partial functions from Nk to N

The computable partial functions

The computable total functions

The primitive recursive functions

?

n

A(m,n)

add(m,n)

Ngày đăng: 08/05/2021, 18:17

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w