Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Definitions for Programmable quantum gate arrays

Definition
QAlgorithms_Papers_Independent_Extend50_P43

by Gohan · Oct 29, 2026 · Mathlib 0df444a (Lean v4.33.1)

prove2quantum

The objects the formalized statements of Programmable quantum gate arrays (arXiv:quant-ph/9703032) are stated in. Each was checked against the paper by a blind read-back and a moderator.

  • ExactPhaseEquivalent: PDF p.2, Result: exact equality of operations modulo a global phase.
  • ImplementsProgramUnitary: PDF p.1, Eqs.(1)–(3): one normalized program implements U exactly on all normalized data states. The residual program is initially allowed to vary with the data; its independence is a conclusion below.
  • orderedBellKet: PDF p.2, Eqs.(12)–(13): ordered Bell kets on (A_i,B_i). Labels 0,1,2,3 mean Phi-plus, Phi-minus, Psi-plus, Psi-minus, respectively.
  • bellProduct: PDF pp.2–3: the product Bell basis on all ordered pairs (A_i,B_i).
  • successOutcome: PDF pp.2–3: the designated all-Phi-plus outcome. This flag is independent of the operation and the input state.
  • program: PDF p.2, Eq.(11): the supplied 2m-qubit program on B,C is the constructed vector (I_B tensor U_C) Phi_m, using the frozen normalized EPR state.
  • contractBellOutcome: PDF pp.2–3: the unnormalized C-register branch from measuring A,B in the product Bell basis. This is the Bell bra contraction, including its phase; it defines every outcome, including failures, without referring to U.
  • bellOutcomeProbability: PDF pp.2–3: Born probability of a Bell outcome, computed from the branch.
  • normalizedBellOutput: PDF p.3: normalized conditional C output. On a zero-probability branch this total function is zero; the success theorem proves strictly positive probability.
  • BellCircuit: PDF pp.2–3, Fig.2: an instruction i is a two-qubit Bell measurement on the ordered pair (A_i,B_i), recording its four-valued outcome. A circuit is its actual instruction list; the C wires are the designated output. Each such primitive has a fixed constant-size elementary realization.
  • fixedProcessor: PDF pp.2–3: the fixed processor measures each pair once, in wire order.
  • bellProjectorAt: PDF p.2, Fig.2: the branch projector for one instruction, acting on A_i,B_i and as identity on the remaining wires, including C. This keeps the measured Bell state, so the full execution has the usual projective-measurement semantics.
  • processorBranch: PDF pp.2–3: execute the instruction list on one recorded outcome path. The vector is subnormalized throughout; no free probability or cost field occurs.
  • regroupABC: PDF p.3, systems A,B,C: regroup the frozen tensor coordinates to trace out A,B.
  • processorOutputDensity: PDF p.3: the actual unnormalized output density on C of the listed processor. Its trace is the branch probability; the measured A,B registers are discarded.
  • ClassicalGate: PDF pp.1,3: an arbitrary classical Boolean gate with a finite ordered input list and one output bit. Its function is unrestricted; this includes any maximum-fan-in-k gate set rather than only AND/OR/NOT.
  • ClassicalArray: PDF pp.1,3: a classical programmable array with p program input bits, m data input bits, and m designated output wires. Gates are in topological order. Input wires are program first, then data; gate i creates wire p+m+i.
  • ClassicalWellFormed: PDF pp.1,3: every gate reads an already defined wire and every output wire exists. This excludes the default getD value from all circuit evaluations.
  • HasFanInAtMost: PDF p.3: maximum fan-in k bounds every actual gate occurrence.
  • classicalEval: PDF pp.1,3: evaluate the fixed gates on program P and data d. Malformed wiring has a total default, excluded by ClassicalWellFormed.
  • ClassicalUniversal: PDF pp.1,3: a classical universal array is one well-formed fixed circuit; only its program may depend on the selected function, and never on the data.
Definition code
import Mathlib
import Definitions.Def_QAlgorithms_Defs_Basic
import Definitions.Def_QAlgorithms_Defs_Channel

/-!
Statements from Nielsen and Chuang, *Programmable quantum gate arrays*,
arXiv:quant-ph/9703032v1, PDF pp.1–3. All new objects are local to this paper.
Program preparation is a supplied resource. For the probabilistic processor,
register C is the output, as explicitly permitted on p.3.
-/

namespace QAlgorithms.Papers.Independent.Extend50.P43

open scoped ComplexConjugate

noncomputable section

/-- PDF p.2, Result: exact equality of operations modulo a global phase. -/
def ExactPhaseEquivalent {m : ℕ}
    (U V : Matrix (Qubits m) (Qubits m) ℂ) : Prop :=
  ∃ z : ℂ, ‖z‖ = 1 ∧ U = z • V

/-- PDF p.1, Eqs.(1)–(3): one normalized program implements U exactly on
all normalized data states. The residual program is initially allowed to
vary with the data; its independence is a conclusion below. -/
def ImplementsProgramUnitary {m n : ℕ}
    (G : Matrix (Qubits m × Qubits n) (Qubits m × Qubits n) ℂ)
    (U : Matrix (Qubits m) (Qubits m) ℂ)
    (P : EuclideanSpace ℂ (Qubits n)) : Prop :=
  IsState P ∧ ∀ d : EuclideanSpace ℂ (Qubits m), IsState d →
    ∃ q : EuclideanSpace ℂ (Qubits n), IsState q ∧
      act G (tensorVec d P) = tensorVec (act U d) q

