0% found this document useful (0 votes)
72 views49 pages

Comput Lection 3

The document provides an overview of computability theory and models of computation. It discusses the Church-Turing thesis which states that any reasonable model of computation is equivalent in power to a Turing machine. The document defines Turing machines and universal Turing machines. It also discusses other models like the lambda calculus and provides examples of computable and non-computable functions.

Uploaded by

raven_blake89
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views49 pages

Comput Lection 3

The document provides an overview of computability theory and models of computation. It discusses the Church-Turing thesis which states that any reasonable model of computation is equivalent in power to a Turing machine. The document defines Turing machines and universal Turing machines. It also discusses other models like the lambda calculus and provides examples of computable and non-computable functions.

Uploaded by

raven_blake89
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Lection 3 Computability Theory

Church Thesis Gdelization Universal Turing machine Padding Lemma Models of computation: -calculus

VU Logic and Computation p. 1

Church-Turing Thesis
The functions computed by an algorithm coincide with the class of functions computable by Turing machines. Recall that f : N N is Turing computable iff there exists a TM A
starting with q0 , x, A halts iff f (x) in that case w0 qa y , where f (x) = y .

VU Logic and Computation p. 2

Church-Turing Thesis
The functions computed by an algorithm coincide with the class of functions computable by Turing machines. Evidences:
many independent proposals for a precise formulation of

computable functions led to the same class of functions


one can show that a vast collection of computable functions

are Turing-computable
the computation of a Turing machine is an example of

algorithm
no one has ever found a computable function that is not

Turing-computable

VU Logic and Computation p. 3

Computable Functions
To prove that a function f is computable:
write a Turing machine that computes the function give an informal algorithm to compute f and use Churchs

thesis

VU Logic and Computation p. 4

Universal Turing Machine


A generic TM that can be programmed to solve any problem that can be solved by a TM.
The program" that makes the generic machine simulated a

specic machine M is a description of M .


We need to encode TMs so that their description can be

used as input to the generic TM. (Enumeration of Gdelization)

VU Logic and Computation p. 5

Godelization
T : TM 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

Universal Turing Machine


The universal Turing machine, U on input T (M ), w , where M is a TM and w a string, behaves as follows:

1. 2. 3.

Extract M from T (M ) and check that w is a correct string Simulates M on input w If M on input w enters its accept state, U accept, and if M on input w ever enters its reject state, U reject.

VU Logic and Computation p. 7

Universal Turing Machine


The universal Turing machine, U on input T (M ), w , where M is a TM and w a string, behaves as follows:

1. 2. 3.

Extract M from T (M ) and check that w is a correct string Simulates M on input w If M on input w enters its accept state, U accept, and if M on input w ever enters its reject state, U reject.

Notice that if M on input w enters an innite loop, so does U on input M, w .

VU Logic and Computation p. 7

Universal Turing Machine


1. Informal argument (via Church thesis and enumeration of TM) 2. Formal proof

VU Logic and Computation p. 8

Universal Turing Machine informal argument


Let Zx be the x-th Turing machine (w.r.t. the enumeration T ) Take the function g : N N N such that
g (x, y ) Zx (y )

VU Logic and Computation p. 9

Universal Turing Machine informal argument


Let Zx be the x-th Turing machine (w.r.t. the enumeration T ) Take the function g : N N N such that
g (x, y ) Zx (y ) g is computable (Churchs thesis) Algorithm
from x to Zx via T 1 : N T M (T 1 (x) = Zx ) Zx (y )

VU Logic and Computation p. 9

Universal Turing Machine a more formal proof


The UTM U takes two arguments: < M > - an encoding of

M and w - the input to M .


U halts on (< M >, w) iff M halts on w. U simulates M on w using 3 tapes: Tape 1: encoding of the current tape contents of M Tape 2: encoding of M Tape 3: the state of M at the current point of simulated

computation.
When U starts (< M >, w) is written on the rst tape and

