Skip to main content
Log in

Automation of C Program Deductive Verification without Using Loop Invariants

  • Published:
Programming and Computer Software Aims and scope Submit manuscript

Abstract

Automation of C program verification is an important problem in modern software development. To solve this problem, the solution of the following problems must be automated: loop invariants, proof of verification conditions, and localization of errors in the case of invalid verification conditions. To this end, the C-lightVer system is under development in the Ershov Institute of Informatics Systems of the Siberian Branch of the Russian Academy of Sciences. This system uses an integrated approach to the automated deductive verification of C programs. This approach includes a symbolic method of verification of definite iterations for eliminating loop invariants, strategies for proving verification conditions, and a method for error localization. The symbolic method of verification of definite iterations is based on replacing the action of certain loops by the application of a special recursive function rep. The error localization method is based on matching the verification conditions to the source code and on generation of a report about the correspondence between the verification conditions and program fragments. Thus, the problem of automation of verification of C programs containing nested loops naturally arises. The application of the symbolic method of verification of definite iterations for such programs leads to a composition of the functions rep for outer and inner loops. A novel result obtained in this paper is a strategy of automation of proof of verification conditions for such programs. This strategy is based on induction on the index of iteration in the outer loop. To prove the induction step, another result obtained in this paper is used. This is a strategy for programs the specification of which contains functions with the concatenation property. The paper also describes strategies of error localization and modifications of the error localization method for the case of nested loops. These strategies are also used for verifying the loop properties that may indicate the presence of errors. As an example of applying the results obtained in this paper, automatic verification of insertion sort without loop invariants is considered.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1.

Similar content being viewed by others

