Anders Møller

Like dokumenter
Call function of two parameters

Dynamic Programming Longest Common Subsequence. Class 27

Slope-Intercept Formula

Oppgave 1a Definer følgende begreper: Nøkkel, supernøkkel og funksjonell avhengighet.

Moving Objects. We need to move our objects in 3D space.

Graphs similar to strongly regular graphs

Unit Relational Algebra 1 1. Relational Algebra 1. Unit 3.3

UNIVERSITETET I OSLO

UNIVERSITETET I OSLO

Databases 1. Extended Relational Algebra

UNIVERSITETET I OSLO

Level Set methods. Sandra Allaart-Bruin. Level Set methods p.1/24

IN 211 Programmeringsspråk. Dokumentasjon. Hvorfor skrive dokumentasjon? For hvem? «Lesbar programmering» Ark 1 av 11

AvtaleGiro beskrivelse av feilmeldinger for oppdrag og transaksjoner kvitteringsliste L00202 levert i CSV fil

Du må håndtere disse hendelsene ved å implementere funksjonene init(), changeh(), changev() og escape(), som beskrevet nedenfor.

Trigonometric Substitution

UNIVERSITETET I OSLO

SVM and Complementary Slackness

UNIVERSITY OF OSLO DEPARTMENT OF ECONOMICS

5 E Lesson: Solving Monohybrid Punnett Squares with Coding

Andrew Gendreau, Olga Rosenbaum, Anthony Taylor, Kenneth Wong, Karl Dusen

IN2010: Algoritmer og Datastrukturer Series 2

Verifiable Secret-Sharing Schemes

Gir vi de resterende 2 oppgavene til én prosess vil alle sitte å vente på de to potensielt tidskrevende prosessene.

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

Level-Rebuilt B-Trees

Den europeiske byggenæringen blir digital. hva skjer i Europa? Steen Sunesen Oslo,

stjerneponcho for voksne star poncho for grown ups

Neural Network. Sensors Sorter

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

DecisionMaker Frequent error codes (valid from version 7.x and up)

EXFAC03-FIL Exfac, filosofivariant HØST 2007 Torsdag 13. desember kl ( 4 timer)

buildingsmart Norge seminar Gardermoen 2. september 2010 IFD sett i sammenheng med BIM og varedata

Second Order ODE's (2P) Young Won Lim 7/1/14

AvtaleGiro beskrivelse av feilmeldinger for oppdrag og transaksjoner for KID bytte kvitteringsliste L02625 levert i CSV format

INF Logikk og analysemetoder Forslag til løsning på oppgave fra læreboken

Endringer i neste revisjon av EHF / Changes in the next revision of EHF 1. October 2015

VLSI Design for Yield on Chip Level

1. Explain the language model, what are the weaknesses and strengths of this model?

Kneser hypergraphs. May 21th, CERMICS, Optimisation et Systèmes

FIRST LEGO League. Härnösand 2012

Skjema for spørsmål og svar angående: Skuddbeskyttende skjold Saksnr TED: 2014/S

Uke 5. Magnus Li INF /

Public roadmap for information management, governance and exchange SINTEF

Dagens tema: Eksempel Klisjéer (mønstre) Tommelfingerregler

Ole Isak Eira Masters student Arctic agriculture and environmental management. University of Tromsø Sami University College

KROPPEN LEDER STRØM. Sett en finger på hvert av kontaktpunktene på modellen. Da får du et lydsignal.

Merak Un-glazed Porcelain Wall and Floor Tiles

Little Mountain Housing

INF5820 Natural Language Processing - NLP. H2009 Jan Tore Lønning

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

Maple Basics. K. Cooper

Bokmål / Nynorsk / English NORGES TEKNISK- NATURVITENSKAPELIGE UNIVERSITET INSTITUTT FOR FYSIKK. Eksamen TFY4185 Måleteknikk

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

Evaluating Call-by-need on the Control Stack

Hvor mye teoretisk kunnskap har du tilegnet deg på dette emnet? (1 = ingen, 5 = mye)

Universitetet i Bergen Det matematisk-naturvitenskapelige fakultet Eksamen i emnet Mat131 - Differensiallikningar I Onsdag 25. mai 2016, kl.

Information search for the research protocol in IIC/IID

Emneevaluering GEOV272 V17

UNIVERSITETET I OSLO

Hvor mye praktisk kunnskap har du tilegnet deg på dette emnet? (1 = ingen, 5 = mye)

Endelig ikke-røyker for Kvinner! (Norwegian Edition)

