Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

43
Theory of Computation More Number Theory Factoids, Pairing Functions, Gödel Numbers Vladimir Kulyukin www.vkedco.blogspot.com www.vkedco.blogspot.com

Transcript of Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Page 1: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Theory of Computation

More Number Theory Factoids, Pairing Functions, Gödel Numbers

Vladimir Kulyukin

www.vkedco.blogspot.comwww.vkedco.blogspot.com

Page 2: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Outline● Review● More Number Theory

Bezout's Identity Euclid's 1st Theorem Fundamental Theorem of Arithmetic (Unique Factorization

Theorem)● Pairing Functions● Gödel Numbers

Page 3: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Review

Page 4: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Review: Well-Ordering Principle

● The well-ordering principle states that every non-empty set of natural numbers has a smallest element

● In axiomatic set theory, the set of natural numbers is defined as the set that contains 0 and is closed under the successor operation

● The set of natural numbers {n | {0, …, n}} is well-ordered contains all natural numbers

Page 5: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Review: Euclid’s 2nd Theorem

There are infinitely many primes

Page 6: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Review: Euclid’s 2nd Theorem (Formulation 1)

.an greater thdivisor prime a has

or prime new aeither is 1...532

,,...,5,3,2 primes of sequence finite aGiven

i

ii

i

p

pE

p

Page 7: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Review: Euclid’s 2nd Theorem (Formulation 2)

.an greater th prime aby divisible

isor prime aeither is Then .1!Consider

,...7,5,3,2 Thus, prime. thebe to

define Then we case. base for the 0set We

4321th

0

n

nnn

i

p

EpE

ppppi

pp

Page 8: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Review: Lower and Upper Bounds for Next Prime

theorem.2 sEuclid'

by ,1!| because ,1! is boundupper The 2)

3). 2, (e.g., ,after right becan , prime,

next thenaturally, because, bound,lower theis 1 )1

.1!,1

nd

1

1

1

iii

ii

i

iii

ppp

pp

p

ppp

Page 9: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Review: Computing N-th Prime is P.R.

npt

n pttp

p

n

&Primemin 2.

0 1.

1!1

0

Page 10: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

More Number Theory Factoids

Page 11: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Bezout’s Identity

.

such that and integers are then there

,gcd i.e., , isdivisor common

greatest whoseintegers are and If

dbyax

yx

da,bd

ba

Page 12: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Bezout’s Identity: Example

