Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Definitions for Exploiting symmetry in variational quantum machine learning

Definition
QAlgorithms_Papers_Independent_Extend50_P01

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

prove2quantum

The objects the formalized statements of Exploiting symmetry in variational quantum machine learning (arXiv:2205.06217) are stated in. Each was checked against the paper by a blind read-back and a moderator.

  • finiteTwirl: PDF p.8, Eq.(52): normalized finite average.
  • operatorHaarAverage: PDF p.8, Eq.(53): Haar integral; the projection theorem supplies integrability.
  • tensorLocal: PDF p.5, Eq.(19): tensor product in the frozen wire convention.
  • axis: PDF p.5: axis order X,Y,Z.
  • localEncoding: PDF p.5, Eq.(19): tensor product of half-angle Pauli rotations.
  • permMatrix: PDF pp.4–6: computational-basis permutation matrix.
  • featurePullback: PDF p.5, Eq.(18): inverse pullback supplies a consistent left action.
  • wirePerm: PDF p.5, Eq.(20): inverse pullback on bit strings.
  • wireMatrix: PDF p.5, Eq.(20): wire-permutation unitary matrix.
  • SignedPerm: PDF p.5, footnote 2: permutation and sign mask.
  • signedMul: PDF p.5: explicit semidirect multiplication.
  • signedInv: PDF p.5: inverse for the semidirect multiplication.
  • signedData: PDF p.5: signed coordinate action.
  • signedMatrix: PDF p.5: wire permutations followed by local X gates.
  • kleinMul: PDF p.4, Eq.(7): multiplication of exchange/sign bits.
  • kleinData: PDF p.4: action on the two real features.
  • kleinMatrix: PDF p.4, Eqs.(16),(17): all four specified matrices.
  • kleinEncoding: PDF p.4, Eq.(10): two-qubit embedding.
  • zWord: PDF p.5: squarefree Z word, including identity at empty support.
  • extraGenerator: PDF p.5: local-Z generators and the additional full Z word.
  • extraEncoding: PDF p.5: d+1-feature encoding.
  • extraSwap: PDF p.5, corrected controls: every other wire controls target i.
  • balancedEncoding: PDF p.5: balanced three-feature encoding.
  • axisHadamard: PDF p.5, Eqs.(21)–(23): retains the printed -i Hadamard phase.
  • supportOrbit: PDF p.5: distinct squarefree supports in a subgroup orbit.
  • monomialEncoding: PDF p.5: matched monomials and commuting Z words over the complete orbit.
  • basisEncoding: PDF pp.5–6, Eq.(24): independent basis phase features.
  • featureMatrix: PDF p.6, Eq.(25): unused basis labels are fixed.
  • inversionEncoding: PDF p.7, Eq.(35): inversion embedding with the specified tensor placement.
  • reupload: PDF pp.10–11, Eq.(68): W_L E ... W_1 E W_0, including L=0.
  • involutionTwirl: PDF pp.8–9: normalized twirl by an order-two unitary.
  • twoGateSet: PDF pp.8–9, Eq.(55): the seven original generators.
  • boardRotation: PDF p.12, Fig.3: clockwise perimeter shift by two; center 8 is fixed.
  • boardReflection: PDF p.12: the specified vertical reflection SWAP02 SWAP73 SWAP64.
  • boardGroup: PDF pp.11–12: the actual D4 subgroup on the nine labeled wires.
  • vehicleGroup: PDF pp.14–15: rotations alone generate the vehicle C4 group.
  • vertexClass: PDF p.12: center, corners, and edges, indexed 0,1,2 for subsequent formulas.
  • vertexOrbit: PDF pp.12,19: explicit vertex orbits.
  • clockwiseEdges: PDF pp.12,15: clockwise corner-to-edge pairs.
  • counterEdges: PDF pp.12,15: counterclockwise corner-to-edge pairs.
  • inwardEdges: PDF p.12: edges control the center.
  • diagonalEdges: PDF p.12: the center controls the corners.
  • controlledGenerator: PDF p.12: generator of a controlled rotation; all spectators are identities.
  • controlledOrbit: PDF pp.12,15: an entire commuting controlled-rotation orbit, one shared half-angle. Each source orbit has disjoint sets of control and target sites, so its gates commute.
  • boardSingle: PDF p.12, Fig.3: RY(theta_2) RX(theta_1), with two real angles shared within each of the three vertex classes. The rightmost X rotation acts first.
  • boardLayer: PDF p.12: one complete cemoid block, with chronological order c,e,m,o,i,d.
  • vehicleLayer: PDF p.15: CRZ vehicle block; clockwise and counterclockwise coordinates are independent.
  • learningCircuit: PDF pp.12–15: repeated data embeddings, each followed by the specified block list.
  • boardObservable: PDF p.13, Eqs.(88)–(90): the circle, draw, cross observable vector, with 1/4 averages.
  • boardPrediction: PDF pp.12–13: the complete real prediction vector, before an unspecified tie rule.
  • vehiclePrediction: PDF p.15, Eq.(92): normalized central-Z vehicle regression.
  • nextSite: PDF p.16, Eq.(94): cyclic successor; only used with a positive chain length.
  • axisSum: PDF pp.16–18: sum of one-site axis generators.
  • tfim: PDF p.16, Eq.(94): periodic ferromagnetic TFIM, including literal Z_i^2 at n=1.
  • plusState: PDF p.17: normalized all-plus input.
  • qaoa: PDF p.17, Eq.(97): QAOA matrix product, no half-angle factor.
  • twirledQaoa: PDF p.17, Eq.(98): every generator of QAOA-prime is parity-twirled.
  • SU2: PDF p.17, Eq.(100): the native determinant-one qubit unitary group.
  • heisenberg: PDF p.17, Eq.(99): periodic antiferromagnetic isotropic chain.
  • singletProduct: PDF p.18, Eq.(101): neighboring normalized singlets on sites (0,1),(2,3),... .
  • totalSpinSquared: PDF pp.17–18: the usual total-spin squared, sum of the squares of collective half-Paulis.
  • collectiveTwirl: PDF p.18, Eq.(104): normalized collective SU(2) Haar average.
  • bondHamiltonian: PDF p.18, Eq.(103): zero-based bond starts 0,2,... for even, and 1,3,... for odd.
  • twirledHeisenbergLayer: PDF p.18, corrected Eq.(102): one Y-mixer and one even and one odd block per layer.
  • isotropicLayer: PDF p.18, corrected Eq.(110): one isotropic even and one isotropic odd block.
  • reduceHeisenberg: PDF p.18: the two surviving coordinates are the means of the three anisotropies.
  • HeisenbergParameters: PDF p.18: source parameter coordinates, not a claim about minimal functional dimension.
  • latticeEdges: PDF p.19, Fig.12: contour, inside, diagonal undirected edges, represented once each.
  • latticeInteraction: PDF p.19, Eqs.(112),(113): the sum of ZZ interactions in a fixed orbit.
  • latticeHamiltonian: PDF p.19, Eqs.(111),(112): weights 1,1/2,3/2 on the fixed Fig.12 graph.
  • orbitLocal: PDF pp.19–20: averaged local generator on one vertex orbit.
  • orbitInteraction: PDF pp.19–20: average ZZ generator in one edge orbit.
  • boardTwirl: PDF pp.19–20: finite D4 average over the actual board subgroup.
  • latticeLayer: PDF pp.19–20: one shared angle for each ZZ edge orbit and each X/Z vertex orbit.
  • LatticeOriginalParameters: PDF p.20: named parameter slots of the unrestricted ansatz.
  • LatticeSymmetricParameters: PDF p.20: named parameter slots of the shared orbit ansatz.
Definition code
import Mathlib
import Definitions.Def_QAlgorithms_Defs_Gates
import Definitions.Def_QAlgorithms_Defs_Hamiltonian
import Definitions.Def_QAlgorithms_Defs_Channel
import Definitions.Def_QAlgorithms_Papers_Independent_Information100_P21
import Definitions.Def_QAlgorithms_Papers_Independent_Information100_P32
import Definitions.Def_QAlgorithms_Papers_Independent_Information100_P69
import Definitions.Def_QAlgorithms_Papers_Independent_Advance50_P49
import Definitions.Def_QAlgorithms_Papers_Independent_Gap48_P33

/-! Statements from Meyer et al., arXiv:2205.06217v1. All page numbers are PDF pages.
Paper-local constructions below supplement the frozen register, state and Pauli conventions.
Source corrections and deferred claims are recorded in the accompanying audit artifacts. -/

noncomputable section

open scoped Matrix Kronecker ComplexConjugate Matrix.Norms.L2Operator Manifold ContDiff
open MeasureTheory

namespace QAlgorithms.Papers.Independent.Extend50.P01

attribute [local instance] Classical.propDecidable Classical.decEq

-- PDF pp.3,8: reuse the accepted operator type, exp(-itH), and A X A†.
-- Notation specializes the imported interfaces without introducing duplicate declarations.
local notation "Op" => (fun n : ℕ => QAlgorithms.Papers.Independent.Information100.P21.Op (Qubits n))

local notation "evolve" => QAlgorithms.Papers.Independent.Information100.P32.evolution

local notation "conjugate" => QAlgorithms.conjSuperop

-- PDF pp.3,10–11: the imported quadratic form is Re(psi† A psi).
local notation "expectation" => QAlgorithms.Papers.Independent.Information100.P21.quad

-- PDF pp.5,16–19: accepted active-wire operator, with identities on all spectators.
local notation "onWire" => QAlgorithms.Papers.Independent.Advance50.P49.onWire

-- PDF p.5: the imported phase-free Pauli tensor uses 0=I,1=X,2=Y,3=Z.
local notation "pauliWord" => QAlgorithms.Papers.Independent.Gap48.P33.pauliWord

/-- PDF p.8, Eq.(52): normalized finite average. -/
def finiteTwirl {S ι : Type*} [Fintype S] [Fintype ι]
    (U : S → Matrix ι ι ℂ) (A : Matrix ι ι ℂ) : Matrix ι ι ℂ :=
  (Fintype.card S : ℂ)⁻¹ • ∑ s, conjugate (U s) A

/-- PDF p.8, Eq.(53): Haar integral; the projection theorem supplies integrability. -/
def operatorHaarAverage {S ι : Type*} [MeasurableSpace S] [Fintype ι]
    (mu : Measure S) (U : S → Matrix ι ι ℂ) (A : Matrix ι ι ℂ) : Matrix ι ι ℂ :=
  ∫ s, conjugate (U s) A ∂mu

/-- PDF p.5, Eq.(19): tensor product in the frozen wire convention. -/
def tensorLocal {n : ℕ} (A : Fin n → Matrix Bool Bool ℂ) : Op n :=
  fun a b => ∏ i, A i (a i) (b i)

/-- PDF p.5: axis order X,Y,Z. -/
def axis (a : Fin 3) : Matrix Bool Bool ℂ := ![pauliX, pauliY, pauliZ] a

/-- PDF p.5, Eq.(19): tensor product of half-angle Pauli rotations. -/
def localEncoding {n : ℕ} (A : Matrix Bool Bool ℂ) (x : Fin n → ℝ) : Op n :=
  tensorLocal (fun i => evolve A (x i / 2))

/-- PDF pp.4–6: computational-basis permutation matrix. -/
def permMatrix {ι : Type*} [DecidableEq ι] (p : Equiv.Perm ι) : Matrix ι ι ℂ :=
  fun a b => if a = p b then 1 else 0

/-- PDF p.5, Eq.(18): inverse pullback supplies a consistent left action. -/
def featurePullback {n : ℕ} (p : Equiv.Perm (Fin n)) (x : Fin n → ℝ) : Fin n → ℝ :=
  fun i => x (p.symm i)

/-- PDF p.5, Eq.(20): inverse pullback on bit strings. -/
def wirePerm {n : ℕ} (p : Equiv.Perm (Fin n)) : Equiv.Perm (Qubits n) where
  toFun b := fun i => b (p.symm i)
  invFun b := fun i => b (p i)
  left_inv b := by funext i; simp
  right_inv b := by funext i; simp

/-- PDF p.5, Eq.(20): wire-permutation unitary matrix. -/
def wireMatrix {n : ℕ} (p : Equiv.Perm (Fin n)) : Op n := permMatrix (wirePerm p)

/-- PDF p.5, footnote 2: permutation and sign mask. -/
abbrev SignedPerm (n : ℕ) := Equiv.Perm (Fin n) × (Fin n → Bool)

/-- PDF p.5: explicit semidirect multiplication. -/
def signedMul {n : ℕ} (g h : SignedPerm n) : SignedPerm n :=
  (g.1 * h.1, fun i => xor (g.2 i) (h.2 (g.1.symm i)))

/-- PDF p.5: inverse for the semidirect multiplication. -/
def signedInv {n : ℕ} (g : SignedPerm n) : SignedPerm n :=
  (g.1.symm, fun i => g.2 (g.1 i))

/-- PDF p.5: signed coordinate action. -/
def signedData {n : ℕ} (g : SignedPerm n) (x : Fin n → ℝ) : Fin n → ℝ :=
  fun i => (if g.2 i then -1 else 1) * x (g.1.symm i)

/-- PDF p.5: wire permutations followed by local X gates. -/
def signedMatrix {n : ℕ} (g : SignedPerm n) : Op n :=
  fun a b => if a = (fun i => xor (b (g.1.symm i)) (g.2 i)) then 1 else 0

/-- PDF p.4, Eq.(7): multiplication of exchange/sign bits. -/
def kleinMul (a b : Bool × Bool) : Bool × Bool := (xor a.1 b.1, xor a.2 b.2)

/-- PDF p.4: action on the two real features. -/
def kleinData (a : Bool × Bool) (x : Fin 2 → ℝ) : Fin 2 → ℝ :=
  fun i => (if a.2 then -1 else 1) * x (if a.1 then (Equiv.swap 0 1) i else i)

/-- PDF p.4, Eqs.(16),(17): all four specified matrices. -/
def kleinMatrix (a : Bool × Bool) : Matrix (Bool × Bool) (Bool × Bool) ℂ :=
  (if a.1 then swapGate else 1) * (if a.2 then pauliX ⊗ₖ pauliX else 1)

/-- PDF p.4, Eq.(10): two-qubit embedding. -/
def kleinEncoding (x : Fin 2 → ℝ) : Matrix (Bool × Bool) (Bool × Bool) ℂ :=
  evolve pauliZ (x 0 / 2) ⊗ₖ evolve pauliZ (x 1 / 2)

/-- PDF p.5: squarefree Z word, including identity at empty support. -/
def zWord {n : ℕ} (A : Finset (Fin n)) : Op n :=
  Matrix.diagonal (fun b => ∏ i ∈ A, if b i then (-1 : ℂ) else 1)

/-- PDF p.5: local-Z generators and the additional full Z word. -/
def extraGenerator {d : ℕ} (k : Fin (d + 1)) : Op d :=
  if h : k.val < d then onWire ⟨k.val, h⟩ pauliZ else zWord Finset.univ

/-- PDF p.5: d+1-feature encoding. -/
def extraEncoding {d : ℕ} (x : Fin (d + 1) → ℝ) : Op d :=
  evolve (∑ k, (x k : ℂ) • extraGenerator k) (1 / 2)

/-- PDF p.5, corrected controls: every other wire controls target i. -/
def extraSwap {d : ℕ} (i : Fin d) : Op d :=
  fun a b => if a = (fun j => if j = i then
    xor (b i) (∑ k ∈ Finset.univ.erase i, b k) else b j) then 1 else 0

/-- PDF p.5: balanced three-feature encoding. -/
def balancedEncoding (x : Fin 3 → ℝ) : Matrix (Bool × Bool) (Bool × Bool) ℂ :=
  evolve (∑ a, (x a : ℂ) • (axis a ⊗ₖ axis a)) (1 / 2)

/-- PDF p.5, Eqs.(21)–(23): retains the printed -i Hadamard phase. -/
def axisHadamard (a b : Fin 3) : Matrix Bool Bool ℂ :=
  evolve (axis a + axis b) (Real.pi / (2 * Real.sqrt 2))

/-- PDF p.5: distinct squarefree supports in a subgroup orbit. -/
def supportOrbit {d : ℕ} (K : Subgroup (Equiv.Perm (Fin d)))
    (A : Finset (Fin d)) : Finset (Finset (Fin d)) :=
  ((Finset.univ : Finset (Equiv.Perm (Fin d))).filter (fun s => s ∈ K)).image
    (fun s => A.image s)

/-- PDF p.5: matched monomials and commuting Z words over the complete orbit. -/
def monomialEncoding {d : ℕ} (K : Subgroup (Equiv.Perm (Fin d)))
    (A : Finset (Fin d)) (x : Fin d → ℝ) : Op d :=
  evolve (∑ B ∈ supportOrbit K A, ((∏ i ∈ B, x i : ℝ) : ℂ) • zWord B) (1 / 2)

/-- PDF pp.5–6, Eq.(24): independent basis phase features. -/
def basisEncoding {n m : ℕ} (e : Fin m ↪ Qubits n) (x : Fin m → ℝ) : Op n :=
  evolve (∑ k, (x k : ℂ) • Matrix.single (e k) (e k) 1) 1

/-- PDF p.6, Eq.(25): unused basis labels are fixed. -/
def featureMatrix {n m : ℕ} (e : Fin m ↪ Qubits n)
    (s : Equiv.Perm (Fin m)) : Op n := permMatrix (s.viaEmbedding e)

/-- PDF p.7, Eq.(35): inversion embedding with the specified tensor placement. -/
def inversionEncoding (x : Fin 3 → ℝ) : Matrix (Bool × Bool) (Bool × Bool) ℂ :=
  evolve ((∑ a, (x a : ℂ) • axis a) ⊗ₖ pauliX) (1 / 2)

/-- PDF pp.10–11, Eq.(68): W_L E ... W_1 E W_0, including L=0. -/
def reupload {n : ℕ} (E : Op n) (W : List (Op n)) : Op n :=
  match W with
  | [] => 1
  | W0 :: rest => (rest.map (fun A => A * E)).reverse.prod * W0

example {ι : Type*} [Fintype ι] [DecidableEq ι] (A : Matrix ι ι ℂ) : evolve A 0 = 1 := by
  simp [QAlgorithms.Papers.Independent.Information100.P32.evolution]

example (x : Fin 0 → ℝ) : localEncoding pauliZ x = (1 : Op 0) := by
  ext a b
  have h : a = b := Subsingleton.elim _ _
  subst b
  simp [localEncoding, tensorLocal]

example (E W0 : Op 2) : reupload E [W0] = W0 := by simp [reupload]

example : kleinMatrix (false, false) = 1 := by simp [kleinMatrix]

example {n : ℕ} : zWord (∅ : Finset (Fin n)) = 1 := by simp [zWord]

example (A : Op 1) : finiteTwirl (fun _ : Unit => (1 : Op 1)) A = A := by
  simp [finiteTwirl, QAlgorithms.conjSuperop]

example {S : Type*} [MeasurableSpace S] (mu : Measure S) (U : S → Op 1) :
    operatorHaarAverage mu U 0 = 0 := by simp [operatorHaarAverage, QAlgorithms.conjSuperop]

example {n : ℕ} (x : Fin n → ℝ) : signedData (1, fun _ => false) x = x := by
  funext i
  change (1 : ℝ) * x i = x i
  exact one_mul _

example {n m : ℕ} (e : Fin m ↪ Qubits n) : basisEncoding e (fun _ => 0) = 1 := by
  simp [basisEncoding, QAlgorithms.Papers.Independent.Information100.P32.evolution]

example {d : ℕ} : extraGenerator (Fin.last d) = zWord (Finset.univ : Finset (Fin d)) := by
  simp [extraGenerator]

example : inversionEncoding (fun _ => 0) = 1 := by simp [inversionEncoding, QAlgorithms.Papers.Independent.Information100.P32.evolution]

/-- PDF pp.8–9: normalized twirl by an order-two unitary. -/
def involutionTwirl {ι : Type*} [Fintype ι] (V A : Matrix ι ι ℂ) : Matrix ι ι ℂ :=
  (1 / 2 : ℂ) • (A + conjugate V A)

/-- PDF pp.8–9, Eq.(55): the seven original generators. -/
def twoGateSet : Set (Matrix (Bool × Bool) (Bool × Bool) ℂ) :=
  Set.range (fun a : Fin 3 => axis a ⊗ₖ (1 : Matrix Bool Bool ℂ)) ∪
  Set.range (fun a : Fin 3 => (1 : Matrix Bool Bool ℂ) ⊗ₖ axis a) ∪ {pauliZ ⊗ₖ pauliZ}

/-- PDF p.12, Fig.3: clockwise perimeter shift by two; center 8 is fixed. -/
def boardRotation : Equiv.Perm (Fin 9) :=
  (Equiv.swap 0 2 * Equiv.swap 2 4 * Equiv.swap 4 6) *
  (Equiv.swap 1 3 * Equiv.swap 3 5 * Equiv.swap 5 7)

/-- PDF p.12: the specified vertical reflection SWAP02 SWAP73 SWAP64. -/
def boardReflection : Equiv.Perm (Fin 9) := Equiv.swap 0 2 * Equiv.swap 7 3 * Equiv.swap 6 4

/-- PDF pp.11–12: the actual D4 subgroup on the nine labeled wires. -/
def boardGroup : Subgroup (Equiv.Perm (Fin 9)) := Subgroup.closure {boardRotation, boardReflection}

/-- PDF pp.14–15: rotations alone generate the vehicle C4 group. -/
def vehicleGroup : Subgroup (Equiv.Perm (Fin 9)) := Subgroup.zpowers boardRotation

/-- PDF p.12: center, corners, and edges, indexed 0,1,2 for subsequent formulas. -/
def vertexClass (i : Fin 9) : Fin 3 := if i = 8 then 0 else if i.val % 2 = 0 then 1 else 2

/-- PDF pp.12,19: explicit vertex orbits. -/
def vertexOrbit (a : Fin 3) : Finset (Fin 9) := Finset.univ.filter (fun i => vertexClass i = a)

/-- PDF pp.12,15: clockwise corner-to-edge pairs. -/
def clockwiseEdges : Finset (Fin 9 × Fin 9) := {(0,1),(2,3),(4,5),(6,7)}

/-- PDF pp.12,15: counterclockwise corner-to-edge pairs. -/
def counterEdges : Finset (Fin 9 × Fin 9) := {(0,7),(2,1),(4,3),(6,5)}

/-- PDF p.12: edges control the center. -/
def inwardEdges : Finset (Fin 9 × Fin 9) := {(1,8),(3,8),(5,8),(7,8)}

/-- PDF p.12: the center controls the corners. -/
def diagonalEdges : Finset (Fin 9 × Fin 9) := {(8,0),(8,2),(8,4),(8,6)}

/-- PDF p.12: generator of a controlled rotation; all spectators are identities. -/
def controlledGenerator (a : Matrix Bool Bool ℂ) (e : Fin 9 × Fin 9) : Op 9 :=
  onWire e.1 (Matrix.diagonal (fun b => if b then (1 : ℂ) else 0)) * onWire e.2 a

/-- PDF pp.12,15: an entire commuting controlled-rotation orbit, one shared half-angle.
Each source orbit has disjoint sets of control and target sites, so its gates commute. -/
def controlledOrbit (a : Matrix Bool Bool ℂ) (edges : Finset (Fin 9 × Fin 9)) (theta : ℝ) : Op 9 :=
  evolve (∑ e ∈ edges, controlledGenerator a e) (theta / 2)

example (a : Matrix Bool Bool ℂ) (theta : ℝ) : controlledOrbit a ∅ theta = 1 := by
  simp [controlledOrbit, QAlgorithms.Papers.Independent.Information100.P32.evolution]

/-- PDF p.12, Fig.3: RY(theta_2) RX(theta_1), with two real angles shared
within each of the three vertex classes. The rightmost X rotation acts first. -/
def boardSingle (angles : Fin 3 → Fin 2 → ℝ) : Op 9 :=
  tensorLocal (fun i => evolve pauliY (angles (vertexClass i) 1 / 2) *
    evolve pauliX (angles (vertexClass i) 0 / 2))

example : boardSingle (fun _ _ => 0) (fun _ => false) (fun _ => false) = 1 := by
  simp [boardSingle, tensorLocal, QAlgorithms.Papers.Independent.Information100.P32.evolution]

/-- PDF p.12: one complete cemoid block, with chronological order c,e,m,o,i,d. -/
def boardLayer (p : (Fin 3 → Fin 2 → ℝ) × (Fin 3 → ℝ)) : Op 9 :=
  controlledOrbit pauliY diagonalEdges (p.2 2) * controlledOrbit pauliY inwardEdges (p.2 1) *
    controlledOrbit pauliY (clockwiseEdges ∪ counterEdges) (p.2 0) * boardSingle p.1

/-- PDF p.15: CRZ vehicle block; clockwise and counterclockwise coordinates are independent. -/
def vehicleLayer (p : (Fin 3 → Fin 2 → ℝ) × (Fin 4 → ℝ)) : Op 9 :=
  controlledOrbit pauliZ diagonalEdges (p.2 3) * controlledOrbit pauliZ inwardEdges (p.2 2) *
    controlledOrbit pauliZ counterEdges (p.2 1) * controlledOrbit pauliZ clockwiseEdges (p.2 0) *
    boardSingle p.1

/-- PDF pp.12–15: repeated data embeddings, each followed by the specified block list. -/
def learningCircuit {P : Type*} (layer : P → Op 9) (W : List (List P)) (x : Fin 9 → ℝ) : Op 9 :=
  (W.map (fun block => (block.map layer).reverse.prod *
    localEncoding pauliX (fun i => (2 * Real.pi / 3) * x i))).reverse.prod

/-- PDF p.13, Eqs.(88)–(90): the circle, draw, cross observable vector, with 1/4 averages. -/
def boardObservable (a : Fin 3) : Op 9 :=
  ![(1 / 4 : ℂ) • ∑ i ∈ vertexOrbit 1, onWire i pauliZ,
    onWire (8 : Fin 9) pauliZ,
    (1 / 4 : ℂ) • ∑ i ∈ vertexOrbit 2, onWire i pauliZ] a

/-- PDF pp.12–13: the complete real prediction vector, before an unspecified tie rule. -/
def boardPrediction (W : List (List ((Fin 3 → Fin 2 → ℝ) × (Fin 3 → ℝ))))
    (x : Fin 9 → ℝ) : Fin 3 → ℝ :=
  fun a => expectation (boardObservable a) (act (learningCircuit boardLayer W x) (zeroKet 9))

/-- PDF p.15, Eq.(92): normalized central-Z vehicle regression. -/
def vehiclePrediction (W : List (List ((Fin 3 → Fin 2 → ℝ) × (Fin 4 → ℝ))))
    (x : Fin 9 → ℝ) : ℝ :=
  (expectation (onWire (8 : Fin 9) pauliZ) (act (learningCircuit vehicleLayer W x) (zeroKet 9)) + 1) / 2

example : boardReflection (0 : Fin 9) = 2 := by decide

example : vertexClass (8 : Fin 9) = 0 := by rfl

example {P : Type*} (layer : P → Op 9) (x : Fin 9 → ℝ) : learningCircuit layer [] x = 1 := by
  simp [learningCircuit]

/-- PDF p.16, Eq.(94): cyclic successor; only used with a positive chain length. -/
def nextSite {n : ℕ} (i : Fin n) : Fin n := ⟨(i.val + 1) % n, Nat.mod_lt _ (lt_of_le_of_lt (Nat.zero_le i.val) i.isLt)⟩

/-- PDF pp.16–18: sum of one-site axis generators. -/
def axisSum (n : ℕ) (a : Fin 3) : Op n := ∑ i, onWire i (axis a)

-- PDF p.16, Eq.(95): accepted tensor power, specialized to the global X parity.
local notation "parity" => (fun n : ℕ => QAlgorithms.Papers.Independent.Information100.P69.matrixPower pauliX n)

/-- PDF p.16, Eq.(94): periodic ferromagnetic TFIM, including literal Z_i^2 at n=1. -/
def tfim (n : ℕ) (g : ℝ) : Op n :=
  -(∑ i, onWire i pauliZ * onWire (nextSite i) pauliZ) - (g : ℂ) • axisSum n 0

/-- PDF p.17: normalized all-plus input. -/
def plusState (n : ℕ) : EuclideanSpace ℂ (Qubits n) :=
  WithLp.toLp 2 (fun _ => (((Real.sqrt 2)⁻¹ : ℂ) ^ n))

/-- PDF p.17, Eq.(97): QAOA matrix product, no half-angle factor. -/
def qaoa {n p : ℕ} (beta gamma : Fin p → ℝ) : Op n :=
  (List.ofFn (fun m => evolve (axisSum n 0) (beta m) *
    evolve (∑ i, onWire i pauliZ * onWire (nextSite i) pauliZ) (gamma m))).prod

/-- PDF p.17, Eq.(98): every generator of QAOA-prime is parity-twirled. -/
def twirledQaoa {n p : ℕ} (alpha beta gamma : Fin p → ℝ) : Op n :=
  (List.ofFn (fun m => evolve (involutionTwirl (parity n) (axisSum n 1)) (alpha m) *
    evolve (involutionTwirl (parity n) (axisSum n 0)) (beta m) *
    evolve (involutionTwirl (parity n) (∑ i, onWire i pauliZ * onWire (nextSite i) pauliZ)) (gamma m))).prod

example : nextSite (0 : Fin 1) = 0 := by decide

example (g : ℝ) : tfim 0 g = 0 := by simp [tfim, axisSum]

example (beta gamma : Fin 0 → ℝ) : qaoa (n := 1) beta gamma = 1 := by simp [qaoa]

/-- PDF p.17, Eq.(100): the native determinant-one qubit unitary group. -/
abbrev SU2 := Matrix.specialUnitaryGroup Bool ℂ

/-- PDF p.18, Eq.(104): the Borel sigma-algebra of the native SU(2) topology. -/
local instance su2MeasurableSpace : MeasurableSpace SU2 := borel SU2

/-- PDF p.18, Eq.(104): the chosen sigma-algebra is exactly Borel. -/
local instance su2BorelSpace : BorelSpace SU2 := ⟨rfl⟩

example : (inferInstance : MeasurableSpace SU2) = borel SU2 := by rfl

-- PDF p.17, Eq.(100): the accepted tensor power restricted to determinant-one unitaries.
local notation "collective" => (fun (n : ℕ) (V : SU2) => QAlgorithms.Papers.Independent.Information100.P69.matrixPower (Subtype.val V) n)

/-- PDF p.17, Eq.(99): periodic antiferromagnetic isotropic chain. -/
def heisenberg (n : ℕ) : Op n :=
  ∑ i, ∑ a : Fin 3, onWire i (axis a) * onWire (nextSite i) (axis a)

/-- PDF p.18, Eq.(101): neighboring normalized singlets on sites (0,1),(2,3),... . -/
def singletProduct (k : ℕ) : EuclideanSpace ℂ (Qubits (2 * k)) :=
  WithLp.toLp 2 (fun b => ∏ j : Fin k,
    if b ⟨2 * j.val, by omega⟩ = b ⟨2 * j.val + 1, by omega⟩ then 0
    else if b ⟨2 * j.val, by omega⟩ then -((Real.sqrt 2)⁻¹ : ℂ) else ((Real.sqrt 2)⁻¹ : ℂ))

/-- PDF pp.17–18: the usual total-spin squared, sum of the squares of collective half-Paulis. -/
def totalSpinSquared (n : ℕ) : Op n := ∑ a : Fin 3, ((1 / 2 : ℂ) • axisSum n a) ^ 2

/-- PDF p.18, Eq.(104): normalized collective SU(2) Haar average. -/
def collectiveTwirl (n : ℕ) (mu : Measure SU2) (A : Op n) : Op n := operatorHaarAverage mu (collective n) A

example : singletProduct 0 (fun i : Fin 0 => Fin.elim0 i) = 1 := by
  simp [singletProduct]

/-- PDF p.18, Eq.(103): zero-based bond starts 0,2,... for even, and 1,3,... for odd. -/
def bondHamiltonian (N : ℕ) (par : Fin 2) (b : Fin 3 → ℝ) : Op N :=
  ∑ i ∈ (Finset.univ : Finset (Fin N)).filter (fun i => i.val % 2 = par.val),
    ∑ a : Fin 3, (b a : ℂ) • (onWire i (axis a) * onWire (nextSite i) (axis a))

/-- PDF p.18, corrected Eq.(102): one Y-mixer and one even and one odd block per layer. -/
def twirledHeisenbergLayer (N : ℕ) (mu : Measure SU2) (theta : Fin 7 → ℝ) : Op N :=
  evolve (collectiveTwirl N mu (axisSum N 1)) (theta 0) *
  evolve (collectiveTwirl N mu (bondHamiltonian N 0 (fun a => theta ⟨a.val + 1, by omega⟩))) 1 *
  evolve (collectiveTwirl N mu (bondHamiltonian N 1 (fun a => theta ⟨a.val + 4, by omega⟩))) 1

/-- PDF p.18, corrected Eq.(110): one isotropic even and one isotropic odd block. -/
def isotropicLayer (N : ℕ) (b c : ℝ) : Op N :=
  evolve (bondHamiltonian N 0 (fun _ => 1)) b * evolve (bondHamiltonian N 1 (fun _ => 1)) c

/-- PDF p.18: the two surviving coordinates are the means of the three anisotropies. -/
def reduceHeisenberg (theta : Fin 7 → ℝ) : Fin 2 → ℝ :=
  ![(theta 1 + theta 2 + theta 3) / 3, (theta 4 + theta 5 + theta 6) / 3]

/-- PDF p.18: source parameter coordinates, not a claim about minimal functional dimension. -/
abbrev HeisenbergParameters (p : ℕ) (symmetric : Bool) := Fin p × Fin (if symmetric then 2 else 7)

example (N : ℕ) (mu : Measure SU2) :
    (List.ofFn (fun j : Fin 0 => twirledHeisenbergLayer N mu (fun _ => (j.elim0)))).prod = 1 := by simp

/-- PDF p.19, Fig.12: contour, inside, diagonal undirected edges, represented once each. -/
def latticeEdges (a : Fin 3) : Finset (Fin 9 × Fin 9) :=
  ![clockwiseEdges ∪ counterEdges, inwardEdges, diagonalEdges] a

/-- PDF p.19, Eqs.(112),(113): the sum of ZZ interactions in a fixed orbit. -/
def latticeInteraction (a : Fin 3) : Op 9 :=
  ∑ e ∈ latticeEdges a, onWire e.1 pauliZ * onWire e.2 pauliZ

/-- PDF p.19, Eqs.(111),(112): weights 1,1/2,3/2 on the fixed Fig.12 graph. -/
def latticeHamiltonian : Op 9 := latticeInteraction 0 + (1 / 2 : ℂ) • latticeInteraction 1 +
  (3 / 2 : ℂ) • latticeInteraction 2 + axisSum 9 0 + axisSum 9 2

/-- PDF pp.19–20: averaged local generator on one vertex orbit. -/
def orbitLocal (a : Matrix Bool Bool ℂ) (c : Fin 3) : Op 9 :=
  ((vertexOrbit c).card : ℂ)⁻¹ • ∑ i ∈ vertexOrbit c, onWire i a

/-- PDF pp.19–20: average ZZ generator in one edge orbit. -/
def orbitInteraction (c : Fin 3) : Op 9 :=
  ((latticeEdges c).card : ℂ)⁻¹ • latticeInteraction c

/-- PDF pp.19–20: finite D4 average over the actual board subgroup. -/
def boardTwirl (A : Op 9) : Op 9 :=
  let groupElements := (Finset.univ : Finset (Equiv.Perm (Fin 9))).filter (fun s => s ∈ boardGroup)
  (groupElements.card : ℂ)⁻¹ • ∑ s ∈ groupElements, conjugate (wireMatrix s) A

/-- PDF pp.19–20: one shared angle for each ZZ edge orbit and each X/Z vertex orbit. -/
def latticeLayer (theta : Fin 9 → ℝ) : Op 9 :=
  evolve (∑ c : Fin 3, (theta ⟨c.val + 6, by omega⟩ : ℂ) •
    ∑ i ∈ vertexOrbit c, onWire i pauliZ) (1 / 2) *
  evolve (∑ c : Fin 3, (theta ⟨c.val + 3, by omega⟩ : ℂ) •
    ∑ i ∈ vertexOrbit c, onWire i pauliX) (1 / 2) *
  evolve (∑ c : Fin 3, (theta ⟨c.val, by omega⟩ : ℂ) • latticeInteraction c) (1 / 2)

/-- PDF p.20: named parameter slots of the unrestricted ansatz. -/
abbrev LatticeOriginalParameters (p : ℕ) :=
  Fin p × (({e : Fin 9 × Fin 9 // e ∈ latticeEdges 0 ∪ latticeEdges 1 ∪ latticeEdges 2}) ⊕ (Fin 2 × Fin 9))

/-- PDF p.20: named parameter slots of the shared orbit ansatz. -/
abbrev LatticeSymmetricParameters (p : ℕ) := Fin p × Fin 9

example : (latticeEdges 1).card = 4 := by decide

end QAlgorithms.Papers.Independent.Extend50.P01
Source
Exploiting symmetry in variational quantum machine learning, arXiv:2205.06217v1, https://arxiv.org/abs/2205.06217v1
Read-back

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

QAlgorithms.Papers.Independent.Extend50.P01.HeisenbergParameters

For every natural number ppp and Boolean value sss, this abbreviates the set of pairs (j,a)(j,a)(j,a) with 0≤j<p0\le j<p0≤j<p and 0≤a<20\le a<20≤a<2 when sss is true, or 0≤a<70\le a<70≤a<7 when sss is false. For p=0p=0p=0, this set is empty for either Boolean value.

QAlgorithms.Papers.Independent.Extend50.P01.LatticeOriginalParameters

For every natural number ppp, this denotes the finite index set {0,…,p−1}×(E⊔({0,1}×{0,…,8}))\{0,\ldots,p-1\}\times\bigl(E\sqcup(\{0,1\}\times\{0,\ldots,8\})\bigr){0,…,p−1}×(E⊔({0,1}×{0,…,8})), where ⊔\sqcup⊔ is a disjoint union and EEE is the following set of ordered pairs:

E={(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5),(1,8),(3,8),(5,8),(7,8),(8,0),(8,2),(8,4),(8,6)}.E=\{(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5), (1,8),(3,8),(5,8),(7,8),(8,0),(8,2),(8,4),(8,6)\}.E={(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5),(1,8),(3,8),(5,8),(7,8),(8,0),(8,2),(8,4),(8,6)}.

Thus an index consists of a number less than ppp, together with either an ordered pair in EEE or a pair consisting of a number less than 222 and a number less than 999; the two alternatives remain distinct. When p=0p=0p=0, this index set is empty.

QAlgorithms.Papers.Independent.Extend50.P01.LatticeSymmetricParameters

For every natural number ppp, this denotes the Cartesian product {0,…,p−1}×{0,…,8}\{0,\ldots,p-1\}\times\{0,\ldots,8\}{0,…,p−1}×{0,…,8}. When p=0p=0p=0, this index set is empty.

QAlgorithms.Papers.Independent.Extend50.P01.SU2

This is an abbreviation for the special unitary group of complex matrices whose rows and columns are indexed by the two Boolean values: equivalently, the group of 2×22\times22×2 complex matrices UUU satisfying U†U=UU†=IU^\dagger U=UU^\dagger=IU†U=UU†=I and det⁡U=1\det U=1detU=1.

QAlgorithms.Papers.Independent.Extend50.P01.SignedPerm

For each natural number nnn, this is an abbreviation for the type of pairs (p,ε)(p,\varepsilon)(p,ε), where ppp is a permutation of {0,…,n−1}\{0,\ldots,n-1\}{0,…,n−1} and ε\varepsilonε is a Boolean-valued function on that set. No further conditions are imposed on either component. For n=0n=0n=0, this type has a single element, consisting of the empty permutation and the empty Boolean function.

QAlgorithms.Papers.Independent.Extend50.P01.axis

For every a∈{0,1,2}a\in\{0,1,2\}a∈{0,1,2}, this selects a complex matrix with Boolean row and column indices: a=0a=0a=0 selects XXX, a=1a=1a=1 selects YYY, and a=2a=2a=2 selects ZZZ. In the order (false,true)(\mathrm{false},\mathrm{true})(false,true), these matrices are

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

QAlgorithms.Papers.Independent.Extend50.P01.axisHadamard

For any indices a,b∈{0,1,2}a,b\in\{0,1,2\}a,b∈{0,1,2}, this defines the complex matrix on Boolean indices

exp⁡ ⁣[−iπ22(σa+σb)],\exp\!\left[-\frac{\mathrm{i}\pi}{2\sqrt2}(\sigma_a+\sigma_b)\right],exp[−22​iπ​(σa​+σb​)],

where σ0=(0110)\sigma_0=\begin{pmatrix}0&1\\1&0\end{pmatrix}σ0​=(01​10​), σ1=(0−ii0)\sigma_1=\begin{pmatrix}0&-\mathrm{i}\\ \mathrm{i}&0\end{pmatrix}σ1​=(0i​−i0​), and σ2=(100−1)\sigma_2=\begin{pmatrix}1&0\\0&-1\end{pmatrix}σ2​=(10​0−1​), in the order false, true. The indices need not differ; when a=ba=ba=b, the definition is exp⁡(−iπσa/2)\exp(-\mathrm{i}\pi\sigma_a/\sqrt2)exp(−iπσa​/2​).

QAlgorithms.Papers.Independent.Extend50.P01.axisSum

For every natural number nnn, including 000, and every a∈{0,1,2}a\in\{0,1,2\}a∈{0,1,2}, this defines the complex matrix on nnn-bit strings

Sa(n)=∑j=0n−1(Aa)j,A0=X,A1=Y,A2=Z,S_a^{(n)}=\sum_{j=0}^{n-1}(A_a)_j, \qquad A_0=X,\quad A_1=Y,\quad A_2=Z,Sa(n)​=j=0∑n−1​(Aa​)j​,A0​=X,A1​=Y,A2​=Z,

where

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

in the Boolean basis ordered as false, true. Explicitly, the (y,z)(y,z)(y,z) entry of (Aa)j(A_a)_j(Aa​)j​ is (Aa)yj,zj∏r≠j1{yr=zr}(A_a)_{y_j,z_j}\prod_{r\ne j}\mathbf1_{\{y_r=z_r\}}(Aa​)yj​,zj​​∏r=j​1{yr​=zr​}​. When n=0n=0n=0, the sum is empty and gives the zero matrix on the single empty bit string.

QAlgorithms.Papers.Independent.Extend50.P01.balancedEncoding

For every real vector x=(x0,x1,x2)x=(x_0,x_1,x_2)x=(x0​,x1​,x2​), this defines the complex matrix on Boolean pairs

exp⁡ ⁣[−i2(x0X⊗X+x1Y⊗Y+x2Z⊗Z)],\exp\!\left[-\frac{\mathrm{i}}2 \left(x_0X\otimes X+x_1Y\otimes Y+x_2Z\otimes Z\right)\right],exp[−2i​(x0​X⊗X+x1​Y⊗Y+x2​Z⊗Z)],

where, in the Boolean order false, true, X=(0110)X=\begin{pmatrix}0&1\\1&0\end{pmatrix}X=(01​10​), Y=(0−ii0)Y=\begin{pmatrix}0&-\mathrm{i}\\ \mathrm{i}&0\end{pmatrix}Y=(0i​−i0​), and Z=(100−1)Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix}Z=(10​0−1​).

QAlgorithms.Papers.Independent.Extend50.P01.basisEncoding

For all natural numbers n,mn,mn,m, every injection e:{0,…,m−1}↪{0,1}ne:\{0,\ldots,m-1\}\hookrightarrow\{0,1\}^ne:{0,…,m−1}↪{0,1}n, and every real vector x=(xk)k<mx=(x_k)_{k<m}x=(xk​)k<m​, this defines the matrix

exp⁡ ⁣(−i∑k=0m−1xk ∣e(k)⟩⟨e(k)∣),\exp\!\left(-\mathrm i\sum_{k=0}^{m-1}x_k\,|e(k)\rangle\langle e(k)|\right),exp(−ik=0∑m−1​xk​∣e(k)⟩⟨e(k)∣),

where ∣e(k)⟩|e(k)\rangle∣e(k)⟩ has coordinate 111 at the bit string e(k)e(k)e(k) and 000 elsewhere. Equivalently, its diagonal entry at e(k)e(k)e(k) is e−ixke^{-\mathrm i x_k}e−ixk​, its diagonal entries at other bit strings are 111, and its off-diagonal entries are 000. The injection requires m≤2nm\le 2^nm≤2n; m=0m=0m=0 gives the identity, and n=0n=0n=0 permits only m≤1m\le1m≤1.

QAlgorithms.Papers.Independent.Extend50.P01.boardGroup

This is the smallest subgroup of permutations of {0,…,8}\{0,\ldots,8\}{0,…,8} containing the rotation (0 2 4 6)(1 3 5 7)(0\ 2\ 4\ 6)(1\ 3\ 5\ 7)(0 2 4 6)(1 3 5 7) and the reflection (0 2)(7 3)(6 4)(0\ 2)(7\ 3)(6\ 4)(0 2)(7 3)(6 4). Its elements are all finite products of these permutations and their inverses, including the identity.

QAlgorithms.Papers.Independent.Extend50.P01.boardLayer

For every parameter pair p=(α,θ)p=(\alpha,\theta)p=(α,θ), where α:{0,1,2}×{0,1}→R\alpha:\{0,1,2\}\times\{0,1\}\to\mathbb Rα:{0,1,2}×{0,1}→R and θ:{0,1,2}→R\theta:\{0,1,2\}\to\mathbb Rθ:{0,1,2}→R, this defines a complex matrix on nine Boolean wires as follows. Let X,YX,YX,Y be the Pauli matrices, let P1=diag⁡(0,1)P_1=\operatorname{diag}(0,1)P1​=diag(0,1), and let AiA_iAi​ mean AAA on wire iii and the identity on all other wires: explicitly, (Ai)y,z=Ayi,zi∏r≠i1yr=zr(A_i)_{y,z}=A_{y_i,z_i}\prod_{r\ne i}\mathbf1_{y_r=z_r}(Ai​)y,z​=Ayi​,zi​​∏r=i​1yr​=zr​​. For an edge set FFF, put KY(F)=∑(i,j)∈F(P1)iYjK_Y(F)=\sum_{(i,j)\in F}(P_1)_iY_jKY​(F)=∑(i,j)∈F​(P1​)i​Yj​. Define

D={(8,0),(8,2),(8,4),(8,6)},I={(1,8),(3,8),(5,8),(7,8)},D=\{(8,0),(8,2),(8,4),(8,6)\},\quad I=\{(1,8),(3,8),(5,8),(7,8)\},D={(8,0),(8,2),(8,4),(8,6)},I={(1,8),(3,8),(5,8),(7,8)}, C={(0,1),(2,3),(4,5),(6,7)},A={(0,7),(2,1),(4,3),(6,5)}.C=\{(0,1),(2,3),(4,5),(6,7)\},\qquad A=\{(0,7),(2,1),(4,3),(6,5)\}.C={(0,1),(2,3),(4,5),(6,7)},A={(0,7),(2,1),(4,3),(6,5)}.

Let c(8)=0c(8)=0c(8)=0, let c(i)=1c(i)=1c(i)=1 for even i<8i<8i<8, and let c(i)=2c(i)=2c(i)=2 for odd iii. Then the defined matrix is

e−iθ(2)KY(D)/2 e−iθ(1)KY(I)/2 e−iθ(0)KY(C∪A)/2 ⨂i=08(e−iα(c(i),1)Y/2e−iα(c(i),0)X/2).e^{-i\theta(2)K_Y(D)/2}\, e^{-i\theta(1)K_Y(I)/2}\, e^{-i\theta(0)K_Y(C\cup A)/2}\, \bigotimes_{i=0}^{8} \left( e^{-i\alpha(c(i),1)Y/2} e^{-i\alpha(c(i),0)X/2} \right).e−iθ(2)KY​(D)/2e−iθ(1)KY​(I)/2e−iθ(0)KY​(C∪A)/2i=0⨂8​(e−iα(c(i),1)Y/2e−iα(c(i),0)X/2).

All parameters are arbitrary real numbers.

QAlgorithms.Papers.Independent.Extend50.P01.boardObservable

For every index a∈{0,1,2}a\in\{0,1,2\}a∈{0,1,2}, this defines a complex matrix OaO_aOa​ on nine-bit strings by

O0=14(Z0+Z2+Z4+Z6),O1=Z8,O2=14(Z1+Z3+Z5+Z7),O_0=\frac14(Z_0+Z_2+Z_4+Z_6), \qquad O_1=Z_8, \qquad O_2=\frac14(Z_1+Z_3+Z_5+Z_7),O0​=41​(Z0​+Z2​+Z4​+Z6​),O1​=Z8​,O2​=41​(Z1​+Z3​+Z5​+Z7​),

where Z=diag⁡(1,−1)Z=\operatorname{diag}(1,-1)Z=diag(1,−1) in the Boolean basis ordered as false, true, and ZjZ_jZj​ acts as ZZZ on wire jjj and as the identity on every other wire. Equivalently, these matrices are diagonal, with respective diagonal entries 14∑j∈{0,2,4,6}(−1)zj\frac14\sum_{j\in\{0,2,4,6\}}(-1)^{z_j}41​∑j∈{0,2,4,6}​(−1)zj​, (−1)z8(-1)^{z_8}(−1)z8​, and 14∑j∈{1,3,5,7}(−1)zj\frac14\sum_{j\in\{1,3,5,7\}}(-1)^{z_j}41​∑j∈{1,3,5,7}​(−1)zj​ at a nine-bit string zzz.

QAlgorithms.Papers.Independent.Extend50.P01.boardPrediction

For every finite list WWW of finite lists of parameter pairs (α,θ)(\alpha,\theta)(α,θ), with α:{0,1,2}×{0,1}→R\alpha:\{0,1,2\}\times\{0,1\}\to\mathbb Rα:{0,1,2}×{0,1}→R and θ:{0,1,2}→R\theta:\{0,1,2\}\to\mathbb Rθ:{0,1,2}→R, and every feature vector x:{0,…,8}→Rx:\{0,\ldots,8\}\to\mathbb Rx:{0,…,8}→R, this defines three real outputs. Let X,Y,ZX,Y,ZX,Y,Z be the Pauli matrices, let P1=diag⁡(0,1)P_1=\operatorname{diag}(0,1)P1​=diag(0,1), and write AiA_iAi​ for AAA on wire iii and identities elsewhere. Define the edge sets D={(8,0),(8,2),(8,4),(8,6)}D=\{(8,0),(8,2),(8,4),(8,6)\}D={(8,0),(8,2),(8,4),(8,6)}, I={(1,8),(3,8),(5,8),(7,8)}I=\{(1,8),(3,8),(5,8),(7,8)\}I={(1,8),(3,8),(5,8),(7,8)}, C={(0,1),(2,3),(4,5),(6,7)}C=\{(0,1),(2,3),(4,5),(6,7)\}C={(0,1),(2,3),(4,5),(6,7)}, and A={(0,7),(2,1),(4,3),(6,5)}A=\{(0,7),(2,1),(4,3),(6,5)\}A={(0,7),(2,1),(4,3),(6,5)}, and put KY(F)=∑(i,j)∈F(P1)iYjK_Y(F)=\sum_{(i,j)\in F}(P_1)_iY_jKY​(F)=∑(i,j)∈F​(P1​)i​Yj​. Assign classes c(8)=0c(8)=0c(8)=0, c(0)=c(2)=c(4)=c(6)=1c(0)=c(2)=c(4)=c(6)=1c(0)=c(2)=c(4)=c(6)=1, and c(1)=c(3)=c(5)=c(7)=2c(1)=c(3)=c(5)=c(7)=2c(1)=c(3)=c(5)=c(7)=2. For a parameter pair define

L(α,θ)=e−iθ(2)KY(D)/2e−iθ(1)KY(I)/2e−iθ(0)KY(C∪A)/2⨂i=08(e−iα(c(i),1)Y/2e−iα(c(i),0)X/2).L(\alpha,\theta)= e^{-i\theta(2)K_Y(D)/2}e^{-i\theta(1)K_Y(I)/2} e^{-i\theta(0)K_Y(C\cup A)/2} \bigotimes_{i=0}^{8} \left(e^{-i\alpha(c(i),1)Y/2}e^{-i\alpha(c(i),0)X/2}\right).L(α,θ)=e−iθ(2)KY​(D)/2e−iθ(1)KY​(I)/2e−iθ(0)KY​(C∪A)/2i=0⨂8​(e−iα(c(i),1)Y/2e−iα(c(i),0)X/2).

Set E(x)=⨂i=08e−iπxiX/3E(x)=\bigotimes_{i=0}^{8}e^{-i\pi x_iX/3}E(x)=⨂i=08​e−iπxi​X/3. If block bbb of WWW contains parameters pb,1,…,pb,mbp_{b,1},\ldots,p_{b,m_b}pb,1​,…,pb,mb​​, put Fb=L(pb,mb)⋯L(pb,1)E(x)F_b=L(p_{b,m_b})\cdots L(p_{b,1})E(x)Fb​=L(pb,mb​​)⋯L(pb,1​)E(x); for rrr blocks put QW(x)=Fr⋯F1Q_W(x)=F_r\cdots F_1QW​(x)=Fr​⋯F1​. Empty matrix products are identities, so an empty block contributes E(x)E(x)E(x), whereas an empty outer list gives QW(x)=1Q_W(x)=1QW​(x)=1. Define O0=(Z0+Z2+Z4+Z6)/4O_0=(Z_0+Z_2+Z_4+Z_6)/4O0​=(Z0​+Z2​+Z4​+Z6​)/4, O1=Z8O_1=Z_8O1​=Z8​, and O2=(Z1+Z3+Z5+Z7)/4O_2=(Z_1+Z_3+Z_5+Z_7)/4O2​=(Z1​+Z3​+Z5​+Z7​)/4. The output at a∈{0,1,2}a\in\{0,1,2\}a∈{0,1,2} is the operation named expectation applied to OaO_aOa​ and QW(x)∣09⟩Q_W(x)|0^9\rangleQW​(x)∣09⟩, where ∣09⟩|0^9\rangle∣09⟩ is the vector equal to 111 at the all-false string and 000 elsewhere. The supplied code does not include a defining formula for expectation.

QAlgorithms.Papers.Independent.Extend50.P01.boardReflection

The permutation of {0,…,8}\{0,\ldots,8\}{0,…,8} exchanges 000 with 222, 777 with 333, and 666 with 444, and fixes 111, 555, and 888.

QAlgorithms.Papers.Independent.Extend50.P01.boardRotation

This definition gives the permutation of {0,…,8}\{0,\ldots,8\}{0,…,8} formed by

((0 2)(2 4)(4 6))((1 3)(3 5)(5 7)),\bigl((0\,2)(2\,4)(4\,6)\bigr) \bigl((1\,3)(3\,5)(5\,7)\bigr),((02)(24)(46))((13)(35)(57)),

with the rightmost factor applied first. Equivalently, it is the permutation with disjoint cycles (0 2 4 6)(1 3 5 7)(0\,2\,4\,6)(1\,3\,5\,7)(0246)(1357), fixing 888.

QAlgorithms.Papers.Independent.Extend50.P01.boardSingle

For every array of real angles α:{0,1,2}×{0,1}→R\alpha:\{0,1,2\}\times\{0,1\}\to\mathbb Rα:{0,1,2}×{0,1}→R, this defines a complex matrix on nine Boolean wires. Assign wire 888 class 000, wires 0,2,4,60,2,4,60,2,4,6 class 111, and wires 1,3,5,71,3,5,71,3,5,7 class 222; write this class as c(i)c(i)c(i). With X,YX,YX,Y the Pauli matrices and EA(t)=exp⁡(−itA)E_A(t)=\exp(-itA)EA​(t)=exp(−itA), the matrix has entries

B(α)y,z=∏i=08[EY ⁣(α(c(i),1)2)EX ⁣(α(c(i),0)2)]yi,zi,y,z∈{0,1}9.B(\alpha)_{y,z} =\prod_{i=0}^{8} \left[ E_Y\!\left(\frac{\alpha(c(i),1)}2\right) E_X\!\left(\frac{\alpha(c(i),0)}2\right) \right]_{y_i,z_i}, \qquad y,z\in\{0,1\}^9.B(α)y,z​=i=0∏8​[EY​(2α(c(i),1)​)EX​(2α(c(i),0)​)]yi​,zi​​,y,z∈{0,1}9.

Thus each factor is the displayed ordered product of two single-qubit matrix exponentials, and the full matrix is their tensor product.

QAlgorithms.Papers.Independent.Extend50.P01.boardTwirl

For every complex nine-qubit matrix AAA, let GGG be the subgroup of permutations of {0,…,8}\{0,\ldots,8\}{0,…,8} generated by

R=((0 2)(2 4)(4 6))((1 3)(3 5)(5 7)),F=(0 2)(7 3)(6 4),R=((0\,2)(2\,4)(4\,6))((1\,3)(3\,5)(5\,7)), \qquad F=(0\,2)(7\,3)(6\,4),R=((02)(24)(46))((13)(35)(57)),F=(02)(73)(64),

with permutation products acting by composition, the rightmost factor first. This defines

1∣G∣∑s∈GC(Ws,A),(Ws)x,y=1{xi=ys−1(i) for every i},\frac1{|G|}\sum_{s\in G}\mathcal C(W_s,A), \qquad (W_s)_{x,y}=\mathbf1_{\{x_i=y_{s^{-1}(i)}\text{ for every }i\}},∣G∣1​s∈G∑​C(Ws​,A),(Ws​)x,y​=1{xi​=ys−1(i)​ for every i}​,

for Boolean strings x,yx,yx,y of length nine. Here C\mathcal CC is the matrix operation named conjugate, whose defining body is not supplied. The sum ranges over every permutation belonging to the generated subgroup, and its denominator is nonzero because that subgroup contains the identity. No Hermitian or normalization assumption is imposed on AAA.

QAlgorithms.Papers.Independent.Extend50.P01.bondHamiltonian

For every natural number NNN, every par∈{0,1}\mathrm{par}\in\{0,1\}par∈{0,1}, and every real triple (bX,bY,bZ)(b_X,b_Y,b_Z)(bX​,bY​,bZ​), this defines the complex matrix on NNN-bit strings

Hpar(b)=∑0≤j<Njmod2=par(bXXjXj+1 mod N+bYYjYj+1 mod N+bZZjZj+1 mod N),H_{\mathrm{par}}(b)= \sum_{\substack{0\le j<N\\j\bmod2=\mathrm{par}}} \left( b_X X_jX_{j+1\bmod N} +b_Y Y_jY_{j+1\bmod N} +b_Z Z_jZ_{j+1\bmod N} \right),Hpar​(b)=0≤j<Njmod2=par​∑​(bX​Xj​Xj+1modN​+bY​Yj​Yj+1modN​+bZ​Zj​Zj+1modN​),

where each Pauli operator acts on its indicated wire and as the identity elsewhere. There is no assumption that NNN is positive or even, or that the coefficients have any particular sign. For N=0N=0N=0 the sum is zero; for N=1N=1N=1 it is (bX+bY+bZ)I(b_X+b_Y+b_Z)I(bX​+bY​+bZ​)I when par=0\mathrm{par}=0par=0 and zero when par=1\mathrm{par}=1par=1.

QAlgorithms.Papers.Independent.Extend50.P01.clockwiseEdges

This finite set of ordered pairs of indices in {0,…,8}\{0,\ldots,8\}{0,…,8} is exactly {(0,1),(2,3),(4,5),(6,7)}\{(0,1),(2,3),(4,5),(6,7)\}{(0,1),(2,3),(4,5),(6,7)}.

QAlgorithms.Papers.Independent.Extend50.P01.collectiveTwirl

For every natural number nnn, every measure μ\muμ on the special unitary group of 2×22\times22×2 complex matrices indexed by Boolean values, and every complex matrix AAA on nnn-bit strings, this defines

Tn,μ(A)=∫C(Un(V),A) dμ(V),\mathcal T_{n,\mu}(A) =\int \mathcal C(\mathcal U_n(V),A)\,d\mu(V),Tn,μ​(A)=∫C(Un​(V),A)dμ(V),

where Un(V)\mathcal U_n(V)Un​(V) denotes the matrix named collective n V and C(V,A)\mathcal C(V,A)C(V,A) denotes the operation named conjugate V A; their defining formulas are not supplied. The integral is the matrix-valued Bochner integral. The definition imposes no Haar, probability, or integrability assumption on μ\muμ or the integrand; the totalized Bochner integral is zero when the integrand is not integrable. The value n=0n=0n=0 is allowed.

QAlgorithms.Papers.Independent.Extend50.P01.controlledGenerator

For any complex matrix aaa indexed by {false,true}\{\mathrm{false},\mathrm{true}\}{false,true} and any ordered pair e=(u,v)∈{0,…,8}2e=(u,v)\in\{0,\ldots,8\}^2e=(u,v)∈{0,…,8}2, this defines a matrix Ga,eG_{a,e}Ga,e​ indexed by nine-bit strings. For strings x,yx,yx,y, its entry is

(Ga,e)x,y=1{xu=true} axv,yv∏r=0r≠v81{xr=yr}.(G_{a,e})_{x,y} =\mathbf 1_{\{x_u=\mathrm{true}\}}\, a_{x_v,y_v}\prod_{\substack{r=0\\r\ne v}}^8\mathbf 1_{\{x_r=y_r\}}.(Ga,e​)x,y​=1{xu​=true}​axv​,yv​​r=0r=v​∏8​1{xr​=yr​}​.

Here each indicator is 111 when its condition holds and 000 otherwise. No Hermitian or unitary condition is imposed on aaa, and u=vu=vu=v is allowed.

QAlgorithms.Papers.Independent.Extend50.P01.controlledOrbit

For any complex matrix aaa indexed by Boolean values, any finite set E⊆{0,…,8}2E\subseteq\{0,\ldots,8\}^2E⊆{0,…,8}2 of ordered pairs, and any real θ\thetaθ, this defines the matrix

exp⁡ ⁣(−iθ2∑(u,v)∈EGa,(u,v)),(Ga,(u,v))x,y=1{xu=true}axv,yv∏r=0r≠v81{xr=yr},\exp\!\left(-\frac{\mathrm i\theta}{2}\sum_{(u,v)\in E}G_{a,(u,v)}\right), \qquad (G_{a,(u,v)})_{x,y} =\mathbf 1_{\{x_u=\mathrm{true}\}}a_{x_v,y_v} \prod_{\substack{r=0\\r\ne v}}^8\mathbf 1_{\{x_r=y_r\}},exp​−2iθ​(u,v)∈E∑​Ga,(u,v)​​,(Ga,(u,v)​)x,y​=1{xu​=true}​axv​,yv​​r=0r=v​∏8​1{xr​=yr​}​,

indexed by nine-bit strings x,yx,yx,y, where exp⁡\expexp is the matrix exponential. The set EEE may be empty and may contain pairs with equal coordinates; aaa need not be Hermitian or unitary. For empty EEE, or for θ=0\theta=0θ=0, the result is the identity.

QAlgorithms.Papers.Independent.Extend50.P01.counterEdges

This finite set of ordered pairs of indices in {0,…,8}\{0,\ldots,8\}{0,…,8} is exactly {(0,7),(2,1),(4,3),(6,5)}\{(0,7),(2,1),(4,3),(6,5)\}{(0,7),(2,1),(4,3),(6,5)}.

QAlgorithms.Papers.Independent.Extend50.P01.diagonalEdges

This finite set of ordered pairs of indices in {0,…,8}\{0,\ldots,8\}{0,…,8} is exactly {(8,0),(8,2),(8,4),(8,6)}\{(8,0),(8,2),(8,4),(8,6)\}{(8,0),(8,2),(8,4),(8,6)}.

QAlgorithms.Papers.Independent.Extend50.P01.extraEncoding

For every natural number ddd and real vector xxx indexed by {0,…,d}\{0,\ldots,d\}{0,…,d}, this defines the diagonal complex matrix indexed by ddd-bit strings whose diagonal entry at bbb is

exp⁡ ⁣[−i2(∑k=0d−1xk(−1)[bk]+xd(−1)∣{j<d:bj=true}∣)],\exp\!\left[-\frac{\mathrm{i}}2\left( \sum_{k=0}^{d-1}x_k(-1)^{[b_k]} +x_d(-1)^{|\{j<d:b_j=\mathrm{true}\}|} \right)\right],exp[−2i​(k=0∑d−1​xk​(−1)[bk​]+xd​(−1)∣{j<d:bj​=true}∣)],

and whose off-diagonal entries are zero. This is the matrix exponential of −i/2-\mathrm{i}/2−i/2 times the weighted sum of the individual-coordinate ZZZ matrices and the product of ZZZ over all coordinates. For d=0d=0d=0, it is the 1×11\times11×1 matrix with entry e−ix0/2e^{-\mathrm{i}x_0/2}e−ix0​/2.

QAlgorithms.Papers.Independent.Extend50.P01.extraGenerator

For every natural number ddd and index k∈{0,…,d}k\in\{0,\ldots,d\}k∈{0,…,d}, this defines a complex diagonal matrix indexed by ddd-bit strings. If k<dk<dk<d, its diagonal entry at a string bbb is 111 when bkb_kbk​ is false and −1-1−1 when bkb_kbk​ is true, with identity action on the other coordinates. If k=dk=dk=d, its diagonal entry is (−1)∣{j<d:bj=true}∣(-1)^{|\{j<d:b_j=\mathrm{true}\}|}(−1)∣{j<d:bj​=true}∣. All off-diagonal entries are zero. For d=0d=0d=0, the sole index k=0k=0k=0 selects the empty product, giving the 1×11\times11×1 identity; for d=1d=1d=1, both indices select the same matrix.

QAlgorithms.Papers.Independent.Extend50.P01.extraSwap

For every natural number ddd and coordinate i∈{0,…,d−1}i\in\{0,\ldots,d-1\}i∈{0,…,d−1}, this defines a complex matrix indexed by ddd-bit strings. Its entry at row aaa and column bbb is 111 exactly when aj=bja_j=b_jaj​=bj​ for all j≠ij\ne ij=i and aia_iai​ is the exclusive OR of bib_ibi​ with the parity of the true bits at all other coordinates; otherwise the entry is 000. Equivalently, the new bit at iii is the parity of all bits of bbb. For d=1d=1d=1, the sum over other coordinates is empty and false, so the matrix is the identity. For d=0d=0d=0, there is no allowable coordinate iii.

QAlgorithms.Papers.Independent.Extend50.P01.featureMatrix

For all natural numbers n,mn,mn,m, every injection e:{0,…,m−1}↪{0,1}ne:\{0,\ldots,m-1\}\hookrightarrow\{0,1\}^ne:{0,…,m−1}↪{0,1}n, and every permutation sss of {0,…,m−1}\{0,\ldots,m-1\}{0,…,m−1}, this defines the permutation matrix of the permutation s~\widetilde ss of nnn-bit strings specified by

s~(e(k))=e(s(k)),s~(b)=bwhen b∉e({0,…,m−1}).\widetilde s(e(k))=e(s(k)),\qquad \widetilde s(b)=b\quad\text{when }b\notin e(\{0,\ldots,m-1\}).s(e(k))=e(s(k)),s(b)=bwhen b∈/e({0,…,m−1}).

Its row-aaa, column-bbb entry is 111 if a=s~(b)a=\widetilde s(b)a=s(b) and 000 otherwise. The injection requires m≤2nm\le2^nm≤2n; when m=0m=0m=0, the matrix is the identity.

QAlgorithms.Papers.Independent.Extend50.P01.featurePullback

For every natural number nnn, every permutation ppp of {0,…,n−1}\{0,\ldots,n-1\}{0,…,n−1}, and every real vector xxx indexed by that set, this defines the real vector yyy given by yi=xp−1(i)y_i=x_{p^{-1}(i)}yi​=xp−1(i)​. The definition includes n=0n=0n=0, when both input and output vectors are the unique empty vector.

QAlgorithms.Papers.Independent.Extend50.P01.finiteTwirl

For types SSS and ι\iotaι, each equipped with a finite enumeration, any family UsU_sUs​ of complex matrices indexed by ι×ι\iota\times\iotaι×ι, and any complex matrix AAA with those indices, this defines the matrix

1∣S∣∑s∈SC(Us,A).\frac{1}{|S|}\sum_{s\in S} C(U_s,A).∣S∣1​s∈S∑​C(Us​,A).

Here C(V,A)C(V,A)C(V,A) denotes the two-argument operation named conjugate; its defining formula is not included in the supplied code. No unitarity assumption on UsU_sUs​ is imposed. If SSS is empty, the result is zero: the sum is zero and the scalar inverse of zero is defined to be zero. The index type ι\iotaι may also be empty.

QAlgorithms.Papers.Independent.Extend50.P01.heisenberg

For every natural number nnn, this defines the complex matrix on nnn-bit strings

HH(n)=∑j=0n−1(XjXj+1 mod n+YjYj+1 mod n+ZjZj+1 mod n),H_{\mathrm H}(n)= \sum_{j=0}^{n-1} \left(X_jX_{j+1\bmod n} +Y_jY_{j+1\bmod n} +Z_jZ_{j+1\bmod n}\right),HH​(n)=j=0∑n−1​(Xj​Xj+1modn​+Yj​Yj+1modn​+Zj​Zj+1modn​),

where each Pauli operator acts on its indicated wire and as the identity elsewhere. No positivity or lower bound on nnn is assumed: for n=0n=0n=0 the sum is zero on the one-dimensional empty-string space; for n=1n=1n=1 it equals 3I3I3I; and for n=2n=2n=2 each pair interaction is counted twice.

QAlgorithms.Papers.Independent.Extend50.P01.inversionEncoding

For every real vector x=(x0,x1,x2)x=(x_0,x_1,x_2)x=(x0​,x1​,x2​), this defines the complex matrix indexed by pairs of Boolean bits

exp⁡ ⁣(−i2(x0X+x1Y+x2Z)⊗X),\exp\!\left(-\frac{\mathrm i}{2} \bigl(x_0X+x_1Y+x_2Z\bigr)\otimes X\right),exp(−2i​(x0​X+x1​Y+x2​Z)⊗X),

where X,Y,ZX,Y,ZX,Y,Z are the Pauli matrices and ⊗\otimes⊗ is the Kronecker product. The three coordinates of xxx are unrestricted real numbers.

QAlgorithms.Papers.Independent.Extend50.P01.involutionTwirl

For every finite index type ι\iotaι and arbitrary complex matrices V,AV,AV,A indexed by ι\iotaι, this definition assigns

TV(A)=12(A+VAV†).\mathcal T_V(A)=\frac12\bigl(A+VAV^\dagger\bigr).TV​(A)=21​(A+VAV†).

There is no assumption that VVV is unitary or satisfies V2=IV^2=IV2=I, and the index type may be empty.

QAlgorithms.Papers.Independent.Extend50.P01.inwardEdges

This finite set of ordered pairs of indices in {0,…,8}\{0,\ldots,8\}{0,…,8} is exactly {(1,8),(3,8),(5,8),(7,8)}\{(1,8),(3,8),(5,8),(7,8)\}{(1,8),(3,8),(5,8),(7,8)}.

QAlgorithms.Papers.Independent.Extend50.P01.isotropicLayer

For every natural number NNN and real numbers b,cb,cb,c, let Xi,Yi,ZiX_i,Y_i,Z_iXi​,Yi​,Zi​ be the supplied Pauli matrices acting on wire iii, with identity elsewhere, and define

Hε=∑0≤i<Nimod2=ε(XiXi+1 mod N+YiYi+1 mod N+ZiZi+1 mod N).H_\varepsilon= \sum_{\substack{0\le i<N\\i\bmod2=\varepsilon}} \left(X_iX_{i+1\bmod N}+Y_iY_{i+1\bmod N}+Z_iZ_{i+1\bmod N}\right).Hε​=0≤i<Nimod2=ε​∑​(Xi​Xi+1modN​+Yi​Yi+1modN​+Zi​Zi+1modN​).

This defines the NNN-qubit operator

exp⁡(−ibH0)exp⁡(−icH1).\exp(-\mathrm i bH_0)\exp(-\mathrm i cH_1).exp(−ibH0​)exp(−icH1​).

There are no positivity restrictions on b,cb,cb,c. For N=0N=0N=0, both sums are empty and the result is the identity; for N=1N=1N=1, the cyclic neighbor is the same wire, giving H0=3IH_0=3IH0​=3I and H1=0H_1=0H1​=0.

QAlgorithms.Papers.Independent.Extend50.P01.kleinData

For every Boolean pair a=(a1,a2)a=(a_1,a_2)a=(a1​,a2​) and real vector x=(x0,x1)x=(x_0,x_1)x=(x0​,x1​), this defines a two-coordinate real vector by first exchanging the coordinates if a1a_1a1​ is true and then multiplying both coordinates by −1-1−1 if a2a_2a2​ is true. Explicitly, its coordinate i∈{0,1}i\in\{0,1\}i∈{0,1} is (−1)[a2]xτ(i)(-1)^{[a_2]}x_{\tau(i)}(−1)[a2​]xτ(i)​, where [a2][a_2][a2​] is 111 for true and 000 for false, and τ\tauτ is the transposition of 000 and 111 when a1a_1a1​ is true and the identity otherwise.

QAlgorithms.Papers.Independent.Extend50.P01.kleinEncoding

For every real vector x=(x0,x1)x=(x_0,x_1)x=(x0​,x1​), this defines the complex matrix

exp⁡ ⁣(−ix02Z)⊗exp⁡ ⁣(−ix12Z),Z=(100−1),\exp\!\left(-\mathrm{i}\frac{x_0}{2}Z\right)\otimes \exp\!\left(-\mathrm{i}\frac{x_1}{2}Z\right), \qquad Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix},exp(−i2x0​​Z)⊗exp(−i2x1​​Z),Z=(10​0−1​),

with Boolean indices ordered as false, true. Thus the matrix is diagonal on Boolean pairs b=(b0,b1)b=(b_0,b_1)b=(b0​,b1​), with diagonal entry exp⁡ ⁣(−i2((−1)[b0]x0+(−1)[b1]x1))\exp\!\left(-\frac{\mathrm{i}}2\bigl((-1)^{[b_0]}x_0+(-1)^{[b_1]}x_1\bigr)\right)exp(−2i​((−1)[b0​]x0​+(−1)[b1​]x1​)); all off-diagonal entries are zero.

QAlgorithms.Papers.Independent.Extend50.P01.kleinMatrix

For every Boolean pair a=(a1,a2)a=(a_1,a_2)a=(a1​,a2​), this defines a complex matrix indexed by Boolean pairs as S[a1](X⊗X)[a2]S^{[a_1]}(X\otimes X)^{[a_2]}S[a1​](X⊗X)[a2​], where SSS exchanges the two bits, X=(0110)X=\begin{pmatrix}0&1\\1&0\end{pmatrix}X=(01​10​), and [aj][a_j][aj​] is 111 for true and 000 for false. Equivalently, its entry at row ppp and column qqq is 111 if ppp is obtained from qqq by complementing both bits when a2a_2a2​ is true and exchanging the bits when a1a_1a1​ is true, and is 000 otherwise.

QAlgorithms.Papers.Independent.Extend50.P01.kleinMul

For any two 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 their product to be (a1xorb1, a2xorb2)(a_1\mathbin{\mathrm{xor}}b_1,\ a_2\mathbin{\mathrm{xor}}b_2)(a1​xorb1​, a2​xorb2​), where exclusive OR is true exactly when its two arguments differ.

QAlgorithms.Papers.Independent.Extend50.P01.latticeEdges

For each a∈{0,1,2}a\in\{0,1,2\}a∈{0,1,2}, this defines a finite set EaE_aEa​ of ordered pairs of indices in {0,…,8}\{0,\ldots,8\}{0,…,8}, explicitly

E0={(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)},E1={(1,8),(3,8),(5,8),(7,8)},E2={(8,0),(8,2),(8,4),(8,6)}.\begin{aligned} E_0&=\{(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)\},\\ E_1&=\{(1,8),(3,8),(5,8),(7,8)\},\\ E_2&=\{(8,0),(8,2),(8,4),(8,6)\}. \end{aligned}E0​E1​E2​​={(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)},={(1,8),(3,8),(5,8),(7,8)},={(8,0),(8,2),(8,4),(8,6)}.​

These are finite sets, so any repeated pair in their construction would be counted only once.

QAlgorithms.Papers.Independent.Extend50.P01.latticeHamiltonian

This defines the nine-qubit operator

∑(u,v)∈E0ZuZv+12∑(u,v)∈E1ZuZv+32∑(u,v)∈E2ZuZv+∑i=08Xi+∑i=08Zi,\sum_{(u,v)\in E_0}Z_uZ_v+ \frac12\sum_{(u,v)\in E_1}Z_uZ_v+ \frac32\sum_{(u,v)\in E_2}Z_uZ_v+ \sum_{i=0}^{8}X_i+\sum_{i=0}^{8}Z_i,(u,v)∈E0​∑​Zu​Zv​+21​(u,v)∈E1​∑​Zu​Zv​+23​(u,v)∈E2​∑​Zu​Zv​+i=0∑8​Xi​+i=0∑8​Zi​,

where XiX_iXi​ flips bit iii, ZiZ_iZi​ multiplies a computational basis vector by +1+1+1 or −1-1−1 according as bit iii is false or true, and both act as identity on other wires. The ordered edge sets are E0={(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)}E_0=\{(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)\}E0​={(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)}, E1={(1,8),(3,8),(5,8),(7,8)}E_1=\{(1,8),(3,8),(5,8),(7,8)\}E1​={(1,8),(3,8),(5,8),(7,8)}, and E2={(8,0),(8,2),(8,4),(8,6)}E_2=\{(8,0),(8,2),(8,4),(8,6)\}E2​={(8,0),(8,2),(8,4),(8,6)}.

QAlgorithms.Papers.Independent.Extend50.P01.latticeInteraction

For each a∈{0,1,2}a\in\{0,1,2\}a∈{0,1,2}, this defines the nine-qubit operator

∑(u,v)∈EaZuZv,\sum_{(u,v)\in E_a}Z_uZ_v,(u,v)∈Ea​∑​Zu​Zv​,

where ZiZ_iZi​ acts diagonally by +1+1+1 when bit iii is false and by −1-1−1 when it is true, leaving the other wires unchanged, and

E0={(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)},E1={(1,8),(3,8),(5,8),(7,8)},E2={(8,0),(8,2),(8,4),(8,6)}.\begin{aligned} E_0&=\{(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)\},\\ E_1&=\{(1,8),(3,8),(5,8),(7,8)\},\\ E_2&=\{(8,0),(8,2),(8,4),(8,6)\}. \end{aligned}E0​E1​E2​​={(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)},={(1,8),(3,8),(5,8),(7,8)},={(8,0),(8,2),(8,4),(8,6)}.​

Every listed ordered pair contributes one summand.

QAlgorithms.Papers.Independent.Extend50.P01.latticeLayer

For every nine real parameters θ0,…,θ8\theta_0,\ldots,\theta_8θ0​,…,θ8​, this defines the nine-qubit matrix

exp⁡ ⁣(−i2∑c=02θc+6∑i∈VcZi)exp⁡ ⁣(−i2∑c=02θc+3∑i∈VcXi)exp⁡ ⁣(−i2∑c=02θc∑(u,v)∈EcZuZv).\exp\!\left(-\frac{\mathrm i}{2}\sum_{c=0}^{2}\theta_{c+6}\sum_{i\in V_c}Z_i\right) \exp\!\left(-\frac{\mathrm i}{2}\sum_{c=0}^{2}\theta_{c+3}\sum_{i\in V_c}X_i\right) \exp\!\left(-\frac{\mathrm i}{2}\sum_{c=0}^{2}\theta_c\sum_{(u,v)\in E_c}Z_uZ_v\right).exp(−2i​c=0∑2​θc+6​i∈Vc​∑​Zi​)exp(−2i​c=0∑2​θc+3​i∈Vc​∑​Xi​)exp​−2i​c=0∑2​θc​(u,v)∈Ec​∑​Zu​Zv​​.

Here XiX_iXi​ flips wire iii, ZiZ_iZi​ gives sign +1+1+1 on false and −1-1−1 on true at wire iii, and both act as identity elsewhere; V0={8}V_0=\{8\}V0​={8}, V1={0,2,4,6}V_1=\{0,2,4,6\}V1​={0,2,4,6}, and V2={1,3,5,7}V_2=\{1,3,5,7\}V2​={1,3,5,7}. The ordered edge sets are E0={(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)}E_0=\{(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)\}E0​={(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)}, E1={(1,8),(3,8),(5,8),(7,8)}E_1=\{(1,8),(3,8),(5,8),(7,8)\}E1​={(1,8),(3,8),(5,8),(7,8)}, and E2={(8,0),(8,2),(8,4),(8,6)}E_2=\{(8,0),(8,2),(8,4),(8,6)\}E2​={(8,0),(8,2),(8,4),(8,6)}. The factors occur in the displayed matrix-multiplication order, so their action on a vector applies the interaction factor first.

QAlgorithms.Papers.Independent.Extend50.P01.learningCircuit

For every type PPP, every function LLL assigning a complex matrix on nine-bit strings to each element of PPP, every finite list W=[B0,…,Br−1]W=[B_0,\ldots,B_{r-1}]W=[B0​,…,Br−1​] of finite lists of elements of PPP, and every real vector x=(x0,…,x8)x=(x_0,\ldots,x_8)x=(x0​,…,x8​), this defines

CL,W(x)=Fr−1(x)⋯F0(x),Fj(x)=L(pj,sj−1)⋯L(pj,0) E(x),C_{L,W}(x)=F_{r-1}(x)\cdots F_0(x), \qquad F_j(x)=L(p_{j,s_j-1})\cdots L(p_{j,0})\,E(x),CL,W​(x)=Fr−1​(x)⋯F0​(x),Fj​(x)=L(pj,sj​−1​)⋯L(pj,0​)E(x),

where Bj=[pj,0,…,pj,sj−1]B_j=[p_{j,0},\ldots,p_{j,s_j-1}]Bj​=[pj,0​,…,pj,sj​−1​] and

E(x)y,z=∏i=08[exp⁡ ⁣(−iπxi3X)]yi,zi,X=(0110).E(x)_{y,z} =\prod_{i=0}^{8} \left[\exp\!\left(-i\frac{\pi x_i}{3}X\right)\right]_{y_i,z_i}, \qquad X=\begin{pmatrix}0&1\\1&0\end{pmatrix}.E(x)y,z​=i=0∏8​[exp(−i3πxi​​X)]yi​,zi​​,X=(01​10​).

No unitary or other condition is imposed on LLL. Every empty matrix product is the identity: an empty block contributes E(x)E(x)E(x), while an empty outer list WWW gives the identity matrix.

QAlgorithms.Papers.Independent.Extend50.P01.localEncoding

For every natural number nnn, every complex matrix AAA with Boolean row and column indices, and every real vector x=(x0,…,xn−1)x=(x_0,\ldots,x_{n-1})x=(x0​,…,xn−1​), this defines a complex matrix indexed by Boolean strings of length nnn, with entries

Ea,b=∏i=0n−1[exp⁡ ⁣(−i xi2A)]ai,bi,E_{a,b}=\prod_{i=0}^{n-1} \left[\exp\!\left(-\mathrm i\,\frac{x_i}{2}A\right)\right]_{a_i,b_i},Ea,b​=i=0∏n−1​[exp(−i2xi​​A)]ai​,bi​​,

where exp⁡\expexp is the matrix exponential. There is no Hermiticity or unitarity assumption on AAA. When n=0n=0n=0, the matrix has a single entry equal to 111.

QAlgorithms.Papers.Independent.Extend50.P01.monomialEncoding

For every natural number ddd, subgroup KKK of the permutations of {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, finite subset AAA of that set, and real feature vector x=(xi)i<dx=(x_i)_{i<d}x=(xi​)i<d​, this defines a complex matrix indexed by ddd-bit strings as

exp⁡ ⁣(−i2∑B∈{s(A):s∈K}(∏i∈Bxi)ZB),(ZB)u,v={∏i∈B(−1)ui,u=v,0,u≠v,\exp\!\left(-\frac{\mathrm i}{2} \sum_{B\in\{s(A):s\in K\}} \left(\prod_{i\in B}x_i\right)Z_B\right), \qquad (Z_B)_{u,v}= \begin{cases} \displaystyle\prod_{i\in B}(-1)^{u_i},&u=v,\\ 0,&u\ne v, \end{cases}exp​−2i​B∈{s(A):s∈K}∑​(i∈B∏​xi​)ZB​​,(ZB​)u,v​=⎩⎨⎧​i∈B∏​(−1)ui​,0,​u=v,u=v,​

where Boolean bits are interpreted as 000 or 111, and each distinct image BBB occurs once. Empty products equal 111; thus A=∅A=\varnothingA=∅ gives e−i/2Ie^{-\mathrm i/2}Ie−i/2I, including when d=0d=0d=0.

QAlgorithms.Papers.Independent.Extend50.P01.nextSite

For every natural number nnn and every index i∈{0,…,n−1}i\in\{0,\ldots,n-1\}i∈{0,…,n−1}, this defines the index whose value is

(i+1) mod n.(i+1)\bmod n.(i+1)modn.

The supplied index iii ensures n>0n>0n>0, so this advances to the next index and wraps n−1n-1n−1 to 000. The parameter n=0n=0n=0 is permitted, but then there is no index iii to which the function can be applied.

QAlgorithms.Papers.Independent.Extend50.P01.operatorHaarAverage

For any measurable space SSS, any type ι\iotaι equipped with a finite enumeration, any measure μ\muμ on SSS, any family U:S→Cι×ιU:S\to\mathbb C^{\iota\times\iota}U:S→Cι×ι, and any matrix A∈Cι×ιA\in\mathbb C^{\iota\times\iota}A∈Cι×ι, this defines

∫SC(Us,A) dμ(s).\int_S C(U_s,A)\,d\mu(s).∫S​C(Us​,A)dμ(s).

Here C(V,A)C(V,A)C(V,A) denotes the operation named conjugate, whose defining formula is absent from the supplied code. There is no assumption that μ\muμ is Haar or a probability measure, that the matrices UsU_sUs​ are unitary, or that the integrand is measurable or integrable. This is the totalized Bochner integral, which is zero when the integrand is not integrable. The finite matrix index type may be empty.

QAlgorithms.Papers.Independent.Extend50.P01.orbitInteraction

For each c∈{0,1,2}c\in\{0,1,2\}c∈{0,1,2}, this defines

1∣Ec∣∑(u,v)∈EcZuZv,\frac1{|E_c|}\sum_{(u,v)\in E_c}Z_uZ_v,∣Ec​∣1​(u,v)∈Ec​∑​Zu​Zv​,

where ZiZ_iZi​ is diagonal with sign +1+1+1 for a false bit and −1-1−1 for a true bit at wire iii, and identity on all other wires. Here E0={(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)}E_0=\{(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)\}E0​={(0,1),(2,3),(4,5),(6,7),(0,7),(2,1),(4,3),(6,5)}, E1={(1,8),(3,8),(5,8),(7,8)}E_1=\{(1,8),(3,8),(5,8),(7,8)\}E1​={(1,8),(3,8),(5,8),(7,8)}, and E2={(8,0),(8,2),(8,4),(8,6)}E_2=\{(8,0),(8,2),(8,4),(8,6)\}E2​={(8,0),(8,2),(8,4),(8,6)}, so the denominators are 8,4,48,4,48,4,4, respectively.

QAlgorithms.Papers.Independent.Extend50.P01.orbitLocal

For every complex matrix AAA indexed by the two Boolean values and every c∈{0,1,2}c\in\{0,1,2\}c∈{0,1,2}, this defines

1∣Vc∣∑i∈VcAi,V0={8},V1={0,2,4,6},V2={1,3,5,7}.\frac1{|V_c|}\sum_{i\in V_c}A_i, \qquad V_0=\{8\},\quad V_1=\{0,2,4,6\},\quad V_2=\{1,3,5,7\}.∣Vc​∣1​i∈Vc​∑​Ai​,V0​={8},V1​={0,2,4,6},V2​={1,3,5,7}.

Here AiA_iAi​ is the nine-qubit matrix with entry Axi,yi∏r≠i1{xr=yr}A_{x_i,y_i}\prod_{r\ne i}\mathbf1_{\{x_r=y_r\}}Axi​,yi​​∏r=i​1{xr​=yr​}​ at Boolean strings x,yx,yx,y. Thus the respective denominators are 1,4,41,4,41,4,4. No Hermitian or unitary assumption is imposed on AAA.

QAlgorithms.Papers.Independent.Extend50.P01.permMatrix

For any type ι\iotaι with decidable equality and any permutation p:ι→ιp:\iota\to\iotap:ι→ι, this defines the complex matrix indexed by ι×ι\iota\times\iotaι×ι whose entry at (a,b)(a,b)(a,b) is 111 if a=p(b)a=p(b)a=p(b), and 000 otherwise. The type ι\iotaι is not required to be finite or nonempty; for an empty type, this is the unique matrix with no entries.

QAlgorithms.Papers.Independent.Extend50.P01.plusState

For every natural number nnn, including 000, this defines a vector in the complex Euclidean space indexed by all nnn-bit strings, with the same amplitude at every string:

ψn(z)=(12)nfor every z∈{false,true}n.\psi_n(z)=\left(\frac1{\sqrt2}\right)^n \qquad\text{for every }z\in\{\mathrm{false},\mathrm{true}\}^n.ψn​(z)=(2​1​)nfor every z∈{false,true}n.

For n=0n=0n=0, there is one empty bit string, and its amplitude is 111.

QAlgorithms.Papers.Independent.Extend50.P01.qaoa

For arbitrary natural numbers n,pn,pn,p and real parameter families (βm)m=0p−1(\beta_m)_{m=0}^{p-1}(βm​)m=0p−1​ and (γm)m=0p−1(\gamma_m)_{m=0}^{p-1}(γm​)m=0p−1​, this defines a complex matrix on the basis of nnn-bit strings by

Q=∏m=0p−1(e−iβmHXe−iγmHZZ),HX=∑j=0n−1Xj,HZZ=∑j=0n−1ZjZj+1 mod n,Q=\prod_{m=0}^{p-1}\left(e^{-i\beta_m H_X}e^{-i\gamma_m H_{ZZ}}\right), \qquad H_X=\sum_{j=0}^{n-1}X_j,\quad H_{ZZ}=\sum_{j=0}^{n-1}Z_jZ_{j+1\bmod n},Q=m=0∏p−1​(e−iβm​HX​e−iγm​HZZ​),HX​=j=0∑n−1​Xj​,HZZ​=j=0∑n−1​Zj​Zj+1modn​,

where Xj,ZjX_j,Z_jXj​,Zj​ act by the standard Pauli matrices on wire jjj and by the identity on all other wires. The factors are multiplied in increasing order of mmm from left to right. If p=0p=0p=0, the product is the identity. If n=0n=0n=0, both Hamiltonian sums are zero and the resulting matrix is the identity on the one-dimensional space indexed by the empty bit string. If n=1n=1n=1, the single ZZZZZZ summand is Z02=IZ_0^2=IZ02​=I; if n=2n=2n=2, the two ZZZZZZ summands count the same pair in opposite orders.

QAlgorithms.Papers.Independent.Extend50.P01.reduceHeisenberg

For every function θ:{0,…,6}→R\theta:\{0,\ldots,6\}\to\mathbb Rθ:{0,…,6}→R, this defines the function on {0,1}\{0,1\}{0,1} whose values are

0⟼θ1+θ2+θ33,1⟼θ4+θ5+θ63.0\longmapsto\frac{\theta_1+\theta_2+\theta_3}{3}, \qquad 1\longmapsto\frac{\theta_4+\theta_5+\theta_6}{3}.0⟼3θ1​+θ2​+θ3​​,1⟼3θ4​+θ5​+θ6​​.

The parameter θ0\theta_0θ0​ does not occur in either value.

QAlgorithms.Papers.Independent.Extend50.P01.reupload

For every natural number nnn, every complex matrix EEE indexed by nnn-bit strings, and every finite list WWW of matrices with the same indices, this defines the identity matrix when WWW is empty, and, when W=[W0,…,WL]W=[W_0,\ldots,W_L]W=[W0​,…,WL​], defines

(WLE)(WL−1E)⋯(W1E)W0.(W_LE)(W_{L-1}E)\cdots(W_1E)W_0.(WL​E)(WL−1​E)⋯(W1​E)W0​.

In particular, a one-element list gives W0W_0W0​. No unitarity or other condition is imposed on EEE or the matrices in WWW, and n=0n=0n=0 is included.

QAlgorithms.Papers.Independent.Extend50.P01.signedData

For every natural number nnn, pair g=(π,s)g=(\pi,s)g=(π,s) consisting of a permutation π\piπ of {0,…,n−1}\{0,\ldots,n-1\}{0,…,n−1} and a Boolean function sss on that set, and real vector xxx indexed by that set, this defines the real vector

(signedData⁡(g,x))i={−xπ−1(i),si=true,xπ−1(i),si=false.(\operatorname{signedData}(g,x))_i= \begin{cases} -x_{\pi^{-1}(i)},&s_i=\mathrm{true},\\ x_{\pi^{-1}(i)},&s_i=\mathrm{false}. \end{cases}(signedData(g,x))i​={−xπ−1(i)​,xπ−1(i)​,​si​=true,si​=false.​

When n=0n=0n=0, both the input and output vectors have no coordinates.

QAlgorithms.Papers.Independent.Extend50.P01.signedInv

For every natural number nnn and every pair g=(p,ε)g=(p,\varepsilon)g=(p,ε), where ppp is a permutation of {0,…,n−1}\{0,\ldots,n-1\}{0,…,n−1} and ε\varepsilonε is a Boolean-valued function on that set, this defines the pair (p−1, i↦εp(i))\left(p^{-1},\,i\mapsto\varepsilon_{p(i)}\right)(p−1,i↦εp(i)​). The declaration defines this operation without itself asserting an inverse identity for the previously defined multiplication. For n=0n=0n=0, it returns the unique such pair.

QAlgorithms.Papers.Independent.Extend50.P01.signedMatrix

For every natural number nnn and pair g=(π,s)g=(\pi,s)g=(π,s), where π\piπ permutes {0,…,n−1}\{0,\ldots,n-1\}{0,…,n−1} and sss is a Boolean function on that set, this defines a complex matrix whose rows and columns are indexed by nnn-bit strings. Its entry at row aaa and column bbb is 111 precisely when ai=bπ−1(i)xorsia_i=b_{\pi^{-1}(i)}\mathbin{\mathrm{xor}}s_iai​=bπ−1(i)​xorsi​ for every coordinate iii, and is 000 otherwise. Here xor is exclusive OR. For n=0n=0n=0, there is one empty bit string, and the matrix is the 1×11\times11×1 matrix with entry 111.

QAlgorithms.Papers.Independent.Extend50.P01.signedMul

For every natural number nnn and every two pairs g=(p,ε)g=(p,\varepsilon)g=(p,ε) and h=(q,δ)h=(q,\delta)h=(q,δ), where p,qp,qp,q are permutations of {0,…,n−1}\{0,\ldots,n-1\}{0,…,n−1} and ε,δ\varepsilon,\deltaε,δ are Boolean-valued functions on that set, this defines

g⋆h=(p∘q, i⟼εi⊕δp−1(i)),g\mathbin{\star}h =\left(p\circ q,\ i\longmapsto \varepsilon_i\mathbin{\oplus}\delta_{p^{-1}(i)}\right),g⋆h=(p∘q, i⟼εi​⊕δp−1(i)​),

where ⊕\oplus⊕ is Boolean exclusive-or, true exactly when its two arguments differ. The definition includes n=0n=0n=0, when the result is the unique such pair.

QAlgorithms.Papers.Independent.Extend50.P01.singletProduct

For every natural number kkk, this defines a vector ψk\psi_kψk​ in the complex Euclidean space indexed by bit strings of length 2k2k2k through its amplitudes

ψk(b)=∏j=0k−1c(b2j,b2j+1),c(u,v)={0,u=v,−1/2,u=true, v=false,1/2,u=false, v=true.\psi_k(b)=\prod_{j=0}^{k-1}c(b_{2j},b_{2j+1}), \qquad c(u,v)= \begin{cases} 0,&u=v,\\ -1/\sqrt2,&u=\mathrm{true},\ v=\mathrm{false},\\ 1/\sqrt2,&u=\mathrm{false},\ v=\mathrm{true}. \end{cases}ψk​(b)=j=0∏k−1​c(b2j​,b2j+1​),c(u,v)=⎩⎨⎧​0,−1/2​,1/2​,​u=v,u=true, v=false,u=false, v=true.​

Thus each consecutive pair contributes the amplitudes of (∣01⟩−∣10⟩)/2(|01\rangle-|10\rangle)/\sqrt2(∣01⟩−∣10⟩)/2​, with false identified with 000. For k=0k=0k=0, the empty product is 111, giving amplitude 111 on the unique empty bit string.

QAlgorithms.Papers.Independent.Extend50.P01.supportOrbit

For every natural number ddd, subgroup KKK of the permutations of {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, and finite subset A⊆{0,…,d−1}A\subseteq\{0,\ldots,d-1\}A⊆{0,…,d−1}, this defines the finite set

{ s(A):s∈K },s(A)={s(i):i∈A}.\{\,s(A):s\in K\,\},\qquad s(A)=\{s(i):i\in A\}.{s(A):s∈K},s(A)={s(i):i∈A}.

Repeated images are included only once. The definition includes A=∅A=\varnothingA=∅, whose orbit is {∅}\{\varnothing\}{∅}, and d=0d=0d=0, when this is the only possible orbit.

QAlgorithms.Papers.Independent.Extend50.P01.tensorLocal

For every natural number nnn, including zero, and every family AiA_iAi​ of complex 2×22\times22×2 matrices whose row and column indices are Boolean values, this defines a complex matrix indexed by pairs of Boolean strings a,b:{0,…,n−1}→{false,true}a,b:\{0,\ldots,n-1\}\to\{\mathrm{false},\mathrm{true}\}a,b:{0,…,n−1}→{false,true}, with entries

Ta,b=∏i=0n−1(Ai)ai,bi.T_{a,b}=\prod_{i=0}^{n-1}(A_i)_{a_i,b_i}.Ta,b​=i=0∏n−1​(Ai​)ai​,bi​​.

No assumption is imposed on the matrices AiA_iAi​. When n=0n=0n=0, there is one empty Boolean string, and the resulting 1×11\times11×1 matrix has entry 111, by the empty-product convention.

QAlgorithms.Papers.Independent.Extend50.P01.tfim

For every natural number nnn, including 000, and every real ggg, this defines the complex matrix on nnn-bit strings

Hn(g)=−∑j=0n−1ZjZ(j+1) mod n−g∑j=0n−1Xj,H_n(g)=-\sum_{j=0}^{n-1}Z_jZ_{(j+1)\bmod n} -g\sum_{j=0}^{n-1}X_j,Hn​(g)=−j=0∑n−1​Zj​Z(j+1)modn​−gj=0∑n−1​Xj​,

where 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 AjA_jAj​ acts as AAA on wire jjj and as the identity elsewhere. For n=0n=0n=0, both sums are empty and the result is the zero matrix; no modular successor is evaluated. For n=1n=1n=1, the interaction term is −Z02=−I-Z_0^2=-I−Z02​=−I, so H1(g)=−I−gX0H_1(g)=-I-gX_0H1​(g)=−I−gX0​. For n=2n=2n=2, both directed successor terms occur, giving H2(g)=−2Z0Z1−g(X0+X1)H_2(g)=-2Z_0Z_1-g(X_0+X_1)H2​(g)=−2Z0​Z1​−g(X0​+X1​).

QAlgorithms.Papers.Independent.Extend50.P01.totalSpinSquared

For every natural number nnn, this defines the complex matrix on nnn-bit strings

J2(n)=(12∑j<nXj)2+(12∑j<nYj)2+(12∑j<nZj)2,J^2(n)= \left(\frac12\sum_{j<n}X_j\right)^2+ \left(\frac12\sum_{j<n}Y_j\right)^2+ \left(\frac12\sum_{j<n}Z_j\right)^2,J2(n)=(21​j<n∑​Xj​)2+(21​j<n∑​Yj​)2+(21​j<n∑​Zj​)2,

where Xj,Yj,ZjX_j,Y_j,Z_jXj​,Yj​,Zj​ are the standard Pauli operators on wire jjj, with identity action on the other wires, and each square is matrix multiplication. For n=0n=0n=0, all three sums are zero, so the defined matrix is zero.

QAlgorithms.Papers.Independent.Extend50.P01.twirledHeisenbergLayer

For every natural number NNN, every measure μ\muμ on the special unitary group of complex matrices indexed by the two Boolean values, and every seven real parameters θ0,…,θ6\theta_0,\ldots,\theta_6θ0​,…,θ6​, this defines an operator on NNN qubits. Write Xi,Yi,ZiX_i,Y_i,Z_iXi​,Yi​,Zi​ for the given Pauli matrices acting on wire iii, with identity on all other wires, and put

Bε(a,b,c)=∑0≤i<Nimod2=ε(aXiXi+1 mod N+bYiYi+1 mod N+cZiZi+1 mod N).B_{\varepsilon}(a,b,c)= \sum_{\substack{0\le i<N\\i\bmod2=\varepsilon}} \left(aX_iX_{i+1\bmod N}+bY_iY_{i+1\bmod N}+cZ_iZ_{i+1\bmod N}\right).Bε​(a,b,c)=0≤i<Nimod2=ε​∑​(aXi​Xi+1modN​+bYi​Yi+1modN​+cZi​Zi+1modN​).

Writing E(H,t)=exp⁡(−itH)E(H,t)=\exp(-\mathrm i tH)E(H,t)=exp(−itH), the defined operator is

E ⁣(Tμ,N ⁣(∑i=0N−1Yi),θ0)E ⁣(Tμ,N(B0(θ1,θ2,θ3)),1)E ⁣(Tμ,N(B1(θ4,θ5,θ6)),1).E\!\left(\mathcal T_{\mu,N}\!\left(\sum_{i=0}^{N-1}Y_i\right),\theta_0\right) E\!\left(\mathcal T_{\mu,N}(B_0(\theta_1,\theta_2,\theta_3)),1\right) E\!\left(\mathcal T_{\mu,N}(B_1(\theta_4,\theta_5,\theta_6)),1\right).E(Tμ,N​(i=0∑N−1​Yi​),θ0​)E(Tμ,N​(B0​(θ1​,θ2​,θ3​)),1)E(Tμ,N​(B1​(θ4​,θ5​,θ6​)),1).

Here Tμ,N(A)=∫C(CN(U),A) dμ(U)\mathcal T_{\mu,N}(A)=\int \mathcal C(C_N(U),A)\,d\mu(U)Tμ,N​(A)=∫C(CN​(U),A)dμ(U), where CN(U)C_N(U)CN​(U) denotes the supplied code’s collective matrix and C\mathcal CC its matrix operation conjugate; their defining bodies are not supplied. No Haar or probability assumption is imposed on μ\muμ. The integral is the total Bochner integral, which is zero when its integrand is not integrable. The definition includes N=0N=0N=0, when all wire sums are empty, and N=1N=1N=1, when the cyclic neighbor of the only wire is itself.

QAlgorithms.Papers.Independent.Extend50.P01.twirledQaoa

For arbitrary natural numbers n,pn,pn,p and real parameter families α,β,γ\alpha,\beta,\gammaα,β,γ indexed by 0,…,p−10,\ldots,p-10,…,p−1, let Πn\Pi_nΠn​ denote the matrix named parity n, and let C(V,A)\mathcal C(V,A)C(V,A) denote the operation named conjugate V A; their defining formulas are not supplied. Put Tn(A)=12(A+C(Πn,A))\mathcal T_n(A)=\tfrac12(A+\mathcal C(\Pi_n,A))Tn​(A)=21​(A+C(Πn​,A)), HY=∑j<nYjH_Y=\sum_{j<n}Y_jHY​=∑j<n​Yj​, HX=∑j<nXjH_X=\sum_{j<n}X_jHX​=∑j<n​Xj​, and HZZ=∑j<nZjZj+1 mod nH_{ZZ}=\sum_{j<n}Z_jZ_{j+1\bmod n}HZZ​=∑j<n​Zj​Zj+1modn​, where the subscript indicates the wire on which a standard Pauli matrix acts, with identity action elsewhere. This declaration defines

Q~=∏m=0p−1(e−iαmTn(HY)e−iβmTn(HX)e−iγmTn(HZZ)),\widetilde Q =\prod_{m=0}^{p-1} \left( e^{-i\alpha_m\mathcal T_n(H_Y)} e^{-i\beta_m\mathcal T_n(H_X)} e^{-i\gamma_m\mathcal T_n(H_{ZZ})} \right),Q​=m=0∏p−1​(e−iαm​Tn​(HY​)e−iβm​Tn​(HX​)e−iγm​Tn​(HZZ​)),

with factors multiplied in increasing order of mmm from left to right. For p=0p=0p=0 the product is the identity. Zero wires are allowed, in which case the three Hamiltonian sums are empty; the cyclic successor is only evaluated for existing wire indices.

QAlgorithms.Papers.Independent.Extend50.P01.twoGateSet

This definition specifies the following set of complex matrices indexed by pairs of Boolean values:

{X⊗I, Y⊗I, Z⊗I, I⊗X, I⊗Y, I⊗Z, Z⊗Z},\{X\otimes I,\ Y\otimes I,\ Z\otimes I,\ I\otimes X,\ I\otimes Y,\ I\otimes Z,\ Z\otimes Z\},{X⊗I, Y⊗I, Z⊗I, I⊗X, I⊗Y, I⊗Z, Z⊗Z},

where III is the 2×22\times22×2 identity and, in the basis ordered as false, true,

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

QAlgorithms.Papers.Independent.Extend50.P01.vehicleGroup

This is the subgroup consisting of all integer powers of the permutation R=(0 2 4 6)(1 3 5 7)R=(0\ 2\ 4\ 6)(1\ 3\ 5\ 7)R=(0 2 4 6)(1 3 5 7), which fixes 888. Thus it is {id,R,R2,R3}\{\mathrm{id},R,R^2,R^3\}{id,R,R2,R3}.

QAlgorithms.Papers.Independent.Extend50.P01.vehicleLayer

For every parameter pair p=(α,θ)p=(\alpha,\theta)p=(α,θ), where α:{0,1,2}×{0,1}→R\alpha:\{0,1,2\}\times\{0,1\}\to\mathbb Rα:{0,1,2}×{0,1}→R and θ:{0,1,2,3}→R\theta:\{0,1,2,3\}\to\mathbb Rθ:{0,1,2,3}→R, this defines a complex matrix on nine Boolean wires. Let X,Y,ZX,Y,ZX,Y,Z be the Pauli matrices, P1=diag⁡(0,1)P_1=\operatorname{diag}(0,1)P1​=diag(0,1), and AiA_iAi​ denote AAA acting on wire iii, with entries Ayi,zi∏r≠i1yr=zrA_{y_i,z_i}\prod_{r\ne i}\mathbf1_{y_r=z_r}Ayi​,zi​​∏r=i​1yr​=zr​​. Put KZ(F)=∑(i,j)∈F(P1)iZjK_Z(F)=\sum_{(i,j)\in F}(P_1)_iZ_jKZ​(F)=∑(i,j)∈F​(P1​)i​Zj​, and define

D={(8,0),(8,2),(8,4),(8,6)},I={(1,8),(3,8),(5,8),(7,8)},D=\{(8,0),(8,2),(8,4),(8,6)\},\quad I=\{(1,8),(3,8),(5,8),(7,8)\},D={(8,0),(8,2),(8,4),(8,6)},I={(1,8),(3,8),(5,8),(7,8)}, C={(0,1),(2,3),(4,5),(6,7)},A={(0,7),(2,1),(4,3),(6,5)}.C=\{(0,1),(2,3),(4,5),(6,7)\},\qquad A=\{(0,7),(2,1),(4,3),(6,5)\}.C={(0,1),(2,3),(4,5),(6,7)},A={(0,7),(2,1),(4,3),(6,5)}.

Assign class 000 to wire 888, class 111 to even wires below 888, and class 222 to odd wires. Writing this assignment as ccc, the matrix is

e−iθ(3)KZ(D)/2 e−iθ(2)KZ(I)/2 e−iθ(1)KZ(A)/2 e−iθ(0)KZ(C)/2 ⨂i=08(e−iα(c(i),1)Y/2e−iα(c(i),0)X/2).e^{-i\theta(3)K_Z(D)/2}\, e^{-i\theta(2)K_Z(I)/2}\, e^{-i\theta(1)K_Z(A)/2}\, e^{-i\theta(0)K_Z(C)/2}\, \bigotimes_{i=0}^{8} \left( e^{-i\alpha(c(i),1)Y/2} e^{-i\alpha(c(i),0)X/2} \right).e−iθ(3)KZ​(D)/2e−iθ(2)KZ​(I)/2e−iθ(1)KZ​(A)/2e−iθ(0)KZ​(C)/2i=0⨂8​(e−iα(c(i),1)Y/2e−iα(c(i),0)X/2).

All parameters are arbitrary real numbers.

QAlgorithms.Papers.Independent.Extend50.P01.vehiclePrediction

For every finite list WWW of finite lists of parameter pairs (α,θ)(\alpha,\theta)(α,θ), with α:{0,1,2}×{0,1}→R\alpha:\{0,1,2\}\times\{0,1\}\to\mathbb Rα:{0,1,2}×{0,1}→R and θ:{0,1,2,3}→R\theta:\{0,1,2,3\}\to\mathbb Rθ:{0,1,2,3}→R, and every feature vector x:{0,…,8}→Rx:\{0,\ldots,8\}\to\mathbb Rx:{0,…,8}→R, this defines one real number. Let X,Y,ZX,Y,ZX,Y,Z be the Pauli matrices, P1=diag⁡(0,1)P_1=\operatorname{diag}(0,1)P1​=diag(0,1), and AiA_iAi​ denote AAA on wire iii and identities elsewhere. Define D={(8,0),(8,2),(8,4),(8,6)}D=\{(8,0),(8,2),(8,4),(8,6)\}D={(8,0),(8,2),(8,4),(8,6)}, I={(1,8),(3,8),(5,8),(7,8)}I=\{(1,8),(3,8),(5,8),(7,8)\}I={(1,8),(3,8),(5,8),(7,8)}, C={(0,1),(2,3),(4,5),(6,7)}C=\{(0,1),(2,3),(4,5),(6,7)\}C={(0,1),(2,3),(4,5),(6,7)}, and A={(0,7),(2,1),(4,3),(6,5)}A=\{(0,7),(2,1),(4,3),(6,5)\}A={(0,7),(2,1),(4,3),(6,5)}, and put KZ(F)=∑(i,j)∈F(P1)iZjK_Z(F)=\sum_{(i,j)\in F}(P_1)_iZ_jKZ​(F)=∑(i,j)∈F​(P1​)i​Zj​. Assign class 000 to wire 888, class 111 to even wires below 888, and class 222 to odd wires, writing the assignment as ccc. Define

L(α,θ)=e−iθ(3)KZ(D)/2e−iθ(2)KZ(I)/2e−iθ(1)KZ(A)/2e−iθ(0)KZ(C)/2⨂i=08(e−iα(c(i),1)Y/2e−iα(c(i),0)X/2).L(\alpha,\theta)= e^{-i\theta(3)K_Z(D)/2}e^{-i\theta(2)K_Z(I)/2} e^{-i\theta(1)K_Z(A)/2}e^{-i\theta(0)K_Z(C)/2} \bigotimes_{i=0}^{8} \left(e^{-i\alpha(c(i),1)Y/2}e^{-i\alpha(c(i),0)X/2}\right).L(α,θ)=e−iθ(3)KZ​(D)/2e−iθ(2)KZ​(I)/2e−iθ(1)KZ​(A)/2e−iθ(0)KZ​(C)/2i=0⨂8​(e−iα(c(i),1)Y/2e−iα(c(i),0)X/2).

Set E(x)=⨂i=08e−iπxiX/3E(x)=\bigotimes_{i=0}^{8}e^{-i\pi x_iX/3}E(x)=⨂i=08​e−iπxi​X/3. For each block bbb containing pb,1,…,pb,mbp_{b,1},\ldots,p_{b,m_b}pb,1​,…,pb,mb​​, put Fb=L(pb,mb)⋯L(pb,1)E(x)F_b=L(p_{b,m_b})\cdots L(p_{b,1})E(x)Fb​=L(pb,mb​​)⋯L(pb,1​)E(x), and for rrr blocks put QW(x)=Fr⋯F1Q_W(x)=F_r\cdots F_1QW​(x)=Fr​⋯F1​. Empty products are identities; an empty block contributes E(x)E(x)E(x), and an empty outer list gives QW(x)=1Q_W(x)=1QW​(x)=1. The defined number is

expectation⁡ ⁣(Z8,QW(x)∣09⟩)+12,\frac{\operatorname{expectation}\!\left(Z_8,Q_W(x)|0^9\rangle\right)+1}{2},2expectation(Z8​,QW​(x)∣09⟩)+1​,

where ∣09⟩|0^9\rangle∣09⟩ has amplitude 111 at the all-false string and 000 elsewhere. The operation named expectation has no defining formula in the supplied code; this definition itself asserts no range bound.

QAlgorithms.Papers.Independent.Extend50.P01.vertexClass

For each i∈{0,…,8}i\in\{0,\ldots,8\}i∈{0,…,8}, its class is 000 if i=8i=8i=8, is 111 if i≠8i\ne8i=8 is even, and is 222 otherwise. In particular, the three classes are {8}\{8\}{8}, {0,2,4,6}\{0,2,4,6\}{0,2,4,6}, and {1,3,5,7}\{1,3,5,7\}{1,3,5,7}, respectively.

QAlgorithms.Papers.Independent.Extend50.P01.vertexOrbit

For each a∈{0,1,2}a\in\{0,1,2\}a∈{0,1,2}, this finite set contains exactly the indices in {0,…,8}\{0,\ldots,8\}{0,…,8} whose class is aaa: it is {8}\{8\}{8} for a=0a=0a=0, {0,2,4,6}\{0,2,4,6\}{0,2,4,6} for a=1a=1a=1, and {1,3,5,7}\{1,3,5,7\}{1,3,5,7} for a=2a=2a=2.

QAlgorithms.Papers.Independent.Extend50.P01.wireMatrix

For every natural number nnn and every permutation ppp of {0,…,n−1}\{0,\ldots,n-1\}{0,…,n−1}, this defines the complex matrix indexed by Boolean strings a,ba,ba,b of length nnn whose (a,b)(a,b)(a,b)-entry is 111 precisely when ai=bp−1(i)a_i=b_{p^{-1}(i)}ai​=bp−1(i)​ for every iii, and is 000 otherwise. When n=0n=0n=0, the condition is vacuous and the resulting 1×11\times11×1 matrix has entry 111.

QAlgorithms.Papers.Independent.Extend50.P01.wirePerm

For every natural number nnn and every permutation ppp of {0,…,n−1}\{0,\ldots,n-1\}{0,…,n−1}, this defines a permutation WpW_pWp​ of the Boolean strings of length nnn by (Wpb)i=bp−1(i)(W_pb)_i=b_{p^{-1}(i)}(Wp​b)i​=bp−1(i)​. Its specified inverse sends a Boolean string bbb to the string with coordinate iii equal to bp(i)b_{p(i)}bp(i)​, and the declaration supplies both inverse identities. For n=0n=0n=0, it is the identity permutation of the singleton set containing the empty string.

QAlgorithms.Papers.Independent.Extend50.P01.zWord

For every natural number nnn and finite subset A⊆{0,…,n−1}A\subseteq\{0,\ldots,n-1\}A⊆{0,…,n−1}, this defines a complex diagonal matrix indexed by nnn-bit strings. Its diagonal entry at a string bbb is ∏i∈A(−1)[bi]\prod_{i\in A}(-1)^{[b_i]}∏i∈A​(−1)[bi​], equivalently (−1)∣{i∈A:bi=true}∣(-1)^{|\{i\in A:b_i=\mathrm{true}\}|}(−1)∣{i∈A:bi​=true}∣, and its off-diagonal entries are zero. An empty product is 111, so A=∅A=\varnothingA=∅ gives the identity matrix; in particular, n=0n=0n=0 gives the 1×11\times11×1 identity.

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

    Confirmed by the moderator at approval.

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