This Article 
 Bibliographic References 
 Add to: 
A Knowledge-Based Approach to the Analysis of Loops
May 1996 (vol. 22 no. 5)
pp. 339-360

Abstract—This paper presents a knowledge-based analysis approach that generates first order predicate logic annotations of loops. A classification of loops according to their complexity levels is presented. Based on this taxonomy, variations on the basic analysis approach that best fit each of the different classes are described. In general, mechanical annotation of loops is performed by first decomposing them using data flow analysis. This decomposition encapsulates closely related statements in events, that can be analyzed individually. Specifications of the resulting loop events are then obtained by utilizing patterns, called plans, stored in a knowledge base. Finally, a consistent and rigorous functional abstraction of the whole loop is synthesized from the specifications of its individual events. To test the analysis techniques and to assess their effectiveness, a case study was performed on an existing program of reasonable size. Results concerning the analyzed loops and the plans designed for them are given.

[1] S.K. Abd-El-Hafiz and V.R. Basili, A Knowledge-Based Approach to Program Understanding. Kluwer Academic, 1995.
[2] S.K. Abd-El-Hafiz and V.R. Basili, "A Tool for Assisting the Understanding and Formal Development of Software," Proc. Sixth Int'l Conf. Software Engineering and Knowledge Engineering,Jurmala, Latvia, pp. 36-45,. 1994.
[3] S.K. Abd-El-Hafiz and V.R. Basili, "Documenting Programs Using a Library of Tree Structured Plans," Proc. Conf. Software Maintenance,"Montreal, Canada, pp. 152-161, 1993.
[4] S.K. Abd-El-Hafiz, V.R. Basili, and G. Caldiera, "Towards Automated Support for Extraction of Reusable Components," Proc. Conf. Software Maintenance,Sorrento, Italy, pp. 212-219, 1991.
[5] A. Abran and H. Nguyenkim, "Analysis of Maintenance Work Categories Through Measurement," Proc. Conf. Software Maintenance,Sorrento, Italy, pp. 104-113, 1991.
[6] D. Allemang and B. Chandrasekaran, "Functional Representation and Program Debugging," Proc. Sixth Ann. Knowledge-Based Software Engineering Conf.,Syracuse, N.Y., pp. 167-178, 1991.
[7] V.R. Basili and S.K. Abd-El-Hafiz, "A Method for Documenting Code Components," The J. of Systems and Software, to appear.
[8] S.K. Basu and J. Misra, "Proving Loop Programs," IEEE Trans. Software Engineering, vol. 1, no. 1, pp. 76-86, 1975.
[9] K. Bertels, P. Vanneste, and C. De Backer, "A Cognitive Approach to Program Understanding," Proc. Working Conf. Reverse Engineering,Baltimore, Md., pp. 1-7, 1993.
[10] G. Brassard and P. Bratley, Algorithmic Theory and Practice.Englewood Cliffs, N.J.: Prentice Hall, 1988.
[11] G. Caldiera and V.R. Basili, "Identifying and Qualifying Reusable Software Components," Computer, pp .61-70, Feb. 1991.
[12] D.D. Dunlop and V.R. Basili, “A Heuristic for Deriving Loop Functions,” IEEE Trans. Software Eng., vol. 10, no. 3, pp. 275–285, May 1984.
[13] R.B. France and V.R. Basili, "A Pattern-Driven Approach to Code Analysis for Reuse," Tech. Report CS-TR-2802, Dept. of Computer Science, Univ. of Maryland, College Park, Md. 1991.
[14] D. Gries, The Science of Programming.New York, Heidelberg, Berlin: Springer-Verlag, 1981.
[15] M.T. Harandi and J.Q. Ning, "PAT: A Knowledge-Based Program Analysis Tool," Proc. Conf. Software Maintenance,Phoenix, Ariz., pp. 312-318, 1988.
[16] M. Harandi and J. Ning, "Knowledge-Based Program Analysis," IEEE Software, vol. 7, no. 1, 1990.
[17] J. Hartman, "Understanding Natural Programs Using Proper decomposition," Proc. 13th Int'l Conf. Software Engineering, pp. 62-73,Austin, Tex., 1991.
[18] P.A. Hausler, M.G. Pleszkoch, R.C. Linger, and A.R. Hevner, "Using Function Abstraction to Understand Program Behavior," IEEE Software, vol. 7, no. 1, pp. 55-63, 1990.
[19] C.A.R. Hoare, "An Axiomatic Basis for Computer Programming," Comm. ACM, 1969.
[20] C.A.R. Hoare, "Procedures and Parameters: An Axiomatic Approach," Symp. Semantics of Algorithmic Languages, pp. 102-116. Springer-Verlag, 1971.
[21] C.S. Hsieh, "Slice, Chunk, and Dataflow Anomaly as Datalog Rules," The J. of Systems and Software, vol. 16, no. 3, pp. 197-203, 1991.
[22] P. Jalote, An Integrated Approach to Software Engineering. Springer-Verlag, 1991.
[23] W.L. Johnson, Intention-Based Diagnosis of Novice Programming Errors, Morgan Kaufmann, 1986.
[24] W.L. Johnson and E. Soloway, “Proust: Knowledge-Based Program Understanding,” IEEE Trans. Software Eng., vol. 11, no. 3, pp. 11-19, Nov. 1985.
[25] C. B. Jones,Systematic Software Development Using VDM. Englewood Cliffs, NJ: Prentice-Hall, 1990, 2nd ed.
[26] S. Katz and Z. Manna, “Logical Analysis of Programs,” Comm. ACM, vol. 19, no. 4, pp. 188–206, Apr. 1976.
[27] K. Lano and P. Breuer, "From Programs to Z Specifications," Z User Workshop, J.E. Nicholls, pp. 46-70. Springer-Verlag, 1989.
[28] B.P. Lientz and E.B. Swanson, Software Maintenance Management: A Study of the Maintenance of Computer Application Software in 487 Data Processing Organizations, Addison Wesley Longman, Reading, Mass., 1980.
[29] S. Letovsky, "Program Understanding with the Lambda Calculus," Proc. 10th Int'l Joint Conf. on AI, pp. 512-514, 1987.
[30] D.C. Luckham and N. Suzuki, "Verification of Array, Record, and Pointer Operations in Pascal," TOPLAS, vol. 1, no. 2, pp. 226-244, Oct. 1979.
[31] K.B. McKeithen, J.S. Reitman, H.H. Rueter, and S.C. Hirtle, "Knowledge Organization and Skill Differences in Computer Programmers," Cognitive Psychology. vol. 13, pp. 307-325, 1981.
[32] H.D. Mills, V.R. Basili, J.D. Gannon, and R.G. Hamlet, Principles of Computer Programming: A Mathematical Approach. Allyn and Bacon, 1987.
[33] W.R. Murray, Automatic Program Debugging for Intelligent Tutoring Systems, Morgan Kaufmann, 1988.
[34] P. Norvig, Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp. Morgan Kaufmann, 1992.
[35] T.W. Pratt, "Control Computations and the Design of Loop Control Structures," IEEE Trans. Software Engineering, vol. 4, no. 2, pp. 81-89, 1978.
[36] A. Quilici, "A Hybrid Approach to Recognizing Programming plans," Proc. Working Conf. Reverse Engineering, pp. 126-133,Baltimore, Md., 1993.
[37] C. Rich, "A Formal Representation for Plans in the Programmer's Apprentice," Proc. Seventh Int'l Joint Conf. on AI, pp. 1,044-1,052, Aug. 1981.
[38] C. Rich and L. Wills, "Recognizing a Program's Design: A Graph Parsing Approach," IEEE Software, vol. 7, no. 1, 1990.
[39] E. Rich and K. Knight, Artificial Intelligence, Mc-Graw Hill, 1991.
[40] P.G. Selfridge, R.C. Waters, and E.J. Chikofsky, "Challenges to the field of Reverse Engineering," Proc. Working Conf. Reverse Engineering,Baltimore, Md., pp. 144-150, 1993.
[41] E. Soloway, "Learning to Program = Learning to Construct Mechanisms and Explanations," Comm. ACM, vol. 29, no. 9, pp. 850-858, 1986.
[42] E. Soloway, J. Bonar, and K. Ehlrich, “Cognitive Strategies and Looping Constructs: An Empirical Study,” Comm. ACM, vol. 26, no. 11, pp. 485–492, 1983.
[43] E. Soloway and K. Ehrlich, "Empirical Studies of Programming Knowledge," IEEE Trans. Software Engineering, vol. 10, no. 5, 1984.
[44] J.M. Spivey, "An Introduction to Z and Formal Specifications," Software Engineering J., pp. 40-50, Jan. 1989.
[45] J.M. Spivey, The Z Notation: A Reference Manual, Prentice-Hall, Englewood Cliffs, N.J., 1992.
[46] M. Ward, F.W. Calliss, and M. Munro, “The Maintainer's Assistant,” Proc. Int'l Conf. Software Maintenance, pp. 307–315, 1989.
[47] R.C. Waters, "A Method for Analyzing Loop Programs," IEEE Trans. Software Engineering, vol. 5, no. 3, pp. 237-247, 1979.
[48] R.C. Waters, "The Programmer's Apprentice: A Session with KBEmacs," IEEE Trans. Software Engineering, vol. 11, no. 11, pp. 1,296-1,320, Nov. 1985.
[49] B. Wegbreit, “The Synthesis of Loop Predicates,” Comm. ACM, vol. 17, no. 2, pp. 102–112, Feb. 1974.
[50] L.M. Wills, "Flexible Control for Program Recognition," Proc. the Working Conf. Reverse Engineering,Baltimore, Md., pp. 134-143, 1993.
[51] J.C.P. Woodcock, "Structuring Specifications in Z," Software Engineering J., pp. 51-66, Jan. 1989.

Index Terms:
First order predicate logic, formal specifications, knowledge base, loops, program understanding, reverse engineering.
Salwa K. Abd-El-Hafiz, Victor R. Basili, "A Knowledge-Based Approach to the Analysis of Loops," IEEE Transactions on Software Engineering, vol. 22, no. 5, pp. 339-360, May 1996, doi:10.1109/32.502226
Usage of this product signifies your acceptance of the Terms of Use.