From PLSwiki

Jump to: navigation, search


Advanced Models and Programs, part 2 (SMP2), Spring 2007 (course code: SASP F2007)

This is the course page for Advanced Models and Programs.


  • Anders 2007-04-13: We have moved the lectures from room 3A18 to 3A14.
  • Peter 2007-04-12: Now there is more information about exams and projects at the bottom of the page.
  • Peter 2007-03-28: Note that projects must be handed in no later than 1500 Wednesday 23 May. That is, you have four weeks (half time) to do them.
  • MAEL 2007-03-12: Please send questions about assignments, etc to the mailing-list for the course: Apparently, there is no news-group for the course.

Practical and administrative matters

  • Lectures: Monday 9 ct (+15 minutes) -12 (Room 3A14), Wednesday 13-15 (Room 3A 14).
  • Exercise labs: Wednesday 15-17 (Room 3A 50).
  • The course period is 16 weeks half time (15 ects). The course will consist of four blocks of three weeks each, covering four themes, with weekly lectures and exercises; and a substantial four-week group project within one of the themes, resulting in a project report.
  • The weekly exercises must be handed in, and at least 9 of the 11 exercises must be approved to pass the course. You are allowed to work in groups to solve the exercises, but each individual student must write his/her solution up individually and hand it in by him/herself. The project must be done in groups (2-4 persons in each group) and the project report must be presented in an oral exam, where questions may be asked in all themes of the course.

Topics and plan

  • The four themes of the course are:
    • Programming language design
    • Static checking
    • Real and abstract machines
    • Generative Programming, models.

Week Date Teacher Topic Materials Assignments
05 Mon 29 Jan No lecture
05 Wed 31 Jan CS Values, Expressions, and Types Chapter 2,3 (Harper [1]] )


Assignment 1

06 Mon 05 Feb CS Functions and Tuples Chapter 4,5 (Harper [2] )


06 Wed 07 Feb CS Case Analysis and Recursive Functions Chapter 6,7 (Harper [3] )

A note on induction

Assignment 1 due, Assignment 2

Correction: The type of the sorting function is int list -> int list.

07 Mon 12 Feb CS Datatypes Chapter 9, 10 (Harper [4] )


07 Wed 14 Feb CS Higher-order Functions Chapters 11 (Harper [5])


Assignment 2 due, Assignment 3


08 Mon 19 Feb LB Polymorphic Type Inference Chapter 2 of Pitts' notes: [6]
08 Wed 21 Feb LB Polymorphic Type Inference Chapter 2 of Pitts' notes: [7] Assignment 3 due, Assignment 4
09 Mon 26 Feb LB Polymorphic Type Inference Implementing type inference in C# [8]
09 Wed 28 Feb MAEL Spec# The Spec# programming system: An overview. Mike Barnett, K. Rustan M. Leino, and Wolfram Schulte. Slides. Assignment 4 due, Assignment 5
10 Mon 05 Mar MAEL Spec# The Spec# programming system: An overview. Mike Barnett, K. Rustan M. Leino, and Wolfram Schulte. Slides. Examples: PosNum.ssc, PreIntArg.ssc, MyCalc.ssc.
10 Wed 07 Mar MAEL Spec# Checking Java programs via guarded commands. Leino et al. Slides. Example: Stack.ssc. Assignment 5 due, Assignment 6: see last page of Slides.
11 Mon 12 Mar PS Abstract syntax, interpretation and checking; lexing and parsing Mogensen pages 13-34 and 63-76. Sestoft PLC chapters 1-3
11 Wed 14 Mar PS Compilation and stack machines Slides. Coco/R User Manual pages 1-17, 23-29. Sestoft PLC chapters 1-3 and 7.2. Assignment 6 due. Assignment 7.
12 Mon 19 Mar PS Micro-C and pointers Slides Kernighan and Ritchie chapter 5. Sestoft PLC chapters 6-7
12 Wed 21 Mar PS Bytecode, abstract machines, and real machines Slides. Sestoft PLC chapters 10-11. Sestoft: Numeric performance in C, C# and Java. Ecma-335, partition I, section 12.3. Richter, chapter 1. Assignment 7 due. Assignment 8.
13 Mon 26 Mar PS Scheme and multi-stage programs Slides. Dybvig sections 2.1-2.7, 6.1. Sestoft PLC chapter 14
13 Wed 28 Mar PS Runtime code generation in .NET Slides. Sestoft PLC chapter 14 Assignment 8 due. Assignment 9.
14 Mon 02 Apr Easter holiday
14 Wed 04 Apr Easter holiday
15 Mon 09 Apr Easter holiday
15 Wed 11 Apr AH Introduction to Model-Driven Development Mandatory reading: "Model-driven development: The good, the bad, and the ugly" by Hailpern and Tarr from IBM Systems Journal, Volume 45, Number 3, 2006 (
Optional reading: Tutorial: Generating an EMF Model
Assignment 9 due. Assignment 10 (Last page of the Slides).
16 Mon 16 Apr AH Eclipse Modeling Framework Mandatory reading: "Eclipse Modeling Framework", ch. 2 by Budinsky et al. (
Optional reading: The Eclipse Modeling Framework (EMF) Overview
16 Wed 18 Apr AH Framework-Specific Modeling Languages Mandatory reading: "Framework-Specific Modeling Languages with Round-Trip Engineering" by Antkiewicz and Czarnecki, proceedings of MoDELS 2006 (
Optional reading: JET Tutorial Part 1 (Introduction to JET), Notes on Eclipse plugins
Assignment 10 due. Assignment 11 (Last page of the Slides. Also, take a look at this demo and the exercise-project).
17 Mon 23 Apr AH Object Constraint Language Mandatory reading: "The Object Constraint Language, 2nd ed.: Getting Your Models Ready for MDA" (ch. 1+2) by Kleppe and Warmer, Addison Wesley 2003 (password protected)
Optional reading: The OCL 2.0 Specification (
17 Wed 25 Apr AH Guided Development with Multiple DSLs (SmartEMF) Mandatory reading: "Guided Development with Multiple Domain-Specific Languages" by Hessellund, Czarnecki, and Wasowski, (unpublished draft)
Optional reading: "Prolog :- Tutorial" by J.R.Fischer
Assignment 11 due.

In weeks 18-21, Mon 30 Apr - Wed 23 May, students work on their project. Projects must be handed in no later than Wednesday 23 May at 1500.

Literature and materials

Course project proposals

The project proposals will be presented in the lecture Monday 23 April at 1030.

  • Proposed by Carsten Schuermann:
    • Recall the machine language interpreter from class. Write a simple compiler for an expression language in reverse polish notation e ::= n | + | - | * | ^ | / | declare x in e | store x in e | recall x in e into the machine language that we defined in class. Then generate x86 assembler code from the compiled program, which you could run standalone.
  • Proposed by Martin Elsman and Lars Birkedal:
    • In SPEC#, develop specifications (object invariants and pre and post conditions) for a set of container libraries (ported to SPEC# from C#) and verify that the implementation of the libraries satisfy the specifictions. Discuss potential difficulties and problems.
    • Present the intermediate verification language BoogiePL (as used in SPEC#) and develop, on paper, a translation of a simple procedural language with embedded specifications into BoogiePL. Consult the following paper for an introduction to BoogiePL and its use in SPEC#:
      • A Verifying Compiler for a Multi-threaded Object-Oriented Language. K. Rustan M. Leino, and Wolfram Schulte. To appear in the Marktoberdorf Summer School 2006. PDF
    • Read and discuss one of the following papers:
      • Friends Need a Bit More: Maintaining Invariants Over Shared State. Mike Barnett and David A. Naumann. In MPC 2004. A methodology for relaxing the ownership system in Spec#. PDF
      The project report should give a summary of the paper and discuss examples illustrating the approach.
  • Proposed by Peter Sestoft:
    • Slides used when presenting the projects
    • Write a generator of specialized XML serialization/deserialization methods in C#. For instance, if S is a struct type with a field i of type int and a field d of type double, then a serialization method generated for S should simply read the fields of the struct value and output them appropriately; no reflection or tests should be performed at serialization time. Extra challenge: Do this using runtime code generation.
    • Change the MicroC compiler to generate x86 code in the form of input for the NASM assembler.
    • Write an interpreter -- in Standard ML, Scheme, Java or C# -- for a substantial subset of the Icon language. This requires an exploration of continuations, a topic not much addressed in the course. See Sestoft: Programming Language Concepts, chapter 8, and RE Griswold & MT Griswold: Icon Programming Language, 3rd edition, Coriolis Group 2000.
    • Relational analysis of .NET assemblies. See detailed proposal by Sebastien Vaucouleur.
  • Proposed by Anders Hessellund:
    • The OFBiz framework uses a combination of models and custom Java code, customizations, to implement modules. It is currently not possible to check dependencies between models and customizations. The idea in this project is to extract an EMF model (by reverse engineering) from each customization such that dependencies between models and custom Java code can be analyzed.
    • Implement a graphical editor for a domain-specific language from the OFBiz framework using the Eclipse Modeling Framework and the Graphical Modeling Framework (GMF). This tutorial should help you get started with GMF.
    • Implement a model-driven tool that can ease development with Struts, Spring MVC or similar web application frameworks using the openArchitectureWare (oAW) tool suite. This paper introduces the various components of oAW. (requires previous knowledge of the chosen web framework)

Project rules

Students must form groups of size N=2 or N=3 (exceptionally, N=1), choose a project topic, make a 20 line problem description, and make an agreement with a supervisor chosen among the course teachers no later than Monday 30 April. Please start this process early; consider the project proposals on the course webpage for inspiration.

A typical project report would state the problem with necessary background information, analyse the problem, discuss possible solutions, implement one or more solutions, evaluate the solution and any tools or theories used, reflect on the process, and outline known deficiencies as well as interesting next steps that could be taken.

The report can be written in English, Danish, Norvegian or Swedish. As a guideline, the report should be around 10+5N pages for a N-person group, not counting code appendices and similar. But of course the contents matter far more than the length. A short and clear report is much preferable to a long unfocused rambling report. A report with substance, interesting observations and reflection on the topic is much preferable to one with bland restatements of textbook knowledge.

The project report must be handed in at the exam office, in three copies.

Actual projects for May 2007

  • Jesper Schulz (, Ole Berard ( and Frej Laursen Würtz ( Compile MicroC to x86 code. Supervisor: Peter
  • Kenneth Sjøholm ( og Rune Glerup ( Icon implementation. Supervisor: Peter
  • Niels Ebbesen ( Icon implementation. Supervisor: Peter
  • Martin Kjeldsen ( og Frederik Raabye ( Serialisering via runtime kodegenerering. Supervisor: Peter
  • Niels Nørskov (, Steffen Sørensen ( og Kim Nielsen ( Serialisering via runtime kodegenerering. Supervisor: Peter
  • Jesper Adamsen og Mohammad Faisal Gulzar: OFBiz-project. Supervisor: Anders
  • Leif Bochis Madsen og Shokran Ibrahim: OFBiz-project. Supervisor: Anders
  • Anders Reinhardt Hansen og Erik Cederstrand: OFBiz-project. Supervisor: Anders


The official course description says:

  "The project report must be presented in an oral exam, where
  questions may be asked in all themes of the course. A single grade
  is given, based on the project and the oral exam."


  "Ekstern censur, 13-skala, B4: Mundtlig eksamen med skriftlige
   arbejder men uden forberedelsestid ved eksamen."

We allow 15+15N minutes for examination of a group consisting of N students. In the examination, 10+8N minutes are spent presenting and discussing the project work, and 7N minutes are spent asking questions in other areas of the course. The latter questions relate to the problems posed in the 11 mandatory exercises, and the questions are directed to each student individually (not to the project group).


Personal tools