Program Semantic Inequivalence Game with Large Language Models

Antonio Valerio Miceli Barone, Vaishak Belle, Ali PayaniarXiv 2025 · DOI

Introduction

While Large Language Models (LLMs) have become proficient at generating boilerplate code, they often struggle with deep semantic reasoning. Models frequently fail to distinguish between programs that look similar but behave differently, or they may be misled by "adversarial" code patterns. This paper introduces SInQ (Semantic Inequivalence Game), a self-play framework designed to force LLMs to understand the underlying logic of code rather than relying on surface-level pattern matching.

The SInQ Framework

The authors propose a competitive game between two LLM agents: Alice (the Generator) and Bob (the Evaluator). The goal of the game is to identify semantic differences between programs.

The SInQ game architecture featuring Alice (Generator) and Bob (Evaluator) competing to identify semantic differences.
  1. Alice (The Generator): Given a source program $P$, Alice must generate a variant $Q$ that is semantically different. To prove the difference, Alice must also provide a "diverging input" $x$ such that $P(x) \neq Q(x)$.
  2. Bob (The Evaluator): Bob receives both $P$ and $Q$ and must independently find a diverging input $\hat{x}$ to demonstrate his understanding of the semantic gap between the two programs.

Training Methodology: Difficulty Targeting

A key challenge in adversarial self-play is preventing the game from stalling. If Alice generates variants that are too simple, Bob learns nothing; if she generates variants that are too complex (e.g., requiring the reversal of a cryptographic hash), Bob also fails to learn.

To address this, the researchers implemented Difficulty Targeting. Alice is prompted to generate variants at a specific difficulty level—the "Goldilocks zone"—where Bob is likely to fail but can still potentially succeed with better reasoning. This iterative Supervised Fine-Tuning (SFT) process allows the model to progressively master more complex computational logic.

Experimental Results

The researchers evaluated the SInQ-trained model (using gpt-4o-mini as a base) across several challenging benchmarks.

Logic Reasoning and Identifier Swaps

One of the most rigorous tests was the "Python Builtin Identifier Swap" benchmark. In this task, models must reason about code where standard functions like len() or print() have been redefined. Historically, this task has shown "inverse scaling," where larger models perform worse.

Accuracy comparison on the challenging Identifier Swap benchmark, showing significant gains for the SInQ-trained model.

As shown in the results, the SInQ-trained model achieved a 5.35% accuracy, a substantial relative improvement over the baseline's 1.65%. While the absolute numbers remain low, the jump indicates a significantly improved capacity for deep logical tracking.

Cross-Language Generalization and Security

Perhaps the most striking result was the model's ability to generalize. Despite being trained primarily on Python-based SInQ puzzles, the model showed improved performance in detecting security vulnerabilities in C/C++ (using the CodeXGLUE dataset). This suggests that the SInQ game teaches general "computational reasoning" that transcends specific programming language syntax.

Standard Code Generation

Training on reasoning puzzles did not degrade standard coding performance. On the MBPP+ benchmark, the model's Pass@1 score improved from 69.6% to 70.4%, indicating that better reasoning directly supports more accurate code generation.

Conclusion and Future Work

The SInQ framework demonstrates that adversarial self-play is a powerful tool for improving LLM code reasoning. Because program equivalence is undecidable (per Rice’s Theorem), there is no theoretical ceiling to the complexity of the puzzles Alice can generate. Future work could involve multiple rounds of back-and-forth training—similar to the AlphaZero approach—and the integration of Reinforcement Learning (RL) to further refine the evaluator's capabilities.

Summary updated

BibTeX
@misc{barone2025program,
  author = {Antonio Valerio Miceli Barone and Vaishak Belle and Ali Payani},
  title = {{Program Semantic Inequivalence Game with Large Language Models}},
  year = {2025},
  eprint = {2505.03818},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.03818},
}
Figure