TCS: Church-Turing Thesis

Church-Turing Thesis

Recursion from Fixed Points

The fixed-point combinator from Lecture 1 turns a recursive equation into a term. First write a function that receives its recursive call as a parameter, then take its fixed point

For factorial, using the Boolean and numeral encodings from Lecture 2, define

F=λfn.if (iszero n) 1‾ (mult n (f(pred n)))fact=YF\begin{aligned} F&=\lambda fn.\mathbf{if}\,(\mathbf{iszero}\,n)\, \overline1\,(\mathbf{mult}\,n\,(f(\mathbf{pred}\,n)))\\ \mathbf{fact}&=\mathbf YF \end{aligned}

Since fact=βFfact\mathbf{fact}=_\beta F\mathbf{fact}, unfolding once gives the intended recurrence

fact n‾=β{1‾n=0mult n‾ (fact n−1‾)n>0\mathbf{fact}\,\overline n=_\beta \begin{cases} \overline1 & n=0\\ \mathbf{mult}\,\overline n\, (\mathbf{fact}\,\overline{n-1}) & n>0 \end{cases}

Induction on nn proves that normal-order evaluation reaches n!‾\overline{n!}. The evaluation strategy matters: eager evaluation of the recursive argument of Y\mathbf Y can diverge before a conditional selects its branch

Pairs, Tuples and Lists

Data as an Interface

A pair packages two terms and waits for a selector to say how they should be used

pair=λabc.cabfst=λp.pTsnd=λp.pF\begin{aligned}\mathbf{pair}&=\lambda abc.cab\\\mathbf{fst}&=\lambda p.p\mathbf T\\\mathbf{snd}&=\lambda p.p\mathbf F\end{aligned}

The projection equations follow by substitution

fst(pair M N)→β∗Msnd(pair M N)→β∗N\mathbf{fst}(\mathbf{pair}\,M\,N)\to_\beta^*M \qquad \mathbf{snd}(\mathbf{pair}\,M\,N)\to_\beta^*N

Similarly, encode a tuple as λc.cM1⋯Mk\lambda c.cM_1\cdots M_k and obtain its ii-th component by supplying λx1⋯xk.xi\lambda x_1\cdots x_k.x_i

A Pair-Based List Encoding

Choose the following representation, with h::th::t abbreviating cons h t\mathbf{cons}\,h\,t

nil=λu.Tcons=pairhead=fsttail=sndempty=λl.l(λht.F)\begin{aligned} \mathbf{nil}&=\lambda u.\mathbf T\\ \mathbf{cons}&=\mathbf{pair}\\ \mathbf{head}&=\mathbf{fst}\\ \mathbf{tail}&=\mathbf{snd}\\ \mathbf{empty}&=\lambda l.l(\lambda ht.\mathbf F) \end{aligned}

Applying empty\mathbf{empty} to nil\mathbf{nil} returns T\mathbf T. Applying it to h::th::t passes h,th,t to a function that returns F\mathbf F

The list operations use head\mathbf{head} and tail\mathbf{tail} only after checking that the list is nonempty. Their behavior on the empty list is not part of their intended interface

Fold, Map and Filter

Define a right fold by its two equations

fold nil f z=βzfold (h::t) f z=βfh(fold t f z)\begin{aligned} \mathbf{fold}\,\mathbf{nil}\,f\,z&=_\beta z\\ \mathbf{fold}\,(h::t)\,f\,z&=_\beta fh(\mathbf{fold}\,t\,f\,z) \end{aligned}

A fixed point realizes these equations

fold=Y(λrlfz.if (empty l) z (f(head l)(r(tail l)fz)))\mathbf{fold}=\mathbf Y \bigl(\lambda rlfz. \mathbf{if}\,(\mathbf{empty}\,l)\,z\, (f(\mathbf{head}\,l)(r(\mathbf{tail}\,l)fz))\bigr)

Then map and filter become choices of the combining function

map=λlf.fold l (λht.cons (fh) t) nilfilter=λlp.fold l (λht.if (ph) (cons h t) t) nil\begin{aligned} \mathbf{map}&=\lambda lf. \mathbf{fold}\,l\,(\lambda ht.\mathbf{cons}\,(fh)\,t)\,\mathbf{nil}\\ \mathbf{filter}&=\lambda lp. \mathbf{fold}\,l\, (\lambda ht.\mathbf{if}\,(ph)\,(\mathbf{cons}\,h\,t)\,t)\, \mathbf{nil} \end{aligned}

For a finite list, structural induction establishes their intended behavior. All the data constructors and control flow are ordinary λ\lambda-terms

What Counts as Computation?

The Church-Turing thesis identifies effectively calculable functions with functions computable by Turing machines

This is a claim connecting an informal notion with a formal model. In contrast, the equivalence between Turing machines and the λ\lambda-calculus is a mathematical theorem about two formal definitions

The thesis concerns which functions can be computed with unbounded finite time and memory. A separate efficiency thesis concerns the cost of simulating computational models

Turing Machines and Their Encodings

A deterministic Turing machine has finitely many states and tape symbols. Each transition reads the current symbol, writes a symbol, changes state, and moves the head

Its finite transition table can be encoded as a string ⟨M⟩\langle M\rangle. A universal machine interprets such a description and simulates MM on an input ww

U(⟨M⟩,w)≃M(w)U(\langle M\rangle,w)\simeq M(w)

Here ≃\simeq allows partial behavior: if the simulated machine runs forever, the universal simulation also runs forever. Code and input are both finite strings, so programs can construct and inspect descriptions of other programs

Deciding, Recognizing and Reducing

A decider halts on every input with the correct membership answer. A recognizer accepts members but may run forever on nonmembers

Consider the halting language

HALT⁡={⟨M,w⟩:M eventually halts on w}\operatorname{HALT} =\{\langle M,w\rangle:M\text{ eventually halts on }w\}

It is recognizable by universal simulation. If a decider HH existed, construct DD that, on input zz, loops when H(⟨z,z⟩)H(\langle z,z\rangle) says the encoded machine halts, and halts otherwise. Running DD on its own description contradicts either answer

The acceptance language ACC⁡TM\operatorname{ACC}_{\mathrm{TM}} is likewise recognizable and undecidable. For a deterministic computation model, a language is decidable exactly when both it and its complement are recognizable: dovetail the two recognizers until one accepts

Mapping Reductions

Write A≤mBA\le_m B when a total computable function ff satisfies

x∈A⟺f(x)∈Bx\in A\quad\Longleftrightarrow\quad f(x)\in B

A decider for BB, composed with ff, would decide AA

To prove a target problem BB undecidable, reduce an already undecidable problem to BB. The transformation must finish on every input; it cannot wait indefinitely to discover whether the source machine halts

For example, transform ⟨M,w⟩\langle M,w\rangle into a machine NN that ignores its input, simulates M(w)M(w), and accepts if that simulation halts. Then MM halts on ww exactly when NN accepts the empty string

Why Lambda Calculus Is Turing Complete

The simulation has two directions

  1. A Turing machine can store a finite λ\lambda-term as a syntax tree, perform capture-avoiding substitution, and follow normal-order reduction
  2. A λ\lambda-term can encode machine states, tape symbols, finite lists, and the transition operation of a Turing machine

For the second direction, represent a configuration by its state, the current symbol, and lists containing the tape to the left and right of the head. A head movement pops one list and pushes onto the other, inserting a blank when necessary

Since the transition table is finite, comparisons and Boolean case selection implement a term stepM\mathbf{step}_M that maps a configuration to its successor

runM=Y(λrc.if (haltMc) (outputMc) (r(stepMc)))\mathbf{run}_M=\mathbf Y \bigl(\lambda rc. \mathbf{if}\,(\mathbf{halt}_M c)\, (\mathbf{output}_M c)\, (r(\mathbf{step}_M c))\bigr)

Each encoded machine step takes finitely many reductions. The recursive term returns the encoded output when the simulated machine halts, and continues unfolding when it does not

Thus both models represent the same partial computable functions under effective input and output encodings


© 2024 本网站由 renxiaodaifu 使用 Stellar主题 创建
总访问 次 | 本页访问 次
共发表 103 篇 Blog(s) · 总计 254.1k 字