Algorithm Search⌘K

Proofs: Coppersmith-Winograd algorithm

These are the human proofs of Coppersmith-Winograd algorithm, at full length.

The q + 2 approximate products compute the Coppersmith-Winograd bilinear map full

This proof shows: correctness, termination.

Let RR be a ring with subtraction: an additive abelian group with an associative multiplication that distributes over addition on both sides. Commutativity of RR is not used. Let ε be an indeterminate that commutes with every element of RR, and work in the polynomial ring R[ε]R[\varepsilon]. In every product the xx factor is on the left and the yy factor on the right.

Fix q≥0q \ge 0 and x,y∈Rq+2x, y \in R^{q+2}, indexed from 00 to q+1q + 1. The target is

φ0=∑i=1qxiyi+x0yq+1+xq+1y0,φi=x0yi+xiy0 (1≤i≤q),φq+1=x0y0.\varphi_0 = \sum_{i=1}^{q} x_i y_i + x_0 y_{q+1} + x_{q+1} y_0, \qquad \varphi_i = x_0 y_i + x_i y_0 \ (1 \le i \le q), \qquad \varphi_{q+1} = x_0 y_0.

The products

By distributivity, and since ε commutes with RR,

Pi=(x0+εxi)(y0+εyi)=x0y0+ε(x0yi+xiy0)+ε2xiyi(1≤i≤q),Pq+1=(x0+ε2X)(y0+ε2Y)=x0y0+ε2(x0Y+Xy0)+ε4XY,Pq+2=(x0+ε3xq+1)(y0+ε3yq+1)=x0y0+ε3(x0yq+1+xq+1y0)+ε6xq+1yq+1,\begin{aligned} P_i &= (x_0 + \varepsilon x_i)(y_0 + \varepsilon y_i) = x_0 y_0 + \varepsilon (x_0 y_i + x_i y_0) + \varepsilon^2 x_i y_i \qquad (1 \le i \le q), \\ P_{q+1} &= (x_0 + \varepsilon^2 X)(y_0 + \varepsilon^2 Y) = x_0 y_0 + \varepsilon^2 (x_0 Y + X y_0) + \varepsilon^4 X Y, \\ P_{q+2} &= (x_0 + \varepsilon^3 x_{q+1})(y_0 + \varepsilon^3 y_{q+1}) = x_0 y_0 + \varepsilon^3 (x_0 y_{q+1} + x_{q+1} y_0) + \varepsilon^6 x_{q+1} y_{q+1}, \end{aligned}

where X=∑i=1qxiX = \sum_{i=1}^q x_i and Y=∑i=1qyiY = \sum_{i=1}^q y_i as in line L2. Also x0Y+Xy0=∑i=1q(x0yi+xiy0)x_0 Y + X y_0 = \sum_{i=1}^q (x_0 y_i + x_i y_0) by distributivity.

The outputs

Write [εk]f[\varepsilon^k] f for the coefficient of εk\varepsilon^k in f∈R[ε]f \in R[\varepsilon].

Output 0 (line L5). c0=ε∑iPi−Pq+1+Pq+2−qεPq+2c_0 = \varepsilon \sum_{i} P_i - P_{q+1} + P_{q+2} - q \varepsilon P_{q+2}. Its coefficients up to ε3\varepsilon^3 are:

  • [ε0][\varepsilon^0]: 0−x0y0+x0y0−0=00 - x_0 y_0 + x_0 y_0 - 0 = 0;
  • [ε1][\varepsilon^1]: q x0y0−0+0−q x0y0=0q\, x_0 y_0 - 0 + 0 - q\, x_0 y_0 = 0;
  • [ε2][\varepsilon^2]: ∑i(x0yi+xiy0)−(x0Y+Xy0)+0−0=0\sum_i (x_0 y_i + x_i y_0) - (x_0 Y + X y_0) + 0 - 0 = 0;
  • [ε3][\varepsilon^3]: ∑ixiyi−0+(x0yq+1+xq+1y0)−q [ε2]Pq+2=φ0\sum_i x_i y_i - 0 + (x_0 y_{q+1} + x_{q+1} y_0) - q\, [\varepsilon^2] P_{q+2} = \varphi_0, since [ε2]Pq+2=0[\varepsilon^2] P_{q+2} = 0.

