
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 In the second part of the paper we consider , which logic containing only and . We then show that our is essentially the -calculus fragment of the language operator is the same as the one usually considered in linear- used in the multi-level binding-time analysis of Gl¨uck and time temporal logics by adding inference rules for negation Jørgensen [8]. We then construct a simple isomorphism and classical reasoning, and then proving equivalence to a m between and that preserves typing, thus showing sound and complete axiomatic system given by Stirling[17] that these languages are equivalent as type systems. We for the fragment of classical linear-time temporal logic con- also give a correspondence between -reductions in the two taining only , and . We then add proof terms to our languages. This gives some explanation for why languages original natural deduction system to yield a simply typed m like are relevant to partial evaluation. -calculus with the operator in the types. Finally, we expand to a small temporal functional language Mini-ML , which is in many ways similar to a realistic binding-time type system. We give an operational semantics for this language, and then give a proof that this 2.1. Intuitionistic Temporal Logic semantics correctly reflects the binding times in the lan- guage. This theorem is the functional programming analog of the time-ordered normalization theorem for . This subsection presents a simple natural-deduction for- We conclude by giving example programs in Mini-ML mulation of an intuitionisticlinear-time temporal logic con- and discussing some practical concepts from binding-time taining only and . Our formulation uses a judge- analysis. ment annotated with a natural number n, representing the This work is similar to work by Davies and Pfenning [5] “time” of the conclusion, and with each assumption A in 2 which shows that a typed language Mini-ML based on Γ also annotated by a time n. These are just like the “lev- modal logic captures a powerful form of staged computa- els” in the modal natural-deduction systems of Martini and tion, including run-time code generation. They also show Masini [13], and in fact our system is exactly the same as that Mini-ML2 is a conservative extension of the two-level their rules for modal K, except that because of linearity we and (linearly ordered) B-level languages studied by Niel- do not need any restriction on the assumptions used in the son and Nielson [14]. However, they note that this system introduction rule for . Our rules for the non-temporal onlyallows programs that manipulateclosed code, whilethe fragment are completely standard. 2 We are now in a positionto prove equivalence to a previ- ously presented temporal logic. The following axioms and n A Γ in inference rules, L , for the fragment of classical linear- V n A Γ time temporal logic containing only , and are due to Stirling[17] (page 516), who shows that they are sound and n n Γ A A 1 2 complete for unravelled models of this logic.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages12 Page
-
File Size-