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

08/07/2020
by   John P. Gallagher, et al.
0

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.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
11/08/2018

A Program Logic for First-Order Encapsulated WebAssembly

WebAssembly (Wasm) is the first new programming language in over 20 year...
research
12/21/2021

A Small-Step Operational Semantics for GP 2

The operational semantics of a programming language is said to be small-...
research
03/08/2018

Semantical Equivalence of the Control Flow Graph and the Program Dependence Graph

The program dependence graph (PDG) represents data and control dependenc...
research
07/25/2012

Redundant Sudoku Rules

The rules of Sudoku are often specified using twenty seven all_different...
research
04/12/2021

A meta-theory for big-step semantics

It is well-known that big-step semantics is not able to distinguish stuc...
research
02/20/2020

Soundness conditions for big-step semantics

We propose a general proof technique to show that a predicate is sound, ...
research
08/16/2018

Compiling Control as Offline Partial Deduction

We present a new approach to a technique known as compiling control, who...

Please sign up or login with your details

Forgot password? Click here to reset