Automating Construction of Provably Correct Software Viktor Kuncak
|
|
- Abraham Waters
- 5 years ago
- Views:
Transcription
1 Your Wish is my Command Automating Construction of Provably Correct Software Viktor Kuncak EPFL School of Computer and Communication Sciences Laboratory for Automated Reasoning and Analysis
2 wish This Talk requirement formalization specification (constraint): C implementation (program): p conventional compilation How to automatically transform specifications into implementations? Command
3 Example Wish: Sorting input output > < < < Given a list of numbers, make this list sorted wish
4 Sorting Specification as a Program input output > < < < Given a list of numbers, make this list sorted wish def sort_spec(input : List, output : List) : Boolean = content(output)==content(input) /\ issorted(output) Specification (for us) is a program that checks, for a given input, whether the given output is acceptable
5 Specification vs Implementation def C(i : List, o : List) : Boolean = content(o)==content(i) /\ issorted(o) true / false constraint on the output more behaviors input specification U implementation output p C fewer behaviors function that computes the output def p(i : List) : List = sort i using a sorting algorithm and return the result
6 Synthesizing Sort in Leon System OOPSLA 2013: Synthesis Modulo Recursive Functions Etienne Kneuss Ivan Kuraj Philippe Suter
7 Example Results Techniques used: Leon s verification capabilities synthesis for theory of trees recursion schemas case splitting symbolic exploration of the space of programs synthesis based on type inhabitation fast falsification using previous counterexamples learning conditional expressions cost-based search over possible synthesis steps
8 Approaches and Their Guarantees both specification C and program p are given: a) Check assertion while program p runs: C(i,p(i)) only specification C is given: b) Verify whether program always meets the spec: i. C(i,p(i)) c) Constraint programming: once i is known, find o to satisfy a given constraint: find o such that C(i,o) run-time d) Synthesis: solve C symbolically to obtain program p that is correct by construction, for all inputs: find p such that i.c(i,p(i)) i.e. p C compile-time
9 Runtime Assertion Checking a) Check assertion while program p runs: C(i,p(i)) def p(i : List) : List = { sort i using a sorting algorithm and return the result } ensuring (o content(i)==content(o) && issorted(o)) def content(lst : List) = lst match { case Nil() Set.empty case Cons(x, xs) Set(x) ++ content(xs) } def issorted(lst : List) = lst match { case Nil() true case Cons(_, Nil()) true case Cons(x, Cons(y, ys)) } x < y && issorted(cons(y, ys)) Already works in Scala! Key design decision: constraints are programs Ongoing: high-level optimization of run-time checks Can we give stronger guarantees? prove postcondition always true
10 Static Verification in Leon b) Verify that program always meets spec: i. C(i,p(i)) def p(i : List) : List = { sort i using a sorting algorithm and return the result } ensuring (o content(i)==content(o) && issorted(o)) def content(lst : List) = lst match { case Nil() Set.empty case Cons(x, xs) Set(x) ++ content(xs) } def issorted(lst : List) = lst match { case Nil() true } case Cons(_, Nil()) true case Cons(x, Cons(y, ys)) x < y && issorted(cons(y, ys)) Type in a Scala program and spec, see it verified proof of i. C(i,p(i)) timeout input i such that not C (i,p(i))
11 Insertion Sort Verified as You Type It Web interface:
12 Reported Counterexample in Case of a Bug
13 Approaches and Their Guarantees both specification C and program p are given: a) Check assertion while program p runs: C(i,p(i)) only specification C is given: b) Verify that program always meets spec: i. C(i,p(i)) c) Constraint programming: once i is known, find o to satisfy a given constraint: find o such that C(i,o) run-time d) Synthesis: solve C symbolically to obtain program p that is correct by construction, for all inputs: find p such that i.c(i,p(i)) i.e. p C compile-time
14 Using Assertions to Compute what to do when assertion fail? presumably some values are wrong what to change (e.g. in repair) alternative: leave some variables unknown (logical variables); find their values to satisfy the assertions: constraint programming like CLP, but richer constraints new compilation techniques (synthesis) embedded in Scala, no Prolog with "cut"
15 Programming with Specifications c) Constraint programming: find a value that satisfies a given constraint: find o such that C(i,o) Method: use verification technology, try to prove that no such o exists, report counter-examples! Philippe Suter Ali Sinan Köksal Etienne Kneuss
16 Sorting a List Using Specifications def content(lst : List) = lst match { case Nil() Set.empty case Cons(x, xs) Set(x) ++ content(xs) } def issorted(lst : List) = lst match { case Nil() true case Cons(_, Nil()) true case Cons(x, Cons(y, ys)) x < y && issorted(cons(y,ys)) } ((l : List) issorted(lst) && content(lst) == Set(0, 1, -3)).solve > Cons(-3, Cons(0, Cons(1, Nil())))
17 Comparison: Date Conversion in C Knowing number of days since 1980, find current year and day BOOL ConvertDays(UINT32 days) { year = 1980; while (days > 365) { } if (IsLeapYear(year)) { if (days > 366) { } days -= 366; year += 1; } else { days -= 365; year += 1; }... Enter December 31, 2008 All music players (of a major brand) froze in the boot sequence.
18 Date Conversion using Specifications Knowing number of days since 1980, find current year and day val origin = 1980 // beginning of the universe def leapstill(y : Int) = (y-1)/4 - (y-1)/100 + (y-1)/400 val (year, day)=choose( (year:int, day:int) => { days == (year-origin)*365 + leapstill(year)-leapstill(origin) + day && 0 < day && day <= 366 }) // Choose year and day such that the property holds. We did not write how to compute year and day Instead, we gave a constraint they should satisfy We defined them implicitly, though this constraint More freedom (can still do it the old way, if needed) Correctness, termination simpler than with loop
19 Implementation: next 30 pages invariants - specification
20 Formalizing Tree Invariants (in Scala) sealed abstract class Tree case class Empty() extends Tree case class Node(color: Color, left: Tree, value: Int, right: Tree) extends Tree def blackbalanced(t : Tree) : Boolean = t match { case Node(_,l,_,r) => blackbalanced(l) && blackbalanced(r) && blackheight(l) ==blackheight(r) case Empty() => true } def blackheight(t : Tree) : Int = t match { case Empty() => 1 case Node(Black(), l, _, _) => blackheight(l) + 1 case Node(Red(), l, _, _) => blackheight(l) } def rb(t: Tree) : Boolean = t match { case Empty() => true case Node(Black(), l, _, r) => rb(l) && rb(r) case Node(Red(), l, _, r) => isblack(l) && isblack(r) && rb(l) && rb(r) }... def issorted(t:tree) =...
21 Define Abstraction as tree fold def content(t: Tree) : Set[Int] = t match { case Empty() => Set.empty case Node(_, l, v, r) => content(l) ++ Set(v) ++ content(r) } { 2, 4, 5, 7, 9 } 2 5
22 We can now define insertion def insert(x : Int, t : Tree) = choose(t1:tree => isrbt(t1) && content(t1) = content(t) ++ Set(x)) Objection: it took a lot of effort to write isrbt Answer: no more effort than implementation - wrote some functions these invariants is what drives data structure design this is how things are explained in a textbook it promotes reuse!
23 Evolving the Program Suppose we have a red-black tree implementation We only implemented insert and lookup Now we also need to implement remove
24 void RBDelete(rb_red_blk_tree* tree, rb_red_blk_node* z){ rb_red_blk_node* y; rb_red_blk_node* x; rb_red_blk_node* nil=tree->nil; rb_red_blk_node* root=tree->root; y= ((z->left == nil) (z->right == nil))? z : TreeSuccessor(tree,z); x= (y->left == nil)? y->right : y->left; if (root == (x->parent = y->parent)) { /* assignment of y->p to x->p is intentional */ root->left=x; } else { if (y == y->parent->left) { y->parent->left=x; } else { y->parent->right=x; } } if (y!= z) { /* y should not be nil in this case */ #ifdef DEBUG_ASSERT Assert( (y!=tree->nil),"y is nil in RBDelete\n"); #endif /* y is the node to splice out and x is its child */ if (!(y->red)) RBDeleteFixUp(tree,x); tree->destroykey(z->key); tree->destroyinfo(z->info); y->left=z->left; y->right=z->right; y->parent=z->parent; y->red=z->red; z->left->parent=z->right->parent=y; if (z == z->parent->left) { z->parent->left=y; } else { z->parent->right=y; } free(z); } else { tree->destroykey(y->key); tree->destroyinfo(y->info); if (!(y->red)) RBDeleteFixUp(tree,x); free(y); } #ifdef DEBUG_ASSERT Assert(!tree->nil->red,"nil not black in RBDelete"); #endif 140 lines of tricky C, even reusing existing functions void RBDeleteFixUp(rb_red_blk_tree* tree, rb_red_blk_node* x) { rb_red_blk_node* root=tree->root->left; rb_red_blk_node* w; while( (!x->red) && (root!= x)) { if (x == x->parent->left) { w=x->parent->right; if (w->red) { w->red=0; x->parent->red=1; LeftRotate(tree,x->parent); w=x->parent->right; } if ( (!w->right->red) && (!w->left->red) ) { w->red=1; x=x->parent; } else { if (!w->right->red) { w->left->red=0; w->red=1; RightRotate(tree,w); w=x->parent->right; } w->red=x->parent->red; x->parent->red=0; w->right->red=0; LeftRotate(tree,x->parent); x=root; /* this is to exit while loop */ } } else { /* the code below is has left and right switched from above */ w=x->parent->left; if (w->red) { w->red=0; x->parent->red=1; RightRotate(tree,x->parent); w=x->parent->left; } if ( (!w->right->red) && (!w->left->red) ) { w->red=1; x=x->parent; } else { if (!w->left->red) { w->right->red=0; w->red=1; LeftRotate(tree,w); w=x->parent->left; } w->red=x->parent->red; x->parent->red=0; w->left->red=0; RightRotate(tree,x->parent); x=root; /* this is to exit while loop */ } } } x->red=0; #ifdef DEBUG_ASSERT
25 remove using specifications: 2 lines def remove(x : Int, t : Tree) = choose(t1:tree => isrbt(t1) && content(t1)=content(t) Set(x)) The biggest expected payoff: properties are more reusable
26 Further Features Supported computing minimal / maximal solution of constraints value using binary search on-the-fly construction of constraints first-class constraints, like first-class functions but they can also be syntactically manipulated enumeration of all values that satisfy constraint application in automated test input generation can be used like Korat tool for test generation
27 Approaches and Their Guarantees both specification C and program p are given: a) Check assertion while program p runs: C(i,p(i)) c) Constraint programming: once i is known, find o to satisfy a given constraint: find o such that C(i,o) only specification C is given: run-time b) Verify that program always meets spec: i. C(i,p(i)) d) Synthesis: solve C symbolically to obtain program p that is correct by construction, for all inputs: find p such that i.c(i,p(i)) i.e. p C compile-time
28 Implicit Programming (ERC project) y o x specification (constraint) implicit x 2 + y 2 = 1 i is assignment for some vars of a propositional formula o is its completion to make formula true i synthesis U o U x implementation (function) explicit y = sqrt(1-x 2 ) compute missing part of a satisfying assignment (SAT) i
29 Synthesis for Linear Arithmetic def secondstotime(totalseconds: Int) : (Int, Int, Int) = choose((h: Int, m: Int, s: Int) ( h * m * 60 + s == totalseconds && h 0 && m 0 && m < 60 could infer from types && s 0 && s < 60 )) close to a wish def secondstotime(totalseconds: Int) : (Int, Int, Int) = val t1 = totalseconds div 3600 val t2 = totalseconds * t1 val t3 = t2 div 60 val t4 = totalseconds * t1-60 * t3 (t1, t3, t4)
30 Compile-time warnings def secondstotime(totalseconds: Int) : (Int, Int, Int) = choose((h: Int, m: Int, s: Int) ( h * m * 60 + s == totalseconds && h 0 && m 0 && m 60 && s 0 && s < 60 )) Warning: Synthesis predicate has multiple solutions for variable assignment: totalseconds = 60 Solution 1: h = 0, m = 0, s = 60 Solution 2: h = 0, m = 1, s = 0
31 Synthesis for sets (BAPA) def splitbalanced[t](s: Set[T]) : (Set[T], Set[T]) = choose((a: Set[T], b: Set[T]) ( a.size b.size 1 && balanced b.size a.size 1 && a union b == s && a intersect b == empty )) partition we can conjoin specs def splitbalanced[t](s: Set[T]) : (Set[T], Set[T]) = val k = ((s.size + 1)/2).floor val t1 = k val t2 = s.size k val s1 = take(t1, s) val s2 = take(t2, s minus s1) (s1, s2) s a Mikael Mayer Ruzica Piskac Philippe Suter b
32 Synthesis for Theories assert(i % 2 == 1) 3 i + 2 o = 13 o = (13 3 i)/2 Wanted: "Gaussian elimination" for programs for linear integer equations: extended Euclid s algorithm need to handle disjunctions, negations, more data types For every formula in e.g. Presburger arithmetic synthesis algorithm terminates produces the most general precondition (assertion characterizing when the result exists) generated code always terminates and gives correct result If there are multiple or no solutions for some input parameters, the algorithm identifies those inputs Works not only for arithmetic but also for e.g. sets with sizes and for trees Goal: lift everything done for SMT solvers to synthesizers
33 Decision & Synthesis Procedures For a well-defined class of formulas: Decision procedure Input: a formula Output: a model of the formula 5a + 7x = 31 a 2 x 3 (modelgenerating) a theorem prover that always succeeds Synthesis procedure a synthesizer that always succeeds Input: a formula, with input and output variables Output: a program to compute output values from input values Inputs: { a } outputs: { x } 5a + 7x = 31 x (31 5a) / 7 33
34 Framework: Transforming Relations a C 1 x a C 2 x Input variables Synthesis predicate Output variables a, x. C 2 C 1 Refinement a. ( x : C 1 ) ( x : C 2 ) Domain preservation 34
35 Programs as Relations a C x P T Input variables Output variables Precondition Program terms Represents the relation: P (x = T ) a. P C[x T ] Refinement a. ( x : C) P Domain preservation 35
36 Compare to Quantifier Elimination A problem of the form: Corresponds to constructively solving the quantifier elimination problem: In the solution, P corresponds to the result of Q.E. and T are witness terms. a C x x : C( a, x ) P T 36
37 Transforming Relations Equivalence a C 1 x P T C 1 C 2 a C 2 x P T Case-Split a C 1 x P 1 T 1 a C 2 x P 2 T 2 a C 1 C 2 x P 1 P 2 if(p 1 ) T 1 else T 2 One-Point a C[x 0 t] x P T x 0 vars(t) a x 0 = t C x 0 ;x P let x := T in t;x 37
38 Synthesis for Linear Integer Arithmetic a 7t a 5a 12t t 5a/12 3a/7 5a/12 a 5x + 7y = a 0 x x y x,y 5a/12 3a/7 let t = 5a/12 in (-7t+3a, 5t-2a) 5x + 7y = a One-dimensional solution space. x = -7t + 3a y = 5t 2a is a solution for any t. 7t a 5a 12t t is bound on both sides, and admits a solution whenever 5a/12 3a/7 38
39 And/Or Search for Rule Applications Synthesis problem Rule application 5 C F E Driven by cost - For rule applications: size of term contributed to program. - For (sub)problems: estimate based on variables and boolean structure. 4 D 1 A 2 3 G B 6 7 H J 39
40 Synthesis in Techniques used: Leon s verification capabilities synthesis for theory of trees recursion schemas case splitting symbolic exploration of the space of programs synthesis based on type inhabitation fast falsification using previous counterexamples learning conditional expressions cost-based search over possible synthesis steps
41 Generating Expression Terms What do we do with problems that: do not fall in a well-defined, synthesizable subset, do not get simplified by decomposition? Use counter-example guided inductive synthesis to search over small expressions Two algorithms use SMT solvers to enumerate terms and evaluate them to find new blocking clauses type-based enumeration (Gvero,Piskac,Kuraj) combined with discovery of preconditions 41
42 Approaches and Their Guarantees both specification C and program p are given: a) Check assertion while program p runs: C(i,p(i)) c) Constraint programming: once i is known, find o to satisfy a given constraint: find o such that C(i,o) only specification C is given: run-time b) Verify that program always meets spec: i. C(i,p(i)) d) Synthesis: solve C symbolically to obtain program p that is correct by construction, for all inputs: find p such that i.c(i,p(i)) i.e. p C compile-time
43 Synthesis and Constraint Solving If we did not find an expression that solves it in all cases, we emit a runtime call to solver Result: solver invoked only in some cases for some components of result for some conditions on inputs after timeout, close the remaining branches by inserting a C runtime solver call 1 A F E D G B 6 7 H J
44 Example Data Structure with Cache case class CTree(cache : Int, data : Tree) def inv(ct : CTree) : Boolean = isrbt(data) && (ct.data = Empty content(ct.data) contains ct.cache) def member(v : Int, ct : CTree) : Boolean = { require(inv(ct)) choose( (x:boolean) => x == (content(ct.data) contains v)) } ADT and equality split, one point rule, simplifications def member(v : Int, ct : CTree) : Boolean = { require(inv(ct)) ct.data match { case n:node => if (ct.cache == v) true else choose( (x:boolean) => x == (content(ct.data) contains v)) case Empty => false } Synthesis did not solve fully but optimized spec for 2 common cases
45 From In-Memory to External Sorting treefold[2 k ]([], unfoldr( funcpow[k](mrg)) in-memory sort external 2 k -way merge sort with blocking C implementation transformation rules for monad algebra of nested sequences exploration of equivalent algorithms through performance estimation w/ non-linear constraint solving Synthesis of Out-of-Core Algorithms (SIGMOD 2013) Ioannis Klonatos Christoph Koch Andres Nötzli Andrej Spielmann
46 Real-World Reasoning Gap between floating points and reality input measurement error floating-point round-off error numerical method error x<y need not mean x*<y* Automated verification tools to compute upper error bound generate code to match math Applied to code fragments for embedded systems (car,train) physics simulations OOPSLA'11,RV'12, EMSOFT'13, POPL'14 Eva Darulova
47 wish requirement formalization specification (constraint): C implementation (program): p conventional compilation Can we help with designing specification themselves, to make programming accessible to non-experts? Command
48 Programming by Demonstration Describe functionality by demonstrating and modifying behaviors while the program runs demonstrate desired actions by moving back in time and referring to past events system generalizes demonstrations into rules Try "Pong Designer" in Android Play Store Mikael Mayer and Lomig Mégard SPLASH Onward'13
Synthesizing Computable Functions from Relations. Viktor Kuncak. EPFL Laboratory for Automated Reasoning and Analysis
Synthesizing Computable Functions from Relations Viktor Kuncak EPFL Laboratory for Automated Reasoning and Analysis http://lara.epfl.ch http://leon.epfl.ch wish requirement formalization From your wish
More informationYour Wish is my Command
Your Wish is my Command Viktor Kunčak School of Computer and Communication Sciences Laboratory for Automated Reasoning and Analysis http://lara.epfl.ch wish human effort Command(program) compilation 11011001
More informationSynthesis using Variable Elimination
Synthesis using Variable Elimination Viktor Kuncak EPF Lausanne http://lara.epfl.ch/w/impro Implicit Programming at All Levels Opportunities for implicit programming in Development within an IDE InSynth
More informationSolving Computations. Viktor Kuncak. PhD MIT,
Solving Computations Viktor Kuncak PhD MIT, 2007 School of Computer and Communication Sciences Laboratory for Automated Reasoning and Analysis http://lara.epfl.ch/~kuncak 1 GOAL Help people construct software
More informationSoftware Construction using Executable Constraints
Software Construction using Executable Constraints Presented by: Viktor Kuncak joint work with: Ali Sinan Köksal, Ruzica Piskac, and Philippe Suter Swiss Federal Institute of Technology Lausanne (EPFL)
More informationImplicit Programming
Implicit Programming Viktor Kuncak EPF Lausanne http://lara.epfl.ch/w/impro Joint work with Ruzica Piskac Philippe Suter Tihomir Gvero Mikaël Mayer Ali Sinan Köksal EPFL Sebastien Vasey Barbara Jobstmann
More informationLaboratory for Automated Reasoning and Analysis
http://lara.epfl.ch Laboratory for Automated Reasoning and Analysis Viktor Kuncak Assistant Professor, IC a project: http://javaverification.org ongoing class: http://richmodels.org/lat Spring, will be
More informationSmall Formulas for Large Programs: On-line Constraint Simplification In Scalable Static Analysis
Small Formulas for Large Programs: On-line Constraint Simplification In Scalable Static Analysis Isil Dillig, Thomas Dillig, Alex Aiken Stanford University Scalability and Formula Size Many program analysis
More informationRuzica Piskac Yale University
Ruzica Piskac Yale University Why Software Verification? Maiden flight of the Ariane 5 rocket on the 4th of June 1996 The reason for the explosion was a software error Financial loss: $500,000,000 (including
More informationFunctional Synthesis for Linear Arithmetic and Sets
Software Tools for Technology Transfer manuscript No. (will be inserted by the editor) Functional Synthesis for Linear Arithmetic and Sets Viktor Kuncak, Mikaël Mayer, Ruzica Piskac, Philippe Suter School
More informationSpark verification features
Spark verification features Paul Jackson School of Informatics University of Edinburgh Formal Verification Spring 2018 Adding specification information to programs Verification concerns checking whether
More informationFinding and Fixing Bugs in Liquid Haskell. Anish Tondwalkar
Finding and Fixing Bugs in Liquid Haskell Anish Tondwalkar Overview Motivation Liquid Haskell Fault Localization Fault Localization Evaluation Predicate Discovery Predicate Discovery Evaluation Conclusion
More informationSpecifications. Prof. Clarkson Fall Today s music: Nice to know you by Incubus
Specifications Prof. Clarkson Fall 2015 Today s music: Nice to know you by Incubus Question Would you like a tiny bonus to your final grade for being here on time today? A. Yes B. Sí C. Hai D. Haan E.
More informationA short manual for the tool Accumulator
A short manual for the tool Accumulator ZHAO Jianhua State Key Laboratory of Novel Software Technology Dept. of Computer Sci. and Tech. Nanjing University Nanjing, Jiangsu, P.R.China 210093 zhaojh@nju.edu.cn
More informationIncremental Proof Development in Dafny
15-414 Lecture 17 1 Instructor: Matt Fredrikson Incremental Proof Development in Dafny TA: Ryan Wagner In this discussion, we ll see in more detail how to go about proving the total correctness of imperative
More informationFreePascal changes: user documentation
FreePascal changes: user documentation Table of Contents Jochem Berndsen February 2007 1Introduction...1 2Accepted syntax...2 Declarations...2 Statements...3 Class invariants...3 3Semantics...3 Definitions,
More informationAbstract Interpretation
Abstract Interpretation Ranjit Jhala, UC San Diego April 22, 2013 Fundamental Challenge of Program Analysis How to infer (loop) invariants? Fundamental Challenge of Program Analysis Key issue for any analysis
More informationRuntime Checking for Program Verification Systems
Runtime Checking for Program Verification Systems Karen Zee, Viktor Kuncak, and Martin Rinard MIT CSAIL Tuesday, March 13, 2007 Workshop on Runtime Verification 1 Background Jahob program verification
More informationVS 3 : SMT Solvers for Program Verification
VS 3 : SMT Solvers for Program Verification Saurabh Srivastava 1,, Sumit Gulwani 2, and Jeffrey S. Foster 1 1 University of Maryland, College Park, {saurabhs,jfoster}@cs.umd.edu 2 Microsoft Research, Redmond,
More informationdoi: / Software Synthesis Procedures By Viktor Kuncak, Mikaël Mayer, Ruzica Piskac, and Philippe Suter
doi:10.1145/2076450.2076472 Software Synthesis Procedures By Viktor Kuncak, Mikaël Mayer, Ruzica Piskac, and Philippe Suter Abstract Automated synthesis of program fragments from specifications can make
More informationProgramming Languages Third Edition
Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand
More informationMinimum Satisfying Assignments for SMT. Işıl Dillig, Tom Dillig Ken McMillan Alex Aiken College of William & Mary Microsoft Research Stanford U.
Minimum Satisfying Assignments for SMT Işıl Dillig, Tom Dillig Ken McMillan Alex Aiken College of William & Mary Microsoft Research Stanford U. 1 / 20 Satisfiability Modulo Theories (SMT) Today, SMT solvers
More informationCOSE212: Programming Languages. Lecture 3 Functional Programming in OCaml
COSE212: Programming Languages Lecture 3 Functional Programming in OCaml Hakjoo Oh 2017 Fall Hakjoo Oh COSE212 2017 Fall, Lecture 3 September 18, 2017 1 / 44 Why learn ML? Learning ML is a good way of
More informationAn Annotated Language
Hoare Logic An Annotated Language State and Semantics Expressions are interpreted as functions from states to the corresponding domain of interpretation Operators have the obvious interpretation Free of
More informationCSCI-GA Scripting Languages
CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation
More informationOn Satisfiability Modulo Computable Functions
On Satisfiability Modulo Computable Functions EPFL-REPORT-161285 Philippe Suter, Ali Sinan Köksal, and Viktor Kuncak École Polytechnique Fédérale de Lausanne (EPFL), Switzerland {firstname.lastname}@epfl.ch
More informationChapter 3 (part 3) Describing Syntax and Semantics
Chapter 3 (part 3) Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings
More informationRecap. Juan Pablo Galeotti,Alessandra Gorla, Software Engineering Chair Computer Science Saarland University, Germany
Recap Juan Pablo Galeotti,Alessandra Gorla, Software Engineering Chair Computer Science Saarland University, Germany 30% projects (10% each) At least 50% threshold for exam admittance Groups of 2 70% final
More informationInduction and Semantics in Dafny
15-414 Lecture 11 1 Instructor: Matt Fredrikson Induction and Semantics in Dafny TA: Ryan Wagner Encoding the syntax of Imp Recall the abstract syntax of Imp: a AExp ::= n Z x Var a 1 + a 2 b BExp ::=
More informationLOGIC AND DISCRETE MATHEMATICS
LOGIC AND DISCRETE MATHEMATICS A Computer Science Perspective WINFRIED KARL GRASSMANN Department of Computer Science University of Saskatchewan JEAN-PAUL TREMBLAY Department of Computer Science University
More informationStatic Contract Checking for Haskell
Static Contract Checking for Haskell Dana N. Xu INRIA France Work done at University of Cambridge Simon Peyton Jones Microsoft Research Cambridge Joint work with Koen Claessen Chalmers University of Technology
More informationCS 220: Discrete Structures and their Applications. Recursive objects and structural induction in zybooks
CS 220: Discrete Structures and their Applications Recursive objects and structural induction 6.9 6.10 in zybooks Using recursion to define objects We can use recursion to define functions: The factorial
More informationDISCRETE MATHEMATICS
DISCRETE MATHEMATICS WITH APPLICATIONS THIRD EDITION SUSANNA S. EPP DePaul University THOIVISON * BROOKS/COLE Australia Canada Mexico Singapore Spain United Kingdom United States CONTENTS Chapter 1 The
More informationProgramming with Contracts. Juan Pablo Galeotti, Alessandra Gorla Saarland University, Germany
Programming with Contracts Juan Pablo Galeotti, Alessandra Gorla Saarland University, Germany Contract A (formal) agreement between Method M (callee) Callers of M Rights Responsabilities Rights Responsabilities
More informationCSE 20 DISCRETE MATH. Fall
CSE 20 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/ Final exam The final exam is Saturday December 16 11:30am-2:30pm. Lecture A will take the exam in Lecture B will take the exam
More informationReasoning About Imperative Programs. COS 441 Slides 10
Reasoning About Imperative Programs COS 441 Slides 10 The last few weeks Agenda reasoning about functional programming It s very simple and very uniform: substitution of equal expressions for equal expressions
More informationAbstractions and small languages in synthesis CS294: Program Synthesis for Everyone
Abstractions and small languages in synthesis CS294: Program Synthesis for Everyone Ras Bodik Emina Torlak Division of Computer Science University of California, Berkeley Today Today: we describe why high-level
More informationBinary search trees. Support many dynamic-set operations, e.g. Search. Minimum. Maximum. Insert. Delete ...
Binary search trees Support many dynamic-set operations, e.g. Search Minimum Maximum Insert Delete... Can be used as dictionary, priority queue... you name it Running time depends on height of tree: 1
More informationCS 161 Computer Security
Wagner Spring 2014 CS 161 Computer Security 1/27 Reasoning About Code Often functions make certain assumptions about their arguments, and it is the caller s responsibility to make sure those assumptions
More informationBasic Verification Strategy
ormal Verification Basic Verification Strategy compare behavior to intent System Model of system behavior intent Verifier results Intent Usually, originates with requirements, refined through design and
More informationThe design of a programming language for provably correct programs: success and failure
The design of a programming language for provably correct programs: success and failure Don Sannella Laboratory for Foundations of Computer Science School of Informatics, University of Edinburgh http://homepages.inf.ed.ac.uk/dts
More informationSymbolic and Concolic Execution of Programs
Symbolic and Concolic Execution of Programs Information Security, CS 526 Omar Chowdhury 10/7/2015 Information Security, CS 526 1 Reading for this lecture Symbolic execution and program testing - James
More informationCOMPUTER SCIENCE TRIPOS
CST.2011.3.1 COMPUTER SCIENCE TRIPOS Part IB Monday 6 June 2011 1.30 to 4.30 COMPUTER SCIENCE Paper 3 Answer five questions. Submit the answers in five separate bundles, each with its own cover sheet.
More informationTheorem proving. PVS theorem prover. Hoare style verification PVS. More on embeddings. What if. Abhik Roychoudhury CS 6214
Theorem proving PVS theorem prover Abhik Roychoudhury National University of Singapore Both specification and implementation can be formalized in a suitable logic. Proof rules for proving statements in
More informationAn Evolution of Mathematical Tools
An Evolution of Mathematical Tools From Conceptualization to Formalization Here's what we do when we build a formal model (or do a computation): 0. Identify a collection of objects/events in the real world.
More informationAdvanced features of Functional Programming (Haskell)
Advanced features of Functional Programming (Haskell) Polymorphism and overloading January 10, 2017 Monomorphic and polymorphic types A (data) type specifies a set of values. Examples: Bool: the type of
More information[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics
400 lecture note #4 [Ch 6] Set Theory 1. Basic Concepts and Definitions 1) Basics Element: ; A is a set consisting of elements x which is in a/another set S such that P(x) is true. Empty set: notated {
More information10/9/17. Using recursion to define objects. CS 220: Discrete Structures and their Applications
Using recursion to define objects CS 220: Discrete Structures and their Applications Recursive objects and 6.9 6.10 in zybooks We can use recursion to define functions: The factorial function can be defined
More informationlearning objectives learn about variables, their types and their values learn about different number representations
programming basics learning objectives algorithms your software system software hardware learn about variables, their types and their values learn about different number representations learn boolean algebra
More informationCombining Static and Dynamic Contract Checking for Curry
Michael Hanus (CAU Kiel) Combining Static and Dynamic Contract Checking for Curry LOPSTR 2017 1 Combining Static and Dynamic Contract Checking for Curry Michael Hanus University of Kiel Programming Languages
More informationHECTOR: Formal System-Level to RTL Equivalence Checking
ATG SoC HECTOR: Formal System-Level to RTL Equivalence Checking Alfred Koelbl, Sergey Berezin, Reily Jacoby, Jerry Burch, William Nicholls, Carl Pixley Advanced Technology Group Synopsys, Inc. June 2008
More informationRethinking Automated Theorem Provers?
Rethinking Automated Theorem Provers? David J. Pearce School of Engineering and Computer Science Victoria University of Wellington @WhileyDave http://whiley.org http://github.com/whiley Background Verification:
More informationComplete Functional Synthesis
Complete Functional Synthesis Viktor Kuncak Mikaël Mayer Ruzica Piskac Philippe Suter School of Computer and Communication Sciences (I&C) - Swiss Federal Institute of Technology (EPFL), Switzerland firstname.lastname@epfl.ch
More informationCMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics
Recall Architecture of Compilers, Interpreters CMSC 330: Organization of Programming Languages Source Scanner Parser Static Analyzer Operational Semantics Intermediate Representation Front End Back End
More informationPlan of the lecture. Quick-Sort. Partition of lists (or using extra workspace) Quick-Sort ( 10.2) Quick-Sort Tree. Partitioning arrays
Plan of the lecture Quick-sort Lower bounds on comparison sorting Correctness of programs (loop invariants) Quick-Sort 7 4 9 6 2 2 4 6 7 9 4 2 2 4 7 9 7 9 2 2 9 9 Lecture 16 1 Lecture 16 2 Quick-Sort (
More informationCSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections p.
CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections 10.1-10.3 p. 1/106 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer
More informationLecture 10 Design by Contract
CS 5959 Writing Solid Code Fall 2015 Nov-23 Lecture 10 Design by Contract Zvonimir Rakamarić University of Utah Design by Contract Also called assume-guarantee reasoning Developers annotate software components
More informationProgram Analysis and Constraint Programming
Program Analysis and Constraint Programming Joxan Jaffar National University of Singapore CPAIOR MasterClass, 18-19 May 2015 1 / 41 Program Testing, Verification, Analysis (TVA)... VS... Satifiability/Optimization
More informationReasoning about programs
Reasoning about programs Last time Coming up This Thursday, Nov 30: 4 th in-class exercise sign up for group on moodle bring laptop to class Final projects: final project presentations: Tue Dec 12, in
More informationLast time. Reasoning about programs. Coming up. Project Final Presentations. This Thursday, Nov 30: 4 th in-class exercise
Last time Reasoning about programs Coming up This Thursday, Nov 30: 4 th in-class exercise sign up for group on moodle bring laptop to class Final projects: final project presentations: Tue Dec 12, in
More informationDeductive Methods, Bounded Model Checking
Deductive Methods, Bounded Model Checking http://d3s.mff.cuni.cz Pavel Parízek CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Deductive methods Pavel Parízek Deductive Methods, Bounded
More informationHardware versus software
Logic 1 Hardware versus software 2 In hardware such as chip design or architecture, designs are usually proven to be correct using proof tools In software, a program is very rarely proved correct Why?
More informationFormally Certified Satisfiability Solving
SAT/SMT Proof Checking Verifying SAT Solver Code Future Work Computer Science, The University of Iowa, USA April 23, 2012 Seoul National University SAT/SMT Proof Checking Verifying SAT Solver Code Future
More informationCover Page. The handle holds various files of this Leiden University dissertation
Cover Page The handle http://hdl.handle.net/1887/22891 holds various files of this Leiden University dissertation Author: Gouw, Stijn de Title: Combining monitoring with run-time assertion checking Issue
More informationBOOGIE. Presentation by Itsik Hefez A MODULAR REUSABLE VERIFIER FOR OBJECT-ORIENTED PROGRAMS MICROSOFT RESEARCH
BOOGIE A MODULAR REUSABLE VERIFIER FOR OBJECT-ORIENTED PROGRAMS MICROSOFT RESEARCH Presentation by Itsik Hefez Introduction Boogie is an intermediate verification language, intended as a layer on which
More informationCS 267: Automated Verification. Lecture 13: Bounded Model Checking. Instructor: Tevfik Bultan
CS 267: Automated Verification Lecture 13: Bounded Model Checking Instructor: Tevfik Bultan Remember Symbolic Model Checking Represent sets of states and the transition relation as Boolean logic formulas
More informationFinite Model Generation for Isabelle/HOL Using a SAT Solver
Finite Model Generation for / Using a SAT Solver Tjark Weber webertj@in.tum.de Technische Universität München Winterhütte, März 2004 Finite Model Generation for / p.1/21 is a generic proof assistant: Highly
More informationSound Compilation of Reals
Sound Compilation of Reals Eva Darulova EPFL eva.darulova@epfl.ch Viktor Kuncak EPFL viktor.kuncak@epfl.ch Abstract Writing accurate numerical software is hard because of many sources of unavoidable uncertainties,
More informationVerification Overview Testing Theory and Principles Testing in Practice. Verification. Miaoqing Huang University of Arkansas 1 / 80
1 / 80 Verification Miaoqing Huang University of Arkansas Outline 1 Verification Overview 2 Testing Theory and Principles Theoretical Foundations of Testing Empirical Testing Principles 3 Testing in Practice
More information6. Hoare Logic and Weakest Preconditions
6. Hoare Logic and Weakest Preconditions Program Verification ETH Zurich, Spring Semester 07 Alexander J. Summers 30 Program Correctness There are many notions of correctness properties for a given program
More information6.170 Lecture 6 Procedure specifications MIT EECS
6.170 Lecture 6 Procedure specifications MIT EECS Outline Satisfying a specification; substitutability Stronger and weaker specifications Comparing by hand Comparing via logical formulas Comparing via
More informationLost in translation. Leonardo de Moura Microsoft Research. how easy problems become hard due to bad encodings. Vampire Workshop 2015
Lost in translation how easy problems become hard due to bad encodings Vampire Workshop 2015 Leonardo de Moura Microsoft Research I wanted to give the following talk http://leanprover.github.io/ Automated
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Operational Semantics CMSC 330 Summer 2018 1 Formal Semantics of a Prog. Lang. Mathematical description of the meaning of programs written in that language
More informationIn Our Last Exciting Episode
In Our Last Exciting Episode #1 Lessons From Model Checking To find bugs, we need specifications What are some good specifications? To convert a program into a model, we need predicates/invariants and
More informationSatisfiability Modulo Theories. DPLL solves Satisfiability fine on some problems but not others
DPLL solves Satisfiability fine on some problems but not others DPLL solves Satisfiability fine on some problems but not others Does not do well on proving multipliers correct pigeon hole formulas cardinality
More informationDiscrete Mathematics Lecture 4. Harper Langston New York University
Discrete Mathematics Lecture 4 Harper Langston New York University Sequences Sequence is a set of (usually infinite number of) ordered elements: a 1, a 2,, a n, Each individual element a k is called a
More informationCSE507. Practical Applications of SAT. Computer-Aided Reasoning for Software. Emina Torlak
Computer-Aided Reasoning for Software CSE507 Practical Applications of SAT courses.cs.washington.edu/courses/cse507/18sp/ Emina Torlak emina@cs.washington.edu Today Past 2 lectures The theory and mechanics
More informationNumerical Computations and Formal Methods
Program verification Formal arithmetic Decision procedures Proval, Laboratoire de Recherche en Informatique INRIA Saclay IdF, Université Paris Sud, CNRS October 28, 2009 Program verification Formal arithmetic
More informationAssertions & Design-by-Contract using JML Erik Poll University of Nijmegen
Assertions & Design-by-Contract using JML Erik Poll University of Nijmegen Erik Poll - JML p.1/39 Overview Assertions Design-by-Contract for Java using JML Contracts and Inheritance Tools for JML Demo
More informationLecture 15 CIS 341: COMPILERS
Lecture 15 CIS 341: COMPILERS Announcements HW4: OAT v. 1.0 Parsing & basic code generation Due: March 28 th No lecture on Thursday, March 22 Dr. Z will be away Zdancewic CIS 341: Compilers 2 Adding Integers
More informationCounterexample-Driven Genetic Programming
Counterexample-Driven Genetic Programming Iwo Błądek, Krzysztof Krawiec Institute of Computing Science, Poznań University of Technology Poznań, 12.12.2017 I. Błądek, K. Krawiec Counterexample-Driven Genetic
More informationLectures 20, 21: Axiomatic Semantics
Lectures 20, 21: Axiomatic Semantics Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Static Analysis Based on slides by George Necula Pratikakis (CSD) Axiomatic Semantics
More informationFormal Systems II: Applications
Formal Systems II: Applications Functional Verification of Java Programs: Java Dynamic Logic Bernhard Beckert Mattias Ulbrich SS 2017 KIT INSTITUT FÜR THEORETISCHE INFORMATIK KIT University of the State
More informationCSE 20 DISCRETE MATH. Winter
CSE 20 DISCRETE MATH Winter 2017 http://cseweb.ucsd.edu/classes/wi17/cse20-ab/ Final exam The final exam is Saturday March 18 8am-11am. Lecture A will take the exam in GH 242 Lecture B will take the exam
More informationRuntime Checking and Test Case Generation for Python
Runtime Checking and Test Case Generation for Python Anna Durrer Master Thesis Chair of Programming Methodology D-INFK ETH Supervisor: Marco Eilers, Prof. Peter Müller 24. Mai 2017 1 Introduction This
More informationFormalization of Incremental Simplex Algorithm by Stepwise Refinement
Formalization of Incremental Simplex Algorithm by Stepwise Refinement Mirko Spasić, Filip Marić Faculty of Mathematics, University of Belgrade FM2012, 30. August 2012. Overview 1 Introduction 2 Approach
More informationSMT Solvers for Verification and Synthesis. Andrew Reynolds VTSA Summer School August 1 and 3, 2017
SMT Solvers for Verification and Synthesis Andrew Reynolds VTSA Summer School August 1 and 3, 2017 Acknowledgements Thanks to past and present members of development team of CVC4: Cesare Tinelli, Clark
More informationHoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré
Hoare Logic COMP2600 Formal Methods for Software Engineering Rajeev Goré Australian National University Semester 2, 2016 (Slides courtesy of Ranald Clouston) COMP 2600 Hoare Logic 1 Australian Capital
More informationPropositional Calculus. Math Foundations of Computer Science
Propositional Calculus Math Foundations of Computer Science Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they can use it to
More informationGADTs. GADTs in Haskell
GADTs GADTs in Haskell ADT vs GADT Algebraic Datatype Data List a = Nil Cons a (List a) Data Tree a b = Tip a Node (Tree a b) b Fork (Tree a b) (Tree a b) Note that types than can be expressed as an ADT
More informationReasoning About Set Comprehensions
Reasoning About Set Comprehensions Edmund S L Lam 1 and Iliano Cervesato 1 Carnegie Mellon University sllam@qatarcmuedu, iliano@cmuedu Abstract Set comprehension is a mathematical notation for defining
More informationComputer Programming: Skills & Concepts (CP) arithmetic, if and booleans (cont)
CP Lect 5 slide 1 Monday 2 October 2017 Computer Programming: Skills & Concepts (CP) arithmetic, if and booleans (cont) Cristina Alexandru Monday 2 October 2017 Last Lecture Arithmetic Quadratic equation
More informationStatic program checking and verification
Chair of Software Engineering Software Engineering Prof. Dr. Bertrand Meyer March 2007 June 2007 Slides: Based on KSE06 With kind permission of Peter Müller Static program checking and verification Correctness
More informationCOSC252: Programming Languages: Semantic Specification. Jeremy Bolton, PhD Adjunct Professor
COSC252: Programming Languages: Semantic Specification Jeremy Bolton, PhD Adjunct Professor Outline I. What happens after syntactic analysis (parsing)? II. Attribute Grammars: bridging the gap III. Semantic
More informationSummary of Course Coverage
CS-227, Discrete Structures I Spring 2006 Semester Summary of Course Coverage 1) Propositional Calculus a) Negation (logical NOT) b) Conjunction (logical AND) c) Disjunction (logical inclusive-or) d) Inequalities
More informationOverview (4) CPE 101 mod/reusing slides from a UW course. Assignment Statement: Review. Why Study Expressions? D-1
CPE 101 mod/reusing slides from a UW course Overview (4) Lecture 4: Arithmetic Expressions Arithmetic expressions Integer and floating-point (double) types Unary and binary operators Precedence Associativity
More informationLecture 5 - Axiomatic semantics
Program Verification March 2014 Lecture 5 - Axiomatic semantics Lecturer: Noam Rinetzky Scribes by: Nir Hemed 1.1 Axiomatic semantics The development of the theory is contributed to Robert Floyd, C.A.R
More informationSatisfiability Modulo Theories: ABsolver
Satisfiability Modulo Theories: ABsolver Michael Tautschnig Joint work with: Andreas Bauer Martin Leucker Christian Schallhart Michael Tautschnig 1 Outline 1. Introduction Michael Tautschnig 2 Outline
More informationMathematics for Computer Scientists 2 (G52MC2)
Mathematics for Computer Scientists 2 (G52MC2) L07 : Operations on sets School of Computer Science University of Nottingham October 29, 2009 Enumerations We construct finite sets by enumerating a list
More informationLecture 4. First order logic is a formal notation for mathematics which involves:
0368.4435 Automatic Software Verification April 14, 2015 Lecture 4 Lecturer: Mooly Sagiv Scribe: Nimrod Busany, Yotam Frank Lesson Plan 1. First order logic recap. 2. The SMT decision problem. 3. Basic
More information