Code over Words: Overcoming Semantic Inertia via Code-Grounded Reasoning

Manjie Xu, Isabella Yin, Xinyi Tu, Chi Zhang, Yixin Zhu


Abstract
LLMs struggle with Semantic Inertia: the inability to inhibit pre-trained priors (e.g., “Lava is Dangerous”) when dynamic, in-context rules contradict them. We probe this phenomenon using , where physical laws are mutable text rules, enabling precise evaluation of models’ ability to override learned priors when rules change. We quantatively observe that larger models can exhibit inverse scaling: they perform worse than smaller models when natural language reasoning requires suppressing pre-trained associations (e.g., accepting “Lava is Safe”). Our analysis attributes this to natural language encoding, which entangles descriptive semantics and logical rules, leading to persistent hallucinations of familiar physics despite explicit contradictory rules. Here we show that representing dynamics as executable code, rather than descriptive text, reverses this trend and enables effective prior inhibition. We introduce LCV, which fine-tunes models on counterfactual pairs and identifies states with contradictory rules, thereby forcing attention to logical constraints rather than visual semantics. This training-time approach outperforms expensive inference-time search methods in both efficiency and accuracy. Our results demonstrate that representation fundamentally determines whether scaling improves or impairs contextual reasoning. This challenges the assumption that larger models are universally better, with implications for domains that require dynamic overriding of learned priors.
Anthology ID:
2026.findings-acl.819
Volume:
Findings of the Association for Computational Linguistics: ACL 2026
Month:
July
Year:
2026
Address:
San Diego, California, United States
Editors:
Maria Liakata, Viviane P. Moreira, Jiajun Zhang, David Jurgens
Venue:
Findings
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
16610–16632
Language:
URL:
https://preview.aclanthology.org/ingest-acl/2026.findings-acl.819/
DOI:
Bibkey:
Cite (ACL):
Manjie Xu, Isabella Yin, Xinyi Tu, Chi Zhang, and Yixin Zhu. 2026. Code over Words: Overcoming Semantic Inertia via Code-Grounded Reasoning. In Findings of the Association for Computational Linguistics: ACL 2026, pages 16610–16632, San Diego, California, United States. Association for Computational Linguistics.
Cite (Informal):
Code over Words: Overcoming Semantic Inertia via Code-Grounded Reasoning (Xu et al., Findings 2026)
Copy Citation:
PDF:
https://preview.aclanthology.org/ingest-acl/2026.findings-acl.819.pdf
Checklist:
 2026.findings-acl.819.checklist.pdf