A won game of TensorGame is a correct bilinear algorithm full
This proof shows: correctness, termination.
Let K be the ring of the game: Z, or Z/qZ when a modulus q is given. Tensors are arrays indexed by [nm]×[mp]×[np] with entries in K. For arrays u, v, w write (u⊗v⊗w)abc=uavbwc.
The invariant
Let St be the residual after t moves and (u(r),v(r),w(r)) the r-th move. Then
T=St+r=1∑tu(r)⊗v(r)⊗w(r)for every t reached. At line L1, S0=T and the sum is empty. Line L4 sets St+1=St−u(t+1)⊗v(t+1)⊗w(t+1) entrywise in K, 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 S.
A won game
If the loop ends with St=0, the invariant gives T=∑r=1tu(r)⊗v(r)⊗w(r) in K. For T=⟨n,m,p⟩, the entry of T at ((i,j),(j′,k),(i′,k′)) is [j=j′][k=k′][i=i′]. Let A be n×m and B be m×p with entries in a ring R that is a K-algebra (any ring when K=Z; a ring of characteristic q when K=Z/qZ). Define Mr=(∑i,juij(r)aij)(∑j,kvjk(r)bjk). By distributivity, keeping a on the left,
r∑wik(r)Mr=i1,j1,j2,k2∑(r∑ui1j1(r)vj2k2(r)wik(r))ai1j1bj2k2=i1,j1,j2,k2∑T(i1,j1),(j2,k2),(i,k)ai1j1bj2k2=j∑aijbjk=cik. No commutativity of R 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=0, the reward is −t−γ(St) with γ(S)=∑arank(Sa,⋅,⋅), the ranks of the slices taken over Q or over Z/qZ for prime q. This is an upper bound on the tensor rank of S: a slice of rank ρa is a sum of ρa products g⊗h, and ea⊗g⊗h is a rank-one tensor, so S=∑aea⊗Sa,⋅,⋅ is a sum of ∑aρa rank-one tensors. Hence finishing the lost game by the slices would give a correct scheme of rank t+γ(St), and the reward of the lost game is minus that rank.
Termination
Each pass through the loop increases t by one, and the loop condition requires t<Rlimit, so there are at most Rlimit 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 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.