Papers
Topics
Authors
Recent
Search
2000 character limit reached

Logical Query Trees: Structure & Optimization

Updated 5 July 2026
  • Logical Query Trees are explicit structured representations that organize subqueries, logical operators, and dependencies to facilitate clear query planning.
  • They enable efficient execution by decomposing complex queries into atomic units and aggregating results through a cost-guided dynamic programming approach.
  • LQTs are applied across diverse environments, from natural language exploratory reasoning to knowledge graph query answering and tree-pattern query evaluation.

Searching arXiv for the requested paper and closely related work on logical/query computation trees. arxiv_search(query="(Xu et al., 1 Jul 2026) PlanRAG logical query trees exploratory reasoning problems", max_results=5, sort_by="submittedDate") to=arxiv_search code 】【:】【“】【json {"results":[{"arxiv_id":"(Xu et al., 1 Jul 2026)","version":"v1","title":"When RAG Meets Query Planning: Logical Query Trees for Resolving Exploratory Reasoning Problems","authors":["Jingyao Zhang","Jian-Yun Nie","Ji-Rong Wen"],"categories":["cs.IR","cs.DB"],"published":"2026-07-01","updated":"2026-07-01","pdf_url":"http://arxiv.org/pdf/([2607.00508](/papers/2607.00508))v1","abs_url":"https://arxiv.org/abs/([2607.00508](/papers/2607.00508))v1"}]} Searching for prior uses of logical/query computation trees in graph querying, logical query answering, and tree-pattern query processing. arxiv_search(query="query computation tree optimization complex logical queries arXiv logical query tree", max_results=10, sort_by="relevance") to=arxiv_search code 】【:】【“】【json {"results":[{"arxiv_id":"(Bai et al., 2022)","version":"v2","title":"Answering Complex Logical Queries on Knowledge Graphs via Query Computation Tree Optimization","authors":["Yanghua Xiao","Yifei Wang","Wenxuan Tu","Yixin Cao","Lei Hou","Juanzi Li"],"categories":["cs.LG","cs.AI"],"published":"2022-12-19","updated":"2023-08-16","pdf_url":"http://arxiv.org/pdf/([2212.09567](/papers/2212.09567))v2","abs_url":"https://arxiv.org/abs/([2212.09567](/papers/2212.09567))v2"},{"arxiv_id":"([2406.14880](/papers/2406.14880))","version":"v1","title":"[Pathformer](https://www.emergentmind.com/topics/pathformer): Recursive Path Query Encoding for Complex Logical Query Answering","authors":["Yiqian Yang","Shiqi Wang","Han Xiao","Wei Wang"],"categories":["cs.LG"],"published":"2024-06-21","updated":"2024-06-21","pdf_url":"http://arxiv.org/pdf/([2406.14880](/papers/2406.14880))v1","abs_url":"https://arxiv.org/abs/([2406.14880](/papers/2406.14880))v1"}]} Searching for graph-structured tree-pattern queries and tree-like conjunctive query results that are relevant to the broader usage of logical query trees. arxiv_search(query="(Zeng et al., 2011) tree pattern queries graph structured data (Bienvenu et al., 2014) tree-like queries OWL 2 QL", max_results=10, sort_by="relevance") to=arxiv_search code 】【:】【“】【json {"results":[{"arxiv_id":"(Zeng et al., 2011)","version":"v2","title":"Adding Logical Operators to Tree Pattern Queries on Graph-Structured Data","authors":["Zhao Yan","Wenyuan Yu","Shuigeng Zhou"],"categories":["cs.DB"],"published":"2011-09-20","updated":"2013-03-14","pdf_url":"http://arxiv.org/pdf/([1109.4288](/papers/1109.4288))v2","abs_url":"https://arxiv.org/abs/([1109.4288](/papers/1109.4288))v2"},{"arxiv_id":"([1406.3047](/papers/1406.3047))","version":"v1","title":"Tree-like Queries in OWL 2 QL: Succinctness and Complexity Results","authors":["Roman Kontchakov","Carsten Lutz","David Toman","Frank Wolter","Michael Zakharyaschev"],"categories":["cs.LO"],"published":"2014-06-11","updated":"2014-06-11","pdf_url":"http://arxiv.org/pdf/([1406.3047](/papers/1406.3047))v1","abs_url":"https://arxiv.org/abs/([1406.3047](/papers/1406.3047))v1"}]} Logical Query Trees (LQTs) are explicit structural representations of query semantics that organize subqueries, logical operators, and dependency relations into a compositional object suitable for planning, optimization, or evaluation. In recent literature, the term is used most directly in PlanRAG, where an exploratory reasoning problem (ERP) in natural language is translated into a directed acyclic graph whose nodes are atomic queries and whose root yields the final answer (Xu et al., 1 Jul 2026). Closely related formulations appear as query computation trees for complex logical query answering over knowledge graphs (Bai et al., 2022, Zhang et al., 2024), as generalized tree-pattern queries over graph-structured data (Zeng et al., 2011), and as tree-shaped conjunctive queries in OWL 2 QL (Bienvenu et al., 2014). Across these settings, the common purpose is to expose query topology so that reasoning, retrieval, pruning, or rewriting can be performed in a structured rather than ad hoc manner.

1. Formal scope and main variants

In PlanRAG, an ERP is a natural-language query QQ, decomposed into a set of atomic queries Q={q1,,qn}\mathcal{Q}=\{q_1,\dots,q_n\}. The corresponding LQT is a directed acyclic graph T=(V,E)\mathcal{T}=(V,E), where each node is associated with an atomic query, each edge denotes a dependency relation, leaf nodes have no incoming dependencies and can be executed directly against a document collection, internal nodes aggregate the answers of their children, and the root corresponds to the overall final answer (Xu et al., 1 Jul 2026).

In knowledge-graph query answering, the closely related query computation tree is a directed, rooted, tree-shaped computation graph. In QTO, Tq=(Vq,Eq)T_q=(V_q,E_q) contains nodes for variable copies and constant anchors, with edge types for intersection, union, relational projection, and anti-relational projection (Bai et al., 2022). In Pathformer, the LQT consists of leaf anchors and variable nodes, while edges are labeled by projection πr\pi_r, intersection, or complement, and the root yields the denotation of the query (Zhang et al., 2024).

In graph query processing, the generalized tree-pattern query (GTPQ) is defined as an 8-tuple

Q=(Vb,Vp,Vo,Eq,fa,fe,fs),Q=(V_b,V_p,V_o,E_q,f_a,f_e,f_s),

with backbone and predicate nodes, output nodes, a directed tree over query nodes, edge labels in {PC,AD}\{PC,AD\}, attribute predicates, and propositional structural predicates (Zeng et al., 2011). In ontology-based data access, the corresponding notion is a tree-shaped conjunctive query, defined by acyclicity of its undirected primal graph; subclasses include linear queries, bounded-leaf queries, and bounded-treewidth queries (Bienvenu et al., 2014).

Context Formal object Core structural elements
PlanRAG T=(V,E)\mathcal{T}=(V,E) DAG atomic-query nodes, dependency edges, root final answer
QTO / Pathformer tree-like computation graph anchors, variables, logical/projection operators
GTPQ Q=(Vb,Vp,Vo,Eq,fa,fe,fs)Q=(V_b,V_p,V_o,E_q,f_a,f_e,f_s) PC/AD edges, attribute predicates, Boolean structural predicates
OWL 2 QL tree-shaped conjunctive query acyclic primal graph, leaves, treewidth

2. LQTs in PlanRAG for exploratory reasoning problems

PlanRAG introduces LQTs to address the mismatch between standard RAG pipelines and exploratory reasoning problems, which are described as complex queries involving high uncertainty and ambiguity. The motivating claim is that ERPs require complex reasoning with unclear paths, which tends to produce retrieval noise and error accumulation, while conventional RAG lacks an end-to-end planning mechanism for generating effective trajectories (Xu et al., 1 Jul 2026).

The construction process begins by decomposing an ERP QQ into a minimal set of atomic queries represented as relational triples,

Q={q1,,qn}\mathcal{Q}=\{q_1,\dots,q_n\}0

intended to capture every semantic unit in the query. The paper emphasizes a strict one-to-one mapping between semantic units and atomic queries so that each Q={q1,,qn}\mathcal{Q}=\{q_1,\dots,q_n\}1 is a self-contained retrieval query. It also classifies each unordered pair Q={q1,,qn}\mathcal{Q}=\{q_1,\dots,q_n\}2 into one of three relations—Parent–Child, Sibling, or Unrelated—to guide how the planner connects atomic queries into Q={q1,,qn}\mathcal{Q}=\{q_1,\dots,q_n\}3 (Xu et al., 1 Jul 2026).

The running example in the paper includes atomic queries such as Q={q1,,qn}\mathcal{Q}=\{q_1,\dots,q_n\}4: “What were the early Christian hymns?” and Q={q1,,qn}\mathcal{Q}=\{q_1,\dots,q_n\}5: “Which late antique authors composed Christian hymns?” These are then assembled into an LQT whose leaves can be executed directly and whose internal nodes aggregate intermediate results. A notable point is that, despite the name “tree,” the formal object in PlanRAG is a DAG rather than a strict rooted tree. This matters because the framework explicitly enforces cycle prevention and semantic consistency during construction (Xu et al., 1 Jul 2026).

3. Cost-guided construction and dynamic programming

PlanRAG constructs LQTs by optimizing a heuristic cost over candidate structures. The cost model is

Q={q1,,qn}\mathcal{Q}=\{q_1,\dots,q_n\}6

where Q={q1,,qn}\mathcal{Q}=\{q_1,\dots,q_n\}7 is the number of nodes, Q={q1,,qn}\mathcal{Q}=\{q_1,\dots,q_n\}8 the number of edges, Q={q1,,qn}\mathcal{Q}=\{q_1,\dots,q_n\}9 the length of the longest root–leaf path, T=(V,E)\mathcal{T}=(V,E)0 a measure of subtree height variance, and T=(V,E)\mathcal{T}=(V,E)1 a semantic-similarity score obtained by encoding the tree textually and scoring its embedding against the original query via BGE. The scalar T=(V,E)\mathcal{T}=(V,E)2 is set to 10 by grid search in order to up-weight semantic alignment (Xu et al., 1 Jul 2026).

The optimizer adapts Selinger’s bottom-up dynamic programming. If T=(V,E)\mathcal{T}=(V,E)3 denotes the minimum cost of an LQT covering a subset T=(V,E)\mathcal{T}=(V,E)4, then

T=(V,E)\mathcal{T}=(V,E)5

where T=(V,E)\mathcal{T}=(V,E)6 is the cost of merging two subtrees plus the structural terms from the cost model. The algorithm first precomputes “Unrelated” pairs via one LLM pass to prune merges, initializes singleton subsets with T=(V,E)\mathcal{T}=(V,E)7, and then enumerates partitions T=(V,E)\mathcal{T}=(V,E)8 for subsets of increasing size. A merge is accepted only if it respects semantic relations, does not create a cycle, and yields a lower cost (Xu et al., 1 Jul 2026).

Under this heuristic cost model, the resulting plan T=(V,E)\mathcal{T}=(V,E)9 is globally optimal with respect to Tq=(Vq,Eq)T_q=(V_q,E_q)0. The worst-case enumeration cost is Tq=(Vq,Eq)T_q=(V_q,E_q)1, but the paper states that in practice Tq=(Vq,Eq)T_q=(V_q,E_q)2, and that prefiltering “Unrelated” pairs reduces expected LLM calls to Tq=(Vq,Eq)T_q=(V_q,E_q)3. At the same time, no formal I/O, CPU, or memory guarantees of the kind common in relational database systems are claimed; instead, the design is said to bias the planner away from deep, error-accumulating chains and toward balanced, semantically faithful structures (Xu et al., 1 Jul 2026).

4. Bottom-up execution over LQTs

Once an LQT has been selected, PlanRAG executes it in a bottom-up, layer-by-layer manner. For a leaf node Tq=(Vq,Eq)T_q=(V_q,E_q)4,

Tq=(Vq,Eq)T_q=(V_q,E_q)5

For an internal node Tq=(Vq,Eq)T_q=(V_q,E_q)6, the framework first aggregates children’s results,

Tq=(Vq,Eq)T_q=(V_q,E_q)7

then rewrites the local query,

Tq=(Vq,Eq)T_q=(V_q,E_q)8

