Formal semantics provides rigorous, mathematically precise definitions of programming languages, with which we can argue about program behaviour and program equivalence by formal means; in particular, we can describe and verify our arguments with a proof assistant. There are various approaches to giving formal semantics to programming languages, at different abstraction levels and applying different mathematical machinery: the reason for using the semantics determines which approach to choose. In this paper we investigate some of the approaches that share their roots with traditional relational big-step semantics, such as (a) functional big-step semantics (or, equivalently, a definitional interpreter), (b) pretty-big-step semantics and (c) traditional natural semantics. We compare these approaches with respect to the following criteria: executability of the semantics definition, proof complexity for typical properties (e.g. determinism) and the conciseness of expression equivalence proofs in that approach. We also briefly discuss the complexity of these definitions and the coinductive big-step semantics, which enables reasoning about divergence. To enable the comparison in practice, we present an example language for comparing the semantics: a sequential subset of Core Erlang, a functional programming language, which is used in the intermediate steps of the Erlang/OTP compiler. We have already defined a relational big-step semantics for this language that includes treatment of exceptions and side effects. The aim of this current work is to compare our big-step definition for this language with a variety of other equivalent semantics in different styles from the point of view of testing and verifying code refactorings.
翻译:正式语义为编程语言提供了严格、 数学精确的定义, 我们可以用正式手段来争论程序行为和编程等同; 特别是, 我们可以用一个校对助理来描述和验证我们的论点。 我们用多种方法在不同抽象级别上将正式语义赋予编程语言, 并应用不同的数学机制: 使用语义决定选择哪种方法的原因 。 在本文中, 我们调查了一些与传统关系大步语义分享其根源的方法, 比如 (a) 功能性大步语义( 或等同的定义翻译 ) ; (b) 相当大步语义和(c) 传统自然语义。 我们比较这些方法的方法有以下标准: 语义定义的可执行性、 典型性( 如确定性) 的复杂性以及 表达等同性证据的简洁性。 我们还简要讨论这些定义的复杂性, 以及 催生性大步调语义的语义, 能够解释差异性 。 为了便于在实践中进行比较, 我们用这些语言的边端比, 我们用一个示例语言来比较正态/ 级语言的阶系 。