Skip to content

Menu

WorksComputer Science

Detecting Incorrect LLM Explanations for Automated Program Repair

Download PDFView on arXiv

Ask your agent about this work

Your agent reads this work through Valency, with its citations and similar works. Paste this at the start of a chat.

Use the Valency MCP. Work: W_6yxb7xhj. Fetch it with get_paper_by_id, then find its nearest works with find_similar_papers and tell me what it adds.

Works with any MCP client. Not connected yet? Connect your agent

Abstract

LLM-generated explanations help developers understand automated program repair (APR) rationale and assess patch quality. Incorrect explanations can mislead developers about a repair's reliability, making their detection important. However, manually inspecting the growing volume of generated repairs is impractical, motivating automated detection. Existing methods mainly target incorrect answers from general question-answering LLMs, often by sampling multiple responses and detecting contradictions. Applied to APR, they face two limitations: (1) they may depend on external verifiers that are unavailable or lack APR-specific reasoning; and (2) sampling strategies such as paraphrasing or re-prompting the same input often yield superficial, redundant responses that repeat the original error rather than expose it. We propose MetaReJ, the first method designed to detect incorrect APR explanations using metamorphic testing. Inspired by debate and viva examinations, MetaReJ challenges explanations through an argumentative strategy without requiring external verifiers. It applies novel metamorphic relations (MRs) to recursively question the LLM under equivalent and non-equivalent repair scenarios and detect contradictions. To obtain diverse samples, MetaReJ transforms the buggy program into variants that preserve or alter the underlying bug, then asks the LLM how to repair each variant. Contradictions among responses are encoded as MR violations, which indicate that the original explanation is incorrect. We evaluate MetaReJ on a manually labelled dataset of 1,756 explanations from multiple LLM-based APR systems. MetaReJ achieves an MCC of up to 0.43, outperforming prior methods by up to 333.3% in MCC.

Introduction

Large language models (LLMs) have advanced automated program repair (APR), achieving state-of-the-art (SOTA) repair success rates of up to 70% on existing benchmarks [1, 2, 3]. Despite this, developers still prefer to remain involved in the repair process, mainly due to the lack of trust in fully automated repairs [4, 5]. Building such trust requires developers to understand not only the generated patch, but also the rationale behind it [6, 7]. LLM-provided explanations offer a useful mechanism for communicating the LLM’s repair rationale to developers [8]. This helps developers assess the quality of the generated repairs [9]. The correctness of explanations may influence how developers act on the repairs. For example, incorrect explanations indicate unreliable repairs that fail to fix bugs and should be disregarded. Hence, detecting incorrect explanations is essential in LLM-based APR. However, it is overwhelming for developers to detect them manually, as the number of LLM-generated repairs continues to grow extensively [1, 2]. This creates a need for automated detection of incorrect explanations. Such automation reduces the number of explanations presented to developers, alleviates review burden, and facilitates the repair process.

No available method detects incorrect APR explanations. Most methods identify if the final answers of LLMs in general question-answering tasks are incorrect. These methods often sample multiple responses and identify if these responses contradict one another [10, 11]. For example, SelfCheck-GPT [10] re-prompts an LLM with the same query and compares the new responses with the original using semantic similarity metrics or external LLMs. MetaQA [11] and DrHall [12] paraphrase the response and identify contradictions among the paraphrased versions.

Unfortunately, existing methods are not well-suited or effective for APR explanations. We identify two key limitations. First, methods like SelfCheckGPT rely on external verifiers to identify contradictions. In APR, such verifiers often do not exist or lack APR-specific knowledge. Second, existing methods sample explanations by re-prompting LLMs with the same input or by paraphrasing the explanation. Such sampled explanations are often low-diversity or only superficially different at the word level. They may preserve incorrectness rather than revealing it through contradictions [11]. Exhaustively detecting incorrect explanations is a non-trivial task. Hence, we take a step toward mitigating manual review effort and facilitating the APR process. We achieve this by mitigating the two limitations. We propose MetaReJ, a new metamorphic testing method and the first approach for detecting incorrect APR explanations. To mitigate the first limitation, we adopt a metamorphic argumentative strategy to challenge the LLM’s explanation. Rather than relying on external verifiers, MetaReJ probes whether the LLM can defend itself under a series of recursive questions without providing contradictory responses. Intuitively, reliable reasoning for generating a correct explanation should transfer to and support these probing questions. In contrast, unreliable reasoning is more likely to surface as contradictions.

This argumentative strategy is inspired by debate and viva examination. A given claim is not directly judged by outside knowledge or understanding. The adopted strategy treats the claim as a premise. The claim-giver then responds to a series of recursive questions to determine whether later responses reinforce or contradict that premise. In this way, the claim-giver is challenged using their own claims, assumptions, or logic. Analogously, we treat the LLM as the claim-giver. The original explanation and patch are considered the claim. MetaReJ questions the LLM to generate sampled explanations and then to verify if these explanations apply to the original program. Metamorphic relations (MRs) are introduced to design such questions and represent the expected responses.

To mitigate the second limitation, we do not apply prior superficial sampling techniques. Instead, we apply diverse, non-redundant transformations at the program level. We transform the original buggy program in terms of syntax or semantics. We then sample explanations by asking the LLM how to fix the transformed programs. These explanations, referred to as follow-up explanations, will inevitably be transformed accordingly. This allows MetaReJ to mitigate the repetition of superficial or redundant sampled explanations.

We encode program transformations in two MRs to generate and evaluate follow-up explanations. [MR1] Explanations for fixing semantically equivalent programs apply to the original program. [MR2] Explanations for fixing semantically non-equivalent programs should not apply, as they have different bugs. The LLM is expected to satisfy these MRs.

Given these two MRs, MetaReJ performs the metamorphic argumentative strategy in three steps. First, it transforms the original buggy program using semantic-preserving and semantic-altering transformations. Second, it asks the LLM to generate follow-up explanations for fixing the transformed programs. Third, it asks the same LLM to evaluate if these explanations satisfy the MRs. Our key insight is that the LLM’s explanation is incorrect if the LLM’s responses are likely to violate the MRs. Such violations mean the LLM contradicts itself about fixing the buggy program, likely to generate an incorrect explanation.

To effectively adopt the metamorphic argumentative strategy, we also explicitly provide the LLM with the original patch as the context when generating follow-up explanations. This is the critical step: it prepares the LLM to be examined, sets up the premise, and anchors follow-up explanations to the same original patch. By doing so, contradictions can be unambiguously traceable back to the original explanation. Otherwise, the strategy may freely generate follow-up explanations that introduce brand new claims. These explanations are therefore less commensurable with the original one. This makes it difficult to determine if apparent contradictions are truly due to the original explanation or to the new claims. Hence, this weakens the logical foundation of the metamorphic argumentative strategy, as used in debate or viva examination.

As detecting incorrect APR explanations is not trivial, MetaReJ is designed to be high-precision while increasing the chances of detecting them. Its metamorphic argumentative strategy can improve precision by avoiding external verifiers, which introduce a new source of uncertainty that may cause false contradictions. MetaReJ derives contradictions from the LLM’s own reasoning, providing stronger evidence of incorrect explanations. The improvement in precision, however, comes with a potential loss in recall. MetaReJ may fail when the LLM is stubborn and consistently defends its incorrect reasoning. By using program transformations, we mitigate the second limitation but also compensate for the loss in recall and further strengthen it by diversifying the sampling.

To evaluate MetaReJ, we create a manually-labeled dataset of APR explanations. These explanations are collected from three SOTA systems: ThinkRepair [13], ReInFix [1], and MOREpair [14] on the respective bug datasets used in the original studies. These studies had already mitigated data leakage. We formulated the detection of incorrect explanations as a binary classification problem. Our experiments show that MetaReJ achieves on average Precision of 0.92, Recall of 0.64, and MCC (Matthew Correlation Coefficient [15]) of 0.39. It also outperforms the SOTA methods designed for general question-answering by up to 30.0% in Precision, 536.4% in Recall, and 333.3% in MCC.

Our main contributions can be summarised as follows:

  • The first benchmark of the correctness of explanations generated by LLM-based APR systems,

  • MetaReJ, the first approach that detects incorrect explanations of LLM-based APR systems,

  • A comprehensive evaluation of MetaReJ on the constructed benchmark, which shows that MetaReJ improves methods designed for general question-answering by up to 30.0% in Precision, 536.4% in Recall, 333.3% in MCC,

  • The dataset and implementation are available at https://doi.org/10.5281/zenodo.21059953.

Preliminary and Background

We show an example to motivate MetaReJ. We then introduce metamorphic testing, which forms a metamorphic argumentative strategy inspired by debate and viva examination.

Motivating Example

The left side of Figure 1 shows the buggy program getTextBuffer, also known as JacksonCore-8 in Defects4J [16]. The bug arises in how the single-segment case is handled: if (!_hasSegments) return _currentSegment;. When only one segment exists, the program returns _currentSegment without checking if it is null. To fix JacksonCore-8, ThinkRepair [13] and ReInFix [1], two SOTA LLM-based APR systems, generate two repairs A and B, respectively. In each repair, the system generates a patch and an explanation.

Figure 1. A motivating example: Two different repairs A and B (left side) generated by ThinkRepair [13] and ReInFix [1], respectively, for fixing JacksonCore-8 in Defects4J [16]. Repair A provides an incorrect explanation ExplA0 and a plausible but incorrect patch. Repair B provides both a correct explanation ExplB0 and a correct patch. MetaReJ can classify ExplA0 as incorrect and ExplB0 as correct (right side).

As expressed in natural language, the explanations are useful to help developers understand the repair rationale and review patch quality. ThinkRepair’s explanation, ExplA0, reveals its flawed reasoning, suggesting that this repair is unreliable. The if (!_hasSegments) branch is supposed to handle the single-segment case. ThinkRepair incorrectly thinks that returning _currentSegment is buggy in this case. In fact, if there is only one segment, _currentSegment may truly contain the correct content, and returning it is correct. On the other hand, ReInFix’s explanation, ExplB0, is correct. It correctly identifies the potential null pointer exception. The suggestion in this explanation is also correct, adding a null check on _currentSegment before returning it.

Based on the explanations, ReInFix’s repair is clearly more reliable than ThinkRepair’s. Indeed, ThinkRepair’s patch turns out to be incorrect, although it is plausible by passing all available test cases. In this case, the test cases may be incomplete and the patch is overfitting. In contrast, ReInFix’s patch is correct, successfully eliminating the bug.

This example demonstrates that incorrect explanations of LLM-based APR systems help developers disregard unreliable repairs. However, manually detecting them requires a lot of effort and is inherently impractical, given the growing number of LLM-generated repairs. This motivates the need for automated detection methods like MetaReJ to reduce developer effort.

The right side of Figure 1 illustrates MetaReJ’s meta-morphic argumentative strategy, where it correctly classifies ExplA0 as incorrect and ExplB0 as correct. First, it applies semantic-preserving and semantic-altering transformations to getTextBuffer to produce multiple transformed buggy programs Program1, Program2, ..., ProgramN¹. For instance, MetaReJ generates semantically equivalent Program1 by rewriting the code using nested if–else blocks. In contrast, MetaReJ generates semantically non-equivalent Program2 by changing _inputStart >= 0 to _inputStart > 0. Details about these transformed programs can be found in Supplementary Material A.

Under the two MRs, MetaReJ asks each APR system to explain how to fix the transformed programs. For example, ThinkRepair generates ExplA1 for Program1 and ExplA2 for Program2. ReInFix generates ExplB1 for Program1 and ExplB2 for Program2. ExplA1 and ExplB1 describe the same rationale as ExplA0 and ExplB0, respectively, while ExplA2 and ExplB2 illustrate rationales different from them. MetaReJ then asks each system if each follow-up explanation applies to the original getTextBuffer. We expect these systems to think that ExplA1 and ExplB1 also fix getTextBuffer, and ExplA2 and ExplB2 do not. However, ThinkRepair fails to satisfy these relations when assessing ExplA1 and ExplA2. It incorrectly answers “No” for ExplA1, thinking it is not applicable to getTextBuffer. It also incorrectly answers “Yes” for ExplA2, even though ExplA2 is derived from fixing a different bug. Since all ThinkRepair’s responses violate the two MRs, its violation score is 1. MetaReJ classifies ExplA0 as incorrect. In contrast, ReInFix’s responses consistently satisfy the MRs. ReInFix answers “Yes” for ExplB1 and “No” for ExplB2, as expected. Hence, its violation score is 0 and MetaReJ classifies ExplB0 as correct.

Metamorphic Testing

Metamorphic testing [17] addresses the oracle problem [18], where expected outputs are unavailable. Instead of directly verifying output correctness, it generates follow-up inputs and checks whether the resulting outputs satisfy predefined MRs. In this setting, the test oracle becomes if the MRs are satisfied.