/-- Sanity: the phase relation identifies each matrix with itself. -/
example {m : ℕ} (U : Matrix (Qubits m) (Qubits m) ℂ) :
    ExactPhaseEquivalent U U := by
  exact ⟨1, by simp, by simp⟩

/-- Sanity: an identity array implements the identity with any normalized program. -/
example {m n : ℕ} (P : EuclideanSpace ℂ (Qubits n)) (hP : IsState P) :
    ImplementsProgramUnitary (1 : Matrix (Qubits m × Qubits n) (Qubits m × Qubits n) ℂ)
      (1 : Matrix (Qubits m) (Qubits m) ℂ) P := by
  refine ⟨hP, ?_⟩
  intro d hd
  exact ⟨P, hP, by simp [act]⟩

/-- PDF p.2, Eqs.(12)–(13): ordered Bell kets on (A_i,B_i).
Labels 0,1,2,3 mean Phi-plus, Phi-minus, Psi-plus, Psi-minus, respectively. -/
def orderedBellKet (r : Fin 4) : EuclideanSpace ℂ (Bool × Bool) :=
  WithLp.toLp 2 fun p =>
    let a : ℂ := ((Real.sqrt (2 : ℝ))⁻¹ : ℂ)
    match r.val with
    | 0 => if p.1 = p.2 then a else 0
    | 1 => if p.1 = p.2 then (if p.1 then -a else a) else 0
    | 2 => if p.1 ≠ p.2 then a else 0
    | _ => if p.1 ≠ p.2 then (if p.1 then -a else a) else 0

/-- PDF pp.2–3: the product Bell basis on all ordered pairs (A_i,B_i). -/
def bellProduct {m : ℕ} (o : Fin m → Fin 4) :
    EuclideanSpace ℂ (Qubits m × Qubits m) :=
  WithLp.toLp 2 fun p => ∏ i, orderedBellKet (o i) (p.1 i, p.2 i)

/-- PDF pp.2–3: the designated all-Phi-plus outcome. This flag is independent
of the operation and the input state. -/
def successOutcome (m : ℕ) : Fin m → Fin 4 := fun _ => 0

/-- PDF p.2, Eq.(11): the supplied 2m-qubit program on B,C is the constructed
vector (I_B tensor U_C) Phi_m, using the frozen normalized EPR state. -/
def program {m : ℕ} (U : Matrix (Qubits m) (Qubits m) ℂ) :
    EuclideanSpace ℂ (Qubits m × Qubits m) :=
  act (Matrix.kronecker (1 : Matrix (Qubits m) (Qubits m) ℂ) U) (maxEntangled m)

/-- PDF pp.2–3: the unnormalized C-register branch from measuring A,B in
the product Bell basis. This is the Bell bra contraction, including its phase;
it defines every outcome, including failures, without referring to U. -/
def contractBellOutcome {m : ℕ} (o : Fin m → Fin 4)
    (psi : EuclideanSpace ℂ (Qubits m × (Qubits m × Qubits m))) :
    EuclideanSpace ℂ (Qubits m) :=
  WithLp.toLp 2 fun c => ∑ a : Qubits m, ∑ b : Qubits m,
    conj (bellProduct o (a, b)) * psi (a, (b, c))

/-- PDF pp.2–3: Born probability of a Bell outcome, computed from the branch. -/
def bellOutcomeProbability {m : ℕ} (o : Fin m → Fin 4)
    (psi : EuclideanSpace ℂ (Qubits m × (Qubits m × Qubits m))) : ℝ :=
  ‖contractBellOutcome o psi‖ ^ 2

/-- PDF p.3: normalized conditional C output. On a zero-probability branch
this total function is zero; the success theorem proves strictly positive probability. -/
def normalizedBellOutput {m : ℕ} (o : Fin m → Fin 4)
    (psi : EuclideanSpace ℂ (Qubits m × (Qubits m × Qubits m))) :
    EuclideanSpace ℂ (Qubits m) :=
  ((Real.sqrt (bellOutcomeProbability o psi))⁻¹ : ℂ) • contractBellOutcome o psi

/-- Sanity: Phi-plus has the positive 00 amplitude; Psi-minus has negative 10 amplitude. -/
example : orderedBellKet 0 (false, false) = ((Real.sqrt (2 : ℝ))⁻¹ : ℂ) ∧
    orderedBellKet 3 (true, false) = -((Real.sqrt (2 : ℝ))⁻¹ : ℂ) := by
  simp [orderedBellKet]

/-- Sanity at the empty-register boundary: an empty Bell product has amplitude one. -/
example (o : Fin 0 → Fin 4) (a b : Qubits 0) : bellProduct o (a, b) = 1 := by
  simp [bellProduct]

/-- Sanity: a zero input has zero branch amplitude and probability. -/
example {m : ℕ} (o : Fin m → Fin 4) :
    contractBellOutcome o 0 = 0 ∧ bellOutcomeProbability o 0 = 0 := by
  have h : contractBellOutcome o 0 = 0 := by
    ext c
    simp [contractBellOutcome]
  exact ⟨h, by simp [bellOutcomeProbability, h]⟩

/-- PDF pp.2–3, Fig.2: an instruction i is a two-qubit Bell measurement
on the ordered pair (A_i,B_i), recording its four-valued outcome.
A circuit is its actual instruction list; the C wires are the designated output.
Each such primitive has a fixed constant-size elementary realization. -/
abbrev BellCircuit (m : ℕ) := List (Fin m)

/-- PDF pp.2–3: the fixed processor measures each pair once, in wire order. -/
def fixedProcessor (m : ℕ) : BellCircuit m := List.ofFn (fun i : Fin m => i)

/-- PDF p.2, Fig.2: the branch projector for one instruction, acting on A_i,B_i
and as identity on the remaining wires, including C. This keeps the measured
Bell state, so the full execution has the usual projective-measurement semantics. -/
def bellProjectorAt {m : ℕ} (i : Fin m) (r : Fin 4) :
    Matrix (Qubits m × (Qubits m × Qubits m))
      (Qubits m × (Qubits m × Qubits m)) ℂ :=
  open Classical in
  fun y z =>
    if y.2.2 = z.2.2 ∧
        (∀ j : Fin m, j ≠ i → y.1 j = z.1 j ∧ y.2.1 j = z.2.1 j) then
      orderedBellKet r (y.1 i, y.2.1 i) * conj (orderedBellKet r (z.1 i, z.2.1 i))
    else 0

/-- PDF pp.2–3: execute the instruction list on one recorded outcome path.
The vector is subnormalized throughout; no free probability or cost field occurs. -/
def processorBranch {m : ℕ} (circuit : BellCircuit m) (o : Fin m → Fin 4)
    (psi : EuclideanSpace ℂ (Qubits m × (Qubits m × Qubits m))) :
    EuclideanSpace ℂ (Qubits m × (Qubits m × Qubits m)) :=
  circuit.foldl (fun v i => act (bellProjectorAt i (o i)) v) psi

/-- PDF p.3, systems A,B,C: regroup the frozen tensor coordinates to trace out A,B. -/
def regroupABC {m : ℕ}
    (psi : EuclideanSpace ℂ (Qubits m × (Qubits m × Qubits m))) :
    EuclideanSpace ℂ ((Qubits m × Qubits m) × Qubits m) :=
  WithLp.toLp 2 fun p => psi (p.1.1, (p.1.2, p.2))

/-- PDF p.3: the actual unnormalized output density on C of the listed processor.
Its trace is the branch probability; the measured A,B registers are discarded. -/
def processorOutputDensity {m : ℕ} (circuit : BellCircuit m) (o : Fin m → Fin 4)
    (psi : EuclideanSpace ℂ (Qubits m × (Qubits m × Qubits m))) :
    Matrix (Qubits m) (Qubits m) ℂ :=
  traceLeft (pureDensity (regroupABC (processorBranch circuit o psi)))

/-- Sanity: no instructions leave the complete state unchanged. -/
example {m : ℕ} (o : Fin m → Fin 4)
    (psi : EuclideanSpace ℂ (Qubits m × (Qubits m × Qubits m))) :
    processorBranch [] o psi = psi := rfl

/-- Sanity: regrouping does not change any amplitude. -/
example {m : ℕ}
    (psi : EuclideanSpace ℂ (Qubits m × (Qubits m × Qubits m)))
    (a b c : Qubits m) : regroupABC psi ((a, b), c) = psi (a, (b, c)) := rfl

/-- Sanity at m=0: the fixed processor has an empty instruction list. -/
example : fixedProcessor 0 = [] := by simp [fixedProcessor]

/-- PDF pp.1,3: an arbitrary classical Boolean gate with a finite ordered
input list and one output bit. Its function is unrestricted; this includes
any maximum-fan-in-k gate set rather than only AND/OR/NOT. -/
structure ClassicalGate where
  arity : ℕ
  inputs : Fin arity → ℕ
  table : (Fin arity → Bool) → Bool

/-- PDF pp.1,3: a classical programmable array with p program input bits,
m data input bits, and m designated output wires. Gates are in topological
order. Input wires are program first, then data; gate i creates wire p+m+i. -/
structure ClassicalArray (m p : ℕ) where
  gates : List ClassicalGate
  outputs : Fin m → ℕ

/-- PDF pp.1,3: every gate reads an already defined wire and every output
wire exists. This excludes the default getD value from all circuit evaluations. -/
def ClassicalWellFormed {m p : ℕ} (circuit : ClassicalArray m p) : Prop :=
  (∀ i : Fin circuit.gates.length, ∀ j : Fin (circuit.gates.get i).arity,
    (circuit.gates.get i).inputs j < p + m + i.val) ∧
  ∀ j : Fin m, circuit.outputs j < p + m + circuit.gates.length

/-- PDF p.3: maximum fan-in k bounds every actual gate occurrence. -/
def HasFanInAtMost {m p : ℕ} (circuit : ClassicalArray m p) (k : ℕ) : Prop :=
  ∀ g ∈ circuit.gates, g.arity ≤ k

/-- PDF pp.1,3: evaluate the fixed gates on program P and data d.
Malformed wiring has a total default, excluded by ClassicalWellFormed. -/
def classicalEval {m p : ℕ} (circuit : ClassicalArray m p)
    (P : Qubits p) (d : Qubits m) : Qubits m :=
  let vals := circuit.gates.foldl
    (fun vals g => vals ++ [g.table (fun j => vals.getD (g.inputs j) false)])
    (List.ofFn (Fin.append P d))
  fun j => vals.getD (circuit.outputs j) false

/-- PDF pp.1,3: a classical universal array is one well-formed fixed circuit;
only its program may depend on the selected function, and never on the data. -/
def ClassicalUniversal {m p : ℕ} (circuit : ClassicalArray m p) : Prop :=
  ClassicalWellFormed circuit ∧
  ∀ f : Qubits m → Qubits m, ∃ P : Qubits p,
    ∀ d : Qubits m, classicalEval circuit P d = f d

/-- Sanity: a zero-gate array may output a program wire directly. Such
arrays are allowed in the model; universality, rather than an extra wiring
hypothesis, rules them out in the lower bound for nontrivial data. -/
example : classicalEval (⟨[], fun _ => 0⟩ : ClassicalArray 1 1)
    ![true] ![false] 0 = true := rfl

/-- Sanity: an arity-zero gate is a constant source, even with no available wires. -/
example : (ClassicalGate.mk 0 (fun i => Fin.elim0 i) (fun _ => true)).table
    (fun i => Fin.elim0 i) = true := rfl

end

end QAlgorithms.Papers.Independent.Extend50.P43
Source
Programmable quantum gate arrays, arXiv:quant-ph/9703032v1, https://arxiv.org/abs/quant-ph/9703032v1
Read-back

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

QAlgorithms.Papers.Independent.Extend50.P43.BellCircuit

For every natural number mmm, a Bell circuit on mmm positions is simply a finite list whose entries belong to {0,…,m−1}\{0,\ldots,m-1\}{0,…,m−1}. There are no restrictions on the list’s length, ordering, repeated entries, or omitted positions. When m=0m=0m=0, the only such list is the empty list.

QAlgorithms.Papers.Independent.Extend50.P43.ClassicalArray

For every pair of natural numbers m,pm,pm,p, a classical array consists of a finite list of classical gates and a function assigning a natural-number output index to each of the mmm output positions. Each gate has a natural-number arity aaa, an input-index function {0,…,a−1}→N\{0,\ldots,a-1\}\to\mathbb N{0,…,a−1}→N, and a truth table {0,1}a→{0,1}\{0,1\}^a\to\{0,1\}{0,1}a→{0,1}. The structure imposes no bounds on gate input indices or output indices and no restrictions on the gates; ppp imposes no additional condition here. The gate list may be empty, and mmm and ppp may be zero.

QAlgorithms.Papers.Independent.Extend50.P43.ClassicalGate

A classical gate consists of a natural number aaa, its arity; a function assigning to each position in {0,…,a−1}\{0,\ldots,a-1\}{0,…,a−1} a natural-number input index; and an arbitrary function {0,1}a→{0,1}\{0,1\}^a\to\{0,1\}{0,1}a→{0,1}, its truth table. The arity may be zero, in which case the truth table specifies a constant bit. Input indices may repeat and have no upper bound imposed by this structure.

QAlgorithms.Papers.Independent.Extend50.P43.ClassicalUniversal

For all natural numbers m,pm,pm,p and every classical array CCC with ppp program bits and mmm data and output bits, this property means that CCC is well formed and can represent every function from mmm-bit strings to mmm-bit strings by choosing its program bits. Explicitly, write its ordered gate list as g0,…,gL−1g_0,\ldots,g_{L-1}g0​,…,gL−1​, where each gate has a natural-number arity, that many natural-number input indices, and an arbitrary Boolean table. Well-formedness requires every input index of gate gig_igi​ to be strictly less than p+m+ip+m+ip+m+i, and every output index to be strictly less than p+m+Lp+m+Lp+m+L. The representation requirement is that for every function f:{false,true}m→{false,true}mf:\{\mathrm{false},\mathrm{true}\}^m\to\{\mathrm{false},\mathrm{true}\}^mf:{false,true}m→{false,true}m, there exists a program P∈{false,true}pP\in\{\mathrm{false},\mathrm{true}\}^pP∈{false,true}p such that for every data string d∈{false,true}md\in\{\mathrm{false},\mathrm{true}\}^md∈{false,true}m, evaluation of CCC on (P,d)(P,d)(P,d) equals f(d)f(d)f(d). Evaluation starts with the program bits followed by the data bits, processes the gates in order by appending each table’s value on its indexed inputs, and reads the designated output indices; any read outside the current list returns false\mathrm{false}false. The program may depend on fff but must work for every ddd, and need not be unique. Both m=0m=0m=0 and p=0p=0p=0 are included; for m=0m=0m=0, the output-index requirements are vacuous and the representation requirement concerns the unique function on the singleton set of empty bit strings.

QAlgorithms.Papers.Independent.Extend50.P43.ClassicalWellFormed

For all natural numbers m,pm,pm,p and every classical array consisting of a gate list [g0,…,gL−1][g_0,\ldots,g_{L-1}][g0​,…,gL−1​] and output indices qj∈Nq_j\in\mathbb Nqj​∈N for j∈{0,…,m−1}j\in\{0,\ldots,m-1\}j∈{0,…,m−1}, this predicate means that every input index of gate gig_igi​ is strictly less than p+m+ip+m+ip+m+i, and every output index qjq_jqj​ is strictly less than p+m+Lp+m+Lp+m+L. Here each gate gig_igi​ has a natural-number arity aia_iai​, an input-index function on {0,…,ai−1}\{0,\ldots,a_i-1\}{0,…,ai​−1}, and an arbitrary Boolean truth table of that arity. Equivalently, each gate input refers to one of the p+mp+mp+m initial positions or to a preceding gate’s position, and each output refers to an initial or gate position. A gate of arity zero has no input inequalities to satisfy, an empty gate list has no gate inequalities to satisfy, and m=0m=0m=0 makes the output condition vacuous.

QAlgorithms.Papers.Independent.Extend50.P43.ExactPhaseEquivalent

For any natural number mmm, including 000, and any two complex matrices U,VU,VU,V indexed by the mmm-bit strings {0,1}m\{0,1\}^m{0,1}m, exact phase equivalence means that there exists a complex number zzz with ∣z∣=1|z|=1∣z∣=1 such that U=zVU=zVU=zV, with scalar multiplication applied to every matrix entry. Neither matrix is required to be unitary. Zero matrices are permitted; if either matrix is zero, the condition holds exactly when both are zero. When m=0m=0m=0, these are 1×11\times11×1 matrices.

QAlgorithms.Papers.Independent.Extend50.P43.HasFanInAtMost

For all natural numbers m,p,km,p,km,p,k and every classical array consisting of a finite gate list and mmm natural-number output indices, this predicate means that every gate in the list has arity at most kkk. Each gate consists of its natural-number arity aaa, an input-index function {0,…,a−1}→N\{0,\ldots,a-1\}\to\mathbb N{0,…,a−1}→N, and a Boolean truth table on aaa bits. The predicate imposes no conditions on those indices, truth tables, or output indices. It holds vacuously for an empty gate list; when k=0k=0k=0, every listed gate must have arity zero.

QAlgorithms.Papers.Independent.Extend50.P43.ImplementsProgramUnitary

For any natural numbers m,nm,nm,n, any complex matrix GGG indexed by pairs of an mmm-bit string and an nnn-bit string, any complex matrix UUU indexed by mmm-bit strings, and any vector P∈C{0,1}nP\in\mathbb C^{\{0,1\}^n}P∈C{0,1}n, this condition means that ∥P∥2=1\|P\|_2=1∥P∥2​=1 and that, for every d∈C{0,1}md\in\mathbb C^{\{0,1\}^m}d∈C{0,1}m with ∥d∥2=1\|d\|_2=1∥d∥2​=1, there exists q∈C{0,1}nq\in\mathbb C^{\{0,1\}^n}q∈C{0,1}n with ∥q∥2=1\|q\|_2=1∥q∥2​=1 satisfying

G(d⊗P)=(Ud)⊗q.G(d\otimes P)=(Ud)\otimes q.G(d⊗P)=(Ud)⊗q.

Here matrix action is ordinary matrix-vector multiplication, and (v⊗w)(a,b)=v(a)w(b)(v\otimes w)(a,b)=v(a)w(b)(v⊗w)(a,b)=v(a)w(b). The vector qqq may depend on ddd. No unitarity assumption on GGG or UUU is included in this definition. Both m=0m=0m=0 and n=0n=0n=0 are allowed, with the corresponding vector space one-dimensional.

QAlgorithms.Papers.Independent.Extend50.P43.bellOutcomeProbability

For every natural number mmm, every assignment o:{0,…,m−1}→{0,1,2,3}o:\{0,\ldots,m-1\}\to\{0,1,2,3\}o:{0,…,m−1}→{0,1,2,3}, and every vector ψ∈C{0,1}m×({0,1}m×{0,1}m)\psi\in\mathbb C^{\{0,1\}^m\times(\{0,1\}^m\times\{0,1\}^m)}ψ∈C{0,1}m×({0,1}m×{0,1}m), write o(i)=2ui+vio(i)=2u_i+v_io(i)=2ui​+vi​ with ui,vi∈{0,1}u_i,v_i\in\{0,1\}ui​,vi​∈{0,1}, and let ⊕\oplus⊕ denote coordinatewise addition modulo 222. This defines the real number

∑c∈{0,1}m∣12m∑a∈{0,1}m(−1)∑i=0m−1viaiψ(a,(a⊕u,c))∣2,\sum_{c\in\{0,1\}^m} \left| \frac{1}{\sqrt{2^m}} \sum_{a\in\{0,1\}^m} (-1)^{\sum_{i=0}^{m-1}v_i a_i} \psi\bigl(a,(a\oplus u,c)\bigr) \right|^2,c∈{0,1}m∑​​2m​1​a∈{0,1}m∑​(−1)∑i=0m−1​vi​ai​ψ(a,(a⊕u,c))​2,

the squared Euclidean norm of the vector obtained by contracting the first two registers against the selected Bell amplitudes. No normalization assumption on ψ\psiψ is included, so the definition does not require this number to be at most 111. When m=0m=0m=0, it is the squared absolute value of the sole coordinate of ψ\psiψ.

QAlgorithms.Papers.Independent.Extend50.P43.bellProduct

For every natural number mmm and every assignment o:{0,…,m−1}→{0,1,2,3}o:\{0,\ldots,m-1\}\to\{0,1,2,3\}o:{0,…,m−1}→{0,1,2,3}, write o(i)=2ui+vio(i)=2u_i+v_io(i)=2ui​+vi​ with ui,vi∈{0,1}u_i,v_i\in\{0,1\}ui​,vi​∈{0,1}. This defines the vector Bo∈C{0,1}m×{0,1}mB_o\in\mathbb C^{\{0,1\}^m\times\{0,1\}^m}Bo​∈C{0,1}m×{0,1}m whose coordinate at a pair of bit strings (a,b)(a,b)(a,b) is

Bo(a,b)={(−1)∑i=0m−1viai2m,bi=ai⊕ui for every i,0,otherwise,B_o(a,b)= \begin{cases} \dfrac{(-1)^{\sum_{i=0}^{m-1}v_i a_i}}{\sqrt{2^m}}, & b_i=a_i\oplus u_i\text{ for every }i,\\ 0,&\text{otherwise}, \end{cases}Bo​(a,b)=⎩⎨⎧​2m​(−1)∑i=0m−1​vi​ai​​,0,​bi​=ai​⊕ui​ for every i,otherwise,​

where ⊕\oplus⊕ is addition modulo 222. Thus the coordinate is the product of the individual two-bit amplitudes selected by ooo. When m=0m=0m=0, there is one pair of empty strings, and its amplitude is the empty product 111.

QAlgorithms.Papers.Independent.Extend50.P43.bellProjectorAt

For every natural number mmm, every position i∈{0,…,m−1}i\in\{0,\ldots,m-1\}i∈{0,…,m−1}, and every r∈{0,1,2,3}r\in\{0,1,2,3\}r∈{0,1,2,3}, this defines a complex matrix indexed by triples of mmm-bit strings, parenthesized as Bm×(Bm×Bm)B_m\times(B_m\times B_m)Bm​×(Bm​×Bm​), where Bm={0,1}mB_m=\{0,1\}^mBm​={0,1}m. Identifying bits with 000 and 111, set

βr(a,b)=12(−1)(r mod 2)a1{a⊕b=⌊r/2⌋},\beta_r(a,b)=\frac{1}{\sqrt2}(-1)^{(r\bmod2)a}\mathbf1_{\{a\oplus b=\lfloor r/2\rfloor\}},βr​(a,b)=2​1​(−1)(rmod2)a1{a⊕b=⌊r/2⌋}​,

where ⊕\oplus⊕ is addition modulo 222. For row y=(a,(b,c))y=(a,(b,c))y=(a,(b,c)) and column z=(a′,(b′,c′))z=(a',(b',c'))z=(a′,(b′,c′)), the matrix entry is

{βr(ai,bi) βr(ai′,bi′)‾,c=c′ and, for every j≠i, aj=aj′ and bj=bj′,0,otherwise.\begin{cases} \beta_r(a_i,b_i)\,\overline{\beta_r(a'_i,b'_i)}, & c=c'\ \text{and, for every }j\ne i,\ a_j=a'_j\ \text{and }b_j=b'_j,\\ 0,&\text{otherwise}. \end{cases}{βr​(ai​,bi​)βr​(ai′​,bi′​)​,0,​c=c′ and, for every j=i, aj​=aj′​ and bj​=bj′​,otherwise.​

Here 1\mathbf11 denotes an indicator and the bar denotes complex conjugation. When m=0m=0m=0, there is no position iii to supply.

QAlgorithms.Papers.Independent.Extend50.P43.classicalEval

For all natural numbers m,pm,pm,p, a classical array CCC consists of a finite ordered list of gates and mmm natural-number output indices; each gate ggg has a natural-number arity aga_gag​, input indices sg:{0,…,ag−1}→Ns_g:\{0,\ldots,a_g-1\}\to\mathbb Nsg​:{0,…,ag​−1}→N, and a Boolean table Tg:{false,true}ag→{false,true}T_g:\{\mathrm{false},\mathrm{true}\}^{a_g}\to\{\mathrm{false},\mathrm{true}\}Tg​:{false,true}ag​→{false,true}. Given a program bit string PPP of length ppp and a data bit string ddd of length mmm, the function returns a bit string of length mmm as follows: start with the list of the bits of PPP, followed by the bits of ddd; then process the gates in list order, appending for each gate ggg the bit Tg((vsg(j))j<ag)T_g((v_{s_g(j)})_{j<a_g})Tg​((vsg​(j)​)j<ag​​), where vvv is the current list and any read outside that list returns false\mathrm{false}false. Output bit jjj is the entry at CCC’s jjjth output index in the final list, again returning false\mathrm{false}false if that index is outside the list. All list indices start at zero. No well-formedness condition is imposed here. Zero-arity gates are allowed, and m=0m=0m=0 or p=0p=0p=0 is included; when m=0m=0m=0, the returned bit string is empty.

QAlgorithms.Papers.Independent.Extend50.P43.contractBellOutcome

For every natural number mmm, every assignment o:{0,…,m−1}→{0,1,2,3}o:\{0,\ldots,m-1\}\to\{0,1,2,3\}o:{0,…,m−1}→{0,1,2,3}, and every vector ψ∈C{0,1}m×({0,1}m×{0,1}m)\psi\in\mathbb C^{\{0,1\}^m\times(\{0,1\}^m\times\{0,1\}^m)}ψ∈C{0,1}m×({0,1}m×{0,1}m), write o(i)=2ui+vio(i)=2u_i+v_io(i)=2ui​+vi​ with ui,vi∈{0,1}u_i,v_i\in\{0,1\}ui​,vi​∈{0,1}. This defines a vector Co,ψ∈C{0,1}mC_{o,\psi}\in\mathbb C^{\{0,1\}^m}Co,ψ​∈C{0,1}m by

Co,ψ(c)=12m∑a∈{0,1}m(−1)∑i=0m−1viai ψ(a,(a⊕u,c)),C_{o,\psi}(c)= \frac{1}{\sqrt{2^m}} \sum_{a\in\{0,1\}^m} (-1)^{\sum_{i=0}^{m-1}v_i a_i}\, \psi\bigl(a,(a\oplus u,c)\bigr),Co,ψ​(c)=2m​1​a∈{0,1}m∑​(−1)∑i=0m−1​vi​ai​ψ(a,(a⊕u,c)),

where (a⊕u)i(a\oplus u)_i(a⊕u)i​ is addition modulo 222. This is the sum over the first two registers against the complex conjugate of their product of selected Bell amplitudes. No normalization assumption on ψ\psiψ is imposed. When m=0m=0m=0, the sole output coordinate is the sole coordinate of ψ\psiψ.

QAlgorithms.Papers.Independent.Extend50.P43.fixedProcessor

For every natural number mmm, the fixed processor is the list

[0,1,…,m−1][0,1,\ldots,m-1][0,1,…,m−1]

of all mmm positions in increasing order, each appearing once. For m=0m=0m=0, this is the empty list.

QAlgorithms.Papers.Independent.Extend50.P43.normalizedBellOutput

For every natural number mmm, every assignment o:{0,…,m−1}→{0,1,2,3}o:\{0,\ldots,m-1\}\to\{0,1,2,3\}o:{0,…,m−1}→{0,1,2,3}, and every vector ψ∈C{0,1}m×({0,1}m×{0,1}m)\psi\in\mathbb C^{\{0,1\}^m\times(\{0,1\}^m\times\{0,1\}^m)}ψ∈C{0,1}m×({0,1}m×{0,1}m), write o(i)=2ui+vio(i)=2u_i+v_io(i)=2ui​+vi​ with ui,vi∈{0,1}u_i,v_i\in\{0,1\}ui​,vi​∈{0,1}, let ⊕\oplus⊕ denote coordinatewise addition modulo 222, and define

C(c)=12m∑a∈{0,1}m(−1)∑i=0m−1viaiψ(a,(a⊕u,c)),p=∑c∈{0,1}m∣C(c)∣2.C(c)=\frac{1}{\sqrt{2^m}} \sum_{a\in\{0,1\}^m} (-1)^{\sum_{i=0}^{m-1}v_i a_i} \psi\bigl(a,(a\oplus u,c)\bigr), \qquad p=\sum_{c\in\{0,1\}^m}|C(c)|^2.C(c)=2m​1​a∈{0,1}m∑​(−1)∑i=0m−1​vi​ai​ψ(a,(a⊕u,c)),p=c∈{0,1}m∑​∣C(c)∣2.

The defined output vector has coordinate p−1/2C(c)p^{-1/2}C(c)p−1/2C(c), where the scalar is specifically the reciprocal of the real square root of ppp, embedded in C\mathbb CC. No normalization assumption on ψ\psiψ or positivity assumption on ppp is imposed. If p=0p=0p=0, the reciprocal is defined to be 000, and the output is the zero vector; if p>0p>0p>0, the output has Euclidean norm 111. When m=0m=0m=0, the same rule applies to the single coordinate of ψ\psiψ.

QAlgorithms.Papers.Independent.Extend50.P43.orderedBellKet

For every index r∈{0,1,2,3}r\in\{0,1,2,3\}r∈{0,1,2,3}, this defines a vector in C{0,1}×{0,1}\mathbb C^{\{0,1\}\times\{0,1\}}C{0,1}×{0,1}, identifying false with 000 and true with 111, by

B0=∣00⟩+∣11⟩2,B1=∣00⟩−∣11⟩2,B2=∣01⟩+∣10⟩2,B3=∣01⟩−∣10⟩2,B_0=\frac{|00\rangle+|11\rangle}{\sqrt2},\qquad B_1=\frac{|00\rangle-|11\rangle}{\sqrt2},\qquad B_2=\frac{|01\rangle+|10\rangle}{\sqrt2},\qquad B_3=\frac{|01\rangle-|10\rangle}{\sqrt2},B0​=2​∣00⟩+∣11⟩​,B1​=2​∣00⟩−∣11⟩​,B2​=2​∣01⟩+∣10⟩​,B3​=2​∣01⟩−∣10⟩​,

where ∣ab⟩|ab\rangle∣ab⟩ is the coordinate vector equal to 111 at (a,b)(a,b)(a,b) and 000 elsewhere. The final branch of the definition applies only to r=3r=3r=3, since the index is restricted to these four values.

QAlgorithms.Papers.Independent.Extend50.P43.processorBranch

For every natural number mmm, every finite list of positions [i1,…,iL][i_1,\ldots,i_L][i1​,…,iL​] with iℓ∈{0,…,m−1}i_\ell\in\{0,\ldots,m-1\}iℓ​∈{0,…,m−1}, every assignment o:{0,…,m−1}→{0,1,2,3}o:\{0,\ldots,m-1\}\to\{0,1,2,3\}o:{0,…,m−1}→{0,1,2,3}, and every complex vector ψ\psiψ indexed by Bm×(Bm×Bm)B_m\times(B_m\times B_m)Bm​×(Bm​×Bm​), where Bm={0,1}mB_m=\{0,1\}^mBm​={0,1}m, this defines a vector by the following successive matrix actions. For bits a,ba,ba,b, let

βr(a,b)=12(−1)(r mod 2)a1{a⊕b=⌊r/2⌋},\beta_r(a,b)=\frac{1}{\sqrt2}(-1)^{(r\bmod2)a}\mathbf1_{\{a\oplus b=\lfloor r/2\rfloor\}},βr​(a,b)=2​1​(−1)(rmod2)a1{a⊕b=⌊r/2⌋}​,

with ⊕\oplus⊕ denoting addition modulo 222 and 1\mathbf11 an indicator. Start with v0=ψv_0=\psiv0​=ψ, and, for ℓ=1,…,L\ell=1,\ldots,Lℓ=1,…,L, set

vℓ(a,(b,c))=βo(iℓ)(aiℓ,biℓ)∑s,t∈{0,1}βo(iℓ)(s,t)‾ vℓ−1(a[iℓ←s],(b[iℓ←t],c)).v_\ell(a,(b,c)) =\beta_{o(i_\ell)}(a_{i_\ell},b_{i_\ell}) \sum_{s,t\in\{0,1\}} \overline{\beta_{o(i_\ell)}(s,t)}\, v_{\ell-1}\bigl(a[i_\ell\leftarrow s],(b[i_\ell\leftarrow t],c)\bigr).vℓ​(a,(b,c))=βo(iℓ​)​(aiℓ​​,biℓ​​)s,t∈{0,1}∑​βo(iℓ​)​(s,t)​vℓ−1​(a[iℓ​←s],(b[iℓ​←t],c)).

Here a[i←s]a[i\leftarrow s]a[i←s] means replacement of bit iii by sss. The defined output is vLv_LvL​. The input vector need not be normalized, the list may repeat positions, and an empty list returns ψ\psiψ; in particular, for m=0m=0m=0 the list is necessarily empty.

QAlgorithms.Papers.Independent.Extend50.P43.processorOutputDensity

For every natural number mmm, every finite list of positions [i1,…,iL][i_1,\ldots,i_L][i1​,…,iL​] in {0,…,m−1}\{0,\ldots,m-1\}{0,…,m−1}, every assignment o:{0,…,m−1}→{0,1,2,3}o:\{0,\ldots,m-1\}\to\{0,1,2,3\}o:{0,…,m−1}→{0,1,2,3}, and every complex vector ψ\psiψ indexed by Bm×(Bm×Bm)B_m\times(B_m\times B_m)Bm​×(Bm​×Bm​), where Bm={0,1}mB_m=\{0,1\}^mBm​={0,1}m, this defines a complex matrix ρ\rhoρ indexed by Bm×BmB_m\times B_mBm​×Bm​ as follows. For bits a,ba,ba,b, write

βr(a,b)=12(−1)(r mod 2)a1{a⊕b=⌊r/2⌋},\beta_r(a,b)=\frac{1}{\sqrt2}(-1)^{(r\bmod2)a}\mathbf1_{\{a\oplus b=\lfloor r/2\rfloor\}},βr​(a,b)=2​1​(−1)(rmod2)a1{a⊕b=⌊r/2⌋}​,

where ⊕\oplus⊕ is addition modulo 222 and 1\mathbf11 an indicator. Starting with v0=ψv_0=\psiv0​=ψ, successively define

vℓ(a,(b,c))=βo(iℓ)(aiℓ,biℓ)∑s,t∈{0,1}βo(iℓ)(s,t)‾ vℓ−1(a[iℓ←s],(b[iℓ←t],c)),v_\ell(a,(b,c)) =\beta_{o(i_\ell)}(a_{i_\ell},b_{i_\ell}) \sum_{s,t\in\{0,1\}}\overline{\beta_{o(i_\ell)}(s,t)}\, v_{\ell-1}\bigl(a[i_\ell\leftarrow s],(b[i_\ell\leftarrow t],c)\bigr),vℓ​(a,(b,c))=βo(iℓ​)​(aiℓ​​,biℓ​​)s,t∈{0,1}∑​βo(iℓ​)​(s,t)​vℓ−1​(a[iℓ​←s],(b[iℓ​←t],c)),

where brackets denote replacement of a bit. The output matrix has entries

ρc,c′=∑a,b∈BmvL(a,(b,c)) vL(a,(b,c′))‾.\rho_{c,c'}=\sum_{a,b\in B_m}v_L(a,(b,c))\,\overline{v_L(a,(b,c'))}.ρc,c′​=a,b∈Bm​∑​vL​(a,(b,c))vL​(a,(b,c′))​.

There is no normalization of ψ\psiψ or of the resulting matrix. Empty lists return this formula with vL=ψv_L=\psivL​=ψ, and m=0m=0m=0 is included.

QAlgorithms.Papers.Independent.Extend50.P43.program

For every natural number mmm and every complex matrix UUU indexed by mmm-bit strings, this defines the vector obtained by applying I⊗UI\otimes UI⊗U to the vector whose coordinate at (a,c)(a,c)(a,c) is 1/2m1/\sqrt{2^m}1/2m​ when a=ca=ca=c and 000 otherwise. Explicitly, the resulting vector in C{0,1}m×{0,1}m\mathbb C^{\{0,1\}^m\times\{0,1\}^m}C{0,1}m×{0,1}m has coordinates

PU(a,b)=Ub,a2m.P_U(a,b)=\frac{U_{b,a}}{\sqrt{2^m}}.PU​(a,b)=2m​Ub,a​​.

There is no assumption that UUU is unitary or that this vector has norm 111. When m=0m=0m=0, its sole coordinate is the sole entry of UUU.

QAlgorithms.Papers.Independent.Extend50.P43.regroupABC

For every natural number mmm and every complex Euclidean vector ψ\psiψ indexed by Bm×(Bm×Bm)B_m\times(B_m\times B_m)Bm​×(Bm​×Bm​), where Bm={0,1}mB_m=\{0,1\}^mBm​={0,1}m, this defines the vector indexed by (Bm×Bm)×Bm(B_m\times B_m)\times B_m(Bm​×Bm​)×Bm​ whose coordinate at ((a,b),c)((a,b),c)((a,b),c) is

ψ(a,(b,c)).\psi(a,(b,c)).ψ(a,(b,c)).

Thus the coordinate values are preserved while the three registers are parenthesized differently. No normalization hypothesis is imposed, and the definition includes m=0m=0m=0, when BmB_mBm​ consists of the single empty bit string.

QAlgorithms.Papers.Independent.Extend50.P43.successOutcome

For every natural number mmm, this defines the function from the mmm positions {0,…,m−1}\{0,\ldots,m-1\}{0,…,m−1} to {0,1,2,3}\{0,1,2,3\}{0,1,2,3} that assigns the value 000 to every position. When m=0m=0m=0, it is the unique function with empty domain.

Human review
  • Endorsed by Shuze Chen · Oct 29, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Gohan · Oct 29, 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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me