Expand description
TensorLogic: Neuro-symbolic reasoning via tensor operations (Domingos, 2025) TensorLogic: Neuro-Symbolic Reasoning via Tensor Operations
This module implements the TensorLogic paradigm (Domingos, 2025), unifying neural and symbolic reasoning through tensor operations. All logical operations are expressed as Einstein summations, enabling:
- Differentiable inference: Backpropagation through logical reasoning
- Dual-mode operation: Boolean (guaranteed correctness) or Continuous (learnable)
- Knowledge graph reasoning: RESCAL factorization and embedding space queries
§Toyota Way Principles
- Jidoka: Boolean mode guarantees no hallucinations (output ⊆ derivable facts)
- Poka-Yoke: Type-safe mode selection prevents accidental mixing
- Genchi Genbutsu: Explicit tensor equations for auditability
§Example
use aprender::logic::{LogicMode, logical_join, logical_project};
// Family tree reasoning: Grandparent = Parent @ Parent
let parent = vec![
vec![0.0, 1.0, 0.0], // Alice is parent of Bob
vec![0.0, 0.0, 1.0], // Bob is parent of Charlie
vec![0.0, 0.0, 0.0], // Charlie has no children
];
let grandparent = logical_join(&parent, &parent, LogicMode::Boolean);
// grandparent[0][2] = 1.0 (Alice is grandparent of Charlie)§References
- Domingos, P. (2025). “Tensor Logic: The Language of AI.” arXiv:2510.12269
- Nickel, M. et al. (2011). “RESCAL: A Three-Way Model for Collective Learning”
- Bordes, A. et al. (2013). “TransE: Translating Embeddings for Multi-relational Data”
Structs§
- Bilinear
Scorer - Bilinear scorer for knowledge graph completion
- Embedding
Space - Embedding space for knowledge graph reasoning
- Program
Builder - Builder for constructing
TensorProgramsfluently - Relation
Matrix - Relation matrix wrapper (for type-safe access)
- Rescal
Factorizer - RESCAL Tensor Factorization for predicate invention
- Tensor
Program - A
TensorProgramis an executable collection of facts and rules
Enums§
- Equation
- An equation defines how to compute a derived tensor
- Logic
Mode - Logic mode determines how operations handle intermediate values
- Nonlinearity
- Nonlinearity functions for attention and activation
Functions§
- apply_
nonlinearity - Apply nonlinearity function to tensor
- apply_
nonlinearity_ with_ mask - Apply nonlinearity with optional mask
- apply_
nonlinearity_ with_ temperature - Apply nonlinearity with temperature parameter
- logical_
join - Logical join (AND): Combines two relations via matrix multiplication
- logical_
negation - Logical negation (NOT): Negates tensor values
- logical_
project - Logical projection (∃): Existential quantification over a dimension
- logical_
select - Logical selection (WHERE): Filters tensor by condition
- logical_
union - Logical union (OR): Combines two tensors via logical OR