Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 4.8 — exact Hamming-weight counter

Open
QuantumLTF.Majority.theorem_4_8

by stockfish-soup · Nov 15, 2026 · Mathlib 0df444a (Lean v4.33.1)

hamming-weightquantum-circuitssection-4

An exact reversible Hamming-weight counter maps ∣T⟩∣0ℓ⟩|T\rangle|0^\ell\rangle∣T⟩∣0ℓ⟩ to ∣T⟩∣∣T∣⟩|T\rangle||T|\rangle∣T⟩∣∣T∣⟩, where ℓ=⌈log⁡2(n+1)⌉\ell=\lceil\log_2(n+1)\rceilℓ=⌈log2​(n+1)⌉. It uses O(nlog⁡n)O(n\log n)O(nlogn) one- and two-qubit gates and has parallel depth O(log⁡n)O(\log n)O(logn).

Preamble
import Mathlib
import Definitions.Def_QAlgorithms_Defs_Basic
import Definitions.Def_QAlgorithms_Defs_Circuit
import Definitions.Def_QuantumLTF_Membership_gates12
import Definitions.Def_QuantumLTF_Sections45_Model
Formal statement
namespace QuantumLTF.Majority

open QAlgorithms QuantumLTF.Membership

theorem theorem_4_8 :
    ∃ C : ℝ, 0 < C ∧ ∀ n : ℕ, 1 ≤ n →
      let ℓ := Nat.clog 2 (n + 1)
      ∃ (c : Circuit gates12 (n + ℓ)) (d : ℕ),
        (c.size : ℝ) ≤ C * n * Real.log (n + 1) ∧
        (d : ℝ) ≤ C * Real.log (n + 1) ∧ HasDepth c d ∧
        ∀ T : Qubits n, ∃ v : Qubits ℓ, bitsToNat v = (Finset.univ.filter fun i => T i).card ∧
          act c.unitary (ket (Fin.append T fun _ => false)) = ket (Fin.append T v) := by sorry

end QuantumLTF.Majority
Source
Krivcenko, Nguyen, de Wolf, Fast Quantum Algorithms for Learning Linear Threshold Functions, STOC 2027 submission #347, Theorem 4.8, p. 52 (PDF p. 53), citing ZYN26 Theorem 1.

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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me