Abstract
Lenses are programs that can be run both "front to back" and "back to front," allowing updates to either their source or their target data to be transferred in both directions. Since their introduction by Foster et al., lenses have been extensively studied, extended, and applied. Recent work has also demonstrated how techniques from type-directed program synthesis can be used to efficiently synthesize a simple class of lenses---so-called bijective lenses over string data---given a pair of types (regular expressions) and a small number of examples.
We extend this synthesis algorithm to a much broader class of lenses, called simple symmetric lenses, including all bijective lenses, all of the popular category of "asymmetric" lenses, and a rich subset of the more powerful "symmetric lenses" proposed by Hofmann et al. Intuitively, simple symmetric lenses allow some information to be present on one side but not the other and vice versa. They are of independent theoretical interest, being the largest class of symmetric lenses that do not rely on persistent internal state.
Synthesizing simple symmetric lenses is substantially more challenging than synthesizing bijective lenses: Since some of the information on each side can be "disconnected" from the other side, there will, in general, be many lenses that agree with a given example. To guide the search process, we use stochastic regular expressions and ideas from information theory to estimate the amount of information propagated by a candidate lens, generally preferring lenses that propagate more information, as well as user annotations marking parts of the source and target data structures as either irrelevant or essential.
We describe an implementation of simple symmetric lenses and our synthesis procedure as extensions to the Boomerang language. We evaluate its performance on 48 benchmark examples drawn from Flash Fill, Augeas, the bidirectional programming literature, and electronic file format synchronization tasks. Our implementation can synthesize each of these lenses in under 30 seconds.
Supplemental Material
- Rajeev Alur, Rastislav Bodik, Garvit Juniwal, Milo M. K. Martin, Mukund Raghothaman, Sanjit A. Seshia, Rishabh Singh, Armando Solar-Lezama, Emina Torlak, and Abhishek Udupa. 2013. Syntax-Guided Synthesis. In Proceedings of the IEEE International Conference on Formal Methods in Computer-Aided Design (FMCAD) . 1–17.Google Scholar
- Arvind Arasu and Hector Garcia-Molina. 2003. Extracting Structured Data from Web Pages. In Proceedings of the 2003 ACM SIGMOD International Conference on Management of Data (SIGMOD ’03) . 337–348. Google Scholar
Digital Library
- Lennart Augustsson. 2004. {Haskell} Announcing Djinn, version 2004-12-11, a coding wizard. Mailing List. (2004). http://www.haskell.org/pipermail/haskell/2005-December/017055.html .Google Scholar
- Davi M.J. Barbosa, Julien Cretin, Nate Foster, Michael Greenberg, and Benjamin C. Pierce. 2010. Matching Lenses: Alignment and View Update. In Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming (ICFP ’10) . ACM, New York, NY, USA, 193–204. Google Scholar
Digital Library
- Aaron Bohannon, J. Nathan Foster, Benjamin C. Pierce, Alexandre Pilkiewicz, and Alan Schmitt. 2008. Boomerang: Resourceful Lenses for String Data. In Proceedings of the 35th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’08) . ACM. Google Scholar
Digital Library
- Aaron Bohannon, Jeffrey A. Vaughan, and Benjamin C. Pierce. 2006. Relational Lenses: A Language for Updateable Views. In Principles of Database Systems (PODS). Extended version available as University of Pennsylvania technical report MS-CIS-05-27. Google Scholar
Digital Library
- Calendars 2016. Calendars. http://fileformats.archiveteam.org/wiki/Calendars . (2016).Google Scholar
- Rafael C. Carrasco, Mikel L. Forcada, and Laureano Santamaría. 1996. Inferring stochastic regular grammars with recurrent neural networks. In Grammatical Interference: Learning Syntax from Sentences, Laurent Miclet and Colin de la Higuera (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 274–281. Google Scholar
Digital Library
- Krzysztof Czarnecki, J. Nathan Foster, Zhenjiang Hu, Ralf Lämmel, Andy Schürr, and James F. Terwilliger. 2009. Bidirectional Transformations: A Cross-Discipline Perspective. In ICMT (Lecture Notes in Computer Science), Richard F. Paige (Ed.), Vol. 5563. Springer, 260–283. Google Scholar
Digital Library
- Kevin Ellis, Armando Solar-Lezama, and Joshua B. Tenenbaum. 2015. Unsupervised Learning by Program Synthesis. In Proceedings of the 28th International Conference on Neural Information Processing Systems - Volume 1 (NIPS’15) . MIT Press, Cambridge, MA, USA, 973–981. http://dl.acm.org/citation.cfm?id=2969239.2969348 Google Scholar
Digital Library
- John K. Feser, Swarat Chaudhuri, and Isil Dillig. 2015. Synthesizing Data Structure Transformations from Input-output Examples. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI) . Google Scholar
Digital Library
- Finance and Accounting 2016. Finance and Accounting. http://fileformats.archiveteam.org/wiki/Finance_and_Accounting . (2016).Google Scholar
- Kathleen Fisher, David Walker, Kenny Q. Zhu, and Peter White. 2008. From Dirt to Shovels: Fully Automatic Tool Generation From Ad Hoc Data. Google Scholar
Digital Library
- J. Nathan Foster, Michael B. Greenwald, Jonathan T. Moore, Benjamin C. Pierce, and Alan Schmitt. 2007. Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem. ACM Transactions on Programming Languages and Systems 29, 3 (May 2007), 17. Google Scholar
Digital Library
- J. Nathan Foster, Alexandre Pilkiewicz, and Benjamin C. Pierce. 2008. Quotient Lenses. SIGPLAN Not. 43, 9 (Sept. 2008), 383–396. Google Scholar
Digital Library
- Jonathan Frankle, Peter-Michael Osera, David Walker, and Steve Zdancewic. 2015. Example-Directed Synthesis: A TypeTheoretic Interpretation (extended version) . Technical Report MS-CIS-15-12. University of Pennsylvania.Google Scholar
- Sumit Gulwani. 2011. Automating String Processing in Spreadsheets Using Input-output Examples. In Proceedings of the 38th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’11) . ACM. Google Scholar
Digital Library
- Tihomir Gvero, Viktor Kuncak, Ivan Kuraj, and Ruzica Piskac. 2013. Complete Completion Using Types and Weights. In Proceedings of the 2013 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI) . Google Scholar
Digital Library
- Martin Hofmann, Benjamin C. Pierce, and Daniel Wagner. 2011. Symmetric Lenses. In ACM SIGPLAN–SIGACT Symposium on Principles of Programming Languages (POPL), Austin, Texas . Google Scholar
Digital Library
- Qinheping Hu and Loris D’Antoni. 2017. Automatic Program Inversion Using Symbolic Transducers. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2017) . ACM, New York, NY, USA, 376–389. Google Scholar
Digital Library
- Nicholas Kushmerick. 1997. Wrapper Induction for Information Extraction. Ph.D. Dissertation. Seattle, WA, USA. Google Scholar
Digital Library
- Vu Le and Sumit Gulwani. 2014. FlashExtract: A Framework for Data Extraction by Examples. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’14) . ACM. Google Scholar
Digital Library
- Daniel Lehmann. 1977. Algebraic structures for transitive closure. Theoretical Computer Science 4 (02 1977), 59–76.Google Scholar
- David Lutterkort. 2007. Augeas: A Linux Configuration API. (Feb. 2007). Available from http://augeas.net/.Google Scholar
- Solomon Maina, Anders Miltner, Kathleen Fisher, Benjamin Pierce, Dave Walker, and Steve Zdancewic. 2018. Synthesizing Quotient Lenses. To appear. Google Scholar
Digital Library
- Anders Miltner, Kathleen Fisher, Benjamin C. Pierce, David Walker, and Steve Zdancewic. 2018a. Synthesizing Bijective Lenses. In Proceedings of the 45th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2018) .Google Scholar
Digital Library
- Anders Miltner, Solomon Maina, Kathleen Fisher, Benjamin C. Pierce, David Walker, and Steve Zdancewic. 2018b. Synthesizing Symmetric Lenses. CoRR abs/1810.11527 (2018). arXiv: 1810.11527 http://arxiv.org/abs/1810.11527 Extended technical report.Google Scholar
- Peter-Michael Osera and Steve Zdancewic. 2015. Type-and-example-directed program synthesis. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation . ACM. Google Scholar
Digital Library
- Fernando Pereira. 2000. Formal grammar and information theory: Together again? Philosophical transactions of the royal society 358 (2000), 1239–1253.Google Scholar
- Brian J. Ross. 2000. Probabilistic Pattern Matching and the Evolution of Stochastic Regular Expressions. Applied Intelligence 13, 3 (Nov. 2000), 285–300. Google Scholar
Digital Library
- Gabriel Scherer and Didier Rèmy. 2015. Which simple types have a unique inhabitant?. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming (ICFP) . Google Scholar
Digital Library
- Andy Schürr. 1995. Specification of graph translators with triple graph grammars. In Graph-Theoretic Concepts in Computer Science , Ernst W. Mayr, Gunther Schmidt, and Gottfried Tinhofer (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 151–163. Google Scholar
Digital Library
- Claude Elwood Shannon. 1948. A Mathematical Theory of Communication. The Bell System Technical Journal 27, 3 (7 1948), 379–423.Google Scholar
Cross Ref
- Janis Voigtländer. 2009. Bidirectionalization for Free! (Pearl). In Proceedings of the 36th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’09) . ACM, New York, NY, USA, 165–176. Google Scholar
Digital Library
Index Terms
Synthesizing symmetric lenses
Recommendations
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 ...
Synthesizing bijective lenses
Bidirectional transformations between different data representations occur frequently in modern software systems. They appear as serializers and deserializers, as parsers and pretty printers, as database views and view updaters, and as a multitude of ...
Edit lenses
POPL '12: Proceedings of the 39th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languagesA lens is a bidirectional transformation between a pair of connected data structures, capable of translating an edit on one structure into an appropriate edit on the other. Many varieties of lenses have been studied, but none, to date, has offered a ...






Comments