642112)3(

1,3

6)1(42412

1,4

64212

6)42,12gcd(

yx

yx

yx

Page 13: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Euclid’s 1st Theorem (Book VII of Euclid’s Elements)

If a prime divides the product of two integers, then the prime divides at least one of the two integers. Formally, if p|ab, then p|a or p|b, where p is a prime and a and b are integers.

Page 14: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Proof Technique Note 1● Suppose we want to prove a statement: if A

then B or C● We assume A and not B and prove C ● In other words, if A and not B are true, then C

must be true, because otherwise, B or C cannot be true

● We can also assume A and not C and prove B

Page 15: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Euclid’s 1st Theorem: Proof

. offactor a is that

shown and )|( that assumed also have could We

. offactor a is So

).()(

Now, .1such that and integers are there

Identity, sBezout'By .1gcdThen .number somefor

, ,| Since ).|( prime, is ,| that Assume

ap

bp

bp

rybxprpybpxbaybpxaypxbb

aypxyx

(p,a)r

abrpabpappabp

Page 16: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Fundamental Theorem of Arithmetic

Every positive integer greater than 1 is either a prime or can be written as a product of primes. The factorizationis unique except for the order of factor primes.

This theorem is also known as Unique Factorization Theorem

Page 17: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

FTA: Examples

24

2

1111

3

5321200

3212

255210

22228

326

Page 18: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

FTA: Key Insight

]2,0[],1,0[],4,0[

where,532

form theof is 1200 ofdivisor Any

5321200 24

zyx

zyx

Page 19: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

FTA: Proof

1. We need to prove 2 statements:1. Every natural number greater than 1 has a

prime factorization, i.e., can be written as a product of primes

2. The prime factorization is unique

Page 20: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

FTA: Proof (Part 1)

. and of ionsfactorizat

prime ofthe consistsion that factorizat prime a has But then 7.

ions.factorizat prime haveboth and

ion,factorizat prime a havenot doesat number thsmallest

theis and than less numbers positive are and Since 6.

.1 and 1 where, composite, a isn Since 5.

composite. a is So 4.

ion.factorizat its as itself have it would it were, if because, prime, anot is 3.

.number thisCall

number.such smallest thebemust thereprinciple, ordering- wellBy the 2.

ion.factorizat prime a has 1an greater thnumber naturalevery not Suppose 1.

ba

n

ba

nn ba

nb na abn

n

n

n

Page 21: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Proof Technique Note 2● Suppose that we want to prove that some

mathematical object A is unique● A common way of doing this is to postulate the

existence of another mathematical object B with A’s properties and then show that A and B are the same

● In other words, A is unique, because any other object that has the same properties is A itself

Page 22: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

FTA: Proof (Part 2)

.,,1for and that case thebemust it , since But, 7.

...., ,,for repeated becan trick same The 6.

.by both themdividingby

and ofout taken becan Thus, .2or that case the

bemust it prime, a is Since .or Theorem,1st sEuclid'By 5.

Thus, . that know We. Take 4.

3.

. and

ionsfactorizat prime twohas that 1an greater thnumber natural a be Let 2.

.or then , and prime a is if :Theorem1st sEuclid' Recall .1

21

32

12

11111

12111

1111

1211

21

ji

n

i

m

m

mn

qpnjimnFF

ppp

pF

Fpmi , qpqp

p...q|qp|qp

....q|qp|npp

n....qqF...ppFn

FF

n

p|bp|ap|abp

Page 23: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Pairing Functions

Page 24: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Pairing Functions

● Pairing functions are coding devices for mapping pairs of natural numbers into single natural numbers and vice versa

● Once we have pairing functions we will be able to map lists of numbers into single numbers and vice versa

● Remember that our end objective is to compile L programs into natural numbers

Page 25: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Pairing Functions

1221,

01122

1122,

yyx

y

yyx

x

x

x

Page 26: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Equation 8.1 (Ch. 3)

., tofor solution

unique a is therenumber, natural a a is If

zyxx, y

z

Page 27: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Equation 8.1 (Ch. 3)

2

12

1

2

112 .5

.1|2such that number largest theis s,other wordIn

.1z| 2max .4

).12(21z .3

).12(21, .2

, .1

x

x

x

d

d

x

x

z

yz

y

zx

x

y

yyx

zyx

Page 28: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Equation 8.1 (Ch. 3): Upper Bounds on x & y

., Hence,

.1,1 Therefore,

.12211,

,1122, Since

zyzx

zyzx

yzyx

yzyxx

x

Page 29: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Example 1

.10111115225,0 :Check

.51112

011|2max

11122

10112210,

.10, Solve

0

yy

xx

y

yyx

yx

d

d

x

x

Page 30: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Example 2

.19120112222,2:Check

.251220122

220|2max

20122

191122,

.19, Solve

2

2

yyy

x

y

yyx

yx

d

d

x

x

Page 31: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Splitting Natural Numbers

Page 32: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Equation 8.1 (Ch. 03)

.22,219;22,219

.55,010;05,010

:Examples

.,

.,

. , and :functions twodefines 8.1Equation

rrll

rrll

yyxrzr

xyxlzl

Nzzrzl

Page 33: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Lemma

recursive. primitive are and zrzl

Page 34: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Proof

,min)(

,min)(

Thus, .,,, then , If

yxzxzr

yxzyzl

zyzxyxzNz

zzy

zzx

Page 35: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Theorem 8.1 (Ch. 03)

zzrzzl

zzrzl

yyxrxyxl

zrzlx,y

, 4.

, 3.

,,, 2.

recursive primitive areThey 1.

:properties following thehave ,, functions The

Page 36: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Proof 8.1 (Ch. 03)

This theorem summarizes the properties of the pairing function and the splitting functions l(z) and r(z). Properties 2, 3, 4 follow from Equation 8.1. Property 1 follows from Equation 8.1 and the definitions for l(z) and r(z).

Page 37: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Gödel Numbers

Page 38: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Kurt Gödel

1906 - 1978

Page 39: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Background

● Gödel investigated the use of logic and set theory to understand the foundations of mathematics

● Gödel developed a technique to convert formal symbolic statements into natural numbers

● The technique was later called Gödel numbering

Page 40: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Coding Programs by Numbers ● Programming languages are symbolic formalisms● If we can convert statements of symbolic formalisms into numbers

[in other words, any program P is associated with a unique number #(P)], we have the foundations of a mathematical theory of program compilation and program execution (interpretation)

● The gist of the theory is three-fold: ● Given a program P, there is a computable function C (Compiler)

such that C(P) = #(P); this is the compiler● Given #(P), there is a computable function RC (Reverse Compiler)

such that RC(#(P))= P; this function is the reverse compiler● Given a program P, there is a partially computable function VM

that can execute C(P); this is the operating system or the virtual machine

Page 41: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Gödel Numbers

n

ii

ain

n

ippaa

aa

i

1

th1

1

prime. theis where,,...,

define Wenumbers. of sequence a be ,...,Let

naa ,...,1is the Gödel number (G-number) of this sequence.

Page 42: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Example

.5321,3,2

is sequence thisofnumber -G The

.2,3,1 sequence following thehave weSuppose

23123

32

11 ppp

Page 43: Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers

Reading Suggestions

● Ch. 03, Computability, Complexity, and Languages, 2nd Edition, by Davis, Sigal, Weyuker, Academic Press

● http://en.wikipedia.org/wiki/Kurt_Gödel