Kleene Algebra with Tests and Coq Tools for while Programs

  • Damien Pous
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7998)


We present a Coq library about Kleene algebra with tests, including a proof of their completeness over the appropriate notion of languages, a decision procedure for their equational theory, and tools for exploiting hypotheses of a certain kind in such a theory.

Kleene algebra with tests make it possible to represent if-then-else statements and while loops in imperative programming languages. They were actually introduced as an alternative to propositional Hoare logic.

We show how to exploit the corresponding Coq tools in the context of program verification by proving equivalences of while programs, correctness of some standard compiler optimisations, Hoare rules for partial correctness, and a particularly challenging equivalence of flowchart schemes.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Allen, S.F., Constable, R.L., Howe, D.J., Aitken, W.E.: The semantics of reflected proof. In: Proc. LICS, pp. 95–105. IEEE Computer Society (1990)Google Scholar
  2. 2.
    Almeida, J.B., Moreira, N., Pereira, D., de Sousa, S.M.: Partial derivative automata formalized in Coq. In: Domaratzki, M., Salomaa, K. (eds.) CIAA 2010. LNCS, vol. 6482, pp. 59–68. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  3. 3.
    Angus, A., Kozen, D.: Kleene algebra with tests and program schematology. Technical Report TR2001-1844, CS Dpt, Cornell University (July 2001)Google Scholar
  4. 4.
    Antimirov, V.M.: Partial derivatives of regular expressions and finite automaton constructions. TCS 155(2), 291–319 (1996)MathSciNetzbMATHCrossRefGoogle Scholar
  5. 5.
    Armstrong, A., Struth, G.: Automated reasoning in higher-order regular algebra. In: Kahl, W., Griffin, T.G. (eds.) RAMICS 2012. LNCS, vol. 7560, pp. 66–81. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  6. 6.
    Asperti, A.: A compact proof of decidability for regular expression equivalence. In: Beringer, L., Felty, A. (eds.) ITP 2012. LNCS, vol. 7406, pp. 283–298. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  7. 7.
    Bertot, Y., Gonthier, G., Biha, S.O., Pasca, I.: Canonical big operators. In: Mohamed, O.A., Muñoz, C., Tahar, S. (eds.) TPHOLs 2008. LNCS, vol. 5170, pp. 86–101. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  8. 8.
    Boyer, R., Moore, J.: Metafunctions: proving them correct and using them efficiently as new proof procedures. In: The Correctness Problem in Computer Science. Academic Press, NY (1981)Google Scholar
  9. 9.
    Braibant, T., Pous, D.: An efficient Coq tactic for deciding Kleene algebras. In: Kaufmann, M., Paulson, L.C. (eds.) ITP 2010. LNCS, vol. 6172, pp. 163–178. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  10. 10.
    Brzozowski, J.A.: Derivatives of regular expressions. J. ACM 11(4), 481–494 (1964)MathSciNetzbMATHCrossRefGoogle Scholar
  11. 11.
    Cohen, E.: Hypotheses in Kleene algebra. Technical report, Bellcore, Morristown, N.J (1994)Google Scholar
  12. 12.
    Coquand, T., Siles, V.: A decision procedure for regular expression equivalence in type theory. In: Jouannaud, J.-P., Shao, Z. (eds.) CPP 2011. LNCS, vol. 7086, pp. 119–134. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  13. 13.
    Foster, S., Struth, G.: Automated analysis of regular algebra. In: Gramlich, B., Miller, D., Sattler, U. (eds.) IJCAR 2012. LNCS, vol. 7364, pp. 271–285. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  14. 14.
    Grégoire, B., Mahboubi, A.: Proving equalities in a commutative ring done right in Coq. In: Hurd, J., Melham, T. (eds.) TPHOLs 2005. LNCS, vol. 3603, pp. 98–113. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  15. 15.
    Hardin, C., Kozen, D.: On the elimination of hypotheses in Kleene algebra with tests. Technical Report TR2002-1879, CS Dpt, Cornell University (October 2002)Google Scholar
  16. 16.
    Hoare, C.A.R.: An axiomatic basis for computer programming. Commun. ACM 12(10), 576–580 (1969)zbMATHCrossRefGoogle Scholar
  17. 17.
    Komendantsky, V.: Reflexive toolbox for regular expression matching: verification of functional programs in Coq+ssreflect. In: Proc. PLPV, pp. 61–70. ACM (2012)Google Scholar
  18. 18.
    Kozen, D.: A completeness theorem for Kleene algebras and the algebra of regular events. Inf. and Comp. 110(2), 366–390 (1994)MathSciNetzbMATHCrossRefGoogle Scholar
  19. 19.
    Kozen, D.: Kleene algebra with tests. Transactions on Programming Languages and Systems 19(3), 427–443 (1997)CrossRefGoogle Scholar
  20. 20.
    Kozen, D.: Typed Kleene algebra, TR98-1669, CS Dpt. Cornell University (1998)Google Scholar
  21. 21.
    Kozen, D.: On Hoare logic and Kleene algebra with tests. ACM Trans. Comput. Log. 1(1), 60–76 (2000)MathSciNetCrossRefGoogle Scholar
  22. 22.
    Kozen, D.: On the coalgebraic theory of Kleene algebra with tests. Technical Report  CIS, Cornell University (March 2008),
  23. 23.
    Kozen, D., Patron, M.-C.: Certification of compiler optimizations using Kleene algebra with tests. In: Palamidessi, C., et al. (eds.) CL 2000. LNCS (LNAI), vol. 1861, pp. 568–582. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  24. 24.
    Kozen, D., Smith, F.: Kleene algebra with tests: Completeness and decidability. In: van Dalen, D., Bezem, M. (eds.) CSL 1996. LNCS, vol. 1258, pp. 244–259. Springer, Heidelberg (1997)CrossRefGoogle Scholar
  25. 25.
    Krauss, A., Nipkow, T.: Proof pearl: Regular expression equivalence and relation algebra. JAR 49(1), 95–106 (2012)MathSciNetCrossRefGoogle Scholar
  26. 26.
    Manna, Z.: Mathematical Theory of Computation. McGraw-Hill (1974)Google Scholar
  27. 27.
    Moreira, N., Pereira, D., de Sousa, S.M.: Deciding regular expressions (In-) equivalence in Coq. In: Kahl, W., Griffin, T.G. (eds.) RAMICS 2012. LNCS, vol. 7560, pp. 98–113. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  28. 28.
    Pereira, D., Moreira, N.: KAT and PHL in Coq. Comput. Sci. Inf. Syst. 5(2), 137–160 (2008)CrossRefGoogle Scholar
  29. 29.
    Pous, D.: Untyping typed algebraic structures and colouring proof nets of cyclic linear logic. In: Dawar, A., Veith, H. (eds.) CSL 2010. LNCS, vol. 6247, pp. 484–498. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  30. 30.
    Pous, D.: RelationAlgebra: Coq library containing all material presented in this paper (December 2012),
  31. 31.
    Thompson, K.: Regular expression search algorithm. C. ACM 11, 419–422 (1968)zbMATHCrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • Damien Pous
    • 1
  1. 1.CNRS – LIP, ENS Lyon, UMR 5668France

Personalised recommendations