Synthesizing quotient lenses

Quotient lenses are bidirectional transformations whose correctness laws are “loosened” by specified equivalence relations, allowing inessential details in concrete data formats to be suppressed. For example, a programmer could use a quotient lens to define a transformation that ignores the order of fields in XML data, so that two XML files with the same fields but in different orders would be considered the same, allowing a single, simple program to handle them both. Building on a recently published algorithm for synthesizing plain bijective lenses from high-level specifications, we show how to synthesize bijective quotient lenses in three steps. First, we introduce quotient regular expressions (QREs), annotated regular expressions that conveniently mark inessential aspects of string data formats; each QRE specifies, simulteneously, a regular language and an equivalence relation on it. Second, we introduce QRE lenses, i.e., lenses mapping between QREs. Our key technical result is a proof that every QRE lens can be transformed into a functionally equivalent lens that canonizes source and target data just at the “edges” and that uses a bijective lens to map between the respective canonical elements; no internal canonization occurs in a lens in this normal form. Third, we leverage this normalization theorem to synthesize QRE lenses from a pair of QREs and example input-output pairs, reusing earlier work on synthesizing plain bijective lenses. We have implemented QREs and QRE lens synthesis as an extension to the bidirectional programming language Boomerang. We evaluate the effectiveness of our approach by synthesizing QRE lenses between various real-world data formats in the Optician benchmark suite.

[1]  Nuno Macedo,et al.  A relational approach to bidirectional transformation , 2014 .

[2]  Martin Gogolla,et al.  Testing models and model transformations using classifying terms , 2016, Software & Systems Modeling.

[3]  Shou-Feng Wang,et al.  𝒫𝒮-regular languages , 2011, Int. J. Comput. Math..

[4]  Benjamin C. Pierce,et al.  Combinators for bi-directional tree transformations: a linguistic approach to the view update problem , 2005, POPL '05.

[5]  Shin-Cheng Mu,et al.  An Algebraic Approach to Bi-directional Updating , 2004, APLAS.

[6]  Meng Wang,et al.  FliPpr: A Prettier Invertible Printing System , 2013, ESOP.

[7]  James Cheney,et al.  Lenses for Web Data , 2013, Electron. Commun. Eur. Assoc. Softw. Sci. Technol..

[8]  Philip Wadler,et al.  The Essence of Form Abstraction , 2008, APLAS.

[9]  Martin Hofmann,et al.  Symmetric lenses , 2011, POPL '11.

[10]  Benjamin C. Pierce,et al.  Boomerang: resourceful lenses for string data , 2008, POPL '08.

[11]  James Cheney,et al.  FLUX: functional updates for XML , 2008, ICFP.

[12]  Shin-Cheng Mu,et al.  Bidirectionalizing Tree Transformation Languages: A Case Study , 2007 .

[13]  Zhenjiang Hu,et al.  BiFluX: A Bidirectional Functional Update Language for XML , 2014, PPDP '14.

[14]  Peter-Michael Osera,et al.  Type-and-example-directed program synthesis , 2015, PLDI.

[15]  Benjamin C. Pierce,et al.  Quotient lenses , 2008, ICFP.

[16]  Sumit Gulwani,et al.  Automating string processing in spreadsheets using input-output examples , 2011, POPL '11.

[17]  David Walker,et al.  Synthesizing bijective lenses , 2018, Proc. ACM Program. Lang..

[18]  Ruzica Piskac,et al.  Complete completion using types and weights , 2013, PLDI.

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

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

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

[22]  Shinya Kawanaka,et al.  biXid: a bidirectional transformation language for XML , 2006, ICFP '06.

[23]  Claus Brabrand,et al.  Dual syntax for XML languages , 2005, Inf. Syst..

[24]  Shin-Cheng Mu,et al.  A programmable editor for developing structured documents based on bidirectional transformations , 2004, PEPM '04.

[25]  Didier Rémy,et al.  Which simple types have a unique inhabitant? , 2015, ICFP.