Neuro-symbolic search hits P-completeness: inverted index traversal turns out harder than thought

7 September 20269 views

Analysis of a new theoretical work that proves the fundamental computational complexity of Boolean queries over an inverted index and shows why classical evaluation strategies lead to exponential expansion or huge memory costs. The author proposes the ComputePN algorithm, which handles such queries without the penalty of universal scanning.

Neuro-symbolic search hits P-completeness: inverted index traversal turns out harder than thought

Theoretical Barrier for Neurosymbolic Agents

Modern AI agents built on neurosymbolic principles increasingly use search infrastructure as external memory. The reasoning chain is compiled not into a simple set of keywords, but into deeply nested boolean queries with negations and branchings. Such queries look natural to a programmer, but for a classic inverted index, they become a serious challenge.

A recent preprint by Amir Aavani on arXiv (2601.18747, latest version from August 17, 2026) shows that the issue is not laziness on the part of search engine developers. The author formalizes the query language L_R, represented as a directed acyclic graph, and rigorously proves that evaluating such a query over an index is a P-complete problem. In other words, in the general case, this process is unlikely to be efficiently parallelized across many cores — unless the classes P and NC turn out to be equal, which most theorists consider highly unlikely.

The work spans several fields at once — information retrieval, artificial intelligence, complexity theory, natural language processing, and databases. This is no coincidence: the problem lies at the intersection of AI and classical search technologies.

Two Traditional Approaches and Their Weaknesses

When a query is executed over an inverted index, one of two strategies is typically used: iterative document-at-a-time processing or materialization of intermediate term lists (Term-at-a-Time). Each has its own "skeleton in the closet."

  • Document-at-a-Time relies on stateful iterators that advance through sorted document lists. It turns out that such iterators are structurally limited to the class of NC¹ circuits. If the query logic contains reconvergent branches — that is, multiple graph paths converging on a single node — naively unrolling these branches into a tree leads to an exponential explosion: worst-case complexity reaches O(2^{|Q|}), where |Q| is the query size.
  • Term-at-a-Time tries to solve the problem differently: each query node is materialized as a document list. But to compute logical negation, this approach must know the entire document universe |U| to understand which documents are not in the result. This incurs a penalty of Ω(|U|) — the so-called universal scan. For large collections, this means effectively scanning the entire database for a single "not."

Thus, each of the two classical methods handles its limited role, but on non-monotonic DAG queries, they hit a wall either in time or in space. Until now, this was considered an inevitable price for expressiveness.

The ComputePN Algorithm

Amir Aavani proposes a workaround — a deterministic algorithm called ComputePN, specifically tailored for sparse data. The key idea is to separate logical negation from materializing the entire universe. Instead of building a full list of "all documents that are absent," ComputePN uses a dual representation of each node: a "positive-negative" pair stores both what is included in the result and what is guaranteed not to be.

This approach allows accounting only for active documents — those that actually participate in computations. Intermediate results are memoized directly on the query graph, so the same subexpressions are not recomputed multiple times. The final complexity is estimated as O(|Q| · |U_active|), where U_active is the set of affected documents, not the entire universe.

In practice, this means that heavy cases with negations and converging branches are no longer fatal. If the real collection is large but the query touches only a small part of it, ComputePN remains efficient.

What This Means for Search Engines and AI

The main takeaway of the work is not that traversing an inverted index is fundamentally impossible to speed up. Rather, the opposite: the author shows how to natively compute P-complete queries while avoiding the two main pitfalls — combinatorial tree unrolling and scanning all documents for negation.

For hybrid neurosymbolic systems, this is an important signal. LLM agents generate increasingly sophisticated queries, and the search backend must be able to serve them without catastrophic degradation. Theoretical P-completeness remains a warning for developers of parallel architectures, but ComputePN shows that sound engineering can circumvent the worst-case scenarios.

However, much work remains before the algorithm appears in production systems. The proposed scheme requires careful handling of dual representations and memoization at the level of a real search engine. But the fact that the problem has finally received a rigorous theoretical foundation is significant in itself: developers now at least know what complexity they are dealing with and which techniques actually help.

Frequently asked questions

Related materials

All materials
Neuro-symbolic search hits P-completeness: inverted index traversal turns out harder than thought