Demand Analysis with Partial Predicates

Julio Marino,Angel Herranz,Juan Jose Moreno-Navarro
DOI: https://doi.org/10.48550/arXiv.cs/0602008
2006-02-05
Abstract:In order to alleviate the inefficiencies caused by the interaction of the logic and functional sides, integrated languages may take advantage of \emph{demand} information -- i.e. knowing in advance which computations are needed and, to which extent, in a particular context. This work studies \emph{demand analysis} -- which is closely related to \emph{backwards strictness analysis} -- in a semantic framework of \emph{partial predicates}, which in turn are constructive realizations of ideals in a domain. This will allow us to give a concise, unified presentation of demand analysis, to relate it to other analyses based on abstract interpretation or strictness logics, some hints for the implementation, and, more important, to prove the soundness of our analysis based on \emph{demand equations}. There are also some innovative results. One of them is that a set constraint-based analysis has been derived in a stepwise manner using ideas taken from the area of program transformation. The other one is the possibility of using program transformation itself to perform the analysis, specially in those domains of properties where algorithms based on constraint solving are too weak.
Programming Languages,Symbolic Computation
What problem does this paper attempt to address?
The problem that this paper attempts to solve is the efficiency problem in functional - logical programming languages caused by the interaction between laziness and backtracking, especially when evaluating functional expressions containing uninstantiated (i.e., existentially quantified) logical variables may be required during program execution. Specifically, the paper mentions two main problems: 1. **The Reevaluation Problem**: Since laziness and backtracking are opposed to each other to some extent, laziness attempts to delay certain calculations, while backtracking drives different calculations through branch paths. If certain calculations are placed after branch points, there is a risk of re - evaluation. This re - evaluation not only wastes resources but also violates the original intention of laziness to save work. 2. **Sequentiality Analysis**: When compiling the function definition code in lazy languages, it is necessary to decide which parameters need to be reduced to match the pattern on the left side of the rule and the reduction order of these parameters. For some programs, it is difficult to construct a decision tree only from the left - side pattern, so a more effective analysis method is required to generate a sequential definition tree. To solve these problems, the paper proposes a static analysis method - demand analysis, which aims to extract demand information from functional - logical programs. This information can be used to guide and improve the needed narrowing strategy, thereby reducing the search space and avoiding re - evaluation. In addition, demand analysis also helps to convert non - sequential programs into sequential programs, safely replace strict equations with unification, and implement default rules, etc. By introducing the formal framework of partial predicates, the author proves the correctness of the demand equations and proposes a novel analyzer implementation method. This method not only simplifies the process of demand analysis but also optimizes its implementation, enabling it to be applied in different contexts and achieve similar success.