A systematic derivation of the STG machine verified in Coq

  • Authors:
  • Maciej Pirog;Dariusz Biernacki

  • Affiliations:
  • University of Wrocław, Wrocław, Poland;University of Wrocław, Wrocław, Poland

  • Venue:
  • Proceedings of the third ACM Haskell symposium on Haskell
  • Year:
  • 2010

Quantified Score

Hi-index 0.01

Visualization

Abstract

Shared Term Graph (STG) is a lazy functional language used as an intermediate language in the Glasgow Haskell Compiler (GHC). In this article, we present a natural operational semantics for STG and we mechanically derive a lazy abstract machine from this semantics, which turns out to coincide with Peyton-Jones and Salkild's Spineless Tagless G-machine (STG machine) used in GHC. Unlike other constructions of STG-like machines present in the literature, ours is based on a systematic and scalable derivation method (inspired by Danvy et al.'s functional correspondence between evaluators and abstract machines) and it leads to an abstract machine that differs from the original STG machine only in inessential details. In particular, it handles non-trivial update scenarios and partial applications identically as the STG machine. The entire derivation has been formalized in the Coq proof assistant. Thus, in effect, we provide a machine checkable proof of the correctness of the STG machine with respect to the natural semantics.