Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

QPBT definitions: Algebra / Pauli

Definition
QPBT_QPBT_Algebra_Pauli

by Dengnifer · Oct 27, 2026 · Mathlib 0df444a (Lean v4.33.1)

qpbt

This bundle defines the generalized Pauli basis data used by the test. It includes the binary phase character, shift and phase operators, normalized basis vectors and projectors, and a compact operator form of a generalized Pauli observable.

Principal definitions:

  • MIPStarRE.QPBT.PauliKind: defines the two generalized Pauli bases used by the test.
  • MIPStarRE.QPBT.phaseSign: defines the binary character used for generalized Pauli phases.
  • MIPStarRE.QPBT.tauShift: defines the generalized Pauli shift operator.
  • MIPStarRE.QPBT.tauPhase: defines the generalized Pauli phase operator with the fixed binary trace in its phase.
  • MIPStarRE.QPBT.singlePauliVec: defines the single-qudit eigenvector coordinate used in the tensor-product basis.
  • MIPStarRE.QPBT.pauliVec: defines the normalized single- or multi-qudit eigenvector for a Pauli basis label.
  • MIPStarRE.QPBT.pauliProj: defines the rank-one projector onto a Pauli basis vector.
  • MIPStarRE.QPBT.tauObservable: defines a compact operator-valued form of a generalized Pauli observable.

Formalization Credit. This Lean declaration is part of the Quantum Pauli basis test formalization by Ruixuan Deng. The source code was generated by AI agents; Ruixuan Deng is the responsible maintainer.

Mathematical Source. The mathematical source is Ji, Natarajan, Vidick, Wright, and Yuen, MIP*=RE, arXiv:2001.04383v3.

Definition code
-- Generated from QPBT/Algebra/Pauli.lean by skeleton subtraction.
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_AxisParallelLine
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_DiagonalLine
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_LinePolynomials
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_LowDegreePolynomial
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_OpFamily
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_ParametersBase
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_ParametersFiniteAnswers
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_QuantumState
import Definitions.Def_LIDT_MIPStarRE_LDT_CommutativityPoints_Defs
import Definitions.Def_LIDT_MIPStarRE_LDT_ExpansionHypercubeGraph_Defs_Core
import Definitions.Def_LIDT_MIPStarRE_LDT_GlobalVariance_Defs_Core
import Definitions.Def_LIDT_MIPStarRE_LDT_MakingMeasurementsProjective_Defs
import Definitions.Def_LIDT_MIPStarRE_LDT_Pasting_Defs_Families
import Definitions.Def_LIDT_MIPStarRE_LDT_Pasting_Defs_Interpolation
import Definitions.Def_LIDT_MIPStarRE_LDT_Preliminaries_FiniteFields
import Definitions.Def_LIDT_MIPStarRE_LDT_Tactic_AvgCongr
import Definitions.Def_LIDT_MIPStarRE_LDT_Test_StrategyCore
import Definitions.Def_LIDT_MIPStarRE_Quantum_FiniteMatrix_Basic
import Definitions.Def_QPBT_QPBT_Algebra_FieldBasis
import Definitions.Def_QPBT_QPBT_Upstream

namespace LIDT.MIPStarRE.LDT.Preliminaries
end LIDT.MIPStarRE.LDT.Preliminaries
namespace LIDT.MIPStarRE.Quantum
end LIDT.MIPStarRE.Quantum
namespace MIPStarRE.QPBT
end MIPStarRE.QPBT

/-!
# Generalized Pauli operators and EPR states

The definitions here use finite matrix entries and rank-one projectors, so they
are usable by the later game statements without introducing an abstract
operator algebra.  The observable/projector expansions are obtained from
finite-field Fourier orthogonality in characteristic two.

## References

The source-facing nodes are blueprint `def:lin-reg`, `def:EPR`,
`def:generalized-pauli`, and `lem:pauli-observable-expansion`.  The paper origin is
`references/qpbt-paper/04_preliminaries.tex:908-1161`.
-/

@[expose] public section

open scoped BigOperators Matrix ComplexOrder

namespace MIPStarRE.QPBT

open LIDT.MIPStarRE.Quantum
open LIDT.MIPStarRE.LDT.Preliminaries

variable {K : Type*} [Field K] [Fintype K] [DecidableEq K]
  [Algebra (ZMod 2) K]

/-- The two generalized Pauli bases used by the test in blueprint
`def:generalized-pauli`, paper origin
`references/qpbt-paper/04_preliminaries.tex:1052-1096`.
-/
inductive PauliKind where
  | X
  | Z
  deriving DecidableEq, Repr, Inhabited
instance PauliKind.instFintype : Fintype _root_.MIPStarRE.QPBT.PauliKind :=
  ⟨{.X, .Z}, by intro x; cases x <;> simp⟩
/-- The binary character used for generalized Pauli phases; see
`references/qpbt-paper/04_preliminaries.tex:1052-1081`.

It is public because the Fourier expansion declarations below expose this
character in their statement types. -/
noncomputable def phaseSign (t : ZMod 2) : ℂ :=
  if t = 0 then 1 else -1

/-- Formalization-only expansion of a sum over the binary field into its two
terms. -/
theorem sum_zmod_two {M : Type*} [AddCommMonoid M] (f : ZMod 2 → M) :
    ∑ b, f b = f 0 + f 1 := by
  calc
    ∑ b, f b = ∑ i : Fin 2, f (ZMod.finEquiv 2 i) := by
      exact Fintype.sum_equiv (ZMod.finEquiv 2).symm f
        (fun i : Fin 2 => f (ZMod.finEquiv 2 i)) (fun _ => rfl)
    _ = f (ZMod.finEquiv 2 0) + f (ZMod.finEquiv 2 1) := Fin.sum_univ_two _
    _ = f 0 + f 1 := by rfl

/-- Formalization-only case split for the binary field: every element is zero
or one. -/
theorem zmod_two_eq_zero_or_one (b : ZMod 2) : b = 0 ∨ b = 1 := by
  by_cases hb : b = 0
  · exact Or.inl hb
  · right
    have hval_ne : b.val ≠ 0 := (ZMod.val_ne_zero b).mpr hb
    have hval_lt : b.val < 2 := ZMod.val_lt b
    have hval : b.val = 1 := by omega
    exact (ZMod.val_eq_one (by omega) b).mp hval

/-- In characteristic two, the standard additive character is the sign
character used by the binary Pauli definitions. -/
theorem phaseSign_eq_ffChar (t : ZMod 2) :
    _root_.MIPStarRE.QPBT.phaseSign t = ZMod.stdAddChar (N := 2) t := by
  by_cases ht : t = 0
  · subst t
    rw [_root_.MIPStarRE.QPBT.phaseSign, if_pos rfl]
    exact (ZMod.stdAddChar (N := 2)).map_zero_eq_one.symm
  · have hval : t.val = 1 := by
      have hval_ne : t.val ≠ 0 := (ZMod.val_ne_zero t).mpr ht
      have hval_lt : t.val < 2 := ZMod.val_lt t
      omega
    have ht_one : t = 1 := (ZMod.val_eq_one (by omega) t).mp hval
    subst t
    rw [_root_.MIPStarRE.QPBT.phaseSign, if_neg one_ne_zero]
    change (-1 : ℂ) = ZMod.stdAddChar (N := 2) ((1 : ℤ) : ZMod 2)
    rw [ZMod.stdAddChar_coe]
    convert Complex.exp_pi_mul_I.symm using 1
    all_goals ring_nf

/-- The binary sign character carries a sum to the product of the two signs.
This is the character property underlying blueprint
`def:generalized-pauli`, paper origin
`references/qpbt-paper/04_preliminaries.tex:1052-1096`. -/
theorem phaseSign_add (s t : ZMod 2) :
    _root_.MIPStarRE.QPBT.phaseSign (s + t) = _root_.MIPStarRE.QPBT.phaseSign s * _root_.MIPStarRE.QPBT.phaseSign t := by
  rw [_root_.MIPStarRE.QPBT.phaseSign_eq_ffChar, _root_.MIPStarRE.QPBT.phaseSign_eq_ffChar, _root_.MIPStarRE.QPBT.phaseSign_eq_ffChar]
  exact (ZMod.stdAddChar (N := 2)).map_add_eq_mul s t

/-- The binary sign character takes real values, so conjugation fixes it. It is
used by the observable expansions of blueprint
`def:generalized-pauli`, paper origin
`references/qpbt-paper/04_preliminaries.tex:1052-1096`. -/
theorem star_phaseSign (t : ZMod 2) : star (_root_.MIPStarRE.QPBT.phaseSign t) = _root_.MIPStarRE.QPBT.phaseSign t := by
  by_cases ht : t = 0 <;> simp [_root_.MIPStarRE.QPBT.phaseSign, ht]



/-- The binary sign character sends sums to products. -/
theorem phaseSign_sum {ι : Type*} [Fintype ι] (f : ι → ZMod 2) :
    _root_.MIPStarRE.QPBT.phaseSign (∑ i, f i) = ∏ i, _root_.MIPStarRE.QPBT.phaseSign (f i) := by
  classical
  induction (Finset.univ : Finset ι) using Finset.induction_on with
  | empty => simp [_root_.MIPStarRE.QPBT.phaseSign]
  | @insert i s hi ih =>
      rw [Finset.sum_insert hi, Finset.prod_insert hi, _root_.MIPStarRE.QPBT.phaseSign_add, ih]

omit [Fintype K] [DecidableEq K] in
/-- The product of the coordinate phases is the phase of the trace pairing. -/
theorem prod_phaseSign_binTrace_dotProduct {ι : Type*} [Fintype ι]
    (u v : ι → K) :
    ∏ i, _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (u i * v i)) =
      _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct u v)) := by
  rw [← _root_.MIPStarRE.QPBT.phaseSign_sum]
  congr 2
  simp [dotProduct]

/-- The complex amplitude `(√n)⁻¹` normalizing a uniform superposition over `n`
basis vectors squares to `n⁻¹`.

This formalization-only normalization identity supports the Pauli normalizer
of blueprint `def:EPR`, paper origin
`references/qpbt-paper/04_preliminaries.tex:908-950`, and the seed-fiber and
correlated-ancilla amplitudes of the direct low-degree transport. -/
theorem inv_sqrt_natCast_mul_self (n : ℕ) :
    (Real.sqrt (n : ℝ) : ℂ)⁻¹ * (Real.sqrt (n : ℝ) : ℂ)⁻¹ =
      (n : ℂ)⁻¹ := by
  calc
    (Real.sqrt (n : ℝ) : ℂ)⁻¹ * (Real.sqrt (n : ℝ) : ℂ)⁻¹ =
        ((Real.sqrt (n : ℝ) : ℂ) ^ 2)⁻¹ := by
      rw [pow_two, mul_inv_rev]
    _ = ((n : ℝ) : ℂ)⁻¹ := by
      rw [← Complex.ofReal_pow, Real.sq_sqrt (Nat.cast_nonneg n)]
    _ = (n : ℂ)⁻¹ := by norm_num



omit [Field K] [DecidableEq K] [Algebra (ZMod 2) K] in
private theorem pauliNormalizer_mul_self {ι : Type*} [Fintype ι]
    [DecidableEq ι] :
    (∏ _i : ι, (Real.sqrt (Fintype.card K : ℝ) : ℂ)⁻¹) *
        (∏ _i : ι, (Real.sqrt (Fintype.card K : ℝ) : ℂ)⁻¹) =
      (Fintype.card (ι → K) : ℂ)⁻¹ := by
  simp only [Finset.prod_const, Finset.card_univ]
  rw [← mul_pow, _root_.MIPStarRE.QPBT.inv_sqrt_natCast_mul_self, inv_pow, Fintype.card_fun]
  norm_cast

omit [Fintype K] [DecidableEq K] in
 theorem phaseSign_binTrace_dotProduct_add {ι : Type*} [Fintype ι]
    (u v w : ι → K) :
    _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct u v)) *
        _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct u w)) =
      _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct u (v + w))) := by
  rw [← _root_.MIPStarRE.QPBT.phaseSign_add]
  congr 2
  simp [dotProduct, mul_add, Finset.sum_add_distrib]

omit [Fintype K] [DecidableEq K] in
 theorem add_add_eq_zero_iff_eq_add {ι : Type*} (a x y : ι → K) :
    a + (x + y) = 0 ↔ x = y + a := by
  letI : CharP K 2 :=
    (Algebra.charP_iff (ZMod 2) K 2).mp (ZMod.charP 2)
  constructor
  · intro h
    funext i
    have hi : a i + (x i + y i) = 0 := by
      simpa only [Pi.add_apply, Pi.zero_apply] using congrFun h i
    have hax : a i + x i = y i := (CharTwo.add_eq_zero).mp (by
      simpa only [add_assoc] using hi)
    calc
      x i = a i + (a i + x i) := (CharTwo.add_cancel_left (a i) (x i)).symm
      _ = a i + y i := by rw [hax]
      _ = y i + a i := add_comm _ _
  · intro h
    funext i
    have hxi : x i = y i + a i := by
      simpa only [Pi.add_apply] using congrFun h i
    simp only [Pi.add_apply, Pi.zero_apply, hxi]
    calc
      a i + (y i + a i + y i) = (a i + a i) + (y i + y i) := by abel
      _ = 0 := by rw [CharTwo.add_self_eq_zero, CharTwo.add_self_eq_zero, zero_add]

 theorem sum_phaseSign_dotProduct {ι : Type*} [Fintype ι]
    [DecidableEq ι] (v : ι → K) :
    ∑ u : ι → K, _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct u v)) =
      if v = 0 then (Fintype.card (ι → K) : ℂ) else 0 := by
  calc
    ∑ u : ι → K, _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct u v)) =
        ∑ u : ι → K, _root_.LIDT.MIPStarRE.LDT.Preliminaries.ffChar (p := 2) (F := K) (dotProduct u v) := by
      apply Finset.sum_congr rfl
      intro u _
      rw [_root_.MIPStarRE.QPBT.phaseSign_eq_ffChar]
      rfl
    _ = if v = 0 then (Fintype.card (ι → K) : ℂ) else 0 := by
      simpa only [dotProduct] using
        (_root_.LIDT.MIPStarRE.LDT.Preliminaries.sum_ffChar_sum_mul (p := 2) (F := K) (ι := ι) v)

/--
The shift operator `τ^X(a)`.  Blueprint `def:generalized-pauli`; paper origin
`references/qpbt-paper/04_preliminaries.tex:1052-1096`.
-/
noncomputable def tauShift (a : K) : _root_.LIDT.MIPStarRE.Quantum.Op K :=
  fun i j => if i = j + a then 1 else 0

/--
The phase operator `τ^Z(b)`, with the fixed binary trace in the phase.  It is
the second operator of blueprint `def:generalized-pauli`; paper
`references/qpbt-paper/04_preliminaries.tex:1052-1096`.
-/
noncomputable def tauPhase (b : K) : _root_.LIDT.MIPStarRE.Quantum.Op K :=
  fun i j => if i = j then _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (b * j)) else 0

/-- The binary shift Pauli operator is Hermitian.  This is a
formalization-only specialization of the generalized Pauli definition. -/
theorem binaryTauShift_conjTranspose :
    (_root_.MIPStarRE.QPBT.tauShift (K := ZMod 2) 1)ᴴ = _root_.MIPStarRE.QPBT.tauShift (K := ZMod 2) 1 := by
  ext i j
  have hiff : j = i + 1 ↔ i = j + 1 := by
    rw [CharTwo.eq_add_iff_add_eq, eq_comm]
  simp [_root_.MIPStarRE.QPBT.tauShift, Matrix.conjTranspose_apply, hiff]

/-- The binary phase Pauli operator is Hermitian.  This is a
formalization-only specialization of the generalized Pauli definition. -/
theorem binaryTauPhase_conjTranspose :
    (_root_.MIPStarRE.QPBT.tauPhase (K := ZMod 2) 1)ᴴ = _root_.MIPStarRE.QPBT.tauPhase (K := ZMod 2) 1 := by
  ext i j
  rcases _root_.MIPStarRE.QPBT.zmod_two_eq_zero_or_one i with rfl | rfl <;>
    rcases _root_.MIPStarRE.QPBT.zmod_two_eq_zero_or_one j with rfl | rfl <;>
      norm_num [_root_.MIPStarRE.QPBT.tauPhase, _root_.MIPStarRE.QPBT.phaseSign, Matrix.conjTranspose_apply,
        Algebra.trace_self_apply]

/-- The binary shift Pauli operator is symmetric.  This formalization-only
identity supports transport across an EPR state. -/
theorem binaryTauShift_transpose :
    (_root_.MIPStarRE.QPBT.tauShift (K := ZMod 2) 1)ᵀ = _root_.MIPStarRE.QPBT.tauShift (K := ZMod 2) 1 := by
  ext i j
  have hiff : j = i + 1 ↔ i = j + 1 := by
    rw [CharTwo.eq_add_iff_add_eq, eq_comm]
  simp [_root_.MIPStarRE.QPBT.tauShift, Matrix.transpose_apply, hiff]

/-- The binary phase Pauli operator is symmetric.  This formalization-only
identity supports transport across an EPR state. -/
theorem binaryTauPhase_transpose :
    (_root_.MIPStarRE.QPBT.tauPhase (K := ZMod 2) 1)ᵀ = _root_.MIPStarRE.QPBT.tauPhase (K := ZMod 2) 1 := by
  ext i j
  rcases _root_.MIPStarRE.QPBT.zmod_two_eq_zero_or_one i with rfl | rfl <;>
    rcases _root_.MIPStarRE.QPBT.zmod_two_eq_zero_or_one j with rfl | rfl <;>
      norm_num [_root_.MIPStarRE.QPBT.tauPhase, _root_.MIPStarRE.QPBT.phaseSign, Matrix.transpose_apply,
        Algebra.trace_self_apply]

/-- The binary shift Pauli operator squares to the identity.  This is a
formalization-only specialization of the generalized Pauli definition. -/
theorem binaryTauShift_sq :
    _root_.MIPStarRE.QPBT.tauShift (K := ZMod 2) 1 * _root_.MIPStarRE.QPBT.tauShift (K := ZMod 2) 1 = 1 := by
  ext i j
  simp only [Matrix.mul_apply]
  rw [_root_.MIPStarRE.QPBT.sum_zmod_two]
  rcases _root_.MIPStarRE.QPBT.zmod_two_eq_zero_or_one i with rfl | rfl <;>
    rcases _root_.MIPStarRE.QPBT.zmod_two_eq_zero_or_one j with rfl | rfl <;>
      simp +decide [_root_.MIPStarRE.QPBT.tauShift]

/-- The binary phase Pauli operator squares to the identity.  This is a
formalization-only specialization of the generalized Pauli definition. -/
theorem binaryTauPhase_sq :
    _root_.MIPStarRE.QPBT.tauPhase (K := ZMod 2) 1 * _root_.MIPStarRE.QPBT.tauPhase (K := ZMod 2) 1 = 1 := by
  ext i j
  simp only [Matrix.mul_apply]
  rw [_root_.MIPStarRE.QPBT.sum_zmod_two]
  rcases _root_.MIPStarRE.QPBT.zmod_two_eq_zero_or_one i with rfl | rfl <;>
    rcases _root_.MIPStarRE.QPBT.zmod_two_eq_zero_or_one j with rfl | rfl <;>
      norm_num [_root_.MIPStarRE.QPBT.tauPhase, _root_.MIPStarRE.QPBT.phaseSign, Matrix.one_apply, Algebra.trace_self_apply]

/-- The binary shift and phase Pauli operators anticommute.  This is a
formalization-only specialization of their generalized definitions. -/
theorem binaryTauShift_mul_tauPhase :
    _root_.MIPStarRE.QPBT.tauShift (K := ZMod 2) 1 * _root_.MIPStarRE.QPBT.tauPhase (K := ZMod 2) 1 =
      -(_root_.MIPStarRE.QPBT.tauPhase (K := ZMod 2) 1 * _root_.MIPStarRE.QPBT.tauShift (K := ZMod 2) 1) := by
  ext i j
  change
    (∑ k, _root_.MIPStarRE.QPBT.tauShift (K := ZMod 2) 1 i k * _root_.MIPStarRE.QPBT.tauPhase (K := ZMod 2) 1 k j) =
      -(∑ k, _root_.MIPStarRE.QPBT.tauPhase (K := ZMod 2) 1 i k * _root_.MIPStarRE.QPBT.tauShift (K := ZMod 2) 1 k j)
  rw [_root_.MIPStarRE.QPBT.sum_zmod_two, _root_.MIPStarRE.QPBT.sum_zmod_two]
  rcases _root_.MIPStarRE.QPBT.zmod_two_eq_zero_or_one i with rfl | rfl <;>
    rcases _root_.MIPStarRE.QPBT.zmod_two_eq_zero_or_one j with rfl | rfl <;>
      simp +decide [_root_.MIPStarRE.QPBT.tauShift, _root_.MIPStarRE.QPBT.tauPhase, _root_.MIPStarRE.QPBT.phaseSign]

/-- The single-qudit eigenvector coordinate used in the tensor-product basis;
see `references/qpbt-paper/04_preliminaries.tex:1126-1161`. -/
noncomputable def singlePauliVec (W : _root_.MIPStarRE.QPBT.PauliKind) (e x : K) : ℂ :=
  match W with
  | .Z => if x = e then 1 else 0
  | .X =>
      (Real.sqrt (Fintype.card K : ℝ) : ℂ)⁻¹ * _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (e * x))

/--
The normalized single/multi-qudit eigenvector for a Pauli basis label.  For an
index type `ι`, the input `e : ι → K` labels the tensor-product basis vector.
This is the vector form of blueprint
`def:generalized-pauli`, paper origin
`references/qpbt-paper/04_preliminaries.tex:1101-1122`.
-/
noncomputable def pauliVec {ι : Type*} [Fintype ι] [DecidableEq ι]
    (W : _root_.MIPStarRE.QPBT.PauliKind) (e : ι → K) (x : ι → K) : ℂ :=
  ∏ i : ι, _root_.MIPStarRE.QPBT.singlePauliVec W (e i) (x i)

/--
The rank-one projector onto `pauliVec W e`.  This is the projective measurement
element `τ^W_e` in blueprint `def:generalized-pauli`; paper
`references/qpbt-paper/04_preliminaries.tex:1101-1122`.
-/
noncomputable def pauliProj {ι : Type*} [Fintype ι] [DecidableEq ι]
    (W : _root_.MIPStarRE.QPBT.PauliKind) (e : ι → K) : _root_.LIDT.MIPStarRE.Quantum.Op (ι → K) :=
  Matrix.vecMulVec (_root_.MIPStarRE.QPBT.pauliVec W e) (fun x => star (_root_.MIPStarRE.QPBT.pauliVec W e x))

private theorem pauliProj_X_apply {ι : Type*} [Fintype ι] [DecidableEq ι]
    (e x y : ι → K) :
    _root_.MIPStarRE.QPBT.pauliProj .X e x y =
      (Fintype.card (ι → K) : ℂ)⁻¹ *
        _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct e (x + y))) := by
  change
    (∏ i : ι, (Real.sqrt (Fintype.card K : ℝ) : ℂ)⁻¹ *
        _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (e i * x i))) *
      star (∏ i : ι, (Real.sqrt (Fintype.card K : ℝ) : ℂ)⁻¹ *
        _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (e i * y i))) = _
  rw [Finset.prod_mul_distrib, Finset.prod_mul_distrib,
    _root_.MIPStarRE.QPBT.prod_phaseSign_binTrace_dotProduct, _root_.MIPStarRE.QPBT.prod_phaseSign_binTrace_dotProduct]
  simp only [star_mul, _root_.MIPStarRE.QPBT.star_phaseSign]
  have hstar :
      star (∏ _i : ι, (Real.sqrt (Fintype.card K : ℝ) : ℂ)⁻¹) =
        ∏ _i : ι, (Real.sqrt (Fintype.card K : ℝ) : ℂ)⁻¹ := by
    simp
  rw [hstar]
  calc
    (∏ _i : ι, (Real.sqrt (Fintype.card K : ℝ) : ℂ)⁻¹) *
          _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct e x)) *
        (_root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct e y)) *
          ∏ _i : ι, (Real.sqrt (Fintype.card K : ℝ) : ℂ)⁻¹) =
        ((∏ _i : ι, (Real.sqrt (Fintype.card K : ℝ) : ℂ)⁻¹) *
          ∏ _i : ι, (Real.sqrt (Fintype.card K : ℝ) : ℂ)⁻¹) *
            (_root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct e x)) *
              _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct e y))) := by ring
    _ = _ := by
      rw [pauliNormalizer_mul_self, phaseSign_binTrace_dotProduct_add]

/-- Generalized Pauli eigenspace projectors are symmetric matrices in
characteristic two. For the `X` basis this uses `x + y = y + x` in the
character formula; for the `Z` basis the projector is diagonal. This is the
EPR-transport property used in `lem:qld-comm-cons`, paper
`references/qpbt-paper/14_analysis_of_the_pauli_basis_test.tex:455-465`. -/
theorem pauliProj_transpose {ι : Type*} [Fintype ι] [DecidableEq ι]
    (W : _root_.MIPStarRE.QPBT.PauliKind) (e : ι → K) :
    (_root_.MIPStarRE.QPBT.pauliProj W e)ᵀ = _root_.MIPStarRE.QPBT.pauliProj W e := by
  ext x y
  rw [Matrix.transpose_apply]
  cases W with
  | X =>
      rw [pauliProj_X_apply, pauliProj_X_apply, add_comm]
  | Z =>
      have hreal (z : ι → K) : star (_root_.MIPStarRE.QPBT.pauliVec .Z e z) = _root_.MIPStarRE.QPBT.pauliVec .Z e z := by
        simp [_root_.MIPStarRE.QPBT.pauliVec, _root_.MIPStarRE.QPBT.singlePauliVec]
      change _root_.MIPStarRE.QPBT.pauliVec .Z e y * star (_root_.MIPStarRE.QPBT.pauliVec .Z e x) =
        _root_.MIPStarRE.QPBT.pauliVec .Z e x * star (_root_.MIPStarRE.QPBT.pauliVec .Z e y)
      rw [hreal x, hreal y, mul_comm]

/-- Generalized Pauli eigenspace projectors are mutually orthogonal. This is
the orthogonal-projector calculation used for the ancillary point measurement
in `lem:qld-comm-cons`, paper
`references/qpbt-paper/14_analysis_of_the_pauli_basis_test.tex:455-465`. -/
theorem pauliProj_mul_pauliProj {ι : Type*} [Fintype ι] [DecidableEq ι]
    (W : _root_.MIPStarRE.QPBT.PauliKind) (e f : ι → K) :
    _root_.MIPStarRE.QPBT.pauliProj W e * _root_.MIPStarRE.QPBT.pauliProj W f =
      if e = f then _root_.MIPStarRE.QPBT.pauliProj W e else 0 := by
  classical
  ext x z
  cases W with
  | X =>
      rw [Matrix.mul_apply]
      simp_rw [pauliProj_X_apply]
      have hsum :
          (∑ y : ι → K,
              ((Fintype.card (ι → K) : ℂ)⁻¹ *
                  _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct e (x + y)))) *
                ((Fintype.card (ι → K) : ℂ)⁻¹ *
                  _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct f (y + z))))) =
            (Fintype.card (ι → K) : ℂ)⁻¹ *
                (Fintype.card (ι → K) : ℂ)⁻¹ *
              _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct e x)) *
              _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct f z)) *
              ∑ y : ι → K,
                _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct y (e + f))) := by
        rw [Finset.mul_sum]
        apply Finset.sum_congr rfl
        intro y _
        rw [← phaseSign_binTrace_dotProduct_add e x y,
          ← phaseSign_binTrace_dotProduct_add f y z,
          ← phaseSign_binTrace_dotProduct_add y e f,
          dotProduct_comm e y, dotProduct_comm f y]
        ring
      rw [hsum, sum_phaseSign_dotProduct]
      letI : CharP K 2 :=
        (Algebra.charP_iff (ZMod 2) K 2).mp (ZMod.charP 2)
      by_cases hef : e = f
      · subst f
        have hzero : e + e = 0 := by
          funext i
          exact CharTwo.add_self_eq_zero (e i)
        rw [if_pos rfl, if_pos hzero]
        rw [pauliProj_X_apply]
        have hcard : (Fintype.card (ι → K) : ℂ) ≠ 0 := by positivity
        field_simp
        rw [← phaseSign_binTrace_dotProduct_add e x z]
      · have hadd : e + f ≠ 0 := by
          intro h
          apply hef
          funext i
          exact CharTwo.add_eq_zero.mp (congrFun h i)
        simp [hef, hadd]
  | Z =>
      have hz (g y : ι → K) :
          _root_.MIPStarRE.QPBT.pauliVec .Z g y = if y = g then 1 else 0 := by
        simp [_root_.MIPStarRE.QPBT.pauliVec, _root_.MIPStarRE.QPBT.singlePauliVec, Fintype.prod_ite_zero, ← funext_iff]
      by_cases hef : e = f
      · subst f
        simp [_root_.MIPStarRE.QPBT.pauliProj, Matrix.mul_apply, Matrix.vecMulVec_apply, hz]
      · have hfe : f ≠ e := Ne.symm hef
        simp [_root_.MIPStarRE.QPBT.pauliProj, Matrix.mul_apply, Matrix.vecMulVec_apply, hz, hef, hfe]

/-- A compact operator-valued form of a generalized Pauli observable from
blueprint `def:generalized-pauli`, paper origin
`references/qpbt-paper/04_preliminaries.tex:1052-1096`.
-/
noncomputable def tauObservable {ι : Type*} [Fintype ι] [DecidableEq ι]
    (W : _root_.MIPStarRE.QPBT.PauliKind) (a : ι → K) : _root_.LIDT.MIPStarRE.Quantum.Op (ι → K) :=
  fun x y =>
    ∏ i : ι,
      match W with
      | .X => _root_.MIPStarRE.QPBT.tauShift (a i) (x i) (y i)
      | .Z => _root_.MIPStarRE.QPBT.tauPhase (a i) (x i) (y i)

/--
The EPR vector on a finite label space.  Blueprint `def:EPR`; paper origin
`references/qpbt-paper/04_preliminaries.tex:946-955`.
-/
noncomputable def eprState (V : Type*) [Fintype V] [DecidableEq V] [Nonempty V] :
    EuclideanSpace ℂ (V × V) :=
  (EuclideanSpace.equiv (V × V) ℂ).symm
    (fun p : V × V =>
      if p.1 = p.2 then (Real.sqrt (Fintype.card V : ℝ) : ℂ)⁻¹ else 0)

/-- The EPR vector is normalized on a nonempty finite carrier; see
`def:EPR`, `references/qpbt-paper/04_preliminaries.tex:946-955`. -/
theorem eprState_norm (V : Type*) [Fintype V] [DecidableEq V] [Nonempty V] :
    ‖_root_.MIPStarRE.QPBT.eprState V‖ = 1 := by
  apply (sq_eq_sq₀ (norm_nonneg _) zero_le_one).mp
  rw [EuclideanSpace.norm_sq_eq]
  change
    (∑ p : V × V,
      ‖if p.1 = p.2 then (Real.sqrt (Fintype.card V : ℝ) : ℂ)⁻¹ else 0‖ ^ 2) =
      1 ^ 2
  rw [Fintype.sum_prod_type]
  have hcard : 0 < (Fintype.card V : ℝ) := by positivity
  calc
    ∑ x : V, ∑ y : V,
        ‖if x = y then (Real.sqrt (Fintype.card V : ℝ) : ℂ)⁻¹ else 0‖ ^ 2 =
        ∑ _x : V, ‖(Real.sqrt (Fintype.card V : ℝ) : ℂ)⁻¹‖ ^ 2 := by
      apply Finset.sum_congr rfl
      intro x _
      rw [Finset.sum_eq_single x]
      · simp
      · intro y _ hy
        simp [hy.symm]
      · simp
    _ = 1 := by
      rw [Finset.sum_const, nsmul_eq_mul]
      simp only [norm_inv, Complex.norm_real, Real.norm_eq_abs,
        abs_of_nonneg (Real.sqrt_nonneg _)]
      rw [inv_pow, Real.sq_sqrt hcard.le]
      norm_num [hcard.ne']
    _ = 1 ^ 2 := by norm_num

/--
Fourier expansion of a generalized Pauli observable in the Pauli projectors.
This theorem is the characteristic-two (binary) specialization of the forward
identity `eq:pauli-obs-proj` in `lem:pauli-observable-expansion`,
with blueprint source `lem:pauli-observable-expansion`; paper origin
`references/qpbt-paper/04_preliminaries.tex:1151-1161`.

**Scope restriction:** This characteristic-two specialization is separated
from the general-prime identity as documented in
`docs/paper-gaps/qpbt_characteristic-two-pauli-scope.tex`.
-/
theorem tauObservable_eq_sum_pauliProj {ι : Type*} [Fintype ι] [DecidableEq ι]
    (W : _root_.MIPStarRE.QPBT.PauliKind) (a : ι → K) :
    _root_.MIPStarRE.QPBT.tauObservable W a =
      ∑ e : ι → K, _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct a e)) • _root_.MIPStarRE.QPBT.pauliProj W e := by
  ext x y
  rw [show
    (∑ e : ι → K, _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct a e)) • _root_.MIPStarRE.QPBT.pauliProj W e) x y =
      ∑ e : ι → K,
        _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct a e)) * _root_.MIPStarRE.QPBT.pauliProj W e x y by
          rw [Matrix.sum_apply]
          rfl]
  cases W with
  | X =>
      change
        (∏ i : ι, if x i = y i + a i then 1 else 0) =
          ∑ e : ι → K,
            _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct a e)) * _root_.MIPStarRE.QPBT.pauliProj .X e x y
      simp_rw [pauliProj_X_apply]
      rw [Fintype.prod_boole]
      have hsupport : (∀ i, x i = y i + a i) ↔ x = y + a := by
        simpa only [Pi.add_apply] using
          (funext_iff (f := x) (g := y + a)).symm
      simp only [hsupport]
      have hsum :
          (∑ e : ι → K,
            _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct a e)) *
              ((Fintype.card (ι → K) : ℂ)⁻¹ *
                _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct e (x + y))))) =
            (Fintype.card (ι → K) : ℂ)⁻¹ *
              ∑ e : ι → K,
                _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct e (a + (x + y)))) := by
        rw [Finset.mul_sum]
        apply Finset.sum_congr rfl
        intro e _
        calc
          _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct a e)) *
                ((Fintype.card (ι → K) : ℂ)⁻¹ *
                  _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct e (x + y)))) =
              (Fintype.card (ι → K) : ℂ)⁻¹ *
                (_root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct e a)) *
                  _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct e (x + y)))) := by
            rw [dotProduct_comm a e]
            ring
          _ = _ := by rw [phaseSign_binTrace_dotProduct_add]
      rw [hsum, sum_phaseSign_dotProduct]
      by_cases hsupport : x = y + a
      · have hzero : a + (x + y) = 0 :=
          (add_add_eq_zero_iff_eq_add a x y).mpr hsupport
        rw [if_pos hsupport, if_pos hzero]
        exact (inv_mul_cancel₀
          (show (Fintype.card (ι → K) : ℂ) ≠ 0 by positivity)).symm
      · have hzero : a + (x + y) ≠ 0 := fun h =>
          hsupport ((add_add_eq_zero_iff_eq_add a x y).mp h)
        simp [hsupport, hzero]
  | Z =>
      change
        (∏ i : ι, if x i = y i then _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (a i * y i)) else 0) =
          ∑ e : ι → K, _root_.MIPStarRE.QPBT.phaseSign (_root_.MIPStarRE.QPBT.binTrace K (dotProduct a e)) *
            ((∏ i : ι, if x i = e i then 1 else 0) *
              star (∏ i : ι, if y i = e i then 1 else 0))
      simp only [Fintype.prod_ite_zero, Finset.prod_const_one]
      by_cases hxy : x = y
      · subst y
        rw [_root_.MIPStarRE.QPBT.prod_phaseSign_binTrace_dotProduct]
        simp [← funext_iff]
      · simp [← funext_iff, hxy]



omit [Field K] [Fintype K] [Algebra (ZMod 2) K] in
/-- Formalization-only: a product of coordinate indicators is the indicator of
equality of the two tuples. -/
private theorem prod_indicator_eq_one_apply {ι : Type*} [Fintype ι]
    (x y : ι → K) :
    (∏ _i : ι, (if x _i = y _i then (1 : ℂ) else 0)) = if x = y then 1 else 0 := by
  by_cases h : x = y
  · subst h
    simp
  · rw [if_neg h]
    obtain ⟨i, hi⟩ := Function.ne_iff.mp h
    exact Finset.prod_eq_zero (Finset.mem_univ i) (if_neg hi)

omit [Fintype K] in
/-- The generalized Pauli observable at the zero label is the identity, for
either Pauli kind.  blueprint
`def:generalized-pauli`. -/
theorem tauObservable_zero {ι : Type*} [Fintype ι] [DecidableEq ι] (W : _root_.MIPStarRE.QPBT.PauliKind) :
    _root_.MIPStarRE.QPBT.tauObservable (K := K) W (0 : ι → K) = 1 := by
  ext x y
  rw [Matrix.one_apply, ← prod_indicator_eq_one_apply (K := K) x y]
  simp only [_root_.MIPStarRE.QPBT.tauObservable]
  cases W <;>
    exact Finset.prod_congr rfl fun i _ => by
      simp [_root_.MIPStarRE.QPBT.tauShift, _root_.MIPStarRE.QPBT.tauPhase, _root_.MIPStarRE.QPBT.phaseSign]

/-- The Pauli basis projectors of one kind sum to the identity: they are the
effects of a complete measurement.  This is the Fourier expansion
`tauObservable_eq_sum_pauliProj` of `lem:pauli-observable-expansion` at the zero
label, blueprint `lem:pauli-observable-expansion`, paper
`references/qpbt-paper/04_preliminaries.tex:1151-1161`. -/
theorem sum_pauliProj_eq_one {ι : Type*} [Fintype ι] [DecidableEq ι] (W : _root_.MIPStarRE.QPBT.PauliKind) :
    (∑ e : ι → K, _root_.MIPStarRE.QPBT.pauliProj W e) = 1 := by
  have h := _root_.MIPStarRE.QPBT.tauObservable_eq_sum_pauliProj (K := K) W (0 : ι → K)
  rw [_root_.MIPStarRE.QPBT.tauObservable_zero] at h
  rw [h]
  refine Finset.sum_congr rfl fun e _ => ?_
  have hzero : dotProduct (0 : ι → K) e = 0 := by
    simp [dotProduct]
  rw [hzero]
  simp [_root_.MIPStarRE.QPBT.phaseSign]

/-- Each Pauli basis projector is positive semidefinite: it is the rank-one
outer product of the normalized Pauli eigenvector with itself. -/
theorem posSemidef_pauliProj {ι : Type*} [Fintype ι] [DecidableEq ι]
    (W : _root_.MIPStarRE.QPBT.PauliKind) (e : ι → K) : (_root_.MIPStarRE.QPBT.pauliProj W e).PosSemidef := by
  set A : Matrix Unit (ι → K) ℂ :=
    Matrix.of (fun (_ : Unit) (x : ι → K) => star (_root_.MIPStarRE.QPBT.pauliVec W e x)) with hA
  have h : _root_.MIPStarRE.QPBT.pauliProj W e = Aᴴ * A := by
    ext x y
    rw [Matrix.mul_apply]
    simp [hA, _root_.MIPStarRE.QPBT.pauliProj, Matrix.vecMulVec_apply, Matrix.conjTranspose_apply]
  rw [h]
  exact Matrix.posSemidef_conjTranspose_mul_self A

end MIPStarRE.QPBT
Source
https://github.com/Dengnifer/MIPStarRE-QPBT/blob/8f4118aeea7be16912adbaee3df6dce1741a2c26/QPBT/Algebra/Pauli.lean#L35-L691

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