Functional Program Correctness Through Types
Doktorsavhandling, 2007

This thesis addresses the problem of avoiding errors in functional programs. The thesis has three parts, discussing different aspects of program correctness, with the unifying theme that types are an integral part of the methods used to establish correctness. The first part validates a common, but not obviously correct, method for reasoning about functional programs. In this method, dubbed "fast and loose reasoning", programs written in a language with non-terminating functions are treated as if they were written in a total language. It is shown that fast and loose reasoning is sound when the programs are written in a given total subset of the language, and the resulting properties are translated back to the partial setting using certain partial equivalence relations which capture the concept of totality. The second part discusses a method for ensuring that functions meet specified time bounds. The method is aimed at implementations of purely functional data structures, which often make essential use of lazy evaluation to ensure good time complexity in the presence of persistence. The associated complexity analyses are often complicated and hence error-prone, but by annotating the type of every function with its time complexity, using an annotated monad to combine time complexities of subexpressions, it is ensured that no details are forgotten. The last part of the thesis is a case study in programming with strong invariants enforced by the type system. A dependently typed object language is represented in the meta language, which is also dependently typed, in such a way that it is impossible to form ill-typed terms. An interpreter is then implemented for the object language by using normalisation by evaluation. By virtue of the strong types used this implementation is a proof that every term has a normal form, and hence normalisation is proved. This also seems to be the first formal account of normalisation by evaluation for a dependently typed language.

well-typed syntax

normalisation by evaluation

program correctness

total languages

partial languages

lazy evaluation

time complexity

strong invariants

dependent types

Lecture room EF, ED&IT building, Rännvägen 6B, Chalmers
Opponent: Professor Martin Hofmann, Institut für Informatik, Ludwig-Maximilians-Universität München, Germany


Nils Anders Danielsson

Chalmers, Data- och informationsteknik, Datavetenskap

A Formalisation of a Dependently Typed Language as an Inductive-Recursive Family

Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics),; Vol. LNCS 4502(2007)p. 93-109

Paper i proceeding

Lightweight Semiformal Time Complexity Analysis for Purely Functional Data Structures

35th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL'08; San Francisco, CA; United States; 7 January 2008 through 12 January 2008,; (2008)p. 133-144

Paper i proceeding

Fast and Loose Reasoning is Morally Correct

Conference record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages (POPL 2006),; (2006)p. 206-217

Paper i proceeding


Datavetenskap (datalogi)



Doktorsavhandlingar vid Chalmers tekniska högskola. Ny serie: 2715

Technical report D - Department of Computer Science and Engineering, Chalmers University of Technology and Göteborg University: 37

Lecture room EF, ED&IT building, Rännvägen 6B, Chalmers

Opponent: Professor Martin Hofmann, Institut für Informatik, Ludwig-Maximilians-Universität München, Germany

Mer information