Reference. Saggitarius: A DSL for Specifying Grammatical Domains
Common data types like dates, addresses, phone numbers and tables can have multiple textual representations, and many heavily-used languages, such as SQL, come in several dialects. These variations can cause data to be misinterpreted, leading to silent data corruption, failure of data processing systems, or even security vulnerabilities. Saggitarius is a new language and system designed to help programmers reason about the format of data, by describing grammatical domains—that is, sets of context-free grammars that describe the many possible representations of a datatype. We describe the design of Saggitarius via example and provide a relational semantics. We show how Saggitarius may be used to analyze a data set: given example data, it uses an algorithm based on semi-ring parsing and MaxSAT to infer which grammar in a given domain best matches that data. We evaluate the effectiveness of the algorithm on a benchmark suite of 110 example problems, and we demonstrate that our system typically returns a satisfying grammar within a few seconds with only a small number of examples. We also delve deeper into a more extensive case study on using Saggitarius for CSV dialect detection. Despite being general-purpose, we find that Saggitarius offers comparable results to hand-tuned, specialized tools; in the case of CSV, it infers grammars for 84% of benchmarks within 60 seconds, and has comparable accuracy to custom-built dialect detection tools.
Cite
Cites 53 works (4 here)
With notes (4)
Synthesizing symmetric lenses miltner-2019-synthesizing
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.
Synthesizing bijective lenses miltner-2017-synthesizing
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 different kinds of ad hoc data converters. Manually building bidirectional transformations—by writing two separate functions that are intended to be inverses—is tedious and error prone. A better approach is to use a domain-specific language in which both directions can be written as a single expression. However, these domain-specific languages can be difficult to program in, requiring programmers to manage fiddly details while working in a complex type system. We present an alternative approach. Instead of coding transformations manually, we synthesize them from declarative format descriptions and examples. Specifically, we present Optician, a tool for type-directed synthesis of bijective string transformers. The inputs to Optician are a pair of ordinary regular expressions representing two data formats and a few concrete examples for disambiguation. The output is a well-typed program in Boomerang (a bidirectional language based on the theory of lenses). The main technical challenge involves navigating the vast program search space efficiently. In particular, and unlike most prior work on type-directed synthesis, our system operates in the context of a language with a rich equivalence relation on types (the theory of regular expressions). Consequently, program synthesis requires search in two dimensions: First, our synthesis algorithm must find a pair of “syntactically compatible types,” and second, using the structure of those types, it must find a type- and example-compliant term. Our key insight is that it is possible to reduce the size of this search space without losing any computational power by defining a new language of lenses designed specifically for synthesis. The new language is free from arbitrary function composition and operates only over types and terms in a new disjunctive normal form. We prove (1) our new language is just as powerful as a more natural, compositional, and declarative language and (2) our synthesis algorithm is sound and complete with respect to the new language. We also demonstrate empirically that our new language changes the synthesis problem from one that admits intractable solutions to one that admits highly efficient solutions, able to synthesize intricate lenses between complex file formats in seconds. We evaluate Optician on a benchmark suite of 39 examples that includes both microbenchmarks and realistic examples derived from other data management systems including Flash Fill, a tool for synthesizing string transformations in spreadsheets, and Augeas, a tool for bidirectional processing of Linux system configuration files.
From dirt to shovels: fully automatic tool generation from ad hoc data fisher-2008-from
An efficient context-free parsing algorithm Earley1970
A parsing algorithm which seems to be the most efficient general context-free algorithm known is described. It is similar to both Knuth’s LR(k) algorithm and the familiar top-down algorithm. It has a time bound proportional to n3 (where n is the length of the string being parsed) in general; it has an n2 bound for unambiguous grammars; and it runs in linear time on a large class of grammars, which seems to include most practical context-free programming language grammars. In an empirical comparison it appears to be superior to the top-down and bottom-up algorithms studied by Griffiths and Petrick.
External (49)
- Saggitarius: a DSL for specifying grammatical domains (2023)
- parsec: monadic parser combinators (2023)
- National conventions for writing telephone numbers (Wikipedia) (2023)
- Google Cloud database identifiers documentation (BigQuery legacy SQL migration) (2022)
- Microsoft SQL Server database identifiers (2022)
- Faster general parsing through context-free memoization (2020)
- DARPA SafeDocs program (2020)
- CSV file reading and writing (Python csv module) (2020)
- PROSE (Microsoft Research) (2020)
- Earley parsing explained (2020)
- Multi-modal synthesis of regular expressions (2019)
- Automatic repair of regular expressions (2019)
- Provenance-guided synthesis of Datalog programs (2019)
- Synthesizing Datalog Programs Using Numerical Relaxation (2019)
- Search-based program synthesis (2018)
- Wrangling messy CSV files by detecting row and type patterns (2018)
- FlashProfile: a framework for synthesizing data profiles (2017)
- Automated data extraction using predictive program synthesis (2017)
- Program synthesis using abstraction refinement (2017)
- Synthesis of data completion scripts using finite tree automata (2017)
- Dig into the attack surface of PDF and gain 100+ CVEs in 1 year (2017)
- Synthesizing program input grammars (2016)
- Extract Me If You Can: Abusing PDF Parsers in Malware Detectors (2016)
- Synthesizing regular expressions from examples for introductory automata assignments (2016)
- FlashRelate: extracting relational data from semi-structured spreadsheets using examples (2015)
- FlashMeta: a framework for inductive program synthesis (2015)
- FlashExtract: a framework for data extraction by examples (2014)
- Syntax-guided synthesis (2013)
- The PADS project: an overview (2011)
- Automating string processing in spreadsheets using input-output examples (2011)
- Pads Manual: Appendix B All Pads Base Types (2009)
- Z3: An Efficient SMT Solver (2008)
- Logical and Relational Learning (2008)
- Provenance semirings (2007)
- Combinatorial sketching for finite programs (2006)
- Programming by sketching for bit-streaming programs (2005)
- Common format and MIME type for comma-separated values (CSV) files (RFC 4180) (2005)
- Parsing inside-out (1998)
- Inducing Probabilistic Grammars by Bayesian Model Merging (1994)
- Grammatical Inference: An Introduction Survey (1994)
- Inferring regular languages in polynomial updated time (1992)
- GLR Parsing for ε-Grammers (1991)
- Inference of k-Testable Languages in the Strict Sense and Application to Syntactic Pattern Recognition (1990)
- Inference of finite automata using homing sequences (1989)
- Learning Regular Sets from Queries and Counterexamples (1987)
- On the Complexity of Minimum Inference of Regular Sets (1978)
- Language Identification in the Limit (1967)
- Twentieth Annual Conference of the Cognitive Science Society
- The Free Encyclopedia