NeurIPS 2026QuestionsPapersAreasAboutMarkdown

Synsema: Syntax-Guided Learning of Semantically Valid Programs

Levin Winter, Cong Li, Hao Sun, Zhendong Su

NeurIPS page · OpenReview · Open on the map

Category: LLM Agents, Evals & Benchmarks › LLM-Driven Code Synthesis and Verification · Type: new method · Keywords: syntax-guided learning, semantic validation, compiler testing, program generation, reinforcement learning

Areas: Code & Coding Agents › Code Generation and Optimization › Code Generation

Summary

Synsema introduces a syntax-guided reinforcement learning approach that learns semantic rules for generating valid programs, achieving a 7.29% success rate and discovering compiler bugs.

Explained to a 5-year-old

We want computers to make programs that follow two kinds of rules: how the program looks and what it does. Learning both kinds of rules at the same time is hard. So we separate them: we use a set of grammar rules to make sure the program looks correct, then we only teach the computer what the program means. This helps the computer make many correct programs quickly. These programs can test other computer programs, like compilers, and find hidden bugs.

Explained to a 5-year-old, longer

Computers sometimes need to make test inputs for other programs, like compilers. These inputs must follow strict rules so they can be understood by the program. There are two kinds of rules: one says how the input should look (syntax), and the other says what it should mean (semantics). Making both kinds of rules at the same time is difficult for a computer. Some people try to write the rules by hand, but that takes a lot of work and can be wrong. Others try to let the computer learn the rules by looking at many examples, but that also is hard. The paper suggests a new idea: use a grammar to guarantee the syntax, so the computer only has to learn the meaning. This is like having a recipe that already tells you the shape of the dish, and you only need to know how it tastes. The computer is trained with a special learning method that gives it feedback about whether the meaning is correct. They test the idea on two popular programming languages, Java and Rust, which have many rules. The computer can generate many programs that are both syntactically correct and semantically useful. These programs are used to test compilers, and they find bugs that were not known before.

For a technical reader

The paper addresses the challenge of generating valid test inputs for compilers by separating syntactic and semantic constraints. It uses a grammar to enforce syntactic correctness, allowing the learning agent to focus solely on semantic rules. Through reinforcement learning with fine-grained feedback, the system learns to produce programs that satisfy the semantic requirements efficiently. Experiments on Java and Rust show a substantial increase in valid program generation and the discovery of previously unknown compiler bugs. The approach can be integrated into existing testing pipelines to improve coverage and reliability of compiler tools.

Problem

Generating inputs for systems that process structured data is difficult because they must satisfy both syntactic and semantic constraints. Existing methods either rely on manually crafted rules or learn both constraints simultaneously, which is complex and error-prone.

Method

The approach reformulates program generation as a syntax-guided reinforcement learning task, using a grammar to enforce syntactic validity while learning only semantic rules. It employs fine-grained semantic feedback and is applied to Java and Rust to train an agent that samples programs within the constrained space.

Results

The approach achieves a 7.29% success rate in generating semantically valid programs, triggering 2.6 times more compiler behaviors than an unconstrained baseline, and discovered five previously unknown compiler bugs.

Contributions

It introduces a syntax-guided reinforcement learning framework that separates syntactic and semantic constraints, enabling efficient learning of semantic rules and significantly improving program generation quality for compiler testing.

Practical relevance

The approach can be used to automatically generate test inputs for compilers, uncovering bugs and improving software reliability.

Research questions this paper is counted under

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction