Skip to main content

Searching Semantically Equivalent Code Fragments in Logic Programs

  • Conference paper
Logic Based Program Synthesis and Transformation (LOPSTR 2004)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 3573))

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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)

    Google Scholar 

  2. Bossi, A., Gabbrielli, M., Levi, G., Martelli, M.: The S-semantics approach: Theory and applications. Journal of Logic Programming 19/20, 149–197 (1994)

    Article  MathSciNet  Google Scholar 

  3. 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)

    Chapter  Google Scholar 

  4. Falaschi, M., Levi, G., Martelli, M., Palamidessi, C.: Declarative modeling of the operational behaviour of logic programs. Theoretical Computer Science 69, 289–318 (1989)

    Article  MATH  MathSciNet  Google Scholar 

  5. Fowler, M., Beck, K., Brant, J., Opdyke, W., Roberts, D.: Refactoring: Improving the Design of Existing Code. Objet Technology Series. Addison-Wesley, Reading (1999)

    Google Scholar 

  6. Griswold, W.G., Notkin, D.: Program restructuring as an aid to software maintenance. Technical report, Seattle, WA, USA (August 1990)

    Google Scholar 

  7. Horwitz, S.: Identifying the semantic and textual differences between two versions of a program. ACM SIGPLAN Notices 25(6), 234–245 (1990)

    Article  MathSciNet  Google Scholar 

  8. 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)

    Google Scholar 

  9. Lloyd, J.W.: Foundations of Logic Programming. Springer, Heidelberg (1987)

    MATH  Google Scholar 

  10. Pettorossi, A., Proietti, M.: Transformation of logic programs: Foundations and techniques. Journal of Logic Programming 19/20, 261–320 (1994)

    Article  MathSciNet  Google Scholar 

  11. Roberts, D., Brant, J., Johnson, R.E.: A refactoring tool for Smalltalk. Theory and Practice of Object Systems (TAPOS) 3(4), 253–263 (1997)

    Article  Google Scholar 

  12. Schimpf, J.: Logical loops. In: Stuckey, P.J. (ed.) ICLP 2002. LNCS, vol. 2401, p. 224. Springer, Heidelberg (2002)

    Chapter  Google Scholar 

  13. 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)

    Google Scholar 

  14. Schrijvers, T., Serebrenik, A., Demoen, B.: Refactoring logic programs. Technical Report CW 373, Department of Computer Science, K.U.Leuven (2003)

    Google Scholar 

  15. Warren, D.H.D.: Higher-Order Extensions to Prolog: Are They Needed? In: Machine Intelligence, vol. 10, pp. 441–454. Ellis Horwood, Chichester (1982)

    Google Scholar 

  16. Winstead, J., Evans, D.: Towards differential program analysis (2002)

    Google Scholar 

  17. Yang, W.: Identifying syntactic differences between two programs. Software Practice and Experience 21(7), 739–755 (1991)

    Article  Google Scholar 

  18. Yang, W., Horwitz, S., Reps, T.: Detecting program components with equivalent behaviors. Technical Report CS-TR-1989-840, University of Wisconsin, Madison (1989)

    Google Scholar 

  19. 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)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics