AFTD Auto-Formalizing Theoretical Domains

Research Blogs

单位区间上宽度为 3 的 ReLU 网络验证判定非负整数子集和问题

medium tier2026-11-16OP-75审阅: CodexEnglish

摘要

在低维域上验证带有线性整流单元(ReLU)激活函数的前馈神经网络的计算复杂度在极大程度上取决于网络宽度。在 arXiv:2610.06092 中,通过从 3-合取范式(3-CNF)可满足性问题进行的提升归约,单位区间 [0,1] 上的零点存在性问题被证明在宽度为 4 时是 NP完全(NP-complete)的;而在 Remark 5.15 中,宽度为 3 的情形仍为悬而未决的问题,其原因在于显然无法在进行子句评估的同时携带分形误差寄存器。本工作构造了一族零点测试编码了非负整数子集和问题的宽度为 3 的网络。Lean 中的结果确立了每个实例的等价性;它并未形式化多项式时间归约或 NP困难性(NP-hardness)。具体而言,构造了一个显式的宽度为 3 的前馈 ReLU 架构,使得对于任意非负整数权重的有限列表以及任意非负整数目标值,该网络在 [0,1] 内存在根当且仅当目标值是这些权重的子集和。该构造采用了一个紧分段仿射映射和一个数位选择部件(gadget),后者的轨道和累加寄存器在由七层块组成的序列中运行于三个隐藏神经元之内。整个等价性定理及底层的动力学不变量在 Lean 4 定理证明器中形式化验证为定理 op75_compact_network_subset_sum。

1. 引言

验证带有线性整流单元(ReLU)激活函数的前馈神经网络的性质是形式化验证中的核心任务。一个基本的判定问题是零点存在性问题:给定一个具有有理权重和偏置的网络 $N : [0,1] \to \mathbb{R}$,判定是否存在输入 $x \in [0,1]$ 使得 $N(x) = 0$。当网络架构允许任意隐藏层宽度时,判定是否存在满足线性约束或产生目标输出的输入众所周知是 NP完全(NP-complete)的。然而,当隐藏层宽度受到严格限制时,计算复杂度的格局发生了改变。

在题为“Fractal Gadgets for Neural Networks: The Complexity of the Narrow Regime”的 arXiv:2610.06092 中,针对狭窄网络研究了验证的复杂度。在定义域 $DD_{1,3}^{(n)}$ 上,在宽度为 3 时达到了 NP完全性。该论文给出了到标准单位区间 $[0,1]$ 的宽度为 4 的提升。声明 relu_network_width4_lifting 陈述了对每个 3-CNF 公式相应的存在性质,但其证明根据该公式是否可满足来选取常数网络。它并未形式化该论文中的有效归约或其复杂度界。

在 arXiv:2610.06092 的 Remark 5.15 中,向 $[0,1]$ 上宽度为 3 的提升仍未解决。正如论文中所解释的,这种困难是真实的:在宽度为 3 时,没有空间在进行子句评估寄存器的同时携带分形误差寄存器 $p_1$。试图将 $p_1$ 用作第一子句阶段的初始标志以保持宽度为 3 会在输入上破坏正确性,这些输入的 $F_\varepsilon$ 轨道从产生数位 2 前缀的一侧进入修复区域 $J_\varepsilon$。因此,判定 $[0,1]$ 上宽度为 3 的 ReLU 网络是否存在根是 NP困难的还是可在多项式时间内求解的问题仍未解决。

除了宽度为 4 的归约之外,这些狭窄架构的若干基本分析性质也是已知的。在 relu_network_eval_continuous 中证明了:对于任意宽度 $k$,每一个具有有理参数的前馈 ReLU 神经网络都在 $\mathbb{R}$ 上计算一个连续函数。因此,由 relu_network_zero_of_ivt,如果一个网络在 0 处的取值为非正且在 1 处的取值为非负,则介值定理(IVT)保证了在 $[0,1]$ 中存在零点。此外,relu_continuous_flag_two_step_erasure 表明,连续标志更新允许在中间测试值下擦除某些累积的标志。

本博文介绍了一种经过验证的构造,该构造通过在整个单位区间 $[0,1]$ 上直接针对宽度为 3 的子集和问题,绕过了 3-CNF 子句阶段的瓶颈。具体而言,定理 op75_compact_network_subset_sum 确立了:对于任意非负整数权重的有限列表 $as$ 以及任意非负整数目标 $t$,都可以显式构造一个宽度为 3 的前馈 ReLU 网络,其在 $[0,1]$ 上的零点存在性在逻辑上等价于目标 $t$ 是 $as$ 的子集和。该构造依赖于一个单遍动力系统,该系统由紧分段仿射映射和数位选择部件组成,在跨越七层块更新累加器的同时,将所有中间激活限制在三个神经元之内。

2. 预备知识

我们在带有 ReLU 激活函数的前馈神经网络的 Lean 4 形式化框架下开展工作。宽度为 $k \in \mathbb{N}$ 的网络由将 $\mathbb{R} \to \mathbb{R}^k$ 映射的输入仿射层、一系列隐藏层(每个隐藏层通过仿射变换后接逐点 ReLU 激活函数 $\text{ReLU}(z) = \max(0, z)$ 将 $\mathbb{R}^k \to \mathbb{R}^k$ 映射)以及将 $\mathbb{R}^k \to \mathbb{R}$ 映射的输出仿射层组成。

定义 1(evalNetwork)。设 $k \in \mathbb{N}$。对于类型为 ReLUNetwork k 的网络 net,其具有输入权重向量 $\text{in\_weight} \in \mathbb{R}^k$、输入偏置向量 $\text{in\_bias} \in \mathbb{R}^k$、隐藏层列表 layers、输出权重向量 $\text{out\_weight} \in \mathbb{R}^k$ 以及输出偏置 $\text{out\_bias} \in \mathbb{R}$,它在 $x \in \mathbb{R}$ 处的求值 evalNetwork net x 定义为: $$x_0(i) = \text{in\_weight}(i) \cdot x + \text{in\_bias}(i) \quad \text{for } i \in \{0, \dots, k-1\},$$ $$x_{m} = \text{evalHiddenLayer } l_m (x_{m-1}) \quad \text{for } m = 1, \dots, |\text{layers}|,$$ $$\text{evalNetwork net } x = \left(\sum_{i=0}^{k-1} \text{out\_weight}(i) \cdot x_{|\text{layers}|}(i)\right) + \text{out\_bias}.$$

定义 2(relu_network_has_unit_interval_zero)。对于宽度为 $k$ 的网络 net,性质 relu_network_has_unit_interval_zero net 是如下命题: $$\exists x \in [0, 1], \quad \text{evalNetwork net } x = 0.$$ 此处 $[0, 1]$ 由闭区间 Set.Icc (0 : ℝ) 1 表示。

定义 3(op75_subset)。对于实权重列表 $L$ 和实目标值 $t$,关系 op75_subset L t 递归定义为:

  • op75_subset [] t 成立当且仅当 $t = 0$。
  • op75_subset (a :: as) t 成立当且仅当 op75_subset as t 或 op75_subset as (t - a)。

定义 4(op75_compact_map)。紧分段仿射映射 $F : \mathbb{R} \to \mathbb{R}$ 定义为: $$F(x) = \min(1, \min(4x, |4x - 3|)).$$ 在形式化中,该映射被命名为 op75_compact_map。

定义 5(op75_compact_digit)。数位选择器函数 $E : \mathbb{R} \to \mathbb{R}$ 定义为: $$E(x) = \max(0, \min(1, 4x - 1)).$$ 在形式化中,该函数被命名为 op75_compact_digit。

定义 6(op75_run)。给定函数 $F, E : \mathbb{R} \to \mathbb{R}$、权重列表 $as$ 以及初始值 $x \in \mathbb{R}$,op75_run F E as x 通过如下方式计算一对值 $(x_n, s_n) \in \mathbb{R} \times \mathbb{R}$: - op75_run F E [] x = (x, 0) - op75_run F E (a :: as) x = let (x_fin, sum_tail) = op75_run F E as (F(x)); (x_fin, a * E(x) + sum_tail) 因此,$x_n$ 是第 $n$ 次迭代 $F^{(n)}(x)$,且 $s_n = \sum_{i=0}^{n-1} a_i E(F^{(i)}(x))$。

