Programs Synthesis from Refinement Types Nadia Polikarpova joint work with: Ivan Kuraj Armando Solar-Lezama To appear at PLDI’16.

Slides:



Advertisements
Similar presentations
COSC 2007 Data Structures II Chapter 14 External Methods.
Advertisements

Type Variables in ML Until we know the type of a value (perhaps never!), we use a variable for its type Book uses, e.g., t1, tx, tf PL literature uses.
CS 261 – Data Structures AVL Trees. Binary Search Tree: Balance Complexity of BST operations: proportional to the length of the path from the root to.
Binary Search Trees Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 19 (continued) © 2002 Addison Wesley.
Lecture13: Tree III Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
AVL Tree Iris Jiaonghong Shi. AVL tree operations AVL find : – Same as BST find AVL insert : – First BST insert, then check balance and potentially.
Balanced Search Trees. 2-3 Trees Trees Red-Black Trees AVL Trees.
1 AVL Trees. 2 Consider a situation when data elements are inserted in a BST in sorted order: 1, 2, 3, … BST becomes a degenerate tree. Search operation.
Dependently Typed Pattern Matching Hongwei Xi Boston University.
Original Tree:
Facilitating Program Verification with Dependent Types Hongwei Xi Boston University.
Midterm Exam Two Tuesday, November 25 st In class cumulative.
Facilitating Programming Verification with Dependent Types Hongwei Xi University of Cincinnati.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
Insertion in a B+ Tree Insert: 8. Insertion in a B+ Tree 8 Insert: 5.
Red-Black Trees Lecture 10 Nawazish Naveed. Red-Black Trees (Intro) BSTs perform dynamic set operations such as SEARCH, INSERT, DELETE etc in O(h) time.
Maria-Cristina Marinescu Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology A Synthesis Algorithm for Modular Design of.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 15: Linked data structures.
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)
Analysis of Red-Black Tree Because of the rules of the Red-Black tree, its height is at most 2log(N + 1). Meaning that it is a balanced tree Time Analysis:
2-3 Tree. Slide 2 Outline  Balanced Search Trees 2-3 Trees Trees.
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.
Hashing is a method to store data in an array so that sorting, searching, inserting and deleting data is fast. For this every record needs unique key.
Final Exam Tuesday, December 22nd 2:00 - 3:50pm room 102 Warren Weaver Hall.
Data Structure II. Outline Heap Binary Search Tree Hash Table Binary Indexed Tree Segment Tree.
Hashing 1 Hashing. Hashing 2 Hashing … * Again, a (dynamic) set of elements in which we do ‘search’, ‘insert’, and ‘delete’ n Linear ones: lists, stacks,
Polymorphism What is it, why it is needed? Dynamic binding Sorting and searching.
Jim Anderson Comp 750, Fall 2009 Splay Trees - 1 Splay Trees In balanced tree schemes, explicit rules are followed to ensure balance. In splay trees, there.
Recursion on Lists Lecture 5, Programmeringsteknik del A.
CSE 3358 NOTE SET 13 Data Structures and Algorithms.
AVL TREES By Asami Enomoto CS 146 AVL Tree is… named after Adelson-Velskii and Landis the first dynamically balanced trees to be propose Binary search.
Linked list: a list of items (nodes), in which the order of the nodes is determined by the address, called the link, stored in each node C++ Programming:
Haskell Chapter 4. Recursion  Like other languages  Base case  Recursive call  Author programs a number of built-in functions as examples.
1 AVL Trees II Implementation. 2 AVL Tree ADT A binary search tree in which the balance factor of each node is 0, 1, of -1. Basic Operations Construction,
Binary Search Trees CH Gowri Kumar
Data Structures Red-Black Trees Design and Analysis of Algorithms I.
AVL Tree: Balanced Binary Search Tree 9.
SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group AVL Tree Insertion and Deletion Demo.
G64ADS Advanced Data Structures
Top 50 Data Structures Interview Questions
Linked Lists Chapter 6 Section 6.4 – 6.6
PROJECT -1 (4 points) Week before midterm, C++.
AVL Tree Example: Insert 14, 17, 11, 7, 53, 4, 13 into an empty AVL tree
Program to search an element of array using linear search.
Introduction Applications Balance Factor Rotations Deletion Example
Design and Analysis of Algorithms
Binary Search Trees.
(edited by Nadia Al-Ghreimil)
Binary Search Tree AVL Tree
AVL Trees: AVL Trees: Balanced binary search tree
Data Structures and Algorithms
Sorting.
Balanced Binary Search Trees
AVL Search Tree put(9)
Lecture No.20 Data Structures Dr. Sohail Aslam
Binary Trees: Motivation
Given value and sorted array, find index.
(edited by Nadia Al-Ghreimil)
CS 457/557: Functional Languages Folds
AVL Tree By Rajanikanth B.
Final Review Dr. Yingwu Zhu.
By Yogesh Neopaney Assistant Professor Department of Computer Science
AVL Tree Chapter 6 (cont’).
Hashing.
AVL Trees (Adelson – Velskii – Landis)
list data list 만들기 list 사용하기 nil : list link :  * list -> list
AVL Tree Example: Insert 14, 17, 11, 7, 53, 4, 13 into an empty AVL tree
Topic 10 Trees.
Self-Balancing Search Trees
AVL Trees: AVL Trees: Balanced binary search tree
Presentation transcript:

