1 Total Pasta: Unfailing Pointer Programs Neil Mitchell, ndm AT cs.york.ac.uk Department of Computer Science, University of York.

Slides:



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

CHECKING MEMORY SAFETY AND TEST GENERATION USING B LAST By: Pashootan Vaezipoor Computing Science Dept of Simon Fraser University.
Synthesis, Analysis, and Verification Lecture 04c Lectures: Viktor Kuncak VC Generation for Programs with Data Structures “Beyond Integers”
Semantics Static semantics Dynamic semantics attribute grammars
Satisfiability Modulo Theories (An introduction)
A Program Transformation For Faster Goal-Directed Search Akash Lal, Shaz Qadeer Microsoft Research.
Verification of Functional Programs in Scala Philippe Suter (joint work w/ Ali Sinan Köksal and Viktor Kuncak) ÉCOLE POLYTECHNIQUE FÉDÉRALE DE LAUSANNE,
Analysis of programs with pointers. Simple example What are the dependences in this program? Problem: just looking at variable names will not give you.
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
Comp 122, Spring 2004 Binary Search Trees. btrees - 2 Comp 122, Spring 2004 Binary Trees  Recursive definition 1.An empty tree is a binary tree 2.A node.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 19: Minding Ps & Qs: Axiomatic.
1 Discrete Structures Lecture 29 Predicates and Programming Read Ch
Predicate Transformers
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
CS 355 – Programming Languages
Recap from last time We were trying to do Common Subexpression Elimination Compute expressions that are available at each program point.
ESC Java. Static Analysis Spectrum Power Cost Type checking Data-flow analysis Model checking Program verification AutomatedManual ESC.
CS 536 Spring Global Optimizations Lecture 23.
ECI 2007: Specification and Verification of Object- Oriented Programs Lecture 1.
ESC Java. Static Analysis Spectrum Power Cost Type checking Data-flow analysis Model checking Program verification AutomatedManual ESC.
Review: forward E { P } { P && E } TF { P && ! E } { P 1 } { P 2 } { P 1 || P 2 } x = E { P } { \exists … }
Insertion into a B+ Tree Null Tree Ptr Data Pointer * Tree Node Ptr After Adding 8 and then 5… 85 Insert 1 : causes overflow – add a new level * 5 * 158.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Lecture 4 Discrete Mathematics Harper Langston. Algorithms Algorithm is step-by-step method for performing some action Cost of statements execution –Simple.
CS 267: Automated Verification Lecture 13: Bounded Model Checking Instructor: Tevfik Bultan.
Proving Program Correctness The Axiomatic Approach.
Proving Program Correctness The Axiomatic Approach.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
Optimizing Compilers Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
1/20 Symbolic Execution and Program Testing Charngki PSWLAB Symbolic Execution and Program Testing James C.King IBM Thomas J.Watson Research Center.
Coinduction in a language and verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond IFIP WG 2.3 meeting Seattle,
TECH Computer Science Data Abstraction and Basic Data Structures Improving efficiency by building better  Data Structure Object IN  Abstract Data Type.
Recursion Textbook chapter Recursive Function Call a recursive call is a function call in which the called function is the same as the one making.
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
Data Structures Chapter 1- Introduction Mohamed Mustaq.A.
Chapter 25 Formal Methods Formal methods Specify program using math Develop program using math Prove program matches specification using.
CS 363 Comparative Programming Languages Semantics.
Mathematical Background and Linked Lists. 2 Iterative Algorithm for Sum Find the sum of the first n integers stored in an array v : sum (v[], n) temp_sum.
Chapter 5: Sequences, Mathematical Induction, and Recursion 5.5 Application: Correctness of Algorithms 1 [P]rogramming reliability – must be an activity.
Reasoning about programs March CSE 403, Winter 2011, Brun.
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.
Semantics In Text: Chapter 3.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
© 2006 Carnegie Mellon University Introduction to CBMC: Part 1 Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Arie Gurfinkel,
Quantified Data Automata on Skinny Trees: an Abstract Domain for Lists Pranav Garg 1, P. Madhusudan 1 and Gennaro Parlato 2 1 University of Illinois at.
/ PSWLAB Evidence-Based Analysis and Inferring Preconditions for Bug Detection By D. Brand, M. Buss, V. C. Sreedhar published in ICSM 2007.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
C HAPTER 3 Describing Syntax and Semantics. D YNAMIC S EMANTICS Describing syntax is relatively simple There is no single widely acceptable notation or.
Lecture 2 What is a computational problem? What is an instance of a problem? What is an algorithm? How to guarantee that an algorithm is correct? What.
Review Linked List Insertion Description Deletion Description Basic Node Implementation Conclusion 1.
© 2006 Carnegie Mellon University Introduction to CBMC: Part 1 Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Arie Gurfinkel,
Haskell With Go Faster Stripes Neil Mitchell. Catch: Project Overview Catch checks that a Haskell program won’t raise a pattern match error head [] =
CORRECTNESS ISSUES AND LOOP INVARIANTS Lecture 8 CS2110 – Fall 2014.
Code Optimization More Optimization Techniques. More Optimization Techniques  Loop optimization  Code motion  Strength reduction for induction variables.
Chapter 3 of Programming Languages by Ravi Sethi
Reasoning About Code.
Reasoning about code CSE 331 University of Washington.
Programming Abstractions
Arrays and Linked Lists
What is a heap? Always keep the thing we are most interested in close to the top (and fast to access). Like a binary search tree, but less structured.
Programming Languages and Compilers (CS 421)
Formal Methods in software development
Building SSA Harry Xu CS 142 (b) 04/22/2018.
Linked Lists.
Programming Languages and Compilers (CS 421)
COP4020 Programming Languages
Presentation transcript:

