Skip to main content
Log in

Verifying traits: an incremental proof system for fine-grained reuse

  • Original Article
  • Published:
Formal Aspects of Computing

Abstract

Traits have been proposed as a more flexible mechanism than class inheritance for structuring code in object-oriented programming, to achieve fine-grained code reuse. A trait originally developed for one purpose can be adapted and reused in a completely different context. Formalizations of traits have been extensively studied, and implementations of traits have started to appear in programming languages. So far, work on formally establishing properties of trait-based programs has mostly concentrated on type systems. This paper presents the first deductive proof system for a trait-based object-oriented language. If a specification of a trait can be given a priori, covering all actual usage of that trait, our proof system is modular as each trait is analyzed only once. However, imposing such a restriction may in many cases unnecessarily limit traits as a mechanism for flexible code reuse. In order to reflect the flexible reuse potential of traits, our proof system additionally allows new specifications to be added to a trait in an incremental way which does not violate established proofs. We formalize and show the soundness of the proof system.

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. Apt KR, de Boer FS, Olderog ER (2009) Verification of sequential and concurrent systems. Texts and Monographs in Computer Science, 3rd edn. Springer, Berlin

  2. Apel S, Kästner C, Lengauer C (2013) Language-independent and automated software composition: the featureHouse experience. IEEE Trans Softw Eng 39(1): 63–79

    Article  Google Scholar 

  3. Aldrich J (2005) Open modules: modular reasoning about advice. In: Black AP (ed) Proceedings of European conference on object-oriented programming (ECOOP), volume 3586 of lecture notes in computer science, pp 144–168. Springer, Berlin

  4. Ancona D, Lagorio G, Zucca E (2003) Jam—designing a Java extension with mixins. Trans Program Lang Syst 25(5): 641–712

    Article  Google Scholar 

  5. America P (1991) Designing an object-oriented programming language with behavioural subtyping. In: de Bakker JW, de Roever W-P, Rozenberg G (eds) Foundations of object-oriented languages, volume 489 of lecture notes in computer science, pp 60–90. Springer, Berlin

  6. Apt KR (1981) Ten years of Hoare’s logic: a survey—Part I. Trans Program Lang Syst 3(4): 431–483

    Article  MATH  Google Scholar 

  7. Bracha G, Cook W (1990) Mixin-based inheritance. In: Meyrowitz N, (ed) Proceedings of the conference on object-oriented programming: systems, languages, and applications / European conference on object-oriented programming, pp 303–311. ACM Press, New York

  8. Burdy L, Cheon Y, Cok DR, Ernst MD, Kiniry JR, Leavens GT, Leino KRM, Poll E (2005) An overview of JML tools and applications. Int J Softw Tools Technol Transf 7(3): 212–232

    Article  Google Scholar 

  9. Bettini L, Capecchi S, Damiani F (2012) On flexible dynamic trait repacement for Java-like languages. Sci Comput Program. Available online doi:10.1016/j.scico.2012.11.003

  10. Bettini L, Damiani F, De Luca M, Geilmann K, Schäfer 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, pp 46–60. Springer, Berlin

  11. Bono V, Damiani F, Giachino E (2007) Separating type, behavior, and state to achieve very fine-grained reuse. In: Proceedings of formal techniques for Java-like Programs (FTfJP)

  12. Bono V, Damiani F, Giachino E (2008) On traits and types in a Java-like setting. In: Fifth IFIP international conference on theoretical computer science (TCS’08), volume 273 of international federation for information processing, pp 367–382. Springer, Berlin

  13. Bettini L, Damiani F, Geilmann K, Schäfer J (2013) Combining traits with boxes and ownership types in a Java-like setting. Sci Comput Program 78(2): 218–247

    Article  MATH  Google Scholar 

  14. Black A, Ducasse S, Nierstrasz O, Pollet D, Cassou D, Denker M (2009) Pharo by example. Square Bracket Associates

  15. Bergel A, Ducasse S, Nierstrasz O, Wuyts R (2008) Stateful traits and their formalization. Comput Lang Syst Struct 34(2–3): 83–108

    Google Scholar 

  16. Bettini L, Damiani F, Schaefer I (2009) Implementing SPL using Traits. Technical report, Dipartimento di Informatica, Università di Torino. Available at http://www.di.unito.it/~damiani/papers/isplurat.pdf

  17. Bettini L, Damiani F, Schaefer I (2010) Implementing software product lines using traits. In: Proceedings of the 2010 ACM symposium on applied computing (SAC’10), pp 2096–2102. ACM Press, New York

  18. Bettini L, Damiani F, Schaefer I, Strocco F (2010) A prototypical Java-like language with records and traits. In: Proceedings of the 8th international conference on the principles and practice of programming in Java (PPPJ’10), pp 129–138. ACM Press, New York

  19. Bettini L, Damiani F, Schaefer I, Strocco F (2013) TraitRecordJ: a programming language with traits and records. Sci Comput Program 78(5):521–541

    Google Scholar 

  20. Beckert B, Hähnle R, Schmitt PH (eds) (2007) Verification of object-oriented software: the key approach, volume 4334 of lecture notes in computer science. Springer, Berlin

  21. Booch G, Rumbaugh JE, Jacobson I (1999) The unified modeling language user guide. Addison-Wesley, Reading

  22. Bagherzadeh M, Rajan H, Leavens GT, Mooney SL (2011) Translucid contracts: expressive specification and modular verification for aspect-oriented interfaces. In: Borba P, Chiba S (eds) Proceedings of the 10th international conference on aspect-oriented software development (AOSD 2011), pp 141–152. ACM Press, New York

  23. Batory D, Sarvela JN, Rauschmayer A (2004) Scaling step-wise refinement. IEEE Trans Softw Eng 30: 355–371

    Article  Google Scholar 

  24. Back R-J, von Wright J (1998) Refinement calculus: a systematic introduction. Graduate texts in computer science. Springer, Berlin

  25. de Boer FS (1999) A WP-calculus for OO. In: Thomas W (ed) Proceedings of foundations of software science and computation structure (FOSSACS’99), volume 1578 of lecture notes in computer science, pp 135–149. Springer, Berlin

  26. Damiani F, Dovland J, Johnsen EB, Owe O, Schaefer I, Yu IC (2012) A transformational proof system for delta-oriented programming. In: de Almeida ES, Schwanninger C, Benavides D (eds) Proceedings of 16th international software product line conference (SPLC’12), vol 2, pp 53–60. ACM Press, New York

  27. Damiani F, Dovland J, Johnsen EB, Schaefer I (2011) Verifying traits: a proof system for fine-grained reuse. In: Proceedings of formal techniques for Java-like programs (FTfJP), pp 8:1–8:6. ACM Press, New York

  28. Dovland J, Johnsen EB, Owe O, Steffen M (2010) Lazy behavioral subtyping. J Logic Algebraic Program 79(7): 578–607

    Article  MATH  MathSciNet  Google Scholar 

  29. Dovland J, Johnsen EB, Owe O, Steffen M (2011) Incremental reasoning with lazy behavioral subtyping for multiple inheritance. Sci Comput Program 76(10): 915–941

    Article  MATH  Google Scholar 

  30. Ducasse S, Nierstrasz O, Schärli N, Wuyts R, Black AP (2006) Traits: a mechanism for fine-grained reuse. Trans Program Lang Syst 28(2): 331–388

    Article  Google Scholar 

  31. De Fraine B, Ernst E, Südholt M (2010) Essential AOP: the A calculus. In: D’Hondt T (ed) Proceedings of European conference on object-oriented programming (ECOOP), volume 6183 of lecture notes in computer science, pp 101–125. Springer, Berlin

  32. Flatt M, Krishnamurthi S, Felleisen M (1998) Classes and mixins. In: Proceedings of principles of programming languages (POPL), pp 171–183. ACM Press, New York

  33. Hatcliff J, Leavens GT, Leino KRM, Müller P, Parkinson MJ (2012) Behavioral interface specification languages. ACM Comput Surv 44(3): 16

    Article  Google Scholar 

  34. Hoare CAR (1969) An axiomatic basis of computer programming. Commun ACM 12:576–580

    Google Scholar 

  35. Hoare CAR (1971) Procedures and parameters: An axiomatic approach. In: Engeler E (e) Symposium on semantics of algorithmic languages, volume 188 of lecture notes in mathematics, pp 102–116. Springer, Berlin

  36. Hähnle R, Schaefer I (2012) A Liskov principle for delta-oriented programming. In: Margaria T, Steffen B (eds) Proceedings of 5th international symposium on leveraging applications of formal methods, verification and validation (ISoLA), volume 7609 of lecture notes in computer science, pp 32–46. Springer, Berlin

  37. Igarashi A, Pierce BC, Wadler P (2001) Featherweight Java: a minimal core calculus for Java and GJ. Trans Program Lang Syst 23(3): 396–450

    Article  Google Scholar 

  38. Johnsen EB, Owe O, Yu IC (2006) Creol: a type-safe object-oriented model for distributed concurrent systems. Theor Comput Sci 365(1–2): 23–66

    Article  MATH  MathSciNet  Google Scholar 

  39. Krishnamurthi S, Fisler K (2007) Foundations of incremental aspect model-checking. Trans Softw Eng Methodol 16(2)

  40. Kiczales G, Lamping J, Mendhekar A, Maeda C, Lopes C, Loingtier J-M, Irwin J (1997) Aspect-oriented programming. In: Akşit M, Matsuoka S (eds) Proceedings of European conference on object-oriented programming (ECOOP), volume 1241 of lecture notes in computer science, pp 220–242. Springer, Berlin

  41. Leavens GT, Naumann DA (2006) Behavioral subtyping, specification inheritance, and modular reasoning. Technical Report 06-20a, Department of Computer Science, Iowa State University, Ames

  42. Luo C, Qin S (2008) Separation logic for multiple inheritance. Electronic Notes in Theoretical Computer Science. In: Proceedings of first international conference on foundations of informatics, computing and software (FICS), vol 212, pp 27–40

  43. Liquori L, Spiwack A (2008) Extending FeatherTrait Java with interfaces. Theor Comput Sci 398(1–3): 243–260

    Article  MATH  MathSciNet  Google Scholar 

  44. Liquori L, Spiwack A (2008) FeatherTrait: a modest extension of Featherweight Java. Trans Program Lang Syst 30(2): 1–32

    Article  Google Scholar 

  45. Lagorio G, Servetto M, Zucca E (2009) Flattening versus direct semantics for featherweight jigsaw. In: Proceedings of workshop on foundations of object-oriented languages (FOOL)

  46. Liskov B, Wing JM (1994) A behavioral notion of subtyping. Trans Program Lang Syst 16(6): 1811–1841

    Article  Google Scholar 

  47. Nordio M, Calcagno C, Müller P, Meyer B (2009) A sound and complete program logic for eiffel. In: Oriol M (ed) TOOLS-EUROPE 2009, volume 33 of lecture notes in business and information processing, pp 195–214

  48. Nierstrasz O, Ducasse S, Schärli N (2006) Flattening traits. J Object Technol 5(4): 129–148

    Article  Google Scholar 

  49. Owicki S, Gries D (1976) An axiomatic proof technique for parallel programs I. Acta Inf 6(4): 319–340

    Article  MATH  MathSciNet  Google Scholar 

  50. Odersky M, Spoon L, Venners B (2010) Programming in Scala, 2 edn. Artima Press, California

  51. Parkinson MJ, Bierman GM (2008) Separation logic, abstraction and inheritance. In: Proceedings of principles of programming languages (POPL), pp 75–86. ACM Press, New York

  52. Parkinson MJ, Bornat R, Calcagno C (2006) Variables as resource in Hoare logics. In: Proceedings of symposium on logic in computer science (LICS’06), pp 137–146. IEEE Computer Society Press, New York

  53. Poetzsch-Heffter A, Müller P (1999) A programming logic for sequential Java. In: Swierstra SD (ed) 8th European symposium on programming languages and systems (ESOP’99), volume 1576 of lecture notes in computer science, pp 162–176. Springer, Berlin

  54. Reppy JH, Turon A (2006) A foundation for trait-based metaprogramming. In: Proceedings of FOOL/WOOD

  55. Reppy JH, Turon A (2007) Metaprogramming with traits. In: Proceedings of European conference on object-oriented programming (ECOOP), volume 4609 of lecture notes in computer science, pp 373–398. Springer, Berlin

  56. Steele Jr GL, Allen EE, Chase D, Flood CH, Luchangco V, Maessen J-W, Ryu S (2011) Fortress (Sun HPCS language). In: Padua DA (ed) Encyclopedia of parallel computing, pp 718–735. Springer, Berlin

  57. Schaefer I, Bettini L, Bono V, Damiani F, Tanzarella N (2010) Delta-oriented programming of software product lines. In: Bosch J, Lee J (eds) Software product lines: going beyond (SPLC’10), volume 6287 of lecture notes in computer science, pp 77–91. Springer, Berlin

  58. Schwerhoff M (2010) Verifying scala traits. Semester Report, Swiss Federal Institute of Technology Zurich (ETH)

  59. Smith C, Drossopoulou S (2005) Chai: traits for Java-like languages. In: Proceedings of European conference on object-oriented programming (ECOOP), volume 3586 of lecture notes in computer science, pp 453–478. Springer, Berlin

  60. Schärli N, Ducasse S, Nierstrasz O, Black A (2003) Traits: composable units of behavior. In: Proceedings of European conference on object-oriented programming (ECOOP), volume 2743 of lecture notes in computer science, pp 248–274. Springer, Berlin

  61. TraitRecordJ website (2011) http://traitrecordj.sourceforge.net/

  62. Thüm T, Schaefer I, Apel S, Hentschel M (2012) Family-based deductive verification of software product lines. In: International conference on generative programming and component engineering (GPCE), pp 11–20. ACM Press, New York

  63. Thüm T, Schaefer I, Kuhlemann M, Apel S (2011) Proof composition for deductive verification of software product lines. In: Proceedings of international workshop on variability-intensive systems testing, validation and verification, pp 270–277. IEEE Computer Society Press, New York

  64. Van Limberghen M, Mens T (1996) Encapsulation and composition as orthogonal operators on mixins: A solution to multiple inheritance problems. Object Oriented Syst 3(1): 1–30

    Google Scholar 

  65. van Staden S, Calcagno C (2010) Reasoning about multiple related abstractions with MultiStar. In: Proceedings of object-oriented programming systems, languages and applications (OOPSLA), pp 504–519. ACM Press, New York

  66. Wills A (1991) Capsules and types in fresco: program verification in smalltalk. In: America P (ed) Proceedings of European conference on object-oriented programming (ECOOP), volume 512 of lecture notes in computer science, pp 59–76. Springer, Berlin

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Einar Broch Johnsen.

Additional information

B. Pierce

The authors of this paper are listed in alphabetical order. This work has been partially supported by the Deutsche Forschungsgemeinschaft (SCHA 1635/2-1), the Italian MIUR (PRIN 2008 DISCO), the German-Italian University Centre (Vigoni program), and the EU project FP7-231620 HATS: Highly Adaptable and Trustworthy Software using Formal Models (http://www.hats-project.eu).

Rights and permissions

Reprints and permissions

About this article

Cite this article

Damiani, F., Dovland, J., Johnsen, E.B. et al. Verifying traits: an incremental proof system for fine-grained reuse. Form Asp Comp 26, 761–793 (2014). https://doi.org/10.1007/s00165-013-0278-3

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00165-013-0278-3

Keywords

Navigation