Verification and Data Structures int kmp_search(char str[], char pat[]){ p = 0; s = 0; while (p<pat.length && s<str.length){ if (str[s] == pat[p]){s++;

Slides:



Advertisements
Similar presentations
Automatic verification of summations K. Rustan M. Leino IFIP WG 2.3 meeting 46 Sydney, Australia 11 January 2007.
Advertisements

Transposing F to C Transposing F to C Andrew Kennedy & Don Syme Microsoft Research Cambridge, U.K.
Logical Abstract Interpretation Sumit Gulwani Microsoft Research, Redmond.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
1 Symbol Tables Chapter Sedgewick. 2 Symbol Tables Searching Searching is a fundamental element of many computational tasks looking up a name.
Satisfiability Modulo Computable Functions Philippe Suter, Ali Sinan Köksal, and Viktor Kuncak ÉCOLE POLYTECHNIQUE FÉDÉRALE DE LAUSANNE, SWITZERLAND Photo:
– Seminar in Software Engineering Cynthia Disenfeld
Automated Verification with HIP and SLEEK Asankhaya Sharma.
50.530: Software Engineering
Type Checking, Inference, & Elaboration CS153: Compilers Greg Morrisett.
Finding bugs: Analysis Techniques & Tools Symbolic Execution & Constraint Solving CS161 Computer Security Cho, Chia Yuan.
Gennaro Parlato (LIAFA, Paris, France) Joint work with P. Madhusudan Xiaokang Qie University of Illinois at Urbana-Champaign.
Satisfiability Modulo Theories (An introduction)
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,
Inferring Disjunctive Postconditions Corneliu Popeea and Wei-Ngan Chin School of Computing National University of Singapore - ASIAN
Automating Relatively Complete Verification of Higher-Order Functional Programs Hiroshi Unno (University of Tsukuba) Tachio Terauchi (Nagoya University)
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
Binary Decision Diagrams1 BINARY DECISION DIAGRAMS.
1 Satisfiability Modulo Theories Sinan Hanay. 2 Boolean Satisfiability (SAT) Is there an assignment to the p 1, p 2, …, p n variables such that  evaluates.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA part 0 Summer School on Logic and Theorem-Proving in Programming.
Checking Properties Of Software Static Safety Verification Dynamic Liveness Testing.
Abstract Data Types (ADT)
Nested Refinements: A Logic for Duck Typing Ravi Chugh, Pat Rondon, Ranjit Jhala (UCSD)
Goal: Static Software Verification Verify absence of run-time errors Buffer overflows Deadlocks Assertion failures Requires precise data structure verification.
Nested Refinements: A Logic for Duck Typing Ravi Chugh, Pat Rondon, Ranjit Jhala (UCSD) ::
VS 3 : Verification and Synthesis using SMT Solvers SMT Solvers for Program Verification Saurabh Srivastava * Sumit Gulwani ** Jeffrey S. Foster * * University.
Program Verification using Templates over Predicate Abstraction Saurabh Srivastava University of Maryland, College Park Sumit Gulwani Microsoft Research,
Balanced Search Trees CS 3110 Fall Some Search Structures Sorted Arrays –Advantages Search in O(log n) time (binary search) –Disadvantages Need.
Higher-Order Verification With Liquid Types Ranjit Jhala, UC San Diego (with Pat Rondon, Ming Kawaguchi)
Using Types For Software Verification Ranjit Jhala, UC San Diego (with Pat Rondon, Ming Kawaguchi)
Dependently Typed Data Structures Hongwei Xi presented by James Hook Pacific Software Research Center Oregon Graduate.
CSCE 3110 Data Structures & Algorithm Analysis Binary Search Trees Reading: Chap. 4 (4.3) Weiss.
CS106X – Programming Abstractions in C++ Cynthia Bailey Lee CS2 in C++ Peer Instruction Materials by Cynthia Bailey Lee is licensed under a Creative Commons.
Abstract Refinement Types Niki Vazou 1, Patrick M. Rondon 2, and Ranjit Jhala 1 1 UC San Diego 2 Google 1.
CS106X – Programming Abstractions in C++ Cynthia Bailey Lee CS2 in C++ Peer Instruction Materials by Cynthia Bailey Lee is licensed under a Creative Commons.
AVL Trees Neil Ghani University of Strathclyde. General Trees Recall a tree is * A leaf storing an integer * A node storing a left subtree, an integer.
Refinement Type Inference via Horn Constraint Optimization Kodai Hashimoto and Hiroshi Unno (University of Tsukuba, Japan)
Binary Search From solving a problem to verifying an answer.
Introduction to Satisfiability Modulo Theories
Extended Static Checking for Java  ESC/Java finds common errors in Java programs: null dereferences, array index bounds errors, type cast errors, race.
1 Balanced Trees There are several ways to define balance Examples: –Force the subtrees of each node to have almost equal heights –Place upper and lower.
Second-Order Functions and Theorems in ACL2 Alessandro Coglio Workshop 2015 Kestrel Institute.
AVL Trees. AVL Node Structure The AVL node structure follows the same structure as the binary search tree, with the addition of a term to store the.
Formal verification of skiplist algorithms Student: Trinh Cong Quy Supervisor: Bengt Jonsson Reviewer: Parosh Abdulla.
Symbolic Execution with Abstract Subsumption Checking Saswat Anand College of Computing, Georgia Institute of Technology Corina Păsăreanu QSS, NASA Ames.
Princeton University COS 423 Theory of Algorithms Spring 2001 Kevin Wayne Average Case Analysis.
1 Lower Bound on Comparison-based Search We have now covered lots of searching methods –Contiguous Data (Arrays) Sequential search Binary Search –Dynamic.
Trees Data Structures and Algorithms (60-254). Recursive Definition of a Tree A tree T is either empty or it consists of a root and zero or more nonempty.
Week 10 - Friday.  What did we talk about last time?  Graph representations  Adjacency matrix  Adjacency lists  Depth first search.
Structuring Data: Arrays ANSI-C. Representing multiple homogenous data Problem: Input: Desired output:
1 Logic Our ability to state invariants, record preconditions and post- conditions, and the ability to reason about a formal model depend on the logic.
CUTE: A Concolic Unit Testing Engine for C Koushik SenDarko MarinovGul Agha University of Illinois Urbana-Champaign.
Dr. Naveed Riaz Design and Analysis of Algorithms 1 1 Formal Methods in Software Engineering Lecture # 26.
Dynamic Dictionaries Primary Operations:  get(key) => search  put(key, element) => insert  remove(key) => delete Additional operations:  ascend()
Dictionaries CS 110: Data Structures and Algorithms First Semester,
1/20 Arrays Changki PSWLAB Arrays Daniel Kroening and Ofer Strichman Decision Procedure.
The Selection Algorithm : Design & Analysis [10].
1 the BSTree class  BSTreeNode has same structure as binary tree nodes  elements stored in a BSTree are a key- value pair  must be a class (or a struct)
Software Verification With Liquid Types Ranjit Jhala, UC San Diego (with Pat Rondon, Ming Kawaguchi)
Duke CPS Faster and faster and … search l Binary search trees ä average case insert/search/delete = O( ) ä worst case = O( ) l balanced search.
Data Structures Red-Black Trees Design and Analysis of Algorithms I.
Liquid Types Pat Rondon, Ming Kawaguchi, Ranjit Jhala University of California, San Diego.
Review: Discrete Mathematics and Its Applications
Learning Invariants using Decision Trees and Implication Counterexamples Pranav Garg Amazon India.
Predicate logic CSC 333.
Satisfiability Modulo Theories
New Ideas Track: Testing MapReduce-Style Programs Christoph Csallner, Leonidas Fegaras, Chengkai Li Computer.
Balanced Binary Search Trees
Review: Discrete Mathematics and Its Applications
Presentation transcript:

Verification and Data Structures int kmp_search(char str[], char pat[]){ p = 0; s = 0; while (p<pat.length && s<str.length){ if (str[s] == pat[p]){s++; p++;} else if (p == 0){s++;} else{p = table[p-1] + 1;} } if (p >= plen) {return (s-plen)}; return (-1); } Need Universally Quantified Invariants 8 i: 0≤ i<table.length ) -1 ≤ table[i] Every element of table exceeds -1 Prove Access Within Array Bounds

Logic Types Precise data invariants Generalization, instantiation hard Coarse data structure invariants Generalization, instantiation easy Good SMT solvers available

Refinement Types Factor Invariant Into Logic x Type 8 i: 0 ≤ i < table.length ) -1 ≤ table[i] Logic Type table :: {v:int|-1 ≤ v} array (Refinement)

How To Retain Precision And Inference

table :: {v:int|-1 ≤ v} array Atoms Liquid Types Set of quantifier-free predicates -1 ≤ v0 < v0 < v v < 20 Refinements are conjunctions of atoms index :: {v:int|-1 ≤ v ∧ v < 20}

OCaml + Asserts Liquid Types Error Dsolve Atoms

Dsolve 1.Liquid Type Inference 2.Results 3.Demo

Liquid Type Inference program ML Type Inference int ! int int ! {v:int| X } x>0 ⊢ {v:int | v=x} <:{v:int |X } int ! {v:int|0 ≤ v} x>0 ∧ v=x ) X Liquid Type Templates Subtyping Implication Constraints Liquid Types

