Rumer a Programming Language and Modular Verification Technique Based on Relationships
Total Page:16
File Type:pdf, Size:1020Kb
Research Collection Doctoral Thesis Rumer A programming language and modular verification technique based on relationships Author(s): Balzer, Stephanie Publication Date: 2011 Permanent Link: https://doi.org/10.3929/ethz-a-007086593 Rights / License: In Copyright - Non-Commercial Use Permitted This page was generated automatically upon download from the ETH Zurich Research Collection. For more information please consult the Terms of use. ETH Library Diss. ETH No. 19851 RUMER: A PROGRAMMING LANGUAGE AND MODULAR VERIFICATION TECHNIQUE BASED ON RELATIONSHIPS A dissertation submitted to ETH Zurich for the degree of Doctor of Sciences presented by Stephanie Balzer accepted on the recommendation of Prof. Dr. Thomas R. Gross, examiner Prof. Dr. Sophia Drossopoulou, co-examiner Prof. Dr. Peter Müller, co-examiner Dr. Alexander J. Summers, co-examiner 2011 Abstract The idea of asserting a program’s correctness by a mathematical proof rather than ex- haustive testing has persisted in software system development. The notion of an invariant to capture the constant properties of data plays a central role in such program verifica- tion attempts. Invariants have also infiltrated object-oriented programming languages and have become a foundation for verifying object-oriented programs. Current invariant-based, object-oriented verification techniques provide modular verifica- tion of single-object invariants. However, as soon as an invariant relates several objects, modular reasoning about the invariant is not possible without imposing certain restric- tions on the program. Current solutions to the verification of such multi-objects invari- ants either restrict aliasing in a program or expand the visibility of an invariant beyond the boundary of the declaring class. This thesis represents a two-part approach to program verification based on invariants. We develop a programming language, Rumer, that provides higher-level abstractions to capture not only objects but also the relationships between them. In addition, we elaborate a visible-state verification technique for Rumer that facilitates the modular verification of Rumer programs. The Rumer programming language employs the abstraction of a relationship as a key architectural element in building a software system. Rather than employing references in objects to represent the relationships between objects, those relationships are repre- sented explicitly by a relationship instance. This indirection gives rise to a stratified programming model. Based on this model, we formulate the Matryoshka Principle, a modularization discipline that provides strong encapsulation for Rumer types. The verification technique is based on the Matryoshka Principle and leverages the par- ticular features of the Rumer programming and specification language. The Matryoshka Principle provides modular reasoning about state changes and permits the adoption of a visible-state semantics for invariants. The Rumer programming and specification lan- guage encompasses techniques to encapsulate multi-object invariants in relationships and includes a rich assertion language that is based on discrete mathematics. i Zusammenfassung Die Idee, die Korrektheit eines Programms durch einen mathematischen Beweis anstatt durch ausgiebiges Testen sicherzustellen, hat seit jeher eine zenrale Bedeutung in der Ent- wicklung von Softwaresystemen eingenommen. Verifikationsansätze basieren traditions- gemäss auf Invarianten, die jene Eigenschaften von Daten spezifizieren, die zur Laufzeit des Programms konstant sind. Invarianten finden mittlerweile auch in objektorientierten Programmiersprachen Anwendung und haben sich zu einer wichtigen Grundlage für die Verifikation objektorientierter Programme entwickelt. Gängige invariantenbasierte, objektorientierte Verifikationstechniken erlauben die modu- lare Verifikation von Invarianten, die sich auf ein einzelnes Objekt beziehen. Setzt eine Invariante jedoch mehrere Objekte zueinander in Beziehung, ist modulares Schliessen nur mittels Einschränkungen des Programms möglich. Gängige Lösungsansätze für die Verifikation solcher Multi-Objekt-Invarianten unterbinden entweder das Aliasing (d.h. die Existenz unterschiedlicher Referenzen auf denselben Speicherplatz) oder weiten die Sichtbarkeit einer Invariante über die Grenzen der deklarierenden Klasse hinaus aus. Die vorliegende Dissertation präsentiert einen zweistufigen Ansatz für die Verifikation in- variantenbasierter Programme. Wir beschreiben die Programmiersprache Rumer, welche Abstraktionen für die Repräsentation von Objekten und deren Beziehungen zueinander zur Verfügung stellt. Des Weiteren erarbeiten wir eine Verifikationstechnik für Rumer. Diese basiert auf sichtbaren Zuständen und ermöglicht die modulare Verifikation von Rumer Programmen. Die Programmiersprache Rumer verwendet die Abstraktion einer Beziehung als grund- legendes Sprachkonstrukt zur Bildung eines Softwaresystems. Dabei werden die Bezie- hungen zwischen Objekten durch explizite Beziehungsinstanzen repräsentiert und nicht durch Referenzen in den beteiligten Objekten. Die Verwendung expliziter Beziehungsin- stanzen zusätzlich zu den beteiligten Objekten führt zu einem mehrschichtigen Program- miermodell. Ausgehend von diesem Programmiermodell formulieren wir das Matrjoschka- Prinzip — ein Modularisierungsansatz, der starke Kapselungseigenschaften für Rumer Datentypen gewährleistet. Die Verifikationstechnik basiert auf dem Matrjoschka-Prinzip und nutzt die spezifischen Eigenschaften der Programmiersprache Rumer und deren Spezifikationssprache aus. Das Matrjoschka-Prinzip ermöglicht das modulare Schliessen über Zustandswechsel und ga- rantiert, dass Invarianten in sichtbaren Programmzuständen gelten. Die Programmierspra- iii che Rumer und deren Spezifikationssprache bieten Techniken zur Kapselung von Multi- Objekt-Invarianten in Beziehungen und unterstützen eine reiche, auf diskreter Mathema- tik beruhende Aussagensprache. iv Acknowledgments I am grateful to the following persons who have accompanied my journey to a PhD: My advisor Thomas Gross. His patience, allowing me to explore and substantiate my research ideas, and his scientific curiosity towards new, maybe even unconventional, re- search ideas are unparalleled. But above all, he has guided me to become, I believe, an independent researcher. My co-examiners Sophia Drossopoulou, Peter Müller, and Alex Summers. I am grate- ful for their valuable feedback, allowing me to improve this thesis importantly. Sophia’s thought-provoking questions on the occasion of my visit have decisively influenced the last revision of the Rumer language. The discussions with Alex on visible-state verifica- tion techniques have deepened my understanding thereof, and I am very appreciative of Alex’s meticulous reading of this thesis, allowing me to greatly polish it. The researchers I was fortunate to get to know at ETH. I am grateful to: Jean-Raymond Abrial for introducing me to formal methods and for his support of my PhD work; Laurent Voisin for his assistance in formal methods and for sharing his enormous knowledge; Patrick Eugster for his belief in first-class relationships and for pushing me to “go for my ideas”. Also, I would like to thank Bertrand Meyer for providing me a start at ETH. My colleagues at ETH. In particular, I want to thank Susanne Cech Previtali for sharing my passion in the search for the right abstraction, her advice, and sisterhood. Also, I want to thank my colleagues of the LST research group Christoph Angerer, Mihai Cuibus, Nicu Fruja, Zoltán Majó, Nicholas Matsakis, Valery Naumov, Albert Noll, Mathias Payer, Michael Pradel, Florian Schneider, Yang Su, Luca Della Toffola, Oliver Trachsel, Cristian Tuduce, and Faheem Ullah for stimulating discussions, both on and off research topics. Furthermore, I want to thank Karine Arnout, Arnaud Bailly, Ilinca Ciupa, Werner Dietl, Lisa Ling Liu, Piotr Nienaltowski, Joseph Ruskiewicz, Silvia Santini, Bernd Schoeller, Sebastien Vaucouleur, and Christoph Wintersteiger for their support and friendship. The students whose projects I was privileged to supervise: Christoph Bäni, Alexandra Burns, Reto Conconi, Roland Schilter, Ágnes Sebestyén-Pál, Shinji Takasaka, Michelle Volery, and Andrea Zimmermann. My parents and my sister Charlotte. I am grateful for their love and encouragement. My partner Adnan. Without his love and unconditional support this work would not have been possible. v Contents 1 Introduction 1 1.1 Thesis ............................................... 3 1.2 Content and contribution ................................. 3 2 Relationships 7 2.1 OO relationships ....................................... 7 2.1.1 Running example .................................. 8 2.1.2 Relationship features ............................... 9 2.1.3 Programming idioms ............................... 9 2.2 Empirical study ........................................ 15 2.2.1 Analysis corpus ................................... 15 2.2.2 Metrics ......................................... 15 2.2.3 Results ......................................... 21 2.2.4 Analysis ......................................... 25 2.3 First-class relationships ................................... 29 2.3.1 Deficiencies of OO relationships ....................... 30 2.3.2 Toward first-class relationships ........................ 32 2.4 Related work .......................................... 34 3 Rumer: a relationship-based programming language 39 3.1 Rationale ............................................. 39 3.2 Language concepts .....................................