论文标题

从大步到小步骤语义,再到口译专业

From Big-Step to Small-Step Semantics and Back with Interpreter Specialisation

论文作者

Gallagher, John P., Hermenegildo, Manuel, Kafle, Bishoksan, Klemen, Maximiliano, García, Pedro López, Morales, José

论文摘要

我们将命令计划的表示形式作为约束的喇叭条款。从操作语义过渡规则开始,我们通过将口译员写入直接编码规则的受约束角子句程序来进行。然后,我们专门针对给定源程序的解释器来实现源语言与Horn Renauses的汇编(第一个Futamura投影的实例)。可以为C的一部分C详细描述该过程,直接编码C的大型操作语义规则。可以进行基于小步骤语义的类似翻译,但是我们展示了一种使用线性解释器来获得大型角等级的线性解释来获得小步骤表示的方法。该口译员再次专门实现从大步到小步骤的翻译。线性小步程序可以使用第三个解释器转换回大型非线性程序。使用Tarjan的算法计算线性程序的常规路径表达式,然后该正则表达式指导解释器计算程序路径。 通道解释器的专业化实现了转换。在所有转换阶段中,我们都使用既定的部分评估器并利用标准逻辑程序转换来删除谓词和重命名谓词中的冗余数据结构和参数,以清楚其与原始源程序中的语句链接。

We investigate representations of imperative programs as constrained Horn clauses. Starting from operational semantics transition rules, we proceed by writing interpreters as constrained Horn clause programs directly encoding the rules. We then specialise an interpreter with respect to a given source program to achieve a compilation of the source language to Horn clauses (an instance of the first Futamura projection). The process is described in detail for an interpreter for a subset of C, directly encoding the rules of big-step operational semantics for C. A similar translation based on small-step semantics could be carried out, but we show an approach to obtaining a small-step representation using a linear interpreter for big-step Horn clauses. This interpreter is again specialised to achieve the translation from big-step to small-step style. The linear small-step program can be transformed back to a big-step non-linear program using a third interpreter. A regular path expression is computed for the linear program using Tarjan's algorithm, and this regular expression then guides an interpreter to compute a program path. The transformation is realised by specialisation of the path interpreter. In all of the transformation phases, we use an established partial evaluator and exploit standard logic program transformation to remove redundant data structures and arguments in predicates and rename predicates to make clear their link to statements in the original source program.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源