Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Definitions for An introduction to measurement based quantum computation

Definition
QAlgorithms_Papers_Independent_Intakenext100_P52

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

prove2quantum

The objects the formalized statements of An introduction to measurement based quantum computation (arXiv:quant-ph/0508124) are stated in. Each was checked against the paper by a blind read-back and a moderator.

  • QubitPair
  • rotatedEntangledKet: PDF p.3: (U† ⊗ I)|phi>, with the first factor the input-side register.
  • teleportContraction: PDF p.3: sum over registers 1 and 2, leaving register 3 in that order.
  • sourceBellBasis: PDF p.2: source Bell labels c,d, with B11=(01-10)/sqrt(2).
  • rotatedBell: PDF p.2: rotate only the first qubit of the measured Bell ket.
  • pauliByproduct: PDF pp.2,5: tensor Pauli representatives with the source output order X^x Z^z.
  • hBond: PDF p.2: the H-bond is a state, distinct from the Hadamard operator.
  • phaseGate: PDF p.5, equation (2): positive-exponent phase gate.
  • wGate: PDF p.5, equation (2): W(theta)=H P(theta).
  • rx: PDF p.5: exp(-i theta X), explicitly cos(theta) I - i sin(theta) X. There is no half-angle in this paper's rotation convention.
  • rz: PDF p.5: exp(-i theta Z), explicitly diagonal.
  • equatorial: PDF pp.8–10: normalized equatorial basis, plus=0 and minus=1.
  • angleSign: PDF pp.5,9,13: (-1)^s as a real angle sign.
  • bellPauliRepresentative: PDF p.4: real Pauli representatives in the order I,X,Z,XZ.
  • czTeleportGate: PDF p.4: the sixteen dimension-four teleportation gates.
  • BellFrame: PDF p.4: the actual rank-one Bell frame identity, with positive weights separate.
  • weightedTeleport: PDF p.4: the rank-one POVM branch bra includes sqrt(k_i).
  • czPhase: PDF p.8: one CZ phase for two computational bits.
  • edgePhase: PDF pp.8,11–12: ordered edges are used once each, with no implicit wire permutations.
  • graphClusterState: PDF p.8: normalized graph cluster, obtained by CZ edges on |+> at every site.
  • RectangularSites
  • gridEdges: PDF p.8 Fig.4: rectangular nearest-neighbour edges, oriented down and right.
  • lineBranch: PDF pp.9–10: all k+1 line sites are entangled first; the first k are then contracted against their normalized measurement bras. Angles may be evaluated from the preceding outcome bits, as explicitly done in Figures 5 and 10. At k=0 there are no ancillas, edges or measurements: the surviving vector is psi.
  • figure5Angles: PDF p.9 Fig.5, corrected for Rx/Rz=exp(-i theta Pauli): double the three printed nonzero measurement angles; keep their causal dependence unchanged.
  • insertSite: PDF pp.11–12: explicit insertion/renaming of the measured site.
  • deletedEdges: PDF pp.11–12: induced edge set on the surviving site subtype.
  • neighbourPhase: PDF p.12: tensor product of Z^s on neighbours of the deleted site.
  • PrepGate: PDF p.8: physical preparation gates, each with its support explicit.
  • PrepGate.support: PDF p.8: the sites occupied by a preparation gate.
  • PrepGate.matrix: PDF p.8: coordinate matrices of one-site H and two-site CZ.
  • LegalPrepLayer: PDF p.8: a physical layer has pairwise disjoint gate supports.
  • prepMatrix: PDF p.8: flattening layers gives the actual gate word (first gate applied first).
  • GridPrepGate: PDF p.8: H at any site, and CZ only on the rectangular nearest-neighbour edges.
  • ghzSeed: PDF p.4 Fig.3: representative strings for the four complementary GHZ pairs.
  • threeQubitBellKet: PDF p.4 Fig.3: normalized plus/minus three-qubit Bell kets.
  • figure3Resource: PDF p.4 Fig.3, actual eight-wire resource: input12 and H-bonds34,57,68.
  • figure3Branch: PDF p.4 Fig.3: destructive measurements on 135 and 246, outputs 78.
  • figure8Output: PDF p.11 Fig.8: unmeasured output sites, top then bottom.
  • Figure8Measured
  • figure8Resource: PDF p.11 Fig.8: arbitrary two-qubit input at upper/lower left, ten |+> ancillas, then all rectangular grid CZs, in the displayed wire order.
  • figure8Basis: PDF p.11 Fig.8: all first-column sites and top/bottom middle sites use X; the other four measured sites use Z. The two rightmost corner sites survive.
  • figure8Branch: PDF p.11 Fig.8: full physical bra contraction, with no assumption of independent or uniformly distributed X/Z outcomes.
  • pairBra: PDF pp.15–16: destructive contraction on a pair, retaining an arbitrary reference.
  • localBellAnalysis: PDF pp.15–16: Bell analysis by CX followed by local X on wire1, Z on wire2.
  • cxWires: PDF p.16 Fig.12: CX with explicitly named control and target.
  • figure12Input: PDF p.16 Fig.12: input psi1, |0>2, |+>3, before either entangling gate.
  • figure12Branch: PDF p.16 Fig.12: prepare pair23 by CX3->2, analyze by CX1->2, then destructively measure X1 and Z2, leaving qubit3.
  • hBell: PDF p.16 equation (3): labels (c,d) order I,X,Z,XZ.
  • fuse: PDF pp.17–18: the local projection with renaming, |00>->|0>, |11>->|1>. This is a rectangular coisometry, not merely the ambient even-space projector.
  • fusionResource: PDF p.18 Fig.14: left site=(left bond half,psi1), right=(right bond half,psi2).
  • EdgeLabel
  • bondGrid: PDF p.17 Fig.13: one independent normalized H-bond per edge. Virtual wire (e,false) is at e's first endpoint, (e,true) at its second.
  • valenceProjection: PDF p.17: tensor product of the explicitly displayed local maps Pi, with all incident virtual wires set to the physical site's bit.
  • cutDownKet: PDF pp.17–18: all four rotated H-bond measurement kets, constructed from W.
  • cutDownFormula: PDF p.18: explicit even/odd representatives for all four outcomes.
  • ladderWires: PDF pp.14–15 Fig.11: adjacent wire placement for a ladder gate.
  • ladderState: PDF p.14: actual (m+1)-qubit ladder state, each Ui,i+1 applied once in order.
  • ladderEvent: PDF p.14: full joint event effect, identity at unmeasured sites and the chosen normalized rank-one projector at every measured site.
  • reduceFirst: PDF p.15: retain the second site, tracing the first or applying its chosen bra.
  • ladderSigma: PDF p.15: two-site intermediate sigma=U(rho tensor |0><0|)U†.
  • ladderScan: PDF p.15: the increasing-site contraction stores only one-site and two-site matrices.
  • ladderScanProbability: PDF p.15: trace the last subnormalized site, or contract its selected bra.
  • ScalarInstruction: PDF pp.14–15: exact scalar arithmetic syntax, with shared previous registers. Complex conjugation is constant work on real/imaginary coordinates.
  • ScalarInstruction.readsBefore: PDF pp.14–15: no uninitialized-register defaults are allowed in a valid word.
  • ScalarInstruction.eval: PDF pp.14–15: one arithmetic instruction, with input reads charged as instructions.
  • ScalarProgram: PDF pp.14–15: a straight-line program has one new scalar register per operation.
  • ScalarProgram.Valid: PDF pp.14–15: all referenced registers exist before the operation using them.
  • ScalarProgram.eval: PDF pp.14–15: evaluation counts actual word operations rather than an unattached cost.
  • LadderScalarInput
  • ladderScalarData: PDF pp.14–15: input entries of the ladder gates and selected measurement bras.
  • outcomeHistoryPrefix: PDF p.19: a history available before stage t contains only t earlier bits.
  • AdaptiveProcess: PDF p.19: finite adaptive unitary/projective process on n data qubits. The basis columns are the measured vectors. All controls are functions of the recorded past, fixed before the unknown input. No cost is attached to them here.
  • siteProjector: PDF p.19: rank-one site projector in the basis supplied as columns of B.
  • processBranchOperator: PDF p.19: branch operator built by actual chronological gate/projector products.
  • pointerWave: PDF p.19: the coherent pointer wave, with data first and k fresh pointer bits second.
Definition code
import Definitions.Def_QAlgorithms_Defs_FiniteRegisters
import Definitions.Def_QAlgorithms_Defs_Circuit
import Definitions.Def_QAlgorithms_Defs_Information
import Definitions.Def_QAlgorithms_Papers_Independent_Information100_P21
import Definitions.Def_QAlgorithms_Papers_Independent_Gap20_P01

/-!
Statements from Jozsa, arXiv:quant-ph/0508124v2. Local definitions have executable
finite-coordinate bodies. A bra destroys its measured registers. Branch vectors
are never silently normalized. Density equalities identify global phases.
The normalization/angle/label corrections are recorded in MODERATION_NOTES.md.
Compilation is deliberately left to the batch handoff.
-/

noncomputable section

open scoped Matrix ComplexConjugate

namespace QAlgorithms.Papers.Independent.Intakenext100.P52

open QAlgorithms.Papers.Independent.Information100.P21 (Vec)

open QAlgorithms.Papers.Independent.Gap20.P01 (applyRect)

abbrev QubitPair := Bool × Bool

/-- PDF p.3: (U† ⊗ I)|phi>, with the first factor the input-side register. -/
def rotatedEntangledKet {I : Type*} [Fintype I] [Nonempty I] [DecidableEq I]
    (U : Matrix I I ℂ) : Vec (I × I) :=
  act (Matrix.kronecker Uᴴ 1) (finiteMaxEntangled I)

/-- PDF p.3: sum over registers 1 and 2, leaving register 3 in that order. -/
def teleportContraction {I : Type*} [Fintype I]
    (alpha : Vec I) (resource measured : Vec (I × I)) : Vec I :=
  WithLp.toLp 2 fun k => ∑ i, ∑ j, conj (measured (i,j)) * alpha i * resource (j,k)

/-- PDF p.2: source Bell labels c,d, with B11=(01-10)/sqrt(2). -/
def sourceBellBasis (c d : Bool) : Vec QubitPair :=
  act (Matrix.kronecker (pauliZ ^ c.toNat * pauliX ^ d.toNat) 1)
    (finiteMaxEntangled Bool)

/-- PDF p.2: rotate only the first qubit of the measured Bell ket. -/
def rotatedBell (U : Matrix Bool Bool ℂ) (c d : Bool) : Vec QubitPair :=
  act (Matrix.kronecker Uᴴ 1) (sourceBellBasis c d)

/-- PDF pp.2,5: tensor Pauli representatives with the source output order X^x Z^z. -/
def pauliByproduct (x z : Bool) : Matrix Bool Bool ℂ :=
  pauliX ^ x.toNat * pauliZ ^ z.toNat

/-- PDF p.2: the H-bond is a state, distinct from the Hadamard operator. -/
def hBond : Vec QubitPair :=
  act (controlled pauliZ) (tensorVec (act hadamard (ket false)) (act hadamard (ket false)))

/-- PDF p.5, equation (2): positive-exponent phase gate. -/
def phaseGate (theta : ℝ) : Matrix Bool Bool ℂ :=
  Matrix.diagonal fun b => if b then Complex.exp (Complex.I * theta) else 1

/-- PDF p.5, equation (2): W(theta)=H P(theta). -/
def wGate (theta : ℝ) : Matrix Bool Bool ℂ := hadamard * phaseGate theta

/-- PDF p.5: exp(-i theta X), explicitly cos(theta) I - i sin(theta) X.
There is no half-angle in this paper's rotation convention. -/
def rx (theta : ℝ) : Matrix Bool Bool ℂ :=
  (Real.cos theta : ℂ) • (1 : Matrix Bool Bool ℂ) -
    (Complex.I * Real.sin theta) • pauliX

/-- PDF p.5: exp(-i theta Z), explicitly diagonal. -/
def rz (theta : ℝ) : Matrix Bool Bool ℂ :=
  Matrix.diagonal fun b => Complex.exp ((if b then Complex.I else -Complex.I) * theta)

/-- PDF pp.8–10: normalized equatorial basis, plus=0 and minus=1. -/
def equatorial (theta : ℝ) (s : Bool) : Vec Bool :=
  WithLp.toLp 2 fun b => ((Real.sqrt 2)⁻¹ : ℂ) *
    if b then (if s then -1 else 1) * Complex.exp (Complex.I * theta) else 1

/-- PDF pp.5,9,13: (-1)^s as a real angle sign. -/
def angleSign (s : Bool) : ℝ := if s then -1 else 1

/-- PDF p.4: real Pauli representatives in the order I,X,Z,XZ. -/
def bellPauliRepresentative (a : Fin 4) : Matrix Bool Bool ℂ := ![1,pauliX,pauliZ,pauliX * pauliZ] a

/-- PDF p.4: the sixteen dimension-four teleportation gates. -/
def czTeleportGate (a b : QubitPair) : Matrix QubitPair QubitPair ℂ :=
  Matrix.kronecker (pauliByproduct a.1 a.2) (pauliByproduct b.1 b.2) * controlled pauliZ

/-- PDF p.4: the actual rank-one Bell frame identity, with positive weights separate. -/
def BellFrame {I : Type*} [Fintype I] [Nonempty I] [DecidableEq I]
    {n : ℕ} (U : Fin n → Matrix I I ℂ) (k : Fin n → ℝ) : Prop :=
  ∑ i, (k i : ℂ) • pureDensity (rotatedEntangledKet (U i)) = 1

/-- PDF p.4: the rank-one POVM branch bra includes sqrt(k_i). -/
def weightedTeleport {I : Type*} [Fintype I] [Nonempty I] [DecidableEq I]
    (U : Matrix I I ℂ) (k : ℝ) (alpha : Vec I) : Vec I :=
  (Real.sqrt k : ℂ) • teleportContraction alpha (finiteMaxEntangled I) (rotatedEntangledKet U)

example (A : Matrix Bool Bool ℂ) (v : Vec Bool) : applyRect A v = act A v := rfl

example : pauliByproduct false false = 1 := by simp [pauliByproduct]

example : phaseGate 0 = 1 := by ext a b; simp [phaseGate]

example : wGate 0 = hadamard := by
  have h : phaseGate 0 = 1 := by ext a b; simp [phaseGate]
  simp [wGate, h]

example : rx 0 = 1 := by simp [rx]

example : rz 0 = 1 := by ext a b; simp [rz]

example : bellPauliRepresentative 0 = 1 ∧ bellPauliRepresentative 1 = pauliX ∧ bellPauliRepresentative 2 = pauliZ ∧ bellPauliRepresentative 3 = pauliX * pauliZ := by
  simp [bellPauliRepresentative]

example : equatorial 0 false false = ((Real.sqrt 2)⁻¹ : ℂ) := by simp [equatorial]

example : teleportContraction (ket () : Vec Unit) (finiteMaxEntangled Unit)
    (finiteMaxEntangled Unit) = ket () := by
  ext x; cases x; simp [teleportContraction, finiteMaxEntangled, ket]

/-- PDF p.8: one CZ phase for two computational bits. -/
def czPhase (a b : Bool) : ℂ := if a && b then -1 else 1

/-- PDF pp.8,11–12: ordered edges are used once each, with no implicit wire permutations. -/
def edgePhase {V : Type*} [DecidableEq V] (E : Finset (V × V)) (z : V → Bool) : ℂ :=
  ∏ e ∈ E, czPhase (z e.1) (z e.2)

/-- PDF p.8: normalized graph cluster, obtained by CZ edges on |+> at every site. -/
def graphClusterState {V : Type*} [Fintype V] [DecidableEq V]
    (E : Finset (V × V)) : Vec (V → Bool) :=
  WithLp.toLp 2 fun z => ((Real.sqrt 2)⁻¹ : ℂ) ^ Fintype.card V * edgePhase E z

abbrev RectangularSites (r c : ℕ) := Fin r × Fin c

/-- PDF p.8 Fig.4: rectangular nearest-neighbour edges, oriented down and right. -/
def gridEdges (r c : ℕ) : Finset (RectangularSites r c × RectangularSites r c) :=
  Finset.univ.filter fun e =>
    (e.1.1.val + 1 = e.2.1.val ∧ e.1.2 = e.2.2) ∨
    (e.1.1 = e.2.1 ∧ e.1.2.val + 1 = e.2.2.val)

/-- PDF pp.9–10: all k+1 line sites are entangled first; the first k are then
contracted against their normalized measurement bras. Angles may be evaluated
from the preceding outcome bits, as explicitly done in Figures 5 and 10.
At k=0 there are no ancillas, edges or measurements: the surviving vector is psi. -/
def lineBranch (k : ℕ) (angles : Fin k → ℝ) (s : Fin k → Bool) (psi : Vec Bool) : Vec Bool :=
  WithLp.toLp 2 fun b => ∑ z : Qubits (k+1),
    if z ⟨k,Nat.lt_succ_self k⟩ = b then
      psi (z 0) * ((Real.sqrt 2)⁻¹ : ℂ)^k *
        (∏ i : Fin k, czPhase (z i.castSucc) (z i.succ)) *
        (∏ i : Fin k, conj (equatorial (angles i) (s i) (z i.castSucc)))
    else 0

/-- PDF p.9 Fig.5, corrected for Rx/Rz=exp(-i theta Pauli): double the three
printed nonzero measurement angles; keep their causal dependence unchanged. -/
def figure5Angles (xi eta zeta : ℝ) (s : Fin 4 → Bool) : Fin 4 → ℝ :=
  ![0, -2 * xi * angleSign (s 0), -2 * eta * angleSign (s 1),
    -2 * zeta * angleSign (xor (s 0) (s 2))]

/-- PDF pp.11–12: explicit insertion/renaming of the measured site. -/
def insertSite {V : Type*} [DecidableEq V] (A : V) (s : Bool)
    (z : {v : V // v ≠ A} → Bool) : V → Bool :=
  fun v => if h : v = A then s else z ⟨v,h⟩

/-- PDF pp.11–12: induced edge set on the surviving site subtype. -/
def deletedEdges {V : Type*} [Fintype V] [DecidableEq V]
    (E : Finset (V × V)) (A : V) :
    Finset ({v : V // v ≠ A} × {v : V // v ≠ A}) :=
  Finset.univ.filter fun e => (e.1.val,e.2.val) ∈ E

/-- PDF p.12: tensor product of Z^s on neighbours of the deleted site. -/
def neighbourPhase {V : Type*} [DecidableEq V] (E : Finset (V × V)) (A : V)
    (s : Bool) (z : {v : V // v ≠ A} → Bool) : ℂ :=
  ∏ e ∈ E, if e.1 = A ∨ e.2 = A then
    czPhase (insertSite A s z e.1) (insertSite A s z e.2) else 1

/-- PDF p.8: physical preparation gates, each with its support explicit. -/
inductive PrepGate (V : Type*) where
  | h (v : V)
  | cz (v w : V)

/-- PDF p.8: the sites occupied by a preparation gate. -/
def PrepGate.support {V : Type*} [DecidableEq V] : PrepGate V → Finset V
  | .h v => {v}
  | .cz v w => {v,w}

/-- PDF p.8: coordinate matrices of one-site H and two-site CZ. -/
def PrepGate.matrix {V : Type*} [Fintype V] [DecidableEq V] :
    PrepGate V → Matrix (V → Bool) (V → Bool) ℂ
  | .h v => fun y z => if ∀ w, w ≠ v → y w = z w then hadamard (y v) (z v) else 0
  | .cz v w => Matrix.diagonal fun z => czPhase (z v) (z w)

/-- PDF p.8: a physical layer has pairwise disjoint gate supports. -/
def LegalPrepLayer {V : Type*} [DecidableEq V] (L : List (PrepGate V)) : Prop :=
  L.Pairwise fun a b => Disjoint a.support b.support

/-- PDF p.8: flattening layers gives the actual gate word (first gate applied first). -/
def prepMatrix {V : Type*} [Fintype V] [DecidableEq V]
    (layers : List (List (PrepGate V))) : Matrix (V → Bool) (V → Bool) ℂ :=
  (layers.flatten.map PrepGate.matrix).reverse.prod

/-- PDF p.8: H at any site, and CZ only on the rectangular nearest-neighbour edges. -/
def GridPrepGate {r c : ℕ} : PrepGate (RectangularSites r c) → Prop
  | .h _ => True
  | .cz v w => (v,w) ∈ gridEdges r c ∨ (w,v) ∈ gridEdges r c

example : edgePhase (∅ : Finset (Bool × Bool)) (fun b => b) = 1 := by simp [edgePhase]

example : gridEdges 1 1 = ∅ := by
  ext e
  simp only [gridEdges, Finset.mem_filter, Finset.mem_univ, true_and, Finset.notMem_empty, iff_false]
  have h1 := e.1.1.isLt; have h2 := e.2.1.isLt
  have h3 := e.1.2.isLt; have h4 := e.2.2.isLt
  omega

example (xi eta zeta : ℝ) (s : Fin 4 → Bool) : figure5Angles xi eta zeta s 0 = 0 := rfl

example {V : Type*} [DecidableEq V] (A : V) (s : Bool)
    (z : {v : V // v ≠ A} → Bool) : insertSite A s z A = s := by simp [insertSite]

example {V : Type*} [Fintype V] [DecidableEq V] :
    prepMatrix ([] : List (List (PrepGate V))) = 1 := rfl

/-- PDF p.4 Fig.3: representative strings for the four complementary GHZ pairs. -/
def ghzSeed (a : Fin 4) : Qubits 3 :=
  ![![false,false,false], ![false,false,true], ![false,true,false], ![true,false,false]] a

/-- PDF p.4 Fig.3: normalized plus/minus three-qubit Bell kets. -/
def threeQubitBellKet (a : Fin 4) (s : Bool) : Vec (Qubits 3) :=
  WithLp.toLp 2 fun z =>
    if z = ghzSeed a then ((Real.sqrt 2)⁻¹ : ℂ)
    else if z = fun i => !(ghzSeed a i) then
      (if s then -1 else 1) * ((Real.sqrt 2)⁻¹ : ℂ) else 0

/-- PDF p.4 Fig.3, actual eight-wire resource: input12 and H-bonds34,57,68. -/
def figure3Resource (psi : Vec QubitPair) : Vec (Qubits 8) :=
  WithLp.toLp 2 fun z => psi (z 0,z 1) * hBond (z 2,z 3) * hBond (z 4,z 6) * hBond (z 5,z 7)

/-- PDF p.4 Fig.3: destructive measurements on 135 and 246, outputs 78. -/
def figure3Branch (a b : Fin 4 × Bool) (psi : Vec QubitPair) : Vec QubitPair :=
  WithLp.toLp 2 fun y => ∑ z : Qubits 8,
    if (z 6,z 7) = y then
      conj (threeQubitBellKet a.1 a.2 ![z 0,z 2,z 4]) *
      conj (threeQubitBellKet b.1 b.2 ![z 1,z 3,z 5]) * figure3Resource psi z else 0

/-- PDF p.11 Fig.8: unmeasured output sites, top then bottom. -/
def figure8Output (i : Bool) : RectangularSites 4 3 := if i then (3,2) else (0,2)

abbrev Figure8Measured := {v : RectangularSites 4 3 // v ≠ figure8Output false ∧ v ≠ figure8Output true}

/-- PDF p.11 Fig.8: arbitrary two-qubit input at upper/lower left, ten |+>
ancillas, then all rectangular grid CZs, in the displayed wire order. -/
def figure8Resource (psi : Vec QubitPair) : Vec (RectangularSites 4 3 → Bool) :=
  WithLp.toLp 2 fun z => psi (z (0,0),z (3,0)) * ((Real.sqrt 2)⁻¹ : ℂ)^10 *
    edgePhase (gridEdges 4 3) z

/-- PDF p.11 Fig.8: all first-column sites and top/bottom middle sites use X;
the other four measured sites use Z. The two rightmost corner sites survive. -/
def figure8Basis (v : Figure8Measured) (s : Bool) : Vec Bool :=
  if v.val.2 = 0 ∨ v.val.1 = 0 ∨ v.val.1 = 3 then equatorial 0 s else ket s

/-- PDF p.11 Fig.8: full physical bra contraction, with no assumption of
independent or uniformly distributed X/Z outcomes. -/
def figure8Branch (s : Figure8Measured → Bool) (psi : Vec QubitPair) : Vec QubitPair :=
  WithLp.toLp 2 fun y => ∑ z : RectangularSites 4 3 → Bool,
    if (z (figure8Output false),z (figure8Output true)) = y then
      (∏ v : Figure8Measured, conj (figure8Basis v (s v) (z v.val))) * figure8Resource psi z else 0

example : ghzSeed 0 = (![false,false,false] : Qubits 3) := rfl

example : figure8Output false = (0,2) ∧ figure8Output true = (3,2) := by
  simp [figure8Output]

example (psi : Vec QubitPair) : figure3Resource psi (fun _ => false) =
    psi (false,false) * hBond (false,false) * hBond (false,false) * hBond (false,false) := rfl

/-- PDF pp.15–16: destructive contraction on a pair, retaining an arbitrary reference. -/
def pairBra {R : Type*} (b : Vec QubitPair) (psi : Vec (QubitPair × R)) : Vec R :=
  WithLp.toLp 2 fun r => ∑ p : QubitPair, conj (b p) * psi (p,r)

/-- PDF pp.15–16: Bell analysis by CX followed by local X on wire1, Z on wire2. -/
def localBellAnalysis {R : Type*} [Fintype R] [DecidableEq R]
    (c d : Bool) (psi : Vec (QubitPair × R)) : Vec R :=
  pairBra (tensorVec (equatorial 0 c) (ket d))
    (act (Matrix.kronecker cnot 1) psi)

/-- PDF p.16 Fig.12: CX with explicitly named control and target. -/
def cxWires {V : Type*} [Fintype V] [DecidableEq V] (control target : V) :
    Matrix (V → Bool) (V → Bool) ℂ :=
  fun y z => if y = Function.update z target (xor (z target) (z control)) then 1 else 0

/-- PDF p.16 Fig.12: input psi1, |0>2, |+>3, before either entangling gate. -/
def figure12Input (psi : Vec Bool) : Vec (Qubits 3) :=
  WithLp.toLp 2 fun z => psi (z 0) * (if z 1 then 0 else 1) * ((Real.sqrt 2)⁻¹ : ℂ)

/-- PDF p.16 Fig.12: prepare pair23 by CX3->2, analyze by CX1->2,
then destructively measure X1 and Z2, leaving qubit3. -/
def figure12Branch (c d : Bool) (psi : Vec Bool) : Vec Bool :=
  let v := act (cxWires (0 : Fin 3) 1 * cxWires (2 : Fin 3) 1) (figure12Input psi)
  WithLp.toLp 2 fun b => ∑ a : Bool, conj (equatorial 0 c a) * v ![a,d,b]

/-- PDF p.16 equation (3): labels (c,d) order I,X,Z,XZ. -/
def hBell (c d : Bool) : Vec QubitPair :=
  act (Matrix.kronecker (pauliByproduct d c) 1) hBond

/-- PDF pp.17–18: the local projection with renaming, |00>->|0>, |11>->|1>.
This is a rectangular coisometry, not merely the ambient even-space projector. -/
def fuse : Matrix Bool QubitPair ℂ := fun b p => if p = (b,b) then 1 else 0

/-- PDF p.18 Fig.14: left site=(left bond half,psi1), right=(right bond half,psi2). -/
def fusionResource (psi1 psi2 : Vec Bool) : Vec (QubitPair × QubitPair) :=
  WithLp.toLp 2 fun p => hBond (p.1.1,p.2.1) * psi1 p.1.2 * psi2 p.2.2

abbrev EdgeLabel {V : Type*} (E : Finset (V × V)) := {e : V × V // e ∈ E}

/-- PDF p.17 Fig.13: one independent normalized H-bond per edge.
Virtual wire (e,false) is at e's first endpoint, (e,true) at its second. -/
def bondGrid {V : Type*} [DecidableEq V] (E : Finset (V × V)) :
    Vec ((EdgeLabel E × Bool) → Bool) :=
  WithLp.toLp 2 fun w => ∏ e : EdgeLabel E, hBond (w (e,false),w (e,true))

/-- PDF p.17: tensor product of the explicitly displayed local maps Pi,
with all incident virtual wires set to the physical site's bit. -/
def valenceProjection {V : Type*} [DecidableEq V] (E : Finset (V × V)) :
    Matrix (V → Bool) ((EdgeLabel E × Bool) → Bool) ℂ :=
  fun x w => if ∀ e : EdgeLabel E,
    w (e,false) = x e.val.1 ∧ w (e,true) = x e.val.2 then 1 else 0

/-- PDF pp.17–18: all four rotated H-bond measurement kets, constructed from W. -/
def cutDownKet (theta : ℝ) (a : Fin 4) : Vec QubitPair :=
  act (Matrix.kronecker ((wGate (-theta))ᴴ * bellPauliRepresentative a) 1) hBond

/-- PDF p.18: explicit even/odd representatives for all four outcomes. -/
def cutDownFormula (theta : ℝ) (a : Fin 4) : Vec QubitPair :=
  WithLp.toLp 2 fun p => ((Real.sqrt 2)⁻¹ : ℂ) *
    if a.val < 2 then
      if p.1 = p.2 then
        if p.1 then (if a.val = 1 then -1 else 1) * Complex.exp (Complex.I * theta) else 1
      else 0
    else if p.1 ≠ p.2 then
      if p.1 then (if a.val = 3 then -1 else 1) * Complex.exp (Complex.I * theta) else 1
    else 0

example : fuse false (false,false) = 1 ∧ fuse true (true,true) = 1 ∧
    fuse false (false,true) = 0 := by simp [fuse]

example : hBell false false = hBond := by simp [hBell, pauliByproduct, act]

example {V : Type*} [DecidableEq V] (x : V → Bool)
    (w : (EdgeLabel (∅ : Finset (V × V)) × Bool) → Bool) :
    valenceProjection ∅ x w = 1 := by simp [valenceProjection]

example (theta : ℝ) : cutDownFormula theta 0 (false,false) = ((Real.sqrt 2)⁻¹ : ℂ) := by
  simp [cutDownFormula]

/-- PDF pp.14–15 Fig.11: adjacent wire placement for a ladder gate. -/
def ladderWires {m : ℕ} (t : Fin m) : Fin 2 ↪ Fin (m+1) where
  toFun j := ⟨t.val+j.val, by have ht := t.isLt; have hj := j.isLt; omega⟩
  inj' := by intro a b h; apply Fin.ext; have hv := congrArg Fin.val h; change t.val + a.val = t.val + b.val at hv; exact Nat.add_left_cancel hv

/-- PDF p.14: actual (m+1)-qubit ladder state, each Ui,i+1 applied once in order. -/
def ladderState (m : ℕ) (U : Fin m → Matrix QubitPair QubitPair ℂ) : Vec (Qubits (m+1)) :=
  act ((List.ofFn fun t => embedOp (Gate.ofMatrix2 (U t)).mat (ladderWires t)).reverse.prod)
    (zeroKet (m+1))

/-- PDF p.14: full joint event effect, identity at unmeasured sites and the
chosen normalized rank-one projector at every measured site. -/
def ladderEvent {m : ℕ} (measured : Fin (m+1) → Bool)
    (v : Fin (m+1) → Vec Bool) : Matrix (Qubits (m+1)) (Qubits (m+1)) ℂ :=
  fun y z => ∏ i : Fin (m+1), if measured i then v i (y i) * conj (v i (z i))
    else if y i = z i then 1 else 0

/-- PDF p.15: retain the second site, tracing the first or applying its chosen bra. -/
def reduceFirst (selected : Option (Vec Bool)) (rho : Matrix QubitPair QubitPair ℂ) : Matrix Bool Bool ℂ :=
  match selected with
  | none => traceLeft rho
  | some v => fun b c => ∑ a : Bool, ∑ d : Bool, conj (v a) * rho (a,b) (d,c) * v d

/-- PDF p.15: two-site intermediate sigma=U(rho tensor |0><0|)U†. -/
def ladderSigma (U : Matrix QubitPair QubitPair ℂ) (rho : Matrix Bool Bool ℂ) : Matrix QubitPair QubitPair ℂ :=
  U * Matrix.kronecker rho (pureDensity (ket false)) * Uᴴ

/-- PDF p.15: the increasing-site contraction stores only one-site and two-site matrices. -/
def ladderScan {m : ℕ} (U : Fin m → Matrix QubitPair QubitPair ℂ)
    (measured : Fin (m+1) → Bool) (v : Fin (m+1) → Vec Bool) : Matrix Bool Bool ℂ :=
  (List.finRange m).foldl (fun rho t =>
    reduceFirst (if measured t.castSucc then some (v t.castSucc) else none)
      (ladderSigma (U t) rho)) (pureDensity (ket false))

/-- PDF p.15: trace the last subnormalized site, or contract its selected bra. -/
def ladderScanProbability {m : ℕ} (U : Fin m → Matrix QubitPair QubitPair ℂ)
    (measured : Fin (m+1) → Bool) (v : Fin (m+1) → Vec Bool) : ℝ :=
  let rho := ladderScan U measured v
  let last : Fin (m+1) := ⟨m,Nat.lt_succ_self m⟩
  if measured last then (∑ a : Bool, ∑ b : Bool, conj (v last a) * rho a b * v last b).re
  else rho.trace.re

/-- PDF pp.14–15: exact scalar arithmetic syntax, with shared previous registers.
Complex conjugation is constant work on real/imaginary coordinates. -/
inductive ScalarInstruction (I : Type*) where
  | input (i : I)
  | constant (c : ℂ)
  | add (a b : ℕ)
  | mul (a b : ℕ)
  | conjugate (a : ℕ)

/-- PDF pp.14–15: no uninitialized-register defaults are allowed in a valid word. -/
def ScalarInstruction.readsBefore {I : Type*} (t : ℕ) : ScalarInstruction I → Prop
  | .input _ => True
  | .constant _ => True
  | .add a b => a < t ∧ b < t
  | .mul a b => a < t ∧ b < t
  | .conjugate a => a < t

/-- PDF pp.14–15: one arithmetic instruction, with input reads charged as instructions. -/
def ScalarInstruction.eval {I : Type*} (data : I → ℂ) (memory : List ℂ) : ScalarInstruction I → ℂ
  | .input i => data i
  | .constant c => c
  | .add a b => (memory[a]?).getD 0 + (memory[b]?).getD 0
  | .mul a b => (memory[a]?).getD 0 * (memory[b]?).getD 0
  | .conjugate a => conj ((memory[a]?).getD 0)

/-- PDF pp.14–15: a straight-line program has one new scalar register per operation. -/
structure ScalarProgram (I : Type*) where
  word : List (ScalarInstruction I)
  output : ℕ

/-- PDF pp.14–15: all referenced registers exist before the operation using them. -/
def ScalarProgram.Valid {I : Type*} (P : ScalarProgram I) : Prop :=
  P.output < P.word.length ∧ ∀ t (h : t < P.word.length), ScalarInstruction.readsBefore t (P.word[t])

/-- PDF pp.14–15: evaluation counts actual word operations rather than an unattached cost. -/
def ScalarProgram.eval {I : Type*} (P : ScalarProgram I) (data : I → ℂ) : ℂ :=
  ((P.word.foldl (fun mem op => mem ++ [ScalarInstruction.eval data mem op]) [])[P.output]?).getD 0

abbrev LadderScalarInput (m : ℕ) := (Fin m × QubitPair × QubitPair) ⊕ (Fin (m+1) × Bool)

/-- PDF pp.14–15: input entries of the ladder gates and selected measurement bras. -/
def ladderScalarData {m : ℕ} (U : Fin m → Matrix QubitPair QubitPair ℂ)
    (v : Fin (m+1) → Vec Bool) : LadderScalarInput m → ℂ
  | .inl (t,a,b) => U t a b
  | .inr (t,a) => v t a

example (U : Fin 0 → Matrix QubitPair QubitPair ℂ) (s : Fin 1 → Bool) (v : Fin 1 → Vec Bool) :
    ladderScan U s v = pureDensity (ket false) := rfl

example (data : Unit → ℂ) :
    ScalarProgram.eval (⟨[.constant 1],0⟩ : ScalarProgram Unit) data = 1 := rfl

example {I : Type*} : ScalarInstruction.readsBefore 0 (.constant (1 : ℂ) : ScalarInstruction I) :=
  True.intro

/-- PDF p.19: a history available before stage t contains only t earlier bits. -/
def outcomeHistoryPrefix {k : ℕ} (s : Qubits k) (t : Fin k) : Qubits t.val :=
  fun i => s ⟨i.val, Nat.lt_trans i.isLt t.isLt⟩

/-- PDF p.19: finite adaptive unitary/projective process on n data qubits.
The basis columns are the measured vectors. All controls are functions of the
recorded past, fixed before the unknown input. No cost is attached to them here. -/
structure AdaptiveProcess (n k : ℕ) where
  gate : (t : Fin k) → Qubits t.val → Matrix (Qubits n) (Qubits n) ℂ
  gate_unitary : ∀ t h, gate t h ∈ Matrix.unitaryGroup (Qubits n) ℂ
  wire : (t : Fin k) → Qubits t.val → Fin n
  basis : (t : Fin k) → Qubits t.val → Matrix Bool Bool ℂ
  basis_unitary : ∀ t h, basis t h ∈ Matrix.unitaryGroup Bool ℂ
  finalGate : Qubits k → Matrix (Qubits n) (Qubits n) ℂ
  final_unitary : ∀ h, finalGate h ∈ Matrix.unitaryGroup (Qubits n) ℂ

/-- PDF p.19: rank-one site projector in the basis supplied as columns of B. -/
def siteProjector {n : ℕ} (wire : Fin n) (B : Matrix Bool Bool ℂ) (s : Bool) :
    Matrix (Qubits n) (Qubits n) ℂ :=
  fun y z => if ∀ i, i ≠ wire → y i = z i then B (y wire) s * conj (B (z wire) s) else 0

/-- PDF p.19: branch operator built by actual chronological gate/projector products. -/
def processBranchOperator {n k : ℕ} (P : AdaptiveProcess n k) (s : Qubits k) :
    Matrix (Qubits n) (Qubits n) ℂ :=
  P.finalGate s * (List.ofFn fun t : Fin k =>
    let h := outcomeHistoryPrefix s t
    siteProjector (P.wire t h) (P.basis t h) (s t) * P.gate t h).reverse.prod

/-- PDF p.19: the coherent pointer wave, with data first and k fresh pointer bits second. -/
def pointerWave {n k : ℕ} (P : AdaptiveProcess n k) (psi : Vec (Qubits n)) :
    Vec (Qubits n × Qubits k) :=
  WithLp.toLp 2 fun p => act (processBranchOperator P p.2) psi p.1

example {n : ℕ} (P : AdaptiveProcess n 0) (s : Qubits 0) :
    processBranchOperator P s = P.finalGate s := by simp [processBranchOperator]

example {n : ℕ} (i : Fin n) (y z : Qubits n) :
    siteProjector i (1 : Matrix Bool Bool ℂ) false y z =
      if ∀ j, j ≠ i → y j = z j then
        (if y i = false then 1 else 0) * conj (if z i = false then 1 else 0) else 0 := by
  simp only [siteProjector, Matrix.one_apply]

/-- Degenerate-resource sanity: a zero input gives the zero physical branch. -/
example {I : Type*} [Fintype I] (resource measured : Vec (I × I)) :
    teleportContraction (0 : Vec I) resource measured = 0 := by
  ext k; simp [teleportContraction]

/-- The identity rotation keeps the resource orientation explicit. -/
example (i j : Bool) : sourceBellBasis false false (i,j) =
    act (Matrix.kronecker (1 : Matrix Bool Bool ℂ) 1) (finiteMaxEntangled Bool) (i,j) := by
  simp only [sourceBellBasis, Bool.toNat_false, pow_zero, mul_one]

/-- The positive weight branch has an actual sqrt-weight, including k=0 off-domain. -/
example {I : Type*} [Fintype I] [Nonempty I] [DecidableEq I]
    (U : Matrix I I ℂ) (alpha : Vec I) : weightedTeleport U 0 alpha = 0 := by
  simp [weightedTeleport]

/-- CZ's zero-control phase is +1, pinning its computational-basis sign. -/
example (b : Bool) : czPhase false b = 1 := by simp [czPhase]

/-- The H-bond's tensor order is left endpoint then right endpoint. -/
example : hBond (false,false) = (1 / 2 : ℂ) := by
  have h2 : ((Real.sqrt 2 : ℝ) : ℂ) ^ 2 = 2 := by
    rw [← Complex.ofReal_pow, Real.sq_sqrt (by norm_num)]
    norm_num
  norm_num [hBond, act, tensorVec, hadamard, ket, controlled, pauliZ,
    Matrix.mulVec, dotProduct, Matrix.one_apply, Fintype.sum_prod_type, Fintype.sum_bool,
    Complex.ofReal_inv, ← pow_two, inv_pow, h2]

/-- No measurement is performed by the empty preparation word. -/
example {V : Type*} [DecidableEq V] : LegalPrepLayer ([] : List (PrepGate V)) := by
  simp [LegalPrepLayer]

/-- An isolated site's neighbour correction is the empty product. -/
example {V : Type*} [DecidableEq V] (A : V) (s : Bool)
    (z : {v : V // v ≠ A} → Bool) : neighbourPhase ∅ A s z = 1 := by
  simp [neighbourPhase]

/-- With no selected measurement the ladder step is exactly an unnormalized trace. -/
example (rho : Matrix QubitPair QubitPair ℂ) : reduceFirst none rho = traceLeft rho := rfl

/-- A branch's outcome-dependent final unitary is applied after its projectors. -/
example {n k : ℕ} (P : AdaptiveProcess n k) (psi : Vec (Qubits n))
    (x : Qubits n) (s : Qubits k) :
    pointerWave P psi (x,s) = act (processBranchOperator P s) psi x := rfl

end QAlgorithms.Papers.Independent.Intakenext100.P52
Source
An introduction to measurement based quantum computation, arXiv:quant-ph/0508124v2, https://arxiv.org/abs/quant-ph/0508124v2
Read-back

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

QAlgorithms.Papers.Independent.Intakenext100.P52.AdaptiveProcess

For natural numbers n,kn,kn,k, an adaptive process consists of the following data: for every step 0≤t<k0\le t<k0≤t<k and every Boolean history hhh of length ttt, a unitary complex matrix Gt,hG_{t,h}Gt,h​ on the space indexed by length-nnn Boolean strings, a selected wire qt,h∈{0,…,n−1}q_{t,h}\in\{0,\ldots,n-1\}qt,h​∈{0,…,n−1}, and a unitary complex 2×22\times22×2 matrix Bt,hB_{t,h}Bt,h​ indexed by Booleans; and, for every complete Boolean history sss of length kkk, a unitary matrix FsF_sFs​ on the same length-nnn string space. These unitarity requirements hold for all histories. No initial state is part of the structure. The case k=0k=0k=0 has no step data and has one final unitary; if n=0n=0n=0 and k>0k>0k>0, the required wire selections cannot exist.

QAlgorithms.Papers.Independent.Intakenext100.P52.BellFrame

Let III be a finite nonempty index type with decidable equality, let D=∣I∣D=|I|D=∣I∣, let nnn be any natural number, and let UiU_iUi​ be arbitrary complex I×II\times II×I matrices and kik_iki​ arbitrary real numbers for 0≤i<n0\le i<n0≤i<n. Define ΩI∈CI×I\Omega_I\in\mathbb C^{I\times I}ΩI​∈CI×I by ΩI(a,b)=D−1/2\Omega_I(a,b)=D^{-1/2}ΩI​(a,b)=D−1/2 if a=ba=ba=b and 000 otherwise, and put ri=(Ui†⊗ID)ΩIr_i=(U_i^\dagger\otimes I_D)\Omega_Iri​=(Ui†​⊗ID​)ΩI​, where †\dagger† denotes conjugate transpose. The predicate asserts precisely

∑i=0n−1ki riri†=II×I,(riri†)p,q=ri(p)ri(q)‾.\sum_{i=0}^{n-1}k_i\,r_i r_i^\dagger=I_{I\times I}, \qquad (r_i r_i^\dagger)_{p,q}=r_i(p)\overline{r_i(q)}.i=0∑n−1​ki​ri​ri†​=II×I​,(ri​ri†​)p,q​=ri​(p)ri​(q)​.

The definition imposes no separate unitarity condition on UiU_iUi​ or positivity condition on kik_iki​. It includes n=0n=0n=0, when the sum is zero and the asserted equality cannot hold because III is nonempty.

QAlgorithms.Papers.Independent.Intakenext100.P52.EdgeLabel

For any type VVV and any finite set EEE of ordered pairs from VVV, this abbreviates the type of pairs e∈V×Ve\in V\times Ve∈V×V equipped with the condition e∈Ee\in Ee∈E. Thus its elements are precisely the ordered pairs belonging to EEE. The type VVV need not be finite, pairs with equal endpoints are allowed, and when EEE is empty this type is empty.

QAlgorithms.Papers.Independent.Intakenext100.P52.Figure8Measured

This abbreviates the type of sites v∈{0,1,2,3}×{0,1,2}v\in\{0,1,2,3\}\times\{0,1,2\}v∈{0,1,2,3}×{0,1,2} satisfying both v≠(0,2)v\ne(0,2)v=(0,2) and v≠(3,2)v\ne(3,2)v=(3,2). Thus its elements are precisely the ten grid sites other than these two specified sites.

QAlgorithms.Papers.Independent.Intakenext100.P52.GridPrepGate

For any natural numbers r,cr,cr,c, including zero, the sites are pairs (i,j)(i,j)(i,j) with 0≤i<r0\le i<r0≤i<r and 0≤j<c0\le j<c0≤j<c. This predicate holds for every gate h(v)\mathrm h(v)h(v). It holds for cz(v,w)\mathrm{cz}(v,w)cz(v,w) exactly when either (v,w)(v,w)(v,w) or (w,v)(w,v)(w,v) is a grid edge, where an ordered pair ((i,j),(i′,j′))((i,j),(i',j'))((i,j),(i′,j′)) is a grid edge when i′=i+1i'=i+1i′=i+1 and j′=jj'=jj′=j, or when i′=ii'=ii′=i and j′=j+1j'=j+1j′=j+1. Thus the two sites must be horizontally or vertically adjacent. If either dimension is zero, there are no sites and hence no preparation gates on this grid.

QAlgorithms.Papers.Independent.Intakenext100.P52.LadderScalarInput

For every natural number mmm, the scalar-input label type is the disjoint union

({0,…,m−1}×({false,true}2)×({false,true}2))  ⊔  ({0,…,m}×{false,true}).\bigl(\{0,\ldots,m-1\}\times(\{\mathrm{false},\mathrm{true}\}^2)\times(\{\mathrm{false},\mathrm{true}\}^2)\bigr) \;\sqcup\; \bigl(\{0,\ldots,m\}\times\{\mathrm{false},\mathrm{true}\}\bigr).({0,…,m−1}×({false,true}2)×({false,true}2))⊔({0,…,m}×{false,true}).

The two summands remain distinct even when their labels have similar components. When m=0m=0m=0, the first summand is empty and the second consists of the two labels (0,false)(0,\mathrm{false})(0,false) and (0,true)(0,\mathrm{true})(0,true).

QAlgorithms.Papers.Independent.Intakenext100.P52.LegalPrepLayer

For any type VVV with decidable equality and any finite list LLL of preparation gates on VVV, this predicate means that the supports of every two gates at distinct positions in the list are disjoint, where the support of h(v)\mathrm h(v)h(v) is {v}\{v\}{v} and that of cz(v,w)\mathrm{cz}(v,w)cz(v,w) is {v,w}\{v,w\}{v,w}. Thus no site occurs in two different gates of the layer; a single gate cz(v,v)\mathrm{cz}(v,v)cz(v,v) is permitted by this predicate. Empty lists and singleton lists satisfy the predicate.

QAlgorithms.Papers.Independent.Intakenext100.P52.PrepGate.matrix

For any finite type VVV with decidable equality, this assigns each preparation gate a complex matrix whose rows and columns are indexed by Boolean assignments V→{false,true}V\to\{\mathrm{false},\mathrm{true}\}V→{false,true}. Write Boolean values as 0,10,10,1, and let H=2−1/2(111−1)H=2^{-1/2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}H=2−1/2(11​1−1​), with rows and columns ordered 0,10,10,1. For h(v)\mathrm h(v)h(v), the entry at assignments y,zy,zy,z is Hy(v),z(v)H_{y(v),z(v)}Hy(v),z(v)​ if y(u)=z(u)y(u)=z(u)y(u)=z(u) for every u≠vu\ne vu=v, and is zero otherwise. For cz(v,w)\mathrm{cz}(v,w)cz(v,w), the matrix is diagonal, with diagonal entry (−1)z(v)z(w)(-1)^{z(v)z(w)}(−1)z(v)z(w) at zzz. The sites v,wv,wv,w need not be distinct; if they coincide, this diagonal entry is (−1)z(v)(-1)^{z(v)}(−1)z(v). The type VVV may be empty, although in that case there are no gates with a site in VVV.

QAlgorithms.Papers.Independent.Intakenext100.P52.PrepGate

For any type VVV, this defines an inductive type with exactly two constructors: an object h(v)h(v)h(v) for each v∈Vv\in Vv∈V, and an object cz(v,w)\mathrm{cz}(v,w)cz(v,w) for each ordered pair v,w∈Vv,w\in Vv,w∈V. The second constructor permits v=wv=wv=w and imposes no adjacency condition. These constructors themselves specify no matrix action; if VVV is empty, the inductive type has no elements.

QAlgorithms.Papers.Independent.Intakenext100.P52.PrepGate.support

For any type VVV with decidable equality, this defines the support of a preparation gate as a finite subset of VVV: the gate h(v)\mathrm h(v)h(v) has support {v}\{v\}{v}, and the gate cz(v,w)\mathrm{cz}(v,w)cz(v,w) has support {v,w}\{v,w\}{v,w}. No condition requires v≠wv\ne wv=w; when v=wv=wv=w, the latter support is the singleton {v}\{v\}{v}.

QAlgorithms.Papers.Independent.Intakenext100.P52.QubitPair

This abbreviates the set of ordered pairs of Boolean values, {false,true}×{false,true}\{\mathrm{false},\mathrm{true}\}\times\{\mathrm{false},\mathrm{true}\}{false,true}×{false,true}.

QAlgorithms.Papers.Independent.Intakenext100.P52.RectangularSites

For any natural numbers rrr and ccc, including zero, this abbreviates the type of pairs (i,j)(i,j)(i,j) of natural-number indices satisfying 0≤i<r0\le i<r0≤i<r and 0≤j<c0\le j<c0≤j<c. It is empty if either r=0r=0r=0 or c=0c=0c=0.

QAlgorithms.Papers.Independent.Intakenext100.P52.ScalarInstruction.eval

For any type III, input data data:I→C\mathrm{data}:I\to\mathbb Cdata:I→C, and finite list memory\mathrm{memory}memory of complex numbers, this function assigns a complex value to each scalar instruction as follows: an input instruction with label iii returns data(i)\mathrm{data}(i)data(i); a constant instruction with value ccc returns ccc; an addition instruction with indices a,b∈Na,b\in\mathbb Na,b∈N returns memorya+memoryb\mathrm{memory}_a+\mathrm{memory}_bmemorya​+memoryb​; a multiplication instruction returns memoryamemoryb\mathrm{memory}_a\mathrm{memory}_bmemorya​memoryb​; and a conjugation instruction with index aaa returns memorya‾\overline{\mathrm{memory}_a}memorya​​. List indices start at 000, and every entry requested outside the list is replaced by 000. No restriction on the indices or the memory list is assumed.

QAlgorithms.Papers.Independent.Intakenext100.P52.ScalarInstruction

For every type III, this defines a type of scalar instructions with exactly five forms: an input instruction carrying a label i∈Ii\in Ii∈I; a constant instruction carrying any complex number ccc; an addition instruction carrying two natural-number indices a,ba,ba,b; a multiplication instruction carrying two natural-number indices a,ba,ba,b; and a conjugation instruction carrying one natural-number index aaa. These constructors impose no bounds on the indices, allow repeated indices, and specify no evaluation rule by themselves; the type III may be empty.

QAlgorithms.Papers.Independent.Intakenext100.P52.ScalarInstruction.readsBefore

For every type III, every natural number ttt, and every scalar instruction whose input labels belong to III, this defines a proposition as follows: an input instruction carrying any i∈Ii\in Ii∈I or a constant instruction carrying any c∈Cc\in\mathbb Cc∈C always satisfies it; an addition or multiplication instruction carrying indices a,b∈Na,b\in\mathbb Na,b∈N satisfies it exactly when a<ta<ta<t and b<tb<tb<t; and a conjugation instruction carrying a∈Na\in\mathbb Na∈N satisfies it exactly when a<ta<ta<t. In particular, at t=0t=0t=0 only input and constant instructions satisfy the proposition.

QAlgorithms.Papers.Independent.Intakenext100.P52.ScalarProgram.Valid

For any type III and scalar program PPP with instruction list word\mathrm{word}word and natural-number output index output\mathrm{output}output, validity means that output<∣word∣\mathrm{output}<|\mathrm{word}|output<∣word∣ and that every instruction at position t<∣word∣t<|\mathrm{word}|t<∣word∣ reads only memory indices strictly less than ttt. More explicitly, input and complex-constant instructions satisfy the latter condition automatically; addition and multiplication instructions with indices a,ba,ba,b require a<ta<ta<t and b<tb<tb<t; and a conjugation instruction with index aaa requires a<ta<ta<t. Thus an empty instruction list cannot be valid, and the instruction at position 000 in a valid program must be an input or a constant instruction.

QAlgorithms.Papers.Independent.Intakenext100.P52.ScalarProgram.eval

For any type III, scalar program PPP, and input data data:I→C\mathrm{data}:I\to\mathbb Cdata:I→C, evaluation starts with an empty memory list and processes the instructions of P.wordP.\mathrm{word}P.word in their listed order, appending each instruction’s value to memory. Input instructions return the corresponding data value, constants return their complex value, addition and multiplication use the two specified memory entries, and conjugation uses the complex conjugate of the specified entry; every unavailable memory entry is interpreted as 000. After all instructions have been processed, evaluation returns the entry at the zero-based index P.outputP.\mathrm{output}P.output, or 000 if that index is outside the final memory list. Validity of PPP is not assumed, so this also defines evaluation for empty programs and programs with unavailable references.

QAlgorithms.Papers.Independent.Intakenext100.P52.ScalarProgram

For any type III, a scalar program consists of a finite list word\mathrm{word}word of instructions and a natural number output\mathrm{output}output. Each instruction either reads input data at a label in III, supplies a complex constant, adds or multiplies values at two natural-number memory indices, or conjugates the value at one such index. The structure imposes no condition that referenced memory entries already exist or that output\mathrm{output}output is a valid index; in particular, the instruction list may be empty.

QAlgorithms.Papers.Independent.Intakenext100.P52.angleSign

For each Boolean sss, this defines the real number angleSign⁡(s)\operatorname{angleSign}(s)angleSign(s) to be −1-1−1 when sss is true and 111 when sss is false.

QAlgorithms.Papers.Independent.Intakenext100.P52.bellPauliRepresentative

For an index a∈{0,1,2,3}a\in\{0,1,2,3\}a∈{0,1,2,3}, this defines a complex matrix indexed by Booleans by selecting, respectively, I2,X,Z,XZI_2,X,Z,XZI2​,X,Z,XZ, where, in the coordinate order false, true,

X=(0110),Z=(100−1).X=\begin{pmatrix}0&1\\1&0\end{pmatrix}, \qquad Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix}.X=(01​10​),Z=(10​0−1​).

QAlgorithms.Papers.Independent.Intakenext100.P52.bondGrid

For any type VVV with decidable equality and any finite set E⊆V×VE\subseteq V\times VE⊆V×V, this defines a complex vector indexed by functions w:E×{0,1}→{0,1}w:E\times\{0,1\}\to\{0,1\}w:E×{0,1}→{0,1}, with one pair of bit positions for each ordered pair in EEE, by

BE(w)=∏e∈Eh(w(e,0),w(e,1))=∏e∈E(−1)w(e,0)w(e,1)2.B_E(w)=\prod_{e\in E}h\bigl(w(e,0),w(e,1)\bigr) =\prod_{e\in E}\frac{(-1)^{w(e,0)w(e,1)}}2.BE​(w)=e∈E∏​h(w(e,0),w(e,1))=e∈E∏​2(−1)w(e,0)w(e,1)​.

Here h(a,b)=(−1)ab/2h(a,b)=(-1)^{ab}/2h(a,b)=(−1)ab/2 is the vector obtained by applying the diagonal sign (−1)ab(-1)^{ab}(−1)ab to (∣0⟩+∣1⟩)⊗2/2(|0\rangle+|1\rangle)^{\otimes2}/2(∣0⟩+∣1⟩)⊗2/2. No finiteness assumption is imposed on VVV, and no restriction excludes equal endpoints or opposite orientations in EEE. When E=∅E=\varnothingE=∅, there is a single indexing function and its component is the empty product 111.

QAlgorithms.Papers.Independent.Intakenext100.P52.cutDownFormula

For every real θ\thetaθ and label a∈{0,1,2,3}a\in\{0,1,2,3\}a∈{0,1,2,3}, this defines a complex vector on ordered bit pairs, with 0=false0=\mathrm{false}0=false and 1=true1=\mathrm{true}1=true, by the four formulas

Φθ,0=∣00⟩+eiθ∣11⟩2,Φθ,1=∣00⟩−eiθ∣11⟩2,Φθ,2=∣01⟩+eiθ∣10⟩2,Φθ,3=∣01⟩−eiθ∣10⟩2,\Phi_{\theta,0}=\frac{|00\rangle+e^{i\theta}|11\rangle}{\sqrt2}, \qquad \Phi_{\theta,1}=\frac{|00\rangle-e^{i\theta}|11\rangle}{\sqrt2}, \qquad \Phi_{\theta,2}=\frac{|01\rangle+e^{i\theta}|10\rangle}{\sqrt2}, \qquad \Phi_{\theta,3}=\frac{|01\rangle-e^{i\theta}|10\rangle}{\sqrt2},Φθ,0​=2​∣00⟩+eiθ∣11⟩​,Φθ,1​=2​∣00⟩−eiθ∣11⟩​,Φθ,2​=2​∣01⟩+eiθ∣10⟩​,Φθ,3​=2​∣01⟩−eiθ∣10⟩​,

where ∣xy⟩|xy\rangle∣xy⟩ denotes the coordinate vector supported at (x,y)(x,y)(x,y).

QAlgorithms.Papers.Independent.Intakenext100.P52.cutDownKet

For every real angle θ\thetaθ and label a∈{0,1,2,3}a\in\{0,1,2,3\}a∈{0,1,2,3}, this defines a complex vector on ordered pairs of bits by

Kθ,a=((W(−θ)†Ba)⊗I2)h,W(t)=Hdiag⁡(1,eit),(B0,B1,B2,B3)=(I2,X,Z,XZ),K_{\theta,a}=\bigl((W(-\theta)^\dagger B_a)\otimes I_2\bigr)h, \qquad W(t)=H\operatorname{diag}(1,e^{it}),\quad (B_0,B_1,B_2,B_3)=(I_2,X,Z,XZ),Kθ,a​=((W(−θ)†Ba​)⊗I2​)h,W(t)=Hdiag(1,eit),(B0​,B1​,B2​,B3​)=(I2​,X,Z,XZ),

where bits are ordered as 0=false0=\mathrm{false}0=false and 1=true1=\mathrm{true}1=true,

H=12(111−1),X=(0110),Z=(100−1),h=12(∣00⟩+∣01⟩+∣10⟩−∣11⟩).H=\frac1{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}, \quad X=\begin{pmatrix}0&1\\1&0\end{pmatrix}, \quad Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix}, \quad h=\frac12\bigl(|00\rangle+|01\rangle+|10\rangle-|11\rangle\bigr).H=2​1​(11​1−1​),X=(01​10​),Z=(10​0−1​),h=21​(∣00⟩+∣01⟩+∣10⟩−∣11⟩).

Here †\dagger† denotes conjugate transpose, matrix action is ordinary matrix multiplication on vectors, and ∣xy⟩|xy\rangle∣xy⟩ is the coordinate vector supported at the bit pair (x,y)(x,y)(x,y).

QAlgorithms.Papers.Independent.Intakenext100.P52.cxWires

For every finite type VVV equipped with decidable equality and every choice of control,target∈V\mathrm{control},\mathrm{target}\in Vcontrol,target∈V, this defines a complex matrix indexed by Boolean assignments y,z:V→{0,1}y,z:V\to\{0,1\}y,z:V→{0,1}. Its entry at (y,z)(y,z)(y,z) is 111 exactly when yyy agrees with zzz everywhere except possibly at the target and

ytarget=ztarget⊕zcontrol,y_{\mathrm{target}} =z_{\mathrm{target}}\mathbin{\oplus}z_{\mathrm{control}},ytarget​=ztarget​⊕zcontrol​,

and is 000 otherwise. The control and target are permitted to coincide; in that case the target bit becomes false. If VVV is empty, there are no choices of control and target.

QAlgorithms.Papers.Independent.Intakenext100.P52.czPhase

For any Boolean values aaa and bbb, this defines a complex number equal to −1-1−1 when both aaa and bbb are true, and equal to 111 otherwise.

QAlgorithms.Papers.Independent.Intakenext100.P52.czTeleportGate

For any Boolean pairs a=(a1,a2)a=(a_1,a_2)a=(a1​,a2​) and b=(b1,b2)b=(b_1,b_2)b=(b1​,b2​), this defines the complex matrix on the space indexed by Boolean pairs to be

Ga,b=(Xa1Za2⊗Xb1Zb2) CZ,G_{a,b}=(X^{a_1}Z^{a_2}\otimes X^{b_1}Z^{b_2})\,C_Z,Ga,b​=(Xa1​Za2​⊗Xb1​Zb2​)CZ​,

where a Boolean exponent is 000 for false and 111 for true, X=(0110)X=\begin{pmatrix}0&1\\1&0\end{pmatrix}X=(01​10​), Z=diag⁡(1,−1)Z=\operatorname{diag}(1,-1)Z=diag(1,−1), and CZC_ZCZ​ is diagonal with entry −1-1−1 at the Boolean pair (true, true) and entry 111 at every other Boolean pair.

QAlgorithms.Papers.Independent.Intakenext100.P52.deletedEdges

For any finite type VVV with decidable equality, any finite set E⊆V×VE\subseteq V\times VE⊆V×V, and any A∈VA\in VA∈V, this defines the finite set

{(u,v)∈(V∖{A})×(V∖{A}):(u,v)∈E}.\{(u,v)\in (V\setminus\{A\})\times(V\setminus\{A\}):(u,v)\in E\}.{(u,v)∈(V∖{A})×(V∖{A}):(u,v)∈E}.

Membership in EEE uses the underlying elements of VVV. There are no symmetry or loop restrictions, and the resulting set may be empty.

QAlgorithms.Papers.Independent.Intakenext100.P52.edgePhase

For any type VVV with decidable equality, any finite set E⊆V×VE\subseteq V\times VE⊆V×V, and any Boolean assignment z:V→{false,true}z:V\to\{\mathrm{false},\mathrm{true}\}z:V→{false,true}, this defines

∏(u,v)∈E{−1,z(u)=z(v)=true,1,otherwise.\prod_{(u,v)\in E} \begin{cases} -1,&z(u)=z(v)=\mathrm{true},\\ 1,&\text{otherwise}. \end{cases}(u,v)∈E∏​{−1,1,​z(u)=z(v)=true,otherwise.​

No symmetry or exclusion of loops is required of EEE: a loop (v,v)(v,v)(v,v) contributes −1-1−1 precisely when z(v)z(v)z(v) is true, and (u,v)(u,v)(u,v) and (v,u)(v,u)(v,u) contribute separately if both belong to EEE. For E=∅E=\varnothingE=∅, the value is 111.

QAlgorithms.Papers.Independent.Intakenext100.P52.equatorial

For every real number θ\thetaθ and Boolean value sss, this defines the vector in the Euclidean space indexed by Boolean values

12(∣0⟩+(−1)sˉeiθ∣1⟩),\frac1{\sqrt2}\bigl(|0\rangle+(-1)^{\bar s}e^{i\theta}|1\rangle\bigr),2​1​(∣0⟩+(−1)sˉeiθ∣1⟩),

where ∣0⟩|0\rangle∣0⟩ and ∣1⟩|1\rangle∣1⟩ are the coordinate basis vectors at false and true, respectively, and sˉ=0\bar s=0sˉ=0 when sss is false and sˉ=1\bar s=1sˉ=1 when sss is true.

QAlgorithms.Papers.Independent.Intakenext100.P52.figure12Branch

For any bits c,dc,dc,d and any complex vector ψ\psiψ indexed by bits, let Fψ(a,t,b)=ψ(a)/2F_\psi(a,t,b)=\psi(a)/\sqrt2Fψ​(a,t,b)=ψ(a)/2​ when t=0t=0t=0, and 000 otherwise, identifying false and true with 000 and 111. Let Ci→jC_{i\to j}Ci→j​ be the permutation matrix that replaces bit jjj by its exclusive-or with bit iii and leaves the other bits unchanged, and set v=C0→1C2→1Fψv=C_{0\to1}C_{2\to1}F_\psiv=C0→1​C2→1​Fψ​, with matrix products acting from right to left. The defined vector has components

(figure12Branch⁡(c,d,ψ))b=∑a∈{0,1}ec(a)‾ v(a,d,b),ec(a)=(−1)ca2.\bigl(\operatorname{figure12Branch}(c,d,\psi)\bigr)_b =\sum_{a\in\{0,1\}}\overline{e_c(a)}\,v(a,d,b), \qquad e_c(a)=\frac{(-1)^{ca}}{\sqrt2}.(figure12Branch(c,d,ψ))b​=a∈{0,1}∑​ec​(a)​v(a,d,b),ec​(a)=2​(−1)ca​.

Equivalently, its component at bbb is 12(−1)c(b⊕d)ψ(b⊕d)\frac12(-1)^{c(b\oplus d)}\psi(b\oplus d)21​(−1)c(b⊕d)ψ(b⊕d), where ⊕\oplus⊕ denotes exclusive-or. No normalization assumption is imposed on ψ\psiψ.

QAlgorithms.Papers.Independent.Intakenext100.P52.figure12Input

For every complex vector ψ\psiψ indexed by {false,true}\{\mathrm{false},\mathrm{true}\}{false,true}, this defines a vector FψF_\psiFψ​ indexed by three-bit strings by

Fψ(z0,z1,z2)={ψ(z0)/2,z1=false,0,z1=true.F_\psi(z_0,z_1,z_2)= \begin{cases} \psi(z_0)/\sqrt2,&z_1=\mathrm{false},\\ 0,&z_1=\mathrm{true}. \end{cases}Fψ​(z0​,z1​,z2​)={ψ(z0​)/2​,0,​z1​=false,z1​=true.​

Thus Fψ=ψ⊗∣0⟩⊗(∣0⟩+∣1⟩)/2F_\psi=\psi\otimes|0\rangle\otimes (|0\rangle+|1\rangle)/\sqrt2Fψ​=ψ⊗∣0⟩⊗(∣0⟩+∣1⟩)/2​, where ∣0⟩|0\rangle∣0⟩ and ∣1⟩|1\rangle∣1⟩ are the coordinate unit vectors for false and true. No normalization or nonzero assumption is imposed on ψ\psiψ.

QAlgorithms.Papers.Independent.Intakenext100.P52.figure3Branch

For any outcomes a=(a0,a1)a=(a_0,a_1)a=(a0​,a1​) and b=(b0,b1)b=(b_0,b_1)b=(b0​,b1​), where a0,b0∈{0,1,2,3}a_0,b_0\in\{0,1,2,3\}a0​,b0​∈{0,1,2,3} and a1,b1a_1,b_1a1​,b1​ are Boolean, and any complex two-bit vector ψ\psiψ, this defines a two-bit vector va,b,ψv_{a,b,\psi}va,b,ψ​. Identify Boolean values with 0,10,10,1, put r0=000r_0=000r0​=000, r1=001r_1=001r1​=001, r2=010r_2=010r2​=010, r3=100r_3=100r3​=100, and define βj,s(t)\beta_{j,s}(t)βj,s​(t) to be 1/21/\sqrt21/2​ when t=rjt=r_jt=rj​, (−1)s/2(-1)^s/\sqrt2(−1)s/2​ when ttt is the bitwise complement of rjr_jrj​, and 000 otherwise. Then

va,b,ψ(y)=18∑z∈{0,1}8$z6,z7)=yβa0,a1(z0,z2,z4)‾ βb0,b1(z1,z3,z5)‾ ψ(z0,z1)(−1)z2z3+z4z6+z5z7.v_{a,b,\psi}(y)=\frac18 \sum_{\substack{z\in\{0,1\}^8\$z_6,z_7)=y}} \overline{\beta_{a_0,a_1}(z_0,z_2,z_4)} \,\overline{\beta_{b_0,b_1}(z_1,z_3,z_5)} \,\psi(z_0,z_1)(-1)^{z_2z_3+z_4z_6+z_5z_7}.va,b,ψ​(y)=81​z∈{0,1}8$z6​,z7​)=y​∑​βa0​,a1​​(z0​,z2​,z4​)​βb0​,b1​​(z1​,z3​,z5​)​ψ(z0​,z1​)(−1)z2​z3​+z4​z6​+z5​z7​.

Neither normalization of (\psi$ nor nonvanishing of the resulting vector is required.

QAlgorithms.Papers.Independent.Intakenext100.P52.figure3Resource

For any complex vector ψ\psiψ indexed by pairs of Boolean values, this defines a vector RψR_\psiRψ​ indexed by eight-bit strings z=(z0,…,z7)z=(z_0,\ldots,z_7)z=(z0​,…,z7​). Identifying false with 000 and true with 111, its coordinates are

Rψ(z)=18 ψ(z0,z1)(−1)z2z3+z4z6+z5z7.R_\psi(z)=\frac18\,\psi(z_0,z_1)(-1)^{z_2z_3+z_4z_6+z_5z_7}.Rψ​(z)=81​ψ(z0​,z1​)(−1)z2​z3​+z4​z6​+z5​z7​.

Each of the three factors represented here by 1/21/21/2 times a sign is the two-bit vector whose coordinate at (u,v)(u,v)(u,v) is 12(−1)uv\frac12(-1)^{uv}21​(−1)uv. No normalization assumption is imposed on ψ\psiψ.

QAlgorithms.Papers.Independent.Intakenext100.P52.figure5Angles

For arbitrary real numbers ξ,η,ζ\xi,\eta,\zetaξ,η,ζ and a Boolean sequence s0,s1,s2,s3s_0,s_1,s_2,s_3s0​,s1​,s2​,s3​, this defines the four real angles

(0,  −2ξ σ(s0),  −2η σ(s1),  −2ζ σ(s0⊕s2)),\left( 0,\; -2\xi\,\sigma(s_0),\; -2\eta\,\sigma(s_1),\; -2\zeta\,\sigma(s_0\mathbin{\oplus}s_2) \right),(0,−2ξσ(s0​),−2ησ(s1​),−2ζσ(s0​⊕s2​)),

where σ(false)=1\sigma(\mathrm{false})=1σ(false)=1, σ(true)=−1\sigma(\mathrm{true})=-1σ(true)=−1, and ⊕\oplus⊕ is Boolean exclusive-or. The value of s3s_3s3​ does not enter the definition.

QAlgorithms.Papers.Independent.Intakenext100.P52.figure8Basis

For any grid site v=(r,c)v=(r,c)v=(r,c) other than (0,2)(0,2)(0,2) and (3,2)(3,2)(3,2), and any Boolean outcome sss, this defines a vector indexed by a Boolean value bbb. Identifying Boolean values with 0,10,10,1, its amplitude is

Bv,s(b)={2−1/2(−1)sb,c=0 or r=0 or r=3,1,otherwise and b=s,0,otherwise and b≠s.B_{v,s}(b)= \begin{cases} 2^{-1/2}(-1)^{sb},&c=0\ \text{or}\ r=0\ \text{or}\ r=3,\\ 1,&\text{otherwise and }b=s,\\ 0,&\text{otherwise and }b\ne s. \end{cases}Bv,s​(b)=⎩⎨⎧​2−1/2(−1)sb,1,0,​c=0 or r=0 or r=3,otherwise and b=s,otherwise and b=s.​

Thus the first case is (∣0⟩+(−1)s∣1⟩)/2(|0\rangle+(-1)^s|1\rangle)/\sqrt2(∣0⟩+(−1)s∣1⟩)/2​, and the remaining case is ∣s⟩|s\rangle∣s⟩.

QAlgorithms.Papers.Independent.Intakenext100.P52.figure8Branch

Let V={0,1,2,3}×{0,1,2}V=\{0,1,2,3\}\times\{0,1,2\}V={0,1,2,3}×{0,1,2}, let M=V∖{(0,2),(3,2)}M=V\setminus\{(0,2),(3,2)\}M=V∖{(0,2),(3,2)}, and let EEE contain each grid edge directed toward increasing row or increasing column. For any Boolean assignment s:M→{0,1}s:M\to\{0,1\}s:M→{0,1} and any complex two-bit vector ψ\psiψ, this defines the two-bit vector

vs,ψ(y)=132∑z:V→{0,1}(z(0,2),z(3,2))=y(∏v∈MBv,s(v)(zv)‾)ψ(z(0,0),z(3,0))(−1)∑(u,v)∈Ezuzv,v_{s,\psi}(y)=\frac1{32} \sum_{\substack{z:V\to\{0,1\}\\ (z_{(0,2)},z_{(3,2)})=y}} \left(\prod_{v\in M}\overline{B_{v,s(v)}(z_v)}\right) \psi(z_{(0,0)},z_{(3,0)}) (-1)^{\sum_{(u,v)\in E}z_u z_v},vs,ψ​(y)=321​z:V→{0,1}(z(0,2)​,z(3,2)​)=y​∑​(v∈M∏​Bv,s(v)​(zv​)​)ψ(z(0,0)​,z(3,0)​)(−1)∑(u,v)∈E​zu​zv​,

where Boolean values are identified with 0,10,10,1, and B(r,c),s(b)=2−1/2(−1)sbB_{(r,c),s}(b)=2^{-1/2}(-1)^{sb}B(r,c),s​(b)=2−1/2(−1)sb if c=0c=0c=0, r=0r=0r=0, or r=3r=3r=3, while otherwise B(r,c),s(b)B_{(r,c),s}(b)B(r,c),s​(b) is 111 for b=sb=sb=s and 000 for b≠sb\ne sb=s. Neither normalization of ψ\psiψ nor nonvanishing of the resulting vector is assumed.

QAlgorithms.Papers.Independent.Intakenext100.P52.figure8Output

This defines a function from Boolean values to sites of the grid {0,1,2,3}×{0,1,2}\{0,1,2,3\}\times\{0,1,2\}{0,1,2,3}×{0,1,2}: false is sent to (0,2)(0,2)(0,2), and true is sent to (3,2)(3,2)(3,2).

QAlgorithms.Papers.Independent.Intakenext100.P52.figure8Resource

For any complex two-bit vector ψ\psiψ, this defines a vector RψR_\psiRψ​ indexed by Boolean assignments zzz to the grid V={0,1,2,3}×{0,1,2}V=\{0,1,2,3\}\times\{0,1,2\}V={0,1,2,3}×{0,1,2}. Identify Boolean values with 0,10,10,1, and let EEE consist of the directed pairs ((r,c),(r+1,c))((r,c),(r+1,c))((r,c),(r+1,c)) for 0≤r<3, 0≤c<30\le r<3,\ 0\le c<30≤r<3, 0≤c<3, together with ((r,c),(r,c+1))((r,c),(r,c+1))((r,c),(r,c+1)) for 0≤r<4, 0≤c<20\le r<4,\ 0\le c<20≤r<4, 0≤c<2. Its coordinates are

Rψ(z)=132 ψ(z(0,0),z(3,0))(−1)∑(u,v)∈Ezuzv.R_\psi(z)=\frac1{32}\, \psi\bigl(z_{(0,0)},z_{(3,0)}\bigr) (-1)^{\sum_{(u,v)\in E}z_u z_v}.Rψ​(z)=321​ψ(z(0,0)​,z(3,0)​)(−1)∑(u,v)∈E​zu​zv​.

No normalization assumption is imposed on ψ\psiψ.

QAlgorithms.Papers.Independent.Intakenext100.P52.fuse

This defines the complex matrix FFF with rows indexed by bits and columns indexed by ordered pairs of bits by

Fb,(u,v)={1,u=b and v=b,0,otherwise.F_{b,(u,v)}= \begin{cases} 1,&u=b\text{ and }v=b,\\ 0,&\text{otherwise}. \end{cases}Fb,(u,v)​={1,0,​u=b and v=b,otherwise.​

Consequently, its action sends ∣0,0⟩|0,0\rangle∣0,0⟩ to ∣0⟩|0\rangle∣0⟩, sends ∣1,1⟩|1,1\rangle∣1,1⟩ to ∣1⟩|1\rangle∣1⟩, and sends the other two coordinate unit vectors to zero.

QAlgorithms.Papers.Independent.Intakenext100.P52.fusionResource

For arbitrary complex vectors ψ1,ψ2\psi_1,\psi_2ψ1​,ψ2​ indexed by bits, identify bits with 0,10,10,1 and set h(u,v)=(−1)uv/2h(u,v)=(-1)^{uv}/2h(u,v)=(−1)uv/2. This defines a vector η\etaη indexed by two ordered pairs of bits through

η((u,a),(v,b))=h(u,v)ψ1(a)ψ2(b)=(−1)uv2 ψ1(a)ψ2(b).\eta\bigl((u,a),(v,b)\bigr) =h(u,v)\psi_1(a)\psi_2(b) =\frac{(-1)^{uv}}2\,\psi_1(a)\psi_2(b).η((u,a),(v,b))=h(u,v)ψ1​(a)ψ2​(b)=2(−1)uv​ψ1​(a)ψ2​(b).

The factor hhh is the vector obtained by applying the diagonal sign (−1)uv(-1)^{uv}(−1)uv to (∣0⟩+∣1⟩)⊗2/2(|0\rangle+|1\rangle)^{\otimes2}/2(∣0⟩+∣1⟩)⊗2/2. No normalization assumptions are made on either input vector.

QAlgorithms.Papers.Independent.Intakenext100.P52.ghzSeed

This defines a three-bit string for each a∈{0,1,2,3}a\in\{0,1,2,3\}a∈{0,1,2,3}, with coordinates ordered 0,1,20,1,20,1,2: the values at a=0,1,2,3a=0,1,2,3a=0,1,2,3 are respectively (false,false,false)(\mathrm{false},\mathrm{false},\mathrm{false})(false,false,false), (false,false,true)(\mathrm{false},\mathrm{false},\mathrm{true})(false,false,true), (false,true,false)(\mathrm{false},\mathrm{true},\mathrm{false})(false,true,false), and (true,false,false)(\mathrm{true},\mathrm{false},\mathrm{false})(true,false,false).

QAlgorithms.Papers.Independent.Intakenext100.P52.graphClusterState

For any finite type VVV with decidable equality and any finite set E⊆V×VE\subseteq V\times VE⊆V×V, this defines a complex Euclidean vector indexed by Boolean assignments z:V→{false,true}z:V\to\{\mathrm{false},\mathrm{true}\}z:V→{false,true}, whose coordinate at zzz is

(12)∣V∣∏(u,v)∈E{−1,z(u)=z(v)=true,1,otherwise.\left(\frac1{\sqrt2}\right)^{|V|} \prod_{(u,v)\in E} \begin{cases} -1,&z(u)=z(v)=\mathrm{true},\\ 1,&\text{otherwise}. \end{cases}(2​1​)∣V∣(u,v)∈E∏​{−1,1,​z(u)=z(v)=true,otherwise.​

The set EEE may contain loops and both orientations of a pair, with each listed ordered pair contributing its own factor. When EEE is empty the product is 111; when VVV is empty, there is one Boolean assignment and its coordinate is 111.

QAlgorithms.Papers.Independent.Intakenext100.P52.gridEdges

For any natural numbers rrr and ccc, this defines the finite set of ordered pairs of sites

Er,c={((i,j),(i′,j′)): 0≤i,i′<r, 0≤j,j′<c, (i+1=i′ ∧ j=j′) ∨ (i=i′ ∧ j+1=j′)}.E_{r,c}= \bigl\{((i,j),(i',j')):\ 0\le i,i'<r,\ 0\le j,j'<c,\ (i+1=i'\ \land\ j=j')\ \lor\ (i=i'\ \land\ j+1=j')\bigr\}.Er,c​={((i,j),(i′,j′)): 0≤i,i′<r, 0≤j,j′<c, (i+1=i′ ∧ j=j′) ∨ (i=i′ ∧ j+1=j′)}.

Thus only pairs increasing exactly one coordinate by one are included; their reverse orientations are not included by this definition. The set is empty if either dimension is zero.

QAlgorithms.Papers.Independent.Intakenext100.P52.hBell

For every pair of bits c,dc,dc,d, identify bits with 0,10,10,1, let X∣a⟩=∣a⊕1⟩X|a\rangle=|a\oplus1\rangleX∣a⟩=∣a⊕1⟩ and Z∣a⟩=(−1)a∣a⟩Z|a\rangle=(-1)^a|a\rangleZ∣a⟩=(−1)a∣a⟩, and define

h=12∑a,b∈{0,1}(−1)ab∣a,b⟩.h=\frac12\sum_{a,b\in\{0,1\}}(-1)^{ab}|a,b\rangle.h=21​a,b∈{0,1}∑​(−1)ab∣a,b⟩.

The defined vector is hcd=(XdZc⊗I)hh_{cd}=(X^dZ^c\otimes I)hhcd​=(XdZc⊗I)h: the matrix XdZcX^dZ^cXdZc acts on the first bit and the identity acts on the second. Here hhh is exactly the result of applying the diagonal matrix ∣a,b⟩↦(−1)ab∣a,b⟩|a,b\rangle\mapsto(-1)^{ab}|a,b\rangle∣a,b⟩↦(−1)ab∣a,b⟩ to (∣0⟩+∣1⟩)⊗2/2(|0\rangle+|1\rangle)^{\otimes2}/2(∣0⟩+∣1⟩)⊗2/2.

QAlgorithms.Papers.Independent.Intakenext100.P52.hBond

This defines the vector in the Euclidean space indexed by Boolean pairs

12(∣00⟩+∣01⟩+∣10⟩−∣11⟩),\frac12\bigl(|00\rangle+|01\rangle+|10\rangle-|11\rangle\bigr),21​(∣00⟩+∣01⟩+∣10⟩−∣11⟩),

where false and true are written as 000 and 111, and ∣ab⟩|ab\rangle∣ab⟩ is the coordinate basis vector at (a,b)(a,b)(a,b). It is obtained by applying the diagonal matrix with entries 1,1,1,−11,1,1,-11,1,1,−1 to the tensor product of two copies of (∣0⟩+∣1⟩)/2(|0\rangle+|1\rangle)/\sqrt2(∣0⟩+∣1⟩)/2​.

QAlgorithms.Papers.Independent.Intakenext100.P52.insertSite

For any type VVV with decidable equality, any site A∈VA\in VA∈V, any Boolean value sss, and any Boolean assignment zzz on {v∈V:v≠A}\{v\in V:v\ne A\}{v∈V:v=A}, this defines the assignment on all of VVV whose value is sss at AAA and z(v)z(v)z(v) at every v≠Av\ne Av=A.

QAlgorithms.Papers.Independent.Intakenext100.P52.ladderEvent

For every natural number mmm, every bit-valued function measured\mathrm{measured}measured on {0,…,m}\{0,\ldots,m\}{0,…,m}, and every family of complex two-coordinate vectors viv_ivi​, this defines a matrix indexed by (m+1)(m+1)(m+1)-bit strings through

Ey,z=∏i=0m{vi(yi)vi(zi)‾,measured(i)=true,1,measured(i)=false and yi=zi,0,measured(i)=false and yi≠zi.E_{y,z}=\prod_{i=0}^{m} \begin{cases} v_i(y_i)\overline{v_i(z_i)},&\mathrm{measured}(i)=\mathrm{true},\\ 1,&\mathrm{measured}(i)=\mathrm{false}\text{ and }y_i=z_i,\\ 0,&\mathrm{measured}(i)=\mathrm{false}\text{ and }y_i\ne z_i. \end{cases}Ey,z​=i=0∏m​⎩⎨⎧​vi​(yi​)vi​(zi​)​,1,0,​measured(i)=true,measured(i)=false and yi​=zi​,measured(i)=false and yi​=zi​.​

Thus each selected coordinate contributes ∣vi⟩⟨vi∣|v_i\rangle\langle v_i|∣vi​⟩⟨vi​∣, and each unselected coordinate contributes the identity. The vectors viv_ivi​ need not be normalized, so the definition does not require this matrix to be a projector or an effect. The case m=0m=0m=0 still has one coordinate.

QAlgorithms.Papers.Independent.Intakenext100.P52.ladderScalarData

For every natural number mmm, every family UtU_tUt​ of complex matrices indexed by Boolean pairs, with 0≤t<m0\le t<m0≤t<m, and every family vtv_tvt​ of complex Euclidean vectors indexed by a Boolean, with 0≤t≤m0\le t\le m0≤t≤m, this function supplies complex scalar data on the disjoint-union label type: a label (t,a,b)(t,a,b)(t,a,b) from the first summand returns the matrix entry Ut(a,b)U_t(a,b)Ut​(a,b), while a label (t,a)(t,a)(t,a) from the second summand returns the vector coordinate vt(a)v_t(a)vt​(a). No unitarity or normalization is required. For m=0m=0m=0, only the coordinates of v0v_0v0​ occur.

QAlgorithms.Papers.Independent.Intakenext100.P52.ladderScan

For every natural number mmm, every family of complex bit-pair matrices U0,…,Um−1U_0,\ldots,U_{m-1}U0​,…,Um−1​, every bit-valued selection function on {0,…,m}\{0,\ldots,m\}{0,…,m}, and every family of complex two-coordinate vectors v0,…,vmv_0,\ldots,v_mv0​,…,vm​, this defines a single-bit matrix ρm\rho_mρm​ recursively, starting from ρ0=∣0⟩⟨0∣\rho_0=|0\rangle\langle0|ρ0​=∣0⟩⟨0∣ with 0=false0=\mathrm{false}0=false. For t=0,…,m−1t=0,\ldots,m-1t=0,…,m−1, set Σt=Ut(ρt⊗∣0⟩⟨0∣)Ut†\Sigma_t=U_t(\rho_t\otimes|0\rangle\langle0|)U_t^\daggerΣt​=Ut​(ρt​⊗∣0⟩⟨0∣)Ut†​ and then

(ρt+1)b,c={∑a,d∈{0,1}vt(a)‾ (Σt)(a,b),(d,c) vt(d),measured(t)=true,∑a∈{0,1}(Σt)(a,b),(a,c),measured(t)=false.(\rho_{t+1})_{b,c}= \begin{cases} \displaystyle\sum_{a,d\in\{0,1\}}\overline{v_t(a)}\,(\Sigma_t)_{(a,b),(d,c)}\,v_t(d), &\mathrm{measured}(t)=\mathrm{true},\\[2mm] \displaystyle\sum_{a\in\{0,1\}}(\Sigma_t)_{(a,b),(a,c)}, &\mathrm{measured}(t)=\mathrm{false}. \end{cases}(ρt+1​)b,c​=⎩⎨⎧​a,d∈{0,1}∑​vt​(a)​(Σt​)(a,b),(d,c)​vt​(d),a∈{0,1}∑​(Σt​)(a,b),(a,c)​,​measured(t)=true,measured(t)=false.​

The value is ρm\rho_mρm​; selection and vector data at coordinate mmm are unused here. No unitarity or vector normalization assumptions are made, and no intermediate trace normalization occurs. For m=0m=0m=0, the result is ∣0⟩⟨0∣|0\rangle\langle0|∣0⟩⟨0∣.

QAlgorithms.Papers.Independent.Intakenext100.P52.ladderScanProbability

For every natural number mmm, every family of complex bit-pair matrices UtU_tUt​ for 0≤t<m0\le t<m0≤t<m, every bit-valued function measured\mathrm{measured}measured on {0,…,m}\{0,\ldots,m\}{0,…,m}, and every family of complex two-coordinate vectors viv_ivi​, first form ρm\rho_mρm​ as follows: start at ρ0=∣0⟩⟨0∣\rho_0=|0\rangle\langle0|ρ0​=∣0⟩⟨0∣, set Σt=Ut(ρt⊗∣0⟩⟨0∣)Ut†\Sigma_t=U_t(\rho_t\otimes|0\rangle\langle0|)U_t^\daggerΣt​=Ut​(ρt​⊗∣0⟩⟨0∣)Ut†​, and define ρt+1(b,c)\rho_{t+1}(b,c)ρt+1​(b,c) to be ∑a,dvt(a)‾Σt((a,b),(d,c))vt(d)\sum_{a,d}\overline{v_t(a)}\Sigma_t((a,b),(d,c))v_t(d)∑a,d​vt​(a)​Σt​((a,b),(d,c))vt​(d) when coordinate ttt is selected, and ∑aΣt((a,b),(a,c))\sum_a\Sigma_t((a,b),(a,c))∑a​Σt​((a,b),(a,c)) otherwise, with all bit sums over {0,1}\{0,1\}{0,1} and 0=false0=\mathrm{false}0=false. This definition returns the real number

{Re⁡∑a,b∈{0,1}vm(a)‾ ρm(a,b) vm(b),measured(m)=true,Re⁡tr⁡(ρm),measured(m)=false.\begin{cases} \displaystyle\operatorname{Re}\sum_{a,b\in\{0,1\}} \overline{v_m(a)}\,\rho_m(a,b)\,v_m(b), &\mathrm{measured}(m)=\mathrm{true},\\[2mm] \operatorname{Re}\operatorname{tr}(\rho_m), &\mathrm{measured}(m)=\mathrm{false}. \end{cases}⎩⎨⎧​Rea,b∈{0,1}∑​vm​(a)​ρm​(a,b)vm​(b),Retr(ρm​),​measured(m)=true,measured(m)=false.​

The matrices need not be unitary and the vectors need not be normalized, so no restriction of this value to [0,1][0,1][0,1] is imposed. When m=0m=0m=0, it is ∣v0(0)∣2|v_0(0)|^2∣v0​(0)∣2 if coordinate 000 is selected and 111 otherwise.

QAlgorithms.Papers.Independent.Intakenext100.P52.ladderSigma

For every complex matrix UUU indexed by ordered bit pairs and every complex matrix ρ\rhoρ indexed by a single bit, this defines

Σ(U,ρ)=U(ρ⊗∣0⟩⟨0∣)U†,\Sigma(U,\rho)=U\bigl(\rho\otimes|0\rangle\langle0|\bigr)U^\dagger,Σ(U,ρ)=U(ρ⊗∣0⟩⟨0∣)U†,

where 0=false0=\mathrm{false}0=false, ∣0⟩|0\rangle∣0⟩ is its coordinate vector, and †\dagger† denotes conjugate transpose. Neither unitarity of UUU nor positivity or trace normalization of ρ\rhoρ is assumed.

QAlgorithms.Papers.Independent.Intakenext100.P52.ladderState

For every natural number mmm and every family of complex matrices UtU_tUt​ indexed by 0≤t<m0\le t<m0≤t<m, each with rows and columns indexed by ordered bit pairs, this defines a vector on (m+1)(m+1)(m+1)-bit strings by

Ψ=U~m−1⋯U~1U~0 ∣0m+1⟩.\Psi=\widetilde U_{m-1}\cdots\widetilde U_1\widetilde U_0\,|0^{m+1}\rangle.Ψ=Um−1​⋯U1​U0​∣0m+1⟩.

Here ∣0m+1⟩|0^{m+1}\rangle∣0m+1⟩ is the coordinate vector of the all-false string, and the embedded matrix has entries

(U~t)y,z={(Ut)(yt,yt+1),(zt,zt+1),yi=zi for every i∉{t,t+1},0,otherwise.(\widetilde U_t)_{y,z}= \begin{cases} (U_t)_{(y_t,y_{t+1}),(z_t,z_{t+1})}, & y_i=z_i\text{ for every }i\notin\{t,t+1\},\\ 0,&\text{otherwise}. \end{cases}(Ut​)y,z​={(Ut​)(yt​,yt+1​),(zt​,zt+1​)​,0,​yi​=zi​ for every i∈/{t,t+1},otherwise.​

No unitarity assumption is imposed on the UtU_tUt​, and no normalization is required of the resulting vector. When m=0m=0m=0, the matrix product is the identity and the result is the one-bit vector ∣0⟩|0\rangle∣0⟩.

QAlgorithms.Papers.Independent.Intakenext100.P52.ladderWires

For every natural number mmm and index t∈{0,…,m−1}t\in\{0,\ldots,m-1\}t∈{0,…,m−1}, this defines an injective map from {0,1}\{0,1\}{0,1} into {0,…,m}\{0,\ldots,m\}{0,…,m} by j↦t+jj\mapsto t+jj↦t+j: the two selected wires, in order, are ttt and t+1t+1t+1. For m=0m=0m=0 there is no permissible index ttt.

QAlgorithms.Papers.Independent.Intakenext100.P52.lineBranch

For every natural number kkk, real-valued sequence (θi)0≤i<k(\theta_i)_{0\le i<k}(θi​)0≤i<k​, Boolean sequence (si)0≤i<k(s_i)_{0\le i<k}(si​)0≤i<k​, and arbitrary complex Euclidean vector ψ\psiψ indexed by Boolean values, this defines another such vector with coordinate

B(b)=∑z:{0,…,k}→{false,true}zk=bψ(z0)(12)k(∏i=0k−1χ(zi,zi+1))(∏i=0k−1eθi,si(zi)‾),B(b)= \sum_{\substack{z:\{0,\ldots,k\}\to\{\mathrm{false},\mathrm{true}\}\\z_k=b}} \psi(z_0)\left(\frac1{\sqrt2}\right)^k \left(\prod_{i=0}^{k-1}\chi(z_i,z_{i+1})\right) \left(\prod_{i=0}^{k-1}\overline{e_{\theta_i,s_i}(z_i)}\right),B(b)=z:{0,…,k}→{false,true}zk​=b​∑​ψ(z0​)(2​1​)k(i=0∏k−1​χ(zi​,zi+1​))(i=0∏k−1​eθi​,si​​(zi​)​),

where χ(a,b)=−1\chi(a,b)=-1χ(a,b)=−1 if both arguments are true and χ(a,b)=1\chi(a,b)=1χ(a,b)=1 otherwise, while

eθ,s(false)=12,eθ,s(true)=(−1)1{s=true}eiθ2.e_{\theta,s}(\mathrm{false})=\frac1{\sqrt2}, \qquad e_{\theta,s}(\mathrm{true})= \frac{(-1)^{\mathbf1_{\{s=\mathrm{true}\}}}e^{i\theta}}{\sqrt2}.eθ,s​(false)=2​1​,eθ,s​(true)=2​(−1)1{s=true}​eiθ​.

No normalization condition is imposed on ψ\psiψ. For k=0k=0k=0, both products are empty products equal to 111, and B=ψB=\psiB=ψ.

QAlgorithms.Papers.Independent.Intakenext100.P52.localBellAnalysis

For every finite type RRR equipped with decidable equality, Boolean values c,dc,dc,d, and complex vector ψ\psiψ indexed by {0,1}2×R\{0,1\}^2\times R{0,1}2×R, this defines a vector on RRR. Identifying Boolean values with 0,10,10,1, its coordinates are

(localBellAnalysis⁡(c,d,ψ))(r)=12∑u∈{0,1}(−1)cu ψ((u,d⊕u),r),(\operatorname{localBellAnalysis}(c,d,\psi))(r) =\frac1{\sqrt2}\sum_{u\in\{0,1\}} (-1)^{cu}\,\psi\bigl((u,d\mathbin{\oplus}u),r\bigr),(localBellAnalysis(c,d,ψ))(r)=2​1​u∈{0,1}∑​(−1)cuψ((u,d⊕u),r),

where ⊕\oplus⊕ is exclusive-or. Equivalently, the definition first applies the operation ∣u,v⟩↦∣u,v⊕u⟩|u,v\rangle\mapsto|u,v\oplus u\rangle∣u,v⟩↦∣u,v⊕u⟩ to the Boolean pair, leaving RRR unchanged, and then contracts that pair against (∣0⟩+(−1)c∣1⟩)/2⊗∣d⟩(|0\rangle+(-1)^c|1\rangle)/\sqrt2\otimes|d\rangle(∣0⟩+(−1)c∣1⟩)/2​⊗∣d⟩. No normalization is required, and an empty RRR is allowed.

QAlgorithms.Papers.Independent.Intakenext100.P52.neighbourPhase

For any type VVV with decidable equality, finite set E⊆V×VE\subseteq V\times VE⊆V×V, site A∈VA\in VA∈V, Boolean value sss, and Boolean assignment zzz on V∖{A}V\setminus\{A\}V∖{A}, extend zzz to z~\widetilde zz on VVV by setting z~(A)=s\widetilde z(A)=sz(A)=s. This defines

∏(u,v)∈E{−1,(u=A ∨ v=A) ∧ z~(u)=z~(v)=true,1,otherwise.\prod_{(u,v)\in E} \begin{cases} -1,&(u=A\ \lor\ v=A)\ \land\ \widetilde z(u)=\widetilde z(v)=\mathrm{true},\\ 1,&\text{otherwise}. \end{cases}(u,v)∈E∏​{−1,1,​(u=A ∨ v=A) ∧ z(u)=z(v)=true,otherwise.​

Each ordered pair is counted separately, including opposite orientations when both occur; a loop (A,A)(A,A)(A,A) contributes −1-1−1 exactly when sss is true. The empty product is 111.

QAlgorithms.Papers.Independent.Intakenext100.P52.outcomeHistoryPrefix

For every natural number kkk, every Boolean string sss of length kkk, and every index ttt with 0≤t<k0\le t<k0≤t<k, this function returns the Boolean string of length ttt whose coordinate at each 0≤i<t0\le i<t0≤i<t is sis_isi​. Thus it restricts sss to the outcomes strictly before position ttt, and for t=0t=0t=0 it returns the empty string. When k=0k=0k=0, there is no admissible index ttt.

QAlgorithms.Papers.Independent.Intakenext100.P52.pairBra

For every type RRR, every complex vector bbb indexed by Boolean pairs, and every complex vector ψ\psiψ indexed by ({0,1}2)×R(\{0,1\}^2)\times R({0,1}2)×R, this defines a vector on RRR by

(pairBra⁡(b,ψ))(r)=∑p∈{0,1}2b(p)‾ ψ(p,r).(\operatorname{pairBra}(b,\psi))(r) =\sum_{p\in\{0,1\}^2}\overline{b(p)}\,\psi(p,r).(pairBra(b,ψ))(r)=p∈{0,1}2∑​b(p)​ψ(p,r).

No finiteness or decidable-equality assumption on RRR, and no normalization assumption on either vector, is required; RRR may be empty.

QAlgorithms.Papers.Independent.Intakenext100.P52.pauliByproduct

For Boolean values x,zx,zx,z, interpreted as integers 000 for false and 111 for true, this defines the complex matrix

XxZz,X=(0110),Z=(100−1),X^xZ^z, \qquad X=\begin{pmatrix}0&1\\1&0\end{pmatrix}, \quad Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix},XxZz,X=(01​10​),Z=(10​0−1​),

with coordinates ordered false, true. An exponent of zero gives the identity matrix, and the multiplication order is XxX^xXx followed on the right by ZzZ^zZz.

QAlgorithms.Papers.Independent.Intakenext100.P52.phaseGate

For every real number θ\thetaθ, this defines the Boolean-indexed complex matrix, in the coordinate order false, true,

(100eiθ).\begin{pmatrix} 1&0\\ 0&e^{i\theta} \end{pmatrix}.(10​0eiθ​).

QAlgorithms.Papers.Independent.Intakenext100.P52.pointerWave

For natural numbers n,kn,kn,k, an adaptive process PPP, and any complex Euclidean vector ψ\psiψ indexed by length-nnn Boolean strings, this definition gives a vector indexed by pairs (x,s)(x,s)(x,s) of a length-nnn Boolean string and a length-kkk Boolean string, with coordinate

Φ(x,s)=(Ksψ)x=∑yKs(x,y)ψy.\Phi(x,s)=(K_s\psi)_x=\sum_y K_s(x,y)\psi_y.Φ(x,s)=(Ks​ψ)x​=y∑​Ks​(x,y)ψy​.

Here, writing ht=(s0,…,st−1)h_t=(s_0,\ldots,s_{t-1})ht​=(s0​,…,st−1​), the matrix KsK_sKs​ is Fs(Πk−1Gk−1,hk−1)⋯(Π0G0,h0)F_s(\Pi_{k-1}G_{k-1,h_{k-1}})\cdots(\Pi_0G_{0,h_0})Fs​(Πk−1​Gk−1,hk−1​​)⋯(Π0​G0,h0​​), using the process’s unitary gates, basis matrices, selected wires, and final unitary; Πt(y,z)\Pi_t(y,z)Πt​(y,z) is Bt,ht(yq,st)Bt,ht(zq,st)‾B_{t,h_t}(y_q,s_t)\overline{B_{t,h_t}(z_q,s_t)}Bt,ht​​(yq​,st​)Bt,ht​​(zq​,st​)​ when y,zy,zy,z agree outside the selected wire q=qt,htq=q_{t,h_t}q=qt,ht​​, and 000 otherwise. No normalization of ψ\psiψ is assumed, and individual branches are not divided by their norms. For k=0k=0k=0, there is one empty outcome string and Φ(x,s)=(Fsψ)x\Phi(x,s)=(F_s\psi)_xΦ(x,s)=(Fs​ψ)x​.

QAlgorithms.Papers.Independent.Intakenext100.P52.prepMatrix

For any finite type VVV with decidable equality and any finite list of layers, each itself a finite list of preparation gates on VVV, flatten the layers in their listed order to obtain g1,…,gℓg_1,\ldots,g_\ellg1​,…,gℓ​. This defines the matrix Mgℓ⋯Mg1M_{g_\ell}\cdots M_{g_1}Mgℓ​​⋯Mg1​​, so g1g_1g1​ acts first on a column vector. Here, for Boolean assignments y,z:V→{0,1}y,z:V\to\{0,1\}y,z:V→{0,1}, Mh(v)(y,z)M_{\mathrm h(v)}(y,z)Mh(v)​(y,z) is 2−1/2(−1)y(v)z(v)2^{-1/2}(-1)^{y(v)z(v)}2−1/2(−1)y(v)z(v) when y,zy,zy,z agree outside vvv, and zero otherwise; Mcz(v,w)M_{\mathrm{cz}(v,w)}Mcz(v,w)​ is diagonal with entry (−1)z(v)z(w)(-1)^{z(v)z(w)}(−1)z(v)z(w). An empty flattened list gives the identity matrix. No disjointness or grid condition is imposed on the supplied layers.

QAlgorithms.Papers.Independent.Intakenext100.P52.processBranchOperator

For natural numbers n,kn,kn,k, an adaptive process PPP, and a Boolean outcome string sss of length kkk, let ht=(s0,…,st−1)h_t=(s_0,\ldots,s_{t-1})ht​=(s0​,…,st−1​) be its prefix before step ttt, and take from PPP the unitary gate Gt,htG_{t,h_t}Gt,ht​​, wire qt,htq_{t,h_t}qt,ht​​, unitary Boolean-indexed basis matrix Bt,htB_{t,h_t}Bt,ht​​, and final unitary FsF_sFs​. The branch operator is

Ks=Fs(Πk−1Gk−1,hk−1)⋯(Π0G0,h0),K_s=F_s \bigl(\Pi_{k-1}G_{k-1,h_{k-1}}\bigr)\cdots \bigl(\Pi_0G_{0,h_0}\bigr),Ks​=Fs​(Πk−1​Gk−1,hk−1​​)⋯(Π0​G0,h0​​),

where Πt(y,z)=Bt,ht(yqt,ht,st)Bt,ht(zqt,ht,st)‾\Pi_t(y,z)=B_{t,h_t}(y_{q_{t,h_t}},s_t)\overline{B_{t,h_t}(z_{q_{t,h_t}},s_t)}Πt​(y,z)=Bt,ht​​(yqt,ht​​​,st​)Bt,ht​​(zqt,ht​​​,st​)​ if y,zy,zy,z agree on every other wire, and is 000 otherwise. Thus the step factors are multiplied in reverse chronological order, with the final gate on the left. For k=0k=0k=0, the step product is the identity and Ks=FsK_s=F_sKs​=Fs​.

QAlgorithms.Papers.Independent.Intakenext100.P52.reduceFirst

For every complex matrix ρ\rhoρ indexed by ordered bit pairs and every optional complex two-coordinate vector selected\mathrm{selected}selected, this defines a matrix on a single bit. If no vector is selected, its entries are

Rb,c=∑a∈{0,1}ρ(a,b),(a,c);R_{b,c}=\sum_{a\in\{0,1\}}\rho_{(a,b),(a,c)};Rb,c​=a∈{0,1}∑​ρ(a,b),(a,c)​;

if the selected vector is vvv, its entries are

Rb,c=∑a,d∈{0,1}va‾ ρ(a,b),(d,c) vd.R_{b,c}=\sum_{a,d\in\{0,1\}}\overline{v_a}\,\rho_{(a,b),(d,c)}\,v_d.Rb,c​=a,d∈{0,1}∑​va​​ρ(a,b),(d,c)​vd​.

There is no assumption that ρ\rhoρ is positive or has trace one, or that vvv is normalized, and the result is not divided by its trace.

QAlgorithms.Papers.Independent.Intakenext100.P52.rotatedBell

For any complex 2×22\times22×2 matrix UUU indexed by Boolean values and any Boolean values c,dc,dc,d, identify false with 000 and true with 111. This defines the vector

(U†ZcXd⊗I2)∣00⟩+∣11⟩2,X=(0110),Z=(100−1),(U^\dagger Z^cX^d\otimes I_2)\frac{|00\rangle+|11\rangle}{\sqrt2}, \qquad X=\begin{pmatrix}0&1\\1&0\end{pmatrix}, \quad Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix},(U†ZcXd⊗I2​)2​∣00⟩+∣11⟩​,X=(01​10​),Z=(10​0−1​),

in the Euclidean space indexed by Boolean pairs, where U†U^\daggerU† is the conjugate transpose and the displayed kets are coordinate basis vectors. No unitarity assumption is imposed on UUU.

QAlgorithms.Papers.Independent.Intakenext100.P52.rotatedEntangledKet

For any finite, nonempty index type III with decidable equality and any complex matrix UUU indexed by I×II\times II×I, this defines a vector in CI×I\mathbb C^{I\times I}CI×I by applying U†⊗IIU^\dagger\otimes I_IU†⊗II​ to the vector ∣I∣−1/2∑j∈I∣j,j⟩|I|^{-1/2}\sum_{j\in I}|j,j\rangle∣I∣−1/2∑j∈I​∣j,j⟩, where U†U^\daggerU† is the conjugate transpose, III_III​ is the identity matrix, and ∣j,j⟩|j,j\rangle∣j,j⟩ is the coordinate basis vector at (j,j)(j,j)(j,j). Equivalently, its coordinate at (a,b)(a,b)(a,b) is

Ub,a‾∣I∣.\frac{\overline{U_{b,a}}}{\sqrt{|I|}}.∣I∣​Ub,a​​​.

There is no assumption that UUU is unitary.

QAlgorithms.Papers.Independent.Intakenext100.P52.rx

For every real number θ\thetaθ, this defines the Boolean-indexed complex matrix, in the coordinate order false, true,

cos⁡θ I2−isin⁡θ(0110)=(cos⁡θ−isin⁡θ−isin⁡θcos⁡θ).\cos\theta\,I_2-i\sin\theta \begin{pmatrix}0&1\\1&0\end{pmatrix} = \begin{pmatrix} \cos\theta&-i\sin\theta\\ -i\sin\theta&\cos\theta \end{pmatrix}.cosθI2​−isinθ(01​10​)=(cosθ−isinθ​−isinθcosθ​).

QAlgorithms.Papers.Independent.Intakenext100.P52.rz

For every real number θ\thetaθ, this defines the Boolean-indexed complex matrix, in the coordinate order false, true,

(e−iθ00eiθ).\begin{pmatrix} e^{-i\theta}&0\\ 0&e^{i\theta} \end{pmatrix}.(e−iθ0​0eiθ​).

QAlgorithms.Papers.Independent.Intakenext100.P52.siteProjector

For every natural number nnn, wire q∈{0,…,n−1}q\in\{0,\ldots,n-1\}q∈{0,…,n−1}, complex Boolean-indexed matrix BBB, and Boolean sss, this definition gives a matrix on length-nnn Boolean strings with entries

Πq,B,s(y,z)={B(yq,s) B(zq,s)‾,yi=zi for every i≠q,0,otherwise.\Pi_{q,B,s}(y,z)= \begin{cases} B(y_q,s)\,\overline{B(z_q,s)},&y_i=z_i\text{ for every }i\ne q,\\ 0,&\text{otherwise}. \end{cases}Πq,B,s​(y,z)={B(yq​,s)B(zq​,s)​,0,​yi​=zi​ for every i=q,otherwise.​

No unitarity or normalization condition on BBB is assumed. Supplying a wire requires n>0n>0n>0; when n=1n=1n=1, the agreement condition outside the wire is vacuous.

QAlgorithms.Papers.Independent.Intakenext100.P52.sourceBellBasis

For Boolean values c,dc,dc,d, identify false with 000 and true with 111. This defines the vector in C{false,true}2\mathbb C^{\{\mathrm{false},\mathrm{true}\}^2}C{false,true}2

(ZcXd⊗I2)∣00⟩+∣11⟩2,X=(0110),Z=(100−1),(Z^cX^d\otimes I_2)\frac{|00\rangle+|11\rangle}{\sqrt2}, \qquad X=\begin{pmatrix}0&1\\1&0\end{pmatrix}, \quad Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix},(ZcXd⊗I2​)2​∣00⟩+∣11⟩​,X=(01​10​),Z=(10​0−1​),

where ∣ab⟩|ab\rangle∣ab⟩ is the coordinate basis vector at the Boolean pair (a,b)(a,b)(a,b), and all matrices use the coordinate order false, true.

QAlgorithms.Papers.Independent.Intakenext100.P52.teleportContraction

For any finite index type III, any vector α∈CI\alpha\in\mathbb C^Iα∈CI, and any vectors r,m∈CI×Ir,m\in\mathbb C^{I\times I}r,m∈CI×I, supplied respectively as the resource and measured vectors, this defines the vector whose coordinate at k∈Ik\in Ik∈I is

∑i∈I∑j∈Imi,j‾ αi rj,k.\sum_{i\in I}\sum_{j\in I}\overline{m_{i,j}}\,\alpha_i\,r_{j,k}.i∈I∑​j∈I∑​mi,j​​αi​rj,k​.

No normalization assumptions are imposed. The definition also permits III to be empty.

QAlgorithms.Papers.Independent.Intakenext100.P52.threeQubitBellKet

For each a∈{0,1,2,3}a\in\{0,1,2,3\}a∈{0,1,2,3} and Boolean sss, this defines a complex vector indexed by three-bit strings. Let g0=000g_0=000g0​=000, g1=001g_1=001g1​=001, g2=010g_2=010g2​=010, and g3=100g_3=100g3​=100, and let g‾a\overline g_ag​a​ denote the string obtained by flipping every bit of gag_aga​. The vector is 12∣ga⟩+(−1)s2∣g‾a⟩\displaystyle \frac1{\sqrt2}\lvert g_a\rangle+\frac{(-1)^s}{\sqrt2}\lvert\overline g_a\rangle2​1​∣ga​⟩+2​(−1)s​∣g​a​⟩, where (−1)s(-1)^s(−1)s is 111 for s=falses=\mathrm{false}s=false and −1-1−1 for s=trues=\mathrm{true}s=true, and ∣z⟩\lvert z\rangle∣z⟩ has amplitude 111 at string zzz and zero elsewhere.

QAlgorithms.Papers.Independent.Intakenext100.P52.valenceProjection

For any type VVV with decidable equality and finite set E⊆V×VE\subseteq V\times VE⊆V×V, this defines a complex matrix with rows indexed by assignments x:V→{0,1}x:V\to\{0,1\}x:V→{0,1} and columns indexed by assignments w:E×{0,1}→{0,1}w:E\times\{0,1\}\to\{0,1\}w:E×{0,1}→{0,1}. Its entry at (x,w)(x,w)(x,w) is 111 exactly when, for every ordered pair e=(u,v)∈Ee=(u,v)\in Ee=(u,v)∈E, both w(e,0)=x(u)w(e,0)=x(u)w(e,0)=x(u) and w(e,1)=x(v)w(e,1)=x(v)w(e,1)=x(v); otherwise its entry is 000. No assumption requires VVV to be finite or every vertex to occur in an edge. For a pair (u,u)(u,u)(u,u), both associated positions must equal x(u)x(u)x(u); when EEE is empty, every matrix entry is 111.

QAlgorithms.Papers.Independent.Intakenext100.P52.wGate

For every real number θ\thetaθ, this defines the Boolean-indexed complex matrix, in the coordinate order false, true,

12(1eiθ1−eiθ).\frac1{\sqrt2} \begin{pmatrix} 1&e^{i\theta}\\ 1&-e^{i\theta} \end{pmatrix}.2​1​(11​eiθ−eiθ​).

This is the matrix product of 12(111−1)\frac1{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}2​1​(11​1−1​) with diag⁡(1,eiθ)\operatorname{diag}(1,e^{i\theta})diag(1,eiθ), in that order.

QAlgorithms.Papers.Independent.Intakenext100.P52.weightedTeleport

Let III be a finite nonempty index type with decidable equality, D=∣I∣D=|I|D=∣I∣, UUU an arbitrary complex I×II\times II×I matrix, k∈Rk\in\mathbb Rk∈R, and α∈CI\alpha\in\mathbb C^Iα∈CI an arbitrary vector. Define ΩI(i,j)=D−1/2\Omega_I(i,j)=D^{-1/2}ΩI​(i,j)=D−1/2 when i=ji=ji=j and 000 otherwise, and rU=(U†⊗ID)ΩIr_U=(U^\dagger\otimes I_D)\Omega_IrU​=(U†⊗ID​)ΩI​. This defines a vector w∈CIw\in\mathbb C^Iw∈CI by

wℓ=k∑i,j∈IrU(i,j)‾ αi ΩI(j,ℓ).w_\ell=\sqrt{k}\sum_{i,j\in I}\overline{r_U(i,j)}\,\alpha_i\,\Omega_I(j,\ell).wℓ​=k​i,j∈I∑​rU​(i,j)​αi​ΩI​(j,ℓ).

There is no normalization assumption on α\alphaα, unitarity assumption on UUU, or sign restriction on kkk; the real square root is zero for k≤0k\le0k≤0, so the defined vector is zero in that case.

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

    Confirmed by the moderator at approval.

  • Endorsed by Gohan · Oct 31, 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