Skip to main content

Reusable Components of Semantic Specifications

  • Chapter
  • First Online:
Transactions on Aspect-Oriented Software Development XII

Part of the book series: Lecture Notes in Computer Science ((TAOSD,volume 8989))

Abstract

Semantic specifications of programming languages typically have poor modularity. This hinders reuse of parts of the semantics of one language when specifying a different language – even when the two languages have many constructs in common – and evolution of a language may require major reformulation of its semantics. Such drawbacks have discouraged language developers from using formal semantics to document their designs.

In the PLanCompS project, we have developed a component-based approach to semantics. Here, we explain its modularity aspects, and present an illustrative case study: a component-based semantics for Caml Light. We have tested the correctness of the semantics by running programs on an interpreter generated from the semantics, comparing the output with that produced on the standard implementation of the language.

Our approach provides good modularity, facilitates reuse, and should support co-evolution of languages and their formal semantics. It could be particularly useful in connection with domain-specific languages and language-driven software development.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    The specifications of the current collection of funcons will not be finalised until we have tested their use in two further major case studies, as discussed in Sect. 6.

  2. 2.

    In fact labels in MSOS are the morphisms of a category, and the unobservable labels are identity morphisms, as explained in [42]. However, models of MSOS specifications correspond to ordinary labelled transition systems.

  3. 3.

    For an assignment that might throw an exception, the corresponding MSOS rule would make explicit the conditions under which that occurs, and incorporate the exception flag in the label.

  4. 4.

    In small-step semantics, the use of auxiliary funcons for specifying while-true appears to be unavoidable.

  5. 5.

    Static semantics sometimes requires such so-called partial evaluation.

  6. 6.

    In effect, non-local bindings correspond to implicit parameters.

  7. 7.

    The notation \({{\mathsf{\textit{abs} }}}(T_1, T_2)\) for abstraction types in the conference version of this paper [13] abbreviates \({{\mathsf{\textit{abs} }}}(\emptyset , T_1, T_2)\).

  8. 8.

    When \(I\) is bound to a type, \({{\mathbf {\mathsf{{bound}}}}}\text {-}{{\mathbf {\mathsf{{type}}}}}(I)\) corresponds to \({{\mathbf {\mathsf{{bound}}}}}\text {-}{{\mathbf {\mathsf{{value}}}}}(I)\), but it is evaluated as part of static semantics.

  9. 9.

    The lack of HOL support for evaluation contexts discouraged Owens from using them for his OCaml Light case study [53].

