Journal of Automated Reasoning

, Volume 43, Issue 1, pp 1–18 | Cite as

Proof Pearl: Mechanizing the Textbook Proof of Huffman’s Algorithm

  • Jasmin Christian BlanchetteEmail author


Huffman’s algorithm is a procedure for constructing a binary tree with minimum weighted path length. Our Isabelle/HOL proof closely follows the sketches found in standard algorithms textbooks, uncovering a few snags in the process. Another distinguishing feature of our formalization is the use of custom induction rules to help Isabelle’s automatic tactics, leading to very short proofs for most of the lemmas.


Huffman coding Interactive theorem provers Higher-order logic 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Aho, A.V., Hopcroft, J.E., Ullman, J.D.: Data Structures and Algorithms. Addison-Wesley, Reading (1983)zbMATHGoogle Scholar
  2. 2.
    Berghofer, S., Nipkow, T.: Random testing in Isabelle/HOL. In: Cuellar, J., Liu, Z. (eds.) Software Engineering and Formal Methods (SEFM 2004), pp. 230–239. IEEE Computer Society, Los Alamitos (2004)CrossRefGoogle Scholar
  3. 3.
    Bird, R., Wadler, P.: Introduction to Functional Programming. Prentice Hall International Series in Computer Science. Prentice Hall, Hemel Hempstead (1988)Google Scholar
  4. 4.
    Blanchette, J.C.: An Isabelle/HOL formalization of the textbook proof of Huffman’s algorithm. Archive of Formal Proofs. (2008)
  5. 5.
    Bulwahn, L., Krauss, A.: Finding lexicographic orders for termination proofs in Isabelle/HOL. In: Schneider, K., Brandt, J. (eds.) Theorem Proving in Higher Order Logics (TPHOLs 2007). Lecture Notes in Computer Science, vol. 4732, pp. 38–53. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  6. 6.
    Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 2nd edn. MIT, Cambridge (2001)zbMATHGoogle Scholar
  7. 7.
    Gordon, M.J.C., Melham, T.F. (eds.): Introduction to HOL: A Theorem Proving Environment for Higher Order Logic. Cambridge University Press, Cambridge (1993)zbMATHGoogle Scholar
  8. 8.
    Haftmann, F., Nipkow, T.: A code generator framework for Isabelle/HOL. In: Schneider, K., Brandt, J. (eds.) Theorem Proving in Higher Order Logics (TPHOLs 2007). Lecture Notes in Computer Science, vol. 4732, pp. 128–143. Springer, Heidelberg (2007)Google Scholar
  9. 9.
    Huffman, D.A.: A method for the construction of minimum-redundancy codes. In: Proc. IRE 40(9), pp. 1098–1101 (1952)Google Scholar
  10. 10.
    Knuth, D.E.: The Art of Computer Programming, Vol. 1: Fundamental Algorithms, 3rd edn. Addison-Wesley, Reading (1997)zbMATHGoogle Scholar
  11. 11.
    Krauss, A.: Automating Recursive Definitions and Termination Proofs in Higher-Order Logic. Ph.D. thesis (submitted), Dept. of Informatics, T. U. München (2009)Google Scholar
  12. 12.
    Milner, R., Tofte, M., Harper, R., MacQueen, D.: The Definition of Standard ML (Revised Edn.). MIT, Cambridge (1997)Google Scholar
  13. 13.
    Nipkow, T., Paulson, L.C., Wenzel, M.: Isabelle/HOL: A Proof Assistant for Higher-order Logic. Lecture Notes in Computer Science, vol. 2283. Springer, Heidelberg (2002) (Updated version, 2008)zbMATHGoogle Scholar
  14. 14.
    Théry, L.: A correctness proof of Huffman algorithm. (2003). Accessed 24 September 2008
  15. 15.
    Théry, L.: Formalising Huffman’s algorithm. Tech. report TRCS 034, Dept. of Informatics, Univ. of L’Aquila (2004)Google Scholar

Copyright information

© Springer Science+Business Media B.V. 2009

Authors and Affiliations

  1. 1.Institut für InformatikTechnische Universität MünchenMunichGermany

Personalised recommendations