More on advice on structuring compilers and proving them correct

https://doi.org/10.1016/0304-3975(81)90080-3Get rights and content
Under an Elsevier user license
open archive

Abstract

Following Lockwood Morris, a method for algebraically structuring a compiler and proving it correct is described. An example language with block structure and side-effects is presented. This determines an initial many-sorted algebra L which is the ‘abstract syntax’ of the example language. Then the semantics of L is completely determined by describing a semantic algebra M ‘similar’ to L. In particular, initiality of L ensures that there is a unique homomorphism Lsem:L→>M. This is algebraically structuring the semantic definition of the language.

A category of flow-charts over a stack machine is used as a target language for the purposes of compilation. The semantics of the flow charts (Tsem:TS) is also algebraically determined given interpretations of the primitive operations on the stack and store. The homomorphism comp:LT is the compiler which is also uniquely determined by presenting an algebra T of flowcharts similar to L. This is algebraically structuring the compiler.

Finally a function encode:MS describes source meanings in terms of target meanings. The proof that the compiler is correct reduces to a proof that encode:MS is a homomorphism; then both comp ∘ Tsem and Lsem ∘ encode are homomorphisms from L to S and they must be equal because there is only one homomorphism from L to S.

Cited by (0)

An earlier version of this paper appears in Proceedings, Sixth International Colloquium on Automata, Languages and Programming, Graz, Austria, July, 1979, pp. 596–615. Another version will appear in Proceedings, Workshop on Semantics Directed Compiler Generation, Aarhus University, Aarhus, Denmark.