Presentation is loading. Please wait.

Presentation is loading. Please wait.

Storyboard Programming Rishabh Singh and Armando Solar-Lezama.

Similar presentations


Presentation on theme: "Storyboard Programming Rishabh Singh and Armando Solar-Lezama."— Presentation transcript:

1 Storyboard Programming Rishabh Singh and Armando Solar-Lezama

2 Storyboard Programming © Nassos Vakalis

3 Storyboard Programming frontbackab head x backbxfronta head x x backb head x frontbackab head x fronta head x x void insert(List l, Node x){ Node head = l.head; Node cur, prev;... while(...){... }... } void insert(List l, Node x){ Node head = l.head; Node cur = head, prev = null; while(cur != null && cur.val < x){ prev = cur; cur = cur.next; } if(head == null) head = x; if(prev != null) prev.next = x; x.next = cur; } head x x frontbackab head x frontbackab head x fronta head x fronta head x backbx b head x

4 How do we make this real ◦Give semantic meaning to the storyboard - storyboard is the link between synthesizer and user - storyboard is a specification - storyboard focuses on what is important ◦Algorithm must exploit storyboard insight - turn the insights of the storyboard into an abstract domain - synthesis algorithm must be able to exploit abstraction ◦Expand expressiveness and scalability - some problems are too hard to solve in one shot even with abstraction - how do we express inductive insight?

5 Anatomy of a Storyboard frontbackabx frontbackab head x Environment Env{ Node head, prev, curr; [Node] a, b, x; [[Node]] front, back ; front.next = { front, a}; back.next = {back, null}; } head

6 Anatomy of a Storyboard frontbackabx frontbackab head x Scenario Start { head = front; a.next = b; b.next = back; } End{ head = front; a.next = x; x.next = b; b.next = back; }

7 Storyboard  Abstract Domain frontbackab x Environment Env{ Node head, prev, curr; [Node] a, b, x; [[Node]] front, back ; front.next = { front, a}; back.next = {back, null}; } struct Node{ Node next; int value; assert next != null => value < next.value; } head prev cur

8 Storyboard  Abstract Domain frontbackab x head prev cur head = {, } a.next = {,, } b.next = {, } x.next = {, } cur = { } prev = { } front backa b b x bxfront backabxfront null

9 Verifying with Abstract Interpretation ◦Standard program analysis technique ◦Our synthesis algorithm will be based on it

10 Transition Function f2f2 prev = cur; cur = cur.next; Given a state Produces a set of states frontbackab cur, head x prev frontbackab cur prev head x frontbackab prev head x cur

11 Transition Function f2f2 prev = cur; cur = cur.next; Given a set of states Produces a new set of states frontbackab cur, head x prev frontbackab prev head x cur frontbackab cur prev head x frontbackab cur, head x prev frontbackab cur prev head x frontbackab prev head x cur frontbackab head x prev cur

12 frontbackab head x prev cur frontbackab cur prev head x frontbackab cur, head x prev Verification by Abstract Interpretation cur = head; prev = nullcur != null & cur.val < x prev = cur; cur = cur.next; frontbackab head x frontbackab head x frontbackab cur, head x prev frontbackab cur prev head x frontbackab prev head x cur frontbackab prev head x cur frontbackab head x prev cur t in t1t1 t3t3 t2t2 t out f1f1 f2f2 f3f3 fpfp true false if(head == null) head = x; if(prev != null) prev.next = x; x.next = cur;

13 Verification by Abstract Interpretation t in t1t1 t3t3 t2t2 t out f1f1 f2f2 f3f3 fpfp true false Sets of states - If the formula is satisfiable, it means the program is correct.

14 From Verification to Synthesis ◦What if the code itself is unknown?

15 frontbackab head x prev cur frontbackab cur prev head x frontbackab cur, head x prev From Verification to Synthesis ?? frontbackab head x frontbackab head x frontbackab cur, head x prev frontbackab cur prev head x frontbackab prev head x cur frontbackab prev head x cur frontbackab head x prev cur t in t1t1 t3t3 t2t2 t out f1f1 f2f2 f3f3 fpfp true false ??

16 From Verification to Synthesis ?? t in t1t1 t3t3 t2t2 t out f1f1 f2f2 f3f3 fpfp true false ?? cur prev head cur.next prev.next head.next cur prev head cur.next prev.next head.next = Assignments in each block are of this form

17 From Verification to Synthesis ?? t in t1t1 t3t3 t2t2 t out f1f1 f2f2 f3f3 fpfp true false ?? switch(c1){ case 0: t = cur; case 1: t = prev; case 2: t = head; } t = if(c2) t; else t.next; switch(c3){ case 0: cur = t; case 1: prev = t; case 2: head = t; case 3: cur.next = t; case 4: prev.next = t; case 5: head.next = t; } Set of possible assignments can be represented with a parameterized block of code

18 Synthesis with Abstract Interpretation ◦Basic Satisfiability Query - just find a C that satisfies the equation and you are done - in principle should be easy to do with a SAT solver - scalability is an issue t in t1t1 t3t3 t2t2 t out f1f1 f2f2 f3f3 fpfp true false

19 Challenge ◦Set of abstract states can get really big - synthesis in “one shot” no longer an option Inductive Synthesizer buggy candidate implementation counterexample input succeed fail observation set E ok Automated Validation Your verifier/checker goes here Derive candidate implementation from concrete inputs. Counterexample Guided Inductive Synthesis Validation is now abstract interpretation

20 CEGIS with Abstract Interpretation ◦Start with a random (and probably wrong) solution ◦Do Abstract Interpretation to discover problem. ◦Extract a trace that illustrates the problem. ◦Derive constraints from the trace ◦Solve constraints to get a new solution ◦Verify the new solution and repeat the process if it turns out to be incorrect.

21 Incorporating Inductive Insight ay h zab c z h ab c z h c ab c z p h c ab c z p c h ab h zab c p c h z d ab c p c z d h ab c z h c p ab c p c z d h ac c p d z e h ac c p d z e h ac c p d z e h … list reverseSK(list lst){ node cur=null, prev=null; while(null!=lst.head){ cur = lst.head; lst.head = cur.next; cur.next = prev; prev = cur; } lst.head = cur; return lst; } Example: Reversing a Linked List In order to reason about this program, we need to know that can be expanded into jk j Once we make this knowledge part of the storyboard, the rest of the process works just like before


Download ppt "Storyboard Programming Rishabh Singh and Armando Solar-Lezama."

Similar presentations


Ads by Google