References

  1. Afroozeh, A., van den Brand, M., Johnstone, A., Scott, E., Vinju, J.: Safe specification of operator precedence rules. In: Erwig, M., Paige, R.F., Van Wyk, E. (eds.) SLE 2013. LNCS, vol. 8225, pp. 137–156. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

  2. Bach Poulsen, C., Mosses, P.D.: Deriving pretty-big-step semantics from small-step semantics. In: Shao, Z. (ed.) ESOP 2014 (ETAPS). LNCS, vol. 8410, pp. 270–289. Springer, Heidelberg (2014)

    Chapter  Google Scholar 

  3. Poulsen, C.B., Mosses, P.D.: Generating Specialized Interpreters for Modular Structural Operational Semantics. In: Gupta, G., Peña, R. (eds.) LOPSTR 2013. LNCS, vol. 8901, pp. 220–236. Springer, Heidelberg (2014)

    Chapter  Google Scholar 

  4. Bergstra, J.A., Heering, J., Klint, P. (eds.): Algebraic Specification. ACM Press/Addison-Wesley, Reading (1989)

    MATH  Google Scholar 

  5. Bogdănaş, D., Roşu, G.: K-Java: a complete semantics of Java. In: POPL 2015. ACM (2015)

    Google Scholar 

  6. Börger, E., Fruja, N.G., Gervasi, V., Stärk, R.F.: A high-level modular definition of the semantics of C#. Theor. Comput. Sci. 336(2–3), 235–284 (2005)

    Article  MATH  Google Scholar 

  7. Börger, E., Stärk, R.F.: Exploiting abstraction for specification reuse: the Java/C# case study. In: de Boer, F.S., Bonsangue, M.M., Graf, S., de Roever, W.-P. (eds.) FMCO 2003. LNCS, vol. 3188, pp. 42–76. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  8. den van Brand, M.G.J., et al.: The ASF+SDF meta-environment: a component-based language development environment. In: Wilhelm, R. (ed.) CC 2001. LNCS, vol. 2027, pp. 365–370. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  9. van den Brand, M.G.J., Iversen, J., Mosses, P.D.: An action environment. Sci. Comput. Program. 61(3), 245–264 (2006)

    Article  MATH  Google Scholar 

  10. Chalub, F., Braga, C.: Maude MSOS tool. https://github.com/fcbr/mmt. Accessed Jan 2015

  11. Churchill, M., Mosses, P.D.: Modular bisimulation theory for computations and values. In: Pfenning, F. (ed.) FOSSACS 2013 (ETAPS 2013). LNCS, vol. 7794, pp. 97–112. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

  12. Churchill, M., Mosses, P.D., Sculthorpe, N., Torrini, P.: Reusable components of semantic specifications: additional material (2015). http://www.plancomps.org/taosd2015

  13. Churchill, M., Mosses, P.D., Torrini, P.: Reusable components of semantic specifications. In: Modularity 2014, pp. 145–156. ACM (2014)

    Google Scholar 

  14. Delaware, B., Keuchel, S., Schrijvers, T., Oliveira, B.C.: Modular monadic meta-theory. In: ICFP 2013, pp. 319–330. ACM (2013)

    Google Scholar 

  15. Doh, K.G., Mosses, P.D.: Composing programming languages by combining action-semantics modules. Sci. Comput. Program. 47(1), 3–36 (2003)

    Article  MATH  Google Scholar 

  16. Doh, K.G., Schmidt, D.A.: Action semantics-directed prototyping. Comput. Lang. 19, 213–233 (1993)

    Article  Google Scholar 

  17. Ellison, C., Roşu, G.: An executable formal semantics of C with applications. In: POPL 2012, pp. 533–544. ACM (2012)

    Google Scholar 

  18. Felleisen, M., Findler, R.B., Flatt, M.: Semantics Engineering with PLT Redex. MIT Press, Cambridge (2009)

    MATH  Google Scholar 

  19. Felleisen, M., Hieb, R.: The revised report on the syntactic theories of sequential control and state. Theor. Comput. Sci. 103(2), 235–271 (1992)

    Article  MATH  MathSciNet  Google Scholar 

  20. Goguen, J.A., Malcolm, G.: Algebraic Semantics of Imperative Programs. MIT Press, Cambridge (1996)

    MATH  Google Scholar 

  21. Harper, R., Stone, C.: A type-theoretic interpretation of Standard ML. In: Plotkin, G.D., Stirling, C., Tofte, M. (eds.) Proof, Language and Interaction: Essays in Honour of Robin Milner. MIT Press, Cambridge (2000)

    Google Scholar 

  22. Heering, J., Klint, P.: Prehistory of the ASF+SDF system (1980–1984). In: ASF+SDF95, pp. 1–4. Technical report 9504, Programming Research Group, University of Amsterdam (1995)

    Google Scholar 

  23. Hudak, P., Hughes, J., Jones, S.P., Wadler, P.: A history of Haskell: being lazy with class. In: HOPL-III, pp. 1–55. ACM (2007)

    Google Scholar 

  24. Iversen, J., Mosses, P.D.: Constructive action semantics for Core ML. Softw. IEE Proc. 152, 79–98 (2005). Special issue on Language Definitions and Tool Generation

    Article  Google Scholar 

  25. Johnstone, A., Mosses, P.D., Scott, E.: An agile approach to language modelling and development. Innov. Syst. Softw. Eng. 6(1–2), 145–153 (2010). Special issue for ICFEM workshop FM+AM’09

    Article  Google Scholar 

  26. Johnstone, A., Scott, E.: Translator generation using ART. In: Malloy, B., Staab, S., van den Brand, M. (eds.) SLE 2010. LNCS, vol. 6563, pp. 306–315. Springer, Heidelberg (2011)

    Chapter  Google Scholar 

  27. Kahn, G.: Natural semantics. In: Brandenburg, F.J., Vidal-Naquet, G., Wirsing, M. (eds.) STACS 87. LNCS, vol. 247, pp. 22–39. Springer, Heidelberg (1987)

    Chapter  Google Scholar 

  28. Kats, L.C.L., Visser, E.: The Spoofax language workbench. In: SPLASH/OOPSLA Companion, pp. 237–238. ACM (2010)

    Google Scholar 

  29. Klein, C., et al.: Run your research: on the effectiveness of lightweight mechanization. In: POPL 2012, pp. 285–296. ACM (2012)

    Google Scholar 

  30. Kutter, P.W., Pierantonio, A.: Montages specifications of realistic programming languages. J. Univ. Comput. Sci. 3(5), 416–442 (1997)

    MATH  MathSciNet  Google Scholar 

  31. Lee, D.K., Crary, K., Harper, R.: Towards a mechanized metatheory of Standard ML. In: POPL 2007, pp. 173–184. ACM (2007)

    Google Scholar 

  32. Leroy, X.: Caml Light manual, December 1997. http://caml.inria.fr/pub/docs/manual-caml-light

  33. Levin, M.Y., Pierce, B.C.: TinkerType: a language for playing with formal systems. J. Funct. Program. 13(2), 295–316 (2003)

    Article  MATH  MathSciNet  Google Scholar 

  34. Lewis, J.R., Launchbury, J., Meijer, E., Shields, M.B.: Implicit parameters: dynamic scoping with static types. In: POPL 2000, pp. 108–118. ACM (2000)

    Google Scholar 

  35. Liang, S., Hudak, P., Jones, M.: Monad transformers and modular interpreters. In: POPL 1995, pp. 333–343 (1995)

    Google Scholar 

  36. McCarthy, J.: Towards a mathematical science of computation. In: Popplewell, C.M. (ed.) Information Processing 1962, pp. 21–28. North-Holland, Amsterdam (1962)

    Google Scholar 

  37. Meseguer, J., Roşu, G.: The rewriting logic semantics project: a progress report. In: Owe, O., Steffen, M., Telle, J.A. (eds.) FCT 2011. LNCS, vol. 6914, pp. 1–37. Springer, Heidelberg (2011)

    Chapter  Google Scholar 

  38. Milner, R., Tofte, M., Macqueen, D.: The Definition of Standard ML. MIT Press, Cambridge (1997)

    Google Scholar 

  39. Moggi, E.: An abstract view of programming languages. Technical report ECS-LFCS-90-113, Edinburgh University (1989)

    Google Scholar 

  40. Mosses, P.D.: Action Semantics, Cambridge Tracts in Theoretical Computer Science, vol. 26. Cambridge University Press, Cambridge (1992)

    Google Scholar 

  41. Mosses, P.D.: Theory and practice of action semantics. In: Penczek, W., Szałas, A. (eds.) MFCS 1996. LNCS, vol. 1113, pp. 37–61. Springer, Heidelberg (1996)

    Chapter  Google Scholar 

  42. Mosses, P.D.: Modular structural operational semantics. J. Log. Algebr. Program. 60–61, 195–228 (2004)

    Article  MathSciNet  Google Scholar 

  43. Mosses, P.D.: A constructive approach to language definition. J. Univ. Comput. Sci. 11(7), 1117–1134 (2005)

    Google Scholar 

  44. Mosses, P.D.: Teaching semantics of programming languages with Modular SOS. In: Teaching Formal Methods: Practice and Experience. Electronic Workshops in Computing. BCS (2006)

    Google Scholar 

  45. Mosses, P.D.: Component-based description of programming languages. In: Visions of Computer Science. Electronic Proceedings, pp. 275–286. BCS (2008)

    Google Scholar 

  46. Mosses, P.D.: Component-based semantics. In: SAVCBS 2009, pp. 3–10. ACM (2009)

    Google Scholar 

  47. Mosses, P.D.: VDM semantics of programming languages: combinators and monads. Form. Asp. Comput. 23, 221–238 (2011)

    Article  MATH  MathSciNet  Google Scholar 

  48. Mosses, P.D.: Semantics of programming languages: using ASF+SDF. Sci. Comput. Program. 97(1), 2–10 (2013). http://dx.doi.org/10.1016/j.scico.2013.11.038

    Google Scholar 

  49. Mosses, P.D., New, M.J.: Implicit propagation in structural operational semantics. In: SOS 2008. Electr. Notes Theor. Comput. Sci., vol. 229(4), pp. 49–66. Elsevier (2009)

    Google Scholar 

  50. Mosses, P.D., Vesely, F.: FunKons: component-based semantics in K. In: Escobar, S. (ed.) WRLA 2014. LNCS, vol. 8663, pp. 213–229. Springer, Heidelberg (2014)

    Chapter  Google Scholar 

  51. Mosses, P.D., Watt, D.A.: The use of action semantics. In: Formal Description of Programming Concepts III, Proceedings of IFIP TC2 Working Conference, Gl. Avernæs, 1986, pp. 135–166. Elsevier (1987)

    Google Scholar 

  52. Owens, S., Peskine, G., Sewell, P.: A formal specification for OCaml: the core language. Technical report, University of Cambridge (2008)

    Google Scholar 

  53. Owens, S.: A sound semantics for OCaml light. In: Drossopoulou, S. (ed.) ESOP 2008. LNCS, vol. 4960, pp. 1–15. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  54. Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)

    Google Scholar 

  55. PLanCompS: Programming language components and specifications (2011). http://www.plancomps.org

  56. Plotkin, G.D.: A structural approach to operational semantics. J. Log. Algebr. Program. 60–61, 17–139 (2004)

    MathSciNet  Google Scholar 

  57. Plotkin, G.D., Power, A.J.: Computational effects and operations: an overview. In: Proceedings of Workshop on Domains VI. Electr. Notes Theor. Comput. Sci., vol. 73, pp. 149–163. Elsevier (2004)

    Google Scholar 

  58. Roşu, G., Şerbănuţă, T.F.: K overview and SIMPLE case study. Electr. Notes Theor. Comput. Sci. 304, 3–56 (2014)

    Article  Google Scholar 

  59. Sewell, P., Nardelli, F.Z., Owens, S., et al.: Ott: effective tool support for the working semanticist. J. Funct. Program. 20, 71–122 (2010)

    Article  MATH  Google Scholar 

  60. Tofte, M.: Type inference for polymorphic references. Inf. Comput. 89(1), 1–34 (1990)

    Article  MATH  MathSciNet  Google Scholar 

  61. Visser, E.: Syntax Definition for Language Prototyping. Ph.D. thesis, University of Amsterdam (1997)

    Google Scholar 

  62. Visser, E.: Stratego: a language for program transformation based on rewriting strategies system description of Stratego 0.5. In: Middeldorp, A. (ed.) RTA 2001. LNCS, vol. 2051, pp. 357–361. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

