# SemLoc: Structured Grounding of Free-Form LLM Reasoning for Fault Localization

arXiv: https://arxiv.org/abs/2603.29109 · HTML: https://mlsanity.com/paper/2603.29109/

## Key facts

- No citing papers in the map yet (data through 14 Oct 2026).
- Placed in Reasoning for agents, planning and code, one of 17 directions in LLM reasoning.
- Builds on 10 of its 38 references that are in the map.
- First posted on arXiv 31 Mar 2026.

## Placed in

- LLM reasoning / [Reasoning for agents, planning and code](https://mlsanity.com/lr/reasoning-for-agents-planning-and-code/)

## Builds on (most cited first, 10 of 10)

- [Large Language Models are Zero-Shot Reasoners](https://mlsanity.com/paper/2205.11916/) (2022)
- [A Quantitative and Qualitative Evaluation of LLM-Based Explainable Fault Localization](https://mlsanity.com/paper/2308.05487/) (2023)
- [AgentFL: Scaling LLM-based Fault Localization to Project-Level Context](https://mlsanity.com/paper/2403.16362/) (2024)
- [BugsInPy: A Database of Existing Bugs in Python Programs to Enable Controlled Testing and Debugging Studies](https://mlsanity.com/paper/2401.15481/) (2024)
- [DeepStability: A Study of Unstable Numerical Methods and Their Solutions in Deep Learning](https://mlsanity.com/paper/2202.03493/) (2022)
- [Spectrum-based Software Fault Localization: A Survey of Techniques, Advances, and Challenges](https://mlsanity.com/paper/1607.04347/) (2016)
- [FlexFL: Flexible and Effective Fault Localization with Open-Source Large Language Models](https://mlsanity.com/paper/2411.10714/) (2024)
- [Simple Fault Localization using Execution Traces](https://mlsanity.com/paper/2503.04301/) (2025)
- [Procedural Refinement by LLM-driven Algorithmic Debugging for ARC-AGI-2](https://mlsanity.com/paper/2603.20334/) (2026)
- [Leveraging counterfactual concepts for debugging and improving CNN model performance](https://mlsanity.com/paper/2501.11087/) (2025)

## Abstract (arXiv)

Fault localization identifies program locations responsible for observed failures. Existing techniques rank suspicious code using syntactic spectra--signals derived from execution structure such as statement coverage, control-flow divergence, or dependency reachability. These signals collapse for semantic bugs, where failing and passing executions follow identical code paths and differ only in whether semantic intent is satisfied. Recent LLM-based approaches introduce semantic reasoning but produce stochastic, unverifiable outputs that cannot be systematically cross-referenced across tests or distinguish root causes from cascading effects. We present SemLoc, a fault localization framework based on structured semantic grounding. SemLoc converts free-form LLM reasoning into a closed intermediate representation that binds each inferred property to a typed program anchor, enabling runtime checking and attribution to program structure. It executes instrumented programs to construct a semantic violation spectrum--a constraint-by-test matrix--from which suspiciousness scores are derived analogously to coverage-based methods. A counterfactual verification step further prunes over-approximate constraints and isolates primary causal violations. We evaluate SemLoc on SemFault-250, a corpus of 250 Python programs with single semantic faults. SemLoc outperforms five coverage-, reduction-, and LLM-based baselines, achieving Top-1 accuracy of 42.8% and Top-3 of 68%, while reducing inspection to 7.6% of executable lines. Counterfactual verification provides an additional 12% accuracy gain and identifies primary causal semantic constraints.
