Contract-Based Data Structure Repair Using Alloy

  • Razieh Nokhbeh Zaeem
  • Sarfraz Khurshid
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6183)


Contracts and specifications have long been used in object-oriented design, programming and testing to enhance reliability before software deployment. However, the use of specifications in deployed software is commonly limited to runtime checking where assertions form a basis for detecting incorrect program states to terminate the erroneous executions. This paper presents a contract-based approach for data structure repair, which allows repairing erroneous executions in deployed software by repairing erroneous states. The key novelty is the support for rich behavioral specifications, such as those that relate pre-states with post-states of the method to accurately specify expected behavior and hence to enable precise repair. The approach is based on the view of a specification as a non-deterministic implementation, which may permit a high degree of non-determinism. The key insight is to use any correct state mutations by an otherwise erroneous execution to prune the non-determinism in the specification, thereby transmuting the specification to an implementation that does not incur a prohibitively high performance penalty. While invariants, pre-conditions and post-conditions could be provided in different modeling languages, we leverage the Alloy tool-set, specifically the Alloy language and the Alloy Analyzer for systematically repairing erroneous states. Four different algorithms are presented and implemented in our data structure repair framework. Experiments using complex specifications show the approach holds much promise in increasing software reliability.


Data Structure Repair Programming by Contract Specifications Alloy 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Alloy home page,
  2. 2.
    Antlr parser generator home page,
  3. 3.
    Dacapo benchmarks home page,
  4. 4.
    Ext2 fsck manual page,
  5. 5.
  6. 6.
    Microsoft chkdsk manual page,
  7. 7.
    Sat4j home page,
  8. 8.
  9. 9.
    Boyapati, C., Khurshid, S., Marinov, D.: Korat: Automated testing based on Java predicates. In: Proc. International Symposium on Software Testing and Analysis, ISSTA (Jul 2002)Google Scholar
  10. 10.
    Bunke, H.: On a relation between graph edit distance and maximum common subgraph. Pattern Recognition Letters 18(9), 689–694 (1997)CrossRefMathSciNetGoogle Scholar
  11. 11.
    Demsky, B.: Data Structure Repair Using Goal-Directed Reasoning. PhD thesis, Massachusetts Institute of Technology (January 2006)Google Scholar
  12. 12.
    Demsky, B., Rinard, M.: Automatic detection and repair of errors in data structures. In: Proc. Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA (2003)Google Scholar
  13. 13.
    Elkarablieh, B.: Assertion-based Repair of Complex Data Structures. PhD thesis, University of Texas at Austin (2009)Google Scholar
  14. 14.
    Haugk, G., Lax, F., Royer, R., Williams, J.: The 5ESS(TM) switching system: Maintenance capabilities. AT&T Technical Journal 64(6 part 2) (1985)Google Scholar
  15. 15.
    Jackson, D.: Alloy: A lightweight object modeling notation. ACM Transactions on Software Engineering and Methodology (TOSEM) 11(2) (April 2002)Google Scholar
  16. 16.
    Jackson, D.: Software Abstractions: Logic, Language and Analysis. MIT Press, Cambridge (2006)Google Scholar
  17. 17.
    Jackson, D., Fekete, A.: Lightweight analysis of object interactions. In: Kobayashi, N., Pierce, B.C. (eds.) TACS 2001. LNCS, vol. 2215, p. 492. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  18. 18.
    Khurshid, S.: Generating Structurally Complex Tests from Declarative Constraints. PhD thesis, Dept. of Electrical Engineering and Computer Science, Massachusetts Institute of Technology (December 2003)Google Scholar
  19. 19.
    Khurshid, S., García, I., Suen, Y.L.: Repairing structurally complex data. In: 12th SPIN Workshop on Model Checking of Software, San Francisco, CA (August 2005)Google Scholar
  20. 20.
    Khurshid, S., Marinov, D.: TestEra: Specification-based testing of Java programs using SAT. Automated Software Engineering Journal (2004)Google Scholar
  21. 21.
    Krishnamurthi, S., Fisler, K., Dougherty, D.J., Yoo, D.: Alchemy: Transmuting base alloy specifications into implementations. In: The 16th ACM SIGSOFT International Symposium on Foundations of software engineering, pp. 158–169. ACM, New York (2008)CrossRefGoogle Scholar
  22. 22.
    Leavens, G.T., Baker, A.L., Ruby, C.: Preliminary design of JML: A behavioral interface specification language for Java. Technical Report TR 98-06i, Department of Computer Science, Iowa State University (1998)Google Scholar
  23. 23.
    Leavens, G.T., Baker, A.L., Ruby, C.: JML: a Java modeling language. In: Formal Underpinnings of Java Workshop (1998)Google Scholar
  24. 24.
    Liskov, B., Guttag, J.: Program Development in Java: Abstraction, Specification, and Object-Oriented Design. Addison-Wesley, Reading (2000)Google Scholar
  25. 25.
    Marinov, D., Khurshid, S.: TestEra: A novel framework for automated testing of Java programs. In: Proc. 16th Conference on Automated Software Engineering (ASE), San Diego, CA (November 2001)Google Scholar
  26. 26.
    Meyer, B.: Applying “design by contract”. IEEE Computer 25(10), 40–51 (1992)Google Scholar
  27. 27.
    Mourad, S., Andrews, D.: On the reliability of the IBM MVS/XA operating system. IEEE Transactions on Software Engineering 13(10) (1987)Google Scholar
  28. 28.
    Sanfeliu, A., Fu, K.-S.: Distance measure between attributed relational graphs for pattern recognition. IEEE Trans. Systems, Man and Cybernetics 13(3), 353–362 (1983)zbMATHGoogle Scholar
  29. 29.
    Torlak, E., Jackson, D.: Kodkod: A relational model finder. In: Grumberg, O., Huth, M. (eds.) TACAS 2007. LNCS, vol. 4424, pp. 632–647. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  30. 30.
    Widom, J., Ceri, S.: Active database systems: Triggers and rules for advanced database processing. Morgan Kaufmann Pub., San Francisco (1996)Google Scholar
  31. 31.
    Zaeem, R.N., Khurshid, S.: Introducing Specification-Based Data Structure Repair Using Alloy. In: Proc. International Conference on ASM Alloy B and Z, Orford, Québec, Canada, pp. 398–399 (2010)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Razieh Nokhbeh Zaeem
    • 1
  • Sarfraz Khurshid
    • 1
  1. 1.University of TexasAustinUSA

Personalised recommendations