Papers
Topics
Authors
Recent
Search
2000 character limit reached

Tensorized Logic Programs

Updated 23 May 2026
  • Tensorized logic programs are a computational paradigm that re-encodes logical rules as tensor operations, enabling scalable and differentiable reasoning.
  • They compile logical constructs such as Horn clauses into sequences of matrix multiplications and tensor contractions to support both deterministic and probabilistic inference.
  • Applications include knowledge graph completion, probabilistic theorem proving, and neural-symbolic integration with efficient GPU-accelerated computation.

Tensorized logic programs are a class of computational formalisms that translate symbolic logical inference into sequences of dense or sparse tensor operations, and, more generally, enable end-to-end differentiable learning and reasoning over structured knowledge. They provide a rigorous and scalable bridge between symbolic logic programming, numerical linear algebra, and neural computation by re-encoding entities, predicates, and logical rules as high-dimensional tensors and deploying operations such as matrix multiplication, contraction, and attention-driven aggregation for inference and learning. Tensorized logic programs have foundational impacts on probabilistic theorem proving, knowledge base completion, neural-symbolic integration, and large-scale differentiable reasoning.

1. Tensor Encodings in Logic Programming

At the core of tensorized logic programming is the mapping from logical atoms and variables to real-valued, often high-dimensional, tensors. For a knowledge base with NN entities, each entity ee is associated with a one-hot vector v(e){0,1}Nv(e)\in\{0,1\}^N, and each binary relation RR is represented as an adjacency matrix MR{0,1}N×NM_R\in\{0,1\}^{N\times N} with (MR)ij=1(M_R)_{ij} = 1 if and only if R(ej,ei)R(e_j, e_i) holds. Higher-arity predicates are encoded as order-kk adjacency tensors, where the entries are 1 if the appropriate ground atom is present (Yang et al., 2017, Sato, 2017, Shah et al., 23 Jan 2026).

Logical queries of the form R1(X,Z)R2(Z,Y)R_1(X,Z)\wedge R_2(Z,Y) for fixed X=xX = x are reduced to chains of matrix multiplications: ee0 where ee1 indicates candidates ee2 such that there exists ee3 with ee4 true. This translation generalizes to arbitrary conjunctive queries and supports both exact logical semantics and probabilistic/soft reasoning via weighted entries or real-valued confidence scores (Cohen, 2016, Yang et al., 2017).

2. Compilation of Logical Rules to Tensor Operations

Tensorized logic programs compile first-order logical rules, especially chain-like or Horn clauses, into fixed sequences of tensor operations. Each rule path of length ee5 corresponds to a multi-step product of matrices (or higher-order contractions for ee6-ary predicates). The execution of such chains supports both deterministic and probabilistic semantics: ee7 where ee8 are rule weights (confidences), and the product is applied to the input one-hot vector (Yang et al., 2017, Sato, 2017, Shah et al., 23 Jan 2026).

TensorLog and related differentiable deductive databases formalize this process by converting each clause to a factor graph and unrolling message-passing steps (belief propagation) into deterministic compositions of sparse matrix–vector multiplications and elementwise products. Mutual recursion, multi-clause definitions, and typing are fully supported, yielding computational graphs amenable to backpropagation (Cohen, 2016, Cohen et al., 2017).

3. End-to-End Differentiable Learning of Logical Rules

Tensorized logic programs support integrated parameter and structure learning in symbolic systems via differentiable execution graphs. Notable frameworks such as Neural Logic Programming (Neural LP) employ a neural controller to “softly” attend over all possible relation-operator chains at each reasoning step, learning both rule structure and confidence concurrently:

  • At each step, operator-attention vectors weight all possible relations; memory-attention vectors aggregate intermediate states.
  • An RNN (e.g., LSTM) controller produces attention weights; the entire rule application sequence is differentiable with respect to both fact parameters and neural parameters (Yang et al., 2017).

This joint structure–parameter learning is realized through negative log-likelihood loss on training examples, with gradients backpropagated through all attention, matrix, and recurrent layers. Empirical results show that such systems outperform non-differentiable or discrete structure-learning baselines and can generalize to unseen entities and longer reasoning chains (Yang et al., 2017).

4. Semantics and Theoretical Foundations

Tensorized logic programs extend classical least-model and Tarskian semantics via tensor algebra. In T-PRISM, the distribution semantics of probabilistic logic programming is generalized to “tensorized semantics,” where head atoms and bodies are mapped to tensors and operations correspond to tensor addition (for disjunction) and Einstein summation/contraction (for conjunction). The computation of the least model is thus recast as solving a monotone system of tensor equations, admitting a unique solution under standard monotonicity and non-negativity constraints (Kojima et al., 2019, Sato, 2017).

This formalism accommodates non-binary predicates, aggregates, and user-defined nonlinear operators via extended tensor expressions. In the linear algebraic approach, the fixpoint computation for propositional definite or normal programs is encoded as sparse matrix–vector iterations, offering provable correctness, convergence, and dramatically enhanced scalability—especially for sparse programs (Quoc et al., 2020).

A summary of semantic compilation is as follows:

Logic Construct Tensorized Equivalent Remarks
Atom ee9 v(e){0,1}Nv(e)\in\{0,1\}^N0 Row vector; v(e){0,1}Nv(e)\in\{0,1\}^N1 iff v(e){0,1}Nv(e)\in\{0,1\}^N2 DB
Binary v(e){0,1}Nv(e)\in\{0,1\}^N3 v(e){0,1}Nv(e)\in\{0,1\}^N4 Adjacency matrix
Disjunction (OR) Tensor addition v(e){0,1}Nv(e)\in\{0,1\}^N5
Conjunction (AND) Einstein summation/contraction v(e){0,1}Nv(e)\in\{0,1\}^N6
Existential v(e){0,1}Nv(e)\in\{0,1\}^N7 Tensor contraction with quantifier tensor Sum over bound index, apply cap

(Sato, 2017, Kojima et al., 2019)

5. Integration with Neural and Probabilistic Models

Tensorized logic programming provides a flexible substrate for the integration of neural representation learning and symbolic logical constraints. Logic Tensor Networks (LTN) instantiate first-order logic over real-valued tensors, interpreting constants as dense vectors, predicates as neural networks (typically tensor layers), and formulas as differentiable compositions via t-norm and s-norm fuzzy logic connectives. Quantifiers are implemented via aggregations (min/max or soft variants), and end-to-end loss optimizes a global satisfiability measure for facts and rules (Serafini et al., 2016, Badreddine et al., 2020).

Probabilistic logic frameworks such as TensorLog and differentiable probabilistic logic networks treat parameterized fact weights as trainable variables and compile the entire deduction process—including belief propagation—into differentiable computation graphs, fully compatible with deep learning platforms. This supports supervised, unsupervised, and semi-supervised learning, and allows backpropagation to adjust both low-level knowledge base entries and higher-level rule parameters (Cohen et al., 2017, Potapov et al., 2019).

6. Scalability, Sparse Methods, and Practical Impact

Large-scale tensorized logic systems exploit hardware acceleration and sparse algebraic representations to achieve scalability unattainable with purely symbolic solvers. Sparse storage formats (e.g., compressed sparse row for program matrices) make fixpoint computations feasible for millions of rules and entities. GPU-backed batch einsum and matrix multiplication further accelerate both exact reasoning (fixpoint computation, transitive closure) and learning (embedding-space reasoning in neural systems) (Quoc et al., 2020, Kojima et al., 2019, Shah et al., 23 Jan 2026).

Empirical benchmarks show that tensorized logic engines match or outperform state-of-the-art both in symbolic relational inference and in neural-link prediction or multi-hop compositional reasoning. Practical applications include knowledge graph completion (e.g., DistMult in T-PRISM), logical rule extraction, complex query answering (e.g., WikiMovies), and large-scale database reasoning (Kojima et al., 2019, Yang et al., 2017, Shah et al., 23 Jan 2026).

7. Expressiveness, Extensions, and Future Directions

Tensorization strictly generalizes traditional logic programming to accommodate:

  • Partial or fuzzy truth values and graded logic via [0,1]-valued tensors and fuzzy connectives (Badreddine et al., 2020).
  • Latent-variable semiring parsing, where weights in parsing logic programs are lifted from scalars to tensors, modeled via partial semirings. This enables context-sensitive inference and strictly improves expressiveness over scalar semirings (Balkir et al., 2020).
  • Arbitrary nonlinear transformations and neural architectures via embedded operator nodes in the computation graph; the “explanation graph with Einstein notation” serves as the bridge from symbolic to differentiable computation (Kojima et al., 2019).
  • Ongoing research focuses on efficient handling of negation, aggregates, richer forms of background knowledge, web-scale graph reasoning with extremely large and sparse tensors, and improved neuro-symbolic unification (Quoc et al., 2020, Shah et al., 23 Jan 2026).

Tensorized logic programs thus constitute a unifying computational paradigm for symbolic, probabilistic, and neural reasoning over rich, structured knowledge bases, combining the formal rigor and interpretability of logic with the scalability and optimization capabilities of modern tensor computation.

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 Tensorized Logic Programs.