1 / 12

Introduction to Sketching

Learn about sketching for program synthesis with special inputs, bounded candidate spaces, and control inputs. Discover how to constrain control sets, validate constraints, and use Counterexample-Guided Inductive Synthesis. Explore techniques, constraints, and solvers for effective program synthesis.

cassandrac
Download Presentation

Introduction to Sketching

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Sketching IAP 2008 Armando Solar-Lezama

  2. Experience with homework

  3. Step 1: Turn holes into special inputs • The ?? Operator is modeled as a special input • we call them control inputs • Bounded candidate spaces are important • bounded unrolling of repeat is important • bounded inlining of generators is important bit[W] isolSk(bit[W] x) { return ~(x + ??) & (x + ??); } bit[W] isolSk(bit[W] x, bit[W]c1, c2) { return ~(x + c1) & (x + c2); }

  4. Step 2: Constraining the set of controls • Correct control • causes the spec & sketch to match for all inputs • causes all assertions to be satisfied for all inputs • Constraints are collected into a predicate • -showDAG will show you the constraints! Q(in, c)

  5. & >> & + + >> & + >> mux mux mux & & x int popSketched (bit[W] x) implements pop { loop (??) { x = (x & ??) + ((x >> ??) & ??); } return x; } & x x S(x,c) = x

  6. 0 0 0 0 0 0 0 1 + mux + mux + mux + mux Ex : Population count. x count one int pop (bit[W] x) { int count = 0; for (int i = 0; i < W; i++) { if (x[i]) count++; } return count; } count count Q(in, c) = S(x,c)==F(x) count F(x) = count

  7. Q(x, c) E A c. x. A Sketch as a constraint system Synthesis reduces to constraint satisfaction Constraints are too hard for standard techniques • Universal quantification over inputs • Too many inputs • Too many constraints • Too many holes

  8. Insight Sketches are not arbitrary constraint systems • They express the high level structure of a program A small set of inputs can fully constrain the soln • focus on corner cases This is an inductive synthesis problem ! • but how do we find the set E? • and how do we solve the inductive synthesis problem? A E c. x in E. Q(x, c) where E = {x1, x2, …, xk}

  9. E A c. x in E. Q(x,c) • Validation Your verifier goes here Step 3:Counterexample Guided Inductive Synthesis Idea: Couple Inductive synthesizer with a verifier • Verifier is charged with detecting convergence candidate implementation succeed • Inductive Synthesizer fail • Derive candidate implementation from concrete inputs. ok buggy fail add counterexample input observation set E • Standard implementation uses Sat based bounded verifier • Any verifier/checker that produces counterexamples works

  10. E A c. x in E. Q(x, c) where E = {x1, x2, …, xk} Inductive Synthesis Deriving a candidate from a set of observations Encode c as a bit-vector • natural encoding given the integer holes Encode Q(xi, c) as boolean constraints on the bit-vector Solve constraints using SAT solver • with lots of preprocessing in between

  11. Controlling the SAT Solver • Several options for the SAT Solver • --synth and --verif • ABC vs MINI (MiniSat) • --cbits and --inbits • --incremental

  12. Using synthesizer feedback • Results of different phases useful for debugging • counterexample inputs • number of iterations • Some useful flags • --keeptmpfiles • --showInputs • --fakesolver • -checkpoint and -restore

More Related