Theory of Computation (Fall 2013): More Number Theory Factoids, Pairing Functions, Godel Numbers
-
Upload
vladimir-kulyukin -
Category
Technology
-
view
364 -
download
0
Transcript of 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
Outline● Review● More Number Theory
Bezout's Identity Euclid's 1st Theorem Fundamental Theorem of Arithmetic (Unique Factorization
Theorem)● Pairing Functions● Gödel Numbers
Review
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
Review: Euclid’s 2nd Theorem
There are infinitely many primes
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
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
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
Review: Computing N-th Prime is P.R.
npt
n pttp
p
n
&Primemin 2.
0 1.
1!1
0
More Number Theory Factoids
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
Bezout’s Identity: Example
642112)3(
1,3
6)1(42412
1,4
64212
6)42,12gcd(
yx
yx
yx
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.
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
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
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
FTA: Examples
24
2
1111
3
5321200
3212
255210
22228
326
FTA: Key Insight
]2,0[],1,0[],4,0[
where,532
form theof is 1200 ofdivisor Any
5321200 24
zyx
zyx
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
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
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
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
Pairing Functions
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
Pairing Functions
1221,
01122
1122,
yyx
y
yyx
x
x
x
Equation 8.1 (Ch. 3)
., tofor solution
unique a is therenumber, natural a a is If
zyxx, y
z
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
Equation 8.1 (Ch. 3): Upper Bounds on x & y
., Hence,
.1,1 Therefore,
.12211,
,1122, Since
zyzx
zyzx
yzyx
yzyxx
x
Example 1
.10111115225,0 :Check
.51112
011|2max
11122
10112210,
.10, Solve
0
yy
xx
y
yyx
yx
d
d
x
x
Example 2
.19120112222,2:Check
.251220122
220|2max
20122
191122,
.19, Solve
2
2
yyy
x
y
yyx
yx
d
d
x
x
Splitting Natural 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
Lemma
recursive. primitive are and zrzl
Proof
,min)(
,min)(
Thus, .,,, then , If
yxzxzr
yxzyzl
zyzxyxzNz
zzy
zzx
Theorem 8.1 (Ch. 03)
zzrzzl
zzrzl
yyxrxyxl
zrzlx,y
, 4.
, 3.
,,, 2.
recursive primitive areThey 1.
:properties following thehave ,, functions The
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).
Gödel Numbers
Kurt Gödel
1906 - 1978
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
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
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.
Example
.5321,3,2
is sequence thisofnumber -G The
.2,3,1 sequence following thehave weSuppose
23123
32
11 ppp
Reading Suggestions
● Ch. 03, Computability, Complexity, and Languages, 2nd Edition, by Davis, Sigal, Weyuker, Academic Press
● http://en.wikipedia.org/wiki/Kurt_Gödel