Skip to main content

Assertion-Directed Precondition Synthesis for Loops over Data Structures

  • Conference paper
  • First Online:
Dependable Software Engineering: Theories, Tools, and Applications (SETTA 2015)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 9409))

Abstract

Program verification typically generates verification conditions for a program to be proven and then uses a theorem prover to prove their correctness. These verification conditions are normally generated by means of weakest-precondition calculus. Nevertheless, the weakest-precondition calculus faces a big challenge when dealing with loops. In this paper, we propose a framework that automatically generates preconditions for loops that iterate over commonly-used data structures. The preconditions are generated based on given assertions of loops and they are proved to be strong enough to ensure those given assertions hold. The data structures dealt with in our framework include one-dimensional arrays, acyclic singly-linked lists, doubly-linked lists and static lists. Such loops usually achieve their final results by focusing on one element in each iteration. In many such cases, the given assertion and the corresponding precondition of the loop separately reflect the part and the whole or vice versa. Inspired by this, our framework automatically generates precondition candidates for loops by transforming a given assertion. Then the framework uses the SMT solver Z3 and the weakest-precondition calculator for non-loop statements provided in the interactive code-verification tool Accumulator to check whether they are strong enough to prove the given assertion. The framework has been integrated into the tool Accumulator to generate suitable preconditions for loops, which greatly relieves the burden of manually providing preconditions for loops.

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. Berghammer, R.: Soundness of a purely syntactical formalization of weakest preconditions. Electronic Notes in Theoretical Computer Science 35 (2000)

    Google Scholar 

  2. Flanagan, C., Saxe, J.B.: Avoiding exponential explosion: Generating compact verification conditions. In: ACM SIGPLAN Notices. Volume 36, ACM (2001)

    Google Scholar 

  3. Barnett, M., Leino, K.R.M.: Weakest-precondition of unstructured programs. In: ACM SIGSOFT Software Engineering Notes. Volume 31, ACM (2005)

    Google Scholar 

  4. Leino, K.R.M.: Efficient weakest preconditions. Information Processing Letters 93(6), 281–288 (2005)

    Article  MathSciNet  MATH  Google Scholar 

  5. Jager, I., Brumley, D.: Efficient directionless weakest preconditions. Technical report, CMU-CyLab-10-002, CMU, CyLab (2010)

    Google Scholar 

  6. Jianhua, Z., Xuandong, L.: Scope logic: an extension to hoare logic for pointers and recursive data structures. In: Liu, Z., Woodcock, J., Zhu, H. (eds.) ICTAC 2013. LNCS, vol. 8049, pp. 409–426. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

  7. de Moura, L., Bjørner, N.S.: Z3: an efficient SMT solver. In: Ramakrishnan, C.R., Rehof, J. (eds.) TACAS 2008. LNCS, vol. 4963, pp. 337–340. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  8. Dijkstra, E.W.: Guarded commands, nondeterminacy and formal derivation of programs. Commun. ACM 18(8), 453–457 (1975)

    Article  MathSciNet  MATH  Google Scholar 

  9. Zhai, J., Wang, H., Zhao, J.: Post-condition-directed invariant inference for loops over data structures. In: 2014 IEEE Eighth International Conference on Software Security and Reliability-Companion (SERE-C), IEEE (2014)

    Google Scholar 

  10. Mraihi, O., Ghardallou, W., Louhichi, A., Labed Jilani, L., Bsaies, K., Mili, A.: Computing preconditions and postconditions of while loops. In: Cerone, A., Pihlajasaari, P. (eds.) ICTAC 2011. LNCS, vol. 6916, pp. 173–193. Springer, Heidelberg (2011)

    Chapter  Google Scholar 

  11. Mraihi, O., Louhichi, A., Jilani, L.L., Desharnais, J., Mili, A.: Invariant assertions, invariant relations, and invariant functions. Volume 78, 1212–1239 Elsevier (2013)

    Google Scholar 

  12. Chin, W.N., David, C., Nguyen, H.H., Qin, S.: Automated verification of shape, size and bag properties via user-defined predicates in separation logic. Sci. Comput. Program. 77(9), 1006–1036 (2012)

    Article  MATH  Google Scholar 

  13. Qin, S., He, G., Luo, C., Chin, W.N., Chen, X.: Loop invariant synthesis in a combined abstract domain. Journal of Symbolic Computation 50, 386–408 (2013)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Juan Zhai .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2015 Springer International Publishing Switzerland

About this paper

Cite this paper

Zhai, J., Wang, H., Zhao, J. (2015). Assertion-Directed Precondition Synthesis for Loops over Data Structures. In: Li, X., Liu, Z., Yi, W. (eds) Dependable Software Engineering: Theories, Tools, and Applications. SETTA 2015. Lecture Notes in Computer Science(), vol 9409. Springer, Cham. https://doi.org/10.1007/978-3-319-25942-0_17

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-25942-0_17

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-25941-3

  • Online ISBN: 978-3-319-25942-0

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics