Logic-Based Hallucinations
- Logic-based hallucinations are defined as failures where outputs not only misrepresent facts but also break the logical entailments between source inputs and generated text.
- They span diverse issues including unsupported reasoning in chain-of-thought, overgeneration in data-to-text systems, and code that is executable yet logically flawed.
- Research offers formal taxonomies, detection frameworks, and mitigation strategies to improve reasoning fidelity and manage these logical inconsistencies.
Logic-based hallucinations are failures in which a model’s output is not merely factually incorrect, but violates a logical constraint that should govern the relation between source, reasoning process, task specification, and response. Recent research treats the phenomenon as heterogeneous rather than unitary. In data-to-text generation, the central issue is whether output matches input under a consequence relation rather than whether it is true in the world (Deemter, 2024). In reasoning models, hallucination can emerge as a trajectory-level corruption of Chain-of-Thought (CoT), with unsupported claims being propagated, reflected upon, and reinforced (Lu et al., 19 May 2025). In code and formal translation, hallucination often denotes executable yet logically wrong programs, semantically invalid API usage, or malformed logical structure (Tian et al., 2024, Oli, 24 Feb 2026, Pan et al., 2 Dec 2025). In multimodal and agentic systems, the same family of failures appears as broken evidence-mediated inference, invalid plans, or logically flawed task decomposition (Xiong et al., 16 Mar 2026, Lin et al., 23 Sep 2025). The literature is also divided on terminology: several authors argue that many such failures are better understood as confabulation, suggestibility, cognitive dissonance, or source-monitoring failure than as “hallucination” in the strict psychological sense (Berberette et al., 2024).
1. Terminological scope and competing definitions
The first major issue is definitional instability. In structured data-to-text generation, one influential critique is that existing discussions of hallucination and omission are too imprecise to support reliable evaluation or mitigation, because they partition the error space in incompatible ways (Deemter, 2024). Dusek and Kasner define hallucination and omission asymmetrically through follow-from relations between formal input and generated sentence. Ji et al. distinguish intrinsic hallucination, defined as output that contradicts the source, from extrinsic hallucination, defined as output that can neither be supported nor contradicted by the source. Thomson and Reiter propose a more surface-oriented taxonomy with categories such as incorrect number, incorrect named entity, incorrect word, non-checkable information, and context errors. The logical critique is that these schemes collapse distinct relations into the same label and can disagree substantially on the same example.
A second line of work argues that the term itself is psychologically misleading. In psychology, hallucinations are perceptual experiences without external stimuli, whereas LLMs do not perceive or experience anything. A psychology-informed taxonomy therefore maps many so-called hallucinations to confabulation, source amnesia, suggestibility, availability heuristics, recency effect, and cognitive dissonance (Berberette et al., 2024). Within that framework, confabulation is defined as “a confident, but misleading output generated with the intention of accurately fulfilling the user's prompt,” suggestibility corresponds to inference being altered by leading prompts, and cognitive dissonance captures contradictory outputs produced under conflicting training information.
The term is extended even further in work on “human hallucinations,” where it denotes unwarranted beliefs such as pseudoscience, superstition, conspiracy thinking, confirmation bias, motivated reasoning, and causal illusion (Sundaram et al., 2024). That paper formalizes idealized rationality in doxastic logic through the “perfect skeptic” condition, , and a no-contradiction condition, . It then characterizes LLM behavior as exhibiting both inconsistency and inaccuracy, using and , and calls the resulting pattern “unstable rationality.”
Taken together, these works indicate that “logic-based hallucinations” is best treated as an umbrella for failures of entailment, consistency, inference, provenance, and plan validity, rather than as a single canonical error type. This suggests that any encyclopedia treatment must distinguish source mismatch, unsupported extrapolation, contradiction, reasoning corruption, and confidence miscalibration rather than treating them as interchangeable.
2. Classical-logic matching between input and output
A precise formalization is given by a classical-logic synthesis for data-to-text generation (Deemter, 2024). Let mean that the output follows from the input, and mean that the input follows from the output. Assuming both input and output are internally consistent, the relation partitions into the following cases.
- Case 0: and . Input and output are well matched.
- Case 1a: and , with 0. This is normal omission.
- Case 1b: 1 and 2, with 3. The output is tautological.
- Case 2a: 4 and 5, with 6. This is normal overgeneration.
- Case 2b: 7 and 8, with 9. The output is contradictory.
- Case 3a: 0, 1, and 2. Input and output are logically independent.
- Case 3b: 3, 4, and 5. The output contradicts the input.
The importance of this partition is that many uses of “hallucination” conflate at least four distinct relations: unsupported but compatible overgeneration, contradictory overgeneration, logical independence, and outright contradiction. Under this view, what is loosely called hallucination may correspond to 2a, 2b, 3a, or 3b, while omission corresponds to 1a or 1b. The framework is explicitly a logic of matching rather than a logic of worldly truth: the question is whether the output matches the input, not whether it is objectively true.
The paper clarifies the taxonomy through formal examples. For an input such as 6, the sentence “7 is an Italian restaurant” is 1a; “8 is an affordable veggie Italian restaurant” is 2a; “9 is a veggie restaurant” is 3a; and “0 is an affordable Norwegian restaurant” is 3b. Analogous distinctions apply to numerical inputs: if the input is that temperature is above 1 Celsius, then “above 2” behaves like overgeneration, while “below 3” is contradiction.
The framework also makes its own limits explicit. Computational implementation depends on Natural Language Inference, yet NLI systems struggle with ambiguity, vagueness, and fuzzy thresholds. The classification must be pragmatically aware, because pronouns, implicatures, presuppositions, irony, and metaphor affect whether one sentence follows from another. Classical consequence also does not measure how much content was added or omitted and does not capture topical relevance. For open-ended LLM applications, the relevant notion of “input” is often unclear; if all influencing data were treated as input, inconsistency would push analysis toward paraconsistent logic.
3. Reasoning-chain hallucinations in large reasoning models
In reasoning-oriented LLMs, logic-based hallucination is increasingly modeled as a trajectory-level phenomenon rather than a single false proposition. One black-box auditing framework defines hallucination relative to a constrained real-world knowledge space and distinguishes two types: Type I: Seen but Unlearned, where a fact 4 appears in training data but is not internalized, 5; and Type II: Unseen or Incorrect, where 6 (Lu et al., 19 May 2025). In long CoT, the key claim is that unsupported claims can propagate downstream, be revisited through reflection, and accumulate support from later elaborations. Hallucinated cases show more reflection, hedging, and hesitation than controls, and only 22.5% of intervention edits successfully reversed a hallucinated outcome. This resistance to correction is named chain disloyalty.
A mechanistic perspective further argues that reasoning hallucinations arise from internal reasoning dynamics rather than from output errors alone (Sun et al., 19 May 2025). That work introduces the Reasoning Score, derived from LogitLens projections of later-layer hidden states, to distinguish shallow pattern matching from deeper reasoning. Using ReTruthQA, it identifies two major patterns: early-stage fluctuation in reasoning depth, quantified by a coefficient of variation over early-step Reasoning Scores, and incorrect backtracking to flawed prior steps, measured by an attention-based trace score over later steps. It also reports a third pattern, overthinking, in which higher Reasoning Score correlates positively with perplexity. These observations motivate Reasoning Hallucination Detection (RHD) and the reward-shaping method GRPO-R, which encourages deep reasoning while clipping excessive overthinking.
A complementary empirical study asks whether large reasoning models are more prone to hallucination and concludes that the answer depends strongly on the post-training pipeline (Yao et al., 29 May 2025). Cold-start SFT + verifiable-reward RL generally alleviates hallucination, while RL-only and SFT-only pipelines introduce new failure modes. Two behaviors are especially salient. Flaw Repetition is the repeated generation of different surface-level reasoning attempts that preserve the same flawed underlying logic. Think-Answer Mismatch occurs when the final answer does not semantically align with the preceding CoT. The same paper connects increased hallucination to misalignment between model uncertainty and factual accuracy, using repeated-answer agreement and Expected Calibration Error (ECE) as probes.
These works jointly shift the locus of analysis from final-answer correctness to reasoning fidelity. A plausible implication is that in long-CoT systems, logical hallucination is often not a missing fact but a self-reinforcing interaction among unsupported premises, reflective bias, and defective answer commitment.
4. Code generation, formal translation, and symbolic grounding
In code generation, logic-based hallucination is often defined operationally through execution and task fulfillment rather than textual plausibility. CodeHalu defines code hallucination as code that appears syntactically correct and semantically plausible but fails during execution or fails to meet the task specification (Tian et al., 2024). Its logic category is divided into logic deviation, where code runs but yields incorrect or non-optimal results, and logic breakdown, where generation becomes stuttering, repetitive, or incoherent. In CodeHaluEval, built from 8,883 samples across 699 tasks, the logic category is the largest, with 173 tasks and 3,612 samples, and the paper concludes that logic hallucinations are “currently the greatest challenge for LLMs.”
ManiBench extends the notion to educational animation code, where correctness depends on API fidelity and temporal-pedagogical structure (Oli, 24 Feb 2026). It targets Syntactic Hallucinations, defined as valid Python that uses nonexistent, deprecated, or version-incompatible Manim APIs, and Visual-Logic Drift, defined as divergence between the intended mathematical narrative and the rendered animation even when execution succeeds. The benchmark is grounded in analysis of about 53,000 lines of 3Blue1Brown’s ManimGL code, 143 scene classes, 120 visual techniques, and 145 documented GL→CE incompatibilities. Its four metrics are Executability, Version-Conflict Error Rate (VCER), Alignment Score, and Coverage Score. The key claim is that standard benchmarks such as HumanEval and MBPP test whether code works, whereas ManiBench tests whether code teaches correctly.
In formal semantic translation, Lang2Logic treats hallucination as structurally invalid logical output that breaks downstream reasoning (Pan et al., 2 Dec 2025). The failure modes include incorrectly reused variables, misclassified literals, spurious operators, and malformed mappings from syntax to logic. The pipeline stages are: English sentence 7 logical expression, logical expression 8 CNF, CNF simplification, and hallucination detection and feedback-based correction. The framework uses a custom context-free grammar with NLTK, Lark, and SymPy, and reports 100% improvement on the same hallucination type of inputs after feeding hallucinated outputs back into the model for fine-tuning.
A different response is to eliminate free-form answer generation entirely. LP-LM uses Prolog Definite Clause Grammar (DCG) parsing to map questions into Prolog terms and execute them against a knowledge base of facts also represented as Prolog terms (Wu et al., 13 Feb 2025). The architecture is: natural language 9 DCG parse tree 0 Prolog term 1 KB lookup via unification. Because answers are derived by matching explicit facts rather than by statistical generation, the system claims to “always produce answers that are reliable” within its supported QA setting.
These systems show that logic-based hallucination in computationally structured tasks is not reducible to syntax. A program may execute yet fail logically, a formula may parse yet distort semantics, and an animation may render yet violate causal or pedagogical structure.
5. Detection, auditing, and diagnostic frameworks
Detection research increasingly separates factual inconsistency from logical fallacy. One paper formalizes a Detection Dilemma: Internal State Probing (ISP) works better on fact-intensive hallucinations, while Chain-of-Thought Verification (CoTV) works better on logic-intensive hallucinations, and neither alone handles both robustly (Song et al., 13 Oct 2025). To bridge the gap, it introduces a three-path diagnostic setup consisting of a Direct Answer Path, a Reasoning-Augmented Path, and a Reverse-Inference Path, together with a Structured Semantic Trajectory List and a segment-aware temporalized cross-attention module. Evaluated on TruthfulQA, TriviaQA, and GSM8K using Qwen2.5-7B and LLaMA2-7B-Chat, the framework reports AUROC values of 84.03, 85.68, and 79.15 for Qwen2.5-7B, with gains of +4.72, +4.16, and +2.60 over the best baselines.
A logic-guided testing approach appears in Drowzee, which targets fact-conflicting hallucination (FCH) through temporal logic and metamorphic testing (Li et al., 19 Feb 2025). The system constructs a factual knowledge base from Wikipedia and Wikidata with 54,483 entities and 1,647,206 facts, then generates 7,200 non-temporal test cases and 1,800 temporal test cases across 9 domains. It uses two semantic-aware oracles: an Edge Vector Metamorphic Oracle based on Jaccard similarity over graph edges and a Node Vector Metamorphic Oracle over graph nodes. The reported hallucination rates range from 24.7% to 59.8% for non-temporal cases and from 16.7% to 39.2% for temporal cases. The paper’s central empirical conclusion is that error inference is the most common category.
In vision-LLMs, diagnosis is explicitly reframed from output error to cognitive trajectory (Xiong et al., 16 Mar 2026). The model’s reasoning process is summarized by the 3D cognitive state vector 2, where Perceptual Entropy measures uncertainty in evidence generation, Inferential Conflict measures illicit direct influence from image to answer bypassing evidence, and Decision Entropy measures answer uncertainty. Hallucination is then treated as geometric anomaly detection in a learned cognitive state space, with score 3. On POPE, MME, and MS-COCO, the framework reports average AUC values of 0.858 on POPE adversarial and 0.7960 on MME.
Across these studies, the methodological trend is clear: logic-based hallucination is increasingly detected by structured verification of trajectories, constraints, or causal relations rather than by surface confidence alone.
6. Causal accounts, mitigation strategies, and theoretical limits
Several recent works explain logic-based hallucination through internal representation or input sensitivity rather than through generation noise alone. Relational Linearity is a Predictor of Hallucinations studies synthetic entities that are unknown to the model by construction and finds a strong positive correlation between relational linearity and hallucination rate, with Pearson 4 across four models (Lu et al., 16 Jan 2026). The proposed explanation is that more linear relations are stored more abstractly, making it easier for the model to generate a plausible object for an unknown subject and harder to recognize that it does not know the answer.
Another causal framing treats hallucination as an adversarial property of transformers. LLM Lies shows that even nonsensical random-token prompts can induce a model to emit a predefined false answer, formalizing this as a hallucination attack (Yao et al., 2023). Reported success rates are 92.31% and 80.77% for weak semantic and out-of-distribution attacks on Vicuna-7B, and 53.85% and 30.77% on LLaMA2-7B-chat. The paper proposes an entropy threshold defense based on first-token entropy; with a threshold of about 1.6, it allows all raw prompts to be answered normally while refusing 46.1% of out-of-distribution prompts and 61.5% of weak semantic prompts.
Mitigation can also be structural. MIH-TCCT targets inconsistent hallucination, defined as contradiction with prompt/source or contradiction among generated sentences, through event-driven text-code cyclic training (You et al., 13 Feb 2025). Its three stages are filter event-like text, convert text to code and code back to text cyclically, and assess the generated code’s quality using a thresholded similarity score with 5. The method uses 3 iterations / epochs and reports strong gains on CNN/Daily Mail and HaluEval, while emphasizing that cyclic training has the largest effect in its ablation study.
At the theoretical level, one paper reconciles inevitability with practical mitigation (Suzuki et al., 15 Feb 2025). It proves a computability-theoretic result: for some acceptable-output map 6, every computable LLM hallucinates on an infinite set of inputs. It also proves a probabilistic result: given sufficiently large, qualified training data and a lower bound on the input-length CDF, there exists a trainer whose hallucinations are statistically negligible. The central distinction is between infinite cardinality and probability mass: an infinite hallucination set may still carry arbitrarily small probability.
Finally, a survey of LLM-based agents locates logic-based hallucination inside the full agent loop (Lin et al., 23 Sep 2025). Its most relevant family is Reasoning Hallucinations, defined as cases where agents generate “seemingly plausible plans which are in fact logically flawed or unsupported.” The survey identifies failures in Goal Understanding, Intention Decomposition, and Planning Generation, as well as eighteen triggering causes across reasoning, execution, perception, memorization, and communication. Recommended responses include Chain-of-Thought, Tree-of-Thought, constrained prompting, causal learning, self-reflection, self-consistency, self-questioning, and neural-symbolic methods.
The resulting picture is neither that logic-based hallucinations are a single defect nor that they are eliminable by a single fix. The literature instead supports a layered view: precise formal taxonomies clarify source-output mismatch; trajectory analysis exposes self-reinforcing reasoning failures; domain-specific benchmarks show that execution or fluency is often insufficient; and mitigation ranges from symbolic grounding and cyclic training to adversarial screening and representation-aware modeling. A plausible implication is that progress depends less on reducing a monolithic “hallucination rate” than on identifying which logical relation has failed, at which stage, and under what task-specific risk profile.