Skip to main content

Towards a Normal Form for Mercury Programs

  • Conference paper
Book cover Logic-Based Program Synthesis and Transformation (LOPSTR 2007)

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

Abstract

In this work we define a program transformation that normalises a Mercury program by reordering clauses, body goals, and predicate arguments. The transformation, which preserves the well-modedness and determinism characteristics of the program, aims at reducing the complexity of performing a search for duplicated or similar code fragments between programs. In previous work, we have defined an analysis that searches for such duplicated functionality basically by pairwise comparing atoms and goals. While feasible in theory, the number of permutations to perform during the search renders it hard if not impossible to use in practice. We conjecture that the transformation to normal form, defined in this work, allows to substantially reduce the number of permutations, and hence the complexity of the search.

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. Chen, X., Francia, B., Li, M., McKinnon, B., Seker, A.: Shared information and program plagiarism detection. IEEE Transactions on Information Theory 50(7), 1545–1551 (2004)

    Article  MathSciNet  MATH  Google Scholar 

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

    Article  Google Scholar 

  3. Kontogiannis, K.A., Demori, R., Merlo, E., Galler, M., Bernstein, M.: Pattern matching for clone and concept detection. In: Reverse engineering, pp. 77–108 (1996)

    Google Scholar 

  4. Mycroft, A., O’Keefe, R.A.: A polymorphic type system for Prolog. Artificial Intelligence 23, 295–307 (1984)

    Article  MathSciNet  MATH  Google Scholar 

  5. Univ. of Melbourne. Mercury language reference manual (2006)

    Google Scholar 

  6. Overton, D., Somogyi, Z., Stuckey, P.: Constraint-based mode analysis of Mercury. In: Proceedings of the 4th ACM SIGPLAN international conference on Principles and practice of declarative programming, New York, USA, 2002, pp. 109–120. ACM Press, New York (2002)

    Google Scholar 

  7. Overton, D., Somogyi, Z., Stuckey, P.J.: Constraint-based mode analysis of Mercury. In: Kirchner, C. (ed.) Proceedings of the Fourth International Conference on Principles and Practice of Declarative Programming, pp. 109–120. ACM Press, New York (2002)

    Google Scholar 

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

  9. Somogyi, Z., Henderson, H., Conway, T.: The execution algorithm of Mercury, an efficient purely declarative logic programming language. Journal of Logic Programming 29(1) (1996)

    Google Scholar 

  10. 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 

  11. Winstead, J., Evans, D.: Towards differential program analysis. In: Proceedings of the 2003 Workshop on Dynamic Analysis (2003)

    Google Scholar 

  12. Wise. YAP3: Improved detection of similarities in computer program and other texts. SIGCSEB: SIGCSE Bulletin (ACM Special Interest Group on Computer Science Education), 28 (1996)

    Google Scholar 

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

    Article  Google Scholar 

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

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2008 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Degrave, F., Vanhoof, W. (2008). Towards a Normal Form for Mercury Programs. In: King, A. (eds) Logic-Based Program Synthesis and Transformation. LOPSTR 2007. Lecture Notes in Computer Science, vol 4915. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-78769-3_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-78769-3_4

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-78768-6

  • Online ISBN: 978-3-540-78769-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics