SoftReason: A Fully Differentiable Neuro-Soft-Symbolic Deductive Reasoning Architecture over High-Dimensional Perceptual Data
By Wael AbdAlmageed
"A fully differentiable neuro-symbolic architecture for deductive reasoning over perceptual data and knowledge graphs, using soft interpretation tensors and a differentiable immediate-consequence operator."
Abstract
In many reasoning problems, the premises are not observed as discrete symbols, but must be inferred from high-dimensional inputs. Further, the predicate vocabulary, argument structure, and trusted evidence are supplied by a Knowledge Graph (KG), or rule definitions. Classical neuro-symbolic pipelines have a discrete interface between perception and deduction. We present a neuro-soft-symbolic architecture for differentiable deductive reasoning over latent perceptual facts and knowledge-provided predicates. SoftReason removes the gradient gap by representing the deductive state as a local soft interpretation tensor over candidate constants and predicates. Perception proposes probabilistic base facts, KG triples enter as high-confidence soft evidence, and every query anchor, predicate choice, and closure update remains differentiable. Our core innovation is a learned differentiable lift of the immediate-consequence operator. It uses predicate-definition embeddings and latent composition channels to form soft body-predicate mixtures, aggregate over all possible witnesses, propose query-conditioned head facts, and update the interpretation through a monotone probabilistic OR. We instantiate the framework on Knowledge-aware Visual Question Answering (KVQA), and demonstrates how SoftReason supports end-to-end perceptual grounding, KG evidence injection, and differentiable deductive closure in one trainable architecture.
Technical Analysis & Implementation
Technical Breakdown§
SoftReason proposes a differentiable framework for deductive reasoning where premises are latent perceptual facts and predicates come from a Knowledge Graph (KG). The core innovation is a differentiable lift of the immediate-consequence operator from logic programming, enabling end-to-end training.
Core Methodology§
Soft Interpretation Tensor: The deductive state at step $t$ is represented as a tensor $\mathbf{I}^{(t)} \in [0,1]^{|C| \times |P|}$, where $C$ is the set of constants (entities) and $P$ the set of predicates. Each entry $\mathbf{I}^{(t)}_{c,p}$ is the probability that predicate $p$ holds for constant $c$.
Differentiable Immediate-Consequence Operator $T_P$: This operator updates the interpretation by evaluating all rules. For a rule $p(\mathbf{x}) \leftarrow q_1(\mathbf{y}_1) \land \dots \land q_k(\mathbf{y}_k)$ with predicate embedding $\mathbf{e}_p$, the operator computes a soft body truth value for each grounding:
$$ \text{body}(\mathbf{x}) = \min_{i} \; \mathbf{I}^{(t)}_{c_i, q_i} $$
where $c_i$ are constants from $\mathbf{y}_i$ unified with $\mathbf{x}$. To make it differentiable, SoftReason replaces min with a smooth approximation (e.g., product or softmin) and uses predicate-definition embeddings to weight rule contributions:
$$ \tilde{\mathbf{I}}^{(t+1)}_{c,p} = \bigvee_{\text{rules } R: \text{head}=p(\mathbf{c})} \; \sigma(\mathbf{e}_p \cdot \mathbf{e}_R) \cdot \text{body}_R(\mathbf{c}) $$
where $\bigvee$ is a smooth OR (e.g., probabilistic OR: $1 - \prod (1 - x_i)$), $\mathbf{e}_R$ is the rule embedding, and $\sigma$ is a sigmoid. The final interpretation is updated monotonically:
$$ \mathbf{I}^{(t+1)} = \mathbf{I}^{(t)} \lor \tilde{\mathbf{I}}^{(t+1)} $$
Perception Module: For KVQA, a neural network extracts latent facts about objects in images. For each candidate object $c$, it outputs probabilities for base predicates (e.g., "red", "location left"). These initialize $\mathbf{I}^{(0)}$.
KG Evidence: Knowledge graph triples are added as high-confidence soft facts directly into $\mathbf{I}^{(0)}$.
Training§
The entire pipeline is differentiable. The query (e.g., "Is there a red cube?" ) is answered by reading the final interpretation $\mathbf{I}^{(T)}$ at the query predicate and constant. Cross-entropy loss trains both perceptual and reasoning components end-to-end.
Code Snippet§
import torch
import torch.nn.functional as F
def immediate_consequence(I, rules, pred_emb, rule_emb):
# I: (batch, num_constants, num_predicates)
# rules: list of (head_pred_idx, body_pred_indices, rule_idx)
new_I = torch.zeros_like(I)
for head, body, r_idx in rules:
body_truth = torch.ones_like(I[:, :, 0]) # (batch, num_constants)
for b in body:
body_truth = body_truth * I[:, :, b] # smooth AND via product
rule_weight = torch.sigmoid((pred_emb[head] * rule_emb[r_idx]).sum())
new_I[:, :, head] = 1 - (1 - new_I[:, :, head]) * (1 - rule_weight * body_truth)
return new_I
# Initial interpretation from perception and KG
I = torch.sigmoid(perception_output) # (B, C, P)
for t in range(num_steps):
I = torch.max(I, immediate_consequence(I, rules, pred_emb, rule_emb))This differentiable closure enables end-to-end training with gradient flow through the reasoning steps.