Documentation

CsdLean4.Mathlib.QuantumInfo.Magic

The magic layer: the T gate escapes the Clifford closure (candidate 5) #

Category: 1-Mathlib (CSD-free).

Glossary: https://glossary.constraintsurfacedynamics.com/magic-state/ Plain-language, CSD-role and formal statements of magic states, with this module as their Lean anchor. Kept symmetric by scripts/check-glossary.sh.

The precise complement of the Gottesman–Knill mechanism (plan specs/magic-plan.md): GK-2 proved that H, S, CNOT conjugate every Pauli to a phase times a Pauli — the closure that makes Clifford circuits classically trackable. This module proves the boundary is real: the T gate (the π/8 gate) breaks it, which is why T is the standard route to universality and why magic states are a resource.

Honest scope. This module formalises what magic is — the provable escape from the Clifford closure and the resource state — not how it is used or distilled: the Bravyi–Kitaev 15-to-1 distillation protocol is not attempted (⚠️ RESIDUE(R-004)), no universality claim is made — that would need a gate-synthesis density theorem (⚠️ RESIDUE(R-005)) — and the gate-teleportation circuit injecting T from magicState is not attempted (⚠️ RESIDUE(R-006)). No priority claim of any kind (CL-061 rule).

The T gate #

noncomputable def QuantumInfo.tPhase :

The T phase e^{iπ/4}.

Equations
Instances For
    noncomputable def QuantumInfo.tPhaseInv :

    The inverse T phase e^{−iπ/4}.

    Equations
    Instances For

      T² = S at the phase level: (e^{iπ/4})² = i.

      √2/2 = (√2)⁻¹.

      The explicit value e^{iπ/4} = (1 + i)/√2.

      The explicit value e^{−iπ/4} = (1 − i)/√2.

      noncomputable def QuantumInfo.tGate {n : } (j : Fin n) (ψ : QReg n) :

      The T gate (π/8 gate) on qubit j: phase e^{iπ/4} on the z_j = 1 branch.

      Equations
      Instances For
        noncomputable def QuantumInfo.tGateInv {n : } (j : Fin n) (ψ : QReg n) :

        The inverse T gate.

        Equations
        Instances For
          @[simp]
          theorem QuantumInfo.tGate_apply {n : } (j : Fin n) (ψ : QReg n) (z : Fin nFin 2) :
          (tGate j ψ).ofLp z = tPhase ^ (z j) * ψ.ofLp z
          @[simp]
          theorem QuantumInfo.tGateInv_apply {n : } (j : Fin n) (ψ : QReg n) (z : Fin nFin 2) :
          (tGateInv j ψ).ofLp z = tPhaseInv ^ (z j) * ψ.ofLp z
          theorem QuantumInfo.tGate_tGateInv {n : } (j : Fin n) (ψ : QReg n) :
          tGate j (tGateInv j ψ) = ψ
          theorem QuantumInfo.tGateInv_tGate {n : } (j : Fin n) (ψ : QReg n) :
          tGateInv j (tGate j ψ) = ψ
          theorem QuantumInfo.tGate_tGate {n : } (j : Fin n) (ψ : QReg n) :
          tGate j (tGate j ψ) = sGate j ψ

          The hierarchy descends: T² = S — the square of the non-Clifford gate is Clifford.

          Conjugating X: out of the Pauli family, into its span #

          def QuantumInfo.unitV {n : } (j : Fin n) :
          Fin nFin 2

          The single-bit label at j.

          Equations
          Instances For
            theorem QuantumInfo.unitV_apply_self {n : } (j : Fin n) :
            unitV j j = 1
            theorem QuantumInfo.bdot_unitV {n : } (j : Fin n) (w : Fin nFin 2) :
            bdot (unitV j) w = w j
            theorem QuantumInfo.tGate_conj_X {n : } (j : Fin n) (ψ : QReg n) :
            tGate j (pauliOp (unitV j) 0 (tGateInv j ψ)) = (↑2)⁻¹ (pauliOp (unitV j) 0 ψ + Complex.I pauliOp (unitV j) (unitV j) ψ)

            The level-3 hierarchy identity: T X T† = (X + i·XZ)/√2 — conjugation by T carries the Pauli X out of the Pauli family, but only into its two-term Clifford-algebra span.

            theorem QuantumInfo.tGate_smul {n : } (j : Fin n) (c : ) (ψ : QReg n) :
            tGate j (c ψ) = c tGate j ψ

            The T gate is homogeneous.

            theorem QuantumInfo.tGate_basisState {n : } (j : Fin n) (w : Fin nFin 2) :

            The T gate on a basis state: a pure phase.

            theorem QuantumInfo.tGateInv_basisState {n : } (j : Fin n) (w : Fin nFin 2) :

            The inverse T gate on a basis state: a pure phase.

            theorem QuantumInfo.tconjX_basisState {n : } (j : Fin n) (w : Fin nFin 2) :
            tGate j (pauliOp (unitV j) 0 (tGateInv j (basisState w))) = (tPhaseInv ^ (w j) * tPhase ^ ↑(w j + 1)) basisState (w + unitV j)

            T X T† on a basis state, in closed form.

            theorem QuantumInfo.tGate_conj_X_not_pauli :
            ¬∃ (c : ) (a : Fin 1Fin 2) (b : Fin 1Fin 2), ∀ (ψ : QReg 1), tGate 0 (pauliOp (unitV 0) 0 (tGateInv 0 ψ)) = c pauliOp a b ψ

            ★★ The no-go: T is not Clifford. There are no c, a, b with T X T† = c · X^a Z^b — the conjugation escape is genuine, not a phase artefact. Pinning the two basis columns forces 1 = ±i.

            The magic state #

            noncomputable def QuantumInfo.magicState :

            The magic state |T⟩ = T·H|0⟩ on one qubit.

            Equations
            Instances For
              theorem QuantumInfo.magicState_apply (z : Fin 1Fin 2) :
              magicState.ofLp z = (↑2)⁻¹ * tPhase ^ (z 0)

              Coordinates: |T⟩ = (|0⟩ + e^{iπ/4}|1⟩)/√2.

              The magic state is a unit vector.