When a user asks for a "screw-in connector for a DIN rail" and the catalog only knows the formal class names from a standards hierarchy, retrieval fails in one of two ways. It may miss the right items because the words differ, which is vocabulary mismatch. Or it may find them along with many look-alike items from the wrong class, and a language model reading that context then picks the wrong one, which is noise sensitivity. Database theory has a mature tool for the first failure that RAG (retrieval-augmented generation, where a model answers from retrieved text) has never used. That tool is first-order rewriting: compiling an ontology's rules, such as "every PushInTerminalBlock is a TerminalBlock," into an ordinary database query whose answers are guaranteed correct. We propose to use this compilation as a hard filter in front of a neural ranker and reader. A small language model translates only the structured part of the user's request into a query over the ontology's vocabulary. A sound rewriting engine expands that query into a union of plain SQL subqueries. A dense ranker orders items only within the certified set, and the rewriting is truncated to a context budget.
The opportunity comes from a property the logic literature treats as a footnote and the RAG literature has not exploited. Every disjunct of a rewritten union is individually sound, so any subset of the union still returns only correct answers. Completeness can therefore be traded against the reader's context budget without ever admitting an item the ontology rules out. Disjointness axioms ("a fuse is never a terminal block") add a second, negative filter that removes lexically similar distractors before the reader sees them. The claim to test is this: on structured-catalog and knowledge-graph question answering, deductive filtering lowers the fraction of distractors in the reader's context and improves end-to-end correctness on colloquial queries, compared with dense retrieval plus reranking, LLM query rewriting, and post-retrieval compression.
What Exists and Where the Gap Is
First-order rewritability is the question of whether answering a query through an ontology can be turned into evaluating a single first-order (SQL-expressible) query over the raw data. Data Complexity of Query Answering in Description Logics shows that the DL-Lite family of ontology languages is the frontier where this is guaranteed. Adding qualified existentials on the left, or adding disjunction, pushes query answering beyond first-order. The same work shows that a rewritten union can grow exponentially. This paper supplies our method and defines our constraint: the ontology must be kept inside DL-Lite, and the union's size is the quantity we budget. Benchmarking Ontology-Based Query Rewriting Systems found that every tested rewriter (CGLLR, Requiem, Rapid, IQAROS, Nyaya) was unsound or incomplete on at least one Sygenia ontology. That is a warning: a soundness claim is only as good as the implementation, so we verify ours on Sygenia before using it.
The vocabulary-mismatch work splits into two camps. Neural rewriters are trained against downstream signals. Query Rewriting in Retrieval-Augmented LLMs uses PPO with reader rewards, RaFe uses reranker feedback, and Think Then Rewrite generates reasoning chains under a mutual-information reward. All three produce free text with no check that the rewrite preserves the user's constraints. The structure-grounded camp relies on lexical heuristics. RQUERY expands words through WordNet and ranks candidates by co-occurrence in knowledge-graph triples. ECLASS-Augmented Semantic Product Search prepends classification codes as flat text to product embeddings.
That second paper gives us our motivating evidence twice over. First, LLM query rewriting with Qwen3-8B made retrieval worse because it dropped technical constraints. Second, richer "Advanced" metadata did worse than "Basic," because flattened taxonomy text acted as noise in the embedding. Both results suggest that the taxonomy should be used as logic rather than as text.
OG-RAG is the closest ontology-RAG system. It builds an ontology-shaped hypergraph and retrieves a minimal covering set of hyperedges. However, it treats the ontology as an index layout and performs no deduction, no subclass unfolding, and no disjointness pruning. Our proposal differs in exactly those respects.
On the reader side, several papers establish that noise is the failure we must prevent rather than repair. Improving Zero-shot Reader by Reducing Distractions shows that reader accuracy falls as more documents are retrieved and that wrong answers come with high confidence. UDA reports that GPT-4 drops from 45.9 to 0.4 on FinHybrid when it reads full documents instead of targeted retrieval. Ext2Gen and CompAct repair noise after retrieval, by training the reader to extract evidence or by compressing documents iteratively. We act earlier, at query time, and with guarantees. These post-hoc methods are therefore competitors, and they are also complements.
Core Claim
The user's request is split into two parts. The first is a structured part that can be expressed in the ontology's vocabulary (classes, properties, value ranges). The second is a residual of free-text constraints. A small model maps the structured part to a conjunctive query $q$ over the ontology signature, and the mapping is checked so that every predicate exists in the ontology. A verified DL-Lite rewriter compiles $q$ with the ontology rules into a union $Q = q_1 \lor \dots \lor q_n$, which is evaluated in SQL.
Because each $q_i$ is sound, we may keep any subset $S$ of the disjuncts. We choose $S$ to fit a context budget $B$:
$$ S^\star = \arg\max_{S \subseteq \{1..n\}} \sum_{i \in S} r_i \quad \text{subject to} \quad \sum_{i \in S} c_i \le B . $$
Here $r_i$ is the summed reranker relevance of the items matched by $q_i$ against the residual text, and $c_i$ is their token cost. Both are cheap to compute because SQL returns match cardinalities directly. We solve the selection greedily by the ratio $r_i/c_i$. Disjointness axioms are compiled into negative filters that exclude items whose asserted class conflicts with the query class.
The guarantee is narrow and stated honestly. It says that no item outside the certain answers of $q$ enters the context. It does not say $q$ is the right translation of the user's request. The guarantee holds relative to the mapping step, and measuring how often that mapping fails is part of the work.
Research Program
The first stage builds the ontologies. We encode the ECLASS 13.0 hierarchy (CL1 to CL4) for the Phoenix Contact catalog as DL-Lite concept inclusions. Property typing and sibling disjointness are added only where the standard asserts them. For the DBpedia subset of the ESWC 2015 Schema-Agnostic Challenge, we use the subclass, domain/range and disjointness axioms of the DBpedia ontology. In both cases, axioms that fall outside DL-Lite, such as qualified existentials on the left, are dropped and logged. The fraction dropped is itself a finding about how much real taxonomies fit inside the first-order frontier.
The second stage builds a PerfectRef-style rewriter and validates it on all Sygenia ontologies. On those ontologies, a rewriting must have zero soundness violations before it may be used downstream.
The third stage trains the mapping model. A 1.5B model maps queries to ontology-signature conjunctive queries. It is trained on automatically generated pairs: sample a catalog item, read off its class and attributes as the target query, and have an LLM write a colloquial paraphrase. Decoding is constrained to the signature, which rules out hallucinated predicates by construction.
The fourth stage connects the certified, budgeted candidate set to a dense ranker and an LLM reader. The reader receives each item tagged with the axiom chain that admitted it.
Baselines
The naive reference point is BM25 over raw item text. On the ECLASS expert queries it scores Hit_Rate@5 of 31.4% according to ECLASS-Augmented Semantic Product Search. Its role is to calibrate how much of the gap any method closes.
The strongest existing competitor is that paper's basicrr configuration: dense retrieval over Basic product data with ECLASS text prepended, followed by reranking. It reports Hit_Rate@5 of 94.3% on expert queries, at a mean latency of 11.45 seconds for top_k=200. It is strongest because it already exploits the same taxonomy, only as text, and it was tuned on this exact catalog. We run it with the same embedding model, the same reranker and the same top_k as our system, so the deductive filter is the only difference. On expert queries we expect at best parity. Beating it means a statistically significant Hit_Rate@5 gain on a new colloquial query set, plus a lower distractor rate in the reader's context. We define distractor rate as the share of context items whose class is disjoint from or unrelated to the gold item's class. Both must hold at equal or lower latency.
On DBpedia, the reference is RQUERY. It reports MRR of 0.53 on mismatch queries and 0.64 on non-mismatch queries. Beating it means exceeding 0.53 on mismatch queries without falling below 0.64 on non-mismatch ones.
The neural-rewriting baselines are a zero-shot Qwen3-8B rewriter, reproducing the ECLASS degradation finding, and a RaFe-trained rewriter of the same 1.5B size as our mapping model. The RaFe rewriter gets the same synthetic training queries and reranker. This isolates whether a formal target language beats free-text rewriting at equal model scale and equal supervision.
The post-retrieval baseline gives the full, unbudgeted union to CompAct-style compression and to an Ext2Gen-style extract-then-answer reader. It tests whether budgeting at query time beats compressing afterwards.
Three ablations isolate our ingredients. The first keeps the full union and drops the budget. The second keeps the budget but selects a random subset of disjuncts. The third removes the disjointness filters. The third ablation is the cleanest test of whether negative axioms specifically remove distractors.
Why not just…?
Why not just put the whole catalog and ontology into a long-context model? UDA reports that GPT-4 falls from 45.9 to 0.4 on FinHybrid under full-document ingestion. Improving Zero-shot Reader shows that accuracy decreases as the number of documents grows. A ten-thousand-item catalog is a worse case than either. We include a long-context run on a sampled sub-catalog only as a sanity check.
Why not just prompt an LLM to rewrite the query? The ECLASS study found that this hurt retrieval, because the rewrite dropped constraints. Our design keeps a model in the loop but changes what it outputs: a query over a fixed signature, checked by construction, instead of free text. The same-size RaFe comparison tells us whether the formal target or simply the training is what helps.
Why not just use dense retrieval with a reranker, which already reaches 94.3%? This is the real threat. On expert queries, which reuse catalog vocabulary, there may be little headroom left. Our bet is that the advantage appears on colloquial queries, where look-alike items from disjoint classes score high in embedding space, and in the downstream reader, where those look-alikes cause wrong picks. If the colloquial set shows no gain in Hit_Rate@5 or in distractor rate, then the deductive filter has no purpose on catalogs of this kind, and we will report that.
Why not just compress after retrieval? Ext2Gen shows that integrated extraction beats standalone compressors. Still, any compressor sees only what retrieval gave it, and it can drop multi-hop clues, as CompAct notes. The unbudgeted-union-plus-compressor baseline settles the question directly. The two approaches can also be stacked, and we report the combination.
Decisive Checks
Four results decide the proposal. First, soundness on Sygenia must be perfect; otherwise no guarantee claims are made. Second, on a held-out colloquial ECLASS query set, the full system should exceed basicrr on Hit_Rate@5 and cut distractor rate. It should also beat the random-subset ablation, which would show that budgeted selection is more than truncation. Third, removing disjointness filters should raise distractor rate and lower LLM-reader item-selection accuracy in a noise-injection protocol modeled on Ext2Gen, in which the gold item is placed among 5 to 25 sibling-class distractors at random positions. Fourth, mapping errors must be attributed. We hand-label 300 failures and count how many come from wrong queries produced by the mapping model, how many from axioms dropped outside DL-Lite, and how many from ranking, which tells us where the guarantee runs out.
On DBpedia, beating RQUERY's 0.53 MRR on mismatch queries while holding 0.64 on clean queries would show that the approach transfers beyond a single industrial taxonomy.
References
- Data Complexity of Query Answering in Description Logics (Extended Abstract)
- Benchmarking Ontology-Based Query Rewriting Systems
- Query Rewriting in Retrieval-Augmented Large Language Models
- RaFe: Ranking Feedback Improves Query Rewriting for RAG
- Think Then Rewrite: Reasoning Enhanced Query Rewriting for Domain Specific Retrieval
- RQUERY: Rewriting Natural Language Queries on Knowledge Graphs to Alleviate the Vocabulary Mismatch Problem
- ECLASS-Augmented Semantic Product Search for Electronic Components
- OG-RAG: Ontology-grounded retrieval-augmented generation for large language models
- Improving Zero-shot Reader by Reducing Distractions from Irrelevant Documents in Open-Domain Question Answering
- UDA: A Benchmark Suite for Retrieval Augmented Generation in Real-World Document Analysis
- Ext2Gen: Alignment through Unified Extraction and Generation for Robust Retrieval-Augmented Generation
- CompAct: Compressing Retrieved Documents Actively for Question Answering