NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

The Usability of Pragmatic Communication in Regular Expression Synthesis

Priyan Vaithilingam, Yewen Pu, Elena L. GlassmanarXiv 2023 · DOI

Abstract

Regular expression (regex) synthesis via Programming-by-Example (PBE) often suffers from ambiguity, where a small set of examples may satisfy many unintended programs. This paper proposes modeling program synthesis as a "pragmatic" conversation using the Rational Speech Acts (RSA) framework. By reasoning about why a user chose specific examples, a pragmatic synthesizer can significantly outperform traditional "literal" systems. In a controlled user study, participants using a pragmatic synthesizer achieved a 95% success rate compared to 51% for the baseline, while requiring 57% fewer examples.

Introduction

Regular expressions are essential but notoriously difficult to author. Programming-by-Example (PBE) systems attempt to lower this barrier by allowing users to provide input-output examples. However, these systems often return "spurious" regexes that match the provided examples but fail to generalize to the user's actual intent. To resolve this, users are typically forced to provide numerous examples, including counter-intuitive negative examples. This research addresses the "user-synthesizer gap" by treating the interaction as a form of rational communication rather than a simple constraint-satisfaction problem.

Methodology: Rational Speech Acts in PBE

The researchers adapted the Rational Speech Acts (RSA) framework from cognitive linguistics to the domain of program synthesis. RSA models communication as a recursive hierarchy of reasoning between a speaker and a listener:

  1. Literal Listener ($L_0$): A baseline synthesizer that treats examples as hard constraints and returns any program consistent with them.
  2. Pragmatic Speaker ($S_1$): A model of an informative user who selects examples specifically to help a listener distinguish the target program from alternatives.
  3. Pragmatic Listener ($L_1$): The proposed synthesizer. It interprets the user's examples by asking: "Which program would a helpful speaker most likely be trying to communicate with these specific inputs?"
The RSA framework illustrated through a simple reference game.

By implementing the $L_1$ model, the synthesizer can perform "inference from absence." If a user provides a highly specific string, the system assumes that specificity was intentional, allowing it to prune the search space more effectively than a literal listener would.

Analogies between rational communication and programming-by-example.

Experimental Setup

Due to the computational complexity of RSA, the authors evaluated the approach on a constrained binary regex subdomain. The grammar supported characters '0' and '1' alongside operators such as *, +, {1}, and {2}. The evaluation involved a user study with 30 participants who performed synthesis tasks using two different interfaces: one that allowed only positive examples and one that allowed both positive and negative examples.

Key Results and Discussion

The quantitative results demonstrate a clear advantage for pragmatic synthesis:

  • Success Rate: Using only positive examples, the pragmatic synthesizer achieved a 95% success rate, nearly doubling the 51% success rate of the non-pragmatic baseline.
  • Efficiency: The pragmatic tool required a median of only 2 examples per task, a 57% reduction compared to the 5 examples required by the baseline.
  • User Experience: 86.6% of participants preferred the pragmatic system, reporting lower mental demand and higher confidence. NASA TLX scores confirmed significantly lower frustration and effort.

One of the most significant findings is that pragmatic reasoning allows users to succeed using only positive examples. In natural communication, humans rarely define concepts by what they are not; by allowing the computer to "read between the lines," the system aligns more closely with human intuition, reducing the cognitive load associated with generating counter-examples.

Conclusion and Future Work

While highly effective, the current implementation of RSA is limited by scalability, as it requires pre-computing a "meaning matrix" of all possible programs and examples. Future research will focus on developing approximation methods or neural models to scale pragmatic reasoning to larger, real-world programming languages and other PBE domains, such as data transformation in spreadsheets.

Summary updated

BibTeX
@misc{vaithilingam2023usability,
  author = {Priyan Vaithilingam and Yewen Pu and Elena L. Glassman},
  title = {{The Usability of Pragmatic Communication in Regular Expression Synthesis}},
  year = {2023},
  eprint = {2308.06656},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.06656},
}
Figure