--:--:-- PKT
← Back to Research

LogicGuard.

LogicGuard: A Neuro-Symbolic Middleware for Deterministic Hallucination Interception in Large Language Models Using Aristotelian-Avicennian Syllogistic Frameworks

Hamza Naseem, Moiz Ali • February 23, 2026

Abstract

Large Language Models (LLMs) generate fluent, open-ended text, but they have no built-in mechanism to enforce logically necessary inferences. When a model claims "not all squares are rectangles," or assigns mammalian traits to fish, the error is not a factual slip that better retrieval could fix. It is a structural violation of deductive constraints that hold independently of any corpus or prompting strategy.

This paper presents LogicGuard, a hybrid neuro-symbolic middleware that enforces deterministic logical constraints on LLM outputs by operationalizing the syllogistic framework (Qiyas) developed by Ibn Sina (Avicenna, 980–1037 CE). LogicGuard classifies each model output into one of four Avicennian epistemic states: Yaqeen (Certainty), Zann (Probability), Shakk (Doubt), and Wahm (Illusion), and intercepts any response that falls into the Wahm state before it reaches the user.

The system runs a strict two-stage pipeline. A constrained LLM first acts as a semantic parser, extracting a zero-temperature, JSON-only representation of the query. This structured output is then passed to a Breadth-First Search (BFS) graph validator, which performs all logical reasoning deterministically, with no further LLM involvement at this stage. We evaluated LogicGuard on a 175-query formal syllogism dataset covering biological taxonomy, geometric relations, and physical conditionals, using three structurally different LLMs: LLaMA2-7B, Mistral-7B, and LLaMA3.2-3B. Across all three models and 525 total evaluations, LogicGuard achieved 100% precision and 100% specificity, with zero false positives. Hallucination interception rates reached 88.6%, 100.0%, and 92.6% for the three models respectively. Overall accuracy improved significantly, and an out-of-domain test on the full TruthfulQA benchmark showed a 99.5% non-interference rate, confirming that LogicGuard only activates within its verified competence scope.