# Circular expressions: Elimination of static environments

## Abstract

Consider the connection between denotational semantics for a language with **goto** statements and flow diagrams for programs in such a language. The main point of interest is that the denotational semantics uses a recursively defined environment to give the meaning of labels, while a flow diagram merely has a jump to the appropriate program point. A simple reduction called “indirection elimination” strips away the environment from the denotational semantics and extracts an expression with cycles (circular expression) that is very close to the flow diagram of a program. The same idea applies to associating bodies with recursive procedures, or to any construct whose semantics is not wedded to the syntax. Circular expressions are offered as a useful data structure and conceptual device. Expressions with cycles are well defined mathematical objects — their semantics can be given by unfolding them into infinite structures that have been well studied. The practicality of the elimination of environments has been tested by constructing a trial implementation, which serves as the front end of a semantics directed compiler generator. The implementation takes a denotational semantics of a language and constructs a “black box” that maps programs in the language into an intermediate representation. The intermediate representation is a circular expression.

## Keywords

Flow Diagram Intermediate Representation Semantic Rule Denotational Semantic Program Point## References

- adj77.adj: J. A. Goguen, J. W. Thatcher, E. G. Wagner, and J. B. Wright, “Initial algebra semantics and continuous algebras,”
*J. ACM***24**(1), pp. 68–95 (January 1977).Google Scholar - aho79.A. V. Aho and J. D. Ullman, “Universality of data retrieval languages,”
*Sixth Annual ACM Symposium on Principles of Programming Languages*, San Antonio TX, pp. 110–120 (January 1979).Google Scholar - chu41.A. Church,
*The calculi of lambda conversion*, Annals of Math. Studies, No. 6, Princeton University Press, Princeton NJ (1941).Google Scholar - cou76.B. Courcelle and M. Nivat, “Algebraic families of interpretations,”
*17th Annual Symposium on Foundations of Computer Science*, Houston TX, pp. 137–146 (October 1976).Google Scholar - dow80.P. J. Downey, R. Sethi, and R. E. Tarjan, “Variations on the common subexpression problem,”
*J. ACM*, pp. 758–771 (October 1980).Google Scholar - gor79.M. J. C. Gordon,
*The Denotational Description of Programming Languages*, Springer-Verlag, New York NY (1979).Google Scholar - hof79.C. M. Hoffman and M. J. O'Donnell, "An interpreter generator using tree pattern matching," pp. 169–179 in
*Sixth Annual ACM Symposium on Principles of Programming Languages*, San Antonio TX (January 1979).Google Scholar - hue79.G. Huet and J. J. Levy, "Call by need computations in non-ambiguous linear term rewriting systems," Rapport Laboria 359, IRIA (August 1979).Google Scholar
- hy176.M. Hyland, "A syntactic characterization of the equality in some models for the lambda calculus,"
*J. London Math Soc, Second Series***12**(3), pp. 361–370 (February 1976).Google Scholar - joh75.S. C. Johnson, "Yacc — yet another compiler compiler," CSTR 32, Bell Laboratories, Murray Hill NJ (July 1975). See the
*UNIX Programmer's Manual***2**Section 19 (January 1979)Google Scholar - jon80.N. D. Jones (ed), in
*Semantics-Directed Compiler Generation*, Lecture Notes in Computer Science 14, Springer-Verlag, Berlin (1980).Google Scholar - ker78.B. W. Kernighan and D. M. Ritchie,
*The C Programming Language*, Prentice-Hall, Englewood Cliffs NJ (1978).Google Scholar - ker80.B. W. Kernighan, "PIC — A crude graphics language for typesetting," CSTR, Bell Laboratories, Murray Hill NJ (1980).Google Scholar
- lan64.P. J. Landin, "The mechanical evaluation of expressions,"
*Computer J.***6**(4), pp. 308–320 (January 1964).Google Scholar - les75.M. E. Lesk, "Lex — a lexical analyzer generator," CSTR 39, Bell Laboratories, Murray Hill NJ (October 1975). See the version by M. E. Lesk and E. Schmidt in the
*UNIX Programmer's Manual***2**Section 20 (January 1979)Google Scholar - lev76.J.-J. Levy, "An algebraic interpretation of the
*λβκ*-calculus and an application of labelled*λ*-calculus,"*Theoretical Computer Science***2**(1), pp. 97–114 (June 1976).Google Scholar - mcc62.J. McCarthy, "Towards a mathematical science of computation," pp. 21–28 in
*Information Processing 1962*, ed. C. M. Popplewell, North-Holland, Amsterdam (1963).Google Scholar - mil76.R. E. Milne and C. Strachey,
*A Theory of Programming Language Semantics, 2 Vols.*, Chapman and Hall, London, and John Wiley, New York (1976).Google Scholar - mos79a.P. D. Mosses, "sis — semantics implementation system: Reference manual and user guide," DAIMI MD-30, Department of Computer Science, University of Aarhus, Denmark (August 1979).Google Scholar
- mos79b.P. D. Mosses, "sis — semantics implementation system: Tested examples," DAIMI MD-33, Department of Computer Science, University of Aarhus, Denmark (August 1979).Google Scholar
- pac74.G. Pacini, C. Montangero, and F. Turini, "Graph representation and computation rules for typeless recursive languages," pp. 158–169 in
*Automata, Languages and Programming, 2nd Colloquium, Saarbrucken*, Lecture Notes in Computer Science 14, Springer-Verlag, Berlin (1974).Google Scholar - par70.D. M. R. Park, "The Y combinator in Scott's lambda-calculus models," unpublished, University of Warwick (1970).Google Scholar
- ras80.M. Raskovsky, "Compiler generation and denotaional semantics,"
*see*[jon80].Google Scholar - rey77.J. C. Reynolds, "Semantics of the domain of flow diagrams,"
*J. ACM***24**(3), pp. 484–503 (July 1977).Google Scholar - sco71.D. S. Scott, "The lattice of flow diagrams," pp. 311–372 in
*Symposium on Semantics of Algorithmic Languages*, ed. E. Engeler, Lecture Notes in Mathematics 188, Springer-Verlag, Berlin (1971).Google Scholar - sco73.D. S. Scott, "Lattice theoretic models for various type-free calculi," pp. 157–187 in
*Proc. IVth International Congress for Logic, Methodology and the Philosophy of Science, Bucharest*, ed. P. Suppes*et al.*, North-Holland, Amsterdam (1973).Google Scholar - sco76.D. S. Scott, "Data types as lattices,"
*SIAM J. Computing***5**(3), pp. 522–587 (September 1976).Google Scholar - sta79.J. Staples, "A graph-like lambda calculus for which leftmost-outermost reduction is optimal," pp. 440–455 in
*Graph-Grammars and Their Application to Computer Science and Biology*, Lecture Notes in Computer Science 73, Springer-Verlag, Berlin (1979).Google Scholar - sto77.J. E. Stoy,
*Denotational Semantics*, MIT Press, Cambridge MA (1977).Google Scholar - str72.C. Strachey, "Varieties of programming language," pp. 222–233 in
*International Computing Symposium*, Cini Foundation, Venice (April 1972).Google Scholar - sts80.B. Stroustrup, "Classes: An abstract data type facility for the C language," CSTR 84, Bell Laboratories, Murray Hill NJ (April 1980).Google Scholar
- ten76.R. D. Tennent, "The denotational semantics of programming languages,"
*Comm. ACM***19**(8), pp. 437–453 (August 1976).Google Scholar - wad76.C. P. Wadsworth, "The relation between computational and denotational properties for Scott's D
_{∞}-models of the lambda calculus,"*SIAM J. Computing***5**(3), pp. 488–521 (September 1976).Google Scholar - wad78.C. P. Wadsworth, "Approximate reductions and lambda calculus models,"
*SIAM J. Computing***7**(3), pp. 337–356 (August 1978).Google Scholar - wan80.M. Wand, "Deriving target code as a representation of continuation semantics," TR 94, Computer Science Department, Indiana University, Bloomington IN (July 1980).Google Scholar
- wel75.P. H. Welch, "Continuous semantics and inside-out reductions," pp. 122–146 in
*λ-calculus and Computer Science Theory*, Lecture Notes in Computer Science 37, Springer-Verlag, Berlin (1975).Google Scholar