Upload
ravenblake89
View
244
Download
0
Embed Size (px)
Citation preview
8/13/2019 Comput Lection 3
1/49
Lection 3 Computability Theory
Church Thesis
Gdelization
Universal Turing machine
Padding Lemma
Models of computation: -calculus
VU Logic and Computation p. 1
8/13/2019 Comput Lection 3
2/49
Church-Turing Thesis
The functions computed by an algorithm coincide withthe class of functions computable by Turing machines.
Recall thatf :N N isTuring computableiff there exists a TMA
starting withq0, x,Ahalts ifff(x)
in that casew0qay, wheref(x) =y.
VU Logic and Computation p. 2
8/13/2019 Comput Lection 3
3/49
8/13/2019 Comput Lection 3
4/49
Computable Functions
To prove that a functionf is computable:
write a Turing machine that computes the function
give an informal algorithm to computefand use Churchsthesis
VU Logic and Computation p. 4
8/13/2019 Comput Lection 3
5/49
Universal Turing Machine
A generic TM that can beprogrammedto solve any problem thatcan be solved by a TM.
The program" that makes the generic machine simulated a
specific machineM is adescriptionofM. We need toencodeTMs so that their description can be
used as input to the generic TM.
(Enumeration ofGdelization)
VU Logic and Computation p. 5
8/13/2019 Comput Lection 3
6/49
Godelization
T :T M N
A possible encoding (there are many other alternatives):
Given a TM we consider its functional matrix
we order all the strings identifying functional matrices of TM
according to their length lexicographically
VU Logic and Computation p. 6
8/13/2019 Comput Lection 3
7/49
Universal Turing Machine
Theuniversal Turing machine,Uon inputT(M), w, whereMis a TM andwa string, behaves as follows:
1. ExtractM fromT(M)and check thatwis a correct string
2. SimulatesMon inputw
3. IfMon inputw enters its accept state,U accept, and ifMon inputwever enters its reject state,U reject.
VU Logic and Computation p. 7
8/13/2019 Comput Lection 3
8/49
Universal Turing Machine
Theuniversal Turing machine,Uon inputT(M), w, whereMis a TM andwa string, behaves as follows:
1. ExtractM fromT(M)and check thatwis a correct string
2. SimulatesMon inputw
3. IfMon inputw enters its accept state,U accept, and ifMon inputwever enters its reject state,U reject.
Notice that ifMon inputw enters an infinite loop, so doesU oninputM, w.
VU Logic and Computation p. 7
8/13/2019 Comput Lection 3
9/49
Universal Turing Machine
1. Informal argument (via Church thesis and enumeration ofTM)
2. Formal proof
VU Logic and Computation p. 8
8/13/2019 Comput Lection 3
10/49
Universal Turing Machine informal argument
LetZx be thex-th Turing machine (w.r.t. the enumerationT)
Take the functiong:N N Nsuch that
g(x, y)Zx(y)
VU Logic and Computation p. 9
8/13/2019 Comput Lection 3
11/49
Universal Turing Machine informal argument
LetZx be thex-th Turing machine (w.r.t. the enumerationT)
Take the functiong:N N Nsuch that
g(x, y)Zx(y)
g is computable (Churchs thesis)
Algorithm
fromxtoZx viaT1 :N T M (T1(x) =Zx)
Zx(y)
VU Logic and Computation p. 9
8/13/2019 Comput Lection 3
12/49
8/13/2019 Comput Lection 3
13/49
Universal Turing Machine 2
A step ofMis simulated as follows:
Uscans tape 2 until it finds the matching transition (the firstcomponent matches the state written on tape 3 and the
second component matches the current symbol on tape 1). If it is found, change the state on tape 3 and update tape 1
accordingly.
If not found, the final state has been reached.
VU Logic and Computation p. 11
8/13/2019 Comput Lection 3
14/49
Universal Turing Machine 3
The universal machineUobviously has afixed numberofstates.
Despite this, it can simulate machinesMwithanynumber
of states.Universal machines inspired the development ofstored-program computers in the 40s and 50s.
VU Logic and Computation p. 12
8/13/2019 Comput Lection 3
15/49
Padding Lemma
0 Z001 Z112 Z22
3 Z33... is an enumeration of computable functions
VU Logic and Computation p. 13
8/13/2019 Comput Lection 3
16/49
Padding Lemma
0 Z001 Z112 Z22
3 Z33... is an enumeration of computable functions
Padding LemmaEvery computable function admits an infinite number of indexes.
VU Logic and Computation p. 13
8/13/2019 Comput Lection 3
17/49
Not all functions are (Turing) computable
VU Logic and Computation p. 14
8/13/2019 Comput Lection 3
18/49
A not computable function
1, 2, . . . (Turing) computable functions
Example: The diagonal function:
g(x) =
ifx(x)0 otherwise
VU Logic and Computation p. 15
8/13/2019 Comput Lection 3
19/49
Other Models of Computations
Formal notionsappeared, starting in 1936:
-calculusof Alonzo Church
Turing machinesof Alan Turing
Recursive functionsof Gdel and Kleene
Countermachines of Minsky
Normal algorithmsof Markov
Unrestrictedgrammars
Two stackautomata
Random accessmachines (RAMs)
...VU Logic and Computation p. 16
8/13/2019 Comput Lection 3
20/49
Church-Turing Thesis
These definitions look very different, but areprovably equivalent.
The Church-Turing Thesis:
The intuitive notion of reasonable models ofcomputation equals Turing machine algorithms.
VU Logic and Computation p. 17
8/13/2019 Comput Lection 3
21/49
Church-Turing Thesis
Why is this a thesis and not atheorem?
Because the notion of reasonable model of computing isnot well defined.
In 2008, Nachum Dershowitz (TAU) and Yu. Gurevitch(MSFT) gave an axiomatization of this notion.
This axiomatization seems to reasonably capture what a
reasonable model of computing is.
Under this axiomatization, DG gave a proof of theChurch-Turing thesis.
VU Logic and Computation p. 18
8/13/2019 Comput Lection 3
22/49
calculus
VU Logic and Computation p. 19
8/13/2019 Comput Lection 3
23/49
Why calculus?
A more abstract, machine-independent description of thecollection of computable functions than that provided by Turingmachines.
Historical Useful for formal semantics of programming languages
Its at the core of functional programming languages (LISP,
ML..)
VU Logic and Computation p. 20
8/13/2019 Comput Lection 3
24/49
-Terms
are built from a given, countable collection of
variablesx, y, z . . .
by two operations for forming-terms:
abstraction: (x.M)(wherexis a variable andM a-term)
application: (M M)
(whereM andM are-terms)
VU Logic and Computation p. 21
8/13/2019 Comput Lection 3
25/49
-Terms
Notational conventions:
(x1x2 . . . xn.M)means(x1.(x2. . . . (xn.M) . . . )
(M1M2 . . . M n)means(. . . (M1M2) . . . M n), i.e. application
is left-associative
drop outermost parentheses and those enclosing the bodyof a-abstraction
VU Logic and Computation p. 22
8/13/2019 Comput Lection 3
26/49
Free and Bound Variables
Inx.Mwe callxthebound variableandM thebodyof theabstraction.
VU Logic and Computation p. 23
8/13/2019 Comput Lection 3
27/49
Free and Bound Variables
Inx.Mwe callxthebound variableandM thebodyof theabstraction.
An occurrence ofxin a-termM is called
binding, if in betweenand .
boundif in the body of a binding occurrence of x
freeif neither binding not bound
VU Logic and Computation p. 23
8/13/2019 Comput Lection 3
28/49
Free and Bound Variables
Sets offreeandboundvariables
F V(x) ={x}
F V(x.M) =F V(M)\ {x}
F V(M N) =F V(M) F V(N)
BV(x) =
BV(x.M) =BV(M) {x}BV(M N) =BV(M) BV(N)
IfF V(M) =,Mis called aclosed term, or combinator
VU Logic and Computation p. 24
8/13/2019 Comput Lection 3
29/49
Rules for transforming terms
VU Logic and Computation p. 25
8/13/2019 Comput Lection 3
30/49
-Equivalence M=M
x.Mis intended to represent the functionfsuch that
f(x) =M, for allx.
VU Logic and Computation p. 26
8/13/2019 Comput Lection 3
31/49
-Equivalence M=M
x.Mis intended to represent the functionfsuch that
f(x) =M, for allx.
Hence ifM =M[x/x]is the result of takingMand changingall occurrences ofxto some variablex that does not appearfree inM, thenx.Mandx.M both represent the samefunction.
VU Logic and Computation p. 26
8/13/2019 Comput Lection 3
32/49
-Equivalence M=M
x.Mis intended to represent the functionfsuch that
f(x) =M, for allx.
Hence ifM =M[x/x]is the result of takingMand changingall occurrences ofxto some variablex that does not appearfree inM, thenx.Mandx.M both represent the samefunction.
x.M x.M[x/x]
VU Logic and Computation p. 26
8/13/2019 Comput Lection 3
33/49
-Equivalence
is the smallest relation onterms satisfying the following rules:
M=M
(refl) N=M
M=N
(symm)
M=N N=PM=P
(trans) M=Nx.M=x.N
()
M=M N=N
M N=MN (cong)
y /M
x.M=y.(M{y/x}) ()
VU Logic and Computation p. 27
8/13/2019 Comput Lection 3
34/49
-Reduction
The process of evaluating lambda terms by "plugging argumentsinto functions".
x.Mcan be seen as a function on -terms via substitution:
map eachN toM[N/x].
VU Logic and Computation p. 28
8/13/2019 Comput Lection 3
35/49
-Reduction
The process of evaluating lambda terms by "plugging argumentsinto functions".
x.Mcan be seen as a function on -terms via substitution:
map eachN toM[N/x].So the natural notion of computation for -terms is given bystepping from a
-redex(x.M)Nto the corresponding
-reductM[N/x]
VU Logic and Computation p. 28
8/13/2019 Comput Lection 3
36/49
Substitution M[N/x]
x[N/x] =N
y[N/x] =y (ifx=y)
y.M[N/x] =y.(M[N/x])ifx=y andyF V(N x)
(M1M2)[N/x] =M1[N/x]M2[N/x]
The side conditionyF V(N x)makes substitution "capture
avoiding".
y.M[N/x] =y.(M{y
/y}[N/x]) y fresh
VU Logic and Computation p. 29
8/13/2019 Comput Lection 3
37/49
Single-step -reduction
Is the smallest relationon terms satisfying
(x.M)NM[N/x] ()
MM
M NMN
(cong1)NN
M NMN
(cong2)
MN
x.Mx.N ()
VU Logic and Computation p. 30
8/13/2019 Comput Lection 3
38/49
-reduction and -equivalence
is the reflexive and transitive closure of .MM ifMreduces toM in zero or more steps.
VU Logic and Computation p. 31
8/13/2019 Comput Lection 3
39/49
-reduction and -equivalence
is the reflexive and transitive closure of .MM ifMreduces toM in zero or more steps.
M= Nholds ifNcan be obtained fromMperforming zero or
more steps of-reductions,-reductions and/or inversereduction steps (i.e. makingsymmetric). Formally,=
is
defined to be the reflexive, symmetric and transitive closure of, i.e. the smallest equivalence relation containing .
VU Logic and Computation p. 31
8/13/2019 Comput Lection 3
40/49
Church-Rosser
Theoremisconfluent, that is, if
M1MM2
then there existsM such that
M1M M2
VU Logic and Computation p. 32
N l F
8/13/2019 Comput Lection 3
41/49
Normal Form
Def.A-termN is in-normal form (nf) if it contains no-redex (i.e.no sub-terms of the form(x.M)M).
M has-nfN ifM=
N withN a-nf.
VU Logic and Computation p. 33
N l F
8/13/2019 Comput Lection 3
42/49
Normal Form
Def.A-termN is in-normal form (nf) if it contains no-redex (i.e.no sub-terms of the form(x.M)M).
M has
-nf
N if
M=
N with
N a
-nf.
Note that ifN is in-nf andNN, thenN= N.
VU Logic and Computation p. 33
N l F
8/13/2019 Comput Lection 3
43/49
Normal Form
Def.A-termN is in-normal form (nf) if it contains no-redex (i.e.no sub-terms of the form(x.M)M).
M has
-nf
N if
M=
N with
N a
-nf.
Note that ifN is in-nf andNN, thenN= N.
Corollary:The-nf ofMis unique up to-equivalence, if it
exists.
VU Logic and Computation p. 33
Non termination
8/13/2019 Comput Lection 3
44/49
Non-termination
Someterms have no-nf
VU Logic and Computation p. 34
Non termination
8/13/2019 Comput Lection 3
45/49
Non-termination
Someterms have no-nf
Ex.
:= (x.xx)(x.xx)
VU Logic and Computation p. 34
Encoding data in calculus
8/13/2019 Comput Lection 3
46/49
Encoding data in -calculus
Computation incalculus is given by-reduction. To relate thisto Turing-machine computation, or computation in other modelswe have to see how to encode numbers, pairs, lists... as-terms.
VU Logic and Computation p. 35
Encoding data in calculus
8/13/2019 Comput Lection 3
47/49
Encoding data in -calculus
Computation incalculus is given by-reduction. To relate thisto Turing-machine computation, or computation in other modelswe have to see how to encode numbers, pairs, lists... as-terms.
Example
T :=xy.x F :=xy.y
and:=ab.abF
if-then-else:=a.a
VU Logic and Computation p. 35
definable functions
8/13/2019 Comput Lection 3
48/49
-definable functions
f :Nn N is-definable if there is a closed-termF thatrepresents it: for all(x1, . . . xn) Nn andy N
iff(x1, . . . xn) =ythenF x1 . . . xn= y
iff(x1, . . . xn), thenF x1 . . . xn has no-nf
Computable =-definable
VU Logic and Computation p. 36
Bibliography
8/13/2019 Comput Lection 3
49/49
Bibliography
Sipser, Introduction to the Theory of Computation, PWSPublishing Co., 1997
Hindley, Selding, Introduction to Combinators and
-Calculus, London Mathematical Society, 1 990 Odifreddi, Classical Recursion Theory, North-Holland, 1989
http://arxiv.org/pdf/0804.3434v1.pdf(Ch. 1-4.2)Selinger, Lecture Notes on the Lambda Calculus
...
VU Logic and Computation p. 37
http://arxiv.org/pdf/0804.3434v1.pdfhttp://arxiv.org/pdf/0804.3434v1.pdf