Proofs of Randomized Algorithms in Coq

  • Philippe Audebaud
  • Christine Paulin-Mohring
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4014)


Randomized algorithms are widely used either for finding efficiently approximated solutions to complex problems, for instance primality testing, or for obtaining good average behavior, for instance in distributed computing. Proving properties of such algorithms requires subtle reasoning both on algorithmic and probabilistic aspects of the programs. Providing tools for the mechanization of reasoning is consequently an important issue. Our paper presents a new method for proving properties of randomized algorithms in a proof assistant based on higher-order logic. It is based on the monadic interpretation of randomized programs as probabilistic distribution [1]. It does not require the definition of an operational semantics for the language nor the development of a complex formalization of measure theory, but only use functionals and algebraic properties of the unit interval. Using this model, we show the validity of general rules for estimating the probability for a randomized algorithm to satisfy certain properties, in particular in the case of general recursive functions.

We apply this theory for formally proving a program implementing a Bernoulli distribution from a coin flip and the termination of a random walk. All the theories and results presented in this paper have been fully formalized and proved in the Coq proof assistant [2].


Operational Semantic Algebraic Property Probabilistic Program Proof Assistant Denotational Semantic 
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.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Ramsey, N., Pfeffer, A.: Stochastic lambda calculus and monads of probability distributions. In: Conf. Record of 29th ACM SIGPLAN-SIGACT Symp. on Principles of Programming Languages, POPL 2002, pp. 154–165. ACM Press, New York (2002)CrossRefGoogle Scholar
  2. 2.
    The Coq Development Team: The Coq Proof Assistant Reference Manual – Version V8.0 (2004),
  3. 3.
    Kozen, D.: Semantics of probabilistic programs. J. of Comput. and Syst. Sci. 22(3), 328–350 (1981)zbMATHCrossRefMathSciNetGoogle Scholar
  4. 4.
    Kozen, D.: A probabilistic PDL. In: Proc. of 15th Ann. ACM Symp. on Theory of Computing, STOC 1983, pp. 291–297. ACM Press, New York (1983)CrossRefGoogle Scholar
  5. 5.
    Morgan, C., McIver, A.: pGCL: formal reasoning for random algorithms. South African Computer J. (1999)Google Scholar
  6. 6.
    Park, S., Pfenning, F., Thrun, S.: A probabilistic language based upon sampling functions. In: Proc. of 32nd ACM SIGPLAN-SIGACT Symp. on Principles of Programming Languages, POPL 2005, pp. 171–182. ACM Press, New York (2005)CrossRefGoogle Scholar
  7. 7.
    Hurd, J., McIver, A., Morgan, C.: Probabilistic guarded commands mechanized in HOL. In: Cerone, A., Pierro, A.D. (eds.) Proc. of 2nd Wksh. on Quantitative Aspects of Programming Languages, QAPL 2004. Electron. Notes in Theor. Comput. Sci., vol. 112, pp. 95–111. Elsevier, Amsterdam (2005)Google Scholar
  8. 8.
    Kwiatkowska, M., Norman, G., Parker, D.: Probabilistic symbolic model checking with PRISM: A hybrid approach. J. on Software Tools for Technology Transfer 6(2), 128–142 (2004)Google Scholar
  9. 9.
    Hurd, J.: Formal Verification of Probabilistic Algorithms. PhD thesis, Univ. of Cambridge (2002)Google Scholar
  10. 10.
    Hurd, J.: Verification of the Miller-Rabin probabilistic primality test. J. of Logic and Algebraic Program. 50(1-2), 3–21 (2003)CrossRefMathSciNetGoogle Scholar
  11. 11.
    Jones, C.: Probabilistic Non-determinism. PhD thesis, Univ. of Edinburgh (1989)Google Scholar
  12. 12.
    Jones, C., Plotkin, G.: A probabilistic powerdomain of evaluations. In: Proc. of 4th Ann. IEEE Symp. on Logic in Computer Science, LICS 1989, pp. 186–195. IEEE Comput. Soc. Press, Los Alamitos (1989)Google Scholar
  13. 13.
    McIver, A., Morgan, C.: Abstraction, Refinement and Proof for Probabilistic Systems. In: Monographs in Computer Science. Springer, Heidelberg (2005)Google Scholar
  14. 14.
    Moggi, E.: Notions of computation and monads. Inform. and Comput. 93(1), 55–92 (1991)zbMATHCrossRefMathSciNetGoogle Scholar
  15. 15.
    Pfenning, F., Davies, R.: A judgmental reconstruction of modal logic. Math. Struct. in Comput. Sci. 11(4), 511–540 (2001)zbMATHMathSciNetGoogle Scholar
  16. 16.
    Geuvers, H., Niqui, M.: Constructive reals in coq: Axioms and categoricity. In: Callaghan, P., Luo, Z., McKinna, J., Pollack, R. (eds.) TYPES 2000. LNCS, vol. 2277, pp. 79–95. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  17. 17.
    Escardó, M., Simpson, A.: A universal characterization of the closed euclidean interval (extended abstract). In: Proc. of 16th Ann. IEEE Symp. on Logic in Computer Science, LICS 2001, pp. 115–125. IEEE Comput. Soc. Press, Los Alamitos (2001)CrossRefGoogle Scholar
  18. 18.
    Paulin-Mohring, C.: A library for reasoning on randomized algorithms in Coq: description of a Coq contribution, Univ. Paris Sud (2006),
  19. 19.
    Hurd, J.: A formal approach to probabilistic termination. In: Carreño, V.A., Muñoz, C.A., Tahar, S. (eds.) TPHOLs 2002. LNCS, vol. 2410, pp. 230–245. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  20. 20.
    Filliâtre, J.C.: Verification of non-functional programs using interpretations in type theory. J. of Funct. Program. 13(4), 709–745 (2003)zbMATHCrossRefGoogle Scholar
  21. 21.
    Filliâtre, J.C.: The why verification tool (2002),

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Philippe Audebaud
    • 1
  • Christine Paulin-Mohring
    • 2
  1. 1.ENS Lyon and INRIA Sophia-AntipolisSophia AntipolisFrance
  2. 2.LRI, Université Paris Sud and INRIA Futurs, Bât. 490, Université Paris SudOrsayFrance

Personalised recommendations