Skip to main content
Log in

An operational semantics for object-oriented concepts based on the class hierarchy

  • Original Article
  • Published:
Formal Aspects of Computing

Abstract

The formalisation of object-oriented languages is essential for describing the implementation details of specific programming languages or for developing program verification techniques. However there has been relatively little formalisation work aimed at abstractly describing the fundamental concepts of object-oriented programming, separate from specific language considerations or suitability for a particular verification style. In this paper we address this issue by formalising a language that includes the core object-oriented programming language concepts of field tests and updates, methods, constructors, subclassing, multithreading, and synchronisation, built on top of standard sequential programming constructs. The abstract syntax is relatively close to the core of typical object-oriented programming languages such as Java. A novel aspect of the syntax is that objects and classes are encapsulated within a single syntactic term, including their fields and methods. Furthermore, class terms are structured according to the class hierarchy, and objects appear as subterms of their class (and method instances as subterms of the relevant object). This helps to narrow the gap between how a programmer thinks about their code and the underlying mathematical objects in the semantics. The semantics is defined operationally, so that all actions a program may take, such as testing or setting local variables and fields, or invoking methods on other objects, appear on the labels of the transitions. A process-algebraic style of interprocess communication is used for object and class interactions. A benefit of this label-based approach to the semantics is that a separation of concerns can be made when defining the rules of the different constructs, and the rules tend to be more concise. The basic rules for individual commands may be composed into more powerful rules that operate at the level of classes and objects. The traces generated by the operational semantics are used as the basis for establishing equivalence between classes.

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

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Abadi M, Cardelli L (1995) An imperative object calculus. In: Mosses P, Nielsen M, Schwartzbach M (eds) Theory and practice of software development (TAPSOFT 95), volume 915 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 469–485

  2. Abadi M, Cardelli L (1996) A theory of objects. Springer, Berlin

    Book  MATH  Google Scholar 

  3. Ábrahám E, de Boer FS, de Roever WP, Steffen M (2003) A compositional operational semantics for Java mt. In: Dershowitz N (ed) Verification: theory and practice, vol 2772 of lecture notes in computer science. Springer, Berlin, pp 290–303

  4. Ábrahám E, de Boer FS, de Roever WP, Steffen M (2008) A deductive proof system for multithreaded Java with exceptions. Fundam Inform 82(4): 391–463

    MATH  Google Scholar 

  5. Apt KR, de Boer FS, Olderog E-R, de Gouw S (2012) Verification of object-oriented programs: a transformational approach. J Comput Syst Sci 78(3): 823–852

    Article  MATH  Google Scholar 

  6. Alves-Foss, J (ed) (1999) Formal syntax and semantics of Java, volume 1523 of lecture notes in computer science. Springer, Berlin

    Google Scholar 

  7. Alves-Foss J, Lam F (1999) Dynamic denotational semantics of Java. In: Alves-Foss J (ed) Formal syntax and semantics of Java, volume 1523 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 541–541

  8. Arnold K, Gosling J, Holmes D (2000) The Java programming language. 3rd edn. Addison-Wesley, Boston

    Google Scholar 

  9. Abadi M, Harris T (2009) Perspectives on transactional memory. In: Bravetti M, Zavattaro G (eds) Proceeding of concurrency theory (CONCUR 2009), volume 5710 of lecture notes in computer science. Springer, Berlin, pp 1–14

  10. Bettini L, Capecchi S, Venneri B (2009) Dynamic overloading with copy semantics in object-oriented languages: a formal account. RAIRO Theor Inform Appl 43(03): 517–565

    Article  MATH  MathSciNet  Google Scholar 

  11. Bettini L, Damiani F, De Luca M, Geilmann K, Schfer J (2010) A calculus for boxes and traits in a Java-like setting. In: Clarke D, Agha G (eds) Coordination models and languages, volume 6116 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 46–60

  12. Birtwistle GM, Dahl O-J, Myhrhaug B, Nygaard K (1973) SIMULA begin. Auerbach Publishers Inc, Philadelphia

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

    Article  MATH  Google Scholar 

  14. Bergstra JA, Klop JW (1984) Process algebra for synchronous communication. Inform Control 60(1–3): 109–137

    Article  MATH  MathSciNet  Google Scholar 

  15. Blanchette JC, Owe O (2008) An open system operational semantics for an object-oriented and component-based language. In: Electronic notes in theoretical computer science, 215(0):151–169, Proceedings of the 4th international workshop on formal aspects of component software (FACS 2007)

  16. Brookes S (2007) A semantics for concurrent separation logic. Theor Comput Sci 375(1G3): 227–270

    Article  MATH  MathSciNet  Google Scholar 

  17. Börger E, Stärk RF (2003) Abstract state machines: a method for high-level system design and analysis. Springer, Berlin

    Book  Google Scholar 

  18. Chalub F, Braga C (2007) Maude MSOS tool. Electr. Notes Theor Comput Sci 176(4): 133–146

    Article  Google Scholar 

  19. Clavel M, Duran F, Eker S, Lincoln P, Marti-Oliet N, Meseguer J, Quesada JF (2002) Maude: specification and programming in rewriting logic. Theor Comput Sci 285(2): 187–243

    Article  MATH  MathSciNet  Google Scholar 

  20. Colvin R, Hayes IJ (2009) CSP with hierarchical state. In: Leuschel M, Wehrheim H (eds) Integrated formal methods (IFM 2009), volume 5423 of lecture notes in computer science. Springer, Berlin, pp 118–135

  21. Colvin RJ, Hayes IJ (2011) Structural operational semantics through context-dependent behaviour. J Logic Algebraic Programm 80(7): 392–426

    Article  MATH  MathSciNet  Google Scholar 

  22. Coleman JW, Jones CB (2007) A structural proof of the soundness of rely/guarantee rules. J Log Comput 17(4): 807–841

    Article  MATH  MathSciNet  Google Scholar 

  23. Cenciarelli P, Knapp A, Reus B, Wirsing M (1999) An event-based structural operational semantics of multi-threaded Java. In: Alves-Foss J (ed) Formal syntax and semantics of Java, volume 1523 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 157–200

  24. de Boer FS (2009) A shared-variable concurrency analysis of multi-threaded object-oriented programs. Theor Comput Sci 410(2–3): 128–141

    Article  MATH  Google Scholar 

  25. Din CC, Dovland J, Johnsen EB, Owe O (2012) Observable behavior of distributed systems: component reasoning for concurrent objects. J Logic Algebraic Programm 81(3): 227–256

    Article  MATH  MathSciNet  Google Scholar 

  26. Dean J, Grove D, Chambers C (1995) Optimization of object-oriented programs using static class hierarchy analysis. In: Tokoro M, Pareschi R (eds) European conference on object-oriented programming (ECOOP 1995), volume 952 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 77–101

  27. Dovland J, Johnsen EB, Owe O (2008) Observable behavior of dynamic systems: component reasoning for concurrent objects. In: Electronic Notes in Theoretical Computer Science, 203(3):19–34. Proceedings of the Workshop on the Foundations of Interactive Computation (FInCo 2007).

  28. Ducournau R, Privat J (2011) Metamodeling semantics of multiple inheritance. Sci Comput Programm 76(7): 555–586

    Article  MATH  MathSciNet  Google Scholar 

  29. de Roever W-P, de Boer F, Hooman UHJ, Lakhnech Y, Poel M, Zwiers J (2001) Concurrency verification: introduction to compositional and noncompositional methods. Cambridge University Press, Cambridge

  30. de Roever W-P, Engelhardt K (2001) Data Refinement: model-oriented proof methods and their comparison. Cambridge University Press, Cambridge

  31. Ellison C, Roşu G (2010) A formal semantics of C with applications. Technical Report, http://hdl.handle.net/2142/17414, University of Illinois, Illinois, November 2010

  32. Farzan A, Chen F, Meseguer J, Rosu G (2004) Formal analysis of Java programs in JavaFAN. In: Alur R, Peled D (eds) Computer aided verification, volume 3114 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 242–244

  33. Fisher J, Henzinger T, Nickovic D, Piterman N, Singh A, Vardi M (2011) Dynamic reactive modules. In: Katoen J-P, Knig B (eds) Concurrency theory (CONCUR 2011), volume 6901 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 404–418

  34. Fruja NG (2004) Specification and implementation problems for C#. In: Zimmermann W, Thalheim B (eds) Abstract state machines, volume 3052 of lecture notes in computer science. Springer, Berlin, pp 127–143

  35. Fruja NG (2010) Towards proving type safety of C#. Comput Lang Syst Struct 36(1): 60–95

    Google Scholar 

  36. Gamma E, Helm R, Johnson R, Vlissides J (1995) Design patterns: elements of reusable object-oriented software. Addison-Wesley Professional, Reading

  37. Groote JF, Mousavi MR, Reniers MA (2006) A hierarchy of SOS rule formats. In; Electronic notes in theoretical computer science, 156(1):3–25, 2006. Proceedings of the second workshop on structural operational semantics (SOS 2005)

  38. Goldberg A, Robson D (2002) Smalltalk 80: the language and its implementation. Addison-Wesley, Reading

    Google Scholar 

  39. He J, Hoare CAR, Sanders J (1986) Data refinement refined (resume). In: Robinet B, Wilhelm R (eds) ESOP 86, volume 213 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 187–196

  40. Hartel PH, Moreau L (2001) Formalizing the safety of Java, the Java virtual machine, and Java card. ACM Comput Surv 33(4): 517–558

    Article  Google Scholar 

  41. Hoare CAR (1985) Communicating sequential processes. Prentice-Hall, Inc., Upper Saddle River

  42. Jacobs B (2001) A formalisation of Java’s exception mechanism. In: Sands D (ed) Programming languages and systems, volume 2028 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 284–301

  43. Jaskelioff M, Ghani N, Hutton G (2011) Modularity and implementation of mathematical operational semantics. In: Electronic notes in theoretical computer science, 229(5):75–95. Proceedings of the second workshop on mathematically structured functional programming (MSFP 2008)

  44. Jones CB (1983) Specification and design of (parallel) programs. In: IFIP Congress, pp 321–332

  45. Jones CB (1983) Tentative steps toward a development method for interfering programs. ACM Trans Program Lang Syst 5: 596–619

    Article  MATH  Google Scholar 

  46. Jones CB (1990) Systematic Software Development using VDM. Prentice Hall, Upper Saddle River

    MATH  Google Scholar 

  47. Jones CB (2003) Operational semantics: concepts and their expression. Inf Process Lett 88(1–2): 27–32

    Article  MATH  Google Scholar 

  48. Jones CB (2003) Wanted: a compositional approach to concurrency. Programming methodology. Springer, Berlin, pp 5–15

  49. Jones CB (2007) Understanding programming language concepts via operational semantics. In: George C, Liu Z, Woodcock J (eds) Domain modeling and the duration calculus, international training school, advanced lectures, volume 4710 of lecture notes in computer science. Springer, Berlin, pp 177–235

  50. Jeffrey A, Rathke J (2005) Java Jr: fully abstract trace semantics for a core Java language. In: Sagiv S (ed) European symposium on programming, volume 3444 of lecture notes in computer science. Springer, Berlin, pp 423–438

  51. Klin B (2011) Bialgebras for structural operational semantics: an introduction. Theor Comput Sci 412(38): 5043–5069

    Article  MATH  MathSciNet  Google Scholar 

  52. Kifer M, Lausen G, Wu J (1995) Logical foundations of object-oriented and frame-based languages. J ACM 42(4): 741–843

    Article  MATH  MathSciNet  Google Scholar 

  53. Klein G, Nipkow T (2006) A machine-checked model for a Java-like language, virtual machine, and compiler. ACM Trans Program Lang Syst 28(4): 619–695

    Article  Google Scholar 

  54. Leuschel M, Fontaine M (2008) Probing the depths of CSP-M: a new fdr-compliant validation tool. In: Liu S, Maibaum T, Araki K (eds) Formal methods and software engineering, volume 5256 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 278–297

  55. Leavens GT, Rustan K, Leino M, Müller P (2007) Specification and verification challenges for sequential object-oriented programs. Formal Asp Comput 19(2): 159–189

    Article  MATH  Google Scholar 

  56. Leino K, Müller P (2005) Modular verification of static class invariants. In: Fitzgerald J, Hayes I, Tarlecki A (eds) FM 2005: formal methods, volume 3582 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 597–597

  57. Lochbihler A (2010) Verifying a compiler for Java threads. In: Gordon A (ed) Programming languages and systems, volume 6012 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 427–447

  58. Logozzo F (2009) Class invariants as abstract interpretation of trace semantics. Comput Lang Syst Struct 35(2): 100–142

    Google Scholar 

  59. Meseguer J (2000) Rewriting logic and Maude: a wide-spectrum semantic framework for object-based distributed systems. In: Smith SF, Talcott CL (eds) Formal methods for open object-based distributed systems IV, IFIF TC6/WG6.1 (FMOODS 2000), volume 177 of IFIP conference proceedings. Kluwer Academic Publishers, Dordrecht, pp 89–119

  60. Meyer B (2000) Object-oriented software construction. 2nd edn. Prentice Hall PTR, Upper Saddle River

    Google Scholar 

  61. Matthews J, Findler RB (2008) An operational semantics for Scheme. J Funct Program 18(1): 47–86

    Article  MATH  MathSciNet  Google Scholar 

  62. Milner R (1982) A calculus of communicating systems. Springer, New York

    Google Scholar 

  63. Milner R (1989) Communication and concurrency. Prentice Hall, Upper Saddle River

    MATH  Google Scholar 

  64. Maffeis S, Mitchell J, Taly A (2008) An operational semantics for JavaScript. In: Ramalingam G (ed) Programming languages and systems, volume 5356 of lecture notes in computer science, pp 307–325. Springer, Berlin/Heidelberg

  65. Mosses PD, New MJ (2009) Implicit propagation in structural operational semantics. Electr Notes Theor Comput Sci 229(4): 49–66

    Article  Google Scholar 

  66. Morgan C (1994) Programming from Specifications. 2nd edn. Prentice Hall, Upper Saddle River

    MATH  Google Scholar 

  67. Mosses PD (2002) Pragmatics of modular SOS. In Kirchner H, Ringeissen C (eds) Algebraic methodology and software technology, 9th international conference, AMAST 2002, Proceedings, volume 2422 of lecture notes in computer science. Springer, Berlin, pp 21–40

  68. Mosses PD (2004) Exploiting labels in structural operational semantics. Fundam Inform 60(1–4): 17–31

    MATH  MathSciNet  Google Scholar 

  69. Mosses PD (2004) Modular structural operational semantics. J Log Algebr Program 60–61: 195–228

    Article  MathSciNet  Google Scholar 

  70. Müller P, Poetzsch-Heffter A, Leavens GT (2006) Modular invariants for layered object structures. Sci Comput Programm 62(3):253–286. Special issue on source code analysis and manipulation (SCAM 2005)

    Google Scholar 

  71. Meseguer J, Rosu G (2011) The rewriting logic semantics project: a progress report. In: Owe O, Steffen M, Telle J (eds) Fundamentals of computation theory, volume 6914 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 1–37

  72. Milner R, Tofte M, MacQueen D (1997) The definition of standard ML. MIT Press, Cambridge

    Google Scholar 

  73. Nipkow T (2003) Java bytecode verification. J Autom Reason 30(3–4): 233–233

    Article  MathSciNet  Google Scholar 

  74. Nipkow T, Paulson LC, Wenzel M (2002) Isabelle/HOL—a proof assistant for higher-order logic, volume 2283 of LNCS. Springer, Berlin

  75. Owens S (2008) A sound semantics for OCaml light. In: Drossopoulou S (ed) European symposium on programming (ESOP), volume 4960 of lecture notes in computer science, pp 1–15. Springer, Berlin

  76. Pop A, Fritzson P (2007) An Eclipse-based integrated environment for developing executable structural operational semantics specifications. In: Electronic notes in theoretical computer science, 175(1):71 – 75, 2007. Proceedings of the third workshop on structural operational semantics (SOS 2006)

  77. Poetzsch-Heffter A, Schäfer J (2006) Modular specification of encapsulated object-oriented components. In: de Boer F, Bonsangue M, Graf S, de Roever W-P (eds) Formal methods for components and objects, volume 4111 of lecture notes in computer science, pp 313–341. Springer, Berlin/Heidelberg

  78. Poetzsch-Heffter A, Schäfer J (2007) A representation-independent behavioral semantics for object-oriented components. In: Bonsangue M, Johnsen E (eds) Formal methods for open object-based distributed systems, volume 4468 of lecture notes in computer science. Springer, Berlin/Heidelberg, pp 157–173

  79. Plotkin GD (1981) A structural approach to operational semantics. Technical Report DAIMI FN-19, Computer Science Department, Aarhus University

  80. Plotkin GD (2004) A structural approach to operational semantics. J Log Algebr Program 60–61: 17–139

    MathSciNet  Google Scholar 

  81. Reichel H (1995) An approach to object semantics based on terminal co-algebras. Math Struct Comput Sci 5(02): 129–152

    Article  MATH  MathSciNet  Google Scholar 

  82. Reynolds JC (1998) Theories of programming languages. Cambridge University Press, Cambridge

    Book  MATH  Google Scholar 

  83. Smith G (2000) The Object-Z specification language. Springer, Berlin

    Book  MATH  Google Scholar 

  84. Spivey JM (1992) The Z notation: a reference manual, 2nd edn. Prentice Hall, Upper Saddle River

  85. Stark RF, Schmid J, Börger E (2001) Java and the Java Virtual Machine: definition, verification, validation. Springer, Berlin

  86. Silva L, Sampaio A, Liu Z (2008) Laws of object-orientation with reference semantics. In: IEEE international conference on software engineering and formal methods, Los Alamitos, CA, USA, IEEE Computer Society, pp 217–226

  87. Stärk RF (2005) Formal specification and verification of the C# thread model. Theor Comput Sci 343(3): 482–508

    Article  MATH  Google Scholar 

  88. Stroustrup B (1997) The C++ Programming Language. Addison-Wesley, Reading

  89. Turi D, Plotkin GD (1997) Towards a mathematical operational semantics. In: IEEE symposium on logic in computer science (LICS), pp 280–291. IEEE Computer Society

  90. van Glabbeek R (2001) The linear time: branching time spectrum I. In: Bergstra J, Ponse A, Smolka S (eds) Handook of process algebra. North-Holland, Amsterdam, pp 3–99

  91. Verdejo A, Mart-Oliet N (2004) Implementing CCS in Maude 2. Electronic Notes Theor Comput Sci 71: 282–300

    Article  Google Scholar 

  92. Verdejo A, Mart-Oliet N (2006) Executable structural operational semantics in Maude. J Logic Algebraic Programm 67(1–2): 226–293

    Article  MATH  Google Scholar 

  93. Wasserrab D, Nipkow T, Snelting G, Tip F (2006) An operational semantics and type safety proof for multiple inheritance in C++. In: Proceedings of the 21st annual ACM SIGPLAN conference on Object-oriented programming systems, languages, and applications, (OOPSLA 06), pp 345–362. ACM

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Robert J. Colvin.

Additional information

Dong Jin Song

Rights and permissions

Reprints and permissions

About this article

Cite this article

Colvin, R.J. An operational semantics for object-oriented concepts based on the class hierarchy. Form Asp Comp 26, 491–535 (2014). https://doi.org/10.1007/s00165-012-0259-y

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00165-012-0259-y

Keywords

Navigation