betaFeedback

WorksComputer Science

Denotational Results in Compiler Correctness and Comparisons with Operational Approaches

Abstract

Anyone setting out to prove a compiler correct must choose a style of semantics. The CakeML and CompCert projects, among others, show that operational semantics such as abstract machines and interpreters are viable choices. In this paper we explore whether denotational semantics can also be used in proofs of compiler correctness and evaluate the tradeoffs. We focus on a compiler from FPC, a language with lexically scoped functions and recursive types, to a first-order low-level intermediate language. This compiler includes closure conversion, but no prior proof of correctness with respect to denotational semantics covers closure conversion for a Turing-complete language. Compiler correctness requires that the denotation of a program be both preserved and reflected by the compiler. For closure conversion, reflection is the hard direction. We present the first denotational proofs of semantic reflection for closure conversion applied to a Turing-complete language, one proof with respect to a graph model and one with respect to Scott domains. For the graph-model proof we develop a new logical relation, the approximant logical relation, and for the Scott-domain proof we adapt a logical relation of Reynolds. As a first step in evaluating the tradeoffs, we compare mechanized correctness proofs of an eight-pass compiler, from FPC down to a typed low-level intermediate language, in five semantic styles. Two of the styles are denotational and three are operational. We find that no one semantics yields the shortest proofs for every compiler pass. We identify two factors that influence proof size. For operational semantics, proof size tends to grow with how much the runs of the source and target differ. For denotational semantics, the proofs are succinct when the correctness of a pass is an equation between meanings, and lengthy when a pass needs a logical relation.

Introduction

This paper furthers our understanding of how the choice of language semantics impacts proofs of compiler correctness and delivers two novel denotational proofs of correctness for closure conversion. But before explaining our results, let us review the state of the art. Thanks to major compiler verification projects such as CompCert [41] and CakeML [38, 58] we have a fairly good understanding of the use of operational semantics in proofs of compiler correctness. CompCert employs small-step semantics and relates them using simulations [42]. CakeML uses interpreters and reasons about them using induction on evaluation and value relations. Both proofs were large undertakings. The proof of CompCert is 100,000 lines of Coq and took 6 person-years, and the proof of the CakeML compiler backend is about 100,000 lines of HOL4 [84], by six people over two years [54]. In contrast, the literature is less complete when it comes to the use of denotational semantics in compiler correctness proofs, but there is evidence that denotational semantics can yield simpler proofs due to equational and compositional reasoning [50, 83, 93]. This paper fills a fundamental gap in the literature, establishing the first proofs of correctness with respect to denotational semantics for a compiler from a Turing-complete, higher-order language to a first-order language. Why is there such a fundamental gap in the literature? We suspect two reasons: (1) the denotational semantics for Turing-complete languages are more complex than those for strongly-normalizing languages, and (2) compilers for higher-order languages that target a first-order language must go through closure conversion, which involves a change of representation, and that is more challenging to reason about in denotational semantics. Recall that closure conversion replaces each function with a pair of code and the values of its free variables, and replaces each function call with code that takes the pair apart [13, 81] and calls its first component with the second component as an extra argument.