Formally, an MR RR is a property between a set of inputs X={x1,x2,…,xn}X=\{x_1, x_2, \ldots, x_n\} and their outputs Y={f(x1),f(x2),…,f(xn)}Y=\{f(x_1), f(x_2), \ldots, f(x_n)\} for a function ff. It can be denoted as R⊆Xn×YnR \subseteq X^n \times Y^n [18]. Essentially, an MR specifies how a system should behave under specific transformations to the inputs. If the system’s outputs violate the MRs, it indicates that the system may produce incorrect outputs.

MRs have been applied in traditional software testing [18], [19]. More recently, research has defined MRs to classify the factual correctness of information produced by NL question-answering systems, including LLMs [11], [12], [20], [21]. However, their application to explanation correctness, particularly in coding tasks like APR, remains underexplored.

As far as we know, this work is the first to leverage MRs to detect incorrect APR explanations. Inspired by debate and viva examination, we introduce a metamorphic argumentative strategy that exposes contradictions in an LLM’s responses. MRs design recursive questions to challenge the LLM and encode its expected responses. MR violations represent contradictions in the LLMs’ bug-fixing reasoning. Such violations are more likely when the original explanation is incorrect.

MetaReJ: The Proposed Detection Method

In this section, we describe MetaReJ, the first method for detecting incorrect APR explanations. MetaReJ adopts a metamorphic argumentative strategy. This strategy is inspired by debate and viva examination, where a claim acts as a premise under examination. In APR, the LLM is considered the claim-giver; the original repair is treated as the claim.

Let mm represent the LLM-based APR system under test. We denote by Prog⁡\operatorname{Prog} the set of programs that implement a function, and by Expl⁡\operatorname{Expl} the set of textual explanations that describe LLM reasoning. Let x∈Prog⁡x \in\operatorname{Prog} be the buggy program, r∈Expl⁡r \in\operatorname{Expl} be the original explanation, and y∈Prog⁡y \in\operatorname{Prog} be the original patch. In this case, the repair (r,y)(r,y) can be considered as the given claim. Given this repair, MetaReJ’s goal is to detect if the generated explanation rr is incorrect.

Figure 2 illustrates the process of MetaReJ. It recursively questions the LLM under equivalent and non-equivalent repair scenarios, and exposes contradictions in the LLM’s responses. The process consists of four main steps: program transformation, follow-up explanation generation, follow-up explanation verification, and violation score calculation. These steps are described in III-A, III-B, III-C, and III-D, respectively.

Figure 2. An explanation and patch are generated by the LLM under test for fixing the buggy program. MetaReJ performs the metamorphic argumentative strategy to determine if the explanation is incorrect. First, it transforms the buggy program into multiple equivalent and non-equivalent variants. Next, MetaReJ asks the LLM to explain how to fix each transformed variant, given the originally generated patch as the argumentative context. This produces a set of follow-up explanations. MetaReJ then asks the LLM whether each follow-up explanation applies to the original buggy program. Based on whether the LLM’s responses violate the MRs, MetaReJ calculates a violation score and uses it to detect if the original explanation is incorrect.

Program Transformation

This step aims to transform the original buggy program xx into a diverse set of semantically equivalent and non-equivalent buggy programs. We define Tran⁡eq\operatorname{Tran}_{eq} and Tran⁡neq\operatorname{Tran}_{neq} for preserving and altering the semantics of a program, respectively. They are modeled as two functions that map each program be the original explanation, and y∈Prog⁡y \in\operatorname{Prog} be the original patch. In this case, the repair (r,y)(r,y) can be considered as the given claim. Given this repair, MetaReJ’s goal is to detect if the generated explanation rr is incorrect.

Figure 2 illustrates the process of MetaReJ. It recursively questions the LLM under equivalent and non-equivalent repair scenarios, and exposes contradictions in the LLM’s responses. The process consists of four main steps: program transformation, follow-up explanation generation, follow-up explanation verification, and violation score calculation. These steps are described in III-A, III-B, III-C, and III-D, respectively.

Program Transformation

This step aims to transform the original buggy program xx into a diverse set of semantically equivalent and non-equivalent buggy programs. We define Tran⁡eq\operatorname{Tran}_{eq} and Tran⁡neq\operatorname{Tran}_{neq} for preserving and altering the semantics of a program, respectively. They are modeled as two functions that map each program x∈Progx \in\mathrm{Prog} to a corresponding set over Prog\mathrm{Prog}. Formally, for all x∈Progx \in\mathrm{Prog}:

Traneqv:x↦{xeqv′∈Prog∣x≡xeqv′}(1)\mathrm{Tran}_{eqv}: x \mapsto\{x'_{eqv} \in\mathrm{Prog} \mid x \equiv x'_{eqv}\} \tag*{(1)}
Tranneq:x↦{xneq′∈Prog∣x≢xneq′}(2)\mathrm{Tran}_{neq}: x \mapsto\{x'_{neq} \in\mathrm{Prog} \mid x \not\equiv x'_{neq}\} \tag*{(2)}

A transformed program sampled from Traneqv\mathrm{Tran}_{eqv} or Tranneq\mathrm{Tran}_{neq} for xx is thus modeled by a variable as follows:

xeqv′∈Traneqv(x)(3)x'_{eqv} \in\mathrm{Tran}_{eqv}(x) \tag*{(3)}
xneq′∈Tranneq(x)(4)x'_{neq} \in\mathrm{Tran}_{neq}(x) \tag*{(4)}

where xeqv′x'_{eqv} is semantically equivalent to xx, sharing the same underlying bug, while xneq′x'_{neq} is not.

Program transformations have been extensively studied in prior research, including APR [22]. Hence, we reuse the existing transformations. Ultimately, we select 40 semantic-preserving and 20 semantic-altering transformations. Supplementary Material C describes the detailed process of collecting transformations, and provides the list of transformations.

MetaReJ aggregates the selected transformations to generate transformed programs. To validate the transformed programs, we compile and run them against the available test cases. Equivalent programs are expected to fail the same test cases as the original buggy program, whereas non-equivalent programs should fail different test cases. Programs that do not satisfy this criterion are discarded. The remaining programs are then used for follow-up explanation generation.

Follow-up Explanation Generation

Given the curated transformed programs, MetaReJ instructs the LLM mm to generate follow-up explanations. This process is designed to simulate the argumentative strategy used in debates or viva examinations. To effectively adopt this strategy, the claim-giver must be aware of the claim as a premise. Otherwise, the claim-giver may bring up new claims that bear no logical relationship to the premise. It is difficult to determine if contradictions stem from the original or the new claims. This weakens the logical foundation of the argumentative strategy. Hence, we do not repeat the original repair pipeline to produce follow-up explanations. We design a repair sub-task that prepares the LLM for the argumentative strategy. It explicitly provides the original patch yy as the context to set up the premise and anchor follow-up explanations to yy.

We denote this sub-task by Explain⁡m(x′,y)\operatorname{Explain}_{m}(x', y) as a function that maps each pair of a transformed buggy program x′∈Progx' \in\mathrm{Prog} and the originally generated patch y∈Progy \in\mathrm{Prog} to a follow-up explanation r′∈Explr' \in\mathrm{Expl}. Formally, for all (x′,y)∈Prog×Prog(x',y) \in\mathrm{Prog} \times\mathrm{Prog}:

