Resource-guided program synthesis

This article presents resource-guided synthesis, a technique for synthesizing recursive programs that satisfy both a functional specification and a symbolic resource bound. The technique is type-directed and rests upon a novel type system that combines polymorphic refinement types with potential annotations of automatic amortized resource analysis. The type system enables efficient constraint-based type checking and can express precise refinement-based resource bounds. The proof of type soundness shows that synthesized programs are correct by construction. By tightly integrating program exploration and type checking, the synthesizer can leverage the user-provided resource bound to guide the search, eagerly rejecting incomplete programs that consume too many resources. An implementation in the resource-guided synthesizer ReSyn is used to evaluate the technique on a range of recursive data structure manipulations. The experiments show that ReSyn synthesizes programs that are asymptotically more efficient than those generated by a resource-agnostic synthesizer. Moreover, synthesis with ReSyn is faster than a naive combination of synthesis and resource analysis. ReSyn is also able to generate implementations that have a constant resource consumption for fixed input sizes, which can be used to mitigate side-channel attacks.

[1]  Armando Solar-Lezama,et al.  Natural synthesis of provably-correct data-structure manipulations , 2017, Proc. ACM Program. Lang..

[2]  Kenneth Knowles,et al.  Compositional reasoning and decidable checking for dependent contract types , 2009, PLPV '09.

[3]  Ranjit Jhala,et al.  Type-based data structure verification , 2009, PLDI '09.

[4]  Armando Solar-Lezama,et al.  Synthesis of Domain Specific CNF Encoders for Bit-Vector Solvers , 2016, SAT.

[5]  Elvira Albert,et al.  Automatic Inference of Resource Consumption Bounds , 2012, LPAR.

[6]  Ranjit Jhala,et al.  Abstract Refinement Types , 2013, ESOP.

[7]  Sumit Gulwani,et al.  Spreadsheet data manipulation using examples , 2012, CACM.

[8]  Jürgen Giesl,et al.  Alternating Runtime and Size Complexity Analysis of Integer Programs , 2014, TACAS.

[9]  Alexander Aiken,et al.  Conditionally correct superoptimization , 2015, OOPSLA.

[10]  Patrick Maxim Rondon,et al.  Liquid types , 2008, PLDI '08.

[11]  Sanjit A. Seshia,et al.  Combinatorial sketching for finite programs , 2006, ASPLOS XII.

[12]  Gilles Barthe,et al.  Monadic refinements for relational cost analysis , 2017, Proc. ACM Program. Lang..

[13]  Sumit Gulwani,et al.  Bound Analysis of Imperative Programs with the Size-Change Abstraction , 2011, SAS.

[14]  Nikolaj Bjørner,et al.  Horn Clause Solvers for Program Verification , 2015, Fields of Logic and Computation II.

[15]  Matt Fredrikson,et al.  J an 2 01 8 Verifying and Synthesizing Constant-Resource Implementations with Types , 2018 .

[16]  Steffen Jost,et al.  Automatic amortised analysis of dynamic memory allocation for lazy functional programs , 2012, ICFP.

[17]  Isil Dillig,et al.  Symbolic reasoning for automatic signal placement , 2018, PLDI.

[18]  R. Tarjan Amortized Computational Complexity , 1985 .

[19]  Benjamin C. Pierce,et al.  Advanced Topics In Types And Programming Languages , 2004 .

[20]  Aws Albarghouthi,et al.  MapReduce program synthesis , 2016, PLDI.

[21]  Isil Dillig,et al.  Program synthesis using conflict-driven learning , 2017, PLDI.

[22]  Isil Dillig,et al.  Program synthesis using abstraction refinement , 2017, Proc. ACM Program. Lang..

[23]  Pedro B. Vasconcelos Space cost analysis using sized types , 2008 .

[24]  T. Henzinger,et al.  Quantitative Synthesis for Concurrent Programs , 2011, CAV.

[25]  Isil Dillig,et al.  Component-based synthesis for complex APIs , 2017, POPL.

[26]  Marco Gaboardi,et al.  Relational cost analysis , 2017, POPL.

[27]  Michael D. Ernst,et al.  Generalized Data Structure Synthesis , 2018, 2018 IEEE/ACM 40th International Conference on Software Engineering (ICSE).

[28]  Alexander Aiken,et al.  Stochastic superoptimization , 2012, ASPLOS '13.

[29]  Martin Hofmann,et al.  Resource Aware ML , 2012, CAV.

[30]  Sumit Gulwani,et al.  From program verification to program synthesis , 2010, POPL '10.

[31]  Alvin Cheung,et al.  Optimizing database-backed applications with query synthesis , 2013, PLDI.

