skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Functional

Synthesizing symmetric lenses

Published:26 July 2019Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

a95-miltner.webm

References

  1. 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 ScholarGoogle Scholar
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle Scholar
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. Calendars 2016. Calendars. http://fileformats.archiveteam.org/wiki/Calendars . (2016).Google ScholarGoogle Scholar
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. Finance and Accounting 2016. Finance and Accounting. http://fileformats.archiveteam.org/wiki/Finance_and_Accounting . (2016).Google ScholarGoogle Scholar
  13. Kathleen Fisher, David Walker, Kenny Q. Zhu, and Peter White. 2008. From Dirt to Shovels: Fully Automatic Tool Generation From Ad Hoc Data. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. J. Nathan Foster, Alexandre Pilkiewicz, and Benjamin C. Pierce. 2008. Quotient Lenses. SIGPLAN Not. 43, 9 (Sept. 2008), 383–396. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle Scholar
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. Nicholas Kushmerick. 1997. Wrapper Induction for Information Extraction. Ph.D. Dissertation. Seattle, WA, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. Daniel Lehmann. 1977. Algebraic structures for transitive closure. Theoretical Computer Science 4 (02 1977), 59–76.Google ScholarGoogle Scholar
  24. David Lutterkort. 2007. Augeas: A Linux Configuration API. (Feb. 2007). Available from http://augeas.net/.Google ScholarGoogle Scholar
  25. Solomon Maina, Anders Miltner, Kathleen Fisher, Benjamin Pierce, Dave Walker, and Steve Zdancewic. 2018. Synthesizing Quotient Lenses. To appear. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle Scholar
  28. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  29. Fernando Pereira. 2000. Formal grammar and information theory: Together again? Philosophical transactions of the royal society 358 (2000), 1239–1253.Google ScholarGoogle Scholar
  30. Brian J. Ross. 2000. Probabilistic Pattern Matching and the Evolution of Stochastic Regular Expressions. Applied Intelligence 13, 3 (Nov. 2000), 285–300. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  32. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  33. Claude Elwood Shannon. 1948. A Mathematical Theory of Communication. The Bell System Technical Journal 27, 3 (7 1948), 379–423.Google ScholarGoogle ScholarCross RefCross Ref
  34. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Synthesizing symmetric lenses

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!