24 research outputs found
A Linear First-Order Functional Intermediate Language for Verified Compilers
We present the linear first-order intermediate language IL for verified
compilers. IL is a functional language with calls to a nondeterministic
environment. We give IL terms a second, imperative semantic interpretation and
obtain a register transfer language. For the imperative interpretation we
establish a notion of live variables. Based on live variables, we formulate a
decidable property called coherence ensuring that the functional and the
imperative interpretation of a term coincide. We formulate a register
assignment algorithm for IL and prove its correctness. The algorithm translates
a functional IL program into an equivalent imperative IL program. Correctness
follows from the fact that the algorithm reaches a coherent program after
consistently renaming local variables. We prove that the maximal number of live
variables in the initial program bounds the number of different variables in
the final coherent program. The entire development is formalized in Coq.Comment: Addressed comments from reviewers (ITP 2015): (1) Added discussion of
a paper in related work (2) Added definition of renamed-apart in appendix (3)
Formulation changes in a coupe of place
Integrated Java Bytecode Verification
AbstractExisting Java verifiers perform an iterative data-flow analysis to discover the unambiguous type of values stored on the stack or in registers. Our novel verification algorithm uses abstract interpretation to obtain definition/use information for each register and stack location in the program, which in turn is used to transform the program into Static Single Assignment form. In SSA, verification is reduced to simple type compatibility checking between the definition type of each SSA variable and the type of each of its uses. Inter-adjacent transitions of a value through stack and registers are no longer verified explicitly. This integrated approach is more efficient than traditional bytecode verification but still as safe as strict verification, as overall program correctness can be induced once the data flow from each definition to all associated uses is known to be type-safe
Towards register allocation of SSA-form programs
In this technical report, we present an architecture for
register allocation on the SSA-form. We show, how the properties
of SSA-form programs and their interference graphs can be
exploited to develop new methods for spilling, coloring and
coalescing. We present heuristic and optimal solution methods
for these three subtasks
Recent Developments and Future Directions in Lisp-Stat
1 online resource (PDF, 16 pages
‘do’ unchained: embracing local imperativity in a purely functional language (functional pearl)
Purely functional programming languages pride themselves with reifying effects that are implicit in imperative languages into reusable and composable abstractions such as monads. This reification allows for more exact control over effects as well as the introduction of new or derived effects. However, despite libraries of more and more powerful abstractions over effectful operations being developed, syntactically the common \u27do\u27 notation still lags behind equivalent imperative code it is supposed to mimic regarding verbosity and code duplication. In this paper, we explore extending \u27do\u27 notation with other imperative language features that can be added to simplify monadic code: local mutation, early return, and iteration. We present formal translation rules that compile these features back down to purely functional code, show that the generated code can still be reasoned over using an implementation of the translation in the Lean 4 theorem prover, and formally prove the correctness of the translation rules relative to a simple static and dynamic semantics in Lean
Approximate Inference via Fibrations of Statistical Games
We characterize a number of well known systems of approximate inference as
loss models: lax sections of 2-fibrations of statistical games, constructed by
attaching internally-defined loss functions to Bayesian lenses. Our examples
include the relative entropy, which constitutes a strict section, and whose
chain rule is formalized by the horizontal composition of the 2-fibration. In
order to capture this compositional structure, we first introduce the notion of
`copy-composition', alongside corresponding bicategories through which the
composition of copy-discard categories factorizes. These bicategories are a
variant of the construction, and so we additionally introduce
coparameterized Bayesian lenses, proving that coparameterized Bayesian updates
compose optically, as in the non-coparameterized case.Comment: Accepted as a proceedings paper at ACT 202
A Graph-Based Higher-Order Intermediate Representation
Abstract Many modern programming languages support both imperative and functional idioms. However, state-of-the-art imperative intermediate representations (IRs) cannot natively represent crucial functional concepts (like higher-order functions). On the other hand, functional IRs employ an explicit scope nesting, which is cumbersome to maintain across certain transformations. In this paper we present Thorin: a higher-order, functional IR based on continuation-passing style that abandons explicit scope nesting in favor of a dependency graph. This makes Thorin an attractive IR for both imperative as well as functional languages. Furthermore, we present a novel program transformation to eliminate the overhead caused by higherorder functions. The main component of this transformation is lambda mangling: an important transformation primitive in Thorin. We demonstrate that lambda mangling subsumes many classic program transformations like tail-recursion elimination, loop unrolling or (partial) inlining. In our experiments we show that higher-order programs translated with Thorin are consistently as fast as C programs