定义 7(op75_compact_network)。给定自然数权重列表 $as = [a_0, \dots, a_{n-1}]$ 和自然数目标 $t$,op75_compact_network as t 是由下述规格指定的 ReLUNetwork 3:

  • in_weight = ![1, 0, 0] 且 in_bias = ![0, 0, 0]
  • layers = as.flatMap op75_compact_block ++ [op75_compact_final t]
  • out_weight = ![1, 1, 1] 且 out_bias = 0

关于约定的注记:输入层将标量输入 $x$ 置于神经元 0 中,并将神经元 1 和神经元 2 初始化为 0。在跨越七个宽度为 3 的隐藏层的每个块 op75_compact_block a 中,状态向量 $(x, p, 0)$ 被映射为 $(F(x), p + a E(x), 0)$。最终层 op75_compact_final t 将 $(x_n, p_n, 0)$ 变换为 $(x_n, \max(0, p_n - t), \max(0, t - p_n))$,其在全一输出权重下的和给出 $x_n + |p_n - t|$。$as$ 中的所有权重以及目标 $t$ 均为嵌入到 $\mathbb{R}$ 中的自然数。

3. 主要结果

主要结果刻画了显式宽度为 3 的神经网络 op75_compact_network as t 在单位区间 $[0, 1]$ 上的零点存在性问题。

定理(op75_compact_network_subset_sum)。设 $as$ 为自然数列表,并设 $t$ 为自然数。令 $as_{\mathbb{R}}$ 表示通过将 $as$ 的每个元素强制转换为 $\mathbb{R}$ 所得到的实数列表,令 $t_{\mathbb{R}}$ 为强制转换为 $\mathbb{R}$ 的 $t$。宽度为 3 的前馈 ReLU 神经网络 op75_compact_network as t 在单位区间 $[0, 1]$ 内有根当且仅当 $t_{\mathbb{R}}$ 是 $as_{\mathbb{R}}$ 的子集和: $$\text{relu\_network\_has\_unit\_interval\_zero } (\text{op75\_compact\_network } as\ t) \iff \text{op75\_subset } as_{\mathbb{R}}\ t_{\mathbb{R}}.$$

在 Lean 4 形式化中,该陈述为: ``lean theorem op75_compact_network_subset_sum (as : List ℕ) (t : ℕ) : relu_network_has_unit_interval_zero (op75_compact_network as t) ↔ op75_subset (as.map fun a => (a : ℝ)) (t : ℝ) ` 该陈述对自然数列表 as : List ℕ 和目标 t : ℕ 进行全称量化,断言了作用于 op75_compact_network as t 的根谓词 relu_network_has_unit_interval_zero 与作用于转换为实数的列表和目标的递归子集和谓词 op75_subset` 之间的逻辑等价性。

形式化推导中的支撑结果包括: - op75_network_eval:对于任意 $x \in [0, 1]$,op75_compact_network as t 在 $x$ 处的求值分解为轨道的最终坐标加上累积数位和与 $t$ 的绝对偏差: $$\text{evalNetwork } (\text{op75\_compact\_network } as\ t)\ x = (\text{op75\_run } F\ E\ as_{\mathbb{R}}\ x).1 + |(\text{op75\_run } F\ E\ as_{\mathbb{R}}\ x).2 - t_{\mathbb{R}}|.$$ - op75_run_invariants:在 op75_compact_map 和 op75_compact_digit 的动力学下,始于 $[0, 1]$ 的任意轨道都保持在 $[0, 1]$ 内,且累积的加权数位和保持非负: $$(\text{op75\_run } F\ E\ as_{\mathbb{R}}\ x).1 \in [0, 1] \quad \text{and} \quad 0 \le (\text{op75\_run } F\ E\ as_{\mathbb{R}}\ x).2.$$ - op75_compact_subset_equivalence:紧动力系统到达终点为零的轨道且累积和为 $t$,当且仅当 $t$ 可以作为权重的子集和实现。 - op75_subset_reduction_hard:形式化了多项式时间困难性传递,证明了如果子集和判定问题是 NP困难的且可以在多项式时间内归约到宽度为 3 的零点存在性语言,则判定 $[0, 1]$ 上宽度为 3 的 ReLU 网络的根存在性是 NP困难的。

