Analysis of Imperative Programs through Analysis of Constraint Logic Programs

In this paper a method is proposed for carrying out analysis of imperative programs. We achieve this by writing down the language semantics as a declarative program (a constraint logic program, in the approach shown here). We propose an effective style of writing operational semantics suitable for analysis which we call one-state small-step semantics. Through controlled partial evaluation we are able to generate residual programs where the relationship between imperative statements and predicates is straightforward. Then we use a static analyser for constraint logic programs on the residual program. The analysis results are interpreted through program points associating predicates in the partially evaluated interpreter to statements in its corresponding imperative program. We used an analyser that allows us to determine linear equality, inequality and disequality relations among the variables of a program without user-provided inductive assertions or human interaction. The proposed method intends to serve as a framework for the analysis of programs in any imperative language. The tools required are a partial evaluator and a static analyser for the declarative language.

[1]  Flemming Nielson,et al.  Two-Level Semantics and Code Generation , 1988, Theor. Comput. Sci..

[2]  John W. Lloyd,et al.  Partial Evaluation in Logic Programming , 1991, J. Log. Program..

[3]  Michael Leuschel,et al.  Advanced Techniques for Logic Program Specialisation , 1997, AI Commun..

[4]  Hüseyin Saglam,et al.  A toolkit for static analysis of constraint logic programs , 1997 .

[5]  V. Gouranton,et al.  Formal development of static program analysers , 1997, Proceedings of the Eighth Israeli Conference on Computer Systems and Software Engineering.

[6]  John P. Gallagher,et al.  Fast and Precise Regular Approximations of Logic Programs , 1994, ICLP.

[7]  John P. Gallagher,et al.  Constrained Regular Approximation of Logic Programs , 1997, LOPSTR.

[8]  Flemming Nielson,et al.  Semantics with applications - a formal introduction , 1992, Wiley professional computing.

[9]  Laurie J. Hendren,et al.  Generalized Constant Propagation: A Study in C , 1996, CC.

[10]  Flemming Nielson,et al.  Semantics-Directed Program Analysis: A Tool-Maker's Perspective , 1996, SAS.

[11]  Nicolas Halbwachs,et al.  Automatic discovery of linear restraints among variables of a program , 1978, POPL.

[12]  Robert A. Kowalski,et al.  Logic for problem solving , 1982, The computer science library : Artificial intelligence series.

[13]  John P. Gallagher,et al.  Tutorial on specialisation of logic programs , 1993, PEPM '93.

[14]  M. V. Wilkes,et al.  The Art of Computer Programming, Volume 3, Sorting and Searching , 1974 .

[15]  Reinhard Wilhelm,et al.  A logic-based approach to program flow analysis , 1998, Acta Informatica.

[16]  Donald Ervin Knuth,et al.  The Art of Computer Programming , 1968 .

[17]  Shmuel Sagiv,et al.  Building a Bridge between Pointer Aliases and Program Dependences , 1998, Nord. J. Comput..

[18]  John P. Gallagher,et al.  Some low-level source transformations of logic programs , 1990 .

[19]  Alfred V. Aho,et al.  Compilers: Principles, Techniques, and Tools , 1986, Addison-Wesley series in computer science / World student series edition.

[20]  Flemming Nielson,et al.  Two-Level Semantics and Abstract Interpretation , 1989, Theor. Comput. Sci..

[21]  Patrick Cousot,et al.  Abstract Interpretation Based Static Analysis Parameterized by Semantics , 1997, SAS.