Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Classical polar encoding uses O(N log N) actual XOR and swap gates

Open
QAlgorithms.Papers.Independent.Intakethird100.P14.classical_encoding_complexity

by Gohan · Nov 1, 2026 · Mathlib 0df444a (Lean v4.33.1)

prove2quantum

For each N=2nN=2^nN=2n, let GN=BNF⊗nG_N=B_NF^{\otimes n}GN​=BN​F⊗n over F2\mathbb F_2F2​, where F=[1011]F=\left[\begin{smallmatrix}1&0\\1&1\end{smallmatrix}\right]F=[11​01​] and BNB_NBN​ reverses the nnn address bits of a wire. Form the explicit classical circuit EnE_nEn​ by swapping each bit-reversal wire pair once and then applying the nnn XOR butterfly layers. Count every two-wire XOR and swap as one operation. There exist absolute constants C>0C>0C>0 and n0∈Nn_0\in\mathbb Nn0​∈N such that the cost bound holds for every n≥n0n\ge n_0n≥n0​, and correctness holds for every n≥0n\ge0n≥0:

∣En∣≤C 2nn,∀u∈F22n,En(u)=uG2n.|E_n|\le C\,2^n n,\qquad \forall u\in\mathbb F_2^{2^n},\quad E_n(u)=uG_{2^n}.∣En​∣≤C2nn,∀u∈F22n​,En​(u)=uG2n​.

Since n=log⁡2Nn=\log_2Nn=log2​N, the actual list length is O(Nlog⁡N)O(N\log N)O(NlogN). The circuit and bound are independent of the transmitted word, information set, and frozen vector. The claim concerns classical encoding; no efficient quantum decoding theorem is supplied by the paper.

Preamble
import Definitions.Def_QAlgorithms_Papers_Independent_Intakethird100_P14
Formal statement
noncomputable section

namespace QAlgorithms.Papers.Independent.Intakethird100.P14

open Filter MeasureTheory

open scoped ENNReal NNReal ComplexOrder BigOperators

open QAlgorithms.RealRegisters (Hilbert)

open QAlgorithms.Papers.Independent.Dependency50.P33 (IsDensity)

open QAlgorithms.Papers.Independent.Dependency50.P13 (compression)

open QAlgorithms.Papers.Independent.Renew46.P44 (wordOutput)

attribute [local instance] Classical.propDecidable Classical.decEq

/-- Unnumbered main contribution, PDF pp.1–2; actual encoder (5), p.4.
The concrete XOR/swap list implements uG_N on every word. Universal constants
and the threshold precede n and the input, hence also all coset choices.
Since N=2^n, N*n is exactly N*log_2(N). No quantum decoding complexity is claimed. -/
theorem classical_encoding_complexity :
    ∃ C : ℝ, 0 < C ∧ ∃ n0 : ℕ,
      (∀ n ≥ n0, ((recursivePolarEncoder n).length : ℝ) ≤ C * (2 ^ n : ℕ) * n) ∧
      ∀ n (u : PolarWire n → Bit), runEncoder (recursivePolarEncoder n) u = polarEncode n u := by sorry

end QAlgorithms.Papers.Independent.Intakethird100.P14

end
Source
Polar codes for classical-quantum channels, arXiv:1109.2591v3, PDF p. 2, Unnumbered main result: O(N log N) classical polar encoding
Read-back

What the Lean code literally says, in plain math · gpt-6.1-sol

There exist a real constant C>0C>0C>0 and an integer n0≥0n_0\ge0n0​≥0 such that the following gate-count bound holds for every n≥n0n\ge n_0n≥n0​, and the following encoding identity holds for every n≥0n\ge0n≥0 and every word u:{0,…,2n−1}→F2u:\{0,\ldots,2^n-1\}\to\mathbb F_2u:{0,…,2n−1}→F2​. Write rev⁡n(i)\operatorname{rev}_n(i)revn​(i) for the index obtained by reversing the nnn binary digits of iii, reduced modulo 2n2^n2n, and write toggle⁡k(i)=(ixor2k) mod 2n\operatorname{toggle}_k(i)=(i\mathbin{\mathrm{xor}}2^k)\bmod2^ntogglek​(i)=(ixor2k)mod2n. The prescribed gate list first swaps iii with rev⁡n(i)\operatorname{rev}_n(i)revn​(i) for every i<rev⁡n(i)i<\operatorname{rev}_n(i)i<revn​(i), in the order supplied by the finite set’s list, and then, for k=0,…,n−1k=0,\ldots,n-1k=0,…,n−1 in increasing order, applies an XOR gate from toggle⁡k(i)\operatorname{toggle}_k(i)togglek​(i) to iii for each iii whose kkk-th binary digit is 000, again in the finite set’s list order. An XOR gate replaces its target value by the sum modulo 222 of the old target and source values; a swap exchanges the two old values. The length LnL_nLn​ of this list satisfies

Ln≤C 2nn(n≥n0).L_n\le C\,2^n n\qquad(n\ge n_0).Ln​≤C2nn(n≥n0​).

Executing the entire list in order gives, at each output coordinate c<2nc<2^nc<2n, exactly

∑r<2nur∏k<nκ ⁣(bit⁡k(rev⁡n(r)),bit⁡k(c)),κ(a,0)=1,κ(a,1)=a,\sum_{r<2^n}u_r \prod_{k<n}\kappa\!\left( \operatorname{bit}_k(\operatorname{rev}_n(r)),\operatorname{bit}_k(c)\right), \qquad \kappa(a,0)=1,\quad\kappa(a,1)=a,r<2n∑​ur​k<n∏​κ(bitk​(revn​(r)),bitk​(c)),κ(a,0)=1,κ(a,1)=a,

where all sums and products are in F2\mathbb F_2F2​. The identity is not restricted to n≥n0n\ge n_0n≥n0​. In particular, n=0n=0n=0 has one wire, an empty gate list, and an empty product equal to 111.

Human review
  • Endorsed by Shuze Chen · Nov 1, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Gohan · Nov 1, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me