[32]  Thomas A. Henzinger,et al.  ABC: Algebraic Bound Computation for Loops , 2010, LPAR.

[33]  Isil Dillig,et al.  Synthesizing data structure transformations from input-output examples , 2015, PLDI.

[34]  Isil Dillig,et al.  Component-based synthesis of table consolidation and transformation tasks from examples , 2016, PLDI.

[35]  Andre Scedrov,et al.  Bounded Linear Logic: A Modular Approach to Polynomial-Time Computability , 1992, Theor. Comput. Sci..

[36]  Emina Torlak,et al.  A lightweight symbolic virtual machine for solver-aided host languages , 2014, PLDI.

[37]  Paul Feautrier,et al.  Multi-dimensional Rankings, Program Termination, and Complexity Bounds of Flowchart Programs , 2010, SAS.

[38]  Elvira Albert,et al.  Cost analysis of object-oriented bytecode programs , 2012, Theor. Comput. Sci..

[39]  Martin Hofmann,et al.  Static determination of quantitative resource usage for higher-order programs , 2010, POPL '10.

[40]  Nikolaj Bjørner,et al.  Z3: An Efficient SMT Solver , 2008, TACAS.

[41]  Sumit Gulwani,et al.  Synthesis of loop-free programs , 2011, PLDI '11.

[42]  Armando Solar-Lezama,et al.  Program sketching , 2012, International Journal on Software Tools for Technology Transfer.

[43]  Peng Wang,et al.  TiML: a functional language for practical complexity analysis with invariants , 2017, Proc. ACM Program. Lang..

[44]  Pavol Cerný,et al.  Segment Abstraction for Worst-Case Execution Time Analysis , 2015, ESOP.

[45]  Alvin Cheung,et al.  Synthesizing highly expressive SQL queries from input-output examples , 2017, PLDI.

[46]  Sumit Gulwani,et al.  SPEED: precise and efficient static estimation of program computational complexity , 2009, POPL '09.

[47]  Nick Benton,et al.  Integrating Linear and Dependent Types , 2015, POPL.

[48]  Armando Solar-Lezama,et al.  Synthesis of Recursive ADT Transformations from Reusable Templates , 2015, TACAS.

[49]  Rastislav Bodík,et al.  Chlorophyll : Synthesis-Aided Compiler for Low-Power Spatial Architectures by Phitchaya Mangpo Phothilimthana , 2015 .

[50]  Emina Torlak,et al.  Optimizing synthesis with metasketches , 2016, POPL.

[51]  Armando Solar-Lezama,et al.  Program synthesis from polymorphic refinement types , 2015, PLDI.

[52]  Daniel R. Licata,et al.  Denotational cost semantics for functional languages with inductive types , 2015, ICFP.

[53]  Amr Sabry,et al.  Reasoning about programs in continuation-passing style , 1992, LFP '92.

[54]  Dinakar Dhurjati,et al.  Scaling up Superoptimization , 2016, ASPLOS.

[55]  Ugo Dal Lago,et al.  Linear Dependent Types and Relative Completeness , 2011, 2011 IEEE 26th Annual Symposium on Logic in Computer Science.

[56]  Thomas A. Henzinger,et al.  Succinct Representation of Concurrent Trace Sets , 2015, POPL.

[57]  Martin Hofmann,et al.  Multivariate amortized resource analysis , 2012, TOPL.

[58]  Sumit Gulwani,et al.  The reachability-bound problem , 2010, PLDI '10.

[59]  NAVID YAGHMAZADEH,et al.  SQLizer: query synthesis from natural language , 2017, Proc. ACM Program. Lang..

[60]  Martin Hofmann,et al.  Static prediction of heap space usage for first-order functional programs , 2003, POPL '03.

[61]  Ugo Dal Lago,et al.  Analysing the complexity of functional programs: higher-order meets first-order , 2015, ICFP.

[62]  Krishnendu Chatterjee,et al.  Better Quality in Synthesis through Quantitative Objectives , 2009, CAV.

[63]  Elvira Albert,et al.  Closed-Form Upper Bounds in Static Cost Analysis , 2011, Journal of Automated Reasoning.

[64]  Michael D. Ernst,et al.  Fast synthesis of fast collections , 2016, PLDI.

[65]  Ankush Das,et al.  Towards automatic resource bound analysis for OCaml , 2016, POPL.

[66]  Viktor Kuncak,et al.  Synthesis modulo recursive functions , 2013, OOPSLA.

[67]  Robert Harper,et al.  Practical Foundations for Programming Languages , 2012 .

[68]  Leonid Ryzhyk,et al.  From Non-preemptive to Preemptive Scheduling Using Synchronization Synthesis , 2015, CAV.