REFERENCES

  1. Apt, K.R. and Olderog, E.-R., Assessing the success and impact of Hoare’s logic, Theories of Programming: The Life and Works of Tony Hoare, 2021, pp. 41–76.

  2. Hähnle, R., and Huisman, M., Deductive software verification: From pen-and-paper proofs to industrial tools, Comput. Software Sci. Lect. Notes Comput. Sci., 2019, vol. 10000. pp. 345–373.

    MATH  Google Scholar 

  3. Müller, P. and Shankar, N., The first fifteen years of the verified software project, Theories of Programming: The Life and Works of Tony Hoare, 2021, pp. 93–124.

  4. Furia, C.A., Meyer, B., and Velder, S., Loop invariants: Analysis, classification, and examples, ACM Comput. Surveys, 2014, vol. 46, no. 3, Article 34, pp. 1–51.

  5. Apt, K.R. and Olderog, E.-R., Fifty years of Hoare’s logic, Formal Aspects Comput., 2019, vol. 31, no. 6, pp. 751–807.

    Article  MathSciNet  Google Scholar 

  6. Hoare, C.A.R., An axiomatic basis for computer programming, Commun. ACM, 1969, vol. 12, pp. 576–580.

    Article  Google Scholar 

  7. Denney, E. and Fischer, B., Explaining verification conditions, Proc. AMAST 2008. Lect. Notes Comput. Sci., 2008, vol. 5140, pp. 145–159.

  8. Maryasov, I.V., Nepomniaschy, V.A., Promsky, A.V., and Kondratyev, D.A., Automatic C program verification based on mixed axiomatic semantics Autom. Control Comput. Sci., 2014, vol. 48, pp. 407–414.

  9. Kondratyev, D.A., Maryasov, I.V., and Nepomniaschy, V.A., The automation of C Program verification by the symbolic method of loop invariant elimination Autom. Control Comput. Sci.,vol. 53, 2019, pp. 653–662.

    Article  Google Scholar 

  10. Kondratyev, D., Maryasov, I., and Nepomniaschy, V., Towards automatic deductive verification of C programs over linear arrays, Proc. PSI 2019. Lect. Notes Comput. Sci., 2019, vol. 11964, pp. 232–242.

  11. Kondratyev, D.A. and Promsky, A.V., The complex approach of the C-lightVer system to the automated error localization in C-Programs, Autom. Control Comput. Sci., 2020, vol. 54, pp. 728–739.

    Article  Google Scholar 

  12. Nepomniaschy, V.A., Symbolic method of verification of definite iterations over altered data structures, Program. Comput. Software, 2005, vol. 31, pp. 1–9.

    Article  MathSciNet  Google Scholar 

  13. Moore, J.S., Milestones from the pure lisp theorem prover to ACL2, Formal Aspects Comput., 2019, vol. 31, pp. 699–732.

    Article  MathSciNet  Google Scholar 

  14. Myreen, M.O. Gordon, M.J.C., Transforming programs into recursive functions, Electron. Notes Theor. Comput. Sci., 2009, vol. 240 pp. 185–200.

    Article  Google Scholar 

  15. Blanc, R., Kuncak, V., Kneuss, E., and Suter, P., An overview of the Leon verification system: verification by translation to recursive functions, Proc. 4th Workshop on Scala. 2013. Article 1, pp. 1–10.

  16. Humenberger, A., Jaroschek, M., and Kovács, L., Invariant generation for multi-path loops with polynomial assignments, Proc. VMCAI 2018. Lect. Notes Comput. Sci., 2018, vol. 10747, pp. 226–246.

  17. Chakraborty, S., Gupta, A., and Unadkat, D., Inductive reasoning of array programs using difference invariants, Proc. of CAV 2021. Lect. Notes Comput. Sci., 2021, vol. 12760, pp. 911–935.

  18. Galeotti, J.P., Furia, C.A., May, E., Fraser, G., and Zeller, A., Inferring loop invariants by mutation, dynamic analysis, and static checking, IEEE Trans. Software Eng., 2015, vol. 41, no. 10, pp. 1019–1037.

    Article  Google Scholar 

  19. Srivastava, S., Gulwani, S., and Foster, J.S., Template-based program verification and program synthesis, Int. J. Software Tools Technol. Transfer, 2013, vol. 15, no. 5–6, pp. 497–518.

    Article  Google Scholar 

  20. Filliâtre, J.-C., Simpler proofs with decentralized invariants, J. Logical Algebraic Methods Program., 2021, vol. 121, Article ID: 100645.

  21. Johansson, M., Lemma discovery for induction, Proc. CICM 2019. Lect. Notes Comput. Sci., 2019, vol. 11617, pp. 125–139.

  22. Heras, J., Komendantskaya, E., Johansson, M., and Maclean, E., Proof-pattern recognition and lemma discovery in ACL2, Proc. LPAR 2013. Lect. Notes Comput. Sci., 2013, vol. 8312, pp. 389–406.

  23. Filliâtre, J.–C. and Magaud, N., Certification of sorting algorithms in the Coq system, Proc. conf. on “Theorem Proving in Higher Order Logics: Emerging Trends,” Nice, 1999.

  24. Imine, A. and Ranise, S., Building satisfiability procedures for verification: The case study of sorting algorithms, Proc. LOPSTR’03, 2003.

  25. Safari, M. and Huisman, M., A Generic approach to the verification of the permutation property of sequential and parallel swap-based sorting algorithms, Proc. IFM 2020. Lect. Notes Comput. Sci., 2020, vol. 12546, pp. 257–275.

  26. Tuerk, T., Local reasoning about while-loops, Proc. Theory Workshop at VSTTE 2010, 2010, pp. 29–39.

  27. Volkov, G., Mandrykin, M., and Efremov, D., Lemma functions for Frama-C: C programs as proofs, Proc. 2018 Ivannikov ISP RAS Open Conference, 2018, pp. 31–38.

  28. Blanchard, A., Loulergue, F., and Kosmatov, N., Towards full proof automation in Frama-C using auto-active verification, Proc. NFM 2019. Lect. Notes Comput. Sci., 2019, vol. 11460, pp. 88–105.

  29. Baudin, P., Bobot, F., Bühler, D., Correnson, L., Kirchner, F., Kosmatov, N., Maroneze, A., Perrelle, V., Prevosto, V., Signoles, J., and Williams, N., The dogged pursuit of bug-free C programs: the Frama-C software analysis platform, Commun. ACM, 2021, vol. 64, no. 8, pp. 56–68.

    Article  Google Scholar 

  30. de Angelis, E., Fioravanti, F., Pettorossi, A., and Proietti, M., Proving properties of sorting programs: A case study in Horn clause verification, Proc. HCVS/PERR 2019. Electron. Proc. Theor. Comput. Sci., 2019, vol. 296, pp. 48–75.

    Article  Google Scholar 

  31. Dailler, S., Hauzar, D., Marché, C., and Moy, Y., Instrumenting a weakest precondition calculus for counterexample generation, J. Logical Algebraic Methods Program., 2018, vol. 99, pp. 97–113.

    Article  MathSciNet  Google Scholar 

  32. Becker, B., Lourenço, C.B., and Marché, C., Explaining counterexamples with giant-step assertion checking, Proc. F-IDE 2021. Electron. Proc. Theor. Comput. Sci., 2021, vol. 338, pp. 82–88.

    Article  Google Scholar 

  33. Könighofer, R., Toegl, R., and Bloem, R., Automatic error localization for software using deductive verification, Proc. HVC 2014. Lect. Notes Comput. Sci., 2014, vol. 8855, pp. 92–98.

  34. Raad, A., Berdine, J., Dang, H.H., Dreyer, D., O’Hearn, P., and Villard, J., Local reasoning about the presence of bugs: Incorrectness separation logic, Proc. CAV 2020. Lect. Notes Comput. Sci., 2020, vol. 12225, pp. 225–252.

  35. de Gouw, S., de Boer, F.S., Bubel, R., Hähnle, R., Rot, J., and Steinhöfel, D., Verifying OpenJDK’s sort method for generic collections, J. Autom. Reasoning, 2019, vol. 62, no. 1, pp. 93–126.

    Article  MathSciNet  Google Scholar 

  36. Möller, B., O’Hearn, P., and Hoare, T., On algebra of program correctness and incorrectness, Proc. RAMiCS 2021. Lect. Notes Comput. Sci., 2021, vol. 13027, pp. 325–343.

  37. Grebing, S., Klamroth, J., and Ulbrich, M., Seamless Interactive Program Verification, Proc. VSTTE 2019. Lect. Notes Comput. Sci., 2020. vol. 12031, pp. 68–86.

  38. Dailler, S., Marché, C., and Moy, Y., Lightweight interactive proving inside an automatic program verifier, Proc. F-IDE 2018. Electron. Proc. in Theoretical Computer Science, 2018, vol. 284, pp. 1–15.

    Article  Google Scholar 

  39. Mandrykin, M.U. and Khoroshilov, A.V., Towards deductive verification of C programs with shared data, Program. Comput. Software, 2016, vol. 42, pp. 324–332.

    Article  Google Scholar 

  40. Efremov, D., Mandrykin, M., and Khoroshilov, A., Deductive verification of unmodified Linux kernel library functions, Proc. ISoLA 2018, Lect. Notes Comput. Sci., 2018, vol. 11245, pp. 216–234.

  41. de Carvalho, D., Hussain, R., Khan, A., Khazeev, M., Lee, JY., Masiagin, S., Mazzara, M., Mustafin, R., Naumchev, A., and Rivera, V., Teaching programming and design-by-contract, Proc. ICL 2018, Advances in Intelligent Systems and Computing, 2020, vol. 916, pp. 68–76.

  42. Khazeev, M., Mazzara, M., Aslam, H., and de Carvalho, D., Towards a broader acceptance of formal verification tools, Proc. ICL 2019. Advances in Intelligent Systems and Computing, 2020, vol . 1135, pp. 188–200.

  43. Sammler, M., Lepigre, R., Krebbers, R., Memarian, K., Dreyer, D., and Garg, D., RefinedC: Automating the foundational verification of C code with refined ownership types, Proc. 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation, 2021, pp. 158–174.

  44. Jiang, D., and Zhou, M., A comparative study of insertion sorting algorithm verification, Proc. 2017 IEEE 2nd Information Technology, Networking, Electronic and Automation Control Conference, 2017, pp. 321–325.

  45. Nepomniaschy, V.A., Anureev, I.S., Mikhailov, I.N., and Promskii, A.V., Towards verification of C programs. C-light language and its formal semantics, Program. Comput. Software, 28, 2002, pp. 314–323.

    Article  MathSciNet  Google Scholar 

  46. Nepomniaschy, V.A., Anureev, I.S., and Promskii, A.V., Towards verification of C programs: Axiomatic semantics of the C-kernel language, Program. Comput. Software, 29, 2003, pp. 338–350.

    Article  MathSciNet  Google Scholar 

  47. Anureev, I.S., Garanina, N.O., Lyakh, T.V., Rozov, A.S., Zyubin, V.E., and Gorlatch, S.P., Dedicative verification of Reflex programs, Program. Comput. Software, 2020, vol. 46, pp. 261–272.

    Article  MathSciNet  Google Scholar 

  48. Kondratyev, D.A., Automatic verification of insertion sorting. https://bitbucket.org/Kondratyev/verify-loops. Cited November 11, 2021.

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to D. A. Kondratyev.

Ethics declarations

The authors declare that they have no conflicts of interest.

Additional information

The paper is dedicated to my teacher, colleague, and coauthor Valery Aleksandrovich Nepomniaschy (1939–2021), the manuscript was finalized soon after he passed away.

Translated by A. Klimontovich

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Kondratyev, D.A., Nepomniaschy, V.A. Automation of C Program Deductive Verification without Using Loop Invariants. Program Comput Soft 48, 331–346 (2022). https://doi.org/10.1134/S036176882205005X

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1134/S036176882205005X

Navigation