Code over Words: Overcoming Semantic Inertia via Code-Grounded Reasoning
Paper · 2026 · Manjie Xu, Isabella Yin, Xinyi Tu et al.
Summary
Large language models often cannot set aside what they learned in pre-training when the context explicitly redefines how the world works. For example, a model may keep treating lava as harmful after a rule declares it safe. The authors call this failure Semantic Inertia. They study it in Baba Is You, a puzzle game whose physical laws are movable text blocks. For this setting they build BABABENCH, a benchmark with paired scenarios of increasing rule conflict, designed to separate inhibition failures from general planning weakness.
With natural-language reasoning, larger models sometimes score lower than smaller ones, an inverse-scaling effect. Their method, Code-Grounded Vistas (LCV), has the model write Python programs that encode the game's current dynamics. It is trained by supervised fine-tuning on counterfactual pairs: identical states governed by contradictory rules. This training-time approach is more accurate and faster than inference-time search methods such as TheoryCoder.
The broader lesson is that the choice of representation, not only model size, determines whether scaling helps or hurts reasoning that depends on context.
Key points
- Representation ablation (Gemini 3 Pro backbone):
- Tier 2 accuracy is 13.3% for NL, 40.0% for a structured Table, 26.7% for PDDL, 31.1% for untuned Code, and 75.6% for LCV.
- On Tier 3, LCV reaches 62.0% versus 10.0% for NL.
- The authors conclude that executability, rather than structural regularity, drives the gains.
- Efficiency: iterative search baselines spend roughly 3.2k tokens per problem. LCV cuts latency about 4× while also raising accuracy.
- Spatial generalization: on unseen map layouts, the fine-tuned model (about 7B) barely drops, going from 76.4% to 74.3%.
- Compositional generalization: on novel rule combinations (e.g., WALL IS MELT), LCV scores 72.4% versus 48.2% for Qwen-72B.
- Limitations:
- The method assumes discrete grid-world states.
- It needs paired data with contradictory rules, which is easy to generate procedurally for puzzles but potentially costly to collect in naturalistic environments.
Institutions
Fields, topics and concepts
📚 Shelves 5The field of science this work belongs to (OpenAlex fields).Computer Science · 18,614 worksArtificial Intelligence · 17,965 worksArts and Humanities · 17,450 worksLanguage and Linguistics · 17,296 worksComputer Vision and Pattern Recognition · 3,486 works
🧭 Topics 1Research subjects and languages the work is about.Reasoning · 1,685 works
Cite
Cite as Manjie Xu, Isabella Yin, Xinyi Tu, Chi Zhang and Yixin Zhu. 2026. Code over Words: Overcoming Semantic Inertia via Code-Grounded Reasoning. Findings of the Association for Computational Linguistics: ACL 2026.
@inproceedings{xu2026code,
title = {{Code over Words: Overcoming Semantic Inertia via Code-Grounded Reasoning}},
author = {Manjie Xu, Isabella Yin, Xinyi Tu, Chi Zhang and Yixin Zhu},
booktitle = {Findings of the Association for Computational Linguistics: ACL 2026},
year = {2026},
doi = {10.18653/v1/2026.findings-acl.819},
url = {https://doi.org/10.18653/v1/2026.findings-acl.819}
}References
- Deepak Bhaskar Acharya, Karthigeyan Kuppan, and B Divya. 2025. Agentic ai: Autonomous intelligence for complex goals–a comprehensive survey. IEEE Access. find
- Zergham Ahmed, Joshua B Tenenbaum, Christopher J Bates, and Samuel J Gershman. 2025. Synthesizing world models for bilevel planning. arXiv preprint arXiv:2503.20124. — [arXiv:2503.20124](https://arxiv.org/abs/2503.20124) find
- Emily M Bender and Alexander Koller. 2020. Climbing towards nlu: On meaning, form, and understanding in the age of data. In Annual Meeting of the Association for Computational Linguistics (ACL).
- Ning Bian, Xianpei Han, Le Sun, Hongyu Lin, Yaojie Lu, Ben He, Shanshan Jiang, and Bin Dong. 2024. Chatgpt is a knowledgeable but inexperienced solver: An investigation of commonsense problem in large language models. In International Conference on Computational Linguistics (COLING).
- Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, and 1 others. 2020. Language models are few-shot learners. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS).
- Sébastien Bubeck, Varun Chandrasekaran, Ronen Eldan, Johannes Gehrke, Eric Horvitz, Ece Kamar, Peter Lee, Yin Tat Lee, Yuanzhi Li, Scott Lundberg, and 1 others. 2023. Sparks of artificial general intelligence: Early experiments with gpt-4. arXiv preprint arXiv:2303.12712.
- Megan Charity and Julian Togelius. 2022. Keke ai competition: Solving puzzle levels in a dynamically changing mechanic space. In IEEE Conference on Games (CoG). find
- Wenhu Chen, Xueguang Ma, Xinyi Wang, and William W Cohen. 2022. Program of thoughts prompting: Disentangling computation from reasoning for numerical reasoning tasks. Transactions on Machine Learning Research. find
- Nathan Cloos, Meagan Jens, Michelangelo Naim, Yen-Ling Kuo, Ignacio Cases, Andrei Barbu, and Christopher J Cueva. 2024. Baba is ai: Break the rules to beat the benchmark. arXiv preprint arXiv:2407.13729. — [arXiv:2407.13729](https://arxiv.org/abs/2407.13729) find
- Ria Das, Joshua B Tenenbaum, Armando Solar-Lezama, and Zenna Tavares. 2023. Combining functional and automata synthesis to discover causal reactive programs. Proceedings of the ACM on Programming Languages, 7(POPL):1628–1658. find
- Adele Diamond. 2013. Executive functions. Annual Review of Psychology, 64(1):135–168. find
- Yilun Du, Shuang Li, Antonio Torralba, Joshua B Tenenbaum, and Igor Mordatch. 2023. Improving factuality and reasoning in language models through multiagent debate. In Proceedings of International Conference on Machine Learning (ICML).
- Karl Duncker and Lynne S Lees. 1945. On problem-solving. Psychological Monographs, 58(5):i. find
- Linxi Fan, Guanzhi Wang, Yunfan Jiang, and 1 others. 2022. Minedojo: Building open-ended embodied agents with internet-scale knowledge. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS).
- Luyu Gao, Aman Madaan, Shuyan Zhou, Uri Alon, Pengfei Liu, Yiming Yang, Jamie Callan, and Graham Neubig. 2023. Pal: Program-aided language models. In Proceedings of International Conference on Machine Learning (ICML). find
- Zellig S Harris. 1954. Distributional structure. Word, 10(2-3):146–162. find
- Guangyuan Jiang, Manjie Xu, Shiji Xin, Wei Liang, Yujia Peng, Chi Zhang, and Yixin Zhu. 2023. Mewl: Few-shot multimodal word learning with referential uncertainty. In Proceedings of International Conference on Machine Learning (ICML). find
- Brenden M Lake, Tomer D Ullman, Joshua B Tenenbaum, and Samuel J Gershman. 2017. Building machines that learn and think like people. Behavioral and Brain Sciences, 40:e253. find
- Chengshu Li, Jacky Liang, Andy Zeng, Xinyun Chen, Karol Hausman, Dorsa Sadigh, Sergey Levine, Li Fei-Fei, Fei Xia, and Brian Ichter. 2024. Chain of code: Reasoning with a language model-augmented code emulator. In Proceedings of International Conference on Machine Learning (ICML). find
- Jacky Liang, Wenlong Huang, Fei Xia, Peng Xu, Karol Hausman, Brian Ichter, Pete Florence, and Andy Zeng. 2023. Code as policies: Language model programs for embodied control. In IEEE International Conference on Robotics and Automation (ICRA). find
- Bo Liu, Yuqian Jiang, Xiaohan Zhang, Qiang Liu, Shiqi Zhang, Joydeep Biswas, and Peter Stone. 2023. Llm+ p: Empowering large language models with optimal planning proficiency. arXiv preprint arXiv:2304.11477.
- John McCarthy. 1980. Circumscription—a form of non-monotonic reasoning. Artificial Intelligence, 13(1-2):27–39. find
- Ian R McKenzie, Alexander Lyzhov, Michael Martin Pieler, Alicia Parrish, Aaron Mueller, Ameya Prabhu, Euan McLean, Xudong Shen, Joe Cavanagh, Andrew George Gritsevskiy, and 1 others. 2023. Inverse scaling: When bigger isn’t better. Transactions on Machine Learning Research.
- Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg S Corrado, and Jeff Dean. 2013. Distributed representations of words and phrases and their compositionality. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS).
- Judea Pearl. 2009. Causality. Cambridge university press. find
- Noah Shinn, Federico Cassano, Ashwin Gopinath, Karthik Narasimhan, and Shunyu Yao. 2023. Reflexion: Language agents with verbal reinforcement learning. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS).
- Mohit Shridhar, Xingdi Yuan, Marc-Alexandre Cote, Yonatan Bisk, Adam Trischler, and Matthew Hausknecht. 2021. Alfworld: Aligning text and embodied environments for interactive learning. In Proceedings of International Conference on Learning Representations (ICLR).
- Elena Stringli, Maria Lymperaiou, Giorgos Filandrianos, Athanasios Voulodimos, and Giorgos Stamou. 2025. Pitfalls of scale: Investigating the inverse task of redefinition in large language models. arXiv preprint arXiv:2502.12821. find
- J Ridley Stroop. 1935. Studies of interference in serial verbal reactions. Journal of Experimental Psychology, 18(6):643. find
- Dídac Surís, Sachit Menon, and Carl Vondrick. 2023. Vipergpt: Visual inference via python execution for reasoning. In Proceedings of International Conference on Computer Vision (ICCV).
- Hao Tang, Darren Key, and Kevin Ellis. 2024a. Worldcoder, a model-based llm agent: building world models by writing code and interacting with the environment. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS). find
- Hao Tang, Darren Yan Key, and Kevin Ellis. 2024b. Worldcoder, a model-based llm agent: Building world models by writing code and interacting with the environment. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS). find
- Miles Turpin, Julian Michael, Ethan Perez, and Samuel Bowman. 2023. Language models don’t always say what they think: Unfaithful explanations in chain-of-thought prompting. Proceedings of Advances in Neural Information Processing Systems (NeurIPS).
- Fien van Wetten, Aske Plaat, and Max van Duijn. 2025. Baba is llm: Reasoning in a game with dynamic rules. arXiv preprint arXiv:2506.19095. find
- Guanzhi Wang, Yuqi Xie, Yunfan Jiang, Ajay Mandlekar, Chaowei Xiao, Yuke Zhu, Linxi Fan, and Anima Anandkumar. 2023a. Voyager: An open-ended embodied agent with large language models. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS). find
- Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, Sharan Narang, Aakanksha Chowdhery, and Denny Zhou. 2023b. Self-consistency improves chain of thought reasoning in language models. In Proceedings of International Conference on Learning Representations (ICLR).
- Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Fei Xia, Ed Chi, Quoc V Le, Denny Zhou, and 1 others. 2022. Chain-of-thought prompting elicits reasoning in large language models. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS).
- Lionel Wong, Gabriel Grand, Alexander K Lew, Noah D Goodman, Vikash K Mansinghka, Jacob Andreas, and Joshua B Tenenbaum. 2023. From word models to world models: Translating from natural language to the probabilistic language of thought. arXiv preprint arXiv:2306.12672. find
- Lionel Wong, Jiayuan Mao, Pratyusha Sharma, Zachary Siegel, Jiahai Feng, Noa Korneev, Joshua B Tenenbaum, and Jacob Andreas. 2024. Learning adaptive planning representations with natural language guidance. In Proceedings of International Conference on Learning Representations (ICLR). find
- Zhaofeng Wu, Linlu Qiu, Alexis Ross, Ekin Akyürek, Boyuan Chen, Bailin Wang, Najoung Kim, Jacob Andreas, and Yoon Kim. 2024. Reasoning or reciting? exploring the capabilities and limitations of language models through counterfactual tasks. In Annual Meeting of the Association for Computational Lingu… find
- Zhiheng Xi, Wenxiang Chen, Xin Guo, Wei He, Yiwen Ding, Boyang Hong, Ming Zhang, Junzhe Wang, Senjie Jin, Enyu Zhou, and 1 others. 2025. The rise and potential of large language model based agents: A survey. Science China Information Sciences, 68(2):121101.
- Manjie Xu, Guangyuan Jiang, Wei Liang, Chi Zhang, and Yixin Zhu. 2023. Active reasoning in an open-world environment. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS). find
- Manjie Xu, Xinyi Yang, Jiayu Zhan, Wei Liang, Chi Zhang, and Yixin Zhu. 2025. Heterogeneous adversarial play in interactive environments. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS). find
- Khurram Yamin, Gaurav Ghosal, and Bryan Wilder. 2025. Llms struggle to perform counterfactual reasoning with parametric knowledge. arXiv preprint arXiv:2506.15732. find
- Shunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran, Tom Griffiths, Yuan Cao, and Karthik Narasimhan. 2023a. Tree of thoughts: Deliberate problem solving with large language models. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS). find
- Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik R Narasimhan, and Yuan Cao. 2023b. React: Synergizing reasoning and acting in language models. In Proceedings of International Conference on Learning Representations (ICLR).
- Yue Zhang, Yafu Li, Leyang Cui, Deng Cai, Lemao Liu, Tingchen Fu, Xinting Huang, Enbo Zhao, Yu Zhang, Yulong Chen, and 1 others. 2025. Siren’s song in the ai ocean: A survey on hallucination in large language models. Computational Linguistics, pages 1–46.
- Jun Zhao, Yongzhuo Yang, Xiang Hu, Jingqi Tong, Yi Lu, Wei Wu, Tao Gui, Qi Zhang, and Xuanjing Huang. 2025. Understanding parametric and contextual knowledge reconciliation within large language models. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS). find
- Xizhou Zhu, Yuntao Chen, Hao Tian, Chenxin Tao, Weijie Su, Chenyu Yang, Gao Huang, Bin Li, Lewei Lu, Xiaogang Wang, and 1 others. 2023. Ghost in the minecraft: Generally capable agents for open-world environments via large language models with text-based knowledge and memory. arXiv preprint arXiv:23…
- Yixin Zhu, Tao Gao, Lifeng Fan, Siyuan Huang, Mark Edmonds, Hangxin Liu, Feng Gao, Chi Zhang, Siyuan Qi, Ying Nian Wu, and 1 others. 2020. Dark, beyond deep: A paradigm shift to cognitive ai with humanlike common sense. Engineering, 6(3):310– 345. find
- Environment Overview: Baba Is You A find
Updated
This page in Markdown → https://md.research.elamur.ai/free/en/papers/xu-2026-code-over-words-overcoming-semantic/