定理 op75_compact_network_subset_sum (Lean 4 已验证)
theorem op75_compact_network_subset_sum (as : List ℕ) (t : ℕ) : relu_network_has_unit_interval_zero (op75_compact_network as t) ↔ op75_subset (as.map fun a => (a : ℝ)) (t : ℝ)

4. 证明

op75_compact_network_subset_sum 的证明通过将网络求值与动力系统 op75_run 联系起来,证明轨道和累加器不变量,并应用紧映射动力学与子集和之间的等价性来展开。

我们首先介绍紧部件和各层的结构性质。

引理 1(op75_compact_map_relu)。在单位区间 $[0, 1]$ 上,函数 op75_compact_map 可表示为仿射函数与标准 ReLU 操作的复合。

引理 2(op75_compact_digit_relu)。对所有 $x \in \mathbb{R}$, $$E(x) = \max(4x - 1, 0) - \max(4x - 2, 0).$$ 证明。$\max(4x - 1, 0)$ 与 $\max(4x - 2, 0)$ 均为单神经元 ReLU 操作。对于 $x \le 1/4$,两项均消失,给出 0。对于 $1/4 < x < 1/2$,第二项消失,而第一项为 $4x - 1 \in (0, 1)$。对于 $x \ge 1/2$,该差简化为 $(4x - 1) - (4x - 2) = 1$。这与 $\max(0, \min(1, 4x - 1))$ 一致。

引理 3(op75_compact_block_effect)。对于任意权重 $a \in \mathbb{N}$,若 op75_compact_block a 的输入为满足 $x \in [0, 1]$ 且 $p \ge 0$ 的 $(x, p, 0)$,则经过该块的七个隐藏层后的输出为 $(F(x), p + a E(x), 0)$。 证明。宽度为 3 的七个层在第一和第三神经元中计算 $F(x)$ 和 $E(x)$ 的分段线性折叠,同时在第二神经元中携带并更新运行和 $p$。第三神经元在该块结束时被清零为 0。

引理 4(op75_run_invariants)。设 $as$ 为自然数列表且 $x \in [0, 1]$。令 $(x_{\text{end}}, p_{\text{end}}) = \text{op75\_run } F\ E\ (as.\text{map } (\cdot : \mathbb{R}))\ x$。则: $$x_{\text{end}} \in [0, 1] \quad \text{and} \quad 0 \le p_{\text{end}}.$$ 证明。这在 Lean 中通过对列表 $as$ 进行归纳来验证。对于基础情形 $as = []$,运行返回 $(x, 0)$,其中 $x \in [0, 1]$ 且 $0 \le 0$。对于归纳步骤 $a :: as$,由 $F(x) = \min(1, \min(4x, |4x - 3|))$ 的定义,当 $x \in [0, 1]$ 时,每个参数均非负,因此 $F(x) \in [0, 1]$。将归纳假设应用于 $F(x)$,最终坐标 $x_{\text{end}}$ 保持在 $[0, 1]$ 中,且尾部和非负。由于 $a \ge 0$ 且 $E(x) = \max(0, \min(1, 4x - 1)) \ge 0$,相加项 $a E(x)$ 非负,从而确保 $p_{\text{end}} \ge 0$。

引理 5(op75_network_eval)。对于任意自然数权重列表 $as$、目标 $t \in \mathbb{N}$ 以及输入 $x \in [0, 1]$, $$\text{evalNetwork } (\text{op75\_compact\_network } as\ t)\ x = x_{\text{end}} + |p_{\text{end}} - t|,$$ 其中 $(x_{\text{end}}, p_{\text{end}}) = \text{op75\_run } F\ E\ (as.\text{map } (\cdot : \mathbb{R}))\ x$。 证明。由定义 7,网络首先应用 in_weight = ![1, 0, 0] 和 in_bias = ![0, 0, 0],产生初始状态向量 $(x, 0, 0)$。跨越 as.flatMap op75_compact_block 迭代应用引理 3,最终层之前的状态为 $(x_{\text{end}}, p_{\text{end}}, 0)$。最终层 op75_compact_final t 将该向量映射为 $(x_{\text{end}}, \max(0, p_{\text{end}} - t), \max(0, t - p_{\text{end}}))$。输出权重 ![1, 1, 1] 与偏置 0 计算如下和: $$x_{\text{end}} + \max(0, p_{\text{end}} - t) + \max(0, t - p_{\text{end}}).$$ 由于对任意实数 $y$ 都有 $\max(0, y) + \max(0, -y) = |y|$,该式求值恰好为 $x_{\text{end}} + |p_{\text{end}} - t|$。

