TorchLean: 在 Lean 中形式化神经网络
TorchLean: Formalizing Neural Networks in Lean
AI总结:
提出 TorchLean 框架,在 Lean 4 中统一神经网络的执行、验证与定理证明,通过共享语义弥合执行网络与分析工件之间的语义鸿沟。
摘要:
神经网络越来越多地部署在科学、安全关键和任务关键型流程中,但验证和分析通常在定义和运行模型的编程环境之外进行。这在执行的网络与分析工件之间造成了语义鸿沟:保证可能依赖于关于算子语义、张量布局、预处理、浮点行为、图变换、加速内核和外部证书的隐式约定。我们提出 TorchLean,一个在 Lean 4 中形式化、执行和验证神经网络的统一框架。TorchLean 将学习模型视为可执行程序和数学对象,具有用于计算、验证和定理证明的共享语义。该框架为类型化张量、层、目标、优化器、自动微分和图程序提供了 PyTorch 风格的 API,具有急切和编译执行路径,这些路径降低到公共计算图表示。TorchLean 支持精确和有限精度张量语义、验证的反向模式微分、区间和仿射边界传播、CROWN/LiRPA 风格的证书检查、导入/导出工作流以及通过显式 FFI 边界的 CUDA 支持执行。它还包括用于注意力和 FlashAttention、状态空间序列模型、扩散和采样过程、概率核、强化学习目标和马尔可夫决策过程以及自监督目标(如掩码自编码、JEPA 风格的预测视图和基于方差/相关性的抗崩溃损失)的语义层。这些组件共同为验证机器学习提供了语义基础,其中可执行的神经网络工件、验证过程、运行时边界和数学声明可以在一个定理证明环境中陈述和关联。
英文摘要:
Neural networks are increasingly deployed in scientific, safety critical, and mission critical pipelines, yet verification and analysis are often performed outside the programming environment that defines and runs the model. This creates a semantic gap between the executed network and the analyzed artifact: guarantees can depend on implicit conventions about operator semantics, tensor layouts, preprocessing, floating-point behavior, graph transformations, accelerated kernels, and external certificates. We present TorchLean, a unified framework for formalizing, executing, and verifying neural networks in Lean 4. TorchLean treats learned models as executable programs and mathematical objects with a shared semantics for computation, verification, and theorem proving. The framework provides a PyTorch style API for typed tensors, layers, objectives, optimizers, automatic differentiation, and graph programs, with eager and compiled execution paths that lower to a common computation-graph representation. TorchLean supports exact and finite-precision tensor semantics, verified reverse-mode differentiation, interval and affine bound propagation, CROWN/LiRPA style certificate checking, import/export workflows, and CUDA-backed execution through explicit FFI boundaries. It also includes semantic layers for attention and FlashAttention, state-space sequence models, diffusion and sampling processes, probability kernels, reinforcement-learning objectives and Markov decision processes, and self-supervised objectives such as masked autoencoding, JEPA-style predictive views, and variance/correlation-based anti-collapse losses. Together, these components provide a semantic foundation for verified machine learning, where executable neural network artifacts, verification procedures, runtime boundaries, and mathematical claims can be stated and related inside one theorem-proving environment.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。