Reversing Abstract Interpretations John Hughes and John Launchbury* Department of Computing Science, University of Glasgow, {rjmh, jl} @dcs.glasgow.a~.uk 1 Introduction Many semantic analyses of functional languages have been developed using the Cousots' abstract interpretation fralnework [CC77]. Some, such as Mycroft's pio- neering strictness analysis [MycS1] and Burn, Hankin and Abramsky's extension of it to higher=m~ler [BHA86], operate on abstract values representing the past history of the computation, and are therefore called forwards analyses. Others, such as W~Uer and Hughes' projection-based strictness analysis [WH87], or Hall's analysis of strictness patterns [Hal87] propagate abstract contexts representing the future of the computation, and are called backwards analyses. However, although the type of abstract information may suggest a "natural" direction, it is in fact possible to perform any analysis in either direction. The goal of this paper is to show how to reverse any given analysis. Why might one prefer one direction of analysis over another? We shall draw an analogy with solving a differential equation on an interval. Solutions may be found by iterating from one end of the interval to the other, with the two possible directions con'esponding to backwards and forwards analysis. But the purpose of an analysis is to answer a question, and such questions correspond to giving the boundary conditions at one end of the interval and asking for the function's value at the other. In such a case it's clearly preferable to start solving the equation at the end where the boundary conditions are known. Note that it's not impossible to work in the other direction--one can always use trial and error to find boundary conditions at the beginning that produce the right values at the end--but in general working in the "wrong" direction will require many solutions to be calculated where one would suffice in the other direction. We will see exactly this effect arising in the case of strictness analysis. Every analysis associates with each function in the source program a correspond- ing abstract function. To reverse an analysis we have to "invert" these abstract functions. We begin by considering the conditions under which one function can be said to safely approximate the inverse of another. We show that there is a best re- "Wozk supported by ESPRIT BRA 3124 - Semantique