Analysis of Imperative Programs through Analysis of Constraint Logic Programs

  • Julio C. Peralta
  • John P. Gallagher
  • Hüseyin Sağlam
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1503)


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.


Partial Evaluation Constraint Logic Programming Operational Semantics Imperative Program Analysis 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman. Compilers: Principles, Techniques, and Tools. Addison Wesley, 1986.Google Scholar
  2. 2.
    P. Cousot and N. Halbwachs. Automatic discovery of linear restraints amog variables of a program. In Proceedings of the Conference Record of the 5th ACM Symposium on Principles of Programming Languages, pages 84–97, Albuquerque, New Mexico, 1978.Google Scholar
  3. 3.
    Patrick Cousot. Abstract interpretation based static analysis parametrized by semantics. In Proceedings of the Fourth International Symposium on Static Analysis, SAS’97, pages 388–394, Paris, France, 1997. LNCS 1302, Springer Verlag.Google Scholar
  4. 4.
    J.P. Gallagher. Tutorial on specialisation of logic programs. In Proceedings of the ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, pages 88–98, Copenhagen, Denmark, 1993. ACM Press.Google Scholar
  5. 5.
    J. Gallagher and M. Bruynooghe. Some low-level source transformations for logic programs. In Proceedings of Meta90 Workshop on Meta Programming in Logic. Katholieke Universiteit Leuven, Belgium, 1990.Google Scholar
  6. 6.
    J. Gallagher and M. Bruynooghe. The derivation of an algorithm for program specialisation. New Generation Computing, 9(3&4):305–333, 1991.CrossRefGoogle Scholar
  7. 7.
    J. Gallagher and D.A. de Waal. Fast and precise regular approximation of logic programs. In P. Van Hentenryck, editor, Proceedings of the International Conference on Logic Programming (ICLP’94), Santa Margherita Ligure, Italy. MIT Press, 1994.Google Scholar
  8. 8.
    Valérie Gouranton and Daniel Le Métayer. Formal development of static program analysers. In Proceedings of the 8th Israeli Conference on Computer Systems and Software Engineering, pages 101–110, Israel, 1997.Google Scholar
  9. 9.
    Donald E. Knuth. The Art of Computer Programming, volume 3 of Sorting and Searching. Addison-Wesley Publishing Company, 1973.Google Scholar
  10. 10.
    Robert Kowalski. Logic for Problem Solving. North Holland, 1979.Google Scholar
  11. 11.
    Michael Leuschel. Advanced Techniques for Logic Program Specialisation. PhD thesis, Katholieke Universiteit Leuven, Department of Computer Science, Leuven, Belgium, May 1997.Google Scholar
  12. 12.
    J. W. Lloyd and J. C. Shepherdson. Partial evaluation in logic programming. The Journal of Logic Programming, 11(3&4):217–242, 1991.CrossRefMathSciNetzbMATHGoogle Scholar
  13. 13.
    Flemming Nielson. Two-level semantics and abstract interpretation. Theoretical Computer Science, (69):117–242, 1989.Google Scholar
  14. 14.
    Flemming Nielson. Semantics-directed program analysis: A toolmaker’s perspective. In Third International Symposium, SAS’96. Springer Verlag, LNCS 1145, 1996.Google Scholar
  15. 15.
    Flemming Nielson and Hanne Riis Nielson. Two-level semantics and code generation. Theoretical Computer Science, (56):59–133, 1988.Google Scholar
  16. 16.
    Hanne Riis Nielson and Flemming Nielson. Semantics with Applications. John Wiley and Sons, 1992.Google Scholar
  17. 17.
    John L. Ross and Mooly Sagiv. Building a bridge between pointer aliases and program dependences. In European Symposium On Programming, Lisbon, Portugal, 1998.Google Scholar
  18. 18.
    Hüseyin Sağlam. A Toolkit for Static Analysis of Constraint Logic Programs. PhD thesis, Bristol University, Department of Computer Science, Bristol, U.K., March 1998.Google Scholar
  19. 19.
    Mooly Sagiv, Nissim Francez, Michael Rodeh, and Reinhard Wilhelm. A logic-based approach to program flow analysis. 1998. Submitted to Acta Informatica.Google Scholar
  20. 20.
    H. Sağlam and J. Gallagher. Constrained regular approximation of logic programs. In N. Fuchs, editor, Logic Program Synthesis and Transformation (LOPSTR’97). Springer-Verlag, Lecture Notes in Computer Science, 1998. in press.Google Scholar
  21. 21.
    Clark Verbrugge, Phong Co, and Laurie Hendren. Generalized constant propagation a study of C. Lecture Notes in Computer Science, Compiler Construction, (1060):74–90, 1996.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1998

Authors and Affiliations

  • Julio C. Peralta
    • 1
  • John P. Gallagher
    • 1
  • Hüseyin Sağlam
    • 1
  1. 1.Dept. of Computer ScienceUniversity of BristolBristolUK

Personalised recommendations