To date, every proof of compiler correctness with respect to a denotational semantics stops short of closure conversion for a Turing-complete language, in several different ways. Nielsen [ [57] proved that defunctionalization, a close cousin of closure conversion, preserves the denotations of programs. However, compiler correctness requires that the denotation of programs is also reflected. Otherwise a compiler could translate a diverging source program into a converging target. Nielsen [ [57] says “Eventually, we want to prove full correctness, i.e., semantic equivalence of the two programs.” Banerjee et al. [ [5] proved both directions, but gave an operational semantics to the source language. They report that they “know of no other proofs of correctness (that is, both directions) for ordinary or CFA-based defunctionalization in the presence of recursion.” Chlipala [ [15] proved correctness of a compiler from the simply typed λ\lambda-calculus (STLC) to assembly, including closure conversion, but the STLC is not Turing-complete, which let him interpret each type as a Coq type and each function as a total Coq function. Other denotational proofs of compiler correctness avoid closure conversion, because either their source language is first-order [14, 68, 91] or their target language is still higher-order [8, 17, 73]. When Chlipala [ [16] proved correct a compiler for a language with general recursion, he switched to operational semantics, explaining that the denotational approach “cannot be applied directly to Turing-complete programming languages.”

A natural setting to study the compilation of higher-order languages is Plotkin’s FPC language [66], a call-by-value λ\lambda-calculus with sums, products, and iso-recursive types. The recursive types of FPC enable the fixed-point combinator, so FPC has general recursion and is Turing-complete. That being said, FPC lacks many of the features of modern programming languages, such as mutable state, exceptions, and multi-threading, to name a few. The claims in this paper are specific to the compilation of FPC. We make no claims about the impact of semantic styles on proofs of correctness for compilers of other programming languages. Our proofs of correctness, like most of those cited above, are for whole programs. They relate the meaning of a closed source program to the meaning of its compiled code. Compositional compiler correctness [61, 82] (Ramanathan et al. 2015), which addresses linking with separately compiled code or code written in another language, is just as important. Cheng et al. [ [14] achieve compositional compiler correctness with a denotational semantics of open modules and a semantic linking operator, for imperative first-order languages, including the front end of CompCert. Extending our denotational proofs to open terms and linking, through closure conversion, would be a good next step.

The compiler for FPC that we study begins with a source optimization pass based on the cp0 pass of Chez Scheme [22, 86], includes three passes for closure conversion, and four back-end passes that target a typed low-level intermediate language that is on the way to x86 assembly. For this compiler we seek to answer three research questions:

RQ1 Can we prove correctness of this compiler with respect to a denotational semantics?

RQ2 How do the sizes of mechanized correctness proofs for this compiler compare across different operational and denotational semantic styles, pass by pass and overall?

RQ3 Which properties of a pass determine the size of its correctness proof in each style?

We answer RQ1 affirmatively, in two denotational models (Theorems 4.1 and 4.2). Our first model is a graph model, in which a program denotes a set of inductively defined graph elements [23, 67, 76]. Each element is a finite description of the program’s behavior, and in particular, the semantics of a function is given by a set of elements that represent input–output entries. To prove semantic reflection for closure conversion we introduce a new kind of relation between denotations, the approximant logical relation. Our key insight is to relate a finite set of target graph elements (a finite approximation) to a possibly infinite source denotation, and to define the relation by recursion on the depth of the elements in the finite set (Lemma 4.6 in § 4.2). Our second model uses Scott domains, in which a program denotes an element of a universal domain of tagged values [78]. There we define the relation by recursion on the stages of the bilimit that constructs the domain (Lemma G.5 in § 4.3), as Reynolds [ [71] did to relate the direct and continuation semantics of an untyped λ\lambda-calculus. Other styles of denotational semantics remain to be evaluated for compiler correctness and closure conversion, among them synthetic domain theory [10, 34, 48, 72], guarded interaction trees [29], categorical semantics [28], the partiality monad [Danielsson 2012], and game semantics [35].

On top of our denotational results for closure conversion, we develop two correctness proofs for the eight-pass compiler from FPC to a typed low-level intermediate language. For seven of the eight passes, correctness is expressed as equality of denotations (Lemma 4.3) and the proofs are by induction on terms and use equational reasoning. The exception is closure conversion, in particular the split closure pass that separates the code of each closure from its environment, whose semantic reflection proof requires the logical relations we discussed above.

To answer RQ2 and RQ3, we compare the two denotational proofs of correctness for our FPC compiler with three more proofs of correctness, each with respect to an operational semantics (Propositions F.1–F.3) and proved using the standard technique for its style: clocked interpreters with relations on values, abstract machines with simulations, and reduction semantics with simulations. We mechanize all five compiler correctness proofs in the Agda proof assistant [2]. Earlier work that compares proofs of compiler correctness focuses on a single phase of a compiler [36, 37, 58]; ours is the first on a whole compiler for a higher-order language. Each of the five correctness results is with respect to a different semantics, so one might wonder if the semantics and therefore the results are equivalent. To check that our mechanized semantics agree, we prove the graph model adequate with respect to the interpreters, the abstract machines, and the reduction semantics, and the Scott-domain semantics adequate with respect to the interpreters (Proposition 5.1), so the five results are equivalent.

No one semantic style gives the smallest proof for every pass (RQ2), but for every pass, the smallest proof is either the graph-model proof or the interpreter proof. Not counting language-independent infrastructure, the interpreters give the smallest proof, at 35,860 lexical tokens of Agda, and the graph model gives the second smallest, at 40,905. The sizes split by the kind of pass (RQ3). The denotational proofs tend to be the smallest for passes that preserve the meaning of a program exactly but change how it runs, such as the source optimizer simplify. The operational proofs are several times smaller for split closure, which changes the representation of closures (§ 6).

§ 2 presents the compiler and § 3 gives background on the graph model. § 4 presents the correctness of each pass wrt. the graph model and the proof for split closure wrt.

Scott domains. § 5 gives the adequacy theorems for the denotational semantics, § 6 compares the five proofs, § 7 discusses related work, and § 8 concludes. Appendix § 15.§ 5 defines the Scott domains. For background on domain theory, we refer the reader to Scott [ [78], Winskel [ [88], and Abramsky and Jung [ [1]. The other appendices define the semantics of every language and compiler pass. Our Agda development is in the supplementary material, which can be accessed using the following link:

https://github.com/cty12/denot-compiler-supplementary

The Compiler and Its Languages

Our compiler translates FPC, the call-by-value λ\lambda-calculus with sums, products, and iso-recursive types of Plotkin [ [66], extended with integers, to Instrμ_\mu, a typed low-level intermediate language, in eight passes through six intermediate languages. Figure 1 shows the sequence of passes and languages. Figure 2 presents the grammars of all the languages and Appendix § 11 gives their typing rules.1 Appendix § 12 lists the full definition of each compiler pass.

The passes of the compiler and the languages between them

Figure 1. The passes of the compiler and the languages between them.

The grammars of the compiler’s languages

Figure 2. The grammars of the compiler’s languages.

Throughout Figure 2, cc ranges over constants, pp over the primitives sub and eq, and fkf_k over the names of a program’s global definitions, where fkf_k refers to the definition dkd_k. In the languages prior to Imp, xx, yy, and zz range over variables. From Imp on, they range over fixed locations in a function’s stack frame. We write binders as one or more names followed by a period, and the scope of the binders is the term after the period. Every language has a graph-model semantics (§ 3), given in full in Appendix § 11.

The source language. FPC has integers, nn-ary tuples, binary sums, the primitives sub and eq, and iso-recursive types. The primitive eq returns inl⁡⟨⟩\operatorname{inl}\langle\rangle for true and inr⁡⟨⟩\operatorname{inr}\langle\rangle for false, so case serves as the conditional. A recursive type μX.A\mu X.A is isomorphic to its unfolding A[μX.A/X]A[\mu X.A/X], and the two coercions of this isomorphism are explicit. The fold operation turns a term of the unfolding into a term of the recursive type, and unfold turns it back:

Γ⊢M:A[μX.A/X]Γ⊢fold⁡M:μX.AΓ⊢M:μX.AΓ⊢unfold⁡M:A[μX.A/X]\begin{aligned} \Gamma\vdash M &: A[\mu X.A/X] \\ \Gamma\vdash\operatorname{fold} M &: \mu X.A \end{aligned} \qquad \begin{aligned} \Gamma\vdash M &: \mu X.A \\ \Gamma\vdash\operatorname{unfold} M &: A[\mu X.A/X] \end{aligned}

Neither coercion does anything at run time. Recursive types make self-application typable, so a program can define the call-by-value fixed-point combinator to write recursive functions.

The optimizer. The first pass, simplify (§C.1), translates from FPC to FPC. It is a simplified version of the optimizer cp0 of Chez Scheme Waddell and Dybvig [ [86]. It propagates known values, folds constants, reduces a case, projection, or unfold of a known value, and inlines small known functions.

Closure conversion. The next three passes perform closure conversion. The enclose pass (§C.2) translates from FPC to EnvClos. It turns each λ\lambda-abstraction into a closure clos⁡(z,y.N) M⃗\operatorname{clos}(z,y.N)\ \vec{M}, which captures the values M⃗\vec{M} of the variables that the code NN uses. The closure binds two variables in its code, the environment zz and the parameter yy, and the code, which has no other free variables, reads the iith captured value as get⁡iz\operatorname{get}_i z.2 The split closure pass (§C.3) then separates a closure into its code and its environment, translating from EnvClos to PairClos. In this target IR, code (z,y.N)(z,y.N) is closed code of type code⁡(Δ;A→C)\operatorname{code}(\Delta; A \to C), which expects an environment of type tup⁡(Δ)\operatorname{tup}(\Delta) and an argument of type AA. The form pair⁡ L M\operatorname{pair}\ L\ M builds a closure, which is a pair of code LL and an environment MM of the same Δ\Delta. Its type, A→CA \to C, hides Δ\Delta, as in the existential type ∃Δ.code⁡(Δ;A→C)×tup⁡(Δ)\exists\Delta.\operatorname{code}(\Delta; A \to C) \times\operatorname{tup}(\Delta) of typed closure conversion Minamide et al. [1996], so closures with different environments have the same type. Thus pair packs the existential, but its dynamic semantics is the usual for a pair. The form call⁡ L M\operatorname{call}\ L\ M calls the code of the closure LL with its environment and the argument MM.

z:tup⁡(Δ), y:A⊢N:CΓ⊢code⁡(z,y.N):code⁡(Δ;A→C)Γ⊢L:code⁡(Δ;A→C)Γ⊢M:tup⁡(Δ)Γ⊢pair⁡ L M:A→CΓ⊢L:A→CΓ⊢M:AΓ⊢call⁡ L M:C\begin{aligned} z &: \operatorname{tup}(\Delta),\ y : A \vdash N : C \\ \Gamma&\vdash\operatorname{code}(z,y.N) : \operatorname{code}(\Delta;A \to C) \end{aligned} \qquad \begin{aligned} \Gamma\vdash L &: \operatorname{code}(\Delta;A \to C) \\ \Gamma\vdash M &: \operatorname{tup}(\Delta) \\ \Gamma&\vdash\operatorname{pair}\ L\ M : A \to C \end{aligned} \qquad \begin{aligned} \Gamma\vdash L &: A \to C \\ \Gamma\vdash M &: A \\ \Gamma&\vdash\operatorname{call}\ L\ M : C \end{aligned}
denotationaloperational
graph modelScott domainsmachinesinterpretersreduction
semantics of the languages9,6026,02610,6017,77315,168
lemmas shared by the passes—3,1862,9712,2892,289
simplify7,0449,39311,88011,33914,589
enclose3,4624,3556,7283,22111,716
split closure8,67215,2111,6507732,534
hoist2,7963,2824,7403,3874,275
remove complex operands2,5803,6083,2442,0184,064
lift locals1,9242,0162,3151,5977,137
explicate control2,1583,8753,0841,9413,084
select instructions2,1533,4283,0671,1443,067
composition514592351378320
total40,90554,97250,63135,86068,243

Table 1. Lexical tokens of Agda in the five correctness proofs. The smallest number in each row is in bold.

Finally, the hoist pass (§C.4) (similar to the hoisting phase of Morrisett et al. [1999]) translates from PairClos to GlobalFun. It turns the code of every function into a global definition dkd_k, and each occurrence of the code into a reference fkf_k to it, so a GlobalFun program is a list of function definitions and a main term.

The back end. The pass remove complex operands (RCO), (§C.5) translates from GlobalFun to MNF, a monadic normal form [32]. It binds each operand that is not atomic to a variable with let, so the operands of every operation in MNF are atomic. The atomic terms are variables, constants, and function names. The lift locals pass (§C.6) translates from MNF to Imp. It gives each variable its own location in the function’s stack frame, called a slot. A function body declares its frame Φ\Phi, which lists the types of its slots. The type system tracks which slots are initialized. The explicate control pass (§C.7) translates from Imp to CFG. It turns the nested cases into a control-flow graph. A CFG program has a function body for each global definition and for the main program. The name of the tail non-terminal is short for tail position. A function body consists of numbered blocks and a starting block, each of which is a tail.

Finally, select instructions (§C.8) translates from CFG to Instrμ_\mu, a typed low-level language in the style of TAL [51], with an x86 flavor. Instrμ_\mu has three registers (rax, rdi, and rsi), a stack frame of slots, and an abstract heap. Programs have the same structure as in CFG. Instruction operands aa are slot numbers, constants, names of function definitions, or registers. Instructions write to a destination dstdst, a register or a slot.

The pass translates each simple expression of CFG into instructions that write its value to a destination, using the registers to stage arithmetic and calls. A closure (pair), a tuple, or an injection becomes the instruction alloc con, dst, which allocates on the heap the result of the constructor concon. A call callc x a of the closure in slot xx on the argument aa becomes the instruction sequence fst x, %rax; snd x, %rdi; movq a, %rsi; callq %rax. The first two instructions load the code and the environment of the closure, the third puts the argument in place, and the call leaves its result in rax. The type system allows only one closure to be open at a time, so that a call never combines the code of one closure with the environment of another. The coercions fold and unfold become annotations on operands, fold a and unfold a, that do nothing.

Instrμ_\mu abstracts from a real instruction set. Its heap is abstract, with no addresses or memory layout, and control flow within a function is acyclic. Neither abstraction concerns closure conversion, because in Instrμ_\mu, as in machine code, a closure is a heap object that pairs a function’s code pointer with a tuple of captured values, and the caller passes the tuple, along with the argument, in argument-passing registers before it calls the code pointer.

Graph Models

A denotational semantics maps each program to a mathematical object that describes its behavior. In a graph model, that object is a set of finite pieces of evidence about the behavior, which we call elements. Our model is a variant of the model of Engeler [ [23], which we extend with constants, pairs, tuples, and disjoint sums. Figure 3 defines elements, several semantic operators on sets of elements, and the semantics of FPC. We first explain how the model represents functions, then introduce the elements, and then the operators. We review how the model handles recursion and divergence, and why we require sets of elements to be consistent. We end this section with the properties of the semantics that our proofs rely on, including a β\beta-law.

!Graph elements, finite lists of elements, denotations, indices, consistency, operators on denotations, and semantics of FPC. Graph elements: u,v,w::=c∣V↦w∣ν∣⟨∣u,v∣⟩∣tup⁡i(v)∣left⁡(v)∣right⁡(v)∣⟨⟩u,v,w ::= c \mid V \mapsto w \mid\nu\mid\langle|u,v|\rangle\mid\operatorname{tup}_i(v) \mid\operatorname{left}(v) \mid\operatorname{right}(v) \mid\langle\rangle. Finite lists of elements: U,V,W∈List⁡(Element⁡)U,V,W \in\operatorname{List}(\operatorname{Element}). Denotations: D,E⊆Element⁡D,E \subseteq\operatorname{Element}. Indices: i,j∈Ni,j \in\mathbb{N}. Consistency: u∼vu \sim v; con⁡(V)⟺u∼v\operatorname{con}(V) \Longleftrightarrow u \sim v for all u,v∈Vu,v \in V. Operators on denotations: op⁡(D1,…,Dn)⊆Element⁡\operatorname{op}(D_1,\ldots,D_n) \subseteq\operatorname{Element}. Λ(F)={V↦w∣V≠[ ],con⁡(V),w∈F(V)}∪{ν}\Lambda(F)=\{V\mapsto w\mid V\ne[\ ],\operatorname{con}(V),w\in F(V)\}\cup\{\nu\}. D∙E={w∣V↦w∈D,V≠[ ],V⊆E}D\mathbin{\bullet}E=\{w\mid V\mapsto w\in D,V\ne[\ ],V\subseteq E\}. pair⁡(D,E)={⟨∣u,v∣⟩∣u∈D,v∈E}\operatorname{pair}(D,E)=\{\langle|u,v|\rangle\mid u\in D,v\in E\}. car⁡(D)={u∣⟨∣u,v∣⟩∈D}\operatorname{car}(D)=\{u\mid\langle|u,v|\rangle\in D\}. cdr⁡(D)={v∣⟨∣u,v∣⟩∈D}\operatorname{cdr}(D)=\{v\mid\langle|u,v|\rangle\in D\}. T(D1,…,Dn)={tup⁡i(v)∣v∈Di}\mathcal{T}(D_1,\ldots,D_n)=\{\operatorname{tup}_i(v)\mid v\in D_i\} if D1,…,Dn≠∅D_1,\ldots,D_n\ne\varnothing, and ∅\varnothing otherwise. inl⁡(D)={left⁡(v)∣v∈D}\operatorname{inl}(D)=\{\operatorname{left}(v)\mid v\in D\}; inr⁡(D)={right⁡(v)∣v∈D}\operatorname{inr}(D)=\{\operatorname{right}(v)\mid v\in D\}. πt(D)={v∣t(v)∈D}\pi_t(D)=\{v\mid t(v)\in D\} for t∈{tup⁡i,left⁡,right⁡}t\in\{\operatorname{tup}_i,\operatorname{left},\operatorname{right}\}. C(D,F,G)={w∣V≠[ ],con⁡(V),left⁡(V)⊆D,w∈F(V)}∪{w∣V≠[ ],con⁡(V),right⁡(V)⊆D,w∈G(V)}C(D,F,G)=\{w\mid V\ne[\ ],\operatorname{con}(V),\operatorname{left}(V)\subseteq D,w\in F(V)\}\cup\{w\mid V\ne[\ ],\operatorname{con}(V),\operatorname{right}(V)\subseteq D,w\in G(V)\}. left⁡(V)={left⁡(v)∣v∈V}\operatorname{left}(V)=\{\operatorname{left}(v)\mid v\in V\}; right⁡(V)={right⁡(v)∣v∈V}\operatorname{right}(V)=\{\operatorname{right}(v)\mid v\in V\}. prim⁡p(D,E)={δ(p,n,m)∣n∈D,m∈E integers}\operatorname{prim}_p(D,E)=\{\delta(p,n,m)\mid n\in D,m\in E\text{ integers}\}. δ(sub⁡,n,m)=n−m\delta(\operatorname{sub},n,m)=n-m; δ(eq⁡,n,m)=left⁡(⟨⟩)\delta(\operatorname{eq},n,m)=\operatorname{left}(\langle\rangle) if n=mn=m, and right⁡(⟨⟩)\operatorname{right}(\langle\rangle) otherwise. Semantics of FPC: ⟦M⟧ρ=D\llbracket M\rrbracket_\rho=D; ⟦x⟧ρ=ρ(x)\llbracket x\rrbracket_\rho=\rho(x); ⟦c⟧ρ={c}\llbracket c\rrbracket_\rho=\{c\}; ⟦λx.N⟧ρ=Λ(λX.⟦N⟧ρ[x:=X])\llbracket\lambda x.N\rrbracket_\rho=\Lambda(\lambda X.\llbracket N\rrbracket_{\rho[x:=X]}); ⟦L M⟧ρ=⟦L⟧ρ∙⟦M⟧ρ\llbracket L\ M\rrbracket_\rho=\llbracket L\rrbracket_\rho\mathbin{\bullet}\llbracket M\rrbracket_\rho; ⟦tuple⁡(M1,…,Mn)⟧ρ=T(⟦M1⟧ρ,…,⟦Mn⟧ρ)\llbracket\operatorname{tuple}(M_1,\ldots,M_n)\rrbracket_\rho=\mathcal{T}(\llbracket M_1\rrbracket_\rho,\ldots,\llbracket M_n\rrbracket_\rho); ⟦get⁡i M⟧ρ=πtup⁡i(⟦M⟧ρ)\llbracket\operatorname{get}_i\ M\rrbracket_\rho=\pi_{\operatorname{tup}_i}(\llbracket M\rrbracket_\rho); ⟦inl⁡ M⟧ρ=inl⁡(⟦M⟧ρ)\llbracket\operatorname{inl}\ M\rrbracket_\rho=\operatorname{inl}(\llbracket M\rrbracket_\rho); ⟦inr⁡ M⟧ρ=inr⁡(⟦M⟧ρ)\llbracket\operatorname{inr}\ M\rrbracket_\rho=\operatorname{inr}(\llbracket M\rrbracket_\rho); ⟦prim⁡p L M⟧ρ=prim⁡p(⟦L⟧ρ,⟦M⟧ρ)\llbracket\operatorname{prim}_p\ L\ M\rrbracket_\rho=\operatorname{prim}_p(\llbracket L\rrbracket_\rho,\llbracket M\rrbracket_\rho); ⟦fold⁡ M⟧ρ=⟦M⟧ρ\llbracket\operatorname{fold}\ M\rrbracket_\rho=\llbracket M\rrbracket_\rho; ⟦let⁡ x=M in⁡ N⟧ρ=Λ(λX.⟦N⟧ρ[x:=X])∙⟦M⟧ρ\llbracket\operatorname{let}\ x=M\ \operatorname{in}\ N\rrbracket_\rho=\Lambda(\lambda X.\llbracket N\rrbracket_{\rho[x:=X]})\mathbin{\bullet}\llbracket M\rrbracket_\rho; ⟦unfold⁡ M⟧ρ=⟦M⟧ρ\llbracket\operatorname{unfold}\ M\rrbracket_\rho=\llbracket M\rrbracket_\rho; ⟦case⁡ L (x.M) (y.N)⟧ρ=C(⟦L⟧ρ,λX.⟦M⟧ρ[x:=X],λY.⟦N⟧ρ[y:=Y])\llbracket\operatorname{case}\ L\ (x.M)\ (y.N)\rrbracket_\rho=C(\llbracket L\rrbracket_\rho,\lambda X.\llbracket M\rrbracket_{\rho[x:=X]},\lambda Y.\llbracket N\rrbracket_{\rho[y:=Y]}) bbox=0.08,0.12,0.92,0.70

Figure 3. The graph model (elements, denotations, and operators) and the semantics of FPC.

References

  1. [1]Samson Abramsky and Achim Jung. 1994. Domain Theory. In Handbook of Logic in Computer Science, S. Abramsky, Dov M. Gabbay, and T. S. E. Maibaum (Eds.). Vol. 3. Clarendon Press, Oxford, 1–168.
  2. [2]The Agda Team. 2026. Agda, a dependently typed functional programming language and proof assistant. https://github.com/agda/agda. Accessed: November 2026.
  3. [3]Amal Ahmed and Matthias Blume. 2008. Typed Closure Conversion Preserves Observational Equivalence. In Proceedings of the 13th ACM SIGPLAN International Conference on Functional Programming (ICFP). 157–168.
  4. [4]Patrick Bahr and Graham Hutton. 2015. Calculating Correct Compilers. Journal of Functional Programming 25 (2015), e14.DOI
  5. [5]Anindya Banerjee, Nevin Heintze, and Jon G. Riecke. 2001. Design and Correctness of Program Transformations Based on Control-Flow Analysis. In Theoretical Aspects of Computer Software (TACS) (Lecture Notes in Computer Science, Vol. 2215). Springer, 420–447.DOI
  6. [6]Henk Barendregt, Mario Coppo, and Mariangiola Dezani-Ciancaglini. 1983. A filter lambda model and the completeness of type assignment. Journal of Symbolic Logic 48, 4 (001 12 1983), 931–940. doi:10.2307/2273659DOI
  7. [7]Nick Benton, Lars Birkedal, Andrew Kennedy, and Carsten Varming. 2010. Formalizing Domains, Ultrametric Spaces and Semantics of Programming Languages. (2010). Manuscript, under consideration for Mathematical Structures in Computer Science.
  8. [8]Nick Benton and Chung-Kil Hur. 2009. Biorthogonality, Step-indexing and Compiler Correctness. In Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming (Edinburgh, Scotland) (ICFP ’09). ACM, New York, NY, USA, 97–108. doi:10.1145/1596550.1596567DOI
  9. [9]Nick Benton, Andrew Kennedy, and Carsten Varming. 2009. Some Domain Theory and Denotational Semantics in Coq. Springer Berlin Heidelberg, Berlin, Heidelberg, 115–130. doi:10.1007/978-3-642-03359-9_10DOI
  10. [10]L. Birkedal, R. E. Møgelberg, J. Schwinghammer, and K. Støvring. 2011. First Steps in Synthetic Guarded Domain Theory: Step-Indexing in the Topos of Trees. In 2011 IEEE 26th Annual Symposium on Logic in Computer Science. 55–64. doi:10. 1109/LICS.2011.16DOI
  11. [11]William J. Bowman and Amal Ahmed. 2018. Typed Closure Conversion for the Calculus of Constructions. In Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). 797–811.DOI
  12. [12]Robert S. Boyer and J Strother Moore. 1984. A Mechanical Proof of the Unsolvability of the Halting Problem. J. ACM 31, 3 (1984), 441–458.DOI
  13. [13]Luca Cardelli. 1984. Compiling a Functional Language. In ACM Symposium on LISP and Functional Programming (Austin, Texas, USA) (LFP ’84). ACM, 208–217.
  14. [14]Zhang Cheng, Jiyang Wu, Di Wang, and Qinxing Cao. 2026. Denotation-based Compositional Compiler Verification. ACM Transactions on Programming Languages and Systems 48, 1 (2026), 1–65. doi:10.1145/3797874DOI
  15. [15]Adam Chlipala. 2007. A certified type-preserving compiler from lambda calculus to assembly language. In PLDI ’07: Proceedings of the 2007 ACM SIGPLAN conference on programming language design and implementation (San Diego, California, USA). ACM Press, 54–65.
  16. [16]Adam Chlipala. 2010. A Verified Compiler for an Impure Functional Language. In Proceedings of the 37th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (Madrid, Spain) (POPL ’10). ACM, New York, NY, USA, 93–106. doi:10.1145/1706299.1706312DOI
  17. [17]William Clinger. 1984. The Scheme 311 Compiler an Exercise in Denotational Semantics. In Proceedings of the 1984 ACM Symposium on LISP and Functional Programming (Austin, Texas, USA) (LFP ’84). ACM, New York, NY, USA, 356–364. doi:10.1145/800055.802052DOI
  18. [19]Zaynah Dargaye. 2009. Vérification formelle d’un compilateur pour langages fonctionnels. Ph. D. Dissertation. Université Paris 7 Diderot.
  19. [20]Tom de Jong. 2023. Domain Theory in Constructive and Predicative Univalent Foundations. Ph. D. Dissertation. University of Birmingham. http://etheses.bham.ac.uk/id/eprint/13401arxiv.org/abs/2301.12405
  20. [22]R. Kent Dybvig. 2006. The Development of Chez Scheme. In Proceedings of the Eleventh ACM SIGPLAN International Conference on Functional Programming (Portland, Oregon, USA) (ICFP ’06). ACM, New York, NY, USA, 1–12. doi:10.1145/1159803.1159805DOI
  21. [23]Erwin Engeler. 1981. Algebras and combinators. Algebra Universalis 13, 1 (01 Dec 1981), 389–392.
  22. [25]Martín H. Escardó and Cory M. Knapp. 2017. Partial Elements and Recursion via Dominances in Univalent Type Theory. In 26th EACSL Annual Conference on Computer Science Logic (CSL 2017) (LIPIcs, Vol. 82). Schloss Dagstuhl–Leibniz-Zentrum für Informatik, 21:1–21:16. doi:10.4230/LIPIcs.CSL.2017.21DOI
  23. [26]Matthias Felleisen and Daniel P. Friedman. 1986. Control operators, the SECD-machine and the lambda-calculus. In Formal Description of Programming Concepts III, Martin Wirsing (Ed.). North-Holland Pub. Co., 193–217.
  24. [27]Andrzej Filinski. 2007. On the Relations between Monadic Semantics. Theoretical Computer Science 375, 1–3 (2007), 41–75.DOI
  25. [28]Marcelo P. Fiore and Gordon D. Plotkin. 1994. An Axiomatisation of Computationally Adequate Domain Theoretic Models of FPC. In Proceedings of the Ninth Annual IEEE Symposium on Logic in Computer Science (LICS). 92–102. doi:10.1109/LICS.1994.316083
  26. [29]Dan Frumin, Amin Timany, and Lars Birkedal. 2024. Modular Denotational Semantics for Effects with Guarded Interaction Trees. Proc. ACM Program. Lang. 8, POPL (2024). doi:10.1145/3632854
  27. [30]Dan R. Ghica and Fabio Zanasi. 2027. String Diagrams for Lambda Calculi and Functional Computation. Cambridge University Press. https://www.cambridge.org/core/elements/string-diagrams-for-lambda-calculi-and-functional-computation/C5E0FC1F93194ADD0F17A7D1FA49E8FB
  28. [32]John Hatcliff and Olivier Danvy. 1994. A generic account of continuation-passing styles. In Proceedings of the 21st ACM SIGPLAN-SIGACT symposium on Principles of programming languages (Portland, Oregon, United States) (POPL ’94). ACM, New York, NY, USA, 458–471. doi:10.1145/174675.178053DOI
  29. [34]J. Martin E. Hyland. 1991. First Steps in Synthetic Domain Theory. In Category Theory (Como 1990) (Lecture Notes in Mathematics, Vol. 1488). Springer, 131–156.DOI
  30. [35]J. M. E. Hyland and C.-H. L. Ong. 2000. On full abstraction for PCF: I, II, and III. Inf. Comput. 163, 2 (2000), 285–408.DOI
  31. [36]David M. Kahn, Jan Hoffmann, and Rumming Li. 2025. Big-Stop Semantics: Small-Step Semantics in a Big-Step Judgment. arXiv:2508.15157arxiv.org/abs/2508.15157
  32. [37]David Knothe and Oliver Bringmann. 2026. Combining Small-Step and Big-Step Semantics to Verify Loop Optimizations. arXiv:2602.19868.arxiv.org/abs/2602.19868
  33. [38]Ramana Kumar, Magnus O. Myreen, Michael Norrish, and Scott Owens. 2014. CakeML: A Verified Implementation of ML. In Principles of Programming Languages (POPL). ACM Press, 179–191. doi:10.1145/2535838.2535841DOI
  34. [39]P. J. Landin. 1966. The next 700 programming languages. Commun. ACM 9, 3 (1966), 157–166.DOI
  35. [40]Kim G. Larsen and Glynn Winskel. 1984. Using Information Systems to Solve Recursive Domain Equations Effectively. In Semantics of Data Types (Lecture Notes in Computer Science, Vol. 173). Springer, 109–129.DOI
  36. [41]Xavier Leroy. 2009. Formal Verification of a Realistic Compiler. Commun. ACM 52, 7 (July 2009), 107–115. doi:10.1145/1538788.1538814DOI
  37. [42]Xavier Leroy, Sandrine Blazy, Daniel Kästner, Bernhard Schommer, Markus Pister, and Christian Ferdinand. 2016. CompCert – A Formally Verified Optimizing Compiler. In Embedded Real Time Software and Systems (ERTS). SEE. https://hal.science/hal-01238879
  38. [43]David MacQueen, Gordon Plotkin, and Ravi Sethi. 1986. An ideal model for recursive polymorphic types. Information and Control 71, 1 (1986), 95–130. doi:10.1016/S0019-9958(86)80019-5DOI
  39. [44]Albert R. Meyer and Mitchell Wand. 1985. Continuation Semantics in Typed Lambda-Calculi (Summary). In Logics of Programs (Lecture Notes in Computer Science, Vol. 193). Springer, 219–224.DOI
  40. [45]Robert Milne and Christopher Strachey. 1976. A Theory of Programming Language Semantics. Chapman and Hall.
  41. [46]Robin Milner. 1978. A Theory of Type Polymorphism in Programming. J. Comput. System Sci. 17, 3 (1978), 348–375.DOI
  42. [48]Rasmus Ejlers Møgelberg and Marco Paviotti. 2016. Denotational Semantics of Recursive Types in Synthetic Guarded Domain Theory. In Proceedings of the 31st Annual ACM/IEEE Symposium on Logic in Computer Science (New York, NY, USA) (LICS ’16). ACM, New York, NY, USA, 317–326. doi:10.1145/2933575.2934516DOI
  43. [49]J. Strother Moore. 1989. A Mechanically Verified Language Implementation. J. Autom. Reason. 5, 4 (Nov. 1989), 461–492. http://dl.acm.org/citation.cfm?id=83471.83477DOI
  44. [50]F. Lockwood Morris. 1973. Advice on Structuring Compilers and Proving Them Correct. In Proceedings of the 1st Annual ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL). 144–152.DOI
  45. [51]Greg Morrissett, David Walker, Karl Crary, and Neal Glew. 1999. From system F to typed assembly language. ACM Trans. Program. Lang. Syst. 21, 3 (May 1999), 527–568. doi:10.1145/319341.319345
  46. [52]Eric Mullen, Stuart Pernsteiner, James R. Wilcox, Zachary Tatlock, and Dan Grossman. 2018. Œuf: Minimizing the Coq Extraction TCB. In Proceedings of the 7th ACM SIGPLAN International Conference on Certified Programs and Proofs (CPP). 172–185.
  47. [53]Ketan Mulmuley. 1987. Full Abstraction and Semantic Equivalence. MIT Press.
  48. [54]Magnus O. Myreen. 2016. A New Verified Compiler Backend for CakeML. Talk at Imperial College London. https://www.cl.cam.ac.uk/~mom22/2016-imperial-talk.pdf Slide “Size, Effort, Speed”.
  49. [55]Georg Neis, Chung-Kil Hur, Jan-Oliver Kaiser, Craig McLaughlin, Derek Dreyer, and Viktor Vafeiadis. 2015. Pilsner: A Compositionally Verified Compiler for a Higher-Order Imperative Language. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming (ICFP). 166–178.
  50. [56]Max S. New. 2017. Closure Conversion as CoYoneda. Blog post, Inside PRL, https://prl.khoury.northeastern.edu/blog/2017/08/28/closure-conversion-as-coyoneda/
  51. [57]Lasse R. Nielsen. 2000. A Denotational Investigation of Defunctionalization. Technical Report RS-00-47. BRICS.DOI
  52. [58]Scott Owens, Magnus O. Myreen, Ramana Kumar, and Yong Kiam Tan. 2016. Functional Big-Step Semantics. In Proceedings of the 25th European Symposium on Programming Languages and Systems - Volume 9632. Springer-Verlag New York, Inc., New York, NY, USA, 589–615. doi:10.1007/978-3-662-49498-1_23DOI
  53. [59]Alberto Pardo, Emmanuel Gunther, Miguel Pagano, and Marcos Viera. 2018. An Internalist Approach to Correct-by-Construction Compilers. In Proceedings of the 20th International Symposium on Principles and Practice of Declarative Programming (PPDP).DOI
  54. [60]Robert E. Park. 1992. Software Size Measurement: A Framework for Counting Source Statements. Technical Report CMU/SEI-92-TR-020. Software Engineering Institute, Carnegie Mellon University.DOI
  55. [61]James T. Perconti and Amal Ahmed. 2014. Verifying an Open Compiler Using Multi-language Semantics. In Programming Languages and Systems, Zhong Shao (Ed.). Lecture Notes in Computer Science, Vol. 8410. Springer Berlin Heidelberg, 128–148. doi:10.1007/978-3-642-54833-8_8DOI
  56. [62]Benjamin C. Pierce. 2002. Types and Programming Languages. MIT Press.
  57. [63]Andrew M. Pitts. 1996. Relational Properties of Domains. Information and Computation 127, 2 (1996), 66 – 90. doi:10.1006/inco.1996.0052DOI
  58. [64]G. Plotkin. 1978. Tω as a Universal Domain. J. Comput. System Sci. 17, 2 (1978), 209 – 236. doi:10.1016/0022-0000(78)90006-5DOI
  59. [65]G. D. Plotkin. 1977. LCF considered as a programming language. Theoretical Computer Science 5, 3 (December 1977), 223–255.DOI
  60. [66]Gordon D. Plotkin. 1985. Lectures on Predomains and Partial Functions. (1985). Lecture notes, Center for the Study of Language and Information, Stanford University.
  61. [67]Gordon D. Plotkin. 1993. Set-theoretical and other elementary models of the λ-calculus. Theoretical Computer Science 121, 1 (1993), 351 – 409.DOI
  62. [68]Wolfgang Polak. 1981. Compiler Specification and Verification. Lecture Notes in Computer Science, Vol. 124. Springer. doi:10.1007/3-540-10886-6DOI
  63. [69]François Potter and Nadji Gauthier. 2006. Polymorphic Typed Defunctionalization and Concretization. Higher-Order and Symbolic Computation 19, 1 (2006).DOI
  64. [71]John C. Reynolds. 1974. On the Relation between Direct and Continuation Semantics. In Automata, Languages and Programming (ICALP) (Lecture Notes in Computer Science, Vol. 14). Springer, 141–156.DOI
  65. [72]Giuseppe Rosolini. 1986. Continuity and Effectiveness in Topoi. Ph. D. Dissertation. University of Oxford.
  66. [73]Ralf Schweimeier and Alan Jeffrey. 1999. A Categorical and Graphical Treatment of Closure Conversion. Electronic Notes in Theoretical Computer Science 20 (1999), 481–511. doi:10.1016/S1571-0661(04)80090-2 Mathematical Foundations of Programming Semantics (MFPS XV).
  67. [74]Helmut Schwichtenberg. 2006. Recursion on the Partial Continuous Functionals. In Logic Colloquium ’05 (Lecture Notes in Logic, Vol. 28). Association for Symbolic Logic, 173–201.
  68. [75]Dana Scott. 1971. Continuous Lattices. Technical Report PRG-7. Oxford University Computing Laboratory.
  69. [76]Dana Scott. 1976. Data Types as Lattices. SIAM J. Comput. 5, 3 (1976), 522–587.
  70. [77]Dana Scott and Christopher Strachey. 1971. Toward a mathematical semantics for computer languages. Technical Report PRG-6. Oxford Programming Research Group.
  71. [78]Dana S. Scott. 1982. Domains for denotational semantics. In Automata, Languages and Programming: Ninth Colloquium Aarhus, Denmark, July 12–16, 1982, Mogens Nielsen and Erik Meineche Schmidt (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 577–610.DOI
  72. [79]Jeremy G. Siek. 2017. Revisiting Elementary Denotational Semantics. CoRR abs/1707.03762, 4 (2017). arXiv:1707.03762 http://arxiv.org/abs/1707.03762
  73. [80]Jeremy G. Siek. 2025. Verified Nanopasses for Compiling Conditionals. In OlivierFest 2025, co-located with ICFP/SPLASH 2025.
  74. [81]Guy L. Steele. 1978. Rabbit: A Compiler for Scheme. Technical Report AI-TR-474. MIT Artificial Intelligence Laboratory, Cambridge, MA, USA.
  75. [82]Gordon Stewart, Lennart Beringer, Santiago Cuellar, and Andrew W. Appel. 2015. Compositional CompCert. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’15). ACM, 275–287. doi:10.1145/2676726.2676985DOI
  76. [83]Joseph E. Stoy. 1977. Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory. MIT Press, Cambridge, MA, USA.
  77. [84]Yong Kiam Tan, Magnus O. Myreen, Ramana Kumar, Anthony Fox, Scott Owens, and Michael Norrish. 2019. The Verified CakeML Compiler Backend. Journal of Functional Programming 29 (2019), e2. doi:10.1017/S0956796818000229DOI
  78. [85]James W. Thatcher, Eric G. Wagner, and Jesse B. Wright. 1981. More on Advice on Structuring Compilers and Proving Them Correct. Theoretical Computer Science 15, 3 (1981), 223–249.
  79. [86]Oscar Waddell and R. Kent Dybvig. 1997. Fast and Effective Procedure Inlining. In Proceedings of the 4th International Symposium on Static Analysis (SAS ’97). Springer-Verlag, London, UK, 35–52.DOI
  80. [87]Mitchell Wand and Paul Steckler. 1994. Selective and Lightweight Closure Conversion. In Proceedings of the 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (Portland, Oregon, USA) (POPL ’94). ACM, New York, NY, USA, 435–445. doi:10.1145/174675.178044DOI
  81. [88]Glynn Winskel. 1993a. The Formal Semantics of Programming Languages: An Introduction. MIT Press.
  82. [89]Glynn Winskel. 1993b. The Formal Semantics of Programming Languages. MIT Press.
  83. [90]Andrew K. Wright and Matthias Felleisen. 1994. A syntactic approach to type soundness. Information and Computation 115, 1 (1994), 38–94.DOI
  84. [91]Li-yao Xia, Nyrki Zakowski, Paul He, Chung-Kil Hur, Gregory Malecha, Benjamin C. Pierce, and Steve Zdancewic. 2019. Interaction Trees: Representing Recursive and Impure Programs in Coq. Proc. ACM Program. Lang. 4, POPL, Article 51 (Dec. 2019), 32 pages. doi:10.1145/3371119
  85. [92]William D. Young. 1989. A Mechanically Verified Code Generator. Journal of Automated Reasoning 5, 4 (1989), 493–518.DOI
  86. [93]Yannick Zakowski, Calvin Beck, Irene Yoon, Jia Ziauchk, Vadim Zaliva, and Steve Zdancewic. 2021. Modular, Compositional, and Executable Formal Semantics for LLVM IR. Proceedings of the ACM on Programming Languages 5, ICFP, Article 67 (2021), 30 pages. doi:10.1145/3473572DOI

Paper details

vlnc:W_kexdx4gw
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents