Pauli operators, Z2 symmetry, translation and the Kramers-Wannier operator on a periodic qubit chain
DefinitionKramersWannier_defsFor qubits on a ring: basis labels Config L , operators Op L (complex matrices indexed by configurations), the sign sgn , Pauli operators pauliX j (flip spin ) and pauliZ j (diagonal ), the symmetry eta (flip all spins), the translation transl (, , indices mod ), and the Kramers-Wannier operator kwD with .
import Mathlib
/-!
# The Kramers–Wannier operator on a periodic qubit chain (Seiberg–Seifnashri–Shao 2024)
N. Seiberg, S. Seifnashri, S.-H. Shao, *Non-invertible symmetries and LSM-type constraints on a
tensor product Hilbert space*, SciPost Phys. 16, 154 (2024), arXiv:2401.12281, §1.1 and §2.
A chain of `L` qubits with periodic boundary conditions (site `j` and site `j + L` are identified,
realised by modular arithmetic in `Fin L`). The Hilbert space `(ℂ²)^{⊗L}` is identified with
functions on the computational (`Z`-eigen)basis `Config L = Fin L → ZMod 2`, where `s j = 0`
means `Z_j = +1` and `s j = 1` means `Z_j = -1`. Operators are complex matrices indexed by
`Config L`.
* `pauliX j`, `pauliZ j`: the Pauli operators on site `j` (`X_j` flips `s j`, `Z_j = (-1)^{s j}`);
* `eta`: the `ℤ₂` symmetry `η = ∏_j X_j` (flips every spin), eq. (1.2);
* `transl`: the lattice translation `T`, with `T X_j T⁻¹ = X_{j+1}`, `T Z_j T⁻¹ = Z_{j+1}`,
eqs. (1.1), (2.10); in the basis, `T |s⟩ = |s'⟩` with `s'_{k} = s_{k-1}`;
* `kwD`: the Kramers–Wannier operator `D` with matrix elements
`⟨t| D |s⟩ = 2^{-L/2} (-1)^{∑_k t_k (s_k + s_{k+1})}`.
This explicit formula is taken as the definition; it is the operator satisfying (1.4)–(1.5) and
(2.65) in the paper's normalisation (footnote 1). Its equality with the matrix-product presentation
(2.64) is not part of this development.
-/
namespace KramersWannier
/-- Computational-basis labels of `L` qubits: `s j ∈ ZMod 2` is the `Z_j` eigenvalue `(-1)^{s j}`. -/
abbrev Config (L : ℕ) := Fin L → ZMod 2
/-- The sign `(-1)^a` for `a ∈ ZMod 2`. -/
def sgn (a : ZMod 2) : ℂ := if a = 0 then 1 else -1
/-- Operators on `(ℂ²)^{⊗L}`, as matrices in the computational basis. -/
abbrev Op (L : ℕ) := Matrix (Config L) (Config L) ℂ
variable (L : ℕ)
/-- Pauli `X_j`: flips the spin on site `j`, `X_j |s⟩ = |s + e_j⟩`. -/
def pauliX (j : Fin L) : Op L := fun t s => if t = s + Pi.single j 1 then 1 else 0
/-- Pauli `Z_j`: diagonal, `Z_j |s⟩ = (-1)^{s j} |s⟩`. -/
def pauliZ (j : Fin L) : Op L := Matrix.diagonal fun s => sgn (s j)
/-- The `ℤ₂` symmetry operator `η = ∏_j X_j` (eq. (1.2)): flips every spin. -/
def eta : Op L := fun t s => if t = s + 1 then 1 else 0
/-- Lattice translation `T` (eqs. (1.1), (2.10): `T X_j T⁻¹ = X_{j+1}`):
`T |s⟩ = |s'⟩` with `s'_k = s_{k-1}`, indices mod `L`. -/
def transl [NeZero L] : Op L := fun u s => if u = (fun k => s (k - 1)) then 1 else 0
/-- The non-invertible Kramers–Wannier operator `D` (eqs. (1.4), (1.5), (2.64)):
`⟨t| D |s⟩ = 2^{-L/2} (-1)^{∑_k t_k (s_k + s_{k+1})}`, indices mod `L`. -/
noncomputable def kwD [NeZero L] : Op L :=
fun t s => ((Real.sqrt 2 : ℂ)⁻¹) ^ L * sgn (∑ k, t k * (s k + s (k + 1)))
end KramersWannier
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Throughout, is a natural number and . Site indices live in (i.e. with addition and subtraction taken mod ; in particular and wrap around). The definitions below do not themselves assume , except transl and kwD, which require .
Configurations. is the set of all functions (there are of them). It is an additive group under pointwise addition; denotes the configuration that is at site and elsewhere, and the constant configuration .
Sign. For , is if and if , i.e. ; it satisfies .
Operators. An "operator" is simply a complex matrix whose rows and columns are indexed by ; is the entry in row , column (read as ). Products are ordinary matrix products, acting on column vectors. No tensor-product structure is used; all operators are defined by their matrix entries:
- Pauli X at site : if , else . So is the permutation matrix sending basis vector to .
- Pauli Z at site : the diagonal matrix with .
- : if (every spin flipped), else .
- Translation (requires ): if for all (indices mod ), else . So with ; for , is the identity matrix.
- Kramers–Wannier operator (requires ):
where the exponent is computed in and wraps mod . All entries are real, of absolute value . Edge case : , so .
The docstrings attribute these to a specific paper (equation numbers, normalisation, "closed form of the matrix-product operator of eq. (2.64)"); the code contains only the explicit formulas above, with no matrix-product-operator construction, so that identification is a claim not represented in the code.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.