
Liquid Type Inference for Verification and Data Structures
Learn about Liquid Type Inference used in verification and data structures, as discussed in the research paper by Ming Kawaguchi, Patrick Rondon, and Ranjit Jhala from UC San Diego. Explore the concepts of precise data invariants, SMT solvers, and how to retain precision in inference.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Dsolve Verification via Liquid Type Inference Ming Kawaguchi, Patrick Rondon, Ranjit Jhala UC San Diego
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;} } Need Universally Quantified Invariants Verification and Data Structures if (p >= plen) {return (s-plen)}; return (-1); } Every element of table exceeds -1 8 8i:0 i<table.length) Prove Access Within Array Bounds )-1 table[i]
Logic Precise data invariants Good SMT solvers available Generalization, instantiation hard Types Coarse data structure invariants Generalization, instantiation easy
Refinement Types Factor Invariant Into Logic x Type 8 8i:0 i<table.length) Logic (Refinement) )-1 table[i] Type table::{v:int|-1 v}array table::{v:int|-1 v}array
How To Retain Precision And Inference
Liquid Types Refinements are conjunctions of atoms table::{v:int|-1 v}array index ::{v:int|-1 v v<20} Atoms Set of quantifier-free predicates v<20 -1 v 0<v
OCaml + Asserts Liquid Types Dsolve Atoms Error
Dsolve 1. Liquid Type Inference 2. Results 3. Demo
Liquid Type Inference program int! !int ML Type Inference ! {v:int|X} int! Liquid Type Templates Subtyping x>0 {v:int|v=x}<:{v:int|X} x>0 v=x) ) X Implication Constraints int! !{v:int|0 v} Liquid Types
Template of f {v:int|X}! Type of f int! Solution X= l v v<u let rec ffor l u f = if l < u then ( f l; ffor (l+1) u f ) !unit !unit lFlows Into Input of f {v:int|v=l}<:{v:int|X} l<u Liquid Type of f {v:int|l v v<u}! l<u v=l) !unit Reduces to ) X
mapreduce (nearest dist ctra) (centroid plus) xs |> List.iter(fun (i,(x,sz))->ctra.(i)<-divxsz) Type of mapreduce ! b* c list)! Type Instantiation a with a b withint c with a*int c with a*{v:int|X2} Liquid Type of mapreduceOutput {0 v<lenctra}* a*{0<v}list Template of mapreduce ! {X1}* a*{X2}list)! Reduces To 0 v<lenctra ) 0<v ) !{X1}* a*{X2}list ( a! ( a! Liquid Type of (nearest dist ctra) a! <: a! ! b* clist !...! !...! Template Instantiation a with a b with{v:int|X1} ! {X1}* a*{X2}list Solution ) X1 ) X2 a! ! {0 v<lenctra}* a*{0<v}list ! {0 v<lenctra}* a*{0<v}list X1= 0 v<lenctra X2= 0<v
Dsolve 1. Liquid Type Inference 2. Results 3. Demo
Finite Maps 5: cat 3: cow 8: tic From OCaml Standard Library Verified Invariants Binary Search Ordered Height Balanced Keys Implement Set 1: doc 4: hog 7: ant 9: emu Implemented as AVL Trees Rotate/Rebalance on Insert/Delete
Binary Decision Diagrams X1 X2 X2 X3 X4 X4 1 Verified Invariant Variables Ordered Along Each Path X1 X2 X3 X4
Program Verified Invariants List-Based Sorting Sorted, Outputs Permutation of Input Finite Map (AVL) Balance, BST, Implements a Set Red-Black Trees Balance, BST, Color Stablesort Sorted Extensible Vectors Balance, Bounds Checking, Binary Heaps Heap, Returns Min, Implements Set Splay Heaps BST, Returns Min, Implements Set Malloc Used and Free Lists Are Accurate BDDs Variable Order Union Find Acyclicity Bitvector Unification Acyclicity
Dsolve 1. Liquid Type Inference 2. Results 3. Demo http://pho.ucsd.edu/liquid/demo/