CS358 : topics in PL theory
CS358 : topics in PL theory
General course information:
This course will present the foundations of programming languages: the lambda calculus -- both its typed and untyped form.
Then it will describe advanced type systems applied to the lambda calculus: polymorphism (System F), recursive types, heap typing, linear types and security types.
Finally, this course will delve deep in the meaning of semantic typing and in reasoning about programs using logical relations.
Students will learn how to formalise languages and why that is important, how to reason about different and complex language constructs through advanced methods. Students will come to know all basic typing constructs as well as several advanced ones as found in many modern languages.
For any question, please contact Marco Patrignani (see mail here).
Piazza and Gradescope links:
Piazza: https://piazza.com/stanford/spring2019/cs358/home
Gradescope: https://www.gradescope.com/courses/47071
Prerequisites and interests:
Interest in formal languages and formal techniques is important.
Having attended cs143, or cs242 (2018 edition) or cs350 will provide a bit of background.
Location and Time Slots:
Time slot:
WF 10:30 - 12:00
Location:
200-219
Office hours:
preferrably friday afternoon 15 - 17, other slots can be opened if need be.
Please drop an email ahead of time if you plan to come.
Evaluation and Grading:
The course has 6 intermediate assignments and a final exam.
Assignments will help a student consolidate the skills necessary to understand this course as well as prepare them for the final exam.
Assignments will be available one week in advance below.
Please check them out before class and report possible elements of confusion.
-Assignment 1 [ .pdf ] due date: April 19th at 12:00
-Assignment 2 [ .pdf ] due date: April 26th at 12:00
-Assignment 3 [ .pdf ] due date: May 3rd at 12:00
-Assignment 4 [ .pdf ] due date: May 14th at 12:00
-Assignment 5 [ .pdf ] due date: May 21th at 12:00
-Assignment 6 [ .pdf ] due date: May 28nd at 12:00
Assignment turn-in must happen through Gradescope (see link above).
Final exam: the final exam is a take-home set of exercises analogous to those presented in the assignments. The exam has to be handed in before June 12th.
- Exam [ .pdf ]. The same collaboration policy as the assignments applies.
Final exam turn-in must happen through Gradescope (see link above).
Grading:
70% assignments
30% final exam
Course materials:
Courses on foundations on PL are widespread, thus there are many textbooks and lecture notes out there.
The instructor recommends the following in order to integrate notes taken during class. Please note that the course will indeed follow Dreyer’s notes and TAPL.
-Derek Dreyer’s lecture notes [ pdf ]
-Benjamin Pierce’s TAPL [ amazon ] (we’ll follow this mostly)
-John Mitchell’s FPL [ amazon ]
High-level Syllabus Outline:
The course is divided in the following parts:
-Part 1: the lambda calculus.
Here we’ll see the untyped and simply-typed lambda calculus, different forms of operational semantics: structural and contextual, church encodings of boolean and naturals, types such as pairs, products, properties such as: progress, preservation, strong normalisation, semantic type soundness
-Part 2: System F
Here we’ll see System F, the polymorphic lambda calculus with universal and existential types, how to encode them in a semantic model of type soundness, how to scale the previous properties to this complex setting
-Part 3: Recursion
Here we’ll see how to extend the language with recursive (or \mu) types, their different forms, the semantic model for (now) possibly-diverging computation in the form of Kripke Logical Relations
-Part 4: Mutable state
Here we’ll extend the language with a state, so a heap with operations for allocation, reading and writing to it, changing the computation from pure to impure, we will study the semantic model for stateful computation
-Part 5: Program equivalence
Here we’ll learn how to formalise and reason about the semantics of programs and how to tell when they behave the same, we will see what properties to encode as equivalences and how to develop a semantic model for program equivalence
-Part 6: Advanced Type Systems
Here we’ll study advanced type systems such as linear types, security types for secure information flow and non-interference, robust-safety typing, multilanguage semantics
Class (and Lectures) Outline:
Please note that this is tentative and precise class contents can vary slightly
April 3rd:
Class introduction, practicalities, exam modes, clarifications
April 5th:
Untyped lambda calculus (ULC): syntax, semantics, big & small steps,
call by name & value, substitutions, examples
Topics: TAPL 5.1, 5.3
Suggested reading: TAPL 1, 2, 3
Whiteboard images: left board [ png ] and right board [ png ]
ULC summary [ .pdf ]
April 10th:
ULC: evaluation contexts, equivalence of contextual and structural semantics
encoding constructs as lambdas
Topics: TAPL 5.1, Derek’s notes on COS
Suggested reading: TAPL 5.2, 5.4, 6
Whiteboard images: left board [ png ] and right board [ png ]
April 12th:
COS examples and proof that COS and SOS are equivalent (parts)
Topics: notes
Whiteboard images: left board [ png ] and right board [ png ] and other [ png ]
April 17th:
Simply-typed lambda calculus (STLC): judgements, typing rules, pairs
Topics: TAPL 9.1, 9.2, 11.6
Suggested reading: TAPL 8
Whiteboard images: left board [ png ] and right board [ png ] and other [ png ]
April 19th:
STLC: products, encoding if-then-else, properties of typed programs: progress
Topics: TAPL 11.9, 9.3
Whiteboard images: left board [ png ] and right board [ png ] and other [ png ]
April 24th:
STLC: preservation, strong normalisation, logical relation for STLC
Topics: Derek’s notes section 1
Whiteboard images: left board [ png ] and right board [ png ]
April 26th:
Normalisation and semantic typing for STLC, compatibility lemmas.
Topics: Derek’s notes section 1
Whiteboard images: left board [ png ] and right board [ png ] and other [ png ]
May 1st:
Compatibility lemma for app, System F, universal types: syntax, semantics,
typing, examples
Topics: , Derek’s notes section 2, TAPL 23
Whiteboard images: left board [ png ] and right board [ png ]
May 3rd:
Existential types, records, semantic model, new compatibility lemmas
Topics: TAPL 24, Derek’s notes section 2
Suggested reading: TAPL 11.8
Whiteboard images: left board [ png ] and right board [ png ]
May 8th:
Semantic model for F, new compatibility lemmas, (some) free theorems
Topics: Derek’s notes section 2.5, This paper (sections 1, 2, 3).
Whiteboard images: left board [ png ] and right board [ png ] and other [ png ]
May 10th:
Free theorems, Assertions, type safety despite untypability
Topics: Derek’s notes section 2.3, 2.5
Whiteboard images: left board [ png ] and right board [ png ] and other [ png ]
May 15th:
Using the value relation for existentials, Mu types, iso and equi recursive types
Topics: Derek’s notes section 2.5, 3. TAPL 20
Whiteboard images: left board [ png ] and right board [ png ]
May 17th:
Semantic model, step-indexing
Topics: Derek’s notes section 3, 4
Whiteboard images: left board [ png ] and right board [ png ]
May 22nd:
References, their usage and typing, LR with references, side effects, Kripke worlds
Topics: Derek’s notes section 4
Whiteboard images: left board [ png ] and right board [ png ]
Further reading on LR for higher-order heap: this paper
May 24th:
Contextual equivalence, program contexts
Topics: Derek’s notes section 5 + This paper section 3.
Whiteboard images: left board [ png ] and right board [ png ]
May 29th:
Binary logical relation, representation independence
Topics: This paper, section 3, A
Suggested reading on parametricity: This paper section 2.1.
Whiteboard images: left board [ png ] and right board [ png ]
May 31st:
Advanced type system: information flow
Topics: Chapter 3 of this thesis
Whiteboard images: left board [ png ] and right board [ png ]
June 5th:
Advanced type system: Lambda-seal, robust safety, Hyperproperties (hints)
Topics: This paper. Sections 3.1 and 5 from this paper
Whiteboard images: left board [ png ] and right board [ png ]
Instructors: Marco Patrignani and John Mitchell