Exploiting Purely Functional Programming to Obtain Bounded Resource Behaviour: The Hume Approach

  • Kevin Hammond
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4164)


This chapter describes Hume: a functionally-based language for programming with bounded resource usage, including time and space properties. The purpose of the Hume language design is to explore the expressibility/costability spectrum in resource-constrained systems, such as real-time embedded or control systems. It is unusual in being based on a combination of λ-calculus and finite state machine notions, rather than the more usual propositional logic, or flat finite-state-machine models. The use of a strict, purely functional programming notation allows the construction of a strong cost model for expressions, which can then be embedded into a simple cost model for processes.

In this chapter, we introduce Hume, describe the Hume Abstract Machine implementation, and show how a high-level cost model can be constructed that relates costs from the abstract machine to Hume source programs. We illustrate our approach with an example adapted from the literature: a simple vending machine controller.


  1. 1.
    Amey, P.: Correctness by Construction: Better can also be Cheaper. CrossTalk: the Journal of Defense Software Engineering, 24–28 (March 2002)Google Scholar
  2. 2.
    Apt, K.R., Olderog, E.-R.: Verification of Sequential and Concurrent Programs, 2nd edn. Springer, Heidelberg (1997)MATHGoogle Scholar
  3. 3.
    Armstrong, J.: Erlang — a Survey of the Language and its Industrial Applications. In: Proc. INAP 1996 — The 9th Exhibitions and Symposium on Industrial Applications of Prolog, Hino, Tokyo, Japan, pp. 16–18 (1996)Google Scholar
  4. 4.
    Armstrong, J.: The Development of Erlang. In: Proc. 1997 ACM Intl. Conf. on Functl. Prog (ICFP 1997), Amsterdam, The Netherlands, pp. 196–203 (1997)Google Scholar
  5. 5.
    Armstrong, J., Virding, S.R., Williams, M.C.: Concurrent Programming in Erlang. Prentice-Hall, Englewood Cliffs (1993)MATHGoogle Scholar
  6. 6.
    Augustsson, L.: Compiling Lazy Functional Languages, Part II. PhD thesis, Dept. of Computer Science, Chalmers University of Technology, Göteborg, Sweden (1987)Google Scholar
  7. 7.
    Barnes, J.G.P.: High Integrity Ada: the Spark Approach. Addison-Wesley, Reading (1997)MATHGoogle Scholar
  8. 8.
    Blau, S., Rooth, J.: AXD-301: a New Generation ATM Switching System. Ericsson Review 1 (1998)Google Scholar
  9. 9.
    Bollela, G., et al.: The Real-Time Specification for Java. Addison-Wesley, Reading (2000)Google Scholar
  10. 10.
    Boussinot, F., de Simone, R.: The Esterel Language. Proceedings of the IEEE 79(9), 1293–1304 (1991)CrossRefGoogle Scholar
  11. 11.
    Breitinger, S., Loogen, R., Ortega-Mallén, Y., Pena, R.: The Eden Coordination Model for Distributed Memory Systems. In: High-Level Parallel Programming Models and Supportive Environments (HIPS 1997), vol. 1123. IEEE Press, Los Alamitos (1997)Google Scholar
  12. 12.
    Burstall, R.: Inductively Defined Functions in Functional Programming Languages. Technical Report ECS-LFCS-87-25, Dept. of Comp. Sci., Univ. of Edinburgh (1987)Google Scholar
  13. 13.
    Caspi, P., Pilaud, D., Halbwachs, N., Place, J.: Lustre: a Declarative Language for Programming Synchronous Systems. In: Proc. POPL 1987 – 1987 Symposium on Principles of Programming Languages, München, Germany, pp. 178–188 (January 1987)Google Scholar
  14. 14.
    Claessen, K., Sheeran, M.: A Tutorial on Lava: a Hardware Description and Verification System, unpublished report, chalmers university of technology, sweden (August 2000)Google Scholar
  15. 15.
    Colaço, J.-L., Pagano, B., Pouzet, M.: A Conservative Extension of Synchronous Data-flow with State Machines. In: Proc. ACM International Conference on Embedded Software (EMSOFT 2005), Jersey City, New Jersey, USA (September 2005)Google Scholar
  16. 16.
    Fijma, D.H., Udink, R.T.: A Case Study in Functional Real-Time Programming. Technical report, Dept. of Computer Science, Univ. of Twente, The Netherlands, Memoranda Informatica, pp. 91–62 (1991)Google Scholar
  17. 17.
    Gautier, T., Le Guernic, P., Besnard, L.: Signal: A declarative language for synchronous programming of real-time systems. In: Kahn, G. (ed.) FPCA 1987. LNCS, vol. 274, pp. 257–277. Springer, Heidelberg (1987)Google Scholar
  18. 18.
    Hammond, K., Michaelson, G.J.: Hume: A Domain-Specific Language for Real-Time Embedded Systems. In: Pfenning, F., Smaragdakis, Y. (eds.) GPCE 2003. LNCS, vol. 2830, pp. 37–56. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  19. 19.
    Hammond, K., Michaelson, G.J.: Predictable Space Behaviour in FSM-Hume. In: Peña, R., Arts, T. (eds.) IFL 2002. LNCS, vol. 2670. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  20. 20.
    Hawkins, J., Abdallah, A.E.: Behavioural Synthesis of a Parallel Hardware JPEG Decoder from a Functional Specification. In: Monien, B., Feldmann, R.L. (eds.) Euro-Par 2002. LNCS, vol. 2400, pp. 615–619. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  21. 21.
    Hofmann, M., Jost, S.: Static Prediction of Heap Space Usage for First-Order Functional Programs. In: POPL 2003 — Symposium on Principles of Programming Languages, New Orleans, LA, USA, pp. 185–197. ACM Press, New York (2003)CrossRefGoogle Scholar
  22. 22.
    Hughes, R.J.M.: The Design and Implementation of Programming Languages, DPhil Thesis, Programming Research Group, Oxford (July 1983)Google Scholar
  23. 23.
    Hughes, R.J.M., O’Donnell, J.T.: Expressing and reasoning about non-deterministic functional programs. In: Proceedings of the 1989 Glasgow Workshop on Functional Programming, London, UK, pp. 308–328. Springer, Heidelberg (1990)Google Scholar
  24. 24.
    Hughes, R.J.M., Pareto, L.: Recursion and Dynamic Data Structures in Bounded Space: towards Embedded ML Programming. In: ICFP 1999 — International Conference on Functional Programming, Paris, France, pp. 70–81. ACM Press, New York (1999)CrossRefGoogle Scholar
  25. 25.
    Hughes, R.J.M., Pareto, L., Sabry, A.: Proving the Correctness of Reactive Systems Using Sized Types. In: POPL 1996 — Symposium on Principles of Programming Languages, St.Petersburg Beach, Florida, pp. 410–423. ACM, New York (1996)CrossRefGoogle Scholar
  26. 26.
    Launchbury, J., Matthews, J., Cook, B.: Microprocessor Specification in Hawk. In: Proc. International Conference on Computer Languages, pp. 90–101 (1998)Google Scholar
  27. 27.
    Landin, P.: The Mechanical Evaluation of Expressions. The Computer Journal 6(4), 308–320 (1964)MATHGoogle Scholar
  28. 28.
    Liang, S., Hudak, P., Jones, M.P.: Monad transformers and modular interpreters. In: Proc. POPL 1995 — 1995 Symposium on Principles of Programming Languages, San Francisco, California, pp. 333–343. ACM Press, New York (1995)CrossRefGoogle Scholar
  29. 29.
    Lindholm, T., Yellin, F.: The Java Virtual Machine Specification, 2nd edn. Addison-Wesley, Reading (1999)Google Scholar
  30. 30.
    McDermid, J.: Engineering Safety-Critical Systems, pp. 217–245. Cambridge University Press, Cambridge (1996)Google Scholar
  31. 31.
    Mycroft, A., Sharp, R.: Hardware/Software Co-Design Using Functional Languages. In: Margaria, T., Yi, W. (eds.) TACAS 2001. LNCS, vol. 2031, pp. 236–251. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  32. 32.
    Nöcker, E.G.J.M.H., Smetsers, J.E.W., van Eekelen, M.C.J.D., Plasmeijer, M.J.: Concurrent Clean. In: Aarts, E.H.L., Rem, M., van Leeuwen, J. (eds.) PARLE 1991. LNCS, vol. 505, pp. 202–219. Springer, Heidelberg (1991)Google Scholar
  33. 33.
    Nordlander, J., Carlsson, M., Jones, M.: Programming with Time-Constrained Reactions (unpublished report) (2006), http://www.cse.ogi.edu/pacsoft/projects/Timber/publications.htm
  34. 34.
    O’Donnell, J.T.: The Hydra Hardware Description Language. In: Lengauer, C., Batory, D., Consel, C., Odersky, M. (eds.) Domain-Specific Program Generation. LNCS, vol. 3016, pp. 143–164. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  35. 35.
    Peña, R., Segura, C.: A Polynomial-Cost Non-determinism Analysis. In: Arts, T., Mohnen, M. (eds.) IFL 2002. LNCS, vol. 2312, pp. 121–137. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  36. 36.
    Peña, R., Segura, C.: A First-Order Functl. Lang. for Reasoning about Heap Consumption. In: Grelck, C., Huch, F., Michaelson, G.J., Trinder, P. (eds.) IFL 2004. LNCS, vol. 3474, Springer, Heidelberg (2005)Google Scholar
  37. 37.
    Peterson, J., Hudak, P., Elliot, C.: Lambda in Motion: Controlling Robots with Haskell. In: Gupta, G. (ed.) PADL 1999. LNCS, vol. 1551, p. 91. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  38. 38.
    Peyton Jones, S.L., Lester, D.: Implementing Functional Languages: a Tutorial. Prentice-Hall, Englewood Cliffs (1992)Google Scholar
  39. 39.
    Peyton Jones, S.L.: Implementing Lazy Functional Languages on Stock Hardware:the Spineless Tagless G-Machine. Journal of Functional Programming 2(2), 127–202 (1992)MATHCrossRefGoogle Scholar
  40. 40.
    Peyton Jones, S.L., Gordon, A.D., Finne, S.O.: Concurrent Haskell. In: Proc. POPL 1996 — ACM Symp. on Principles of Programming Languages, pp. 295–308 (January 1996)Google Scholar
  41. 41.
    Rebón Portillo, A.J., Hammond, K., Loidl, H.-W., Vasconcelos, P.: A Sized Time System for a Parallel Functional Language (Revised). In: Peña, R., Arts, T. (eds.) IFL 2002. LNCS, vol. 2670, pp. 1–16. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  42. 42.
    Reppy, J.H.: CML: a Higher-Order Concurrent Language. In: Proc. 1991 ACM Conf. on Prog. Lang. Design and Impl (PLDI 1991), pp. 293–305 (June 1991)Google Scholar
  43. 43.
    Schwarz, R.: Causality in distributed systems. In: Proc. EW 5: 5th ACM SIGOPS European workshop, pp. 1–5. ACM Press, New York (1992)CrossRefGoogle Scholar
  44. 44.
    Taha, W., Ellner, S., Xi, H.: Generating Heap-Bounded Programs in a Functional Setting. In: Alur, R., Lee, I. (eds.) EMSOFT 2003. LNCS, vol. 2855, pp. 340–355. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  45. 45.
    Tofte, M., Talpin, J.-P.: Region-Based Memory Management. Information and Computation 132(2), 109–176 (1997)MATHCrossRefMathSciNetGoogle Scholar
  46. 46.
    Turner, D.A.: Elementary Strong Functional Programming. In: Hartel, P.H., Plasmeijer, R. (eds.) FPLE 1995. LNCS, vol. 1022. Springer, Heidelberg (1995)Google Scholar
  47. 47.
    Vasconcelos, P.B.: Cost Inference and Analysis for Recursive Functional Programs. PhD thesis, University of St Andrews (in preparation, 2006)Google Scholar
  48. 48.
    Wadge, W.W., Ashcroft, E.A.: LUCID, the dataflow programming language. Academic Press, London (1985)MATHGoogle Scholar
  49. 49.
    Wallace, M., Runciman, C.: Extending a Functional Programming System for Embedded Applications. Software: Practice & Experience 25(1) (January 1995)Google Scholar
  50. 50.
    Wikström, C., Nilsson, H.: Mnesia — an Industrial Database with Transactions, Distribution and a Logical Query Language. In: Proc. 1996 International Symposium on Cooperative Database Systems for Advanced Applications (1996)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Kevin Hammond
    • 1
  1. 1.School of Computer ScienceUniversity of St AndrewsSt AndrewsScotland

Personalised recommendations