Code Generation via Higher-Order Rewrite Systems

  • Florian Haftmann
  • Tobias Nipkow
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6009)


We present the meta-theory behind the code generation facilities of Isabelle/HOL. To bridge the gap between the source (higher-order logic with type classes) and the many possible targets (functional programming languages), we introduce an intermediate language, Mini-Haskell. To relate the source and the intermediate language, both are given a semantics in terms of higher-order rewrite systems (HRSs). In a second step, type classes are removed from Mini-Haskell programs by means of a dictionary translation; we prove the correctness of this step. Building on equational logic also directly supports a simple but powerful algorithm and data refinement concept.


Code Generation Target Language Type Class High Order Logic Type Constructor 
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.
    Berghofer, S., Bulwahn, L., Haftmann, F.: Turning inductive into equational specifications. In: Urban, C. (ed.) TPHOLs 2009. LNCS, vol. 5674, pp. 131–146. Springer, Heidelberg (2009)Google Scholar
  2. 2.
    Berghofer, S., Nipkow, T.: Executing higher order logic. In: Callaghan, P., Luo, Z., McKinna, J., Pollack, R. (eds.) TYPES 2000. LNCS, vol. 2277, pp. 24–40. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  3. 3.
    Berghofer, S., Nipkow, T.: Random testing in Isabelle/HOL. In: Second International Conference on SEFM 2004: Proc. of the Software Engineering and Formal Methods. IEEE Computer Society, Los Alamitos (2004)Google Scholar
  4. 4.
    Crow, J., Owre, S., Rushby, J., Shankar, N., Stringer-Calvert, D.: Evaluating, testing, and animating PVS specifications. Tech. rep., Computer Science Laboratory, SRI International (2001)Google Scholar
  5. 5.
    Greve, D.A., Kaufmann, M., Manolios, P., Moore, J.S., Ray, S., Ruiz-Reina, J.L., Sumners, R., Vroon, D., Wilding, M.: Efficient execution in an automated reasoning environment. Journal of Functional Programming 18(1), 15–46 (2007)Google Scholar
  6. 6.
    Haftmann, F.: Code generation from specifications in higher order logic. Ph.D. thesis, Technische Universität München (2009)Google Scholar
  7. 7.
    Hall, C., Hammond, K., Peyton Jones, S., Wadler, P.: Type classes in Haskell. ACM Transactions on Programming Languages and Systems 18(2) (1996)Google Scholar
  8. 8.
    Jones, C.B.: Systematic Software Development using VDM, 2nd edn. Prentice Hall International, Englewood Cliffs (1990)zbMATHGoogle Scholar
  9. 9.
    Jones, M.P.: Qualified types: Theory and practice. Ph.D. thesis, University of Nottingham (1994)Google Scholar
  10. 10.
    Letouzey, P.: Programmation fonctionnelle certifiée – l’extraction de programmes dans l’assistant Coq. Ph.D. thesis, Université Paris-Sud (2004)Google Scholar
  11. 11.
    Letouzey, P.: Coq Extraction, an Overview. In: Beckmann, A., Dimitracopoulos, C., Löwe, B. (eds.) CiE 2008. LNCS, vol. 5028, pp. 359–369. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  12. 12.
    Lochbihler, A.: Formalising FinFuns - generating code for functions as data from Isabelle/HOL. In: Urban, C. (ed.) TPHOLs 2009. LNCS, vol. 5674, pp. 310–326. Springer, Heidelberg (2009)Google Scholar
  13. 13.
    Mayr, R., Nipkow, T.: Higher-order rewrite systems and their confluence. Theor. Comput. Sci. 192, 3–29 (1998)zbMATHCrossRefMathSciNetGoogle Scholar
  14. 14.
    Nipkow, T., Paulson, L.C., Wenzel, M.: Isabelle/HOL. LNCS, vol. 2283. Springer, Heidelberg (2002)zbMATHGoogle Scholar
  15. 15.
    Nipkow, T., Prehofer, C.: Type checking type classes. In: Proc. 20th ACM Symp. Principles of Programming Languages. ACM Press, New York (1993)Google Scholar
  16. 16.
    Nipkow, T., Prehofer, C.: Type reconstruction for type classes. J. Functional Programming 5(2), 201–224 (1995)zbMATHCrossRefMathSciNetGoogle Scholar
  17. 17.
    Okasaki, C.: Catenable double-ended queues. In: Proc. Int. Conf. Functional Programming (ICFP 1997). ACM Press, New York (1997)Google Scholar
  18. 18.
    Schmidt-Schauß, M.: Computational aspects of an order-sorted logic with term declarations. LNAI 395. Springer (1989)zbMATHGoogle Scholar
  19. 19.
    Thiemann, R., Sternagel, C.: Certification of termination proofs using CeTA. In: Urban, C. (ed.) TPHOLs 2009. LNCS, vol. 5674, pp. 452–468. Springer, Heidelberg (2009)Google Scholar
  20. 20.
    Wehr, S.: ML modules and Haskell type classes: A constructive comparison. Master’s thesis, Albert-Ludwigs-Universität, Freiburg (2005)Google Scholar
  21. 21.
    Wehr, S., Chakravarty, M.M.T.: ML modules and Haskell type classes: A constructive comparison. In: Ramalingam, G. (ed.) APLAS 2008. LNCS, vol. 5356, pp. 188–204. Springer, Heidelberg (2008)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Florian Haftmann
    • 1
  • Tobias Nipkow
    • 1
  1. 1.Institut für InformatikTechnische Universität München 

Personalised recommendations