15.08.2013 Views

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

As µML are programs are pairs consisting of declaration lists and an expression, we have a main<br />

function compile that first analyzes the declarations (getting a command sequence and an environment<br />

back from the declaration compiler) and then appends the command sequence, the<br />

compiled expression and the halt command. Note that the expression is compiled with respect to<br />

the environment computed in the compilation of the declarations.<br />

Compiling µML<br />

fun compile ((ds,e) : program) : code =<br />

let<br />

val (cds,env) = compileD(ds, empty, ~1)<br />

in<br />

cds @ compileE(e,env,nil) @ [halt]<br />

end<br />

handle<br />

Unbound i => raise Error("Unbound identifier: " \^ i)<br />

c○: Michael Kohlhase 323<br />

Now that we have seen a couple of models of computation, computing machines, programs, . . . ,<br />

we should pause a moment and see what we have achieved.<br />

Where To Go Now?<br />

We have completed a µML compiler, which generates L(VMP) code from µML programs.<br />

µML is minimal, but Turing-Complete (has conditionals and procedures)<br />

c○: Michael Kohlhase 324<br />

3.4.5 Turing Machines: A theoretical View on Computation<br />

In this subsection, we will present a very important notion in theoretical <strong>Computer</strong> <strong>Science</strong>: The<br />

Turing Machine. It supplies a very simple model of a (hypothetical) computing device that can<br />

be used to understand the limits of computation.<br />

What have we achieved<br />

what have we done? We have sketched<br />

a concrete machine model (combinatory circuits)<br />

a concrete algorithm model (assembler programs)<br />

Evaluation: (is this good?)<br />

how does it compare with SML on a laptop?<br />

Can we compute all (string/numerical) functions in this model?<br />

Can we always prove that our programs do the right thing?<br />

Towards Theoretical <strong>Computer</strong> <strong>Science</strong> (as a tool to answer these)<br />

look at a much simpler (but less concrete) machine model (Turing Machine)<br />

show that TM can [encode/be encoded in] SML, assembler, Java,. . .<br />

Conjecture 477 [Church/Turing] (unprovable, but accepted)<br />

All non-trivial machine models and programming languages are equivalent<br />

183

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!