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
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
40CHAPTER 4. COMPUTING WITH FUNCTIONS OVER INDUCTIVELY DEFINED SETS<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 />
clean enough to learn important concepts (e.g. typing and recursion)<br />
SML uses functions as a computational model (we already understand them)<br />
SML has an interpreted runtime system (inspect program state)<br />
Book: SML for the working programmer by Larry Paulson [Pau91]<br />
Web resources: see the post on the course forum in PantaRhei.<br />
Homework: install it, and play with it at home!<br />
©: Michael Kohlhase 61<br />
Disclaimer: We will not give a full introduction to SML in this course, only enough to make the<br />
course self-contained. There are good books on ML and various web resources:<br />
• A book by Bob Harper (CMU) http://www-2.cs.cmu.edu/~rwh/smlbook/<br />
• The Moscow ML home page, one of the ML’s that you can try to install, it also has many<br />
interesting links http://www.dina.dk/~sestoft/mosml.html<br />
• The home page of SML-NJ (SML of New Jersey), the standard ML http://www.smlnj.org/<br />
also has a ML interpreter and links Online Books, Tutorials, Links, FAQ, etc. And of course<br />
you can download SML from there for Unix as well as for Windows.<br />
• A tutorial from Cornell University. It starts with ”Hello world” and covers most of the<br />
material we will need for the course. http://www.cs.cornell.edu/gries/CSCI4900/ML/<br />
gimlFolder/manual.html<br />
• and finally a page on ML by the people who originally invented ML: http://www.lfcs.<br />
inf.ed.ac.uk/software/ML/<br />
One thing that takes getting used to is that SML is an interpreted language. Instead of transforming<br />
the program text into executable code via a process called “compilation” in one go, the SML<br />
interpreter provides a run time environment that can execute well-formed program snippets in a<br />
dialogue with the user. After each command, the state of the run-time systems can be inspected<br />
to judge the effects and test the programs. In our examples we will usually exhibit the input to<br />
the interpreter and the system response in a program block of the form<br />
- input to the interpreter<br />
system response