and finally performs retrieval and generation again to obtain

Tq=(Vq,Eq)T_q=(V_q,E_q)9

Intermediate answers are propagated upward until the root yields the final response (Xu et al., 1 Jul 2026).

A central engineering feature is concurrency. All nodes at the same depth are processed in parallel, and the implementation further parallelizes across multiple threads. The stated effect is a reduction in wall-clock time from πr\pi_r0 for a worst-case chain toward πr\pi_r1 for a balanced structure. This execution model is presented as a mechanism for limiting sequential error propagation while retaining structured aggregation and query rewriting (Xu et al., 1 Jul 2026).

The broader claim of PlanRAG is that LQTs address three ERP-specific difficulties: retrieval noise, error accumulation, and lack of global planning. The paper reports that PlanRAG outperforms state-of-the-art iteration-based and graph-based RAG systems on the newly constructed WikiWeb-ERP dataset. It further distinguishes its approach from iteration-based RAG, described as chain-only, and graph-based RAG, described as data-side graph walking, by emphasizing that LQTs plan over the query structure itself with an explicit cost model (Xu et al., 1 Jul 2026).

5. Query computation trees in complex logical query answering

In complex logical query answering over incomplete knowledge graphs, LQTs are used as tree-like computation graphs for exact optimization or neural encoding. QTO considers conjunctive and more general DNF queries with conjunction, disjunction, and negation, and transforms them into a rooted tree πr\pi_r2 with four edge types: intersection, union, relational projection, and anti-relational projection. Each relation πr\pi_r3 is associated with a neural adjacency matrix πr\pi_r4, and the algorithm computes for each node πr\pi_r5 a vector πr\pi_r6 of maximal truth values by a forward bottom-up pass, followed by a backward top-down pass that recovers a maximizing assignment. The paper states in Theorem 3.1 that this forward–backward scheme finds the exact global optimum. Empirically, QTO is reported to outperform the previous best results by an average of 22% MRR, with dataset-level results of 33.5% vs 26.8% on FB15k-237, 32.9% vs 28.9% on NELL-995, and 74.0% vs 72.8% on FB15k; it also interprets intermediate one-hop atoms with over 90% accuracy (Bai et al., 2022).

Pathformer uses a related LQT for one-free-variable existential first-order logic queries in DNF. Its tree contains leaf anchors, variable nodes, and edges labeled by projection πr\pi_r7, intersection, and complement. Rather than optimizing assignments directly, Pathformer decomposes the tree into path queries by branches and recursively encodes them. Each path query is passed through a Transformer encoder and mean pooled,

πr\pi_r8

while branch points are merged by an MLP,

πr\pi_r9

The final root embedding is scored against entity embeddings with Q=(Vb,Vp,Vo,Eq,fa,fe,fs),Q=(V_b,V_p,V_o,E_q,f_a,f_e,f_s),0 distance and trained with a margin-based objective. The paper attributes Pathformer’s gains to its use of bidirectional self-attention to capture future context in branch-structured paths, including negations. Reported MRR results are 24.2 on FB15k-237 and 27.8 on NELL995 for EPFO queries, an average of 26.0 across the two datasets; on the Q2B setting, Pathformer scores 28.5 on FB237-Q2B and 34.2 on NELL-Q2B; for EFOL queries with negation, it scores 7.1 on FB15k-237 and 6.3 on NELL995, averaging 6.7 (Zhang et al., 2024).

These two knowledge-graph lines illustrate distinct uses of the same structural idea. In QTO, the tree exposes conditional independence so that exact optimization can be performed by local computations. In Pathformer, the tree is decomposed into branch paths so that a sequence model can encode a non-sequential logical structure without directly flattening the whole computation graph (Bai et al., 2022, Zhang et al., 2024).

6. Tree-pattern queries, OWL 2 QL, and complexity-theoretic perspectives

In graph-structured data management, the GTPQ formalism extends tree-pattern queries with propositional logic over structural constraints. A data graph is Q=(Vb,Vp,Vo,Eq,fa,fe,fs),Q=(V_b,V_p,V_o,E_q,f_a,f_e,f_s),1, and a GTPQ is

Q=(Vb,Vp,Vo,Eq,fa,fe,fs),Q=(V_b,V_p,V_o,E_q,f_a,f_e,f_s),2

For each internal query node Q=(Vb,Vp,Vo,Eq,fa,fe,fs),Q=(V_b,V_p,V_o,E_q,f_a,f_e,f_s),3, the extended structural predicate is

Q=(Vb,Vp,Vo,Eq,fa,fe,fs),Q=(V_b,V_p,V_o,E_q,f_a,f_e,f_s),4

The paper studies satisfiability, containment, minimization, and evaluation. Its satisfiability criterion states that Q=(Vb,Vp,Vo,Eq,fa,fe,fs),Q=(V_b,V_p,V_o,E_q,f_a,f_e,f_s),5 is satisfiable iff the root’s attribute predicate and complete structural predicate are satisfiable; satisfiability is linear in Q=(Vb,Vp,Vo,Eq,fa,fe,fs),Q=(V_b,V_p,V_o,E_q,f_a,f_e,f_s),6 for Q=(Vb,Vp,Vo,Eq,fa,fe,fs),Q=(V_b,V_p,V_o,E_q,f_a,f_e,f_s),7-only structural predicates and NP-complete in general. Containment is characterized via homomorphism and is co-NP-hard, while minimization is NP-hard, with minimum queries unique up to isomorphism. For evaluation, the GTEA algorithm uses candidate sets Q=(Vb,Vp,Vo,Eq,fa,fe,fs),Q=(V_b,V_p,V_o,E_q,f_a,f_e,f_s),8, a maximal-matching graph Q=(Vb,Vp,Vo,Eq,fa,fe,fs),Q=(V_b,V_p,V_o,E_q,f_a,f_e,f_s),9, two-phase pruning, and a 3-hop reachability index, with complexity dominated by

{PC,AD}\{PC,AD\}0

Reported experiments show that GTEA is 3×–100× faster than TwigStack/Twig²Stack and 5×–300× faster than HGJoin on XMark, while on the arXiv graph it is 10×–1,000× faster than TwigStackD and HGJoin; it also produces 1–4 orders of magnitude fewer intermediate elements (Zeng et al., 2011).

In OWL 2 QL, the relevant objects are tree-shaped conjunctive queries, where the undirected primal graph is acyclic. A linear query has exactly two leaves, bounded-leaf queries have at most {PC,AD}\{PC,AD\}1 leaves, and bounded-treewidth queries are parameterized by the usual graph-theoretic treewidth. This line does not use LQTs as an execution structure in the PlanRAG sense; instead, it treats tree-like topology as the parameter controlling rewriting size and data-complexity. The paper proves a superpolynomial lower bound {PC,AD}\{PC,AD\}2 on positive-existential rewritings already for linear queries with depth-2 ontologies, polynomial-size NDL rewritings for bounded-leaf queries with arbitrary ontologies and for bounded-treewidth queries with bounded-depth ontologies, and conditional characterizations of polynomial-size FO rewritings via {PC,AD}\{PC,AD\}3 and {PC,AD}\{PC,AD\}4. For data-complexity, it establishes LOGCFL-completeness for treewidth-{PC,AD}\{PC,AD\}5 queries with depth-{PC,AD}\{PC,AD\}6 ontologies, NL-completeness for bounded-leaf tree-shaped queries with depth-{PC,AD}\{PC,AD\}7 ontologies, and LOGCFL-completeness for bounded-leaf or linear queries with arbitrary ontologies (Bienvenu et al., 2014).

Taken together, these lines of work indicate that explicit query topology serves several roles: a planning abstraction for RAG over natural-language ERPs, an optimization backbone for exact or neural reasoning over knowledge graphs, a vehicle for pruning and logical expressivity in graph pattern matching, and a structural parameter for rewriting and complexity analysis in ontology-based data access. A recurrent source of confusion is that the term “Logical Query Tree” is not attached to a single canonical syntax. PlanRAG’s LQT is a DAG over atomic natural-language queries, whereas the knowledge-graph, graph-database, and OWL 2 QL settings typically use rooted trees or tree-shaped query formalisms. The commonality lies less in a uniform grammar than in the decision to make query composition explicit and algorithmically exploitable.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Logical Query Trees (LQTs).