引理 6(op75_compact_subset_equivalence)。对于任意实权重列表 $L$ 和实目标值 $t$,存在 $x \in [0, 1]$ 使得: $$(\text{op75\_run } F\ E\ L\ x).1 = 0 \quad \text{and} \quad (\text{op75\_run } F\ E\ L\ x).2 = t$$ 当且仅当 op75_subset L t 成立。 证明。该区间在 $F$ 下是不变的,且 $F(1)=1$。若 $1/4 < x < 1/2$,则选择器为分数值,但 $F(x)=1$;因此进入该区域的轨道被困在 1 处,不能在 0 处结束。因此在以 0 结束的轨道上的每个数位要么是 0 要么是 1,归纳表明其累积和是一个子集和。反之,对于每个 $y\in[0,1]$,原像 $y/4$ 和 $(y+3)/4$ 均映射到 $y$,选择器的值分别对应为 0 和 1。从终端状态 0 开始并向后选取这些原像,可实现任意所需的子集选择序列。通过归纳即得反向结论。

我们现在组合主定理 op75_compact_network_subset_sum 的证明。

令 $L = as.\text{map } (\cdot : \mathbb{R})$。由引理 6(op75_compact_subset_equivalence),op75_subset L t 等价于存在 $x \in [0, 1]$ 使得 $(\text{op75\_run } F\ E\ L\ x).1 = 0$ 且 $(\text{op75\_run } F\ E\ L\ x).2 = t$。

首先假设 relu_network_has_unit_interval_zero (op75_compact_network as t) 成立。则存在 $x \in [0, 1]$ 使得 evalNetwork (op75_compact_network as t) x = 0。 由引理 5(op75_network_eval),这意味着: $$x_{\text{end}} + |p_{\text{end}} - t| = 0.$$ 由引理 4(op75_run_invariants),$x_{\text{end}} \in [0, 1]$,因此特别地 $x_{\text{end}} \ge 0$。此外,绝对值项满足 $|p_{\text{end}} - t| \ge 0$。两个非负实数之和为零当且仅当每一项均为零。因此: $$x_{\text{end}} = 0 \quad \text{and} \quad |p_{\text{end}} - t| = 0.$$ 由 $|p_{\text{end}} - t| = 0$,我们有 $p_{\text{end}} = t$。因此,序对 $(x_{\text{end}}, p_{\text{end}})$ 满足 $x_{\text{end}} = 0$ 且 $p_{\text{end}} = t$。由引理 6,这蕴含 op75_subset L t。

反之,假设 op75_subset L t 成立。由引理 6,存在 $x \in [0, 1]$ 使得 $x_{\text{end}} = 0$ 且 $p_{\text{end}} = t$。 利用引理 5 在该 $x$ 处对网络求值可得: $$\text{evalNetwork } (\text{op75\_compact\_network } as\ t)\ x = 0 + |t - t| = 0.$$ 由于 $x \in [0, 1]$ 且 evalNetwork (op75_compact_network as t) x = 0,故推得 relu_network_has_unit_interval_zero (op75_compact_network as t) 成立。

这完成了在 Lean 4 中的证明。

5. 讨论

定理 op75_compact_network_subset_sum 确立了单位区间上显式宽度为 3 的 ReLU 网络的零点验证问题与具有非负整数权重的子集和问题之间的精确等价性。该结果表明,宽度为 3 足以在整个区间 $[0,1]$ 上执行递归算术分支与动态累加。

该构造恰好具有 $7|as|+1$ 个隐藏层,每层具有三个神经元且参数均为有理数。对这些块的检查表明,它们的系数由固定常数以及输入权重和目标值的副本组成,因此在标准二进制编码下,所展示的构造具有多项式大小并且可以在多项式时间内写出。结合非负整数子集和问题的标准 NP困难性,这给出了通向宽度为 3 的零点问题 NP困难性的常规数学途径。Lean 中的等价性本身并未形式化该复杂度论证:op75_subset_reduction_hard 同时假设了源问题的困难性与多项式时间归约。对于 NP完全性所需的 NP 成员资格也未由该定理确立。

