Abstract
In this work, we devise an analysis that searches for semantically equivalent code fragments within a given logic program. The presence of duplicated code (or functionality) is a primary indication that the design of the program can be improved by performing a so-called refactoring transformation. Within the framework of our analysis, we formally characterize three situations of duplicated functionality and their associated refactorings: the extraction of a duplicated goal into a new predicate, the removal of equivalent predicates and the generalization of two predicates into a higher-order predicate. The resulting analysis detects in a completely automatic way what program fragments are suitable candidates for the considered refactoring transformations.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Apt, K.R.: Logic programming. In: van Leeuwen, J. (ed.) Handbook of Theoretical Computer Science, Volume B, Formal Models and Semantics, pp. 493–574. Elsevier, Amsterdam (1990)
Bossi, A., Gabbrielli, M., Levi, G., Martelli, M.: The S-semantics approach: Theory and applications. Journal of Logic Programming 19/20, 149–197 (1994)
Bruynooghe, M., Leuschel, M., Sagonas, K.: A polyvariant binding-time analysis for off-line partial deduction. In: Hankin, C. (ed.) ESOP 1998. LNCS, vol. 1381, pp. 27–41. Springer, Heidelberg (1998)
Falaschi, M., Levi, G., Martelli, M., Palamidessi, C.: Declarative modeling of the operational behaviour of logic programs. Theoretical Computer Science 69, 289–318 (1989)
Fowler, M., Beck, K., Brant, J., Opdyke, W., Roberts, D.: Refactoring: Improving the Design of Existing Code. Objet Technology Series. Addison-Wesley, Reading (1999)
Griswold, W.G., Notkin, D.: Program restructuring as an aid to software maintenance. Technical report, Seattle, WA, USA (August 1990)
Horwitz, S.: Identifying the semantic and textual differences between two versions of a program. ACM SIGPLAN Notices 25(6), 234–245 (1990)
Li, H., Reinke, C., Thompson, S.: Tool support for refactoring functional programs. In: Jeuring, J. (ed.) CM SIGPLAN 2003 Haskell Workshop. Association for Computing Machinery (2003)
Lloyd, J.W.: Foundations of Logic Programming. Springer, Heidelberg (1987)
Pettorossi, A., Proietti, M.: Transformation of logic programs: Foundations and techniques. Journal of Logic Programming 19/20, 261–320 (1994)
Roberts, D., Brant, J., Johnson, R.E.: A refactoring tool for Smalltalk. Theory and Practice of Object Systems (TAPOS) 3(4), 253–263 (1997)
Schimpf, J.: Logical loops. In: Stuckey, P.J. (ed.) ICLP 2002. LNCS, vol. 2401, p. 224. Springer, Heidelberg (2002)
Schleimer, S., Wilkerson, D.S., Aiken, A.: Winnowing: local algorithms for document fingerprinting. In: Proceedings of the 2003 ACM SIGMOD international conference on Management of Data, San Diego, CA (2003)
Schrijvers, T., Serebrenik, A., Demoen, B.: Refactoring logic programs. Technical Report CW 373, Department of Computer Science, K.U.Leuven (2003)
Warren, D.H.D.: Higher-Order Extensions to Prolog: Are They Needed? In: Machine Intelligence, vol. 10, pp. 441–454. Ellis Horwood, Chichester (1982)
Winstead, J., Evans, D.: Towards differential program analysis (2002)
Yang, W.: Identifying syntactic differences between two programs. Software Practice and Experience 21(7), 739–755 (1991)
Yang, W., Horwitz, S., Reps, T.: Detecting program components with equivalent behaviors. Technical Report CS-TR-1989-840, University of Wisconsin, Madison (1989)
Zhao, J., Cheng, J., Ushijima, K.: Program dependence analysis of concurrent logic programs and its applications. In: 1996 International Conference on Parallel and Distributed Systems (ICPADS 1996), Tokyo, Japan (1996)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2005 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Vanhoof, W. (2005). Searching Semantically Equivalent Code Fragments in Logic Programs. In: Etalle, S. (eds) Logic Based Program Synthesis and Transformation. LOPSTR 2004. Lecture Notes in Computer Science, vol 3573. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11506676_1
Download citation
DOI: https://doi.org/10.1007/11506676_1
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-26655-6
Online ISBN: 978-3-540-31683-1
eBook Packages: Computer ScienceComputer Science (R0)