Mathematics 114Q Integration Practice Problems SOLUTIONS. = 1 8 (x2 +5x) 8 + C. [u = x 2 +5x] = 1 11 (3 x)11 + C. [u =3 x] = 2 (7x + 9)3/2

HONSEL process monitoring

Den som gjør godt, er av Gud (Multilingual Edition)

Exercise 1: Phase Splitter DC Operation

Medisinsk statistikk, KLH3004 Dmf, NTNU Styrke- og utvalgsberegning

Estimating Peer Similarity using. Yuval Shavitt, Ela Weinsberg, Udi Weinsberg Tel-Aviv University

STILLAS - STANDARD FORSLAG FRA SEF TIL NY STILLAS - STANDARD

EN Skriving for kommunikasjon og tenkning

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

Explicit vs. Implicit Polymorphism in OML. Thomas Christensen MSc. (CS) (Soon) University of Aarhus, Denmark

Object [] element. array. int [] tall

Dialogkveld 03. mars Mobbing i barnehagen

Hvordan 3 konsulenter tester et konserndatavarehus

Innholdsfortegnelse... 1 Endringslogg UD BETALINGSTERMINAL NETS NEW DRIVERS FULL SUPPORT WINDOWS

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

API: Application programming interface, eller programmeringsgrensesnitt

Brukerkrav og use case diagrammer og -tekst 19. januar Agenda. Brukerkrav og use case. Diagrammer Tekst.

6350 Månedstabell / Month table Klasse / Class 1 Tax deduction table (tax to be withheld) 2012

Physical origin of the Gouy phase shift by Simin Feng, Herbert G. Winful Opt. Lett. 26, (2001)

Speed Racer Theme. Theme Music: Cartoon: Charles Schultz / Jef Mallett Peanuts / Frazz. September 9, 2011 Physics 131 Prof. E. F.

SAS FANS NYTT & NYTTIG FRA VERKTØYKASSA TIL SAS 4. MARS 2014, MIKKEL SØRHEIM

Administrasjon av postnummersystemet i Norge Post code administration in Norway. Frode Wold, Norway Post Nordic Address Forum, Iceland 5-6.

1 BANESTRØMFORSYNING TOGVARMEANLEGG KONTAKTLEDNINGSANLEGG... 5

klassisk angoragenser classic angora sweater

INF2820 Datalingvistikk V2011. Jan Tore Lønning & Stephan Oepen

Løsningsforslag for oppgavene i operativsystemer og C, uke 38 ( )

Improving Customer Relationships

1 User guide for the uioletter package

Smart High-Side Power Switch BTS730

NO X -chemistry modeling for coal/biomass CFD

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

3/1/2011. I dag. Recursive descent parser. Problem for RD-parser: Top Down Space. Jan Tore Lønning & Stephan Oepen

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

Fra sekvensielt til parallelt

EMPIC MEDICAL. Etterutdanningskurs flyleger 21. april Lars (Lasse) Holm Prosjektleder Telefon: E-post:

melting ECMI Modelling week 2008 Modelling and simulation of ice/snow melting Sabrina Wandl - University of Linz Tuomo Mäki-Marttunen - Tampere UT

Løsningsforslag 2017 eksamen

Transkript:

Smallfoot program verification with separation logic by O Hearn et al. Anders Møller <amoeller@cs.au.dk>

Plan Hoare logic + pointers and functions Separation logic Smallfoot 2 / 20

Hoare logic and pointers Consider the standard axiom for assignment: {Q[E/X]} X=E; {Q} Example: {y+7>42} x=y+7; {x>42} This doesn t work with pointers! Example: {y.a=42} x.a=c; {y.a=42} aliasing? 3 / 20

Morris general axiom of assignment Idea: encode all possible aliasing scenarios Assume for simplicity that Y is the only heap reference in Q {(X=Y Q[E / Y.F]) (X Y Q)} X.F=E; {Q} Example: {(x=y c=42) (x y y.a=42)} x.a=c; {y.a=42} This works, but it gives a blow-up in formula size it results in global reasoning We want simpler proofs! 4 / 20

Hoare logic and function calls Let P pre and P post be the pre/post-conditions of a function f??? {Q} {R} x=f(y) Proof obligations (ignore parameter and return value passing): Q P pre P post R??? this is too weak! ( the frame problem ) we want modular reasoning! 5 / 20

