pauliMatrix
defimported Lean
For a Pauli string $p$ on $n$ qubits, the $2^n\times 2^n$ matrix obtained as the tensor product of the single-qubit Pauli matrices $\sigma_{p(i)}$ over all coordinates~$i$.
Statement
set_option linter.mathlibStandardSet false in open scoped BigOperators in open scoped Real in open scoped Nat in open scoped Classical in open scoped Pointwise in set_option maxRecDepth 4000 in set_option synthInstance.maxHeartbeats 20000 in set_option synthInstance.maxSize 128 in set_option relaxedAutoImplicit false in set_option autoImplicit false in open Complex Matrix in noncomputable def pauliMatrix {n : ℕ} (p : PauliString n) : Matrix (Fin n → Fin 2) (Fin n → Fin 2) ℂ
- Defined in
- TCSlib, `pauliMatrix`
- Lean proof
- By Allan Li, Hydroxyi (from the file's git history), from github.com/Shilun-Allan-Li/tcslib at
c8a02591b1e5(Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.25.0.pauliMatrix← pauliMatrix (TCSlib/ErrorCorrectingCodes/QuantumHamming.lean:97): verbatim
- Verified
- 07 Oct 2026
- Axioms
- none listed
- Built on 2
- PauliBasis.toMatrixMaps each Pauli basis element $\{I,X,Y,Z\}$ to its corresponding $2\times 2$ matrix $\{\sigma_I,\sigma_X,\sigma_Y,\sigma_Z\}$.
- PauliStringA Pauli string of length $n$ is a function $p : \mathrm{Fin}\,n \to \mathrm{PauliBasis}$.
- Used by 12
- tr_pauli_of_ne_oneIf a Pauli string on $n$ qubits contains at least one non-identity single-qubit Pauli operator, then its tensor-product matrix has trace…
- xz_matrix_aThe matrix
xz_matrix_a (L : ℕ) : Matrix (Fin L → Fin 2) (Fin L → Fin 2) ℂdefined as… - stabilizer_subspace_finrank_eq_two_powLet $k \le n$ and let $g_1, \dots, g_{n-k}$ be $n$-qubit Pauli operators $g_l = \varepsilon_l P_l$ with signs…
- pauliOpAdjointThe adjoint (Hermitian conjugate) $\hat{p}^\dagger : \mathcal{H}_n \to \mathcal{H}_n$ of the Pauli operator associated with a Pauli string…
- xz_rho_trace_oneFor every natural number L with 1 ≤ L, the trace of the reduced density matrix
xz_rho Lequals 1:Matrix.trace (xz_rho L) = 1. - pauli_moment_two_eq_four_replica_sumFor every natural number n and n-qubit pure state ψ in Hn n, the second Pauli-Liouville moment (pauliLiouvilleMomentTwo n ψ as a complex…
- pauliOpFor $p \in \mathrm{PauliString}\,n$, the associated Pauli operator $\hat{p} : \mathcal{H}_n \to \mathcal{H}_n$.
- gaussPauliExpectReal part of the Pauli expectation of the 3-qubit Pauli string p in the pure state ψ, i.e. Re⟨ψ|P_p|ψ⟩.
- xz_matrix_a_is_hermitianFor every natural number L, the matrix
xz_matrix_a Lis Hermitian:(xz_matrix_a L).IsHermitian. - error_subspaces_orthogonalOrthogonality of distinct error subspaces. Let $C \le \mathcal{H}_n$ be a code that is non-degenerate for $t$-error correction, and let…
- error_sphere_dimensionDimension of the error sphere of a non-degenerate code. Let $C \le \mathcal{H}_n$ be a code on $n$ qubits that is non-degenerate for $t$…
- xz_rho_is_hermitianFor every natural number L, the reduced density matrix
xz_rho Lis Hermitian:(xz_rho L).IsHermitian.
Lean source view module on GitHub
set_option linter.mathlibStandardSet false in open scoped BigOperators in open scoped Real in open scoped Nat in open scoped Classical in open scoped Pointwise in set_option maxRecDepth 4000 in set_option synthInstance.maxHeartbeats 20000 in set_option synthInstance.maxSize 128 in set_option relaxedAutoImplicit false in set_option autoImplicit false in open Complex Matrix in /-- The 2^n × 2^n matrix for an n-qubit Pauli string, given as a tensor product of single-qubit Pauli matrices. -/ noncomputable def pauliMatrix {n : ℕ} (p : PauliString n) : Matrix (Fin n → Fin 2) (Fin n → Fin 2) ℂ := fun i j => ∏ k, (p k).toMatrix (i k) (j k)