Explain⁡m:(x′,y)↦r′∈Expl(5)\operatorname{Explain}_{m}: (x',y) \mapsto r' \in\mathrm{Expl} \tag*{(5)}

where x′=xeqv′∈Traneqv(x)x' = x'_{eqv} \in\mathrm{Tran}_{eqv}(x) or x′=xneq′∈Tranneq(x)x' = x'_{neq} \in\mathrm{Tran}_{neq}(x).

To implement Explain⁡m(x′,y)\operatorname{Explain}_{m}(x', y), we embed the original patch yy directly into the prompt and ask mm to explain how to fix the transformed program x′x' based on the given patch yy. Supplementary Material D shows the prompt template for follow-up explanation generation for transformed programs.

Follow-up Explanation Verification

In this step, MetaReJ asks the LLM under test mm to verify whether each follow-up explanation r′r' applies to the original buggy program xx. We model this verification task performed by mm as Verify⁡m\operatorname{Verify}_{m}. It is a function that maps a pair of the follow-up explanation r′∈Explr' \in\mathrm{Expl} and the buggy program x∈Progx \in\mathrm{Prog} to B={0,1}\mathbb{B} = \{0,1\}. The value of 1 indicates that the model mm thinks the explanation r′r' can be applied to the program xx, and 0 otherwise. Formally, for all (r′,x)∈Expl×Prog(r',x) \in\mathrm{Expl} \times\mathrm{Prog}:

Verify⁡m:(r′,x)∈Expl×Prog↦{0,1}(6)\operatorname{Verify}_{m}: (r',x) \in\mathrm{Expl} \times\mathrm{Prog} \mapsto\{0,1\} \tag*{(6)}

This verification task can be performed through a straightforward question-answering process. Specifically, MetaReJ uses a prompt-based method that allows the LLM mm itself to rigorously assess whether the explanation is applicable to the buggy program. The prompt template shown in Supplementary Material D is used to guide the LLM in generating precise responses to enhance the overall reliability of MetaReJ.

If the original explanation rr is correct, the follow-up explanations derived from equivalent programs are expected to return “Yes” when verified, and those derived from non-equivalent programs should return “No.” When the LLM is uncertain about the correctness of a follow-up explanation, MetaReJ instructs it to return “Not Sure.”

Violation Score Calculation

The goal of this step is to enhance the testing of LLM explanations by analyzing the violations of the two MRs. The MRs can be modeled as follows.

MR1. Explanations derived from equivalent programs that lead to the same patch also apply to the original program.

Verify⁡m(reqv′,x)=1(7)\operatorname{Verify}_{m}(r'_{eqv},x) = 1 \tag*{(7)}

where reqv′=Explain⁡m(xeqv′,y)r'_{eqv} = \operatorname{Explain}_{m}(x'_{eqv}, y) and xeqv′∈Traneqv(x)x'_{eqv} \in\mathrm{Tran}_{eqv}(x). Violating MR1 means while mm fixes a program semantically equivalent to xx using reqv′r'_{eqv}, mm does not think reqv′r'_{eqv} is applicable to xx.

MR2. Explanations derived from non-equivalent programs do not apply to the original program.

Verify⁡m(rneq′,x)=0(8)\operatorname{Verify}_{m}(r'_{neq},x) = 0 \tag*{(8)}

where rneq′=Explain⁡m(xneq′)r'_{neq} = \operatorname{Explain}_{m}(x'_{neq}) and xneq′∈Tranneq(x)x'_{neq} \in\mathrm{Tran}_{neq}(x). Violating MR2 means that mm believes both rneq′r'_{neq} and rr are applicable to xx, even though they are derived from fixing semantically different programs.

For the same LLM mm, verifying explanations is inherently no more difficult than generating a correct one. This is because, from a complexity perspective [23], explanation generation requires mm to search over an extremely large space to produce a correct explanation. Therefore, if mm generates a correct explanation, it will provide verification results satisfying the expected outcome specified by the MRs. Our empirical results in Supplementary Material B support this assumption. When the LLM generates a correct explanation, it verifies explanations correctly with a probability of 0.90 (close to 1). Moreover, verification failures are rare when the LLM generates correct explanations, while verification still often succeeds even when the LLM generates incorrect explanations. These results show that verifying explanations is almost always no more difficult than generating them. Hence, verification failures, which are encoded as MR violations, strongly imply that the LLM generates an incorrect explanation.

(Verify⁡m(reqv′,x)=0∨Verify⁡m(rneq′,x)=1)⟹“r is incorrect”(9)\left(\operatorname{Verify}_{m}(r'_{eqv},x)=0 \lor \operatorname{Verify}_{m}(r'_{neq},x)=1\right) \Longrightarrow\text{“}r\text{ is incorrect”} \tag*{(9)}

We define the violation score of the two MRs as follows.

Vm(r,x):=P(Verify⁡m(reqv′,x)=0∨Verify⁡m(rneq′,x)=1)(10)\mathcal{V}_{m}(r,x) := \mathbb{P}\left(\operatorname{Verify}_{m}(r'_{eqv},x)=0 \lor\operatorname{Verify}_{m}(r'_{neq},x)=1\right) \tag*{(10)}

Based on this, the violation score provides a lower bound on the incorrectness probability:

Vm(r,x)≤P(“r is incorrect”)(11)\mathcal{V}_{m}(r,x) \leq\mathbb{P}(\text{“}r\text{ is incorrect”}) \tag*{(11)}

Supplementary Material B provides detailed theoretical and empirical proofs. In this study, we consider rr as incorrect if Vm(r,x)>θ\mathcal{V}_{m}(r,x)>\theta, implying P(“r is incorrect”)≥θ\mathbb{P}(\text{“}r\text{ is incorrect”})\geq\theta. Consequently, this approach provides a statistically sound way to identify incorrect explanations without access to ground truths.

Practical consideration: Program transformations Tr⁡aneqv\operatorname{Tr}_{aneqv} and Tr⁡anneq\operatorname{Tr}_{anneq} are typically inexpensive. However, generating follow-up explanations Explain⁡m\operatorname{Explain}_{m} may be costly, as it requires querying the LLM multiple times. To reduce this cost, we adopt a fixed sampling budget strategy. Given a budget N×2N \times2, we draw NN follow-up explanations for NN equivalent programs and NN follow-up explanations for NN non-equivalent ones. To enhance the diversity of this sampling, MetaReJ selects the most representative transformed programs. It clusters each list of equivalent and non-equivalent transformed programs into NN clusters, and randomly chooses one in each cluster as a representative example. Details about the clustering process are provided in Supplementary Material F-1. The value of NN will be analysed through a sensitivity analysis in RQ4.

Given the budget NN, we define an empirical violation score V^m\hat{\mathcal{V}}_{m} that approximates Vm\mathcal{V}_{m} described in Equation (10).

V^m(r,x,N)=1N×2(∑i=1NI[Verify⁡m(rneqi′,x)=1]+∑j=1NI[Verify⁡m(reqvj′,x)=0])(12)\hat{\mathcal{V}}_{m}(r,x,N)=\frac{1}{N\times2}\left(\sum_{i=1}^{N}\mathbb{I}\left[\operatorname{Verify}_{m}(r'_{neq_i},x)=1\right]+\sum_{j=1}^{N}\mathbb{I}\left[\operatorname{Verify}_{m}(r'_{eqv_j},x)=0\right]\right) \tag*{(12)}

where I[⋅]\mathbb{I}[\cdot] is the indicator function, which returns 1 when the predicate holds and 0 otherwise. Let v∈{“Yes”, “Not Sure”, “No”}v \in\{\text{“Yes”, “Not Sure”, “No”}\} represent the verification response for the follow-up explanation r′r'. I[⋅]\mathbb{I}[\cdot] only returns 0 or 1, while vv can receive three values. To map these values, we design a mechanism that assigns a numeric score for each follow-up explanation on a scale of [0,1][0,1] based on its verification response vv. “Not Sure” is considered equally likely to indicate whether the explanation is correct or not, thus receiving a score of 0.5. The scores are mapped as follows:

I[⋅]={1.0if (reqv′ and v=No) or (rneq′ and v=Yes)0.5if v=Not Sure0.0if (reqv′ and v=Yes) or (rneq′ and v=No)\mathbb{I}[\cdot]= \begin{cases} 1.0 & \text{if }(r'_{eqv}\text{ and }v=\text{No})\text{ or }(r'_{neq}\text{ and }v=\text{Yes})\\ 0.5 & \text{if }v=\text{Not Sure}\\ 0.0 & \text{if }(r'_{eqv}\text{ and }v=\text{Yes})\text{ or }(r'_{neq}\text{ and }v=\text{No}) \end{cases}

The empirical violation score approximates the original violation score while avoiding repeated expensive LLM queries. As NN increases, the estimation of the violation score becomes more faithful. While this approximation introduces some additional variance, it is highly effective in practice [10, 11]. It amortizes LLM sampling costs across many evaluations, enabling scalable violation estimation.

According to Equation (11), we consider the original explanation rr as incorrect if V^m>θ\hat{\mathcal{V}}_{m}>\theta. The value of the threshold θ\theta will be identified through sensitivity analysis in RQ4.

Experimental Design

We study the following research questions (RQs):

RQ1. To what extent do SOTA LLM-based APR systems produce incorrect explanations?

RQ2. How effective is MetaReJ in detecting incorrect explanations of LLM-based APR systems?

RQ3. How efficient is MetaReJ in detecting incorrect explanations of LLM-based APR systems?

RQ4. How do the parameters NN and θ\theta impact MetaReJ?

RQ5. How does each component influence MetaReJ?

To measure detection quality, we use standard binary classification metrics. In particular, we adopt the Matthews Correlation Coefficient (MCCMCC) as it considers all four components of the confusion matrix, and produces more reliable statistical results than F1-score [15]. We also report Balanced Accuracy (BABA), Precision (PrePre), Recall (RecRec), also known as True Positive Rate, and Specificity (SpeSpe), also known as True Negative Rate. To measure efficiency, we report the number of input tokens, output tokens, and total tokens.

Hyperparameters

In MetaReJ, we set the LLM’s temperature to 0 when generating and verifying follow-up explanations to enhance stability. RQ4 investigates the optimal values of NN and θ\theta, while other RQs use their default values, 5 and 0.5, respectively. The implementation of program transformations is reused from Le et al.’s work [22]. We performed three runs per experiment.

Baselines for Detecting Incorrect Explanations

Several detection approaches rely on databases, search engines [24], or internal access to LLMs [25]. As they are often unavailable, these approaches are unsuitable as baselines. Consequently, we compare MetaReJ with the following methods.

  • SelfCheckGPT [10]: an SOTA task-agnostic, zero-resource approach for checking the correctness of an LLM’s response. It repeatedly queries the LLM to generate multiple samples and measures their consistency with the original response. Following the prior setting [11], we

set the LLM’s temperature to 0.5 when sampling, which yields the best performance.

  • MetaQA [11]: a method for detecting incorrect facts generated by an LLM for general question-answering. It paraphrases the originally generated fact, then checks if the paraphrases remain valid. For APR, we adapt MetaQA by using the LLM under test to paraphrase the original explanation. We use the same setting as the original study.

  • DrHall [12]: a metamorphic testing method for detecting incorrect facts generated by an LLM for general question-answering. Since most of its MRs are not applicable to APR, we only consider AMR1, which asks the LLM a follow-up question “[Original Answer] Is this statement not true?” We use the same setting as the original study.

  • SelfCheck w/ ProgTrans: an extension of SelfCheckGPT. It samples responses using transformed programs instead of re-querying the LLM with the same input. It uses the same set of transformed programs as MetaReJ.

Studied Models (LLMs Under Test)

We aim to select LLM-based APR systems published within the past five years at top venues in SE, such as conferences (e.g., ICSE, FSE, ASE, ISSTA) and journals (e.g., TOSEM, TSE, EMSE). We focus specifically on systems that can produce explanations. At the time of writing, only a limited number of such systems are available, as most existing systems only generate patches. Three systems are selected:

  • ThinkRepair [13]: A self-directed LLM-based APR approach. ThinkRepair first gathers CoTs as repair knowledge. It then repairs bugs via few-shot example selection, iterative LLM interaction, and testing feedback. We use CodeLlama 13B as the underlying model, the best-performing open-source LLM in the original study.

  • ReinFix [1]: An agentic framework that enables LLMs to autonomously search for repair ingredients throughout both the reasoning and solution phases of bug fixing. ReinFix employs GPT-4o as the underlying LLM.

  • MORepair [14]: A novel perspective on LLM fine-tuning for APR. It not only adapts model parameters to the syntactic nuances of code transformation but also finetunes the model to capture the underlying logic behind code changes in the training data. We use CodeLlama 13B as the underlying LLM, as in the original study.

Benchmark Construction

To answer RQ1, we constructed a benchmark of the correctness of explanations generated by LLM-based APR systems.

1) Data leakage: All three original studies [1, 13, 14] evaluated their APR systems on Defects4J [16]. To mitigate potential data leakage, they also evaluated their systems on benchmarks constructed after the LLMs’ cutoff dates. ThinkRepair and ReinFix were evaluated on RWB [13], while MORepair was evaluated on SWE-Repair (a subset of SWE-Bench [26]), EvalRepair-C++, EvalRepair-Java [14]. Regardless, as we do not train an LLM and program transformations are used, data leakage has limited impact on MetaReJ.

**2) Prediction collection: ** The original evaluations of the studied systems have already performed data cleaning to avoid data leakage. Therefore, we directly replicated their experiments using the original settings. Specifically, both ThinkRepair and ReinFix were evaluated on Defects4J and RWB datasets, producing 556 and 720 repairs. MORepair was evaluated on Defects4J, EvalRepair-C++, EvalRepair-Java, and SWE-Repair, producing 902 repairs.

**3) Data cleaning: ** We excluded incomplete responses, resulting in 432, 711, and 615 completed responses from ThinkRepair, ReinFix, and MORepair, respectively. We further removed duplicates based on their MD5 hash code. Ultimately, we curated 1,756 responses of patches and explanations, including 431, 711, and 614 from ThinkRepair, ReinFix, and MORepair, respectively.

**4) Data Labeling: ** In this step, we labeled the correctness of 1,756 APR explanations. Two annotators, each with 3–5 years of experience in programming and program repair, were assigned to independently label them. For each explanation, the annotators were given the buggy program, the developer’s patch, the LLM’s explanation, the LLM’s patch, and the auxiliary information such as the bug report and triggering tests. They were instructed to review these artifacts to understand the bug. Then, they judged whether the explanation is correct and indicated their confidence on a five-point Likert scale. If one of them was unsure or the two annotators disagreed, a third annotator with over five years of relevant experience participated in the discussion to reach a consensus. Details about the labeling process are described in Supplementary Material E. Table 1 shows the final results.

APR System Under Test# Expls# Correct Expls# Incorrect ExplsIncorrect Expl Rate
ThinkRepair [13]4315437787.5%
ReinFix [1]71130540657.1%
MORepair [14]61418043470.7%
Total1,7565391,21769.3%

Table 1. Benchmarking explanations generated by LLM-based APR systems

Experimental Results

RQ1: Benchmark

The annotation process achieves a Cohen’s Kappa value [27] for inter-annotator agreement of 0.78, indicating substantial consistency and reliability. This has significantly bolstered our confidence in both the benchmark’s quality and the evaluation of the detection approach, MetaReJ.

Table 1 shows the results of the labeling process. It is clear that many generated explanations are incorrect. Among 1,756 explanations produced, 1,217 are incorrect, accounting for 69.3% of all explanations. This shows that the systems are still highly unreliable for explaining their repairs, even the best-performing agentic system, ReinFix. A breakdown of the benchmark is shown in Supplementary Material F-3.

RQ1: All APR systems frequently generate incorrect explanations, with an overall incorrect rate of 69.3%.

RQ2: Detection Effectiveness of MetaReJ

In RQ2, we examine whether MetaReJ can achieve better effectiveness in detecting correct explanations than the baselines. Table II compares their effectiveness across three LLM-based APR systems: ThinkRepair, ReInFix, and MORepair.

APR System Under Test# ExplsDetectorMCC↑ΔMCC↑BA↑Pre↑Rec↑Spe↑InputOutputTotal
ThinkRepair [13]431SelfCheckGPT [10]0.05*-50.0%0.53*0.89*0.38*0.68⋄8.964.8913.85
ThinkRepair [13]431SelfCheck w/ ProgTrans0.10*0%0.56*0.89*0.750.36*9.154.9714.12
ThinkRepair [13]431MetaQA [11]-0.02*-120.0%0.49*0.87*0.37*0.61*4.062.556.61
ThinkRepair [13]431DrHall [12]-0.06*-160.0%0.49*0.87*0.98*0.00*0.290.170.46
ThinkRepair [13]431MetaReJ (ours)0.34+240.0%0.750.960.720.779.195.2014.39
ThinkRepair [13]431MetaReJ w/ ext. Claude0.25*+150.0%0.68*0.920.75⋄0.60*9.305.1114.41
ThinkRepair [13]431MetaReJ w/o non-eqv.0.08*-20.0%0.56*0.92⋄0.31*0.80*4.542.577.11
ThinkRepair [13]431MetaReJ w/o eqv.0.23*+130.0%0.64*0.91*0.83*0.45*4.652.637.28
ReInFix [1]711SelfCheckGPT [10]0.17*0%0.54*0.92*0.09*0.99⋄30.412.5232.93
ReInFix [1]711SelfCheck w/ ProgTrans-0.07*-141.2%0.47*0.55*0.70*0.24*32.582.4535.03
ReInFix [1]711MetaQA [11]0.16*-5.9%0.57*0.72*0.27*0.86⋄7.434.6712.1
ReInFix [1]711DrHall [12]0.12*-29.4%0.54*0.72*0.19*0.90*0.520.280.80
ReInFix [1]711MetaReJ (ours)0.43+152.9%0.700.880.500.9115.088.6023.68
ReInFix [1]711MetaReJ w/ ext. Claude0.29*+70.6%0.64*0.76*0.480.80*15.127.3522.47
ReInFix [1]711MetaReJ w/o non-eqv.0.20*+17.6%0.57*0.79*0.23*0.927.594.1111.70
ReInFix [1]711MetaReJ w/o eqv.0.18*+5.9%0.58*0.63*0.77*0.40*7.494.4911.98
MORepair [14]614SelfCheckGPT [10]0.09*0%0.53*0.84*0.11*0.95*9.315.1214.43
MORepair [14]614SelfCheck w/ ProgTrans-0.14*-255.6%0.45*0.68*0.82*0.07*9.395.2514.64
MORepair [14]614MetaQA [11]-0.01*-111.1%0.50*0.70*0.48*0.51*5.155.8611.01
MORepair [14]614DrHall [12]0.08*-11.10.54*0.75*0.45*0.64⋄0.330.590.92
MORepair [14]614MetaReJ (ours)0.39+333.3%0.710.910.700.729.448.5017.94
MORepair [14]614MetaReJ w/ ext. Claude0.36⋄+300.0%0.700.83*0.79⋄0.60*10.347.4117.75
MORepair [14]614MetaReJ w/o non-eqv.0.06*–33.3%0.52*0.79*0.11*0.93*4.243.858.09
MORepair [14]614MetaReJ w/o eqv.0.02*-77.8%0.50*0.71*0.92*0.09*5.204.659.85

Table II. The effectiveness in detecting incorrect APR explanations of MetaReJ and the other methods. Abbreviations: MCC = Matthews Correlation Coefficient, ΔMCC: Relative MCC Improvement Over the Best Baseline, BA = Balanced Accuracy, Pre = Precision, Rec = Recall, Spe = Specificity. Paired t-test between MetaReJ and other methods, with ⋄: p-value < 0.05, *: p-value < 0.01.

Overall, the baselines achieve poor effectiveness. SelfCheckGPT is the strongest baseline on ReInFix and MORepair in terms of MCC (0.17 and 0.09, respectively). The main issue is its low Recall of 0.09–0.38, despite high Specificity of 0.69–0.99. This means SelfCheckGPT misclassifies many incorrect explanations as correct. MetaQA is generally unstable and close to random. It achieves MCC of -0.02–0.01 on ThinkRepair and MORepair, only getting better MCC of 0.16 on ReInFix. MetaQA’s Recall is low (0.27–0.48), showing that it misses many incorrect explanations. DrHall is the poorest baseline, with MCC of -0.06–0.12.

Adding program transformations into SelfCheckGPT, as expected, improves Recall by 97.4%–677.8% but severely hurts Specificity by 47.1%–92.6%. This causes MCC to become negative on ReInFix (-0.07) and MORepair (-0.14). SelfCheck w/ ProgTrans tends to over-detect explanations as incorrect, failing to identify many correct ones.

In contrast, MetaReJ consistently achieves strong effectiveness across the APR systems. It achieves 0.34–0.43 in MCC and 0.70–0.75 in BA. Compared with the best baseline on each APR system, MetaReJ improves MCC substantially by up to 580.0%. MetaReJ maintains relatively higher Precision of 0.88–0.96 and much higher Recall of 0.50–0.72. These results contrast with SelfCheckGPT and MetaQA, with lower Precision and Recall, and DrHall, which can achieve high Precision and Recall by always classifying explanations as incorrect. Therefore, MetaReJ provides a better balance between detecting incorrect explanations.

RQ2: MetaReJ consistently outperforms the baselines in detection quality across all APR systems and bug datasets. It achieves an improvement of up to 333.3% in MCC over SelfCheckGPT, the best detection baseline.

RQ3: Token Usage

Since MetaReJ involves multiple rounds of LLM queries, it may consume more tokens than direct LLM prompts. We quantify this increase and investigate the trade-off between token use and detection quality. Table II provides the token usage across detectors and APR systems. For each detector, we measure the input tokens, the output tokens, and total tokens.

SelfCheckGPT and SelfCheck w/ ProgTrans consume tokens comparable to MetaReJ on ThinkRepair and MORepair. On ReInFix, they consume 0.48 times more tokens on average than MetaReJ, due to the design of ReInFix’s query. MetaReJ consumes 0.92 times more tokens than MetaQA and 25.79 times more tokens than DrHall, two more direct prompting methods. These results reveal a clear trade-off between computational cost and detection effectiveness. MetaReJ consumes comparable or more tokens than most baselines, but justifies that cost by superior detection effectiveness.

RQ3: MetaReJ consumes similar or even fewer tokens than SelfCheckGPT by 0.39 times. It consumes 0.92 times more tokens than MetaQA and 25.79 times more tokens than DrHall. MetaReJ’s superior performance boost sometimes comes at the cost of increased token usage.

Sensitivity Analysis

RQ4 further investigates the sensitivity of MetaReJ to two thresholds, θ\theta and NN, across the APR systems. Figure 3 shows MetaReJ’s effectiveness with different values of θ\theta. Across all APR systems, MetaReJ achieves the best MCC consistently around θ=0.5\theta=0.5. When θ\theta is small, Precision remains low, while Recall is high. This indicates that MetaReJ relaxes the detection condition and tends to detect explanations as incorrect. As θ\theta increases, Precision improves rapidly while Recall decreases. However, after θ=0.5\theta=0.5, Recall drops substantially, meaning that more incorrect explanations are misclassified as correct. This degradation is reflected in MCC, which decreases after θ=0.5\theta=0.5 for all systems. These results suggest that θ=0.5\theta=0.5 provides the best detection for incorrect explanations.

Three line charts showing MCC, Precision, and Recall across threshold $\theta$ values for ThinkRepair, ReInFix, and MORepair

Figure 3. MetaReJ’s effectiveness with different values of θ\theta across three APR systems: ThinkRepair, ReInFix, and MORepair.

Figure 4 shows MetaReJ’s effectiveness with different values of NN. Increasing NN generally improves MCC and Precision across all three APR systems, while Recall changes only slightly. This indicates that sampling more explanations helps MetaReJ detect incorrect explanations more effectively. The gains are most evident from N=1N=1 to N=5N=5. After N=5N=5, MetaReJ’s effectiveness becomes more stable.

Three line charts showing MCC, Precision, and Recall across threshold $N$ values for ThinkRepair, ReInFix, and MORepair

Figure 4. MetaReJ’s effectiveness with different values of NN across three APR systems: ThinkRepair, ReInFix, MORepair.

RQ4: MetaReJ shows a clear trade-off between Precision and Recall as θ\theta changes: increasing θ\theta improves Precision but reduces Recall. θ=0.5\theta=0.5 achieves the balance with the best MCC. MetaReJ’s effectiveness is improved when increasing NN and becomes more stable when N≥5N \ge5.

Ablation Study

We conduct an ablation study to understand the contribution of MetaReJ’s three components: identifying contradictions by the same LLM, the equivalent questioning, and non-equivalent questioning. We develop three variants of MetaReJ. The first one relies on an external LLM to identify contradictions instead of using the same LLM. Claude Opus 4.5 (claude-opus-4-5-20251101) is selected as it is the best LLM for SE and is different from the LLM families used in APR systems. The next two variants only use the equivalent questioning or non-equivalent questioning, respectively. The results show that all components are necessary for MetaReJ’s detection quality. Removing a component consistently degrades MCC and balanced accuracy across all three APR systems.

When MetaReJ relies on Claude Opus 4.5 to identify contradictions, its MCC decreases by up to 32.6%. This variant often achieves slightly higher Recall of 0.75–0.79, except for lower Recall of 0.48 on RelnFix. It achieves lower Precision of 0.76–0.92 (drop by up to 13.6%) and lower Specificity of 0.60–0.80 (drop by up to 22.1%). Although its Recall is slightly better, many explanations are misclassified, leading to the overall decrease in MCC.

Compared to MetaReJ, removing the non-equivalent questioning reduces MCC by up to 84.6%. This variant often achieves high Specificity of 0.80–0.93, but at the cost of a much lower Recall of 0.11–0.31. This indicates that it tends to misclassify incorrect explanations as correct.

In contrast, removing the equivalent questioning decreases MCC by up to 94.9%. Doing so substantially harms the ability to differentiate incorrect and correct explanations. This variant often has lower Specificity, especially on MORrepair, where Specificity drops to 0.09. Although it sometimes achieves higher Recall, the big drops in Specificity show that it becomes overly relaxed and often mislabels explanations as incorrect.

RQ5: When using an external LLM to identify contradictions, MetaReJ maintains slightly higher Recall but achieves lower Precision. This leads to the overall decrease in MCC of up to 32.6%. Additionally, both equivalent and non-equivalent questioning in MetaReJ are crucial. Removing them reduces MetaReJ’s detection ability by up to 84.6% and 94.9% in MCC, respectively.

Qualitative Error Analysis

To better understand the limitations of MetaReJ, we manually analyzed a subset of misclassifications. The most common reason for incorrect explanations being misdetected is that the LLM is stubborn and consistently defends its wrong reasoning under MetaReJ. We provide a few examples in Supplementary Material F-4. This is a well-known limitation of sampling-based detection methods. Future work can explore different sampling techniques to better reveal LLMs’ contradictions. On the other hand, correct explanations misclassified as incorrect are rare. As shown in Supplementary Material B, there are only a few outliers, where the LLM generates a correct explanation but incorrectly verifies the follow-up explanations.

Threats to Validity

Construct Validity: We constructed a new benchmark based on recent APR studies. They have already mitigated data leakage. In the benchmark, each record is manually labeled by at least two annotators with 3–5 years of programming and repair experience. The labeling process achieved a Cohen’s Kappa of 0.78 for inter-annotator agreement. This suggests substantial consistency and reliability of labels. We acknowledge that the labeling is imperfect, leaving a small portion of mislabeled data. However, we believe the results still hold good.

Internal Validity: LLMs are inherently nondeterministic, leading to varied responses. To address this, we set the temperature to 0 and employed three runs of experiments. Another threat is data leakage. Although we do not train an LLM and program transformations are used, data leakage may have limited impact on MetaReJ. We mitigate this threat by using the experimental design in prior studies [1], [13], [14] of LLMs and datasets. They have already mitigated data leakage.

External Validity: Main threats to external validity are that the selected dataset may not generalize to other programs, or that performance enhancements will not generalize to other LLMs. While the benchmark contains three different programming languages (Java, Python, and C++), future studies on alternative datasets could further validate generalizability and performance trends. We evaluated MetaReJ across three recent SOTA LLM-based APR systems, including both open-source and commercial LLMs. This broad spectrum enhances generalizability; however, different systems may yield varying results. Nevertheless, observed trends suggest broad applicability. Evaluating MetaReJ on larger and more powerful models may help assess its scalability and effectiveness.

Conclusion Validity: We interpreted the results using multiple well-established metrics: Precision, Recall, Specificity, and MCC. We also used appropriate statistical tests, such as the paired t-test, to support our findings.

Related Work

Automated Program Repair with LLMs

Novel approaches have been designed to maximize the repair potential of LLMs. Many approaches can generate correct patches for buggy programs with a success rate of up to 70% [28], [29]. In recent years, approaches have also been developed to explain what the bug is and how to fix it.

Many studies have adopted the fine-tuning paradigm [9], [14]. This allows LLMs to learn empirical knowledge used to guide bug repair from bug-fix history. For example, MORepair [14] leverages explanations of code changes to capture the logic underlying a repair operation during fine-tuning.

In addition, researchers have utilized the prompt-learning paradigm [2], [13] to stimulate the repair potential of LLMs. They often combine LLMs with traditional APR techniques to construct specific prompt templates. For example, ThinkRepair [13] enables LLMs to better implement reasoning to complete the repair by leveraging CoT prompting [30].

Recent research has entered the era of agents. Researchers have allowed LLMs to take on different task roles, further expanding the repair capabilities of LLMs. For example, AutoCodeRover [31] combines LLMs with sophisticated code search capabilities to generate patches. RepairAgent [32] enables the LLM-based agent to perform repair by invoking external tools. ReInFix [1] allows LLMs to search for repair ingredients, such as variables and historical changes, to better analyze bug causes and guide bug fixing.

The Detection of Incorrect LLM Responses

Incorrect responses generated by LLMs are often referred to as hallucinations. Detecting them is essential for assuring the trustworthiness of LLM-generated content. Many detection approaches have been introduced for both NL [10], [11], [33], [34] and code artifacts [35]–[38]. A straightforward strategy is to compare the content against reliable knowledge sources [24]. However, this strategy requires curated databases, which are often unavailable and costly to construct.

To address this, prior work has explored zero-resource detection approaches. One line of work exploits LLMs’ internal states [25], [39]–[41] These methods do not require external knowledge and can be computationally efficient. However, they assume access to the internal states, which are not always available. A second line of work targets black-box settings. Some methods adopt a multi-agent perspective by using additional LLMs to judge the original LLM’s response [12], [33]. Others use a sampling-based approach, which is often more practical [11]. They sample multiple responses from the LLM and identify if they contradict one another. For instance, SelfCheckGPT [10] repeatedly queries the LLM and identifies contradictions. MetaQA [11] and DrHall [12] apply semantic perturbations and check if new responses remain valid.

The sampling-based methods have significantly advanced the detection of incorrect LLM-generated content, primarily in general question-answering. Unfortunately, these methods are not well-suited or effective for APR explanations. This is because detection methods need APR-specific knowledge, and the correctness of APR explanations depends on the bug and the intended program behavior. We introduce MetaReJ, a more effective detection method of incorrect APR explanations by addressing these limitations.

Conclusion

This work introduces MetaReJ, the first approach to detect incorrect explanations of LLM-based APR systems. Inspired by debate and viva examination, MetaReJ adopts a metamorphic argumentative strategy to identify contradictions in LLM responses. MetaReJ also applies sampling based on diverse program transformations to better reveal contradictions. Our evaluation shows significant performance improvements in detection quality. MetaReJ improves MCC by up to 333.3% over existing SOTA methods designed for general question-answering. Although MetaReJ sometimes consumes more tokens, it is an acceptable cost for improving the detection quality. Future work can define more MRs to better detect incorrect APR explanations, as well as explore the application of MetaReJ in other SE tasks.

Motivating Example

Listing 1: Program1 semantically equivalent to getTextBuffer, as shown in Figure 1. It is generated by rewriting the program into nested if–else blocks.

public char[] getTextBuffer() {
    if (_inputStart >= 0) {
        return _inputBuffer;
    } else {
        if (_resultArray != null) {
            return _resultArray;
        } else {
            if (_resultString != null) {
                return _resultArray =
                    _resultString.toCharArray();
            } else {
                if (!_hasSegments) {
                    return _currentSegment;
                } else {
                    return contentsAsArray();
                }
            }
        }
    }
}

Listing 2: Program3 semantically non-equivalent to getTextBuffer, as shown in Figure 1. The comparison operator >= in _inputStart >= 0 is changed to >.

public char[] getTextBuffer() {
    if (_inputStart > 0)
        return _inputBuffer;
    if (_resultArray != null)
        return _resultArray;
    if (_resultString != null) {
        return (_resultArray =
            _resultString.toCharArray());
    }
    if (!_hasSegments)
        return _currentSegment;
    return contentsAsArray();
}

Detection Proof

1) Empirical Proof by Comparing MR Violation Rates: Figure 5 shows a clear association between the correctness of the original LLM-generated explanation and the MR violation score. Overall, the violation score across all cases is 0.54. For cases where the original explanation is correct, the violation score is 0.10±0.120.10 \pm0.12. Most values fall close to 0.00, although there are some high outliers near 0.50–0.70. For cases where the original explanation is incorrect, the violation score is

Figure 5. Comparing MR violation rates when the original LLM-generated explanations are correct and incorrect.

0.73±0.210.73 \pm0.21. This is much higher than the violation score when the explanation is correct. Most values fall close to 1.00. There are a few low outliers, but the overall distribution is shifted upward.

Let VV represent that the LLM correctly verifies an explanation’s correctness. Let GG represent that the LLM generates a correct explanation. Given the benchmark shown in Table I, we get P(¬G)≈0.69\mathbb{P}(\neg G) \approx0.69. Based on the empirical results, we have P(¬V)=0.54\mathbb{P}(\neg V) = 0.54. P(¬V∣G)≈0.10\mathbb{P}(\neg V \mid G) \approx0.10, meaning P(V∣G)≈0.90\mathbb{P}(V \mid G) \approx0.90. P(¬V∣¬G)≈0.73\mathbb{P}(\neg V \mid\neg G) \approx0.73, meaning P(V∣¬G)≈0.27\mathbb{P}(V \mid\neg G) \approx0.27. We can calculate P(G∣¬V)\mathbb{P}(G \mid\neg V) as follows

P(G∣¬V)=P(G∩¬V)P(¬V)=P(¬V∣G)⋅P(G)P(¬V)=P(¬V∣G)⋅(1−P(¬G))P(¬V)=0.10⋅(1−0.69)0.54≈0.05(13)\begin{aligned} \mathbb{P}(G \mid\neg V) &= \frac{\mathbb{P}(G \cap\neg V)}{\mathbb{P}(\neg V)} \\ &= \frac{\mathbb{P}(\neg V \mid G) \cdot\mathbb{P}(G)}{\mathbb{P}(\neg V)} \\ &= \frac{\mathbb{P}(\neg V \mid G) \cdot\left(1 - \mathbb{P}(\neg G)\right)}{\mathbb{P}(\neg V)} \\ &= \frac{0.10 \cdot(1 - 0.69)}{0.54} \approx0.05 \tag*{(13)} \end{aligned}

P(V∣G)≈0.90\mathbb{P}(V \mid G) \approx0.90 (close to 1), and P(V∣¬G)≈0.27≫P(G∣¬V)≈0.05\mathbb{P}(V \mid\neg G) \approx0.27 \gg\mathbb{P}(G \mid\neg V) \approx0.05. Hence, VV is almost always no more difficult than GG. This relationship can be visualised in the Venn diagram in Figure 6. Given ¬V\neg V, we can imply ¬G\neg G, with only a few false positives (¬V∩G\neg V \cap G). On the other hand, false negatives (V∩¬GV \cap\neg G) are relatively more common.

Figure 6. Venn diagram of correctly verifying explanations (VV) and generating correct explanations (GG).

2) Theoretical Proof: Let mm be the LLM-based APR system, (r,y)(r,y) be the original repair consisting of the explanation rr and the patch yy. Let C(r)≡{0,1}C(r) \equiv\{0,1\} indicate whether the original explanation rr is incorrect or correct. We define Tran⁡eqv\operatorname{Tran}_{eqv} and Tran⁡neq\operatorname{Tran}_{neq} for preserving and altering the semantics of a program, respectively. We design a repair sub-task Explain⁡m(x′,y)\operatorname{Explain}_{m}(x', y) that asks the system mm to explain how to fix transformed programs, explicitly given the original patch yy. We further model the verification task performed by mm, where MetaReJ asks mm to assess if a follow-up explanation applies to the original program. We denote it by Verify⁡m(r′,x)={0,1}\operatorname{Verify}_{m}(r', x) = \{0, 1\}, where the response of 1 indicates that the model mm thinks the explanation r′r' can be applied to the program xx, and 0 otherwise.

A violation of the two MRs can be represented as

Verify⁡m(rneq′,x)=1∨Verify⁡m(reqv′,x)=0\operatorname{Verify}_{m}(r'_{neq}, x) = 1 \lor\operatorname{Verify}_{m}(r'_{eqv}, x) = 0

where reqv′∼Explain⁡m(xeqv′,y)∘Tran⁡eqv(x)r'_{eqv} \sim\operatorname{Explain}_{m}(x'_{eqv}, y) \circ\operatorname{Tran}_{eqv}(x) and rneq′∼Explain⁡m(xneq′,y)∘Tran⁡neq(x)r'_{neq} \sim\operatorname{Explain}_{m}(x'_{neq}, y) \circ\operatorname{Tran}_{neq}(x).

Our assumption is that when a system is capable of generating a correct explanation, it is also capable of performing easier follow-up tasks correctly.

C(r)=1⟹C(z)=1, or C(z)=0⟹C(r)=0C(r) = 1 \Longrightarrow C(z) = 1,\ \text{or}\ C(z) = 0 \Longrightarrow C(r) = 0

where z∼Tm(⋅)z \sim T_m(\cdot) and TmT_m is less complex than Gen⁡m\operatorname{Gen}_m, i.e., Tm=o(Gen⁡m)T_m = o(\operatorname{Gen}_m).

Explain⁡m\operatorname{Explain}_m, and Verify⁡m\operatorname{Verify}_m are designed to be easier than Gen⁡m\operatorname{Gen}_m. A violation of the MRs represents failures in a sequence of tasks Explain⁡m\operatorname{Explain}_m, and Verify⁡m\operatorname{Verify}_m. Hence, an MR violation indicates that Gen⁡m\operatorname{Gen}_m fails. In other words,

(Verify⁡m(rneq′,x)=1∨Verify⁡m(reqv′,x)=0)⟹C(r)=0\left(\operatorname{Verify}_{m}(r'_{neq}, x) = 1 \lor \operatorname{Verify}_{m}(r'_{eqv}, x) = 0\right) \Longrightarrow C(r) = 0

Taking corresponding probabilistic events

Eviol,eqv:={Verify⁡m(reqv′,x)=0}E_{viol,eqv} := \{\operatorname{Verify}_{m}(r'_{eqv}, x) = 0\}
Eviol,neq:={Verify⁡m(rneq′,x)=1}E_{viol,neq} := \{\operatorname{Verify}_{m}(r'_{neq}, x) = 1\}
ECr,0:={Verify⁡m(reqv′,x)=0}E_{Cr,0} := \{\operatorname{Verify}_{m}(r'_{eqv}, x) = 0\}

We thus have

Eviol,eqv∪Eviol,neq⊆ECr,0E_{viol,eqv} \cup E_{viol,neq} \subseteq E_{Cr,0}

Therefore

P(Eviol,eqv∪Eviol,neq)≤P(ECr,0)\mathbb{P}(E_{viol,eqv} \cup E_{viol,neq}) \leq\mathbb{P}(E_{Cr,0})

Since by definition, the violation score Vm(r,x)=P(Eviol,eqv∪Eviol,neq)V_m(r, x) = \mathbb{P}(E_{viol,eqv} \cup E_{viol,neq}). We thus obtain

Vm(r,x)≤P(ECr,0)V_m(r, x) \leq\mathbb{P}(E_{Cr,0})

The violation score acts as a lower bound on the incorrectness of the explanation rr.

Literature Survey of Program Transformation

  1. Scope: Our literature survey covers research published between 2021 and 2025, focusing on the most influential venues in software engineering. We selected conferences and journals known for their prominence and impact in the field. Specifically, we included the International Conference on Software Engineering (ICSE), Foundations of Software Engineering (FSE), International Symposium on Software Testing and Analysis (ISSTA), Automated Software Engineering (ASE), and Programming Language Design and Implementation (PLDI). We also considered some leading venues in security and machine learning, such as Symposium on Security and Privacy (S&P), Computer and Communications Security (CCS), USENIX Security Symposium (USENIX), International Conference on Machine Learning (ICML), Annual Meeting of the Association for Computational Linguistics (ACL), and Annual AAAI Conference on Artificial Intelligence (AAAI). In addition, we incorporated top software engineering journals, such as Transactions on Software Engineering and Methodology (TOSEM), Transactions on Software Engineering (TSE), Journal of Systems and Software (JSS), Information and Software Technology (IST), and Empirical Software Engineering (ESE). These venues were chosen for their reputation in publishing high-quality and influential research in software engineering (CORE² rank A* or A).

  1. Criteria for Paper Selection: To identify relevant publications, we established clear selection criteria. Eligible papers must:

  • Be full-length papers published in the proceedings or issues of the listed in-scope venues between 2021 and 2025,

  • Exclude short papers (e.g., PhD symposium or work-in-progress papers), as these typically represent incomplete research, and

  • Address program transformations, meaning they either propose a new transformation technique or provide a review of existing ones.

To support paper identification, we defined a set of keywords that capture the research focus of this area: program, code, transformation, transform, modify, modification, perturb, perturbation, mutate, mutation, mutant, counterexample, adversarial, attack, semantic, preserve, alter, equivalence, and morph. We searched for these keywords in the titles and abstracts of all in-scope papers using multiple tools, including IEEE Xplore Advanced Search for IEEE venues, ACM DL Advanced Search for ACM venues, and Google Scholar Advanced Search2 for independent venues. This process yielded 88 potential papers, which were flagged for further manual review.

  1. Filtering Process: We manually reviewed the flagged papers to exclude those not directly related to program transformations. A total of 49 papers were excluded as off-topic. The remaining 39 papers are shown in Table III.

TitleYearVenue
Assessing Robustness of ML-Based Program Analysis Tools using Metamorphic Program Transformations2021ASE
On the generalizability of Neural Program Models with respect to semantic-preserving program transformations2021IST
Self-Supervised Contrastive Learning for Code Retrieval and Summarization via Semantic-Preserving Transformations2021SIGIR
Adversarial Robustness of Deep Code Comment Generation2022TOSEM
Bridging Pre-trained Models and Downstream Tasks for Source Code Understanding2022ICSE
CODE-MVP: Learning to Represent Source Code from Multiple Views with Contrastive Pre-Training2022NAACL
Data augmentation by program transformation2022JSS
NatGen: generative pre-training by “naturalizing” source code2022FSE
ReACC: A Retrieval-Augmented Code Completion Framework2022ACL
Selfapr: Self-supervised program repair with test execution diagnostics2022ASE
Towards Learning (Dis)-Similarity of Source Code from Program Contrasts2022ACL
Towards Robustness of Deep Program Processing Models—Detection, Estimation, and Enhancement2022TOSEM
TransRepair: Context-aware Program Repair for Compilation Errors2022ASE
A Black-Box Attack on Code Models via Representation Nearest Neighbor Search2023EMNLP
An Extensive Study on Adversarial Attack against Pre-trained Models of Code2023FSE
CCTEST: Testing and Repairing Code Completion Systems2023ICSE
Challenging Machine Learning-Based Clone Detectors via Semantic-Preserving Code Transformations2023TSE
Code Difference Guided Adversarial Example Generation for Deep Code Models2023ASE
CodeAttack: Code-Based Adversarial Attacks for Pre-trained Programming Language Models2023AAAI
CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion Models2023FSE
DIP: Dead code insertion based black-box attack for programming language model2023ACL
Discrete Adversarial Attack to Models of Code2023PLDI
How Effective Are Neural Networks for Fixing Security Vulnerabilities2023ISSTA
Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation2023NeurIPS
Repair Is Nearly Generation: Multilingual Program Repair with LLMs2023AAAI
ALANCA: Active Learning Guided Adversarial Attacks for Code Comprehension on Diverse Pre-trained and Large Language Models2024SANER
An LLM-Assisted Easy-to-Trigger Backdoor Attack on Code Completion Models: Injecting Disguised Vulnerabilities against Strong Detection2024USENIX
Benchmarking Automated Program Repair: An Extensive Study on Both Real-World and Artificial Bugs2024ISSTA
Do large code models understand programming concepts? counterfactual analysis for code predicates2024ICML
Effective test generation using pre-trained Large Language Models and mutation testing2024IST
Mutation-based Consistency Testing for Evaluating the Code Understanding Capability of LLMs2024CAIN
Poison Attack and Poison Detection on Deep Source Code Processing Models2024TOSEM
Stealthy Backdoor Attack for Code Models2024TSE
AdverIntent-Agent: Adversarial Reasoning for Repair Based on Inferred Program Intent2025ISSTA
CodeMorph: Mitigating Data Leakage in Large Language Model Assessment2025ICSE
How Accurately Do Large Language Models Understand Code?2025
Metamorphic-Based Many-Objective Distillation of LLMs for Code-related Tasks2025ICSE
Towards Reliable Evaluation of Neural Program Repair with Natural Robustness Testing2025TOSEM
Understanding the Robustness of Transformer-Based Code Intelligence via Code Transformation: Challenges and Opportunities2025TSE

Table III. Papers about Program Transformation

Prompt Templates

Listing 3: Follow-up Explanation Generation

System: You are an Automatic Program Repair
    Tool. You are now the examinee in a
    debate-style viva examination, where you
    defend your original repair decision.

User: You originally provided the following
    fix for the original buggy function:
// Buggy Function
{{original_buggy_code}}

// Fixed Function
{{fixed_code}}

Now, the examiner presents a transformed
    buggy function:
// Buggy Function
{{transformed_buggy_code}}

Since you proposed the original fix, explain
    how this transformed buggy function
    should be fixed.

Listing 4: Follow-up Explanation Verification

System: You are an Automatic Program Repair
    Tool. You are now the examinee in a
    debate-style viva examination, where you
    defend your original repair decision.
Answer YES or NO. If you are NOT SURE, answer
    NOT SURE. Don’t return anything else
    except YES, NO, or NOT SURE.

User:
// Buggy Function
{{original_buggy_code}}

// Explanation
{{explanation}}

Given a buggy function and an explanation,
    you need to verify if the explanation is
    applicable to fix the buggy function.

Annotation Process

Experts were invited to label the correctness of 1,756 explanations, as collected in Section IV-D. Each has 3–5 years of experience in programming and program repair. They first went through a tutorial on how to review and label an explanation. Then, for each explanation, two annotators were assigned to independently label its correctness. A web application was developed to facilitate this process. Figure 7 shows a screenshot of the web application for labeling an explanation generated by MORepair for Cli-19 in Defects4J. The annotators were provided with various artifacts, including the buggy program, the developer’s fix, the LLM-generated explanation, the LLM-generated fix, and auxiliary information about the bug, such as the bug report and triggering tests. After reviewing these artifacts, the annotators decided whether the explanation is correct and stated their level of confidence from 1 to 5 on a Likert-like scale. They were also encouraged to note their rationale during the labeling process. If they are unsure, the third option “unsure” could be selected.

Annotation page of a MOREpair-generated explanation for Cli-19 in Defects4J.

Figure 7. Annotation page of an MOREpair-generated explanation for Cli-19 in Defects4J.

For example, the program processOptionToken in Figure 7 does not handle the token properly. The token is simply ignored if it does not belong to options or if stopAtNoOpt is disabled. Based on the developer’s fix, this buggy program can be fixed by moving tokens.add(token) outside of the if-else block. The explanation generated by MORepair correctly describes the bug and how to fix it. As a result, this explanation is labeled as correct.

The web application recorded that it took 182.62 seconds on average for an annotator to label an explanation. In total, it took 178.15 hours to label the entire 1,756 explanations. This annotation process achieved a Cohen’s Kappa value for inter-annotator agreement of 0.78. This indicates substantial consistency and reliability, significantly bolstering our confidence in both the benchmark’s quality and MetaReJ’s evaluation.

If an annotator is unsure about the explanation’s correctness or the two annotators disagree, a third annotator got involved in the discussion to reach a consensus. Ultimately, 1,217 incorrect explanations were identified, as shown in Table I. This shows that many generated explanations, in particular 69.3% of the explanations, are incorrect. The APR systems are still highly unreliable for explaining their repairs, even the best-performing system, ReInFix.

Experiments

  1. Sampling Transformed Programs: The generations of transformed programs TraneqvTran_{eqv} and TranneqvTran_{neqv} are typically inexpensive. However, generating follow-up explanations ExplainmExplain_m may be costly, as it requires querying the LLM multiple times. To reduce this cost, we adopt a fixed sampling budget strategy: given a budget NN, we draw NN follow-up explanations for NN equivalent programs and NN follow-up explanations for NN non-equivalent ones. To enhance the diversity of this sampling, MetaReJ selects the most representative transformed programs.

To do this, MetaReJ clusters each list of equivalent and non-equivalent transformed programs into NN clusters. MetaReJ transform each program into its vector representation using UniXCoder3. For each category of equivalence or non-equivalence, MetaReJ clusters the vector representations of transformed programs into NN clusters. Then, it randomly chooses one in each cluster as a representative example.

Table VII compares MetaReJ’s effectiveness with two strategies for sampling transformed programs. The default strategy is clustering, as aforementioned. The alternative strategy is to randomly select NN programs. The results show that clustering is consistently more effective than random selection for sampling transformed programs across all three APR systems. For ThinkRepair, MCC drops from 0.42 with clustering to only 0.04 with random selection, a reduction of 91.4%. ReInFix also drops from 0.47 to 0.24, while MORepair decreases from 0.39 to 0.14. This shows that random sampling substantially weakens MetaReJ’s ability to distinguish correct and incorrect explanations. Precision, Recall, and Specificity help clarify the difference between the two strategies. For ThinkRepair, random selection achieves higher Recall than clustering, but its Specificity drops sharply from 0.75 to 0.20. This means MetaReJ correctly detects many incorrect explanations but incorrectly labels correct ones as incorrect, which severely reduces MCC. For ReInFix, the opposite trend appears. Random selection has slightly higher Specificity, but Recall falls from 0.67 to 0.36, meaning it misses many true incorrect explanations. For MORepair, random selection performs worse on almost every metric. Overall, the results suggest that clustering selects a more diverse and representative set of

transformed programs, leading to more effective detection.

  1. Interpretation of Evaluation Metrics: Tables VIII–IX show the interpretations of Matthew Correlation Coefficient (MCC) [42] and Cohen’s Kappa [27], respectively.

  1. Benchmark Breakdown: Table VI shows that incorrect explanations are common across all APR systems and datasets. On Defects4J, all three systems produce a large proportion of incorrect explanations. ThinkRepair has the highest incorrect rate at 88.1%, followed by MORepair at 79.4%, and ReInFix at 57.2%. Even the best-performing system, ReInFix, still produces more incorrect explanations than correct ones.

The trend remains consistent on the other datasets. ThinkRepair and ReInFix show almost the same incorrect rates as on Defects4J, with 87.1% and 56.1%, respectively. This suggests that their explanation correctness is relatively stable across bug benchmarks. MORepair achieves a lower incorrect rate on the other datasets, dropping from 79.4% to 63.4%, but incorrect explanations still dominate.

Overall, these results suggest that incorrect APR explanations are not an isolated issue of Defects4J. Across all datasets, there are 1,756 explanations, of which 1,219 are incorrect, giving an overall incorrect explanation rate of about 69.3%. This supports the need for automated methods such as MetaReJ to detect incorrect explanations before they are presented to developers.

IdTransformationOriginalTransformed
PCS-1Change Spacing Styleif (x == 0) { }if(x==0){ }
PCS-2Change Naming StylemyNumbermy_number
Stylistic Transformations
Unused or Dead Code Transformations
PUD-1Add Unused Statements/Dead Code
PUD-2Delete Unused Statement
PUD-3Add Unused Parameters/-Variable
PUD-4Move Partial Code into Functionz=x+ydef func(x,y): return x+y z=func(x,y)
PUD-5Delete Unused Variable
Expression Transformations
PEL-1Wrap with Logical NOTx<y!(y>=x)
PEL-2Split Compound Condition into Nested Ifsif (cond1) && cond2) { //Body }if (cond1) { if (cond2) { //Body } }
PEL-3Merge Variable Declarationsint a; int b;int a, b;
PEL-4Separate Declaration and Initializationint i=0;int i; i=0;
PEL-5Combine Declaration and Initializationint i; i=0;int i=0;
PEL-6Transform Relational Expressiona < bb > a
PEL-7Transform Boolean Logic Equivalentlyx == -1 i == j (ab) && cx + 1 == 0 j == i (a && c)(b && c)
PEL-8Convert Add/Subtract Assignment to Equal Assignmentx += 1 y -= 2x = x + 1 y = y - 2
PEL-9Divide Expression into Small Expressions with Intermediate Variablesx = a + b * c return 1 get().run() f(g())temp = b * c x = a + temp ret = 1 return ret i=get(); i.run() v = g(); f(v)
PEL-10Swap Operandsa + bb + a
PEL-11Combine Small Expressions into Expressiontemp = b * c x = a + temp ret = 1 return ret i=get(); i.run() v = g(); f(v)x = a + b * c return 1 get().run() f(g())
PEL-12Change Arithmetic Expression Equivalentlya - b + ca - (b - c)

Table IV. Semantic preserving transformations used in this study

IdTransformationOriginalTransformed
PNL-1Modify Comment
PNL-2Add Comment
PNL-3Remove Comment
PNL-4Add Print Statement
PNL-5Remove Print Statement
PNL-6Modify Print Message
Control Flow Transformations
PCL-1Convert For-Loop to While-Loop
PCL-2Convert While-Loop to For-Loop
PCL-3Convert If–Elseif to If–Elseif (a < 3){ //BodyA } else if (a < 5){ //BodyB }if (a < 3){ //BodyA } else { if (a < 5) //BodyB }
PCL-4Convert If–Else to If–Elseifif (a < 3){ //BodyA } else { if (a < 5) //BodyB }if (a < 3){ //BodyA } else if (a < 5){ //BodyB }
PCL-5Convert Switch–Case to If–Else
PCL-6Convert If–Else to Switch–Case
PCL-7Convert If–Continue to If–Else
PCL-8Swap If and Else Blocksif (condition){ //BodyA } else { //BodyB }if (!condition){ //BodyB } else { //BodyA }
PCL-9Swap Two Independent Statements
PCL-10Convert If Statement to Conditional Expressionif (condition){ //BodyA } else { //BodyB }condition ? BodyA : BodyB
PCL-11Convert Conditional Expression to If Statementcondition ? BodyA : BodyBif (condition){ //BodyA } else { //BodyB }
PCL-12Add Else Clause
PCL-13Wrap Statement in If or Loopstatementif (1) statement
PCL-14Move Iterator Declaration into For-Loopint i; for (i; i < n; i++)for (int i = 0; i < n; i++)
PCL-15Move Iterator Declaration out of For-Loopfor (int i = 0; i < n; i++)int i; for (i; i < n; i++)

Table IV (PDF p. 17). Semantic preserving transformations used in this study

4) Detection Examples: We provide an example of a true positive, where an incorrect explanation is correctly detected.

Listing 5: The buggy program containsIgnoreCase, also known as Lang-40 in Defects4J.

public static boolean
    containsIgnoreCase(String str, String
    searchStr) {
    if (str == null || searchStr == null) {
        return false;
    }
    return contains(str.toUpperCase(),
        searchStr.toUpperCase());
}

Listing 6: The fix for Lang-40 generated by ThinkRepair.

-    return contains(str.toUpperCase(),
-        searchStr.toUpperCase());
+    return contains(str.toUpperCase(),
+        searchStr.toUpperCase()) ||
+        contains(str.toLowerCase(),
+        searchStr.toLowerCase());

Original Explanation: The bug in the containsIgnoreCase function is with the line ‘contains(str.toUpperCase(), searchStr.toUpperCase())’. This line checks if the search string is a substring of the input string, but it is incorrect and will result in a stack overflow for certain inputs.

IdTransformationOriginalTransformed
AIB-1Rename Variable
Identifier Based Transformations
Control Flow Transformations
ACL-1Misplace Return
ACL-2Swap Break and Continue
ACL-3Delete Exception Handlerexcept: passexcept: raise
ACL-4Swallow Exceptionexcept: returnexcept: pass
ACL-5Delete Statement
ACL-6Wrap Statement with Condition
ACL-7Unwrap Block
ACL-8Delete Block
ACL-9Insert Block
ACL-10Misuse Variable

Table V. Semantic altering transformations used in this study

IdTransformationOriginalTransformed
Expression Transformations
PEL-1Off-By-Onenn+1
PEL-2Replace Conditional Expressiona || ba
PEL-3Expand Boolean Expressionx && yx && y || z
PEL-4Replace Relational Operatorx < 10x <= 10
PEL-5Replace Boolean Operatorx && yx || y
PEL-6Replace Literal Value
PEL-7Negative Condition!condcond
PEL-8Remove Slice Indexsorted(l[::3])sorted(l[:])
PEL-9Modify Function Call

Table V (PDF p. 18). Semantic altering transformations used in this study

Listing 7: A transformed program semantically non-equivalent to Lang-40 in Defects4J. The logical operator || is replaced by &&.

public static boolean
    containsIgnoreCase(String str, String
    searchStr) {
        if (null == str && null == searchStr) {
            return false;
        }
        return contains(str.toUpperCase(),
                searchStr.toUpperCase());
    }

Follow-up Explanation: The bug in the original function is that it returns ‘false’ if either ‘str’ or ‘searchStr’ is ‘null’, even if the other argument is not ‘null’. This is because the ‘&&’ operator short-circuits and returns ‘false’ as soon as it encounters a ‘null’ value. To fix this bug, we need to change the ‘&&’ operator to ‘||’ so that both arguments are checked for ‘null’ before calling the ‘contains’ method. This will ensure that the function returns ‘false’ only if both ‘str’ and ‘searchStr’ are ‘null’.

This follow-up explanation explains that we need to change the ‘&&’ operator to ‘||’, which is not applicable to the original Lang-40. However, ThinkRepair responds that it is not applicable.

APR System Under TestDefects4J # Expls# Correct Expls# Incorrect ExplsIncorrect Expl RateOther Datasets Name# Expls# Correct Expls# Incorrect ExplsIncorrect Expl Rate
ThinkRepair3694432588.1%RWB6285487.1%
ReInFix67028738357.2%RWB41182356.1%
MORepair2815822379.4%SWE-Repair, EvalRepair-C++, EvalRepair-Java33312221163.4%

Table VI. Benchmarking the correctness of LLM-generated APR explanations

System Under TestDetectorMCCΔ\DeltaMCCBAPreRecSpe
ThinkRepairCluster0.340.750.960.720.77
ThinkRepairRandom0.04-88.2%0.520.880.840.20
ReInFixCluster0.430.700.880.500.91
ReInFixRandom0.26-39.5%0.610.790.360.87
MORepairCluster0.390.710.910.700.72
MORepairRandom0.15-61.5%0.580.760.630.53

Table VII. Comparing two strategies for sampling transformed programs: clustering and random selection

Matthew Correlation Coefficient (MCC)Interpretation
0.00 – 0.09Negligible correlation
0.10 – 0.39Weak correlation
0.40 – 0.69Moderate correlation
0.70 – 0.89Strong correlation
0.90 – 1.00Very strong correlation

Table VIII. Interpretation of Matthew Correlation Coefficient (MCC), based on thresholds from [42]

Value of KappaLevel of Agreement
0.00 – 0.20None
0.21 – 0.39Minimal
0.40 – 0.59Weak
0.60 – 0.79Moderate
0.80 – 0.90Strong
0.91 – 1.00Almost Perfect

Table IX. Interpretation of Cohen’s Kappa [27]

We provide an example of a false negative.

Listing 8: The buggy program random, also known as Lang-12 in Defects4J.

public static String random(int count, int
    start, int end, boolean letters, boolean
    numbers, char[] chars, Random random) {
    if (count == 0) {
        return "";
    } else if (count < 0) {
        throw new
            IllegalArgumentException("Requested
            random string length " + count + " is
            less than 0.");
    }

    if (start == 0 && end == 0) {
        if (!letters && !numbers) {
            end = Integer.MAX_VALUE;
        } else {
            end = 'z' + 1;
            start = ' ';
        }
    }

    char[] buffer = new char[count];
    int gap = end - start;

    while (count-- != 0) {
        char ch;
        if (chars == null) {
            ch = (char) (random.nextInt(gap) +
                start);
        } else {
            ch = chars[random.nextInt(gap) + start];
        }
        if (letters && Character.isLetter(ch)
            || numbers && Character.isDigit(ch)
            || !letters && !numbers) {
            if(ch >= 56320 && ch <= 57343) {
                if(count == 0) {
                    count++;
                } else {
                    // low surrogate, insert high
                    // surrogate after putting it in
                    buffer[count] = ch;
                    count--;
                    buffer[count] = (char) (55296 +
                        random.nextInt(128));
                }
            } else if(ch >= 55296 && ch <= 56191) {
                if(count == 0) {
                    count++;
                } else {
                    // high surrogate, insert low
                    // surrogate before putting it in
                    buffer[count] = (char) (56320 +
                        random.nextInt(128));
                    count--;
                    buffer[count] = ch;
                }
            } else if(ch >= 56192 && ch <= 56319) {
                // private high surrogate, no effing
                // clue, so skip it
                count++;
            } else {
                buffer[count] = ch;
            }
        } else {
            count++;
        }
    }
}
return new String(buffer);
}

Listing 9: The fix for Lang-12 generated by ThinkRepair.

- if (start == 0 && end == 0) {
+ if (start == 0 || end == 0) {

Original Explanation: The bug is in the ‘if (start == 0 && end == 0)‘ statement. The function is checking if both ‘start‘ and ‘end‘ are 0, but the intended behavior is to check if either one of them is 0.

This repair generated by ThinkRepair is incorrect. The actual bug is that the chars array may be null or empty and there is currently no check for that. The repair incorrectly identifies the root cause, and proposes a wrong explanation.

We transform the program Lang-12 into a semantically equivalent program as follows.

Listing 10: A transformed program semantically equivalent to Lang-12 in Defects4J.

public static String random(int count, int
    start, int end, boolean letters, boolean
    numbers, char[] chars, Random random) {
  if (count < 0) {
    throw new
        IllegalArgumentException("Requested
        random string length " + count + " is
        less than 0.");
  } else if (count == 0) {
    return "";
  }

  if (start == 0 && end == 0) {
    if (!letters && !numbers) {
      end = Integer.MAX_VALUE;
    } else {
      end = ’z’ + 1;
      start = ’ ’;
    }
  }

  char[] buffer = new char[count];
  int gap = end - start;

  while (count-- != 0) {
    char ch = (chars == null) ? (char)
        (random.nextInt(gap) + start) :
        chars[random.nextInt(gap) + start];
    if (letters && Character.isLetter(ch)
        || numbers && Character.isDigit(ch)
        || !letters && !numbers) {
      if(ch >= 56320 && ch <= 57343) {
        if(count == 0) {
          count++;
        } else {
          // low surrogate, insert high
          // surrogate after putting it in
          buffer[count] = ch;
          count--;
          buffer[count] = (char) (55296 +
              random.nextInt(128));
        }
      } else if(ch >= 55296 && ch <= 56191) {
        if(count == 0) {
          count++;
        } else {
          // high surrogate, insert low
          // surrogate before putting it in
          buffer[count] = (char) (56320 +
              random.nextInt(128));
          count--;
          buffer[count] = ch;
        }
      } else if(ch >= 56192 && ch <= 56319) {
        // private high surrogate, no effing
        // clue, so skip it
        count++;
      } else {
        buffer[count] = ch;
      }
    } else {
      count++;
    }
  }
  return new String(buffer);
}

The transformed program makes two refactoring changes while preserving the original behavior. First, it reorders the initial boundary checks by checking ‘count ¡ 0‘ before ‘count == 0‘; this does not change the logic because the two conditions are mutually exclusive. Second, it replaces the explicit ‘if-else‘ block used to assign ‘ch‘ with an equivalent ternary expression. Thus, the transformation simplifies the code structure and makes the assignment more compact, but it does not alter the program’s intended functionality.

Follow-up Explanations: The bug is caused by the fact that the function is using the ‘&&‘ operator instead of the ‘||‘ operator to check if either ‘start‘ or ‘end‘ is equal to 0. This means that the function will only set ‘end‘ to ‘Integer.MAX_VALUE‘ if both ‘start‘ and ‘end‘ are equal to 0, which is not the intended behavior. To fix this bug, you should change the line ‘if (start == 0 && end == 0) { ... }‘ to ‘if (start == 0 || end == 0) { ... }‘. This will ensure that the function sets ‘end‘ to ‘Integer.MAX_VALUE‘ if either ‘start‘ or ‘end‘ is equal to 0, which is the intended behavior.

This follow-up explanation is similar to the original one. Although the follow-up explanation is incorrect, as the original, the LLM verifies that it is applicable to the buggy program Lang-12.

We also transform the program Lang-12 into a semantically non-equivalent program as follows.

Listing 11: A transformed program semantically non-equivalent to Lang-12 in Defects4J.

public static String random(int count, int
    start, int end, boolean letters, boolean
    numbers, char[] chars, Random random) {
  char[] buffer = new char[count];
  int gap = end - start;

  while (count-- != 0) {
    char ch;
    if (chars == null) {
      ch = (char) (random.nextInt(gap) +
          start);
9        } else {
10           ch = chars[random.nextInt(gap) + start];
11       }
12       if (letters && Character.isLetter(ch)
13               || numbers && Character.isDigit(ch)
14               || !letters && !numbers) {
15           if(ch >= 56320 && ch <= 57433) {
16               if(count == 0) {
17                   count++;
18               } else {
19                   // low surrogate, insert high
                       surrogate after putting it in
20                   buffer[count] = ch;
21                   count--;
22                   buffer[count] = (char) (55296 +
                           random.nextInt(128));
23               }
24           } else if(ch >= 55296 && ch <= 56191) {
25               if(count == 0) {
26                   count++;
27               } else {
28                   // high surrogate, insert low
                       surrogate before putting it in
29                   buffer[count] = (char) (56320 +
                           random.nextInt(128));
30                   count--;
31                   buffer[count] = ch;
32               }
33           } else if(ch >= 56192 && ch <= 56319) {
34               // private high surrogate, no effing
                   clue, so skip it
35               count++;
36           } else {
37               buffer[count] = ch;
38           }
39       } else {
40           count++;
41       }
42   }
43   return new String(buffer);
44 }

This new program removes the if statement ‘if (start == 0 && end == 0) { ... }‘. ThinkRepair provides a follow-up explanation for this program.

Follow-up Explanation: The bug in the original function is that it does not correctly handle the case where ‘start‘ and ‘end‘ are both 0. In this case, the function sets ‘end‘ to ‘Integer.MAX_VALUE‘ and ‘start‘ to ‘ ’‘, which is not the correct behavior. To fix this bug, we need to check if ‘start‘ and ‘end‘ are both 0, and if so, set ‘end‘ to ‘Integer.MAX_VALUE‘ and ‘start‘ to ‘0‘. We can do this by adding the following code at the beginning of the function:

if (start == 0 && end == 0) {
    end = Integer.MAX_VALUE;
    start = 0;
}

This follow-up explanation is completely different from the original. ThinkRepair verifies that this explanation is not applicable to the original program. In this case, ThinkRepair is stubborn and consistently defends its wrong reasoning. As a result, MetaReJ fails to detect the original explanation generated by ThinkRepair as incorrect.

References

  1. [1]J. Zhang, K. Huang, J. Zhang, Y. Liu, and C. Chen, “Repair ingredients are all you need: Improving large language model-based program repair via repair ingredients search,” 2025. [Online]. Available: https://arxiv.org/abs/2506.23100
  2. [2]C. S. Xia and L. Zhang, “Automated program repair via conversation: Fixing 162 out of 337 bugs for $0.42 each using chatgpt,” in Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis, ser. ISSTA 2024. New York, NY, USA: Association for Computing Machinery, 2024, p. 819–831. [Online]. Available: https://doi.org/10.1145/3650212.3680323
  3. [3]F. Li, J. Jiang, J. Sun, and H. Zhang, “Evaluating Generalizability of LLMs in Automated Program Repair ,” in 2025 IEEE/ACM 47th International Conference on Software Engineering: New Ideas and Emerging Results (ICSE-NIER). Los Alamitos, CA, USA: IEEE Computer Society, May 2025, pp. 91–95. [Online]. Available: https://doi.ieeecomputersociety.org/10.1109/ICSE-NIER66352.2025.00024arxiv.org/abs/2503.09217
  4. [4]M. Böhme, E. O. Soremekun, S. Chattopadhyay, E. Ugherughe, and A. Zeller, “Where is the bug and how is it fixed? an experiment with practitioners,” in Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering, ser. ESEC/FSE 2017. New York, NY, USA: Association for Computing Machinery, 2017, p. 117–128. [Online]. Available: https://doi.org/10.1145/3106237.3106255
  5. [5]E. Winter, D. Bowes, S. Counsell, T. Hall, S. Haraldsson, V. Nowack, and J. Woodward, “How do developers really feel about bug fixing? directions for automatic program repair,” in Proceedings of the IEEE/ACM 46th International Conference on Software Engineering, vol. 49, no. 4, pp. 1823–1841, 2023.
  6. [6]F. N. Meem, J. Smith, and B. Johnson, “Exploring experiences with automated program repair in practice,” in Proceedings of the IEEE/ACM 46th International Conference on Software Engineering, ser. ICSE ’24. New York, NY, USA: Association for Computing Machinery, 2024. [Online]. Available: https://doi.org/10.1145/3597503.3639182
  7. [7]Y. Tao, J. Kim, S. Kim, and C. Xu, “Automatically generated patches as debugging aids: a human study,” in Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering, ser. FSE 2014. New York, NY, USA: Association for Computing Machinery, 2014, p. 64–74. [Online]. Available: https://doi.org/10.1145/2635868.2635873
  8. [8]D. Khati, Y. Liu, D. N. Palacio, Y. Zhang, and D. Poshyvanyk, “Mapping the trust terrain: Llms in software engineering - insights and perspectives,” ACM Trans. Softw. Eng. Methodol., Oct. 2025, just Accepted. [Online]. Available: https://doi.org/10.1145/3771282
  9. [9]J. Zhang, C. Wang, A. Li, W. Wang, T. Li, and Y. Liu, “Vuladvisor: Natural language suggestion generation for software vulnerability repair,” in Proceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering, ser. ASE ’24. New York, NY, USA: Association for Computing Machinery, 2024, p. 1932–1944. [Online]. Available: https://doi.org/10.1145/3691620.3695555
  10. [10]P. Manakul, A. Liusie, and M. Gales, “SelfCheckGPT: Zero-resource black-box hallucination detection for generative large language models,” in Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, H. Bouamor, J. Pino, and K. Bali, Eds. Singapore: Association for Computational Linguistics, Dec. 2023, pp. 9004–9017. [Online]. Available: https://aclanthology.org/2023.emnlp-main.557/
  11. [11]B. Yang, M. A. Al Mamun, J. M. Zhang, and G. Uddin, “Hallucination detection in large language models with metamorphic relations,” Proc. ACM Softw. Eng., vol. 2, no. FSE, Jun. 2025. [Online]. Available: https://doi.org/10.1145/3715735
  12. [12]W. Wu, Y. Cao, N. Yi, R. Ou, and Z. Zheng, “Detecting and reducing the factual hallucinations of large language models with metamorphic testing,” Proc. ACM Softw. Eng., vol. 2, no. FSE, Jun. 2025. [Online]. Available: https://doi.org/10.1145/3715784
  13. [13]X. Yin, C. Ni, S. Wang, Z. Li, L. Zeng, and X. Yang, “Thinkrepair: Self-directed automated program repair,” in Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis, ser. ISSTA 2024. New York, NY, USA: Association for Computing Machinery, 2024, p. 1274–1286. [Online]. Available: https://doi.org/10.1145/3650212.3680359
  14. [14]B. Yang, H. Tian, J. Ren, H. Zhang, J. Klein, T. F. Bissyané, C. L. Goues, and S. Jin, “Morepair: Teaching llms to repair code via multi-objective fine-tuning,” ACM Trans. Softw. Eng. Methodol., vol. 35, no. 2, Jan. 2026. [Online]. Available: https://doi.org/10.1145/3735129
  15. [15]D. Chicco and G. Jurman, “The matthews correlation coefficient (mcc) should replace the roc auc as the standard metric for assessing binary classification,” BioData Mining, vol. 16, no. 1, p. 4, Feb 2023. [Online]. Available: https://doi.org/10.1186/s13040-023-00322-4
  16. [16]R. Just, D. Jalali, and M. D. Ernst, “Defects4j: a database of existing faults to enable controlled testing studies for java programs,” in Proceedings of the 2014 International Symposium on Software Testing and Analysis, ser. ISSTA 2014. New York, NY, USA: Association for Computing Machinery, 2014, p. 437–440. [Online]. Available: https://doi.org/10.1145/2610384.2628055
  17. [17]T. Y. Chen, S.-C. Cheung, and S.-M. Yiu, “Metamorphic testing: A new approach for generating next test cases,” Hong Kong University of Science and Technology, Department of Computer Science, Tech. Rep. HKUST-CS98-01, 1998. [Online]. Available: https://arxiv.org/abs/2002.12543
  18. [18]E. T. Barr, M. Harman, P. McMinn, M. Shahbaz, and S. Yoo, “The oracle problem in software testing: A survey,” IEEE Transactions on Software Engineering, vol. 41, no. 5, pp. 507–525, 2015.DOI
  19. [19]S. Segura, G. Fraser, A. B. Sanchez, and A. Ruiz-Cortés, “A survey on metamorphic testing,” IEEE Transactions on Software Engineering, vol. 42, no. 9, pp. 805–824, 2016.DOI
  20. [20]S. Cho, S. Ruberto, and V. Terragni, “Metamorphic testing of large language models for natural language processing,” in 2025 IEEE International Conference on Software Maintenance and Evolution (ICSME), 2025, pp. 174–186.DOI
  21. [21]G. A. Guo, A. Neti, N. Neelofar, C. Tantithamthavorn, Y. Qi, and T. Y. Chen, “Mortar: Multi-turn metamorphic testing for llm-based dialogue systems,” IEEE Transactions on Software Engineering, pp. 1–18, 2026.DOI
  22. [22]T. Le-Cong, D. Nguyen, B. Le, and T. Murray, “Towards reliable evaluation of neural program repair with natural robustness testing,” ACM Trans. Softw. Eng. Methodol., vol. 34, no. 7, Aug. 2025. [Online]. Available: https://doi.org/10.1145/3716167
  23. [23]C. H. Papadimitriou, Computational complexity. GBR: John Wiley and Sons Ltd., 2003, p. 260–265.
  24. [24]Z. Guo, M. Schlichtkrull, and A. Vlachos, “A survey on automated fact-checking,” Transactions of the Association for Computational Linguistics, vol. 10, pp. 178–206, 2022. [Online]. Available: https://aclanthology.org/2022.tacl-1.11/arxiv.org/abs/2108.11896
  25. [25]G. Sriramanan, S. Bharti, V. S. Sadasivan, S. Saha, P. Kattakinda, and S. Feizi, “Llm-check: Investigating detection of hallucinations in large language models,” in Advances in Neural Information Processing Systems, A. Globerson, L. Mackey, D. Belgrave, A. Fan, U. Paquet, J. Tomczak, and C. Zhang, Eds., vol. 37. Curran Associates, Inc., 2024, pp. 34 188–34 216.DOI
  26. [26]C. E. Jimenez, J. Yang, A. Wettig, S. Yao, K. Pei, O. Press, and K. Narasimhan, “Swe-bench: Can language models resolve real-world github issues?” in International Conference on Learning Representations, B. Kim, Y. Yue, S. Chaudhuri, K. Fragiadaki, M. Khan, and Y. Sun, Eds., vol. 2024, 2024, pp. 54 107–54 157.arxiv.org/abs/2310.06770
  27. [27]M. L. McHugh, “Interrater reliability: the kappa statistic,” Biochem Med (Zagreb), vol. 22, no. 3, pp. 276–282, 2012.
  28. [28]J. Zhao, D. Yang, L. Zhang, X. Lian, Z. Yang, and F. Liu, “Enhancing automated program repair with solution design,” in Proceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering, ser. ASE ’24. New York, NY, USA: Association for Computing Machinery, 2024, p. 1706–1718. [Online]. Available: https://doi.org/10.1145/3691620.3695537
  29. [29]T. Le-Cong, B. Le, and T. Murray, “Memory-efficient large language models for program repair with semantic-guided patch generation,” 2025. [Online]. Available: https://arxiv.org/abs/2410.16655
  30. [30]J. Wei, X. Wang, D. Schuurmans, M. Bosma, B. ichter, F. Xia, E. Chi, Q. V. Le, and D. Zhou, “Chain-of-thought prompting elicits reasoning in large language models,” in Advances in Neural Information Processing Systems, S. Koyejo, S. Moham ed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh, Eds., vol. 35. Curran Associates, Inc., 2022, pp. 24 824–24 837.arxiv.org/abs/2201.11903
  31. [31]Y. Zhang, H. Ruan, Z. Fan, and A. Roychoudhury, “Autocodever: Autonomous program improvement,” in Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis, ser. ISSTA 2024. New York, NY, USA: Association for Computing Machinery, 2024, p. 1592–1604. [Online]. Available: https://doi.org/10.1145/3650212.3680384
  32. [32]I. Bouzenia, P. Devanbu, and M. Pradel, “Repairagent: An autonomous, llm-based agent for program repair,” in Proceedings of the IEEE/ACM 47th International Conference on Software Engineering, ser. ICSE ’25. IEEE Press, 2025, p. 2188–2200. [Online]. Available: https://doi.org/10.1109/ICSE55347.2025.000157
  33. [33]R. Cohen, M. Hamri, M. Geva, and A. Globerson, “LM vs LM: Detecting factual errors via cross examination,” in Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, H. Bouamor, J. Pino, and K. Bali, Eds. Singapore: Association for Computational Linguistics, Dec. 2023, pp. 12 621–12 640. [Online]. Available: https://aclanthology.org/2023.emnlp-main.778/
  34. [34]L. Nguyen Tung, S. Cho, X. Du, N. Neelofar, V. Terragni, S. Ruberto, and A. Aleti, “Automated trustworthiness oracle generation for machine learning text classifiers,” Proc. ACM Softw. Eng., vol. 2, no. FSE, Jun. 2025. [Online]. Available: https://doi.org/10.1145/3729376
  35. [35]Y. Tian, W. Yan, Q. Yang, X. Zhao, Q. Chen, W. Wang, Z. Luo, L. Ma, and D. Song, “Codehalu: Investigating code hallucinations in llms via execution-based verification,” Proceedings of the AAAI Conference on Artificial Intelligence, vol. 39, no. 24, pp. 25 300–25 308, Apr. 2025. [Online]. Available: https://doi.org/10.1609/aaai.v39i24.34717
  36. [38]L. N. Tung, X. Du, N. Neelofar, and A. Aleti, “Untrustvul: Automated untrustworthy alert identification in vulnerability detection models,” IEEE Transactions on Software Engineering, vol. 52, no. 8, pp. 2335–2353, 2026.DOI
  37. [39]W. Su, C. Wang, Q. Ai, Y. Hu, Z. Wu, Y. Zhou, and Y. Liu, “Unsupervised real-time hallucination detection based on the internal states of large language models,” in Findings of the Association for Computational Linguistics: ACL 2024, L.-W. Ku, A. Martins, and V. Srikumar, Eds. Bangkok, Thailand: Association for Computational Linguistics, Aug. 2024, pp. 14 379–14 391. [Online]. Available: https://aclanthology.org/2024.findings-acl.854/arxiv.org/abs/2403.06448
  38. [41]H. Kim, T. A. Lamb, A. Bibi, P. Torr, and Y. Gal, “Detecting LLM hallucination through layer-wise information deficiency: Analysis of ambiguous prompts and unanswerable questions,” in Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing, C. Christodoulopoulos, T. Chakraborty, C. Rose, and V. Peng, Eds. Suzhou, China: Association for Computational Linguistics, Nov. 2025, pp. 32310–32322. [Online]. Available: https://aclanthology.org/2025.emnlp-main.1644/arxiv.org/abs/2412.10246
  39. [42]P. Schober, C. Boer, and L. A. Schwarte, “Correlation coefficients: Appropriate use and interpretation,” Anesthesia & Analgesia, vol. 126, no. 5, 2018.DOI

AI tools statement

No AI-use declaration is available for this version in Valency.

The available record does not establish whether AI systems or models contributed to this work.

How AI tools are recorded

Paper details

Cite this paper

Publication

Published
Version
Latest

Data & code

Code, data, proofs and workflows the authors linked for testing, review and reproduction. These links are part of this work’s metadata and are released under the same license as the rest of that metadata. Valency doesn’t host the files; each keeps the license set where it’s hosted.

Pick where to look, or just type