A Temporal-Logic Approach to Binding-Time Analysis
Rowan Davies Carnegie Mellon University Computer Science Department Pittsburgh PA 15213, USA [email protected]
Abstract languages that include binding-time annotations, as for example by Nielson and Nielson [14] and Gomard and The Curry-Howard isomorphism identifies proofs with Jones [9]. However, the motivation for the particular typing
typed -calculus terms, and correspondingly identifies rules that are chosen is often not clear. There has been some propositions with types. We show how this isomorphism work, for example by Palsberg [15], on modular proofs that can be extended to relate constructive temporal logic with binding-time analyses generate annotations that allow large binding-timeanalysis. In particular,we show how to extend classes of partial evaluators to specialize correctly. How-
the Curry-Howard isomorphism to include the (“next”) ever this still does not provide a direct motivation for the
operator from linear-time temporal logic. This yields the particular rules used in binding-time type systems. simply typed -calculus which we prove to be equiva- In this paper we give a logical construction of a binding- lent to a multi-level binding-timeanalysis like those used in time typesystem based on temporal logic. Temporal logicis
partial evaluation for functional programming languages. an extension of logic to include proofs that formulas are valid
Further, we prove that normalization in can be done at particular times. The Curry-Howard [11] isomorphism in an order corresponding to the times in the logic, which
relates constructive proofs to typed -terms and formulas to
explains why is relevant to partial evaluation. We then types. Thus, we expect that extending the Curry-Howard
extend to a small functional language, Mini-ML , and isomorphism to constructive temporal logic should yield a give an operational semantics for it. Finally, we prove that
typed -calculus that expresses that a result of a particular this operational semantics correctly reflects the binding- type will be available at a particular time. This is exactly times in the language, a theorem which is the functional what a binding-time type system should capture. programming analog of time-ordered normalization. Many different temporal logics and many different tem- poral operators have been studied, so we need to determine exactly which are relevant to binding-time analysis. In a 1. Introduction binding-time separated program, one stage in the program can manipulate as data the code of the following stage. At Partial evaluation [12] is a method for specializing a pro- the level of types this suggests that at each stage we should gram given part of the program’s input. The basic technique have a type for code of the next stage. Thus, via the Curry- is to execute those parts of the program that do not depend Howard isomorphism we are led to consider the temporal
on the unknown data, while constructing a residual program logic operator, which denotes truth at the next stage, i.e.
A A from those parts that do. Offline partial evaluation uses a is valid if is valid at the next time. Further, since binding-time analysis to determine those parts of the pro- temporal logics generally allow an unbounded number of gram that will not depend on the unknown (dynamic) data, “times”, they should naturally correspond to a binding-time regardless of the actual value of the known (static) data. analysis with many levels, such as that studied by Gl¨uck and Binding-time analyses are usually described via typed Jørgensen [8]. The more traditional two-level binding-time analyses can then be trivially obtained by restriction. Also, This work wasmostly completedduring a visit bythe author to BRICS in binding-time analysis we have a simple linear ordering (Basic Research in Computer Science, Centre of the Danish National Re- search Foundation)in the summer of 1995. It was also partly supported by of the binding times, so we consider linear-time temporal a Hackett Studentship from the University of Western Australia logic, in which each time has a unique time immediately following it. Putting this all together naturally suggests that binding-timetypesystems used in partial evaluation, such as
constructive linear-time temporal logic with and a type that of Gomard and Jones [9], allow manipulation of code system for multi-level binding-time analysis should be im- with free variables. Thus, the original motivation for the ages of each other under the Curry-Howard isomorphism. present work was to consider how to extend Mini-ML2 to a This does not seem to have been observed previously, and system that is a conservative extension of the binding-time in this paper we show formally that this is indeed the case. type systems used in partial evaluation. In this paper we The development is relatively straightforward and our main achieve that goal, though find that we also lose the features
interest is in demonstrating the direct logical relationship of Mini-ML2 beyond ordinary binding-time analysis. Our 2
between binding-time analysis and temporal logic. conclusion is that the 2 operator in Mini-ML corresponds
The structure of this paper is then as follows. In the toatypefor closed code, whilethe operatorinMini-ML following section, we start with a natural deduction formu- corresponds to a type for code with free variables. Thus the
lation of intuitionistic linear-time temporal logic with two operators are suitable for different purposes, and which
and . Our system has a similar style to the modal sys- one is preferred depends on the context. This suggests that
tems of Martini and Masini [13]. We then verify that our a desirable direction for future work would be the design of operator is the same as that considered elsewhere by show- a type system correctly capturing both closed code and code
ing that adding negation and classical reasoning leads to a with free variables within a single framework.
system equivalent to L , an axiomatic formulation due to Stirling [17] for a small classical linear-time temporal logic
including .
We then apply the Curry-Howard isomorphism to the 2. A temporal -calculus
natural-deduction system, yielding the typed -calculus
withthe operator in thetypes. We givereduction rulesfor thiscalculus, and prove that normalizationcan be performed In this section we will show how to extend the Curry- in an order corresponding to the times in the logic. This
Howard isomorphism to include the (“next”) operator theorem gives an abstract explanation for why is relevant from temporal logic. In order to do this, we give a natural-
to partial evaluation. deduction system for an intuitionistic linear-time temporal
m