1 / 15

Synthesis with the Sketch System

Synthesis with the Sketch System. Day 2. Armando Solar- Lezama. The challenge of synthesis. For functions, the environment controls the inputs i.e. whatever we synthesize must work for all inputs Modeled with a doubly quantified constraint What does it mean to quantify over programs?.

abram
Download Presentation

Synthesis with the Sketch System

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. Synthesis with the Sketch System Day 2 Armando Solar-Lezama

  2. The challenge of synthesis • For functions, the environment controls the inputs • i.e. whatever we synthesize must work for all inputs • Modeled with a doubly quantified constraint • What does it mean to quantify over programs?

  3. Quantifying over programs • Synthesis as curve fitting • we want a function that satisfies some properties • It’s hard to do curve fitting with arbitrary curves • Instead, people use parameterized families of curves • Quantify over parameters instead of over functions • A sketch is just a way of describing these families

  4. Insight where E = {x1, x2, …, xk} Sketches are not arbitrary constraint systems • They express the high level structure of a program A small number of inputs can be enough • focus on corner cases This is an inductive synthesis problem !

  5. CEGIS Synthesize Check Insert your favorite checker here

  6. CEGIS • Constraints for each follow from semantics • Loops handled through simple unrolling Synthesize Check Insert your favorite checker here

  7. CEGIS in Detail a b c d + + + + + + + + + + + + A A A A Synthesize Check

  8. CEGIS in Detail a b c d + + + + + + + + + + + + A A A A Synthesize Check Bits 5 4 3 2

  9. Generators

  10. User defined generators • Mechanism to define sets of code fragments • They look like functions • But with a few caveats

  11. Key features of generators • Different dynamic invocations •  different code • Recursive generators = grammar of expressions generator bit[W] gen(bit[W] x, intbnd){ assertbnd > 0; if(??) return x; if(??) return ??; if(??) return ~gen(x, bnd-1); if(??){ return {| gen(x, bnd-1) (+ | & | ^) gen(x, bnd-1) |}; } } bit[W] isolate0sk (bit[W] x) implementsisolate0 { returngen(x, 3); }

  12. Gens + Closures = Extensible Language • Redefining Repeat bit[W] reverseSketch(bit[W] in) implementsreverse { bit[W] t = in; ints = 1; repeat(??){ bit[W] tmp1 = (t << s); bit[W] tmp2 = (t >> s); t = tmp1 {|} tmp2; s = s*??; } returnt; }

  13. Gens + Closures = Extensible Language generator voidrep(intn, funf){ if(n>0){ f(); rep(n-1, f); } } • Redefining Repeat bit[W] reverseSketch(bit[W] in) implementsreverse { bit[W] t = in; ints = 1; generatorvoidtmp(){ bit[W] tmp1 = (t << s); bit[W] tmp2 = (t >> s); t = tmp1 {|} tmp2; s = s*??; } rep(??, tmp); returnt; }

  14. Karatsuba Multiplication • Recursive grade-school multiplication

  15. Karatsuba Multiplication • Smarter Karatsuba Multiplication

More Related