1 Total Pasta: Unfailing Pointer Programs Neil Mitchell, ndm AT cs.york.ac.uk Department of Computer Science, University of York

2 Pasta – Linked List Example list { nil(); cons(int head, ptr tail); } -- inserts an element into an ordered list insert(int i, ptr s) { while (s::cons && s->head tail; if (s::nil || s->head > i) *s = *cons(i,copy(s)); } main() { ptr r = nil(); insert(1,r); insert(9,r); insert(2,r); insert(8,r); }

3 Total Pasta Functions? Must not crash  if (s::nil) s = s->tail; Must terminate  while (s::cons) s = s; Don't need to worry about  arithmetic overflow (no addition in Pasta!)  recursion (also not in Pasta) Assume unbounded memory

4 Subtype checking Subtype annotations  if (x::cons) … Subtype assertions  x->tail requires x::cons Can use powerset to represent subtypes  Subtype(x)  {{cons,nil}, {nil}, {cons},  } Type assertions can be discharged by static checking

5 Termination Checking Only has a while statement to loop There must be one variable that is advanced down an acyclic path during every iteration  while (s::cons) s = s->tail; Requires an acyclic annotation  list acyclic(tail) { … }

6 My Approach B/Z inspired approach  Define postconditions for safety  Propagate backwards  Show the conditions are satisfied The Method  Assign a postcondition of True  Transform post conditions to generate preconditions  Total function has precondition of True

7 Details: Safe and Prec Safe(  ) – the conditions for  to be safe  Safe( s->tail ) = s::cons Prec( ,  ) – the condition , with   Prec( x = y, x::cons ) = y::cons  { y::cons } x = y { x::cons }

8 Flow Structures (if) {  } if (cond) t; else f; {  }  =safe( cond )  ( cond  safe( t )  prec( t,  ))  (  cond  safe( f )  prec( f,  ))

9 A small example if (s::nil || s->head > i) *s = *cons(i,copy(s)); Now lets expand the || … {True}

10 Expanding out the || if (s::nil) stmt; else if (s->head > i) stmt; Equivalent to: {True} {s::cons} {True} {(s::nil  True)  (  s::nil  s::cons)} {s::cons} {True}

11 Ingredients of Checking Prec and Safe functions A predicate solver Fixed pointing for loops Check that acyclic property is preserved Check all loops terminate

12 Back to the example The precondition to main is True The precondition to insert is True Both are total functions Also tested on Queues, Binary Trees, 234 Trees, for insertion and deletion  Proves all to be total functions

13 Future Work Use a mainstream language, i.e. C++ Extend Pasta with static typing, arithmetic Operate on individual procedures  Currently it expands them ALL inline Make it go faster  Some runs took hours ( insert in 234 Tree)  Profiling gave 20x speedup with ease

14 Total Pasta: Unfailing Pointer Programs Neil Mitchell, ndm AT cs.york.ac.uk Department of Computer Science, University of York

15 Starred Assignment *a = *c a b c nil cons a b c Notice that the value of b changes, without being mentioned