arXiv:2605.20919cs.LGcs.AI2026-05

将符号逻辑编程编译为可训练的神经网络,实现代码即模型。

Sutra: Tensor-Op RNNs as a Compilation Target for Vector Symbolic Architectures

  • 用函数式语言编写程序,自动转为融合张量运算图。
  • 在多种嵌入模型上准确解码组合信息,远超传统方法。
  • 训练后的模型可还原为可读代码,兼具逻辑与神经特性。

Sutra 是一种类型化、纯函数式编程语言,其编译后的前向传播为 PyTorch 神经网络。编译器将整个程序(包括原语、控制流、字符串输入输出)β-归约为一个在固定嵌入底座上的融合张量操作图。旋转绑定、解绑、打包、多项式克莱尼三值逻辑及尾递归循环均降为张量操作;克莱尼连接词为在 {-1, 0, +1} 真值网格上精确的拉格朗日插值多项式。验证分两步:(1) 同一程序在四种固定嵌入上运行,覆盖三种文本编码器(nomic-embed-text, all-minilm, mxbai-embed-large)和一个蛋白质语言模型(ESM-2),在宽度 k=8 时解码组合信息准确率达 100%,而教科书级哈达玛积在 mxbai-embed-large 上仅 2.5%,all-minilm 上为 7.5%;(2) PyTorch 自动微分可穿过实际生成的图:用 .su 编写的模糊规则分类器从随机初始化(18.7 ± 9.5%;基准 20%,五类)经反向传播训练至 100.0 ± 0.0%(三个种子),且不修改源码;加权变体同时训练标量余弦增益并写回 .su 源码为数值常量;重新编译后重现训练行为至 ~2e-7 每 logit,表明训练模型本身是可读、可重编译的代码。同一产物既是逻辑程序又是可训练神经网络。

原文摘要 · Abstract (English)

Sutra is a typed, purely functional programming language whose compiled forward pass is a PyTorch neural network. The compiler beta-reduces the whole program -- primitives, control flow, string I/O -- to one fused tensor-op graph over a frozen embedding substrate. Rotation binding, unbind, bundle, polynomial Kleene three-valued logic, and tail-recursive loops all lower to tensor operations; the Kleene connectives are Lagrange-interpolated polynomials exact on the {-1, 0, +1} truth grid. Validation is one fact tested two ways. (1) The same program runs on four frozen embeddings spanning two modalities -- three text encoders (nomic-embed-text, all-minilm, mxbai-embed-large) and one protein language model (ESM-2) -- and decodes bundles at 100% accuracy through width k=8 on every substrate, where the textbook Hadamard product has already collapsed (2.5% on mxbai-embed-large, 7.5% on all-minilm). (2) PyTorch autograd flows through the actually compiled graph: a fuzzy-rule classifier written in .su trains from random init (18.7 +/- 9.5%; chance = 20%, five classes) to 100.0 +/- 0.0% (three seeds) by backpropagating through the emitted graph, the symbolic source unmodified. A weighted variant additionally trains a scalar cosine gain and writes it back into the .su source as a numeric literal; recompiling reproduces the trained behaviour to ~2e-7 per logit, so the trained model is itself legible, recompilable code. The same artifact is therefore both a logic program and a trainable neural network.

符号计算可训练代码张量运算神经符号

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。