[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-85431-en":3,"doc-seo-85431-105":29,"detail-sidebar-cat-0-en-105":91},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":20,"is_deleted":4,"is_public":20,"is_downloadable":20,"audit_status":20,"page_count":21,"language":22,"language_code":23,"site_id":24,"html_lang":23,"table_of_contents":25,"faqs":26,"seo_title":13,"seo_description":14,"update_tm":27,"read_time":28},85431,687197100911,"Himbo","https://ap-avatar.wpscdn.com/avatar/a000239b6f1da00475?x-image-process=image/resize,m_fixed,w_180,h_180&k=1782698725881665579",8,"Research & Report","Syntax Repair as Language Intersection","Syntax repair is formalized as a finite-language problem: for an invalid string and a given context-free grammar, the task is to identify exactly which nearby strings are syntactically valid within a bounded edit distance. The method intersects a CFG with an acyclic Levenshtein automaton to obtain a finite set of all and only repairs in a chosen radius. Using Bar-Hillel CFL-regular intersection and Brzozowski derivatives enables parallel repairability decisions and fast incremental enumeration. Experiments on Python syntax errors show practical candidate spaces and improved repair precision via grammar-constrained search plus transformer reranking.","„  \nSyntax Repair as Language Intersection  \nBREANDAN CONSIDINE  \nSyntax repair can be viewed as a question about finite languages: given an invalid string and a grammar, which nearby strings are syntactically valid? We formalize bounded syntax repair as the intersection of a context-free language with an acyclic Levenshtein automaton, obtaining a finite language that contains all and only repairs within a chosen edit radius. This approach leverages the classic Bar-Hillel construction for CFL-regular intersection, and specializes it to acyclic automata, and yielding a highly parallel decision procedure for deciding repairability. We then show how Brzozowski derivatives support fast incremental enumeration from this intersection, separating exact admissibility from probabilistic ranking. Experiments on Python syntax errors demonstrate the resulting candidate spaces are practical to construct and substantially improve repair accuracy when used as a grammar-constrained search space.  \n1 INTRODUCTION  \nA missing delimiter or mistyped keyword can turn an otherwise meaningful program into an unrecognizable string. Typical parsers can detect invalidity, but cannot infer what the author intended to write. Suppose the parser instead responds by proposing a small set of valid alternatives. What should that set contain? We propose that each suggestion be (1) syntactically valid, (2) similar to the original string,(3) highly natural. Producing a single repair with any one of these properties individually is relatively straightforward. Producing a small set of repairs satisfying all three properties – without missing the author’s intended repair – is substantially harder.  \nThis paper studies that problem for syntax defined by an arbitrary context-free grammar. Let ⌧ describe the language, let :: 8 L (⌧) be an invalid token sequence, and let !( :: , 3) denote the strings within 3 edits of :: . The natural candidate space is ✓\\ = L (⌧) \\ L!!( :: , 3)\". The grammar enforces validity, the edit language enforces locality, and a probabilistic model supplies naturalness. Assuming the intended repair requires at most 3 edits, it will be contained in ✓\\ and the problem becomes how to represent this finite language and quickly recover its members.  \nClassical error-correcting parsers return either one repair or a set minimizing a hand-designed cost [2, 20]. While appealing for their interpretability and well-understood algorithmic properties, these methods are unable to handle ambiguity and must rely on relatively brittle heuristics to select the repair. Learning-based systems [54, 66], while statistically more robust, typically use some form of approximate inference and thus require expensive postprocessing or rejection sampling to ensure the generated results conform to the grammar. In both cases, existing approaches generate far too few repairs to be effective. We argue that for local syntax errors, completeness must be a first-class objective: a repair system must retrieve broadly before selecting the best repair(s) .  \nOur approach makes the local search space explicit. We construct an acyclic Levenshtein automaton denoting every string within distance 3 of :: , then intersect it with the grammar. Previously this route may have deterred exploration to its seemingly high cost: directly materializing the Bar–Hillel product appears intractable for practical grammars. Instead, we exploit a correspondence between Bar–Hillel intersection and CFL reachability to quickly construct the intersection grammar.  \nThis representation turns repair into a constrained decoding problem, allowing any off-the-shelf autoregressive decoder to traverse ✓\\ incrementally without rejection sampling. In our implementation, a lightweight decoder provides an initial set of plausible hypotheses, of which the top-k are then scored with a pretrained transformer, reranked, and finally truncated. Syntactic validity is enforced by construction, edit locality becomes exact, and ","cbCaipka2kkxfTYh","https://ap.wps.com/l/cbCaipka2kkxfTYh","pdf",3368444,1,36,"English","en",105,"# Introduction\n## Contributions\n# Background","[{\"question\":\"How is bounded syntax repair defined in this work?\",\"answer\":\"Bounded syntax repair is defined as the intersection between a context-free language generated by a grammar and the set of strings within a fixed edit radius of an invalid token sequence. This yields a finite language containing exactly the repairs permitted by both syntax and locality constraints.\"},{\"question\":\"What automata-based construction is used to capture edit distance?\",\"answer\":\"An acyclic Levenshtein automaton is constructed to represent every string within distance 3 of the invalid input. The resulting automaton is then intersected with the context-free grammar to form the bounded repair language.\"},{\"question\":\"How are repairs generated and ranked in the proposed pipeline?\",\"answer\":\"A fast probabilistic decoder enumerates candidate members from the intersection incrementally, producing an initial set of plausible hypotheses. The top-k candidates are then scored by a pretrained transformer for reranking, and the list is truncated for presentation, enforcing syntactic validity by construction.\"}]",1784203475,91,{"code":4,"msg":30,"data":31},"ok",{"site_id":24,"language":23,"slug":32,"title":13,"keywords":33,"description":14,"schema_data":34,"social_meta":86,"head_meta":88,"extra_data":90,"updated_unix":27},"syntax-repair-as-language-intersection","",{"@graph":35,"@context":85},[36,53,68],{"@type":37,"itemListElement":38},"BreadcrumbList",[39,43,47,50],{"item":40,"name":41,"@type":42,"position":20},"https://docshare.wps.com","Home","ListItem",{"item":44,"name":45,"@type":42,"position":46},"https://docshare.wps.com/document/","Document",2,{"item":48,"name":12,"@type":42,"position":49},"https://docshare.wps.com/document/research-report/",3,{"item":51,"name":13,"@type":42,"position":52},"https://docshare.wps.com/document/syntax-repair-as-language-intersection/85431/",4,{"url":51,"name":13,"@type":54,"author":55,"headline":13,"publisher":57,"fileFormat":60,"inLanguage":23,"description":14,"dateModified":61,"datePublished":62,"encodingFormat":60,"isAccessibleForFree":63,"interactionStatistic":64},"DigitalDocument",{"name":9,"@type":56},"Person",{"url":40,"name":58,"@type":59},"DocShare","Organization","application/pdf","2026-07-17","2026-07-16",true,{"@type":65,"interactionType":66,"userInteractionCount":20},"InteractionCounter",{"@type":67},"ViewAction",{"@type":69,"mainEntity":70},"FAQPage",[71,77,81],{"name":72,"@type":73,"acceptedAnswer":74},"How is bounded syntax repair defined in this work?","Question",{"text":75,"@type":76},"Bounded syntax repair is defined as the intersection between a context-free language generated by a grammar and the set of strings within a fixed edit radius of an invalid token sequence. This yields a finite language containing exactly the repairs permitted by both syntax and locality constraints.","Answer",{"name":78,"@type":73,"acceptedAnswer":79},"What automata-based construction is used to capture edit distance?",{"text":80,"@type":76},"An acyclic Levenshtein automaton is constructed to represent every string within distance 3 of the invalid input. The resulting automaton is then intersected with the context-free grammar to form the bounded repair language.",{"name":82,"@type":73,"acceptedAnswer":83},"How are repairs generated and ranked in the proposed pipeline?",{"text":84,"@type":76},"A fast probabilistic decoder enumerates candidate members from the intersection incrementally, producing an initial set of plausible hypotheses. The top-k candidates are then scored by a pretrained transformer for reranking, and the list is truncated for presentation, enforcing syntactic validity by construction.","https://schema.org",{"og:url":51,"og:type":87,"og:title":13,"og:site_name":58,"og:description":14},"article",{"robots":89,"canonical":51},"index,follow",{"doc_id":7,"site_id":24},{"code":4,"msg":5,"data":92},[93,97,101,105,110,115,120,123,128,131,135],{"id":20,"doc_module":4,"doc_module_name":45,"category_name":94,"show_sort_weight":95,"slug":96},"Story & Novel",90,"story-novel",{"id":46,"doc_module":4,"doc_module_name":45,"category_name":98,"show_sort_weight":99,"slug":100},"Literature",80,"literature",{"id":52,"doc_module":4,"doc_module_name":45,"category_name":102,"show_sort_weight":103,"slug":104},"Exam",70,"exam",{"id":106,"doc_module":4,"doc_module_name":45,"category_name":107,"show_sort_weight":108,"slug":109},5,"Comic",60,"comic",{"id":111,"doc_module":4,"doc_module_name":45,"category_name":112,"show_sort_weight":113,"slug":114},6,"Technology",50,"technology",{"id":116,"doc_module":4,"doc_module_name":45,"category_name":117,"show_sort_weight":118,"slug":119},7,"Healthcare",40,"healthcare",{"id":11,"doc_module":4,"doc_module_name":45,"category_name":12,"show_sort_weight":121,"slug":122},30,"research-report",{"id":124,"doc_module":4,"doc_module_name":45,"category_name":125,"show_sort_weight":126,"slug":127},9,"Religion & Spirituality",20,"religion-spirituality",{"id":126,"doc_module":4,"doc_module_name":45,"category_name":129,"show_sort_weight":126,"slug":130},"World Cup","world-cup",{"id":132,"doc_module":4,"doc_module_name":45,"category_name":133,"show_sort_weight":132,"slug":134},10,"Lifestyle","lifestyle",{"id":136,"doc_module":4,"doc_module_name":45,"category_name":137,"show_sort_weight":106,"slug":138},19,"General","general"]