Skip to main content

Clones in Logic Programs and How to Detect Them

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

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

Abstract

In this paper, we propose a theoretical framework that allows us to capture, by program analysis, the notion of code clone in the context of logic programming. Informally, two code fragments are considered as cloned if they implement the same functionality. Clone detection can be advantageous from a software engineering viewpoint, as the presence of code clones inside a program reveals redundancy, broadly considered a “bad smell”. In the paper, we present a detailed definition of a clone in a logic program and provide an efficient detection algorithm able to identify an important subclass of code clones that could be used for various applications such as program refactoring and plagiarism recognition. Our clone detection algorithm is not tied to a particular logic programming language, and can easily be instantiated for different such languages.

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 54.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 72.00
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: Handbook of Theoretical Computer Science, Volume B: Formal Models and Sematics, pp. 493–574. Elsevier (1990)

    Google Scholar 

  2. Baxter, I.D., Yahin, A., Moura, L., Sant’Anna, M., Bier, L.: Clone detection using abstract syntax trees. In: Proceedings of the International Conference on Software Maintenance (CSM 1998), pp. 368–377. IEEE (1998)

    Google Scholar 

  3. Brown, C., Thompson, S.: Clone detection and elimination for Haskell. In: Proceedings of the 2010 SIGPLAN Workshop on Partial Evaluation and Program Manipulation (PEPM 2010), pp. 111–120. ACM (2010)

    Google Scholar 

  4. Clocksin, W.F., Mellish, C.S.: Programming in Prolog: Using the ISO Standard. Springer (2003)

    Google Scholar 

  5. Degrave, F., Vanhoof, W.: Towards a Normal Form for Mercury Programs. In: King, A. (ed.) LOPSTR 2007. LNCS, vol. 4915, pp. 43–58. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  6. Fowler, M., Beck, K., Brant, J., Opdyke, W., Roberts, D.: Refactoring: improving the design of existing code. Addison-Wesley (1999)

    Google Scholar 

  7. Jablonski, P., Hou, D.: CReN: a tool for tracking copy-and-paste code clones and renaming identifiers consistently in the IDE. In: Proceedings of the 2007 OOPSLA Workshop on Eclipse Technology eXchange (ETX 2007), pp. 16–20. ACM (2007)

    Google Scholar 

  8. Lancaster, T., Finta, C.: A comparison of source code plagiarism detection engines. Computer Science Education 14(2), 101–112 (2004)

    Article  Google Scholar 

  9. Li, H., Thompson, S.: Clone detection and removal for Erlang/OTP within a refactoring environment. In: Proceedings of the 2009 SIGPLAN Workshop on Partial Evaluation and Program Manipulation (PEPM 2009), pp. 169–178. ACM (2009)

    Google Scholar 

  10. Rieger, M., Ducasse, S., Lanza, M.: Insights into system-wide code duplication. In: Proceedings of the 11th Working Conference on Reverse Engineering (WCRE 2004), pp. 100–109. IEEE (2004)

    Google Scholar 

  11. Roy, C.K., Cordy, J.R.: A survey on software clone detection research. Tech. Rep. 2007-541, School of Computing, Queen’s University at Kingston, Canada (2007)

    Google Scholar 

  12. Roy, C.K., Cordy, J.R., Koschke, R.: Comparison and evaluation of code clone detection techniques and tools: A qualitative approach. Science of Computer Programming 74(7), 470–495 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  13. Serebrenik, A., Schrijvers, T., Demoen, B.: Improving Prolog programs: Refactoring for Prolog. Theory and Practice of Logic Programming (TPLP) 8, 201–215 (2008), other version consulted: https://lirias.kuleuven.be/bitstream/123456789/164765/1/technical_note.pdf

    MathSciNet  MATH  Google Scholar 

  14. Somogyi, Z., Henderson, F., Conway, T.: The execution algorithm of Mercury, an efficient purely declarative logic programming language. Journal of Logic Programming 29, 17–64 (1996)

    Article  MATH  Google Scholar 

  15. Vanhoof, W.: Searching Semantically Equivalent Code Fragments in Logic Programs. In: Etalle, S. (ed.) LOPSTR 2004. LNCS, vol. 3573, pp. 1–18. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  16. Vanhoof, W., Degrave, F.: An Algorithm for Sophisticated Code Matching in Logic Programs. In: Garcia de la Banda, M., Pontelli, E. (eds.) ICLP 2008. LNCS, vol. 5366, pp. 785–789. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  17. Walenstein, A., Jyoti, N., Li, J., Yang, Y., Lakhotia, A.: Problems creating task-relevant clone detection reference data. In: Proceedings of the 10th Working Conference on Reverse Engineering (WCRE 2003), pp. 285–294. IEEE (2003)

    Google Scholar 

  18. Walenstein, A., Lakhotia, A.: The software similarity problem in malware analysis. In: Duplication, Redundancy, and Similarity in Software. IBFI (2007)

    Google Scholar 

  19. Yoshida, N., Higo, Y., Kamiya, T., Kusumoto, S., Inoue, K.: On refactoring support based on code clone dependency relation. In: Proceedings of the 11th International Software Metrics Symposium (METRICS 2005), pp. 16–25. IEEE (2005)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Dandois, C., Vanhoof, W. (2012). Clones in Logic Programs and How to Detect Them. In: Vidal, G. (eds) Logic-Based Program Synthesis and Transformation. LOPSTR 2011. Lecture Notes in Computer Science, vol 7225. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-32211-2_7

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-32211-2_7

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-32210-5

  • Online ISBN: 978-3-642-32211-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics