The dynamic semantics of Olaf/Ola was described using small-step operational semantics. Syntactic Type Safety is the idea that we can use how the program executes to determine if the langauage’s type-system is safe. That is, we know the type system is correct if execution will eventually result in a value. When reasoning mechanically about a language’s type system we must prove both:
- progress
- program execution will eventually result in a value, and not get stuck;
- preservation
- as a program reduces to values, the type of the expression, statement, method does not change;
If you have read PLFA before then you will have seen, or will see, a really neat use of dependent types to encode the operational semantics and proof progress and preservation.
An alternate approach is to use Definitional Interpreters, in which we describe the evaluation of our language at the value-level and map constant terms and core operations within Idris. We* will be using intrinsically-typed definitional interpreters where intrinsically-typed terms are input and intrinsically-typed values are the output. Meaning that as the type of the output value is the same as the input expression, we know that typing has been preserved. As as we are purely returning a value, we also know that evaluation will make progress towards a value.
A further benefit of the definitional interpreter approach is that we can accommodate side-effecting operations such as printing, and in future other operations with the outside world i.e. file IO.