Dynamic Logic for an Intermediate Language: Verification, Interaction

Total Page:16

File Type:pdf, Size:1020Kb

Dynamic Logic for an Intermediate Language: Verification, Interaction Dynamic Logic for an Intermediate Language Verification, Interaction and Refinement zur Erlangung des akademischen Grades eines Doktors der Naturwissenschaften von der Fakultat¨ fur¨ Informatik des Karlsruher Instituts fur¨ Technologie (KIT) genehmigte Dissertation von Mattias Ulbrich aus Ludwigsburg Tag der mundlichen¨ Prufung:¨ 17. Juni 2013 Erster Gutachter: Prof. Dr. Peter H. Schmitt Karlsruher Institut fur¨ Technologie Zweite Gutachterin: Assoc. Prof. Dr. Marieke Huisman University of Twente Acknowledgements I would not have been able to compose this thesis without the help of many who contributed to it in various ways. First and foremost, I would like to express my special appreciation and gratitude to my advisor Professor Dr. Peter H. Schmitt for giving me the opportunity to undertake this dissertation project, for his continuous scientific advice and support, and for granting me so much freedom in my research. His gentle way of leading the group always made me feel at home. I am thankful to my second reviewer Assoc. Prof. Dr. Marieke Huisman for the time and energy she invested into fulfilling this role. My thanks go also to Juniorprofessor Dr. Mana Taghdiri and Professor Dr. Jorn¨ Muller-Quade¨ for their service as examiners in the defense committee. I have always very much enjoyed working together with my colleagues in the formal method groups at KIT. We had plenty of inspiring discussions, an excellent teamwork and lots of fun. My thanks go to my former colleagues Dr. Christian Engel, Dr. Benjamin Weiß and Dr. Frank Werner as well as to my current fellow researchers Thorsten Bormer, Daniel Bruns, Aboubakr Achraf El Ghazi, Dr. Stephan Falke, David Farago,´ Dr. Christoph Gladisch, Sarah Grebing, Simon Greiner, Markus Iser, Dr. Vladimir Klebanov, Tianhai Liu, Florian Merz, Christoph Scheben and Dr. Carsten Sinz. I am thankful to all students who worked with me; in particular to Timm Felden who helped me implementing parts of the ivil tool. I am grateful to Professor Dr. Bernhard Beckert for giving me the opportunity to continue my research on verification in his group at KIT. I would also like to express my thanks to the members of the KeY group with whom I was able to have interesting exchanges of thoughts, in particular to Professor Dr. Reiner Hahnle,¨ Dr. Richard Bubel, Dr. Wojciech Mostowski, Martin Hentschel, Dr. Philipp Rummer¨ and Dr. Wolfgang Ahrend. I owe my deepest gratitude to my parents and my family for the many years of their ongoing support and love without whom nothing would have been possible. Lastly and most importantly, infinitely many thanks to Martina for her love, vitality, care and constant encouragement from which I took the energy to finish this work. You are great. Karlsruhe, June 2013 Mattias Ulbrich Dynamische Logik f ¨ureine Zwischensprache Verifikation, Interaktion und Verfeinerung (Deutsche Zusammenfassung) Computerisierte Systeme spielen in unserem Alltag eine immer wichtigere Rolle. Viele werden dabei in Bereichen eingesetzt, in denen ihr korrektes Verhalten von hochster¨ Bedeutung ist, z. B. im Bereich von Medizintechnik oder der Flug- oder Automobiltechnologie. Immer haufiger¨ werden dabei sicherheitskritische Entschei- dungen automatisch von Softwaresystemen getroffen. Wenn diese fehlerhaft sind, so kann das fatale Auswirkungen haben, finanzieller Natur, oder gar Schaden an Leib und Leben von Menschen bedeuten. Diese Arbeit beschaftigt¨ sich damit, sicherzustellen, dass Software sich so verhalt,¨ wie sie sich verhalten soll. Praziser¨ gesagt beschaftigt¨ sie sich mit der deduktiven funktionalen Verifikation von Software-Implementierungen in Hinblick auf ihre formale Spezifikation. Formale Methoden sind eine Alternative zum Durchfuhren¨ von Softwaretests, wenn es darum geht, die funktionale Sicherheit von Systemen sicherzustellen. Die Methoden, die als formal“ klassifiziert werden konnen,¨ decken dabei eine große ” Bandbreite von Ansatzen¨ und Werkzeugen ab. Diese unterscheiden sich im Abstrak- tionsgrad, mit dem sie ein System beschreiben und auf ihm operieren und in der Starke¨ der Aussagen, die sie treffen. Die Starken¨ reichen von leichtgewichtiger Un- terstutzung¨ bei der Suche nach Fehlern (Bugs) bis hin zur Verifikation vollstandig¨ funktionaler Spezifikationen. Je starker¨ die von einer Analyse gemachten Aussa- gen jedoch sind, desto mehr Expertise, Zeit und Aufwand muss in ihre Verifikation investiert werden. Diese Arbeit halt¨ sich dabei im Bereich der Verifikation vollstandiger¨ funktionaler Spezifikationen auf. Dies ist ein aufwandiger¨ schwergewichtiger formaler Ansatz; dennoch ist das Ziel, eine Verifikation auf der Ebene des implementierten Program- mes zu bewerkstelligen und nicht (alleine) auf einer Abstraktion von ihm. Damit vereinigt der untersuchte Verifikationsansatz Schwierigkeiten aus zwei Gebieten: zum x einen die Probleme der Verifikation auf Implementierungsebene und zum anderen die der hohen Genauigkeit der Spezifikation. Um mit dieser hohen Komplexitat¨ besser umgehen zu konnen,¨ schlagt¨ diese Ar- beit vor, die Aufgabe der Verifikation mittels der zwei Werkzeuge Interaktion und Verfeinerung zu bandigen:¨ Interaktion Im Gegensatz zu leichtgewichtigen Ansatzen,¨ fur¨ die es charakteristisch ist, dass sie in relativ großem Rahmen mit relativ geringem Aufwand anwend- bar sind, ist die volle funktionale Verifikation signifikant aufwandiger¨ und benotigt¨ einen erfahrenen Benutzer. In dieser Arbeit wird ein interaktives Verifikationswerkzeug vorgestellt, mit dem in den Verifikationsprozess Einblick gewonnen werden kann und das dem Benutzer des Systems erlaubt, mit dem System hauptsachlich¨ in Begriffen des ursprunglichen¨ zu verifizierenden Programmes zu interagieren. Mittels inter- aktiven Eingreifens kann die automatische Komponente des Systems geleitet werden, bis sie schließlich den Bewies selbstandig¨ zu Ende fuhren¨ kann. Verfeinerung Volle funktionale Verifikation auf der Ebene von Implementierungen vereinigt zwei an sich schwere Aufgaben in einer. Wir schlagen eine Methodik vor, diesen schweren Auftrag in zwei jeweils leichtere zu unterteilen und dann die etablierte Technik der Verfeinerung zu benutzen, um aus der abstrakteren Beschreibung die Implementierung formal abzuleiten. Es gibt funktionale Korrektheitsaussagen, die am besten direkt auf der Imple- mentierung beschrieben und dort leicht gezeigt werden konnen,¨ und es gibt Korrektheitsaussagen, die von konzeptioneller Natur sind und besser auf einer Abstraktion des Programmes gezeigt werden. Um diese beiden Ziele zu erreichen, wird eine neue Programmlogik entworfen, die zwei seit langem im Bereich der Implementierungsverifikation erfolgreiche Paradig- men vereint. Zum einen ist dies die dynamische Logik, die einen sehr flexiblen Ansatz fur¨ die Formalisierung und den Beweis von Eigenschaften von Programmen darstellt. Sie ist eng verwandt mit anderen Programmlogiken wie der Hoare-Logik“ oder dem ” Weakest-Precondition-Kalkul“,¨ hat aber als besondere Eigenschaft, dass Programme ” freier kombiniert werden konnen.¨ Programme sind in dynamischer Logik Konstruk- toren fur¨ Formeln. Da die Menge der Formeln unter Komposition abgeschlossen ist, konnen¨ auch programminduzierte Formeln geschachtelt oder logisch verknupft¨ auftreten. Zum anderen wird die Verifikation auf einer elementaren, reduzierten aber allge- meinen Verifikationszwischensprache in den Ansatz mit eingebracht. Die Idee, Verifi- kationsbedingungen einer modernen Programmiersprache auf eine solche elementare Sprache zu reduzieren, scheint auf den ersten Blick einen Ruckschritt¨ darzustellen. Aber dieser Eindruck tauscht.¨ Eine schlanke und effiziente Kernsprache erlaubt es, den Verifikationsprozess vom Modellierungsprozess zu entkoppeln. Es gibt fortan xi das Verifikationswerkzeug und den Ubersetzer,¨ der die Beweisverpflichtung aus ei- nem in einer Hochsprache geschriebenen Programm und seiner Spezifikation heraus erzeugt. Die Zwischensprache verbindet die beiden Systeme. Ein prominenter Vertreter der Systeme, die auf auf dynamischer Logik beruhen, ist das KeY-System, das auf einer speziell ausgelegten dynamischen Logik fur¨ Java- Quelltext operiert. Ein erfolgreicher prototypischer Vertreter fur¨ ein Verifikations- system, das auf einer Zwischensprache agiert, ist das System Boogie, fur¨ das eine Vielzahl von Ubersetzern¨ existiert, die Beweisverpflichtungen aus einer Reihe von Quellsprachen und Systemen heraus erlaubt. Diese Arbeit stellt eine dynamische Logik im Stile von KeY vor, die auf einer Zwischensprache definiert ist, die mit der Sprache von Boogie die primitiven Anweisungen gemeinsam hat. Diese Arbeit beschreibt eine Methodik um Algorithmen in einer rein abstrak- ten, mathematischen Pseudocode-Sprache zu formulieren, wie sie aus Lehrbuchern¨ bekannt ist. Diese Algorithmen konnen¨ dann auf eine Implementierung in der Pro- grammiersprache Java verfeinert werden. Interessante funktionale Eigenschaften, die konzeptionell im Algorithmus begrundet¨ sind konnen¨ auf Ebene der mathe- matischen Modellierung beschrieben, untersucht und verifiziert werden, wobei die Implementierungsdetails bei dieser Betrachtung außen vor gelassen werden konnen.¨ Ein formaler Verfeinerungsschritt ubertr¨ agt¨ dann die Verifikationsergebnisse auf die Implementierung, ohne die Beweise auf der detaillierten Ebene erneut fuhren¨ zu mussen.¨ Der kombinierte Ansatz erlaubt eine besonders flexible Formulierung von Verifi- kationsaufgaben. Er ist flexibel in der Formulierung der der Programme, weil die Verifikationsprogrammiersprache besonders grundlegend und allgemein gehalten ist. Er ist flexibel in der
Recommended publications
  • Calculi for Program Incorrectness and Arithmetic Philipp Rümmer
    Thesis for the Degree of Doctor of Philosophy Calculi for Program Incorrectness and Arithmetic Philipp R¨ummer Department of Computer Science and Engineering Chalmers University of Technology and G¨oteborg University SE-412 96 G¨oteborg Sweden G¨oteborg, 2008 Calculi for Program Incorrectness and Arithmetic Philipp R¨ummer ISBN 978-91-628-7242-7 c Philipp R¨ummer, 2008 Technical Report no. 50D Department of Computer Science and Engineering Research Group: Formal Methods Department of Computer Science and Engineering Chalmers University of Technology and G¨oteborg University SE-412 96 G¨oteborg, Sweden Telephone +46 (0)31–772 1000 Printed at Chalmers, G¨oteborg, 2008 II Abstract This thesis is about the development and usage of deductive methods in two main areas: (i) the deductive dis-verification of programs, i.e., how techniques for deductive verification of programs can be used to detect program defects, and (ii) reasoning modulo integer arithmetic, i.e., how to prove the validity (and, in special cases, satisfiability) of first-order formulae that involve integer arithmetic. The areas of program verification and of testing are traditionally considered as complementary: the former searches for a formal proof of program correctness, while the latter searches for witnesses of program incorrectness. Nevertheless, de- ductive verification methods can discover bugs indirectly: the failure to prove the absence of bugs is interpreted as a sign for the incorrectness of the program. This approach is bound to produce “false positives” and bugs can be reported also for correct programs. To overcome this problem, I investigate how techniques that are normally used for verification can be used to directly prove the incorrectness of programs.
    [Show full text]
  • Module COMP11212 Fundamentals of Computation
    Module COMP11212 Fundamentals of Computation Correctness, Complexity, and Computability (First Half of Notes) Giles Reger Semester 2, 2017 Organisation and Learning Outcomes Structure, Assessment, Coursework All of this information is the same as for Part 1 and you should refer to those notes for the details. Assumptions This course requires a certain level of mathematical skill; indeed one of the goals is to show that there is a use for much of the discrete mathematics that you are taught elsewhere. Chapter 0 attempts to gather the assumed material together but you should also cross-reference material on discrete mathematics or use the web to look up unfamiliar concepts. These Notes This part of the course is divided up into four main chapters. Before they start there is an introduction to the Part which gives a high-level overview of the contents - I strongly suggest reading this. Important Read the introduction. I use these boxes to highlight things that are important that you may miss when scanning through the notes quickly. Typically the box will repeat something that has already been said. In this case, read the introduction! i ii Chapter 0 recaps some mathematical material from COMP11120. Then the main four chapters cover the four main concepts of models of compu- tation, correctness, complexity and computability. There are examples and exercises throughout the notes. The assessed exercises for the examples classes are outlined in question sheets at the end of the notes. Some exam- ples are marked with a (*) indicating that they go significantly beyond the examined material. Confused? Great! Learning theory tells us that we do the best learning when we are confused by something and resolve that confusion.
    [Show full text]
  • Extending Dynamic Invariant Detection with Explicit Abstraction
    EXTENDING DYNAMIC INVARIANT DETECTION WITH EXPLICIT ABSTRACTION by DANIEL BRIAN KEITH A DISSERTATION Presented to the Department of Computer and Information Science and the Graduate School of the University of Oregon in partial fulfillment of the requirements for the degree of Doctor of Philosophy March 2012 DISSERTATION APPROVAL PAGE Student: Daniel Brian Keith Title: Extending Dynamic Invariant Detection with Explicit Abstraction This dissertation has been accepted and approved in partial fulfillment of the requirements for the Doctor of Philosophy degree in the Department of Computer and Information Science by: Michal Young Chair Zena Ariola Member Christopher Wilson Member Edward Vogel Outside Member and Kimberly Andrews Espy Vice President for Research & Innovation/ Dean of the Graduate School Original approval signatures are on file with the University of Oregon Graduate School. Degree awarded March 2012 ii c 2012 Daniel Brian Keith iii DISSERTATION ABSTRACT Daniel Brian Keith Doctor of Philosophy Department of Computer and Information Science March 2012 Title: Extending Dynamic Invariant Detection with Explicit Abstraction Dynamic invariant detection is a software analysis technique that uses traces of function entry and exit from executing programs and infers partial specifications that characterize the observed behavior. The specifications are reported as logical precondition and postcondition expressions (invariants) that relate arguments, instance variables, and results. Detectors typically generate large collections of invariants, among which most are true but few are interesting or useful. Refining this flood of invariants into a useful subset often requires manual tuning through configuration options and modification of the program under analysis. Our research asks whether we can improve dynamic invariant detection by enabling explicit abstractions to be declared and applied to a program under analysis and whether this is practical; this dissertation shows that it is indeed practical and useful.
    [Show full text]
  • An Introduction to Rely/Guarantee Reasoning About Concurrency
    Rely/guarantee An introduction to rely/guarantee reasoning about concurrency Pre I assume that this lecture starts at 8:30am Ian J. Hayes (and Cliff B. Jones) Guarantee you will understand to rely/guarantee reasoning Rely that you ask questions when you don’t understand The University of Queensland, Australia (and Newcastle University, UK) Post finish this lecture at 9:30am SETSS Spring School Chongqing, China 2017-04-17–19 1 / 1 2 / 1 Overview Your background Logic and set theory I Propositional logic: , and ^ _ : I Predicate logic: and I Deriving sequential programs 8 9 I Set theory: , , , and ::: I Example: Sieve of Eratosthenes 2 ⊆ [ \ f g I Deriving concurrent programs I Specification languages: VDM, Z, B and TLA I Example: Sieve of Eratosthenes Reasoning about programs I Example: Communicating through a circular buffer I Hoare logic: p c q I Semantics of concurrent programs f g f g î ó I Refinement calculus or B or Event-B: , x : p ; q v I Rely/guarantee concurrency I Separation logic I Concurrent separation logic 3 / 1 4 / 1 Reasoning about (concurrent) software Compositional reasoning Our main tool is abstraction: Reasoning about the whole is decomposed into reasoning about the components sequential specify components using pre/post conditions Why? I Make reasoning tractable I e.g. sorting I Partition the work (e.g. for multiple people to work on different I precondition noduplicates(s) components) 0 0 I postcondition ordered(s ) items(s ) = items(s) I Avoid reasoning about paths ^ data use abstractions such as sets and maps j :=
    [Show full text]
  • A Systematic Derivation of Loop Specifications Using Patterns Aditi Barua University of Texas at El Paso, [email protected]
    University of Texas at El Paso DigitalCommons@UTEP Departmental Technical Reports (CS) Department of Computer Science 12-2015 A Systematic Derivation of Loop Specifications Using Patterns Aditi Barua University of Texas at El Paso, [email protected] Yoonsik Cheon University of Texas at El Paso, [email protected] Follow this and additional works at: http://digitalcommons.utep.edu/cs_techrep Part of the Programming Languages and Compilers Commons, and the Software Engineering Commons Comments: Technical Report: UTEP-CS-15-90 Recommended Citation Barua, Aditi and Cheon, Yoonsik, "A Systematic Derivation of Loop Specifications Using Patterns" (2015). Departmental Technical Reports (CS). Paper 988. http://digitalcommons.utep.edu/cs_techrep/988 This Article is brought to you for free and open access by the Department of Computer Science at DigitalCommons@UTEP. It has been accepted for inclusion in Departmental Technical Reports (CS) by an authorized administrator of DigitalCommons@UTEP. For more information, please contact [email protected]. A Systematic Derivation of Loop Specifications Using Patterns Aditi Barua and Yoonsik Cheon TR #15-90 December 2015 Keywords: formal proof, functional program verification, intended function, program specification, specification pattern, while statement 1998 CR Categories: D.2.4 [Software Engineering] Requirements/Specifications — languages; D.2.4 [Software Engineering] Software/Program Verification — correctness proofs, formal methods; D.3.3 [Programming Languages] Language Constructs and Features — control structures; F.3.1 [Logics and Meanings of Programs] Specifying and Verifying and Reasoning about Programs — logics of programs, specification techniques. Department of Computer Science The University of Texas at El Paso 500 West University Avenue El Paso, Texas 79968-0518, U.S.A.
    [Show full text]
  • Theory of Programs Bertrand Meyer
    Draft 3, 6 December 2015 Theory of Programs Bertrand Meyer While the theoretical study of programs fills volumes, a handful of concepts from elementary set theory suffice to establish a clear and practical basis. Among the results: • To describe a specification or a program, it suffices to define one relation and one set. • To describe the concepts of programming, concurrent as well as sequential, three elementary operations on sets and relations suffice: union, composition and restriction. • These techniques suffice to derive the axioms of classic papers on the “laws of programming” as straightforward consequences. • To define both program correctness and refinement, the ordinary subset operator “⊆” suffices. Paragraphs labeled “Intuition” relate the concepts to the experience of readers having done some programming. Readers familiar with other views of theoretical informatics will find comparisons in “Comment” paragraphs. Section 5 provides more discussion. 1 Programs A program is a mathematical object: a constrained relation over a set of states. Definition: program, specification, precondition, postcondition. A program, also known as a specification, over a state set S, consists of: • A relation post: S ↔ S, the program’s postcondition. •A set Pre ⊆ S, the program’s precondition. Notation: A ↔ B is the set of binary relations between A and B, that is, P (A × B). The domain of a relation r is written r and its range r . Intuition: a program starts from a certain state and produces one of a set of possible states satis- fying properties represented by post. Pre tells us which states are acceptable as initial states. In the general case, more than one resulting state can meet the expectation expressed by post.
    [Show full text]
  • ACSL: ANSI/ISO C Specification Language
    ACSL: ANSI/ISO C Specification Language ACSL: ANSI/ISO C Specification Language Version 1.4 Patrick Baudin1, Pascal Cuoq1, Jean-Christophe Filliâtre4;3, Claude Marché3;4, Benjamin Monate1, Yannick Moy2;4;3, Virgile Prevosto1 1 CEA LIST, Software Reliability Laboratory, Saclay, F-91191 2 France Télécom, Lannion, F-22307 3 INRIA Saclay - Île-de-France, ProVal, Orsay, F-91893 4 LRI, Univ Paris-Sud, CNRS, Orsay, F-91405 c 2009-2010 CEA LIST and INRIA This work has been supported by the ‘CAT’ ANR project (ANR-05-RNTL-0030x) and by the ANR CIFRE contract 2005/973. CONTENTS Contents 1 Introduction 11 1.1 Organization of this document........................... 11 1.2 Generalities about Annotations.......................... 11 1.2.1 Kinds of annotations............................ 12 1.2.2 Parsing annotations in practice...................... 12 1.2.3 About preprocessing............................ 12 1.2.4 About keywords.............................. 13 1.3 Notations for grammars.............................. 13 2 Specification language 15 2.1 Lexical rules..................................... 15 2.2 Logic expressions.................................. 16 2.2.1 Operators precedence........................... 18 2.2.2 Semantics.................................. 19 2.2.3 Typing.................................... 19 2.2.4 Integer arithmetic and machine integers................. 20 2.2.5 Real numbers and floating point numbers................ 22 2.2.6 Structures, Unions and Arrays in logic.................. 25 2.2.7 String literals................................ 27 2.2.8 Address operator.............................. 27 2.2.9 Function pointers.............................. 27 2.3 Function contracts................................. 27 2.3.1 Built-in constructs \old and \result .................... 28 2.3.2 Simple function contracts......................... 28 2.3.3 Contracts with named behaviors..................... 30 2.3.4 Memory locations.............................
    [Show full text]
  • Verification of Goroutines Using Why3 Radboud University Nijmegen
    Master’s Thesis Verification of Goroutines using Why3 Marc Schoolderman July 2016 supervisor: dr. F. Wiedijk second reader: dr. F. Verbeek Radboud University Nijmegen Institute for Computing and Information Sciences Abstract Concurrent software has become increasingly important in today’s world; but reasoning formally about such programs is hard. The programming language Go offers a paradigm for writing programs that do not rely on memory sharing as a primary means of communication between processes. While this should make it easier to reason about concurrency, methods for formal verification of programs written in Go are absent. In this thesis, we will investigate the capabilities of the Why3 verification platform to fill this gap. We first apply it to verify the complexity of heapsort, check an early program proof by Alan Turing, and solve other logical problems. We then use it as the foundation of a verification method for concurrent Go programs. With this method, we can verify partial correctness and liveness properties for concurrent programs written in a small subset of Go, using a high degree of automation. This technique is designed to be implementable as a tool, which could — if extended further — allow the partial verification of a larger range of Go programs. Contents 1. Introduction 6 1.1. Computer-aided reasoning....................................6 1.2. Software analysis toolchains...................................7 1.3. Concurrent programming.....................................8 1.4. Research question.........................................9 1.4.1. Reproducibility of results................................9 1.5. A verification primer........................................ 10 2. The Why3 verification platform 12 2.1. Overview of Why3 ......................................... 12 2.2. The Why language......................................... 15 2.2.1.
    [Show full text]