the rest of the tapes are empty.


U moves M to tape 2 and writes the encoding of the initial

state on tape 3.

VU Logic and Computation p. 10

Universal Turing Machine 2


A step of M is simulated as follows:
U scans tape 2 until it nds the matching transition (the rst

component 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 nal state has been reached.

VU Logic and Computation p. 11

Universal Turing Machine 3


The universal machine U obviously has a xed number of states. Despite this, it can simulate machines M with any number of states. Universal machines inspired the development of stored-program computers in the 40s and 50s.

VU Logic and Computation p. 12

Padding Lemma
0 Z0 0 1 Z1 1 2 Z2 2 3 Z3 3 ... is an enumeration of computable functions

VU Logic and Computation p. 13

Padding Lemma
0 Z0 0 1 Z1 1 2 Z2 2 3 Z3 3 ... is an enumeration of computable functions

Padding Lemma Every computable function admits an innite number of indexes.

VU Logic and Computation p. 13

Not all functions are (Turing) computable

VU Logic and Computation p. 14

A not computable function


1 , 2 , . . . (Turing) computable functions

Example: The diagonal function:


g (x) = if x (x) 0 otherwise

VU Logic and Computation p. 15

Other Models of Computations


Formal notions appeared, starting in 1936:

-calculus of Alonzo Church Turing machines of Alan Turing Recursive functions of Gdel and Kleene Counter machines of Minsky Normal algorithms of Markov Unrestricted grammars Two stack automata

. .

Random access machines (RAMs)

VU Logic and Computation p. 16

Church-Turing Thesis
These denitions look very different, but are provably equivalent. The Church-Turing Thesis: The intuitive notion of reasonable models of computation equals Turing machine algorithms.

VU Logic and Computation p. 17

Church-Turing Thesis
Why is this a thesis and not a theorem? Because the notion of reasonable model of computing is not well dened. 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 the Church-Turing thesis.

VU Logic and Computation p. 18

calculus

VU Logic and Computation p. 19

Why calculus?
A more abstract, machine-independent description of the collection of computable functions than that provided by Turing machines.
Historical Useful for formal semantics of programming languages Its at the core of functional programming languages (LISP,

ML..)

VU Logic and Computation p. 20

-Terms
are built from a given, countable collection of
variables x, y, z . . .

by two operations for forming -terms:


abstraction: (x.M )

(where x is a variable and M a -term)


application: (M M )

(where M and M are -terms)

VU Logic and Computation p. 21

-Terms
Notational conventions:
(x1 x2 . . . xn .M ) means (x1 .(x2 . . . . (xn .M ) . . . ) (M1 M2 . . . Mn ) means (. . . (M1 M2 ) . . . Mn ), i.e. application

is left-associative
drop outermost parentheses and those enclosing the body

of a -abstraction

VU Logic and Computation p. 22

Free and Bound Variables


In x.M we call x the bound variable and M the body of the abstraction.

VU Logic and Computation p. 23

Free and Bound Variables


In x.M we call x the bound variable and M the body of the abstraction. An occurrence of x in a -term M is called
binding, if in between and . bound if in the body of a binding occurrence of x free if neither binding not bound

VU Logic and Computation p. 23

Free and Bound Variables


Sets of free and bound variables
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 )

If F V (M ) = , M is called a closed term, or combinator

VU Logic and Computation p. 24

Rules for transforming terms

VU Logic and Computation p. 25

-Equivalence M = M
x.M is intended to represent the function f such that f (x) = M,

for all x.

VU Logic and Computation p. 26

-Equivalence M = M
x.M is intended to represent the function f such that f (x) = M,

for all x.

Hence if M = M [x /x] is the result of taking M and changing all occurrences of x to some variable x that does not appear free in M , then x.M and x .M both represent the same function.

VU Logic and Computation p. 26

-Equivalence M = M
x.M is intended to represent the function f such that f (x) = M,

for all x.

Hence if M = M [x /x] is the result of taking M and changing all occurrences of x to some variable x that does not appear free in M , then x.M and x .M both represent the same function.
x.M x .M [x /x]

VU Logic and Computation p. 26

-Equivalence
is the smallest relation on terms satisfying the following rules:

M =M

(ref l)

N = M (symm) M =N M =N ( ) x.M = x.N

M = N N = P (trans) M =P

M = M N = N (cong ) M N = M N

y /M ( ) x.M = y.(M {y /x })

VU Logic and Computation p. 27

-Reduction
The process of evaluating lambda terms by "plugging arguments into functions".
x.M can be seen as a function on -terms via substitution: map each N to M [N/x].

VU Logic and Computation p. 28

-Reduction
The process of evaluating lambda terms by "plugging arguments into functions".
x.M can be seen as a function on -terms via substitution: map each N to M [N/x].

So the natural notion of computation for -terms is given by stepping from a


-redex (x.M )N

to the corresponding
-reduct M [N/x]

VU Logic and Computation p. 28

Substitution M [N/x]
x[N/x] = N y [N/x] = y (if x = y ) y.M [N/x] = y.(M [N/x]) if x = y and y F V (N x) (M1 M2 )[N/x] = M1 [N/x]M2 [N/x]

The side condition y F V (N x) makes substitution "capture avoiding".


y.M [N/x] = y .(M { /y }[N/x])
y

y fresh

VU Logic and Computation p. 29

Single-step -reduction
Is the smallest relation on terms satisfying

(x.M )N M [N/x]

( )

M M (cong1 ) M N M N

N N (cong2 ) M N M N

M N ( ) x.M x.N

VU Logic and Computation p. 30

-reduction and -equivalence


is the reexive and transitive closure of . M M if M reduces to M in zero or more steps.

VU Logic and Computation p. 31

-reduction and -equivalence


is the reexive and transitive closure of . M M if M reduces to M in zero or more steps. M = N holds if N can be obtained from M performing zero or more steps of -reductions, -reductions and/or inverse reduction steps (i.e. making symmetric). Formally, = is dened to be the reexive, symmetric and transitive closure of , i.e. the smallest equivalence relation containing .

VU Logic and Computation p. 31

Church-Rosser
Theorem is conuent, that is, if
M1 M M2

then there exists M such that


M1 M M2

VU Logic and Computation p. 32

Normal Form
Def. A -term N 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.

VU Logic and Computation p. 33

Normal Form
Def. A -term N 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 if N is in -nf and N N , then N = N .

VU Logic and Computation p. 33

Normal Form
Def. A -term N 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 if N is in -nf and N N , then N = N . Corollary: The -nf of M is unique up to -equivalence, if it exists.

VU Logic and Computation p. 33

Non-termination
Some terms have no -nf

VU Logic and Computation p. 34

Non-termination
Some terms have no -nf Ex.
:= (x.xx)(x.xx)

VU Logic and Computation p. 34

Encoding data in -calculus


Computation in calculus is given by -reduction. To relate this to Turing-machine computation, or computation in other models we have to see how to encode numbers, pairs, lists... as -terms.

VU Logic and Computation p. 35

Encoding data in -calculus


Computation in calculus is given by -reduction. To relate this to Turing-machine computation, or computation in other models we have to see how to encode numbers, pairs, lists... as -terms. Example
T := xy.x
and:= ab.abF if-then-else:= a.a

F := xy.y

VU Logic and Computation p. 35

-denable functions
f : N n N is -denable if there is a closed -term F that represents it: for all (x1 , . . . xn ) N n and y N
if f (x1 , . . . xn ) = y then F x1 . . . xn = y if f (x1 , . . . xn ) , then F x1 . . . xn has no -nf

Computable = -denable

VU Logic and Computation p. 36

Bibliography
Sipser, Introduction to the Theory of Computation, PWS

Publishing 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

You might also like