let rec ffor l u f = if l < u then ( f l; ffor (l+1) u f ) Type of f int ! unit Template of f {v:int| X } ! unit Liquid Type of f {v:int|l≤v ∧ v<u} ! unit l Flows Into Input of f {v:int | v=l} <: {v:int |X } l<u ⊢ l<u ∧ v=l ) X Solution X = l≤v ∧ v<u Reduces to

mapreduce (nearest dist ctra) (centroid plus) xs |> List.iter (fun (i,(x,sz)) -> ctra.(i)<- div x sz) Type of mapreduce (’a ! ’b * ’c list) !... ! ’b * ’c list Template of mapreduce (’a ! { X 1 } * ’a * { X 2 } list) !... ! { X 1 } * ’a * { X 2 } list Type Instantiation ’a with ’a ’b with int ’c with ’a * int Template Instantiation ’a with ’a ’b with {v:int| X 1 } ’c with ’a * {v:int| X 2 } Liquid Type of (nearest dist ctra) ’a ! {0≤ v<len ctra} * ’a * {0<v} list <: ’a ! { X 1 } * ’a * { X 2 } list Solution X 1 = 0≤v<len ctra X 2 = 0<v Reduces To 0 ≤ v <len ctra ) X 1 0<v ) X 2 Liquid Type of mapreduce Output {0≤ v<len ctra} * ’a * {0 < v} list

Dsolve 1.Liquid Type Inference 2.Results 3.Demo

Finite Maps 5: ‘cat’ 3: ‘cow’ 8: ‘tic’ 1: ‘doc’ 4: ‘hog’ 7: ‘ant’ 9: ‘emu’ From OCaml Standard Library Implemented as AVL Trees Rotate/Rebalance on Insert/Delete Verified Invariants Binary Search Ordered Height Balanced Keys Implement Set

Binary Decision Diagrams X1X1 X2X2 X2X2 X3X3 X4X4 X4X4 1 X 1  X 2  X 3  X 4 Verified Invariant Variables Ordered Along Each Path

ProgramVerified Invariants List-Based SortingSorted, Outputs Permutation of Input Finite Map (AVL)Balance, BST, Implements a Set Red-Black TreesBalance, BST, Color StablesortSorted Extensible VectorsBalance, Bounds Checking, … Binary HeapsHeap, Returns Min, Implements Set Splay HeapsBST, Returns Min, Implements Set MallocUsed and Free Lists Are Accurate BDDsVariable Order Union FindAcyclicity Bitvector UnificationAcyclicity

Dsolve 1.Liquid Type Inference 2.Results 3.Demo