Skip to main content
Log in

Abstract

Checking whether a given formula is an invariant at a given program location (especially, inside a loop) can be quite nontrivial even for simple loop programs, given that it is in general an undecidable property. This is especially the case if the given formula is not an inductive loop invariant, as most automated techniques can only check or generate inductive loop invariants. In this paper, conditions are identified on simple loops and formulas when this check can be performed automatically. A general theorem is proved which gives a necessary and sufficient condition for a formula to be an invariant under certain restrictions on a loop. As a byproduct of this analysis, a new kind of loop invariant inside the loop body, called inside-loop invariant, is proposed. Such an invariant is more general than an inductive loop invariant typically used in the Floyd-Hoare axiomatic approach to program verification. The use of such invariants for program debugging is explored; it is shown that such invariants can be more useful than traditional inductive loop invariants especially when one is interested in checking extreme/side conditions such as underflow, accessing array/collection data structures outside the range, divide by zero, etc.

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.

Similar content being viewed by others

References

  1. Cousot P and Cousot R, Abstract interpretation: A unified lattice model for static analysis of program by construction or approximation of fixpoints, 4th POPL, 1977.

    Google Scholar 

  2. Floyd R W, Assigning meanings to programs, Proceedings of Symphosium on Applied Mathematics, 1967, 19–37.

    Google Scholar 

  3. Hoare C A R, An axiomatic basis for computer programming, Communications of the ACM, 1969, 12(10): 576–585.

    Article  MATH  Google Scholar 

  4. Rodriguez-Carbonell E and Kapur D, Automatic generation of polynomial invariants of bounded degree using abstract interpretation, Science of Computer Programming, 2007, 64(1): 54–75

    Article  MathSciNet  MATH  Google Scholar 

  5. Cousot P, Halbwachs, N.: Automatic Discovery of Linear Restraints among Variables of a Program, 5th ACM POPL, 1978, 84–97.

    Google Scholar 

  6. Miné A, Weakly relational numerical abstract domains, PhD thesis, École Polytechnique, Paris, France, 2005.

    Google Scholar 

  7. Rodriguez-Carbonell E and Kapur D, Generating all polynomial invariants in simple loops, Journal of Symbolic Computation, 2007, 42: 443–476.

    Article  MathSciNet  MATH  Google Scholar 

  8. Kapur D, A Quantifier Elimination based Heuristic for Automatically Generating Inductive Assertions for Programs, Journal of Systems Science and Complexity, 2006, 19(3): 307–330.

    Article  MathSciNet  MATH  Google Scholar 

  9. Bradley A R and Manna Z, Verification constraint problems with strengthening, ICTAC, 2006, 35–49.

    Google Scholar 

  10. Chen Y, Xia B, Yang L, and Zhan N, Generating polynomial invariants with DISCOVERER and QEPCAD, Proceedings of Formal Methods and Hybrid Real-Time Systems’ 07 (the Festschrift Symposium for Dines Bjorner and Zhou Chaochen), 2007, 67–82.

    Chapter  Google Scholar 

  11. Colón M, Sankaranarayanan S, and Sipma H B, inear invariant generation using non-linear constraint solving, Proceedings of CAV 03, 2003, 420–432.

    Google Scholar 

  12. Sankaranarayanan S, Sipma H B, and Manna Z, Non-linear Loop Invariant Generation Using Grëobner Bases, ACM SIGPLAN Principles of Programming Languages (POPL), 2004, 318–329.

    Google Scholar 

  13. Xia B, Yang L, and Zhan N, Program verification by reduction to semialgebraic systems solving, Proceedings of ISoLA08, 2008, 277–291.

    Google Scholar 

  14. Ernst M D, Perkins J H, Guo P J, McCamant S, Pacheco C, Tschantz M S, and Xiao C, The Daikon system for dynamic detection of likely invariants, Science of Computer Programming, 2007, 69(1–3): 35–45.

    Article  MathSciNet  MATH  Google Scholar 

  15. Loeckx J and Sieber K, The Foundations of Program Verification, John Wiley & Sons Ltd. and B.G. Teubner, 1984.

    Google Scholar 

  16. Chen Y, Xia B, Yang L, Zhan N, and Zhou C, Discovering non-linear ranking functions by solving semi-algebraic systems, eds. by Jones C B, Liu Z, Woodcock J, Lecture Notes in Computer Science, 4711, Springer, 2007, 34–49.

  17. Podelski A and Rybalchenko A, A complete method for the synthesis of linear ranking functions, VMCAI 2004: Verification, Model Checking, and Abstract Interpretation, Lecture Notes in Computer Science, 2937, Springer, 2004, 239–251.

    Article  MathSciNet  Google Scholar 

  18. Tiwari A, Termination of linear programs, CAV: International Conference on Computer Aided Verification, 2004.

    Google Scholar 

  19. Wu B, Shen L, Bi Z, and Zeng Z, Termination of a class of the programs with polynomial guards, Proceedings of International Conference on Information Management and Engineering, 2009, 274–277.

    Google Scholar 

  20. Xia B, Yang L, Zhan N, and Zhang Z, Symbolic decision procedure for termination of linear programs, Formal Aspects of Computing (DOI:10.1007/s00165-009-0144-5), 2009.

    Google Scholar 

  21. Kapur D, Wu’s perspective on Theorem Proving with a recent application to Program Analysis. Invited talk presented at the International Conf. on Mathematics Mechanization, Beijing, China, 2009.

    Google Scholar 

  22. Cousot P, Proving program invariance and termination by parametric abstraction, lagrangian relaxation and semidefinite programming. VMCAI 2005: Verification, Model Checking, and Abstract Interpretation, Lecture Notes in Computer Science, 3385, Springer, 2005.

  23. Brown C W and QEPCAD B, a program for computing with semi-algebraic sets using CADs, ACM SIGSAM Bulletin, 2003, 37(4): 97–108.

    Article  MATH  Google Scholar 

  24. Bradley A R and Manna Z, Property-directed incremental invariant generation. Formal Aspects of Computing, 2008, 20(4–5): 379–405.

    Article  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Zhihai Zhang.

Additional information

The first author is supported by NSFC-90718041, NKBRPC-2005C B321902, and China Scholarship Council in China, and the second author is supported by the National Science Foundation award CCF-0729097.

This paper was recommended for publication by Editor Gao Xiaoshan.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Zhang, Z., Kapur, D. On invariant checking. J Syst Sci Complex 26, 470–482 (2013). https://doi.org/10.1007/s11424-013-1296-1

Download citation

  • Received:

  • Revised:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s11424-013-1296-1

Keywords

Navigation