Abstract: | In this paper we consider the problem of translating core F#, a typed functional language including mutable variables, into scripting languages
such as JavaScript or Python. In previous work, we abstracted the most significant characteristics of scripting languages in an intermediate language (IL for short), which is an imperative language with definition of names (variables and functions) done in blocks and where a definition of a name does not have to statically precede its use.
We define a big-step operational semantics for core F# and for IL and formalise the translation of F# expressions into IL.
The main contribution of the paper is the proof of correctness of the given translation, which is done by showing that the evaluation of a well-typed F# program converges to a primitive value if and only if the evaluation of its translation into IL converges to the same value. For this proof is crucial the type soundness of core F# which is proved by giving a coinductive formalization of the divergence predicate and proving that well-typed expressions either converge to a value or diverge and so they are never stuck. |