LLMs Lean on Priors, Not Programming Language Semantics

Aditya Thimmaiah, Jiyang Zhang, Jayanth Srinivasa, Junyi Jessy Li, Milos Gligoric

Introduction

A central debate in artificial intelligence is whether Large Language Models (LLMs) genuinely reason by following explicit rules or merely rely on sophisticated pattern matching derived from their pre-training data. To investigate this, researchers introduced PLSemanticsBench, a novel benchmark demonstrating that even frontier models like GPT-4o and Gemini struggle to follow explicit logic when it conflicts with their pre-trained "priors." For instance, if a prompt explicitly defines the + symbol to mean subtraction, models frequently fail to execute the code correctly, reverting instead to their ingrained training.

The Problem: Reasoning vs. Pattern Matching

Programming provides an ideal laboratory for testing LLM reasoning because it relies on formal semantics—strict, symbolic rules that dictate exactly how a program state transitions. Typically, LLMs are evaluated on familiar languages like Python or C++. However, because these models have ingested millions of lines of such code during training, it is nearly impossible to determine if they are actually "executing" the provided logic or simply predicting the most likely output based on statistical regularities.

To decouple semantic reasoning from syntactic familiarity, the researchers asked a fundamental question: Can an LLM suppress its prior knowledge of C and strictly follow a novel or conflicting set of rules provided in the prompt?

Methodology: PLSemanticsBench

To test this, the authors developed PLSemanticsBench, pairing a simplified, "featherweight" version of C (called $C^*$) with two distinct formal semantic systems:

  1. Small-step operational semantics ($\mathbb{S}$): Fine-grained, atomic rules that describe state changes at the most granular level (e.g., "first evaluate the left side of the plus sign").
  2. K semantics ($\mathbb{K}$): A higher-level, "big-step" description of program transitions.

To rigorously test rule-following against memory, the benchmark introduces Semantic Mutations:

  • KeywordSwap: Swapping the meanings of familiar operators (e.g., redefining + as subtraction). This induces a "symbol-meaning conflict" where the model's training directly opposes the prompt's instructions.
  • KeywordObf (Obfuscation): Replacing familiar keywords with obscure symbols (such as characters from the Caucasian-Albanian script). This removes the pre-trained prior entirely, forcing the model to rely solely on the supplied rules.

The benchmark evaluates models across three datasets of increasing structural complexity: Human-Written programs (adapted from LeetCode and HumanEval), LLM-Translated programs (C++ translated to $C^*$), and Fuzzer-Generated programs designed to stress-test models with deep loops and unusual data patterns.

Key Findings

Across 11 frontier models—including GPT-4o, Gemini 2.5 Pro, and DeepSeek variants—the results reveal a stark reliance on pre-trained priors over explicit programming language semantics.

  • The "Prior" Trap: Under standard semantics, models performed quite well, achieving up to 90% accuracy. However, under semantic mutations like KeywordSwap, accuracy plummeted by 40 to 60 percentage points. Models frequently ignored the new rules and defaulted to standard operations, proving they lean heavily on lexical associations rather than systematic rule conditioning.
  • Obfuscation is Easier than Conflict: Counterintuitively, models often performed better when keywords were replaced with entirely alien symbols (KeywordObf) than when familiar symbols were reassigned (KeywordSwap). It is easier for an LLM to learn a new rule for an unfamiliar symbol than to "unlearn" an ingrained rule for a familiar one.
  • Complexity Collapse and Long-Horizon Failures: As programs increased in length and complexity, rule-following broke down. In tasks requiring the generation of a full step-by-step execution trace, most models hit 0% accuracy. Even the standout model, Gemini 2.5 Pro—which showed the most consistent "mutation-robustness"—only reached 35% accuracy on long-horizon conditioning.
  • Chain-of-Thought (CoT) Limitations: While CoT reasoning helped models navigate longer programs under standard conditions, it failed to overcome the bias of familiar symbols under mutation. Models would simply use CoT to "reason" their way to the wrong answer using their pre-trained priors.

Limitations and Future Directions

The study acknowledges a few limitations. $C^*$ is a simplified language lacking complex features like pointers, memory management, or concurrency, meaning real-world execution tasks would likely be even harder. Additionally, the study relied on one-shot prompting; extensive in-context learning or alternative prompting strategies might yield different results.

Ultimately, the findings suggest that simply scaling up models will not resolve these fundamental reasoning deficits. The authors advocate for a shift toward "execution-aware" training—teaching models to internalize formal logic systems so they can adapt to novel rules as flexibly as a human programmer adopting a new domain-specific language.

Summary updated

BibTeX
@inproceedings{thimmaiah2026llms,
  author = {Aditya Thimmaiah and Jiyang Zhang and Jayanth Srinivasa and Junyi Jessy Li and Milos Gligoric},
  title = {{LLMs Lean on Priors, Not Programming Language Semantics}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=8xH4BQ8J6Y},
}
Figure