Formal Aspects of Computing

, Volume 26, Issue 4, pp 761–793 | Cite as

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

  • Ferruccio Damiani
  • Johan Dovland
  • Einar Broch Johnsen
  • Ina Schaefer
Original Article

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.

Keywords

Traits Object orientation Program verification Proof systems Incremental reasoning 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. AdBO09.
    Apt KR, de Boer FS, Olderog ER (2009) Verification of sequential and concurrent systems. Texts and Monographs in Computer Science, 3rd edn. Springer, BerlinGoogle Scholar
  2. AKL13.
    Apel S, Kästner C, Lengauer C (2013) Language-independent and automated software composition: the featureHouse experience. IEEE Trans Softw Eng 39(1): 63–79CrossRefGoogle Scholar
  3. Ald05.
    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, BerlinGoogle Scholar
  4. ALZ03.
    Ancona D, Lagorio G, Zucca E (2003) Jam—designing a Java extension with mixins. Trans Program Lang Syst 25(5): 641–712CrossRefGoogle Scholar
  5. Ame91.
    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, BerlinGoogle Scholar
  6. Apt81.
    Apt KR (1981) Ten years of Hoare’s logic: a survey—Part I. Trans Program Lang Syst 3(4): 431–483CrossRefMATHGoogle Scholar
  7. BC90.
    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 YorkGoogle Scholar
  8. BCC+05.
    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–232CrossRefGoogle Scholar
  9. BCD12.
    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. BDD+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, BerlinGoogle Scholar
  11. BDG07.
    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)Google Scholar
  12. BDG08.
    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, BerlinGoogle Scholar
  13. BDGS13.
    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–247CrossRefMATHGoogle Scholar
  14. BDN+09.
    Black A, Ducasse S, Nierstrasz O, Pollet D, Cassou D, Denker M (2009) Pharo by example. Square Bracket AssociatesGoogle Scholar
  15. BDNW08.
    Bergel A, Ducasse S, Nierstrasz O, Wuyts R (2008) Stateful traits and their formalization. Comput Lang Syst Struct 34(2–3): 83–108Google Scholar
  16. BDS09.
    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. BDS10.
    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 YorkGoogle Scholar
  18. BDSS10.
    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 YorkGoogle Scholar
  19. BDSS13.
    Bettini L, Damiani F, Schaefer I, Strocco F (2013) TraitRecordJ: a programming language with traits and records. Sci Comput Program 78(5):521–541Google Scholar
  20. BHS07.
    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, BerlinGoogle Scholar
  21. BRJ99.
    Booch G, Rumbaugh JE, Jacobson I (1999) The unified modeling language user guide. Addison-Wesley, ReadingGoogle Scholar
  22. BRLM11.
    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 YorkGoogle Scholar
  23. BSR04.
    Batory D, Sarvela JN, Rauschmayer A (2004) Scaling step-wise refinement. IEEE Trans Softw Eng 30: 355–371CrossRefGoogle Scholar
  24. BvW98.
    Back R-J, von Wright J (1998) Refinement calculus: a systematic introduction. Graduate texts in computer science. Springer, BerlinGoogle Scholar
  25. dB99.
    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, BerlinGoogle Scholar
  26. DDJ+12.
    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 YorkGoogle Scholar
  27. DDJS11.
    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 YorkGoogle Scholar
  28. DJOS10.
    Dovland J, Johnsen EB, Owe O, Steffen M (2010) Lazy behavioral subtyping. J Logic Algebraic Program 79(7): 578–607CrossRefMATHMathSciNetGoogle Scholar
  29. DJOS11.
    Dovland J, Johnsen EB, Owe O, Steffen M (2011) Incremental reasoning with lazy behavioral subtyping for multiple inheritance. Sci Comput Program 76(10): 915–941CrossRefMATHGoogle Scholar
  30. DNS+06.
    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–388CrossRefGoogle Scholar
  31. FES10.
    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, BerlinGoogle Scholar
  32. FKF98.
    Flatt M, Krishnamurthi S, Felleisen M (1998) Classes and mixins. In: Proceedings of principles of programming languages (POPL), pp 171–183. ACM Press, New YorkGoogle Scholar
  33. HLL+12.
    Hatcliff J, Leavens GT, Leino KRM, Müller P, Parkinson MJ (2012) Behavioral interface specification languages. ACM Comput Surv 44(3): 16CrossRefGoogle Scholar
  34. Hoa69.
    Hoare CAR (1969) An axiomatic basis of computer programming. Commun ACM 12:576–580Google Scholar
  35. Hoa71.
    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, BerlinGoogle Scholar
  36. HS12.
    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, BerlinGoogle Scholar
  37. IPW01.
    Igarashi A, Pierce BC, Wadler P (2001) Featherweight Java: a minimal core calculus for Java and GJ. Trans Program Lang Syst 23(3): 396–450CrossRefGoogle Scholar
  38. JOY06.
    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–66CrossRefMATHMathSciNetGoogle Scholar
  39. KF07.
    Krishnamurthi S, Fisler K (2007) Foundations of incremental aspect model-checking. Trans Softw Eng Methodol 16(2)Google Scholar
  40. KLM+97.
    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, BerlinGoogle Scholar
  41. LN06.
    Leavens GT, Naumann DA (2006) Behavioral subtyping, specification inheritance, and modular reasoning. Technical Report 06-20a, Department of Computer Science, Iowa State University, AmesGoogle Scholar
  42. LQ08.
    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–40Google Scholar
  43. LS08a.
    Liquori L, Spiwack A (2008) Extending FeatherTrait Java with interfaces. Theor Comput Sci 398(1–3): 243–260CrossRefMATHMathSciNetGoogle Scholar
  44. LS08b.
    Liquori L, Spiwack A (2008) FeatherTrait: a modest extension of Featherweight Java. Trans Program Lang Syst 30(2): 1–32CrossRefGoogle Scholar
  45. LSZ09.
    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)Google Scholar
  46. LW94.
    Liskov B, Wing JM (1994) A behavioral notion of subtyping. Trans Program Lang Syst 16(6): 1811–1841CrossRefGoogle Scholar
  47. NCMM09.
    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–214Google Scholar
  48. NDS06.
    Nierstrasz O, Ducasse S, Schärli N (2006) Flattening traits. J Object Technol 5(4): 129–148CrossRefGoogle Scholar
  49. OG76.
    Owicki S, Gries D (1976) An axiomatic proof technique for parallel programs I. Acta Inf 6(4): 319–340CrossRefMATHMathSciNetGoogle Scholar
  50. OSV10.
    Odersky M, Spoon L, Venners B (2010) Programming in Scala, 2 edn. Artima Press, CaliforniaGoogle Scholar
  51. PB08.
    Parkinson MJ, Bierman GM (2008) Separation logic, abstraction and inheritance. In: Proceedings of principles of programming languages (POPL), pp 75–86. ACM Press, New YorkGoogle Scholar
  52. PBC06.
    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 YorkGoogle Scholar
  53. PHM99.
    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, BerlinGoogle Scholar
  54. RT06.
    Reppy JH, Turon A (2006) A foundation for trait-based metaprogramming. In: Proceedings of FOOL/WOODGoogle Scholar
  55. RT07.
    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, BerlinGoogle Scholar
  56. SAC+11.
    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, BerlinGoogle Scholar
  57. SBB+10.
    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, BerlinGoogle Scholar
  58. Sch10.
    Schwerhoff M (2010) Verifying scala traits. Semester Report, Swiss Federal Institute of Technology Zurich (ETH)Google Scholar
  59. SD05.
    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, BerlinGoogle Scholar
  60. SDNB03.
    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, BerlinGoogle Scholar
  61. Tra11.
    TraitRecordJ website (2011) http://traitrecordj.sourceforge.net/
  62. TSAH12.
    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 YorkGoogle Scholar
  63. TSKA11.
    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 YorkGoogle Scholar
  64. LM96.
    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–30Google Scholar
  65. vSC10.
    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 YorkGoogle Scholar
  66. Wil91.
    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, BerlinGoogle Scholar

Copyright information

© British Computer Society 2013

Authors and Affiliations

  • Ferruccio Damiani
    • 1
  • Johan Dovland
    • 2
  • Einar Broch Johnsen
    • 2
  • Ina Schaefer
    • 3
  1. 1.Dipartimento di InformaticaUniversità di TorinoTorinoItaly
  2. 2.Department of InformaticsUniversity of OsloBlindernNorway
  3. 3.Institute for Software EngineeringTechnische Universität BraunschweigBrunswickGermany

Personalised recommendations