Tomáš Petříček and Vít Šefl
petricek@d3s.mff.cuni.cz | sefl@ksvi.mff.cuni.cz
@tomasp.net | https://tomasp.net


To pass the course, you need to successfully pass an oral exam at the end.
Test understanding of semantics & types
Practical details and arrangements


The lectures will be recorded. The recordings
will be made available in some way.
If there's interest, we could make a Discord server like we did last year (for Principles) and share the study materials there as well.


Type systems and semantics are deep topics and we'll only scratch the surface.
For example, we won't cover denotational semantics, axiomatic semantics, subtyping, set-theoretic types, gradual typing, etc.
However, the course will give you the
core tools to delve deeper.

The imperative part of the course will mostly
be given by Tomáš; the functional part by Vít.
The current plan for this semester is:




Whatever the interpreter does

English language specification

Mathematical formal definition






// Computing a factorial
// of value in 'l1'. Stores
// the result in 'l2'.
let l1 = ref 5
let l2 = ref 1
while !l1 >= 1 do
l2 := !l2 * !l1
l1 := !l1 + -1
done
Minimal imperative language a bit like subset of ML or F#
No normal variables!
Stores are special
and assumed (no let)
Expression-based
assign, read, if, while, sequencing, operators



Concrete primitives and abstract locations
We treat primitives
as sets and name members as \(b \in \mathbb{B}\),
\(n\in\mathbb{Z}\) and \(l\in\mathbb{L}\)


BNF-like notation,
but think of it as a definition of a set.
\(:=\) defines a set
\(|\) lists options
Keywords are bold
and \(n,b,l,e,op\) are members of other sets




Proceeds step-by-step
Not how real programs run on a computer!
Formal model
Defined by a set of reduction rules



If the preconditions (above) and side conditions (beside) holds, transition applies
Some reductions require a derivation tree with several rules!


\((1+1)+(20+20)\)
Simple enough, but what exact steps?
Evaluation order can matter in subtle ways!
For example C pattern
if (nd && nd->next)
nd->next = NULL;







