Journal of Automated Reasoning

, Volume 51, Issue 4, pp 357–370 | Cite as

Proof Pearl—A Mechanized Proof of GHC’s Mergesort

Open Access


We present our Isabelle/HOL formalization of GHC’s sorting algorithm for lists, proving its correctness and stability. This constitutes another example of applying a state-of-the-art proof assistant to real-world code. Furthermore, it allows users to take advantage of the formalized algorithm in generated code.


Mergesort Theorem proving Code generation 


  1. 1.
    Filliâtre, J.C., Magaud, N.: Certification of sorting algorithms in the Coq system. In: Theorem Proving in Higher Order Logics: Emerging Trends (1999).
  2. 2.
    Haftmann, F., Nipkow, T.: Code generation via higher-order rewrite systems. In: Blume, M., Kobayashi, N., Vidal, G. (eds.) Functional and Logic Programming, FLOPS 2010, Lecture Notes in Computer Science, vol. 6009, pp. 103–117. Springer (2010). doi:10.1007/978-3-642-12251-4_9
  3. 3.
    Krauss, A.: Partial and nested recursive function definitions in higher-order logic. J. Autom. Reasoning 44(4), 303–336 (2010). doi:10.1007/s10817-009-9157-2 MathSciNetCrossRefMATHGoogle Scholar
  4. 4.
    Nipkow, T., Paulson, L.C., Wenzel, M.: Isabelle/HOL—a proof assistant for higher-order logic. In: Lecture Notes in Computer Science, vol. 2283. Springer (2002). doi:10.1007/3-540-45949-9
  5. 5.
    O’Keefe, R.: A smooth applicative merge sort. Tech. rep., Department of Artificial Intelligence, University of Edinburgh (1982)Google Scholar
  6. 6.
    Paulson, L.C.: ML for the Working Programmer, 2nd edn. Cambridge University Press, New York (1996)CrossRefMATHGoogle Scholar
  7. 7.
    Sternagel, C.: Efficient Mergesort. In: Klein, G., Nipkow, T., Paulson, L.C. (eds.) The Archive of Formal Proofs. (2011, formal proof development)
  8. 8.
    Thiemann, R., Sternagel, C.: Certification of termination proofs using CeTA. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds.) Theorem Proving in Higher Order Logics, TPHOLs 2009, Lecture Notes in Computer Science, vol. 5674, pp. 452–468. Springer (2009). doi:10.1007/978-3-642-03359-9_31

Copyright information

© The Author(s) 2012

Authors and Affiliations

  1. 1.School of Information ScienceJapan Advanced Institute of Science and TechnologyNomiJapan

Personalised recommendations