A Provably Correct Compilation of Functional Languages into Scripting Languages (original) (raw)
Related papers
An Intermediate Language for Compilation to Scripting Languages
2013
In this paper we introduce an intermediate language for translation of F#, a functional language polymorphically typed relying on the .Net platform, to different scripting languages, such as Python and JavaScript. This intermediate language ( IL for short) is an imperative language, with constructs that make possible to move a code fragment outside its definition environment, during the translation. Definition of names (variables and functions) are done in blocks, like in Python (and JavaScript) and do not have to statically precede their use. We present a translation of a core F# (including mutable variables) into IL.
A purely functional language with encapsulated assignment
Lecture Notes in Computer Science, 1994
The ML type system was originally introduced as a means of identifying a class of terms in a simple untyped language, often referred to as core-ML, whose evaluation could be guaranteed not to "go wrong". In subsequent work, the terms of core-ML have also been viewed as a 'convenient shorthand' for programs in typed languages. Notable examples include studies of ML polymorphism and investigations of overloading, motivated by the use of type classes in Haskell.
Compilation of extended recursion in call-by-value functional languages
This paper formalizes and proves correct a compilation scheme for mutually-recursive definitions in call-by-value functional languages. This scheme supports a wider range of recursive definitions than previous methods. We formalize our technique as a translation scheme to a lambda-calculus featuring in-place update of memory blocks, and prove the translation to be correct.
A Higher-Order Abstract Syntax Approach to Verified Transformations on Functional Programs
Programming Languages and Systems, 2016
We describe an approach to the verified implementation of transformations on functional programs that exploits the higher-order representation of syntax. In this approach, transformations are specified using the logic of hereditary Harrop formulas. On the one hand, these specifications serve directly as implementations, being programs in the language λProlog. On the other hand, they can be used as input to the Abella system which allows us to prove properties about them and thereby about the implementations. We argue that this approach is especially effective in realizing transformations that analyze binding structure. We do this by describing concise encodings in λProlog for transformations like typed closure conversion and code hoisting that are sensitive to such structure and by showing how to prove their correctness using Abella.
Non-standard type inference for functional programs
1998
While visiting the Computer Science Department of the University of Torino in November/December 1997. vi The evaluation rules for PCF are a subset of the ones for PCFP (in Figure 2.2), since the rules APP 2 and PROJ i (i ∈ {1, 2}) are not needed. All the results in the previous sections apply to PCF as well. 2.6 PCFP with primitive recursion In this section we introduce an extension of PCFP, called PCFP T , which is more suitable for expressing programs extracted from formal proofs. The language PCFP T is obtained from PCFP by adding a program constructor for primitive recursion over natural numbers (rec). There are also two constructors for specifying simplified uses of primitive recursion: the constructor it (for iteration) and the constructor case. PCFP T , which is a variant of Gödel's system T , is the language considered in Part III of this thesis. The term formation rules for the new constructors are in Fig. 2.4, and the evaluation rules are in Fig. 2.5. Since for every PCFP T term there is an equivalent (w.r.t. the interpretation in all the closed term model described in Section 2.4) PCFP term (see Fact 2.10 below), we have that all the results for PCFP presented in the previous sections apply to PCFP T as well.
A simple functional language compiler
1994
Antoni Diller's book Compiling Functional Languages contains a complete compiler and reducer for a simple language. The compiler is a Pascal program of 1379 lines. A version of that program written in the Turing programming language is presented. The new version makes use of Turing language features such as modules and variant records, supports tracing of each pass of the compiler as a new feature, and takes advantage of a number of di erent minor design and program formatting choices. The Turing version is about 20 smaller than the original version, provides more features and is easier to read.
Functional low-level interpreters
2002
We show how to construct in a pure, lazy functional language Haskell a low-level, FORTH-like (stack based, postfix style) virtual machine, used as a target platform in our compilation course for computer science students. The implementation is clear, reasonably efficient, and easily extensible. Two models are presented: more “classical”, with a separate return stack, and an interpreter based on the continuation-passing style. The idea, although traditional, was a bit experimental, since this was the first contact of our students with Haskell and with advanced functional techniques. We exploited thus this course to teach also those techniques, on a comprehensive and conceptually coherent set of examples.
T IL-Script: Functional Programming Based on Transparent Intensional Logic
In the paper we introduce an interpreter of the Transperent Intensional Logic (TIL), namely the T IL-Script language, its design and implementation. TIL is a brainchild of the Czech logician Pavel Tich and in many ways a revolutionary logical system. The work on the T IL-Script project is being pursued by the team of undergraduate students. The paper we provide is a brief review of the T IL-Script syntax.
An intensional implementation technique for functional languages
1984
The potential of functional programming languages has not been widely accepted yet. The reason lies in the difficulties associated with their implementation. In this dissertation we propose a new implementation technique for functional languages by compiling them into 'Intensional Logic' of R. Montague and R. Carnap. Our technique is not limited to a particular hardware or to a particular evaluation strategy; nevertheless it lends itself directly to demand-driven tagged dataflow architecture. Even though our technique can handle conventional languages as well, our main interest is exclusively with functional languages in general and with Lucid-like dataflow languages in particular. We give a brief general account of intensional logic and then introduce the concept of intensional algebras as structures (models) for intensional logic. We, formally, show the computability requirements for such algebras. The target language of our compilation is the family of languages DE (defin...
A ug 2 01 7 The Unfolding Semantics of Functional Programs
2018
The idea of using unfolding as a way of computing a program semantics has been applied successfully to logic programs and has shown itself a powerful tool that provides concrete, implementable results, as its outcome is actually source code. Thus, it can be used for characterizing not-so-declarative constructs inmostly declarative languages, or for static analysis. However, unfolding-based semantics has not yet been applied to higher-order, lazy functional programs, perhaps because some functional features absent in logic programs make the correspondence between execution and unfolding not as straightforward. This work presents an unfolding semantics for higher-order, lazy functional programs and proves its adequacy with respect to a given operational semantics. Finally, we introduce some applications of our semantics.