experimental · research prototype · v2.0 production capability surfaces

TensorLang

An experimental tensor-equation language for tensor-logic-style relations, symbolic reasoning, numeric models, and dynamical systems.

TensorLang explores a practical implementation path for tensor-first AI programming: finite domains, typed tensors, sparse COO tensors, named-axis einsum, explicit join/project, embedding/gather, scatter-add, semiring-aware reasoning, trainable tensor programs, executable relational backends, SQL/Datalog/TypeDB exports, generic train-loss graph inspection, executable NumPy accelerator runtime, proof-calculus and theorem-prover reports, bounded improvement protocols and ledgers, native Apple Swift reference checking, reproducible evidence suites, fixture-backed real-world datasets, production transformer pretraining manifests, local multi-process foundation training, and a tiny local causal language-model workflow.

NOTE

Inspired by Pedro Domingos's paper "Tensor Logic: The Language of AI". TensorLang is an independent experimental project — not Tensor Logic itself, and not affiliated with the author or the University of Washington.

named tensor-logic equation form
CanDo[User, Action] = project join "User Role, Role Action -> User Role Action"
same tensor substrate · sparse relations · named axes · joins · projections · embeddings
Current reference

Newer capabilities, kept in the cleaner structure

The restored reference site keeps the multi-page information architecture while preserving the newer capability descriptions. The home page summarizes them; the route pages hold the detailed implementation boundaries.

Reference map

A cleaner story for TensorLang

The reference is now organized as a sequence: declare tensor-shaped worlds, express relational computation, check semantics, run evidence, model dynamics, then track implemented capability surfaces and their boundaries. The content is still here, but it is no longer exposed as twenty peer-level navigation items.

one-sentence mental model

TensorLang is a reference stack for writing explicit tensor programs that can behave like relations, proofs, simulations, backend-executable queries, or trainable models without changing the underlying tensor-equation frame.

Attribution

Inspired by Tensor Logic

TensorLang begins from the ideas in Pedro Domingos's paper, which proposes tensor equations as a unifying language for neural, symbolic, and statistical AI. TensorLang is an independent experimental implementation path inspired by that work. It is not Tensor Logic itself, and it should not be presented as an official implementation or affiliated project.

Citation

Tensor Logic: The Language of AI

Author
Pedro Domingos
Institution
Paul G. Allen School of Computer Science & Engineering, University of Washington
arXiv
2510.12269
Link
arxiv.org/pdf/2510.12269
Disclosure
  • ·TensorLang is not Tensor Logic.
  • ·No affiliation with Pedro Domingos or the University of Washington.
  • ·An independent practical implementation/research language inspired by the paper's core idea that tensor equations can bridge symbolic logic, neural computation, and statistical AI.
  • ·Presented as a research prototype exploring ideas motivated by the paper, not as the original invention of tensor logic.
Flagship evidence

The derived-adjacency join

ESA (Buterez et al., Nature Communications 2025) treats a graph as a set of edge tokens and runs masked self-attention where two edges may attend only if they share a node — using a precomputed connectivity mask. Tensor Logic (Domingos 2025) argues one construct, the tensor equation, generalizes both Einstein summation and the Datalog rule, because a rule's join over shared variables is a contraction over a shared index. TensorLang makes that claim executable: the adjacency mask ESA hand-codes is here derived as a contraction of the incidence relation, then reused to gate the attention itself.

Bottom line

Adopt as a flagship evidence case, not a benchmark chase. The derived-adjacency join is the whole pitch — it is the cleanest proof that one tensor-equation language unifies the symbolic and the neural in a way the two source papers only assert.

  • ·The same equation, "en,fn->ef", is a Boolean join (line-graph adjacency) under the Bool semiring and a shared-endpoint count under the reals.
  • ·The connectivity mask is derived, so it generalizes to any logic rule — k-hop reach, typed knowledge-graph edges, motif membership — without ESA's forbidden hand-engineered structural encodings.
  • ·The adjacency relation is verified exhaustively (symmetric, reflexive), and masked attention provably places zero weight on non-adjacent edges where the unmasked block leaks.
References
ESA
Buterez et al., “An end-to-end attention-based approach for learning on graphs,” Nat. Commun. 2025 (arXiv:2402.10793, code)
Tensor Logic
Domingos, “Tensor Logic: The Language of AI,” arXiv:2510.12269
Example
examples/44_esa_derived_adjacency_attention.tl
examples/44_esa_derived_adjacency_attention.tltensorlang
; Adj(e,f) :- Edge(e,_,v), Edge(f,v,_)
; A Datalog rule body is a join over the shared node variable v,
; and that join IS a contraction over the shared index. So the
; line-graph adjacency is DERIVED, not hand-coded:
(def adj_bool
  (type Bool)
  (shape Edge Edge)
  (expr (semiring-einsum bool-or-and "en,fn->ef" inc inc)))

; The same equation, read numerically, builds ESA's connectivity
; mask -- which then gates the masked self-attention contraction.
; ESA precomputes that mask by hand; here it falls out of the logic.
(def masked_weights
  (type F64)
  (shape Edge Edge)
  (expr (softmax (add scores mask) 1)))

An independent TensorLang demonstration re-expressing ESA's structure-aware attention as a tensor-logic program. It validates expressiveness — that a derived relation can drive learned attention — and does not reproduce ESA's published benchmark numbers.

Overview

What is TensorLang?

TensorLang is a small experimental language for writing tensor equations over finite domains, sparse relations, named axes, numeric arrays, semirings, fixed points, trainable local models, native reference implementations, and dynamical systems. It is designed as a reference core for exploring neural-symbolic reasoning, finite Boolean verification, executable relational backends, and tiny local foundation-model workflows.

Tensor-first

Programs are built from typed tensors, shapes, domains, equations, named-axis einsum, semirings, and fixed points.

Tensor-logic

Sparse COO tensors, explicit Bool joins, projections, gather/embedding, and scatter-add make relation programs direct.

Reasoning-aware

Finite Boolean programs can be checked by exhaustive finite-model verification and run through relational backends where supported.

Backend-explicit

Supported relation programs can execute through in-memory or SQLite backends; train declarations can expose structured or generic autodiff graph metadata.

Dynamical

TensorLang can describe simple continuous-time and discrete-time systems for software simulation of time-aware models.

Foundation slice

A tiny local causal language model now trains on next-token prediction, saves JSON artifacts, and generates deterministically.

Apple reference

A parent-owned pure Swift package provides TensorLangKit, a native tl checker, conformance JSON, and a Lean sidecar scaffold.

Motivation

Why tensor equations?

Most AI stacks split neural, symbolic, relational, probabilistic, and dynamical systems across separate frameworks. Tensor equations are a candidate substrate that can describe all of them with shared structure.

  • 01Tensors naturally represent neural computation.
  • 02Sparse Boolean tensors can represent relations.
  • 03Named-axis einsum, join, and project can represent Datalog-like rules.
  • 04Semirings let the same structural operation mean different things depending on algebra.
  • 05Gather and scatter-add connect symbolic IDs to trainable embedding workflows.
  • 06Fixed points model closure, reachability, ancestry, policy expansion, and recursive relations.
  • 07Dynamic equations model evolving state over time.
Traditional split
TensorLang direction
Neural models
Common tensor-equation representation
Symbolic rules
Explicit domains and shapes
Relational queries
Semiring-aware operations
Probabilistic scoring
Verification hooks
Dynamical systems
Simulation and tracing
Beyond LLM

Proof-of-capability demos

TensorLang is not trying to replace frontier LLM systems. It is exploring explicit local computation: finite reasoning, exact graph closure, property checking, trace analysis, small structured model training, continuous dynamical simulation, and a first tiny foundation-model workflow.

Relationship to LLMs

LLMs remain useful for dialog, authoring, explanation, and repair. TensorLang is for explicit tensor programs that can be checked, run locally, verified in finite fragments, traced, and benchmarked.

The local demos make no LLM calls and make no energy-saving claims. Energy fields are unavailable unless measured by a future backend.

demo

Policy Closure

Exact role and permission expansion with deterministic closure, fast lookup, and finite property checks.

demo

Requirement Coverage

Maps requirements to modules, tests, and proof obligations; reports uncovered or assumption-dependent requirements.

demo

Semantic Trace Root Cause

Reasons over structured trace events and extracts a stable causal path from failure spans.

demo

Dynamic Anomaly Detector

Runs a small recurrent signal model locally and continuously, then reports deterministic anomaly metrics.

demo

Knowledge Graph Link Predictor

Trains entity and relation embeddings, saves JSON artifacts, and scores candidate missing facts as evidence.

demo

Semantic Trace Classifier

Trains on structured trace fields such as event, component, operation, reason, status, and mismatch flags.

demo

Reservoir Readout Training

Keeps recurrent dynamics fixed and trains a small readout for deterministic sequence prediction/anomaly scoring.

demo

Relational Backend Execution

Runs finite Bool policy and reachability plans through in-memory or SQLite reference backends and compares results.

demo

Tensor Logic Primitives

Exercises sparse COO relations, named-axis joins, projections, embedding lookup, and scatter-add in one checked program.

demo

Foundation LM Slice

Trains a tiny local causal character model, writes a foundation artifact, and generates text from learned next-token scores.