Download references

Acknowledgments

Thanks to Erik Ernst and the anonymous referees for helpful comments and suggestions for improvement. The reported work was supported by EPSRC grant (EP/I032495/1) to Swansea University for the PLanCompS project.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Peter D. Mosses .

Editor information

Editors and Affiliations

Appendix

Appendix

This appendix contains the translation equations for the subset of Caml Light presented in Table 3, from which the illustrative examples in Sect. 3 are drawn. Our translation of the full Caml Light language is available online [12].

Markup for formatting the equations given below was inserted manually in the Stratego rules used to translate Caml Light programs to funcons. A few equations overlap; in Stratego we apply the more specific ones when possible.

Global names

$$\begin{aligned} \mathsf{ id }\, [\![ \mathtt{ I } ]\!] = {{\mathbf {\mathsf{{ id}}}}}('I') \end{aligned}$$

Type expressions

Constants

Patterns

Expressions

Pattern Matching

Let Bindings

Rights and permissions

Reprints and permissions

Copyright information

© 2015 Springer-Verlag Berlin Heidelberg

About this chapter

Cite this chapter

Churchill, M., Mosses, P.D., Sculthorpe, N., Torrini, P. (2015). Reusable Components of Semantic Specifications. In: Chiba, S., Tanter, É., Ernst, E., Hirschfeld, R. (eds) Transactions on Aspect-Oriented Software Development XII. Lecture Notes in Computer Science(), vol 8989. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-662-46734-3_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-662-46734-3_4

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-662-46733-6

  • Online ISBN: 978-3-662-46734-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics