Algorithm Search⌘K

Proofs: AlphaTensor

These are the human proofs of AlphaTensor, at full length.

A won game of TensorGame is a correct bilinear algorithm full

This proof shows: correctness, termination.

Let KK be the ring of the game: Z\mathbb{Z}, or Z/qZ\mathbb{Z}/q\mathbb{Z} when a modulus qq is given. Tensors are arrays indexed by [nm]×[mp]×[np][nm] \times [mp] \times [np] with entries in KK. For arrays uu, vv, ww write (u⊗v⊗w)abc=uavbwc(u \otimes v \otimes w)_{abc} = u_a v_b w_c.

The invariant

Let StS_t be the residual after tt moves and (u(r),v(r),w(r))(u^{(r)}, v^{(r)}, w^{(r)}) the rr-th move. Then

T=St+∑r=1tu(r)⊗v(r)⊗w(r)for every t reached.T = S_t + \sum_{r=1}^{t} u^{(r)} \otimes v^{(r)} \otimes w^{(r)} \qquad \text{for every } t \text{ reached}.

At line L1, S0=TS_0 = T and the sum is empty. Line L4 sets St+1=St−u(t+1)⊗v(t+1)⊗w(t+1)S_{t+1} = S_t - u^{(t+1)} \otimes v^{(t+1)} \otimes w^{(t+1)} entrywise in KK, and appends the move, so the right side is unchanged. The checks before L4 only reject moves with entries outside F or with wrong shapes; they do not change SS.

A won game

If the loop ends with St=0S_t = 0, the invariant gives T=∑r=1tu(r)⊗v(r)⊗w(r)T = \sum_{r=1}^{t} u^{(r)} \otimes v^{(r)} \otimes w^{(r)} in KK. For T=⟨n,m,p⟩T = \langle n, m, p \rangle, the entry of TT at ((i,j),(j′,k),(i′,k′))((i, j), (j', k), (i', k')) is [j=j′][k=k′][i=i′][j = j'][k = k'][i = i']. Let AA be n×mn \times m and BB be m×pm \times p with entries in a ring RR that is a KK-algebra (any ring when K=ZK = \mathbb{Z}; a ring of characteristic qq when K=Z/qZK = \mathbb{Z}/q\mathbb{Z}). Define Mr=(∑i,juij(r)aij)(∑j,kvjk(r)bjk)M_r = \big(\sum_{i,j} u^{(r)}_{ij} a_{ij}\big)\big(\sum_{j,k} v^{(r)}_{jk} b_{jk}\big). By distributivity, keeping aa on the left,

∑rwik(r)Mr=∑i1,j1,j2,k2(∑rui1j1(r)vj2k2(r)wik(r))ai1j1bj2k2=∑i1,j1,j2,k2T(i1,j1),(j2,k2),(i,k) ai1j1bj2k2=∑jaijbjk=cik.\sum_r w^{(r)}_{ik} M_r = \sum_{i_1, j_1, j_2, k_2} \Big(\sum_r u^{(r)}_{i_1 j_1} v^{(r)}_{j_2 k_2} w^{(r)}_{ik}\Big) a_{i_1 j_1} b_{j_2 k_2} = \sum_{i_1, j_1, j_2, k_2} T_{(i_1, j_1), (j_2, k_2), (i, k)}\, a_{i_1 j_1} b_{j_2 k_2} = \sum_{j} a_{ij} b_{jk} = c_{ik}.

No commutativity of RR is used, so the same holds when the entries are blocks, and the recursive use in multiply_with is correct by block multiplication; zero padding does not change the top-left part of the product.

The policy does not appear in this argument. So a won game is correct whatever the policy, the network or the search did.

The penalty

If the game ends with St≠0S_t \ne 0, the reward is −t−γ(St)-t - \gamma(S_t) with γ(S)=∑arank⁡(Sa,⋅,⋅)\gamma(S) = \sum_a \operatorname{rank}(S_{a,\cdot,\cdot}), the ranks of the slices taken over Q\mathbb{Q} or over Z/qZ\mathbb{Z}/q\mathbb{Z} for prime qq. This is an upper bound on the tensor rank of SS: a slice of rank ρa\rho_a is a sum of ρa\rho_a products g⊗hg \otimes h, and ea⊗g⊗he_a \otimes g \otimes h is a rank-one tensor, so S=∑aea⊗Sa,⋅,⋅S = \sum_a e_a \otimes S_{a,\cdot,\cdot} is a sum of ∑aρa\sum_a \rho_a rank-one tensors. Hence finishing the lost game by the slices would give a correct scheme of rank t+γ(St)t + \gamma(S_t), and the reward of the lost game is minus that rank.

Termination

Each pass through the loop increases tt by one, and the loop condition requires t<Rlimitt < R_{\text{limit}}, so there are at most RlimitR_{\text{limit}} passes, each finite. The slice ranks are computed by Gaussian elimination, which is finite. The recursion in multiply_with stops because a scheme with max⁡(n,m,p)≥2\max(n, m, p) \ge 2 strictly shrinks at least one side that is larger than the cutoff at each level, and the base case is reached when a side is at most the cutoff.

Back to AlphaTensor