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.
Similar content being viewed by others
References
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
Abadi M, Cardelli L (1996) A theory of objects. Springer, Berlin
Á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
Á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
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
Alves-Foss, J (ed) (1999) Formal syntax and semantics of Java, volume 1523 of lecture notes in computer science. Springer, Berlin
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
Arnold K, Gosling J, Holmes D (2000) The Java programming language. 3rd edn. Addison-Wesley, Boston
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
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
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
Birtwistle GM, Dahl O-J, Myhrhaug B, Nygaard K (1973) SIMULA begin. Auerbach Publishers Inc, Philadelphia
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
Bergstra JA, Klop JW (1984) Process algebra for synchronous communication. Inform Control 60(1–3): 109–137
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)
Brookes S (2007) A semantics for concurrent separation logic. Theor Comput Sci 375(1G3): 227–270
Börger E, Stärk RF (2003) Abstract state machines: a method for high-level system design and analysis. Springer, Berlin
Chalub F, Braga C (2007) Maude MSOS tool. Electr. Notes Theor Comput Sci 176(4): 133–146
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
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
Colvin RJ, Hayes IJ (2011) Structural operational semantics through context-dependent behaviour. J Logic Algebraic Programm 80(7): 392–426
Coleman JW, Jones CB (2007) A structural proof of the soundness of rely/guarantee rules. J Log Comput 17(4): 807–841
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
de Boer FS (2009) A shared-variable concurrency analysis of multi-threaded object-oriented programs. Theor Comput Sci 410(2–3): 128–141
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
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
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).
Ducournau R, Privat J (2011) Metamodeling semantics of multiple inheritance. Sci Comput Programm 76(7): 555–586
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
de Roever W-P, Engelhardt K (2001) Data Refinement: model-oriented proof methods and their comparison. Cambridge University Press, Cambridge
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
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
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
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
Fruja NG (2010) Towards proving type safety of C#. Comput Lang Syst Struct 36(1): 60–95
Gamma E, Helm R, Johnson R, Vlissides J (1995) Design patterns: elements of reusable object-oriented software. Addison-Wesley Professional, Reading
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)
Goldberg A, Robson D (2002) Smalltalk 80: the language and its implementation. Addison-Wesley, Reading
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
Hartel PH, Moreau L (2001) Formalizing the safety of Java, the Java virtual machine, and Java card. ACM Comput Surv 33(4): 517–558
Hoare CAR (1985) Communicating sequential processes. Prentice-Hall, Inc., Upper Saddle River
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
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)
Jones CB (1983) Specification and design of (parallel) programs. In: IFIP Congress, pp 321–332
Jones CB (1983) Tentative steps toward a development method for interfering programs. ACM Trans Program Lang Syst 5: 596–619
Jones CB (1990) Systematic Software Development using VDM. Prentice Hall, Upper Saddle River
Jones CB (2003) Operational semantics: concepts and their expression. Inf Process Lett 88(1–2): 27–32
Jones CB (2003) Wanted: a compositional approach to concurrency. Programming methodology. Springer, Berlin, pp 5–15
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
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
Klin B (2011) Bialgebras for structural operational semantics: an introduction. Theor Comput Sci 412(38): 5043–5069
Kifer M, Lausen G, Wu J (1995) Logical foundations of object-oriented and frame-based languages. J ACM 42(4): 741–843
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
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
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
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
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
Logozzo F (2009) Class invariants as abstract interpretation of trace semantics. Comput Lang Syst Struct 35(2): 100–142
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
Meyer B (2000) Object-oriented software construction. 2nd edn. Prentice Hall PTR, Upper Saddle River
Matthews J, Findler RB (2008) An operational semantics for Scheme. J Funct Program 18(1): 47–86
Milner R (1982) A calculus of communicating systems. Springer, New York
Milner R (1989) Communication and concurrency. Prentice Hall, Upper Saddle River
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
Mosses PD, New MJ (2009) Implicit propagation in structural operational semantics. Electr Notes Theor Comput Sci 229(4): 49–66
Morgan C (1994) Programming from Specifications. 2nd edn. Prentice Hall, Upper Saddle River
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
Mosses PD (2004) Exploiting labels in structural operational semantics. Fundam Inform 60(1–4): 17–31
Mosses PD (2004) Modular structural operational semantics. J Log Algebr Program 60–61: 195–228
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)
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
Milner R, Tofte M, MacQueen D (1997) The definition of standard ML. MIT Press, Cambridge
Nipkow T (2003) Java bytecode verification. J Autom Reason 30(3–4): 233–233
Nipkow T, Paulson LC, Wenzel M (2002) Isabelle/HOL—a proof assistant for higher-order logic, volume 2283 of LNCS. Springer, Berlin
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
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)
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
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
Plotkin GD (1981) A structural approach to operational semantics. Technical Report DAIMI FN-19, Computer Science Department, Aarhus University
Plotkin GD (2004) A structural approach to operational semantics. J Log Algebr Program 60–61: 17–139
Reichel H (1995) An approach to object semantics based on terminal co-algebras. Math Struct Comput Sci 5(02): 129–152
Reynolds JC (1998) Theories of programming languages. Cambridge University Press, Cambridge
Smith G (2000) The Object-Z specification language. Springer, Berlin
Spivey JM (1992) The Z notation: a reference manual, 2nd edn. Prentice Hall, Upper Saddle River
Stark RF, Schmid J, Börger E (2001) Java and the Java Virtual Machine: definition, verification, validation. Springer, Berlin
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
Stärk RF (2005) Formal specification and verification of the C# thread model. Theor Comput Sci 343(3): 482–508
Stroustrup B (1997) The C++ Programming Language. Addison-Wesley, Reading
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
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
Verdejo A, Mart-Oliet N (2004) Implementing CCS in Maude 2. Electronic Notes Theor Comput Sci 71: 282–300
Verdejo A, Mart-Oliet N (2006) Executable structural operational semantics in Maude. J Logic Algebraic Programm 67(1–2): 226–293
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
Author information
Authors and Affiliations
Corresponding author
Additional information
Dong Jin Song
Rights 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
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00165-012-0259-y