Lightweight Support for Magic Wands in an Automatic Verifier Malte Schwerhoff and Alexander J. Summers 10 th July 2015, ECOOP, Prague.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

Shape Analysis with Structural Invariant Checkers Bor-Yuh Evan Chang Xavier Rival George C. Necula May 10, 2007 OSQ Retreat.
Automated Verification with HIP and SLEEK Asankhaya Sharma.
Semantics Static semantics Dynamic semantics attribute grammars
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Verifying Executable Object-Oriented Specifications with Separation Logic Stephan van Staden, Cristiano Calcagno, Bertrand Meyer.
Constraint Semantics for Abstract Read Permissions 28 th July 2014, FTfJP, Uppsala John Tang Boyland (UW-Milwaukee/ETH Zurich) Peter Müller, Malte Schwerhoff,
Automated Software Verification with a Permission-Based Logic 20 th June 2014, Zürich Malte Schwerhoff, ETH Zürich.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
A survey of techniques for precise program slicing Komondoor V. Raghavan Indian Institute of Science, Bangalore.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
CS 355 – Programming Languages
Changing perspective can be useful Relating alternative logics for automatic software verification Alex Summers (ETH Zurich) partly based on joint work.
Logic in general Logics are formal languages for representing information such that conclusions can be drawn Syntax defines the sentences in the language.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Review: forward E { P } { P && E } TF { P && ! E } { P 1 } { P 2 } { P 1 || P 2 } x = E { P } { \exists … }
Review: forward E { P } { P && E } TF { P && ! E } { P 1 } { P 2 } { P 1 || P 2 } x = E { P } { \exists … }
Describing Syntax and Semantics
Reasoning about Multiple Related Abstractions with MultiStar Stephan van Staden, Cristiano Calcagno Chair of Software Engineering.
Proving termination conditions Name Country, City, University Omer Subasi Turkey, Istanbul, Koc University Anton Dergunov
K. Rustan M. Leino RiSE, Microsoft Research, Redmond joint work with Peter Müller and Jan Smans Lecture 0 1 September 2009 FOSAD 2009, Bertinoro, Italy.
Data Structures and Programming.  John Edgar2.
Crowfoot: a verifier for higher order store programs Billiejoe (Nathaniel) Charlton Ben Horsfall Bernhard Reus University of Sussex VMCAI 2012.
Pre/Post Condition Logic 03/06/2013. Agenda Hoare’s Logic Overview Application to Pre/Post Conditions.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
Aquinas Hobor and Cristian Gherghina (National University of Singapore) TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.
Chapter 3 (Part 3): Mathematical Reasoning, Induction & Recursion  Recursive Algorithms (3.5)  Program Correctness (3.6)
Automated Software Verification with Implicit Dynamic Frames 5 th December 2013, Leuven Malte Schwerhoff, ETH Zürich/KU Leuven.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
Viper A Verification Infrastructure for Permission-Based Reasoning 1 st March 2015, ECOOP’15 PC Meeting, Zurich Uri Juhasz, Ioannis Kassios, Peter Müller,
Checking Reachability using Matching Logic Grigore Rosu and Andrei Stefanescu University of Illinois, USA.
© Andrew IrelandDependable Systems Group Cooperative Reasoning for Automatic Software Verification Andrew Ireland School of Mathematical & Computer Sciences.
Viper A Verification Infrastructure for Permission-Based Reasoning 24 th March 2015, JML Workshop, Leiden Uri Juhasz, Ioannis Kassios, Peter Müller, Milos.
Muhammad Idrees Lecturer University of Lahore 1. Outline Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute.
A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.
Formal verification of skiplist algorithms Student: Trinh Cong Quy Supervisor: Bengt Jonsson Reviewer: Parosh Abdulla.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
ISBN Chapter 3 Describing Semantics.
Chapter 3 Part II Describing Syntax and Semantics.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Semantics In Text: Chapter 3.
Syntax and Semantics CIS 331 Syntax: the form or structure of the expressions, statements, and program units. Semantics: the meaning of the expressions,
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen.
Lecture 5 1 CSP tools for verification of Sec Prot Overview of the lecture The Casper interface Refinement checking and FDR Model checking Theorem proving.
1 Reasoning with Infinite stable models Piero A. Bonatti presented by Axel Polleres (IJCAI 2001,
An Introduction to Automated Program Verification with Permission Logics 15 th May 2015, Systems Group, ETH Zurich Uri Juhasz, Ioannis Kassios, Peter Müller,
CSE Winter 2008 Introduction to Program Verification for-loops; review.
1 Proving program termination Lecture 5 · February 4 th, 2008 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A.
Adaptive Shape Analysis Thomas Wies joint work with Josh Berdine Cristiano Calcagno TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
/ PSWLAB Thread Modular Model Checking by Cormac Flanagan and Shaz Qadeer (published in Spin’03) Hong,Shin Thread Modular Model.
Spring 2017 Program Analysis and Verification
A Verification Infrastructure for Permission-based Reasoning
The Relationship Between Separation Logic and Implicit Dynamic Frames
Matching Logic An Alternative to Hoare/Floyd Logic
The Relationship Between Separation Logic and Implicit Dynamic Frames
Formal Methods in Software Engineering 1
Modular Verification of Message Passing Programs
Important Concepts from Clojure
Important Concepts from Clojure
A Verification Infrastructure for Permission-Based Reasoning
Reduction in End-User Shape Analysis
Predicate Transformers
Logic: tool-based modeling and reasoning
Important Concepts from Clojure
Representations & Reasoning Systems (RRS) (2.2)
Presentation transcript:

Lightweight Support for Magic Wands in an Automatic Verifier Malte Schwerhoff and Alexander J. Summers 10 th July 2015, ECOOP, Prague

Frame Problem Modular, static verification of imperative programs Frame problem: Which memory locations change? Automated verification: Pre-/Postconditions, invariants, ghost code Well-known approach: Permissions ( ≈ Separation Logic) 2

3 callercallee Permission Transfer

4 ? callercallee

5 ? callercallee Permission Transfer

Permissions ( ≈ Separation Logic) 6 (≈) acc(x.f) ∗ x.f == 0 x.f ⟼ 0 Logical properties 0 (≈) acc(x.f) ∗ acc(y.f)x.f ⟼ _ ∗ y.f ⟼ _ Disjointness: x ≠ y Syntax & Properties

7 A ∗ B describes the current state in terms of disjoint substates Separating Conjunction

8 A ∗ B describes the current state in terms of disjoint substates Is at the heart of verifiers based on separation logic Separating Conjunction

9 A —∗ B describes hypothetical states Read as a promise: “In any state, if you provide A, then you will get B ” Magic Wands

10 Scenario: Iteratively traverse a recursively defined tree (Verification Challenge at Partial Data Structures

11 Scenario: Iteratively traverse a recursively defined tree Loop invariant: Describe partial data structure Partial Data Structures

12 Indirectly describe partial data structure as a promise ---—∗ Partial Data Structures as Magic Wands

13 Modus-Ponens-like rule makes promise applicable ---—∗∗ Partial Data Structures as Magic Wands

14 ---—∗∗ σ ⊨ A —∗ B ⇔ ∀ σ ’ · ( σ ’ ⊨ A ⇒ σ ⊎ σ ’ ⊨ B) Partial Data Structures as Magic Wands

15 Used in various pen & paper proofs −Partial data structures −Usage protocols for data structures −Synchronisation barriers −…−… Typically* not supported in automatic verifiers * Only exception we are aware of is VerCors; developed in parallel σ ⊨ A —∗ B ⇔ ∀ σ ’ · ( σ ’ ⊨ A ⇒ σ ⊎ σ ’ ⊨ B) Magic Wands in Proofs and Tools

16 Entailment of magic wand formulas is undecidable Lightweight user guidance to direct verification Automating Magic Wand Reasoning

17 package A —∗ B apply A —∗ B Use it Pass it around Make a promise ---—∗∗ Opaque resource; Specifications Guidance: Ghost Operations + Specifications

18 package A —∗ B apply A —∗ B Use it Pass it around Make a promise ---—∗∗ Opaque resource; Specifications Guidance: Ghost Operations + Specifications Challenge: Ensure soundness of apply in any (future) state

19 Permissions guaranteeing that giving up A ∗ ( A —∗ B ) and obtaining B is sound ---—∗ carved out effectively immutable Footprints of A —∗ B

20 Footprints are not unique ---—∗ or or all available permissions Footprints of A —∗ B

21 Footprints are not unique ---—∗ or or all available permissions How to choose a footprint? Footprints of A —∗ B

package A —∗ ( B 1 ∗ B 2 ∗ … ∗ B n ) given current state v1v1 v2v2 v3v3 v5v5 v4v4 Footprint Computation Algorithm: Setup

package A —∗ ( B 1 ∗ B 2 ∗ … ∗ B n ) create LHS state current state ⊨ A v1v1 v2v2 v3v3 v5v5 w2w2 w3w3 w1w1 v4v4 w3w3 Footprint Computation Algorithm: Setup

package A —∗ ( B 1 ∗ B 2 ∗ … ∗ B n ) 24 LHS state current state ⊨ A v1v1 v2v2 v3v3 v5v5 w2w2 w3w3 w1w1 v4v4 w3w3 Footprint Computation Algorithm: Setup 2. create empty RHS state

package A —∗ ( B 1 ∗ B 2 ∗ … ∗ B n ) 25 LHS state current state RHS state v1v1 v2v2 v3v3 v5v5 w2w2 w3w3 w1w1 v4v4 w3w3 3. iterate over B i ’s:If B i is acc( x.f ) then transfer permissions and assumptions Footprint Computation Algorithm: Execution

package A —∗ ( B 1 ∗ B 2 ∗ … ∗ B n ) 26 LHS state current state RHS state v1v1 v2v2 v3v3 v5v5 w2w2 w3w3 3. iterate over B i ’s:If B i is acc(x.f) then transfer permissions and assumptions w1w1 v4v4 w3w3 w1w1 X w3w3 X v2v2 X Footprint Computation Algorithm: Execution

package A —∗ ( B 1 ∗ B 2 ∗ … ∗ B n ) 27 LHS state current state RHS state v1v1 v2v2 v3v3 v5v5 w2w2 w3w3 w1w1 v4v4 w3w3 w1w1 X w3w3 X v2v2 X 3. iterate over B i ’s:If B i is a logical property P, e.g. x.f == 0, then check P ⊨ P ? Footprint Computation Algorithm: Execution

package acc(x.f) —∗ acc(x.f) 28 LHS state current state RHS state Examples

package true —∗ acc(x.f) 29 LHS state current state RHS state Examples

package true —∗ acc(x.f) ∗ x.f == 0 30 LHS state current state RHS state ⊨ x.f == 0 0 Examples

package acc(x.f) —∗ acc(x.f) ∗ x.f == 0 31 LHS state current state RHS state ⊭ x.f == 0 0 ? Examples

Abstract predicates for recursive data structures 32 x == null ∗ x l xx r Existing Features

Abstract predicates plus ghost operations 33 ∗ x l x r fold tree(x) unfold tree(x) Existing Ghost Operations

package —∗ xxxxx 34 Integrating Existing Ghost Operations

package —∗ (fold tree(x) in ) 35 Integrating Existing Ghost Operations

36 LHS state current state RHS state package —∗ (fold tree(x) in ) Integrating Existing Ghost Operations

37 LHS state current state RHS state package —∗ (fold tree(x) in ) Integrating Existing Ghost Operations

Part of Viper verification infrastructure −Implementation based on symbolic execution −Rich logic: unrestricted abstract predicates, abstraction functions, quantifiers, sets, sequences, custom mathematical domains, flexible permission model, … Set of interesting examples; 1.6 to 3 seconds Verification challenge from VerifyThis’12 −Verifies in 3s −VerCors: −6 minutes (originally, using Chalice/Boogie) −60 seconds (currently, using Viper) 38 Implementation

Simple heuristics to infer package and apply statements Infers all package and apply statements in our examples Verification time: +0.5s or less 39 Annotation Inference Heuristics

40 Scenario: Iteratively traverse a recursively defined tree Loop invariant: Describe partial data structure A A ---—∗ B B VerifyThis’12 Challenge Revisited

41 VerifyThis’12 Challenge Encoded

42 Named shorthand, could be inlined Inferred by heuristics Required in either case VerifyThis’12 Challenge Encoded

Algorithm for computing wand footprints −Sound (proof sketch) −Permissive and predictable Formalised verifier-independently Implementation −Co-first* to support magic wands in an automatic verifier −Lightweight user annotations −Convincing initial results (expressiveness, performance) 43 * VerCors