当前位置: X-MOL 学术arXiv.cs.SC › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
From Big-Step to Small-Step Semantics and Back with Interpreter Specialisation
arXiv - CS - Symbolic Computation Pub Date : 2020-08-07 , DOI: arxiv-2008.02931
John P. Gallagher (Roskilde University, Denmark and IMDEA Software Institute, Spain), Manuel Hermenegildo (IMDEA Software Institute, Spain), Bishoksan Kafle (IMDEA Software Institute, Spain), Maximiliano Klemen (IMDEA Software Institute, Spain), Pedro L\'opez Garc\'ia (IMDEA Software Institute, Spain), Jos\'e Morales (IMDEA Software Institute, Spain)

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.

中文翻译:

从大步语义到小步语义,然后返回翻译专业化

我们研究将命令式程序表示为受约束的 Horn 子句。从操作语义转换规则开始,我们将解释器编写为直接编码规则的受约束 Horn 子句程序。然后,我们针对给定的源程序专门设计一个解释器,以实现将源语言编译为 Horn 子句(第一个 Futamura 投影的实例)。该过程针对 C 子集的解释器进行了详细描述,直接编码 C 的大步操作语义的规则。可以执行基于小步语义的类似翻译,但我们展示了一种获得使用线性解释器对大步霍恩子句进行小步表示。该翻译器再次专门用于实现从大步到小步的翻译。可以使用第三个解释器将线性小步程序转换回大步非线性程序。使用 Tarjan 算法为线性程序计算正则路径表达式,然后该正则表达式指导解释器计算程序路径。这种转换是通过路径解释器的专业化来实现的。在所有转换阶段,我们使用已建立的部分评估器并利用标准逻辑程序转换来删除谓词中的冗余数据结构和参数,并重命名谓词以明确它们与原始源程序中的语句的链接。然后这个正则表达式引导解释器计算程序路径。这种转换是通过路径解释器的专业化来实现的。在所有转换阶段,我们使用已建立的部分评估器并利用标准逻辑程序转换来删除谓词中的冗余数据结构和参数,并重命名谓词以明确它们与原始源程序中的语句的链接。然后这个正则表达式引导解释器计算程序路径。这种转换是通过路径解释器的专业化来实现的。在所有转换阶段,我们使用已建立的部分评估器并利用标准逻辑程序转换来删除谓词中的冗余数据结构和参数,并重命名谓词以明确它们与原始源程序中的语句的链接。
更新日期:2020-08-10
down
wechat
bug