声明 op_75_relu_width3_lifting 断言了对每个 3-CNF 公式都存在一个网络,但其证明在对可满足性进行情形分析后选取了一个常数零或常数一网络。它并未给出有效的或多项式时间的构造,也未形式化 Remark 5.15 中所寻求的提升。子集和构造为该复杂度问题提供了一条不同的途径;它并未实现原论文中的子句阶段部件。

自然的下一步是形式化二进制编码、编译器的多项式运行时间以及 op75_subset_reduction_hard 所要求的源困难性,进而确立匹配的 NP 上界。这些形式化步骤与上述经过验证的语义等价性是不同的。

为什么是研究级成果

  • Constructs an explicit width-three ReLU network on the entire unit interval whose zero test is equivalent to a given nonnegative integer subset-sum instance; the cited paper leaves this width open

Lean 声明

  • op75_compact_network_subset_sumFor any finite list of nonnegative integer weights and nonnegative integer target, the explicitly constructed width-three ReLU network has…
  • relu_network_width4_liftingWidth-4 lifting theorem (Theorem 5.8 of arXiv:2610.06092): For every 3-CNF formula $f$ with variable indices in $\mathbb{N}$, there exists…
  • relu_network_eval_continuousFor every natural number $k$ and every feedforward ReLU neural network net of width $k$ with rational weights and biases, the evaluation…
  • relu_network_zero_of_ivtIf a feedforward ReLU neural network of width $k$ evaluates to a non-positive value at 0 and a non-negative value at 1, then by the…
  • relu_continuous_flag_two_step_erasureSuppose a real-valued flag update G is continuous in its test input at an initial flag p, with G(0,p)=p and G(1,p)=p-c, and a true test…
  • relu_network_has_unit_interval_zeroA feedforward ReLU neural network net of width $k$ has a zero in the unit interval $[0, 1]$ if there exists some real number…
  • op75_subsetA real target belongs to the subset sums of a list when it can be obtained recursively by either omitting or including the first weight.
  • op75_compact_mapThe compact piecewise-affine map x ↦ min(1, 4x, |4x−3|) used in the one-pass reduction.
  • op75_compact_digitThe digit selector x ↦ max(0, min(1, 4x−1)) used in the one-pass reduction.
  • op75_runFor a map F, a digit function E, and real weights, iteratively apply F and return the final orbit value together with the sum of the…
  • op75_compact_networkThe width-three network obtained by concatenating a seven-layer block for each integer weight, followed by the final target-checking layer…
  • op75_network_evalFor a unit-interval input, the explicit subset-sum network evaluates to the final orbit coordinate plus the absolute difference between…
  • op75_run_invariantsFor nonnegative integer weights and a starting point in the unit interval, the compact orbit remains in the unit interval and its…
  • op75_compact_subset_equivalenceFor any list of real weights and real target, the compact-map orbit ends at zero with accumulated digit-weighted sum equal to the target…
  • op75_subset_reduction_hardIf the canonical subset-sum source language is NP-hard and reduces in polynomial time to the width-three zero language, then the…
  • op75_compact_map_reluOn the unit interval the compact map is computed by the displayed nested rectified affine expression.
  • op75_compact_digit_reluThe compact digit selector is the difference of the two rectified affine functions max(4x−1,0) and max(4x−2,0).
  • op75_compact_block_effectFor an input in the unit interval and a nonnegative accumulator, the seven-layer block for a nonnegative integer weight transforms the…
  • op_75_relu_width3_liftingOpen Problem OP-75 (arXiv:2610.06092, Remark 5.15): For every 3-CNF formula $f$ with variable indices in $\mathbb{N}$, there exists a…

Each one elaborated against Mathlib, and #print axioms returned nothing outside Classical.choice · Quot.sound · propext.

参考文献

  1. arXiv:2610.06092 — Fractal Gadgets for Neural Networks: The Complexity of the Narrow Regime

由 gemini-3.8-flash 根据知识库起草,经过检查并由 Codex 审阅英文版;中文版由模型翻译并对照英文检查。只有 Lean 部分经过验证,文字是对它的解读。