AFTD Auto-Formalizing Theoretical Domains

apply_clifford_gate

def

The symplectic action of a Clifford gate g : CliffordGate k on a PauliLabel k: h i swaps the x and z components at qubit i; s i updates the z component at qubit i by adding the x component; and cnot c t _ adds the x component at control c to target t, and adds the z component at target t to control c.

Statement

def apply_clifford_gate {k : ℕ} (g : CliffordGate k) (p : PauliLabel k) : PauliLabel k
Defined in
scout/2610-04621-exact-clifford-optimality-for-two-sided-locally-randomized.md:453
Verified
31 Oct 2026
Axioms
none listed
Built on 2
  • CliffordGateAn inductive type representing a quantum gate in a k-qubit Clifford circuit: Hadamard h on qubit i : Fin k, phase gate s on qubit i : Fin…
  • PauliLabelA binary symplectic Pauli label on k qubits, given as a pair of binary vectors (x, z) in (ZMod 2)^k x (ZMod 2)^k.
Used by 5

Read back from the Lean

Given a natural number $k$, a Clifford gate $g$ on $k$ qubits, and a Pauli label $p = (x, z) \in (\mathrm{Fin}\ k \to \mathbb{Z}/2\mathbb{Z}) \times (\mathrm{Fin}\ k \to \mathbb{Z}/2\mathbb{Z})$, apply_clifford_gate g p defines the Pauli label resulting from applying $g$ to $p$: - If $g = \mathrm{h}(i)$ for $i \in \mathrm{Fin}\ k$, it swaps the $i$-th components of $x$ and $z$, returning $(\mathrm{update}(x, i, z(i)),\ \mathrm{update}(z, i, x(i)))$. - If $g = \mathrm{s}(i)$ for $i \in \mathrm{Fin}\ k$, it keeps $x$ unchanged and updates the $i$-th component of $z$ by adding $x(i)$, returning $(x,\ \mathrm{update}(z, i, z(i) + x(i)))$. - If $g = \mathrm{cnot}(c, t, \_)$ for control $c \in \mathrm{Fin}\ k$ and target $t \in \mathrm{Fin}\ k$ (with proof $c \neq t$), it updates the $t$-th component of $x$ to $x(t) + x(c)$ and the $c$-th component of $z$ to $z(c) + z(t)$, returning $(\mathrm{update}(x, t, x(t) + x(c)),\ \mathrm{update}(z, c, z(c) + z(t)))$.

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

Lean source view module on GitHub

/-- Symplectic action of a Clifford gate on a binary Pauli label. -/
def apply_clifford_gate {k : ℕ} (g : CliffordGate k) (p : PauliLabel k) : PauliLabel k := match g with
  | .h i => (Function.update p.1 i (p.2 i), Function.update p.2 i (p.1 i))
  | .s i => (p.1, Function.update p.2 i (p.2 i + p.1 i))
  | .cnot c t _ => (Function.update p.1 t (p.1 t + p.1 c), Function.update p.2 c (p.2 c + p.2 t))
See it in the graphDiscuss this resultChallenge it