skip to main content
research-article

Synthesizing iterators from abstraction functions

Published:26 September 2012Publication History
Skip Abstract Section

Abstract

A technique for synthesizing iterators from declarative abstraction functions written in a relational logic specification language is described. The logic includes a transitive closure operator that makes it convenient for expressing reachability queries on linked data structures. Some optimizations, including tuple elimination, iterator flattening, and traversal state reduction, are used to improve performance of the generated iterators.

A case study demonstrates that most of the iterators in the widely used JDK Collections classes can be replaced with code synthesized from declarative abstraction functions. These synthesized iterators perform competitively with the hand-written originals.

In a user study the synthesized iterators always passed more test cases than the hand-written ones, were almost always as efficient, usually took less programmer effort, and were the qualitative preference of all participants who provided free-form comments.

References

  1. J. Bloch. Effective Java. Addison-Wesley, Reading, Mass., 2001.Google ScholarGoogle Scholar
  2. L. Burdy, Y. Cheon, D. Cok, M. D. Ernst, J. R. Kiniry, G. T. Leavens, K. R. M. Leino, and E. Poll. An overview of JML tools and applications. Software Tools for Technology Transfer, 7(3): 212--232, June 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Y. Cheon. A Runtime Assertion Checker for the Java Modeling Language. PhD thesis, Department of Computer Science, Iowa State University, Apr. 2003.Google ScholarGoogle Scholar
  4. T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein. Introduction to Algorithms. The MIT Press and McGraw-Hill, 2nd edition, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. B. Demsky, C. Cadar, D. Roy, and M. C. Rinard. Efficient specification-assisted error localization. In WODA, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  6. G. Dennis. A Relational Framework for Bounded Program Verification. PhD thesis, MIT, 2009.Google ScholarGoogle Scholar
  7. A. Gesar, H. Hussmann, and A. Muck. A compiler for a class of conditional term rewriting systems. In Kaplan and Jouannaud {19}.Google ScholarGoogle Scholar
  8. ECOOP, volume 1628 of LNCS, 1999. Springer-Verlag.Google ScholarGoogle Scholar
  9. P. Hawkins, A. Aiken, K. Fisher, M. Rinard, and M. Sagiv. Data representation synthesis. In PLDI, June 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. J. Henkel and A. Diwan. Discovering algebraic specifications from Java classes. In ECOOP. July 2003. ISBN 3-540-40531-3.Google ScholarGoogle Scholar
  11. T. Heuillard. Compiling conditional rewriting systems. In Kaplan and Jouannaud {19}.Google ScholarGoogle Scholar
  12. C. A. R. Hoare. Proof of correctness of data representations. Acta Informatica, 1(4): 271--281, Dec. 1972.Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. S. S. Huan, D. Zook, and Y. Smaragdakis. Domain-specific languages and program generation with Meta-AspectJ. TOSEM, 18(2), Oct. 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. D. Jackson. Software Abstractions: Logic, Language, and Analysis. The MIT Press, revised edition, Jan. 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. B. Jacobs, E. Meijer, F. Piessens, and W. Schulte. Iterators revisited: proof rules and implementation. In Formal Techniques for Java-like Programs (FTfJP), 2005.Google ScholarGoogle Scholar
  16. L. Jadoul, L. Duponcheel, and W. Van Puymbroeck. An algebraic data type specification language and its rapid prototyping environment. In ICSE, May 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. P. Jalote. Synthesizing implementations of abstract data types from axiomatic specifications. Software---Practice & Experience, 17(11), Nov. 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. K. D. Jones. A Semantics for a Larch/Modula-3 Interface Language. In Workshop on Larch. July 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Proceedings of the 1st International Workshop on Term Rewriting Systems, volume 308 of LNCS, 1988. Springer-Verlag.Google ScholarGoogle Scholar
  20. T. Kühne. Internal iteration externalized. In Guerraoui {8}.Google ScholarGoogle Scholar
  21. V. Kuncak. Modular Data Structure Verification. PhD thesis, MIT, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. R. Laemmel and S. P. Jones. Scrap your boilerplate: a practical approach to generic programming. In TLDI, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. G. T. Leavens, A. L. Baker, and C. Ruby. Preliminary design of JML: A behavioral interface specification language for Java. Technical Report 98-06u, Iowa State University, Apr. 2003. URL http://www.jmlspecs.org.Google ScholarGoogle Scholar
  24. K. R. M. Leino. Data groups: specifying the modification of extended state. In OOPSLA, Oct. 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. K. R. M. Leino and A. Milicevic. Program extrapolation with Jennisys. Technical Report KRML219, Microsoft Research, 2012. URL http://research.microsoft.com/pubs/158573/krml219.pdf.Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. R. Lencevicius, U. Hölzle, and A. K. Singh. Query-based debugging of object-oriented programs. In OOPSLA, Oct. 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. R. Lencevicius, U. Hölzle, and A. K. Singh. Dynamic query-based debugging. In Guerraoui {8}, pages 135--160. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. K. J. Lieberherr. Adaptive Object-Oriented Software: The Demeter Method with Propagation Patterns. PWS, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. J. Liu and A. C. Myers. JMatch: Iterable Abstract Pattern Matching for Java. In PADL, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. J. Liu, A. Kimball, and A. C. Myers. Interruptible iterators. In POPL, Jan. 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. A. Milicevic, D. Rayside, K. Yessenov, and D. Jackson. Unifying execution of imperative and declarative code. In ICSE, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. C. Morgan. Programming from Specifications. Prentice-Hall, Inc., 2nd edition, 1998. First edition 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. S. Murer, S. Omohundro, D. Stoutamire, and C. Szypersky. Iteration abstraction in Sather. TOPLAS, 18(1), 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. M. Odersky, L. Spoon, and B. Venners. Programming in Scala. Artima, Nov. 2008.Google ScholarGoogle Scholar
  35. C. Pacheco, S. K. Lahiri, M. D. Ernst, and T. Ball. Feedback-directed random test generation. In ICSE, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. A. Potanin, J. Noble, and R. Biddle. Checking ownership and confinement. Concurrency and Computation: Practice and Experience, 16(7): 671--687, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. V. K. Proulx and W. Jossey. Unit test support for Java via reflection and annotations. In Principles and Practice of Programming in Java, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. D. Rayside, Z. Benjamin, R. Singh, J. P. Near, A. Milicevic, and D. Jackson. Equality and hashing for (almost) free: Generating implementations from abstraction functions. In ICSE, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. D. Rayside, A. Milicevic, K. Yessenov, G. Dennis, and D. Jackson. Agile specifications. In Proceedings of Onward'09, Oct. 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. C. Reichenbach, N. Immerman, Y. Smaragdakis, E. E. Aftandilian, and S. Z. Guyer. What can the GC compute efficiently? A language for heap assertions at GC time. In OOPSLA, Oct. 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. H. Samimi, E. D. Aung, and T. Millstein. Falling back on executable specifications. In ECOOP. June 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Y. Smaragdakis and D. Batory. DiSTiL: a Transformation Library for Data Structures. In DSL, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. M. K. Srivas. Automatic synthesis of implementations for abstract data types from algebraic specifications. PhD thesis, MIT, 1982.Google ScholarGoogle Scholar
  44. E. Torlak and D. Jackson. Kodkod: A relational model finder. In TACAS. Mar. 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. M. T. Vandevoorde and J. V. Guttag. Using specialized procedures and specification-based analysis to reduce the runtime costs of modularity. In FSE, Dec. 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. M. Vaziri, F. Tip, S. Fink, and J. Dolby. Declarative object identity using relation types. In ECOOP. July 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. P. Wadler. Deforestation: transforming programs to eliminate trees. TCS, 73: 231--248, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. D. Willis, D. J. Pearce, and J. Noble. Efficient object querying for Java. In ECOOP. July 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. K. Yessenov. A light-weight specification language for bounded program verification. Master's thesis, MIT, May 2009.Google ScholarGoogle Scholar
  50. K. Zee, V. Kuncak, and M. Rinard. Full functional verification of linked data structures. In PLDI, June 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Synthesizing iterators from abstraction functions

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 48, Issue 3
      GPCE '12
      March 2013
      140 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2480361
      Issue’s Table of Contents
      • cover image ACM Conferences
        GPCE '12: Proceedings of the 11th International Conference on Generative Programming and Component Engineering
        September 2012
        148 pages
        ISBN:9781450311298
        DOI:10.1145/2371401

      Copyright © 2012 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 26 September 2012

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!