Programs Synthesis from Refinement Types Nadia Polikarpova joint work with: Ivan Kuraj Armando Solar-Lezama To appear at PLDI’16

Program Synthesis 2 “Make a list with n copies of x” replicate n x = if n ≤ 0 then Nil else Cons x (replicate (dec n) x) declarative specification executable program 2 50 ⊨ ? Synthesizer

Modular Verification for Synthesis 3

“Make a list with n copies of x” Specifications for synthesis 4 refinement type replicate n x = if n ≤ 0 then Nil else Cons x (replicate (dec n) x) Synthesizer

Example: replicate data List α where Nil :: List α Cons :: x: α → xs: List α → List α measure len :: List α -> Int where... zero :: {ν: Int | ν = 0} inc :: x: Int → {ν: Int | ν = x + 1} dec :: x: Int → {ν: Int | ν = x - 1} replicate :: n: Nat → x: α → {ν: List α | len ν = n} replicate = ?? 5 Demo

Type-driven Synthesis 6 Γ ⊢ ?? :: T x 1 :: T 1 ;... ?? :: U ?? :: V I. top-down enumerative search II. round-trip type checking

Specification decomposition 7 Nil ; 0 ; 5 ; -5 zeros replicate ; Cons ⊢ ?? :: {List Neg | len ν ≥ 5} Nil :: {List Neg |len ν = 0} Nil :: {List a | len ν = 0} zeros :: n:Nat → {List Zero | len ν = n} Γ ?? :: _ → List Neg

0 :: { ν = 0 } 5 :: { ν = 5 } Nil ; 0 ; 5 ; -5 zeros replicate Cons Specification decomposition 8 ⊢ ?? :: {List Neg | len ν ≥ 5} replicate :: n: Nat → x: Neg → {List Neg | len ν = n} ?? :: Nat?? :: Neg 0 :: { ν = 0 } 5 :: { ν = 5 } :: {List Neg | len ν = 0} :: {List Neg | len ν = 5} -5 :: { ν = -5 } replicate :: n: Nat → x: a → {List a | len ν = n} ?? :: _ → _ → List Neg

Evaluation 9 take, drop, delete, zip with, reverse, de-duplicate, fold, length/append with fold,... Lists insertion s., selection s., merge s., quick s. Sorting member, insert, delete Binary Search Trees RBT & AVL insertion, AVL deletion Balanced trees AST desugaring, address book Custom datatypes 20 s 6 s 64 benchmarks > 120 s No roundtrip type checking