Example: Reversing a linked list struct Node { struct Node *n; int data; } Node *reverse(node *x) { Node *y, *t; y = NULL; while (x!= NULL) { t = y; y = x; x = x->n; y->n = t; } return y; } Assume that the input is an acyclic list, argue that there are no null pointer dereferences no elements are lost the output is an acyclic list the output is the reverse of the input no other parts of the heap are modified 6 / 20

Reversing a linked list Consider a possible loop invariant: α,β: LIST α (x) LIST β (y) α 0R = R α β Unfortunately, it is not enough: we must explicitly forbid sharing between the x and y lists we must explicitly state that every other part of the heap is unaffected! 7 / 20

Plan Hoare logic + pointers and functions Separation logic Smallfoot 8 / 20

Separation logic New assertions: emp (empty heap) E F 1 :E 1,..,F n :E n (one-record heap) P * Q (separating conjunction) assertions describe heaplets, not global heaps! 9 / 20

Examples (x a:42, b:nil) * (y a:42, b:nil) x,y are not aliases (x a:42, b:nil) (y a:42, b:nil) x,y are aliases ((x a:42, b:nil) * true) ((y a:42, b:nil) * true) x,y may be aliases (x a:7, b:y) * (y a:87, b:x) 2-node cyclic list 10 / 20

Axioms Axiom for assignment to the heap ( mutation ): mutation): { } { } {X ρ, F:_,σ} X.F = E; ; {X ρ,f:e,σ} Axiom for assignment from the heap ( lookup ): { ρ,, } { ρ,, } {Y ρ,f:v,σ} X = Y.F; ; {X=V Y ρ,f:v,σ} - variants for backwards reasoning also exist - allocation/disposal, pointer arithmetic, etc., also work 11 / 20

The frame rule, local reasoning {P} S S {Q} {P{ * R} {Q{ * R} All heap cells that are not mentioned in the specification are guaranteed to remain unchanged! Many other new inference rules... Loop invariant for the list reversal example: α,β: (LIST α (x) * LIST β (y)) α 0R = R α β 12 / 20

Other issues Logical variables/predicates are often used in proofs Classical Hoare logic is relatively complete this extension does not preserve that property... New assertion languages? (beyond predicate logic, e.g. to express isomorphisms) Concurrent languages?, code pointers?,... 13 / 20

Plan Hoare logic + pointers and functions Separation logic Smallfoot 14 / 20

Smallfoot A step towards automated program verification with separation logic Requires pre/post-conditions and loop invariants Also supports concurrent extension of separation logic The general verification problem is undecidable predicate logic... data structures specified by inductive definitions... applying the frame rule is not trivial... 15 / 20

The approach Hardwired reasoning about a small collection of list and tree structures Limits the assertion language: only allowing conjunctions of pure boolean conditions *-combination of heap predicates (e.g. no quantifiers, no general inductive reasoning) Generates verification condition for each Hoare triple using a technique of symbolic execution Verifies VCs (easy, because of the limited assertion language) reminiscent of PALE... 16 / 20

Demo reverse.sf list_reverse(o,i) [list(i)] { local t; o = NULL; while (i!= NULL) [list(i) * list(o)] { t = i->tl; i->tl = o; o = i; i = t; } } [list(o)] Properties being verified: there are no null pointer dereferences no elements are lost the output is an acyclic list the output t is the reverse of the input no other parts of the heap are modified similar to PALE cannot be expressed in the annotation language of Smallfoot using the frame rule! 17 / 20

Demo VERIFICATION CONDITION: [listseg(tl; i, 0)] o=0; fcall({i, o, t},listseg(tl; i, 0) * listseg(tl; o, 0), 0==i * listseg(tl; i, 0) * listseg(tl; o, 0)); [listseg(tl; o, 0)] VERIFICATION CONDITION: [0!=i * listseg(tl; i, 0) * listseg(tl; o, 0)] t=i->tl; i->tl=o; o=i; i=t; [listseg(tl; i, 0) * listseg(tl; o, 0)] Valid 18 / 20

Demo If we accidentally swap two lines in the loop: File "reverse-bug.sf", line 4, characters 2-97: ERROR invalid entailment: loop exit 0!=o * o_2!=o * o!=t * o -> tl:o * listseg(tl; t, 0) * listseg(tl; o_2, 0) - listseg(tl; t, 0) * listseg(tl; o, 0) NOT Valid 19 / 20

Conclusion Separation logic extends Hoare logic with pointers key idea: separating conjunction (P*Q) Permits local reasoning (the frame rule) Smallfoot: the first tool based on separation logic automated verification for simple data structures and simple properties (limited assertion language) 20 / 20