skip to main content
research-article

Synthesizing iterators from abstraction functions

Published: 26 September 2012 Publication History

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.
[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.
[3]
Y. Cheon. A Runtime Assertion Checker for the Java Modeling Language. PhD thesis, Department of Computer Science, Iowa State University, Apr. 2003.
[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.
[5]
B. Demsky, C. Cadar, D. Roy, and M. C. Rinard. Efficient specification-assisted error localization. In WODA, 2004.
[6]
G. Dennis. A Relational Framework for Bounded Program Verification. PhD thesis, MIT, 2009.
[7]
A. Gesar, H. Hussmann, and A. Muck. A compiler for a class of conditional term rewriting systems. In Kaplan and Jouannaud {19}.
[8]
ECOOP, volume 1628 of LNCS, 1999. Springer-Verlag.
[9]
P. Hawkins, A. Aiken, K. Fisher, M. Rinard, and M. Sagiv. Data representation synthesis. In PLDI, June 2011.
[10]
J. Henkel and A. Diwan. Discovering algebraic specifications from Java classes. In ECOOP. July 2003. ISBN 3-540-40531-3.
[11]
T. Heuillard. Compiling conditional rewriting systems. In Kaplan and Jouannaud {19}.
[12]
C. A. R. Hoare. Proof of correctness of data representations. Acta Informatica, 1(4): 271--281, Dec. 1972.
[13]
S. S. Huan, D. Zook, and Y. Smaragdakis. Domain-specific languages and program generation with Meta-AspectJ. TOSEM, 18(2), Oct. 2008.
[14]
D. Jackson. Software Abstractions: Logic, Language, and Analysis. The MIT Press, revised edition, Jan. 2012.
[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.
[16]
L. Jadoul, L. Duponcheel, and W. Van Puymbroeck. An algebraic data type specification language and its rapid prototyping environment. In ICSE, May 1989.
[17]
P. Jalote. Synthesizing implementations of abstract data types from axiomatic specifications. Software---Practice & Experience, 17(11), Nov. 1987.
[18]
K. D. Jones. A Semantics for a Larch/Modula-3 Interface Language. In Workshop on Larch. July 1992.
[19]
Proceedings of the 1st International Workshop on Term Rewriting Systems, volume 308 of LNCS, 1988. Springer-Verlag.
[20]
T. Kühne. Internal iteration externalized. In Guerraoui {8}.
[21]
V. Kuncak. Modular Data Structure Verification. PhD thesis, MIT, 2007.
[22]
R. Laemmel and S. P. Jones. Scrap your boilerplate: a practical approach to generic programming. In TLDI, 2003.
[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.
[24]
K. R. M. Leino. Data groups: specifying the modification of extended state. In OOPSLA, Oct. 1998.
[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.
[26]
R. Lencevicius, U. Hölzle, and A. K. Singh. Query-based debugging of object-oriented programs. In OOPSLA, Oct. 1997.
[27]
R. Lencevicius, U. Hölzle, and A. K. Singh. Dynamic query-based debugging. In Guerraoui {8}, pages 135--160.
[28]
K. J. Lieberherr. Adaptive Object-Oriented Software: The Demeter Method with Propagation Patterns. PWS, 1996.
[29]
J. Liu and A. C. Myers. JMatch: Iterable Abstract Pattern Matching for Java. In PADL, 2003.
[30]
J. Liu, A. Kimball, and A. C. Myers. Interruptible iterators. In POPL, Jan. 2006.
[31]
A. Milicevic, D. Rayside, K. Yessenov, and D. Jackson. Unifying execution of imperative and declarative code. In ICSE, 2011.
[32]
C. Morgan. Programming from Specifications. Prentice-Hall, Inc., 2nd edition, 1998. First edition 1990.
[33]
S. Murer, S. Omohundro, D. Stoutamire, and C. Szypersky. Iteration abstraction in Sather. TOPLAS, 18(1), 1996.
[34]
M. Odersky, L. Spoon, and B. Venners. Programming in Scala. Artima, Nov. 2008.
[35]
C. Pacheco, S. K. Lahiri, M. D. Ernst, and T. Ball. Feedback-directed random test generation. In ICSE, 2007.
[36]
A. Potanin, J. Noble, and R. Biddle. Checking ownership and confinement. Concurrency and Computation: Practice and Experience, 16(7): 671--687, 2004.
[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.
[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.
[39]
D. Rayside, A. Milicevic, K. Yessenov, G. Dennis, and D. Jackson. Agile specifications. In Proceedings of Onward'09, Oct. 2009.
[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.
[41]
H. Samimi, E. D. Aung, and T. Millstein. Falling back on executable specifications. In ECOOP. June 2010.
[42]
Y. Smaragdakis and D. Batory. DiSTiL: a Transformation Library for Data Structures. In DSL, 1997.
[43]
M. K. Srivas. Automatic synthesis of implementations for abstract data types from algebraic specifications. PhD thesis, MIT, 1982.
[44]
E. Torlak and D. Jackson. Kodkod: A relational model finder. In TACAS. Mar. 2007.
[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.
[46]
M. Vaziri, F. Tip, S. Fink, and J. Dolby. Declarative object identity using relation types. In ECOOP. July 2007.
[47]
P. Wadler. Deforestation: transforming programs to eliminate trees. TCS, 73: 231--248, 1990.
[48]
D. Willis, D. J. Pearce, and J. Noble. Efficient object querying for Java. In ECOOP. July 2006.
[49]
K. Yessenov. A light-weight specification language for bounded program verification. Master's thesis, MIT, May 2009.
[50]
K. Zee, V. Kuncak, and M. Rinard. Full functional verification of linked data structures. In PLDI, June 2008.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

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
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 26 September 2012
Published in SIGPLAN Volume 48, Issue 3

Check for updates

Author Tags

  1. Java
  2. abstraction functions
  3. alloy
  4. iterator
  5. synthesis

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)5
  • Downloads (Last 6 weeks)0
Reflects downloads up to 16 Jan 2025

Other Metrics

Citations

Cited By

View all

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media