Assertion-Directed Precondition Synthesis for Loops over Data Structures

Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, 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.

Keywords

Loop Variable Static List Memory Unit Program Point Loop Body 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Berghammer, R.: Soundness of a purely syntactical formalization of weakest preconditions. Electronic Notes in Theoretical Computer Science 35 (2000)Google Scholar
  2. 2.
    Flanagan, C., Saxe, J.B.: Avoiding exponential explosion: Generating compact verification conditions. In: ACM SIGPLAN Notices. Volume 36, ACM (2001)Google Scholar
  3. 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. 4.
    Leino, K.R.M.: Efficient weakest preconditions. Information Processing Letters 93(6), 281–288 (2005)MathSciNetCrossRefMATHGoogle Scholar
  5. 5.
    Jager, I., Brumley, D.: Efficient directionless weakest preconditions. Technical report, CMU-CyLab-10-002, CMU, CyLab (2010)Google Scholar
  6. 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) CrossRefGoogle Scholar
  7. 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) CrossRefGoogle Scholar
  8. 8.
    Dijkstra, E.W.: Guarded commands, nondeterminacy and formal derivation of programs. Commun. ACM 18(8), 453–457 (1975)MathSciNetCrossRefMATHGoogle Scholar
  9. 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. 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) CrossRefGoogle Scholar
  11. 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. 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)CrossRefMATHGoogle Scholar
  13. 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)MathSciNetCrossRefMATHGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2015

Authors and Affiliations

  1. 1.State Key Laboratory for Novel Software TechnologyNanjing UniversityNanjingChina
  2. 2.Software InstituteNanjing UniversityNanjingChina
  3. 3.Department of Computer Science and TechnologyNanjing UniversityNanjingChina

Personalised recommendations