AFTD Auto-Formalizing Theoretical Domains

PauliBasis.toMatrix

defimported Lean

Maps each Pauli basis element $\{I,X,Y,Z\}$ to its corresponding $2\times 2$ matrix $\{\sigma_I,\sigma_X,\sigma_Y,\sigma_Z\}$.

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 PauliBasis.toMatrix : PauliBasis → Matrix (Fin 2) (Fin 2) ℂ
Defined in
TCSlib, `PauliBasis.toMatrix`
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.
Verified
07 Oct 2026
Axioms
none listed
Built on 5
  • sigmaIThe $2\times 2$ identity matrix over $\mathbb{C}$, i.e.\ the Pauli operator $I$.
  • sigmaXThe bit-flip Pauli matrix $X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}$ over $\mathbb{C}$.
  • sigmaZThe phase-flip Pauli matrix $Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}$ over $\mathbb{C}$.
  • PauliBasisThe four Pauli basis elements $\{I,X,Y,Z\}$, represented as an inductive type.
  • sigmaYThe bit-phase-flip Pauli matrix $Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}$ over $\mathbb{C}$.
Used by 11
  • xz_transfer_matrixThe 16x16 transfer matrix M whose entries M u v are given by the trace of the 4-fold product of Pauli matrices (xz_pauli (u 0) (v…
  • 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_replica_transfer_matrixxz_replica_transfer_matrix q : Matrix (Fin (2*q) → Fin 2) (Fin (2*q) → Fin 2) ℂ, with entry…
  • 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…
  • gaussPauliFrameThe single-qubit Pauli frame C(m)_{ij} = Re tr(m^* σ_i m σ_j)/2 of a 2x2 matrix m.
  • xz_rho_trace_oneFor every natural number L with 1 ≤ L, the trace of the reduced density matrix xz_rho L equals 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…
  • pauliMatrixFor 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…
  • xz_matrix_a_is_hermitianFor every natural number L, the matrix xz_matrix_a L is Hermitian: (xz_matrix_a L).IsHermitian.
  • 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 L is 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
/-- Maps each Pauli basis element to its corresponding 2×2 matrix. -/
noncomputable def PauliBasis.toMatrix : PauliBasis → Matrix (Fin 2) (Fin 2) ℂ
| PauliBasis.I => sigmaI
| PauliBasis.X => sigmaX
| PauliBasis.Y => sigmaY
| PauliBasis.Z => sigmaZ
See it in the graphDiscuss this resultChallenge it