Synthesis with the Sketch System

Slides:



Advertisements
Similar presentations
_Synthesis__________________ __Of_______________________ ___First-Order_____Dynamic___ _____________Programming___ _______________Algorithms___ Yewen (Evan)
Advertisements

Linked Lists Chapter 4.
CS 367 – Introduction to Data Structures
LIST PROCESSING.
Data Structure Lecture-5
Linked Lists. 2 Merge Sorted Lists Write an algorithm that merges two sorted linked lists The function should return a pointer to a single combined list.
The Sketching Approach to Program Synthesis
Linked Lists. Example We would like to keep a list of inventory records – but only as many as we need An array is a fixed size Instead – use a linked.
Circular Linked List. COMP104 Circular Linked List / Slide 2 Circular Linked Lists * A Circular Linked List is a special type of Linked List * It supports.
Doubly Linked List. COMP104 Doubly Linked Lists / Slide 2 Doubly Linked Lists * In a Doubly Linked List each item points to both its predecessor and successor.
Variations on Linked Lists Ellen Walker CPSC 201 Data Structures Hiram College.
Doubly Linked Lists Representation Space Analysis Creation and Insertion Traversal Deletion.
Data Structures & Algorithms
Abstract Data Type Example l One more example of ADT: l integer linked list using class l A class with dynamic objects: l Copy constructor l Destructor.
Linked Lists. Example We would like to keep a list of inventory records – but only as many as we need An array is a fixed size Instead – use a linked.
© 2004 Goodrich, Tamassia Linked Lists1. © 2004 Goodrich, Tamassia Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data.
Linked Lists. COMP104 Lecture 33 / Slide 2 Linked Lists: Basic Idea * Data may be stored consecutively in a linked list. * Each element of the linked.
COMP104 Linked List Algorithms / Slide 1 Some Simple Algorithms on Linked Lists * Write a function that returns the length of a given list. * Write a boolean.
Josephus Problem: Build the Circular Linked List
CMSC 341 Lists 3. 2 Doubly-Linked Lists Option: add pointer to previous node Issues –doubles number of pointers –allows immediate (O(1)) access to previous.
Generative Programming Meets Constraint Based Synthesis Armando Solar-Lezama.
Synthesis with the Sketch System D AY 1 Armando Solar-Lezama.
Linked Lists Ellen Walker CPSC 201 Data Structures Hiram College.
Storyboard Programming Rishabh Singh and Armando Solar-Lezama.
Synthesis with the Sketch System D AY 2 Armando Solar-Lezama.
Chapter 5 Linked Lists II
CS 201 Data Structures and Algorithms Chapter 3: Lists, Stacks, and Queues - I Text: Read Weiss, §3.1 – 3.5 1Izmir University of Economics.
LINKED LIST’S EXAMPLES Salim Malakouti. Linked List? 523 Pointer Node ValuePointer.
CSC 205 Programming II Lecture 15 Linked List – Other Variations.
Recursion COMP x1 Sedgewick Chapter 5. Recursive Functions problems can sometimes be expressed in terms of a simpler instance of the same problem.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
1 CMPT 117 Linked Lists (singly linked). 2 Problems with arrays  When an element is deleted from or inserted into an array, the rest of the array has.
CSC 143 P 1 CSC 143 Recursion [Chapter 5]. CSC 143 P 2 Recursion  A recursive definition is one which is defined in terms of itself  Example:  Compound.
Recursive. Recursive F(n) = F(n-1) + F(n-2) n! = (n-1)! x n C(m,n) = C(m-1,n-1)+C(m-1,n)......
Recursion.
Unit 3 Linked Lists King Fahd University of Petroleum & Minerals
Abstract Data Type 1.
Singly Linked Lists.
Introduction to Sketching
Data Structure and Algorithms
Linked List.
Data Structures and Algorithms
New applications of program synthesis
Activity Write the code fragment to reverse a singly linked list
Week 15 – Monday CS221.
Introduction to Sketching
Linked list insertion Head. Linked list insertion Head.
Chapter 4 Linked Lists
LinkedList Class.
Lecture 7 Constraint-based Search
Linked Lists Chapter 4.
Linked Lists.
Summary on linked lists
Making synthesis practical Are we there yet?
Data Structures ADT List
Data Structures ADT List
ADT list.
Data Structures and Algorithms
CMSC 341 Lists 3.
CMSC 341 Lists 3.
Stacks with Dynamic Memory
Data Structures ADT List
Linked Lists Adapted from Dr. Mary Eberlein, UT Austin.
프로그래밍2 및 실습 Sort Code 전명중.
Jeff West - Quiz Section 16
Activity Write the code fragment to reverse a singly linked list
General List.
Recursive Linked Lists
CS148 Introduction to Programming II
Linked Lists.
Presentation transcript:

Synthesis with the Sketch System Day 3 Over the last few days, we have seen several different applications of synthesis for what could collectively be called Quality Control Armando Solar-Lezama

In place list reversal

Problem statement Given a list like this: Produce a list like this: head . . . head . . .

Constraints Your algorithm must be O(n) Your algorithm must use a constant space It can not use arrays or recursion

The Spec harness void main(int n){ if(n >= MAXN){ n = MAXN-1; } node[n] nodes = null; list l = newList(); popList(n, l, nodes); reverseSK(l); check(n, l, nodes); }

The Spec void popList(int n, list l, ref node[n] nodes){ node tail= null; for(int i=0; i<n;++i){ node t = newNode(); if(i>0){ tail.next = t; }else{ l.head = t; } tail = t; nodes[i] = t;

The Spec void check(int n, list l, node[n] nodes){ node cur = l.head; int i=0; while(cur != null){ assert cur == nodes[n-1-i]; cur = cur.next; i = i+1; } assert i == n; if(n > 0){ assert l.head == nodes[n-1]; }else{ assert l.head == null;

The Sketch {| (tmp1 | tmp2 | l.head)(.next)? |} void reverseSK(ref list l){ node tmp1 = null; node tmp2 = null; while( ){ } {| (tmp1 | tmp2 | l.head)(.next)? |}