AFTD Auto-Formalizing Theoretical Domains

PauliBasis

inductiveimported Lean

The four Pauli basis elements $\{I,X,Y,Z\}$, represented as an inductive type.

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
inductive PauliBasis
Defined in
TCSlib, `PauliBasis`
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.
What was changed in PauliBasis
--- TCSlib/ErrorCorrectingCodes/QuantumHamming.lean:58 (PauliBasis)
+++ as compiled here
@@ -1,5 +1,14 @@
-/-- The four-element type indexing the single-qubit Pauli matrices:
-identity `I`, bit-flip `X`, bit-phase-flip `Y`, and phase-flip `Z`. -/
-inductive PauliBasis
-| I | X | Y | Z
-deriving DecidableEq, Fintype, Inhabited
+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
+inductive PauliBasis | I | X | Y | Z
+deriving DecidableEq, Inhabited
Verified
07 Oct 2026
Axioms
none listed
Used by 23
  • 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…
  • PauliNZ.toBasis_ne_INon-identity Paulis embed away from the identity. Write $\{X, Y, Z\}$ for the three non-identity Pauli labels, embedded in the natural way…
  • PauliNZ.toBasisEmbeds a non-identity Pauli ($X$, $Y$, or $Z$) from the three-element type $\mathrm{PauliNZ}$ into the full Pauli basis $\{I,X,Y,Z\}$.
  • gaussBlochBBloch vector of the second qubit: b_i = ⟨I ⊗ σ_i ⊗ I⟩.
  • xz_pauliThe function xz_pauli : Fin 2 → Fin 2 → PauliBasis taking two curried arguments a, b : Fin 2, mapping a = 0, b = 0 to PauliBasis.X; a =…
  • mkWithSupportGiven a finset $S \subseteq \mathrm{Fin}\,n$ and an assignment $f : S \to \mathrm{PauliNZ}$, constructs the Pauli string that equals…
  • supportThe support $\mathrm{supp}(p) \subseteq \mathrm{Fin}\,n$ consists of coordinates where $p(i) \neq I$; the weight is…
  • 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…
  • gaussAxisThe standard Bloch axis order X, Y, Z.
  • 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\}$.
  • instFintypePauliStringinstFintypePauliString
  • pauliXSupportThe X-support (bit-flip) vector of a Pauli string: (pauliXSupport p) i = 1 iff p i ∈ {X, Y}, else 0.
  • 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.
  • gaussBlochABloch vector of the first qubit: a_i = ⟨σ_i ⊗ I ⊗ I⟩.
  • 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…
  • gaussCorr2-qubit correlation matrix of qubits 1 and 2: A_{ij} = ⟨σ_i ⊗ σ_j ⊗ I⟩.
  • pauliZSupportThe Z-support (phase) vector of a Pauli string: (pauliZSupport p) i = 1 iff p i ∈ {Y, Z}, else 0.
  • PauliStringA Pauli string of length $n$ is a function $p : \mathrm{Fin}\,n \to \mathrm{PauliBasis}$.
  • xz_matrix_a_is_hermitianFor every natural number L, the matrix xz_matrix_a L is Hermitian: (xz_matrix_a L).IsHermitian.
  • card_pauliStringsExactSupportNumber of Pauli strings with a prescribed support. Let $n$ be a natural number and let $S \subseteq \mathrm{Fin}\,n$ be a set of…
  • pauliPhaseThe coordinate-independent scalar κ(b) ∈ {1, −i} extracted from a single-qubit Pauli matrix entry: κ(Y) = −i and κ = 1 otherwise, so that…
  • 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
/-- The four-element type indexing the single-qubit Pauli matrices: identity `I`, bit-flip `X`, bit-phase-flip `Y`, and phase-flip `Z`. -/
inductive PauliBasis | I | X | Y | Z
deriving DecidableEq, Inhabited

instance PauliBasis.instFintype : Fintype PauliBasis :=
  ⟨{.I, .X, .Y, .Z}, by intro x; cases x <;> decide⟩
See it in the graphDiscuss this resultChallenge it