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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.3 Computing with Functions over Inductively Defined Sets<br />

2.3.1 Standard ML: Functions as First-Class Objects<br />

Enough theory, let us start computing with functions<br />

We will use Standard ML for now<br />

c○: Michael Kohlhase 58<br />

We will use the language SML for the course. This has three reasons<br />

• The mathematical foundations of the computational model of SML is very simple: it consists<br />

of functions, which we have already studied. You will be exposed to an imperative<br />

programming language (C) in the lab and later in the course.<br />

• We call programming languages where procedures can be fully described in terms of their<br />

input/output behavior functional.<br />

• As a functional programming language, SML introduces two very important concepts in a<br />

very clean way: typing and recursion.<br />

• Finally, SML has a very useful secondary virtue for a course at Jacobs University, where students<br />

come from very different backgrounds: it provides a (relatively) level playing ground,<br />

since it is unfamiliar to all students.<br />

<strong>General</strong>ly, when choosing a programming language for a computer science course, there is the<br />

choice between languages that are used in industrial practice (C, C++, Java, FORTRAN, COBOL,. . . )<br />

and languages that introduce the underlying concepts in a clean way. While the first category have<br />

the advantage of conveying important practical skills to the students, we will follow the motto<br />

“No, let’s think” for this course and choose ML for its clarity and rigor. In our experience, if the<br />

concepts are clear, adapting the particular syntax of a industrial programming language is not<br />

that difficult.<br />

Historical Remark: The name ML comes from the phrase “Meta Language”: ML was developed as<br />

the scripting language for a tactical theorem prover 3 — a program that can construct mathematical<br />

proofs automatically via “tactics” (little proof-constructing programs). The idea behind this is the<br />

following: ML has a very powerful type system, which is expressive enough to fully describe proof<br />

data structures. Furthermore, the ML compiler type-checks all ML programs and thus guarantees<br />

that if an ML expression has the type A → B, then it implements a function from objects of<br />

type A to objects of type B. In particular, the theorem prover only admitted tactics, if they were<br />

type-checked with type P → P, where P is the type of proof data structures. Thus, using ML as<br />

a meta-language guaranteed that theorem prover could only construct valid proofs.<br />

The type system of ML turned out to be so convenient (it catches many programming errors<br />

before you even run the program) that ML has long transcended its beginnings as a scripting<br />

language for theorem provers, and has developed into a paradigmatic example for functional<br />

programming languages.<br />

Standard ML (SML)<br />

Why this programming language?<br />

Important programming paradigm (Functional Programming (with static typing))<br />

because all of you are unfamiliar with it (level playing ground)<br />

3 The “Edinburgh LCF” system<br />

33

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

Saved successfully!

Ooh no, something went wrong!