Verify models understand the notation
Before any execution test, models solve two multiple-choice tasks: match a natural-language description to its formal rule (NL → Rule) and vice-versa (Rule → NL), under every semantic shift.
The 43rd International Conference on Machine Learning (ICML 2026) · Seoul, South Korea
Can a language model condition its reasoning on explicitly supplied formal semantics—even when those semantics contradicts its priors?
1The University of Texas at Austin 2Cisco Research
Citation
@inproceedings{ThimmaiahETAL25PLSemanticsBench,
title = {LLMs Lean on Priors, Not Programming Language Semantics},
author = {Thimmaiah, Aditya and Zhang, Jiyang and Srinivasa, Jayanth
and Li, Junyi Jessy and Gligoric, Milos},
booktitle = {ICML},
year = {2026}
}
Ask a model to execute 2 + 2 under standard semantics where + means addition, and it
answers 4 every time. Now supply a complete formal semantics in the prompt in which
+ is defined—rule by rule—to perform subtraction, and ask again.
2 + 2 → models answer 4 ✓
2 + 2 → models still answer 4 ✗ (should be 0)
They are not conditioning on the semantics they are given; instead, they are recalling “+ means add” from their prior knowledge.
This scenario is neither contrived nor purely synthetic; operator overloading in C++, Python, Scala, and DSLs such as Triton routinely assigns new meanings to familiar operators—or introduces symbols a model has never encountered. Models expected to reason about code in these languages must be able to follow the semantic specifications they are given for symbols rather than simply relying on their prior knowledge.
1 int x; 2 x = ( + );
Faithful interpreter
x = 4 follows semanticsPrior-driven model
x = 4 same answer"+" Semantic Rule
+ evaluates as integer addition.
+ v₂, σ⟩ → ⟨v₃, σ⟩
Formal semantics gives us a controlled intervention: preserve a program’s surface syntax while changing the transition rules that define its behavior. A model that truly conditions on the supplied rules should change its answer immediately. Our methodology makes sure that when models fail, the failure is about reasoning—not parsing, tokenization, or ambiguity.
Before any execution test, models solve two multiple-choice tasks: match a natural-language description to its formal rule (NL → Rule) and vice-versa (Rule → NL), under every semantic shift.
Two systematic transformations of the standard C★ semantics preserve rule structure while perturbing the symbol–meaning map: KeywordSwap creates direct conflict with priors; KeywordObf removes familiarity altogether.
Three program splits with sharply increasing control-flow, data-flow, and size complexity—from adapted LeetCode/MBPP solutions to fuzzer-generated programs with 100× the cyclomatic complexity.
Standard
+meansadditionSyntax and pretrained associations agree. Measures baseline execution ability.
KeywordSwap
-meansadditionThe strongest test of whether supplied rules override lexical priors.
KeywordObf
𐔱meansadditionFamiliar symbolic cues are removed while rule structure is preserved.
The semantic shifts
KeywordSwap exchanges the semantics of familiar operators (+↔−, *↔/, …).
KeywordObf assigns semantics to symbols from the Caucasian-Albanian script.
| Standard | + | - | * | / |
< | <= | > | >= |
== | != | && | || |
while | ... |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| KeywordSwap | - | + | / | * |
> | >= | < | <= |
!= | == | || | && |
while | ... |
| KeywordObf | 𐔱 | 𐔲 | 𐔳 | 𐔴 |
𐔶 | 𐔷 | 𐔸 | 𐔹 |
𐔺 | 𐔻 | 𐔽 | 𐔾 |
𐕀 | ... |
Rule structure, granularity, and count are identical across all three variants.
C★—a featherweight C with explicit block delimiters—is formalized in both fine-grained small-step operational semantics (𝕊) and coarser rewriting-based K semantics (𝕂). Ground truths come from executing each program under the transformed semantics with the K-framework and a custom interpreter.
Models can compose many rule applications to correctly predict final states.
→ PredStateModels can select correct rules when execution never mutates program state.
→ PredRuleModels can follow formal rules consistently across full execution traces.
→ PredTraceModels continue following supplied rules when those rules conflict with priors.
→ Swap / Obf on all tasksHuman-written, LLM-translated, or fuzzer-generated.
Small-step operational semantics or K semantics.
Standard, KeywordSwap, or KeywordObf.
Final state, rule sequence, and full execution trace.
Hypothesis H1 · Global conditioning
Compose many rule applications across control and data flow to determine all variable values after termination.
<ans> <n>5</n> </ans>
Dataset splits · median complexity
Splits are validated by execution: human-written programs are checked against public test oracles; translated programs are filtered by successful K-framework execution; fuzzed programs are generated with legality masks and guaranteed-terminating loops.
| Split | Programs | Source | Cyclomatic | Lines of code | DepDegree | Trace length |
|---|---|---|---|---|---|---|
| Human-Written | 162 | LeetCode, HumanEval, CodeContests, MBPP | 3 | 19 | 12 | 20 |
| LLM-Translated | 165 | CodeForces C++ → C★ via Qwen2.5-Inst 32B | 9 | 106 | 48 | 180 |
| Fuzzer-Generated | 165 | Depth-controlled, semantics-aware grammar fuzzer | 100 | 794 | 6K | 190 |
semantic formalisms (𝕊 and 𝕂)
program splits of rising complexity
semantic shifts per formalism
tasks from outcomes to full traces
Explore published results across tasks, program complexity, formalization, and semantic condition. The most revealing contrast is not which model scores highest, but how much accuracy survives when symbol meanings shift.
PredState · exact-match accuracy (%)
The swap condition creates a direct conflict between familiar symbols and supplied meanings.
Semantic gap: Several models approach ceiling accuracy under standard semantics yet lose tens of percentage points when operator meanings are swapped.
Values reported in Tables 4–6 of the paper (one-shot prompting; reasoning-model results averaged over three runs, std. dev. ≤ 5.2 points). Only models reported for the selected split/task are shown.
Supplying formal semantics lifts reasoning models by 9–16 points under standard semantics, but most non-reasoning models actually degrade when given the rules.
KeywordSwap causes 40–70-point drops where KeywordObf causes modest ones. Conflict with priors—not unfamiliarity—is what breaks models.
Moving to fuzzer-generated programs collapses accuracy by 40+ points even under standard semantics. Loop nesting depth, data-flow degree, and trace length are the strongest predictors of failure.
Only 4 of 11 models achieve any non-zero PredTrace accuracy; the best result is 35%. Most models cannot stay grounded in the rules for dozens of steps.
Each control experiment targets a candidate excuse for the failures—prompting style, tokenization, state-tracking burden—and eliminates it. What remains is the core deficit: conditioning on supplied rules.
Attempt 1
CoT lifts non-reasoning models by ~50 points under standard semantics (Llama-3.3 70B: 29% → 75%). Under KeywordSwap the gains vanish entirely (4% → 3%).
Attempt 2
Maybe KeywordObf fails because rare Unicode glyphs shatter into many tokens? Replacing every symbol with a verified single-token alternative changes accuracy by ≤ 2.5 points (e.g., 8.4% → 7.0%).
Attempt 3
Even when programs never mutate state—eliminating the long-horizon burden entirely—most models still mispredict rules under KeywordSwap (o3-mini drops ~30 points).
Gemini-2.5-pro maintains ≥97% PredState accuracy under KeywordSwap on human-written programs and is the only model whose PredTrace accuracy improves under semantic shift (32% → 35%). This shows mutation-robust rule conditioning is achievable—yet it appears in a single frontier system, is far from a general consequence of scale or reasoning training, and still collapses on fuzzer-generated programs (69% → 26% under swap).
Across 11 frontier models, two formalisms, three semantic shifts, and three complexity regimes, the picture is consistent: contemporary LLMs rely on pretrained lexical associations rather than systematically conditioning on supplied formal rules.
Models read the formalism at near-ceiling accuracy—then fail to apply it.
Swapping familiar meanings hurts far more than introducing unfamiliar symbols.
Gains from reasoning traces evaporate exactly when rules conflict with priors.
Only 4 models produce any correct full trace; the best reaches 35%.
Icon credits
We credit the creators of the following icons used on this webpage: