Functional programming and type systems (2024-2025)
This page supplements the official page of MPRI 2-4.
This course presents the principles, formalisms, and mathematical techniques that underlie many of today's typed programming languages, including OCaml, Haskell, and Rust. Here are some introductory slides.
The course is taught by Pierre-Evariste Dagand (PED), Jacques-Henri Jourdan (JHJ), François Pottier (FP) (head), and Gabriel Scherer (GS).
The content of the course is partly renewed in 2024-2025. In particular, we will teach both syntactic and semantic proofs of type soundness, place more emphasis on logical relations, including logical relations in Iris, and present two distinct algorithmic approaches to type inference.
Didier Rémy's slides and lecture notes, from an earlier version of the course, are still available and can serve as a useful reference.
Location and Schedule
The lectures take place at University of Paris, Bâtiment Sophie Germain, in room 1002.
They are scheduled on Tuesdays from 12:45 to 15:30. There is a 15-minute break in the middle of each lecture, so each lecture lasts 2h30.
Syllabus and Time Table
The syllabus is organized in four main segments of five lectures each.
Operational Semantics, Type Systems, and Program Transformations
- (17/09/2024) Syntax, semantics, and interpreters (FP).
- Introduction to this course (slides 00)
- From operational semantics to interpreters (slides 01, slides without animations 01)
- Machine-checked proofs and de Bruijn syntax in Coq (slides 01b, slides without animations 01b)
- Source files:
- (24/09/2024) System F and a syntactic proof of its type soundness (FP).
- (01/10/2024) Algebraic data types and existential types (FP).
- (08/10/2024) GADTs (FP).
- (15/10/2024) Closure conversion and defunctionalization (FP).
- (22/10/2024) System F with mutable state; the value restriction; type soundness (GS)
- (slides)
Semantic Proofs of Type Soundness and Logical Relations
-
(29/10/2024) Unary logical relations for simple types; (weak) normalisation of simply-typed λ-calculus (GS).
-
(05/11/2024) Unary logical relations for polymorphic types; (weak) normalisation of System F; binary logical relations and parametricity (GS).
- (Same slides).
-
(12/11/2024) The CPS transformation (FP).
A proof of type soundness in Coq (FP).
- definition of simply-typed λ-calculus
- auxiliary lemmas and judgements
- subject reduction and progress: template, solution
-
(19/11/2024) Semantic type soundness for System F with mutable state in Coq/Iris (JHJ).
-
(26/11/2024) break
-
(03/12/2024) mid-term exam, in the usual room and at the usual time, from 12:45 to 15:30, without a break. The duration of the exam is 2h45.
-
(10/12/2024) (Interlude.) Introduction to programming in Rust (JHJ)
- (slides).
Typed Programming
- (17/12/2024) Ad-hoc polymorphism and overloading (handout by D. Rémy, PED).
- (07/01/2025) Applicative functors and monads (PED).
- (14/01/2025) System Fω and modules (PED).
- (21/01/2025) Hindley-Milner type inference and elaboration (PED).
- (28/01/2025) Bidirectional type inference and elaboration (PED).
Programming with Resources in Rust
- (04/02/2025) When the aliasing discipline is too strong (JHJ) (slides).
- (11/02/2025) Practicing Rust.
- (18/02/2025) Metatheory of Rust's type system (JHJ) (slides).
- (25/02/2025) Exercise session (GS).
- (04/03/2025) break
- (11/03/2025) final exam
Evaluation of the course
Two written exams and one programming project are used to evaluate the students.
The mid-term exam will take place on 03/12/2024.
The final exam will take place on 11/03/2025.
The exam takes place in the usual room and at the usual time, from 12:45 to 15:30, without a break. The duration of the exam is 2h45.
Only printed course notes and hand-written notes are allowed during the mid-term and final exams. Electronic devices are not allowed.
Although the course evolves over time, you are encouraged to have a look at the previous exams and their solutions:
- final exam 2023-2024: circuits and functors.
- mid-term exam 2023-2024: fixed point combinators and recursive types.
- final exam 2022-2023: safe unchecked arrays; branded types in Rust.
- mid-term exam 2022-2023: extensible records.
- final exam 2021-2022: type class elaboration.
- mid-term exam 2021-2022: gradual typing.
- intermediate exam 2020-2021: calcul d'objets.
- mid-term exam 2020-2021: delimited control in System F.
- final exam 2019-2020: gradually-typed functional languages.
- mid-term exam 2019-2020: a type system for information flow control.
- final exam 2018-2019: (not available)
- mid-term exam 2018-2019: a simple object encoding.
- final exam 2017-2018: static differentiation.
- mid-term exam 2017-2018: encoding call-by-name into call-by-value; extensible records (Coq solution of part 1).
Programming Project
Programming is an important part of the course. We give a mandatory programming project, which counts for about a third of the final grade.
Research Internship Proposals
We, the teachers of this course, are planning to post a few internship offers at some point during the fall.
Please do not hesitate to talk to us (during the break or at the end of each lecture), to contact us by email, or to visit us at our offices.
So far, the following offers have been posted:
- Our colleague Arthur Charguéraud has posted an offer entitled Optimisation interactive de programmes OCaml via des transformations source-à-source.
To find internships related to the topics of this course, you may wish to also contact our colleagues:
- The Cambium team at Inria Paris. Keywords: program verification in separation logic (Iris; Osiris), programming language design and implementation (OCaml), proof assistants (Coq; MetaCoq), type systems, verified compilation, and more.
- The PPS lab at IRIF, which includes the Picube team. Keywords: programming language design and implementation (OCaml), proof assistants (Coq), semantics, type theory, and more.
- The Prosecco team at Inria Paris. Keywords: verification of security protocols (ProVerif; CryptoVerif; Squirrel), program verification, programming languages for the law (Catala), proof assistants (F*), software security, and more.
- The Antique team at ENS Paris. Keywords: abstract interpretation, program analysis, analysis of biological systems, and more.
- The Parkas team at ENS Paris. Keywords: synchronous programming languages, type systems, verified compilation, and more.
- The Partout team at Inria Saclay. Keywords: connections between computation and deduction, proof theory, type theory, and more.
- The Gallinette team at Inria Nantes. Keywords: formalized mathematics (Mathematical Components), proof assistants (Coq), type theory, and more.
- The Toccata team at Inria Saclay. Keywords: automated deduction, program verification, and more.
- The Epicure team at Inria Rennes. Keywords: automated deduction, program analysis, semantics, software security, verified compilation, and more.
- The Pesto team at Inria Nancy. Keywords: electronic voting, verification of security protocols, verified compilation, and more.
- The Stamp team at Inria Sophia. Keywords: formalized mathematics (Mathematical Components), proof assistants (Coq), verification of security protocols (EasyCrypt), and more.
- The Cash team at ENS Lyon. Keywords: compilation, formalized mathematics (Mathematical Components), program analysis, semantics, type systems, verified compilation, and more.
- The Camus team at Inria Strasbourg. Keywords: compilation, parallelism, program verification, semantics, and more.
We also have contacts abroad, mainly in Europe, North America, and Asia. If you would like to find an internship abroad, do not hesitate to talk to us.
See also the official list of internship offers at MPRI.
Recommended software
Coq
Please install opam first. A recent version is recommended (at the time of writing, 2.1.5). If you have installed it already, skip this step.
Then, install OCaml 4.12.0,
Coq 8.13.2,
and
AutoSubst by executing
this script.
This script does not destroy your existing installation of
OCaml and Coq. It creates a new "switch" named mpri24
and installs
appropriate versions of OCaml, Coq, and AutoSubst in it. You can activate
these versions with the following commands:
ORIGINAL=$(opam switch show)
opam switch mpri24
eval "$(opam config env)"
and return to your original working environment with the following command:
opam switch "$ORIGINAL"
eval "$(opam config env)"
In order to use Coq inside emacs
,
ProofGeneral
is highly recommended.
Here is a suggested
installation script.
If desired, ProofGeneral can be further customized.
Rust
In order to participate to the hands-on exercises on Rust, please install the following tools:
- The Rust compiler (version 1.41 or newer)
- The Cargo package manager (any compatible version)
Installation should be easy on any recent Linux distribution using the system's package manager. An alternative is to follow these instructions.
In order to test the installation, the students are asked to use the Rust compiler on the following program:
fn main() {
let mut f = |x : i32| x;
let _r : &mut dyn Fn(i32) -> i32 = &mut f;
println!("{}", f(42))
}
If the compiler is correctly installed, then the command rustc test.rs
should produce an executable.
Recommended Reading
Types and Programming Languages, Benjamin C. Pierce, MIT Press, 2002.
Advanced Topics in Types and Programming Languages, edited by Benjamin C. Pierce, MIT Press, 2005.
Practical Foundations for Programming Languages, Second Edition, Robert Harper, Cambridge University Press, 2016.