---
title: Logical Computation Graphs Overview
url: https://www.emergentmind.com/topics/logical-computation-graphs
type: topic
---

# Logical Computation Graphs Overview

Searching arXiv for recent and foundational papers on logical computation graphs and related query computation graph methods.
arxiv_search(query="logical computation graph knowledge graph query computation tree Pathformer CaQR GQE QTO", max_results=10)
arxiv_search(query="Pathformer recursive path query encoding complex logical query answering", max_results=5)
Logical computation graphs are graph-structured representations in which logical expressions are compiled into explicit computational objects. In knowledge-graph reasoning, a First-Order-Logic query can be represented as a directed acyclic query graph \(G_q=(V_q,E_q)\), a dependency graph \(D_q\), or a directed rooted query computation tree whose leaves are anchor entities or constants and whose root is the free answer variable [2406.07034] [1806.01445] [2212.09567]. In other settings, computational objects are expressed as graphs with interfaces, proofs of multiplicative linear logic are interpreted as interaction graphs, and arbitrary undirected graphs are treated as generalized Boolean formulas in Boolean Graph Logic [1007.3794] [1205.6558] [2004.12941]. A plausible unifying description is that logical structure is made explicit as graph topology, and evaluation proceeds by composing local operators attached to nodes, edges, or paths.

## 1. Query graphs, dependency DAGs, and computation trees

In complex logical query answering over knowledge graphs, the basic formal object is a graph representation of a FOL query. CaQR defines a FOL conjunctive/disjunctive query as a directed acyclic query graph \(G_q=(V_q,E_q)\) with \(V_q = V_{\text{anchor}} \cup V_{\text{exist}} \cup \{V_?\}\), where \(V_{\text{anchor}}\subseteq\mathcal V\) are fixed entities, \(V_{\text{exist}}=\{V_1,\dots,V_k\}\) are existentially quantified intermediate variables, and \(V_?\) is the target answer variable; each edge \((u,r,v)\) encodes an atomic formula \(r(u,v)\) or its inverse [2406.07034]. GQE gives the equivalent dependency-graph view: a \(k\)-ary conjunctive query with one free variable is associated with a dependency graph \(D_q\), a directed acyclic graph whose nodes are anchor nodes, bound variables, and the free variable \(V_?\), and whose edges are relational atoms [1806.01445].

The query computation tree is a stricter tree-shaped compilation. In QTO, a FOL query with conjunction, disjunction, negation, and existential quantifiers is rewritten in Disjunctive Normal Form, and the resulting query computation tree \(T\) has leaf nodes that are constant entities and internal nodes of four types: relational projection, anti-relational projection, intersection, and union; its edges point from children up toward the root \(v_?\) [2212.09567]. Pathformer uses a closely related query computation tree \({\cal T}=(\mathcal N,\mathcal E)\) for Existential First-Order Logic queries with a single free variable, where nodes are leaf anchor entities or branch-variable nodes and edges are decorated with relational projection \(\mathrm{proj}_r\) or atomic negation \(\neg\); the root \(V_?\) holds the final answer set [2406.14880].

These formulations differ in granularity but agree on the role of topology. Prior embedding-based methods compile \(G_q\) into a tree-shaped computation graph where each edge applies a learned projection or a set operation, whereas Pathformer emphasizes a tree-like computation graph with branch structure and QTO emphasizes a tree that exposes conditional independence for optimization [2406.07034] [2406.14880] [2212.09567].

## 2. Core operators and evaluation semantics

GQE formulates logical computation directly in a shared \(d\)-dimensional Euclidean space. Graph nodes are embedded as
\[
z_u = \frac{Z_\gamma x_u}{\|x_u\|}\in\mathbb R^d,
\]
and two differentiable operators are composed over the dependency DAG: a relation-specific projection \(P_r(q)\), instantiated either as \(R_r q\) or, in a TransE-style version, \(q+r\), and a symmetric intersection operator
\[
I(\{q_i\}_{i=1\dots k}) = W_\gamma\,\Psi\bigl(\{\mathrm{ReLU}(B q_i)\}_{i=1\dots k}\bigr).
\]
A topological pass initializes each anchor to its node embedding, propagates projected messages along edges, applies intersection when all incoming edges to a node have arrived, and produces a query embedding \(\theta_q\) at \(V_?\). Candidate answers are ranked by cosine score \( \mathrm{score}(q,x)=\cos(\theta_q,z_x)\), and training uses max-margin ranking with hard negatives for intersection queries [1806.01445].

CaQR summarizes the standard per-branch operators used by the main embedding families. In Q2B, a set of entities is represented by a box with center \(c\in\mathbb R^d\) and offset \(o\in\mathbb R^d\), projection is
\[
c' = W_r\cdot c + b_r,\qquad o' = \mathrm{softplus}(U_r\cdot o + d_r),
\]
intersection uses the mean of centers and the maximum of offsets, and scoring uses \( \mathrm{Dist}_{\text{box}} \). In ConE, a set is encoded as 2-D cones with axis \(a\in\mathbb R^d\) and aperture \(\phi\in\mathbb R^d\), with relation projection by rotation and scaling and scoring by angular distance plus radial distance to axis. In BetaE, each variable set is a product of independent Beta distributions parameterized by \((\alpha,\beta)\), projection is given by relation-specific MLPs \(f_r^{(\alpha)}\) and \(f_r^{(\beta)}\), intersection is point-wise product, and scoring uses \( \mathrm{Dist}_{\mathrm{KL}} \) [2406.07034].

QTO replaces learned geometric composition with a forward-backward optimization over truth-score vectors. Each node \(v\) receives \(\mathbf T^*(v)\in[0,1]^{|\mathcal V|}\), where \(T^*(v=e)\) is the maximal probability of the subquery at \(v\) conditioned on \(v=e\). Intersection uses elementwise products, union uses \( \mathbf 1-\prod_i(\mathbf 1-\mathbf T^*(u_i)) \), relational projection uses
\[
T^*(v=e)=\max_{e'\in\mathcal V}\{T^*(u=e')\times r(e',e)\},
\]
and anti-relational projection replaces \(r(e',e)\) by \(1-r(e',e)\). After a forward pass to the root and a backward pass to recover intermediate assignments, QTO returns \(\hat e_?=\arg\max_e \mathbf T^*(v_?=e)\) [2212.09567].

## 3. Path decomposition, bidirectional encoding, and context injection

Pathformer addresses the mismatch between sequence models and branch-structured logical queries by decomposing the query computation tree into path queries. Because \({\cal T}\) is a tree, each non-leaf node is a fork node with two or more children; a depth-first traversal from every leaf anchor toward the root, cut whenever a fork is reached, yields branch paths of the form
\[
n_s \xrightarrow{\,l_1\,} n_{v_1}\xrightarrow{\,l_2\,}\dots\xrightarrow{\,l_k\,}n_{v_k},
\]
with \(l_i\in\{\mathrm{proj}_{r_i},\neg\}\). Each path is turned into a token sequence consisting of the start-node embedding, learned relation vectors \(E(r)\), and a special token \([\mathrm{Neg}]\) for negation. A standard Transformer encoder with \(k_1\) layers, multi-head self-attention, and position encoding then produces a path-query embedding
\[
E_{pq}=\mathrm{MP}\Bigl(\mathrm{TrmEnc}_{k_1}(E_1,\dots,E_m)\Bigr)\in\mathbb R^d,
\]
where the bidirectional attention mechanism allows future operators and relations to influence earlier tokens. At fork nodes, Pathformer fuses incoming path embeddings by an MLP intersection network,
\[
E_v=\mathrm{MLP}_{k_2}\bigl([E_{pq_i}\,\|\,E_{pq_j}]\bigr)\in\mathbb R^d,
\]
applied pairwise when there are more than two branches, and recursively assembles a final one-point embedding \(v_q\equiv E(V_?)\). Answer scoring uses \(L_1\) distance,
\[
\mathrm{Dist}(e,q)=\|v_e-v_q\|_1,
\]
and training uses a margin-based logistic loss with positive and negative answers [2406.14880].

CaQR keeps the base operator family unchanged and instead augments each intermediate node with two explicit context vectors. The structural context \(c_{\text{struct}}(v)\) combines a position embedding \(p_v\), a role embedding \(r_v\in\{\text{anchor},\text{var},\text{answer}\}\), and a query-type embedding \(g_G\) obtained from a normalized \(3\times L\) count table of \((\text{position},\text{role})\) pairs, followed by an \( \mathrm{MLP}_s \). The relation-induced context \(c_{\text{rel}}(v)\) is computed by sampling up to \(K\) entities from KG head and tail neighborhoods associated with the incident query relations, aggregating frozen entity embeddings into \(l_v^{\text{in}}\) and \(l_v^{\text{out}}\), and averaging them. Fusion is model-agnostic:
\[
\tilde h_v=\mathrm{MLP}_q(q_v),\qquad
x_v=[\tilde h_v \,\|\, \mathrm{MLP}_I(c_{\text{struct}}(v)\,\|\,c_{\text{rel}}(v))],\qquad
q'_v=W' x_v,
\]
and \(q'_v\) replaces the original intermediate representation for subsequent logical operators [2406.07034].

The two methods differ in where they introduce global information. Pathformer pushes future context into each branch by bidirectional self-attention over path sequences, whereas CaQR injects structural context and relation-induced context at every projection step of an existing base model. This suggests two distinct strategies for logical computation graphs: reparameterizing the computation graph itself, or enriching node states while retaining the original operators [2406.14880] [2406.07034].

## 4. Locality, independence, and algorithmic complexity

A central motivation for logical computation graphs is to avoid exhaustive enumeration over existential assignments. GQE makes this explicit in its complexity analysis. If \(E_q\) is the number of edges in the query DAG \(D_q\), Algorithm 1 performs exactly \(E_q\) calls to \(P_r\) and at most \(E_q\) calls to \(I\). A single projection costs \(O(d^2)\), or \(O(d)\) in the TransE variant, and a single intersection costs \(O(kh+dh)\). The total time is \(O(E_q d^2 + E_q dh)\), linear in the query size and independent of \(|V|\), whereas naive enumeration over \(m\) bound variables costs \(O(|V|^m)\) [1806.01445].

QTO exploits independence encoded in the query computation tree. Because \(T\) is a tree, any two disjoint subtrees under a conjunction or disjunction are conditionally independent given the value of their common parent variable. The factorization
\[
\max_{e,u_1,\dots,u_K}\prod_i T(u_i=e)
=
\max_e\;\prod_i \max\{T(u_i=e)\}
\]
allows each subtree to be solved locally, removing the need to enumerate joint assignments and collapsing an exponential search into a sequence of \(O(N)\) local maximizations. In implementation terms, each \(\land\) or \(\lor\) node costs \(O(|\mathcal V|)\), while each projection node costs \(O(|\mathcal V|^2)\) naively or \(O(|\mathcal V|\times \#\text{candidates})\) with sparse storage [2212.09567].

Pathformer offers a different locality argument. By unfolding the EFOL tree into per-branch paths, it avoids trying to encode a full graph in one pass, which would require elaborate positional schemes or graph-transformers. Every encoded sequence is a simple path, negation is represented by a single \([\mathrm{Neg}]\) token, and fork MLPs reassemble multiple path views of the same variable in an intersection-like fashion [2406.14880].

These results delimit a common design space. Standard linear sequential operations are efficient but, in CaQR’s formulation, do not adapt to the global query structure or to node-specific KG context; exact tree optimization is feasible when independence is exposed; and path-based transformer encoders trade direct graph encoding for repeated sequence encoding over tree branches [2406.07034] [2212.09567] [2406.14880].

## 5. Empirical behavior in complex logical query answering

The reported empirical results span different datasets, query families, and scoring protocols, so they are not directly interchangeable. They nonetheless show that changes to the logical computation graph—whether geometric, contextual, transformer-based, or optimization-based—alter answer quality measurably [1806.01445] [2406.14880] [2406.07034] [2212.09567].

| Method | Dataset / setting | Reported result |
|---|---|---|
| GQE | Bio | AUC \(= 0.910\), APR \(= 0.915\) |
| GQE | Reddit | AUC \(= 0.764\), APR \(= 0.787\) |
| Pathformer | FB15k-237 EPFO queries | overall MRR \(= 24.2\%\) |
| Pathformer | NELL995 avg MRR | \(27.8\%\) |
| CaQR + Q2B | NELL Avg MRR | \(22.57 \rightarrow 26.97\) |
| CaQR + BetaE | FB15k-237 | \(20.98 \rightarrow 22.96\) |
| QTO | 3 datasets | previous best results improved by an average of \(22\%\) |

GQE demonstrated that training on complex queries, including paths and intersections, yields a \(\sim 13\%\) absolute AUC gain over an edge-only baseline, and that the framework scales to a biomedical graph with \(\sim 97\,000\) nodes, \(42\) relation types, and \(8\) million edges as well as a Reddit graph with \(\sim 700\,000\) nodes and \(\sim 4\) million edges [1806.01445].

Pathformer reports that it consistently outperforms competitive neural QE methods on standard CLQA benchmarks FB15k-237 and NELL995. On FB15k-237 EPFO queries it achieves an overall Mean Reciprocal Rank of \(24.2\,\%\), versus \(24.0\,\%\) for FuzzQE and \(23.3\,\%\) for GammaE; on NELL995 the average MRR is \(27.8\,\%\) versus \(27.4\,\%\) for MLP-Mixer. It also leads on zero-shot held-out structures such as \(ip\), \(pi\), \(2u\), and \(up\), and compared to BIQE is described as both more accurate and easily extending to queries with negation [2406.14880].

CaQR reports consistent gains across Q2B, BetaE, and ConE. The largest stated improvement is on NELL with Q2B, where the Avg MRR goes from \(22.57\) to \(26.97\), corresponding to \(+19.5\%\). On FB15k-237, BetaE improves from \(20.98\) to \(22.96\) and ConE from \(23.31\) to \(23.67\). QTO, evaluated on 3 datasets, is reported to obtain state-of-the-art performance on complex query answering, outperforming previous best results by an average of \(22\%\), and to interpret the intermediate solutions for each of the one-hop atoms in the query with over \(90\%\) accuracy [2406.07034] [2212.09567].

## 6. Expressiveness, graph logic, and broader semantic frameworks

Logical computation graphs also appear as an expressiveness lens for neural graph models. The logic \(C^{(k)}\), the \(k\)-dimensional Weisfeiler-Leman algorithm, and higher-order message-passing GNNs form equivalent descriptions of the same isomorphism-invariant distinguishing power. For standard message-passing GNNs, any \(d\)-layer architecture refines the \(d\)-round color refinement \( \mathrm{cr}_d(v)=\mathrm{wl}_1^d(v) \), so no such GNN can distinguish vertices or graphs that 1-WL still considers equivalent; conversely, recurrent GNNs with sum aggregation can simulate color refinement. For higher-order models, \(k\)-GNNs operating on \(k\)-tuples match standard \((k-1)\)-WL and hence the logic \(C^{(k)}\). The paper summarizes this as a unifying computation-graph perspective: counting quantifiers map to local degree-counts, variable-reuse up to \(k\) corresponds to the width of tuple lifting, quantifier-rank corresponds to the number of GNN rounds, and invariance under renaming corresponds to parameter sharing across the graph [2104.14624].

Outside knowledge-graph query answering, graph-based logical computation supports denotational semantics and proof theory. In interaction graphs, proofs of multiplicative linear logic are represented by directed weighted multigraphs \(G=(V_G,E_G,s_G,t_G,\omega_G)\), composed by plugging and analyzed through alternating paths, 1-circuits, and the measurement
\[
\langle G,H\rangle=\sum_{\pi\in\mathrm{1\text{-}Circuits}(G,H)} -\log\bigl(1-\omega_{G\,H}(\pi)\bigr).
\]
Projects and conducts then yield tensor, linear implication, orthogonality, truth, and ultimately a \(\ast\)-autonomous category; a restricted fragment recovers Girard’s geometry of interaction in the hyperfinite factor [1205.6558].

Boolean Graph Logic pushes the formula-as-graph perspective further by lifting cograph-based Boolean formulas to all finite undirected graphs. A graph \(G\) computes a binary relation \( \llbracket G\rrbracket \subseteq 2^V\times\{0,1\} \) via maximal cliques and maximal stable sets, evaluation is NP-complete for arbitrary graphs, and entailment is \( \Pi_2^p \)-complete. The framework also provides a recursive evaluation algorithm by modular decomposition, a game-theoretic characterization in terms of static and sequential strategies, and a deep-inference-style axiomatization with soundness and completeness [2004.12941].

Open graphs provide a compositional calculus for computational objects with interfaces made of half-edges. Inputs, outputs, and boundary embeddings define interfaces; plugging is implemented by pushouts in the category of open graphs; and rewrite rules between graphs with the same boundary support algebraic reasoning about Boolean circuits and other computational models. The theory establishes soundness and completeness properties for rewriting and identifies the resulting diagrammatic systems with free symmetric strict monoidal categories generated by a signature and equations [1007.3794].

A recurrent misconception is that logical computation graphs are necessarily trees or formula cotrees. The surveyed literature is more heterogeneous: some frameworks insist on tree structure because it exposes efficient local composition or exact optimization, while others explicitly generalize from cographs to arbitrary graphs, from formula trees to open graphs with half-edge interfaces, or from proof nets to interaction graphs with path-based semantics [2212.09567] [2004.12941] [1007.3794] [1205.6558].

Source: https://www.emergentmind.com/topics/logical-computation-graphs