Outputs 1 to q (line L6). Pi−Pq+1=ε(x0yi+xiy0)+ε2(xiyi−x0Y−Xy0)−ε4XYP_i - P_{q+1} = \varepsilon (x_0 y_i + x_i y_0) + \varepsilon^2 (x_i y_i - x_0 Y - X y_0) - \varepsilon^4 X Y has zero constant term, so ci=ε2(Pi−Pq+1)c_i = \varepsilon^2 (P_i - P_{q+1}) has [ε0]ci=[ε1]ci=[ε2]ci=0[\varepsilon^0] c_i = [\varepsilon^1] c_i = [\varepsilon^2] c_i = 0 and [ε3]ci=x0yi+xiy0=φi[\varepsilon^3] c_i = x_0 y_i + x_i y_0 = \varphi_i.

Output q + 1 (line L7). cq+1=ε3Pq+2c_{q+1} = \varepsilon^3 P_{q+2}, so its coefficients below ε3\varepsilon^3 are 00 and [ε3]cq+1=[ε0]Pq+2=x0y0=φq+1[\varepsilon^3] c_{q+1} = [\varepsilon^0] P_{q+2} = x_0 y_0 = \varphi_{q+1}.

So line L8 returns (φ0,…,φq+1)(\varphi_0, \ldots, \varphi_{q+1}). The case q=0q = 0 is included: the sums over ii are empty, X=Y=0X = Y = 0, and the same computation applies.

The computation also shows that ck=ε3φk+O(ε4)c_k = \varepsilon^3 \varphi_k + O(\varepsilon^4) for every kk. In trilinear form, with Z=∑i=1qziZ = \sum_{i=1}^q z_i, this is

∑i=1qε(x0+εxi)(y0+εyi)(z0+εzi)−(x0+ε2X)(y0+ε2Y)(z0+ε2Z)+(1−qε)(x0+ε3xq+1)(y0+ε3yq+1)(z0+ε3zq+1)=ε3Tq+O(ε4),\sum_{i=1}^{q} \varepsilon (x_0 + \varepsilon x_i)(y_0 + \varepsilon y_i)(z_0 + \varepsilon z_i) - (x_0 + \varepsilon^2 X)(y_0 + \varepsilon^2 Y)(z_0 + \varepsilon^2 Z) + (1 - q\varepsilon)(x_0 + \varepsilon^3 x_{q+1})(y_0 + \varepsilon^3 y_{q+1})(z_0 + \varepsilon^3 z_{q+1}) = \varepsilon^3 T_q + O(\varepsilon^4),

because the coefficient of zkz_k on the left is ckc_k, up to the term −qε4Pq+2zq+1-q\varepsilon^4 P_{q+2} z_{q+1}, which is O(ε4)O(\varepsilon^4). Hence R‾(Tq)≤q+2\underline{R}(T_q) \le q + 2 with error degree 33.

The exact version by interpolation

Let c~k\tilde c_k be ckc_k as written in lines L5 to L7, a polynomial in ε. Each PrP_r has degree at most 66 and each multiplier in L5 to L7 has degree at most 33, so c~k\tilde c_k has degree at most 99, and by the above its coefficients of ε0,ε1,ε2\varepsilon^0, \varepsilon^1, \varepsilon^2 are zero. So fk(ε)=c~k(ε)/ε3f_k(\varepsilon) = \tilde c_k(\varepsilon) / \varepsilon^3 is a polynomial of degree at most 66 with fk(0)=φkf_k(0) = \varphi_k. Over Q\mathbb{Q}, or over a field with at least 88 elements, the values of fkf_k at the 77 distinct nonzero points 1,…,71, \ldots, 7 determine fkf_k, and Lagrange interpolation gives

φk=fk(0)=∑t=17fk(t)∏s≠t−st−s.\varphi_k = f_k(0) = \sum_{t=1}^{7} f_k(t) \prod_{s \ne t} \frac{-s}{t - s}.

Each fk(t)f_k(t) is computed from the q+2q + 2 products at ε=t\varepsilon = t, divided by t3t^3, so the exact version uses 7(q+2)7(q + 2) products and divides only by the nonzero constants t3t^3 and t−st - s. The implementation requires a prime modulus larger than 77, so that 1,…,71, \ldots, 7 are distinct and nonzero.

Termination

Lines L1 and L6 are loops over i=1,…,qi = 1, \ldots, q, and every other line is a single step. Each step is a finite operation on polynomials of degree at most 99 in ε. So the algorithm stops after O(q)O(q) steps. The interpolation version makes 77 such runs and a fixed number of further operations per output.

Back to Coppersmith-Winograd algorithm