Synthesis of layout engines from relational constraints

We present an algorithm for synthesizing efficient document layout engines from compact relational specifications. These specifications are compact in that a single specification can produce multiple engines, each for a distinct layout situation, i.e., a different combination of known vs. unknown attributes. Technically, our specifications are relational attribute grammars, while our engines are functional attribute grammars. By synthesizing functions from relational constraints, we obviate the need for constraint solving at runtime, because functional attribute grammars can be easily evaluated according to a fixed schedule, sidestepping the backtracking search performed by constraint solvers. Our experiments show that we can generate layout engines for non-trivial data visualizations, and that our synthesized engines are between 39- and 200-times faster than general-purpose constraint solvers. Relational specifications of layout give rise to synthesis problems that have previously proved intractable. Our algorithm exploits the hierarchical, grammar-based structure of the specification, decomposing the specification into smaller subproblems, which can be tackled with off-the-shelf synthesis procedures. The new synthesis problem then becomes the composition of the functions thus generated into a correct attribute grammar, which might be recursive. We show how to solve this problem by efficient reduction to an SMT problem.

[1]  V. S. Costa,et al.  Theory and Practice of Logic Programming , 2010 .

[2]  Ben Shneiderman,et al.  Tree-maps: a space-filling approach to the visualization of hierarchical information structures , 1991, Proceeding Visualization '91.

[3]  Zohar Manna,et al.  Toward automatic program synthesis , 1971, Symposium on Semantics of Algorithmic Languages.

[4]  Amir Pnueli,et al.  On the synthesis of a reactive module , 1989, POPL '89.

[5]  Michael Sannella Skyblue: a multi-way local propagation constraint solver for user interface construction , 1994, UIST '94.

[6]  Roman Barták,et al.  Constraint Processing , 2009, Encyclopedia of Artificial Intelligence.

[7]  Saumya K. Debray,et al.  Automatic Mode Inference for Logic Programs , 1988, J. Log. Program..

[8]  Wilmot Li,et al.  Review of automatic document formatting , 2009, DocEng '09.

[9]  Krzysztof R. Apt,et al.  Constraint logic programming using Eclipse , 2007 .

[10]  Giorgio Ausiello Directed Hypergraphs: Data Structures and Applications , 1988, CAAP.

[11]  Jan Maluszynski,et al.  Relating Logic Programs and Attribute Grammars , 1985, J. Log. Program..

[12]  Nishant Sinha,et al.  Compiling mockups to flexible UIs , 2013, ESEC/FSE 2013.

[13]  Bradley T. Vander Zanden,et al.  An incremental algorithm for satisfying hierarchies of multiway dataflow constraints , 1996, TOPL.

[14]  Zohar Manna,et al.  A Deductive Approach to Program Synthesis , 1979, TOPL.

[15]  Roland H. C. Yap Book review: Constraint Processing by Rina Dechter, Morgan Kaufmann Publishers, 2003, ISBN 1-55860-890-7 , 2004, Theory Pract. Log. Program..

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

[17]  Leo A. Meyerovich,et al.  Fast and parallel webpage layout , 2010, WWW '10.

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

[19]  John H. Maloney Using constraints for user interface construction , 1992 .

[20]  Rishabh Singh,et al.  Modular Synthesis of Sketches Using Models , 2014, VMCAI.

[21]  Rina Dechter,et al.  Constraint Processing , 1995, Lecture Notes in Computer Science.

[22]  John Wawrzynek,et al.  Chisel: Constructing hardware in a Scala embedded language , 2012, DAC Design Automation Conference 2012.

[23]  Leo A. Meyerovich,et al.  Parallel schedule synthesis for attribute grammars , 2013, PPoPP '13.

[24]  Krzysztof R. Apt,et al.  Principles of constraint programming , 2003 .

[25]  Steven K. Feiner,et al.  A grid-based approach to automating display layout , 1998 .

[26]  Rajeev Alur,et al.  Syntax-guided synthesis , 2013, 2013 Formal Methods in Computer-Aided Design.

[27]  Ruzica Piskac,et al.  Complete functional synthesis , 2010, PLDI '10.

[28]  Donald E. Knuth,et al.  Semantics of context-free languages , 1968, Mathematical systems theory.

[29]  Jeffrey S. Salowe,et al.  Spanning trees in hypergraphs with applications to steiner trees , 1998 .

[30]  Hubert Comon,et al.  Tree automata techniques and applications , 1997 .

[31]  Rastislav Bodík,et al.  Programming by manipulation for layout , 2014, UIST.

[32]  João Saraiva,et al.  Designing and Implementing Combinator Languages , 1998, Advanced Functional Programming.