{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,8,20]],"date-time":"2026-08-20T06:23:35Z","timestamp":1787207015599,"version":"build-2736575974"},"reference-count":32,"publisher":"Frontiers Media SA","license":[{"start":{"date-parts":[[2026,8,20]],"date-time":"2026-08-20T00:00:00Z","timestamp":1787184000000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/"}],"content-domain":{"domain":["frontiersin.org"],"crossmark-restriction":true},"short-container-title":["Front. Artif. Intell."],"abstract":"<jats:p>Explainability is particularly challenging in legal prediction, where decisions are expected not only to be accurate but also to be justified under explicit legal norms and open to external scrutiny. Legal reasoning therefore provides one of the most demanding settings for explainable AI because a legal determination often depends on information distributed across the input record, external legal sources, procedural context, evidentiary assumptions, and institutional judgment. Direct outcome generation hides this decision path, while natural-language rationales and retrieved citations do not necessarily show whether a legal condition was actually applied. This article presents studies of retrieval-augmented codification as a way to produce executable explanation traces for legal large language model (LLM) predictions. The goal is not to generate human-facing rationales directly, but to produce auditable artifacts: short programs that extract signals, apply program-level conditions, follow branches, and produce final labels under a fixed output schema. The approach retrieves legal sources and fold-safe in-domain examples, compiles them into an executable intermediate representation, and refines the program using model feedback. The resulting trace records retrieved materials, generated conditions, feedback, and the final prediction. We evaluate this framework on five legal benchmarks covering Chinese criminal law, European human-rights cases, U.S. class-action complaints, Indian judgments, and Japanese tort cases. The evaluation asks not only whether the predicted label is correct, but also whether the explanation is executable, whether its conditions are supported by retrieved legal sources, whether it responds to legally material edits, and where it fails. The results show that executable explanations can be obtained without sacrificing predictive utility: the full codification setting improves mean label accuracy over direct prompting, chain-of-thought prompting, one-pass codification, and text-based retrieval baselines. More importantly, trace analysis reveals why legal explainability is difficult. Codification is most informative when decisions depend on definitions, thresholds, exceptions, and other rule-like components. It is less complete when benchmark labels depend on procedural, evidentiary, or discretionary factors outside the input record. These findings position retrieval-augmented codification as a practical explainable artificial intelligence (XAI) tool for studying when legal LLM predictions can be explained through explicit, source-supported decision paths.<\/jats:p>","DOI":"10.3389\/frai.2026.1905145","type":"journal-article","created":{"date-parts":[[2026,8,20]],"date-time":"2026-08-20T05:26:34Z","timestamp":1787203594000},"update-policy":"https:\/\/doi.org\/10.3389\/crossmark-policy","source":"Crossref","is-referenced-by-count":0,"title":["Executable explanation traces for legal LLM predictions via retrieval-augmented codification"],"prefix":"10.3389","volume":"9","author":[{"given":"Haoyang","family":"Chen","sequence":"first","affiliation":[{"name":"Department of Computer Science and Communications Engineering, School of Fundamental Science and Engineering, Waseda University","place":["Tokyo, Japan"]}],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"Kumiko","family":"Tanaka-Ishii","sequence":"additional","affiliation":[{"name":"Department of Computer Science and Communications Engineering, School of Fundamental Science and Engineering, Waseda University","place":["Tokyo, Japan"]}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"1965","published-online":{"date-parts":[[2026,8,20]]},"reference":[{"key":"B1","doi-asserted-by":"publisher","DOI":"10.1016\/j.inffus.2024.102303","article-title":"Adversarial attacks and defenses in explainable artificial intelligence: a survey","author":"Baniecki","year":"2023","journal-title":"arXiv"},{"key":"B2","doi-asserted-by":"crossref","first-page":"4317","DOI":"10.18653\/v1\/P19-1424","article-title":"\u201cNeural legal judgment prediction in English,\u201d","volume-title":"Proceedings of the 57th annual meeting of the association for computational linguistics","author":"Chalkidis","year":"2019"},{"key":"B3","first-page":"4310","article-title":"\u201cLexglue: a benchmark dataset for legal language understanding in English,\u201d","volume-title":"Proceedings of the 60th annual meeting of the association for computational linguistics","author":"Chalkidis","year":"2022"},{"key":"B4","article-title":"Understanding benchmark language under weakened formal semantics","author":"Chen","year":"2026","journal-title":"arXiv"},{"key":"B5","article-title":"Program of thoughts prompting: disentangling computation from reasoning for numerical reasoning tasks","author":"Chen","year":"2023","journal-title":"arXiv"},{"key":"B6","doi-asserted-by":"publisher","DOI":"10.1109\/ACCESS.2023.3317083","article-title":"A survey on legal judgment prediction: datasets, metrics, models and challenges","author":"Cui","year":"2022","journal-title":"arXiv"},{"key":"B7","article-title":"Opportunities and challenges in explainable artificial intelligence (XAI): a survey","author":"Das","year":"2020","journal-title":"arXiv"},{"key":"B8","doi-asserted-by":"publisher","first-page":"105696","DOI":"10.1016\/j.clsr.2022.105696","article-title":"Toward a practical legal rule revision in legal debugging","volume":"46","author":"Fungwacharakorn","year":"2022","journal-title":"Comput. Law Secur. Rev"},{"key":"B9","first-page":"10764","article-title":"\u201cPAL: program-aided language models,\u201d","volume-title":"Proceedings of the 40th international conference on machine learning, volume 202 of proceedings of machine learning research","author":"Gao","year":"2023"},{"key":"B10","article-title":"Retrieval-augmented generation for large language models: a survey","author":"Gao","year":"2024","journal-title":"arXiv"},{"key":"B11","doi-asserted-by":"publisher","DOI":"10.2139\/ssrn.4583531","article-title":"LegalBench: a collaboratively built benchmark for measuring legal reasoning in large language models","author":"Guha","year":"2023","journal-title":"arXiv"},{"key":"B12","article-title":"A dataset for statutory reasoning in tax law entailment and question answering","author":"Holzenberger","year":"2020","journal-title":"arXiv"},{"key":"B13","first-page":"9459","article-title":"\u201cRetrieval-augmented generation for knowledge-intensive NLP tasks,\u201d","volume-title":"Advances in neural information processing systems, Vol. 33","author":"Lewis","year":"2020"},{"key":"B14","first-page":"28259","article-title":"\u201cChain of code: reasoning with a language model-augmented code emulator,\u201d","volume-title":"Proceedings of the 41st international conference on machine learning, volume 235 of proceedings of machine learning research","author":"Li","year":"2024"},{"key":"B15","first-page":"4046","article-title":"\u201cILDC for CJPE: indian legal documents corpus for court judgment prediction and explanation,\u201d","volume-title":"Proceedings of the 59th annual meeting of the Association for Computational Linguistics and the 11th international joint conference on natural language processing (long papers), Vol. 1","author":"Malik","year":"2021"},{"key":"B16","article-title":"Legally-informed explainable AI","author":"Mansi","year":"2025","journal-title":"arXiv"},{"key":"B17","doi-asserted-by":"publisher","DOI":"10.1145\/3473582","article-title":"\u201cCatala: a programming language for the law,\u201d","author":"M\u00e9rigoux","year":"2021","journal-title":"Proceedings of the ACM on programming languages, 5(ICFP)"},{"key":"B18","author":"Mohun","year":"2020","journal-title":"Cracking the Code: Rulemaking for Humans and Machines"},{"key":"B19","doi-asserted-by":"publisher","first-page":"1759211","DOI":"10.3389\/frai.2026.1759211","article-title":"Audit-as-code: a policy-as-code framework for continuous AI assurance","volume":"9","author":"Muhammad","year":"2026","journal-title":"Front. Artif. Intell"},{"key":"B20","doi-asserted-by":"publisher","DOI":"10.18653\/v1\/2025.ijcnlp-long.92","article-title":"NyayaRAG: realistic legal judgment prediction with RAG under the Indian common law system","author":"Nigam","year":"2025","journal-title":"arXiv"},{"key":"B21","article-title":"Athena: retrieval-augmented legal judgment prediction with large language models","author":"Peng","year":"2024","journal-title":"arXiv"},{"key":"B22","article-title":"Argumentation-based explainability for legal AI: comparative and regulatory perspectives","author":"Prajescu","year":"2025","journal-title":"arXiv"},{"key":"B23","doi-asserted-by":"publisher","first-page":"17","DOI":"10.18653\/v1\/2025.nllp-1.3","article-title":"\u201cTowards reliable retrieval in RAG systems for large legal datasets,\u201d","author":"Reuter","year":"2025","journal-title":"Proceedings of the Natural Legal Language Processing Workshop 2025"},{"key":"B24","doi-asserted-by":"publisher","first-page":"1688209","DOI":"10.3389\/frai.2025.1688209","article-title":"Evaluating AI decision tools in Ecuador's courts: efficiency, consistency, and uncertainty in legal judgments","volume":"8","author":"Rodr\u00edguez-Salcedo","year":"2025","journal-title":"Front. Artif. Intell"},{"key":"B25","doi-asserted-by":"crossref","first-page":"31","DOI":"10.18653\/v1\/2022.nllp-1.3","article-title":"\u201cClassActionPrediction: a challenging benchmark for legal judgment prediction of class action cases in the US,\u201d","volume-title":"Proceedings of the natural legal language processing workshop 2022","author":"Semo","year":"2022"},{"key":"B26","doi-asserted-by":"crossref","first-page":"10014","DOI":"10.18653\/v1\/2023.acl-long.557","article-title":"\u201cInterleaving retrieval with chain-of-thought reasoning for knowledge-intensive multi-step questions,\u201d","volume-title":"Proceedings of the 61st annual meeting of the Association for Computational Linguistics (long papers), Vol. 1","author":"Trivedi","year":"2023"},{"key":"B27","doi-asserted-by":"publisher","first-page":"179","DOI":"10.26826\/law-in-context.v37i1.134","article-title":"Rules as code","volume":"37","author":"Waddington","year":"2021","journal-title":"Law Context"},{"key":"B28","first-page":"50058","article-title":"\u201cExecutable code actions elicit better LLM agents,\u201d","volume-title":"Proceedings of the 41st international conference on machine learning, voloum 235 of proceedings of machine learning research","author":"Wang","year":"2024"},{"key":"B29","first-page":"24824","article-title":"\u201cChain-of-thought prompting elicits reasoning in large language models,\u201d","volume-title":"Advances in neural information processing systems, Vol. 35","author":"Wei","year":"2022"},{"key":"B30","article-title":"CAIL2018: a large-scale legal dataset for judgment prediction","author":"Xiao","year":"2018","journal-title":"arXiv"},{"key":"B31","doi-asserted-by":"publisher","first-page":"783","DOI":"10.1007\/s10506-024-09402-0","article-title":"Japanese tort-case dataset for rationale-supported legal judgment prediction","volume":"33","author":"Yamada","year":"2025","journal-title":"Artif. Intell. Law"},{"key":"B32","article-title":"ReAct: synergizing reasoning and acting in language models","author":"Yao","year":"2023","journal-title":"arXiv"}],"container-title":["Frontiers in Artificial Intelligence"],"original-title":[],"link":[{"URL":"https:\/\/www.frontiersin.org\/articles\/10.3389\/frai.2026.1905145\/full","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2026,8,20]],"date-time":"2026-08-20T05:26:37Z","timestamp":1787203597000},"score":1,"resource":{"primary":{"URL":"https:\/\/www.frontiersin.org\/articles\/10.3389\/frai.2026.1905145\/full"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2026,8,20]]},"references-count":32,"alternative-id":["10.3389\/frai.2026.1905145"],"URL":"https:\/\/doi.org\/10.3389\/frai.2026.1905145","relation":{},"ISSN":["2624-8212"],"issn-type":[{"value":"2624-8212","type":"electronic"}],"subject":[],"published":{"date-parts":[[2026,8,20]]},"article-number":"1905145"}}