344 Cartesian, Linear and Quantum: Logic from the Diagonal
Logics and their categories are distinguished by what they allow the diagonal and the discard
to do. Both come from the identity (Remark 350.1).
Structural rules.
the identity axiom \(A\vdash A\) is the identity itself;
cut is composition;
exchange is the swap involution;
contraction is the diagonal;
weakening is the discard.
Three regimes.
Regime
Copy and discard
Logic
cartesian
both natural on every object
intuitionistic, simply typed \(\lambda \)
linear
neither, except under \(!\)
linear logic
quantum
discard natural, copy only per basis
categorical quantum mechanics
Qubits and circuits again. In the quantum regime, each orthonormal basis is exactly
a commutative Frobenius algebra: a diagonal that copies its own basis states and
nothing else. Two complementary such diagonals, \(Z\) and \(X\), generate the ZX-calculus,
in which qubits, Paulis, Hadamard, Clifford and \(T\) gates, CNOT, CZ, measurement,
dephasing and teleportation are all derived. Teleportation is the triangle identity of an
adjunction.
344.1 Structural rules from the floor
In a sequent \(\Gamma \vdash B\), the structural rules are:
Rule
Form
Floor
identity
\(A\vdash A\)
\(\mathrm {id}_A\)
cut
from \(\Gamma \vdash A\) and \(A,\Delta \vdash B\) infer \(\Gamma ,\Delta \vdash B\)
composition
exchange
\(\Gamma ,A,B,\Delta \vdash C\) to \(\Gamma ,B,A,\Delta \vdash C\)
swap, \(\sigma ^2=\mathrm {id}\)
contraction
\(\Gamma ,A,A\vdash B\) to \(\Gamma ,A\vdash B\)
diagonal \(A\to A\otimes A\)
weakening
\(\Gamma \vdash B\) to \(\Gamma ,A\vdash B\)
discard \(A\to I\)
Cut elimination is the statement that composites of identities and rules reduce to normal
forms.
344.2 Cartesian categories
Copy and discard. In a symmetric monoidal category \((\mathcal C,\otimes ,I)\), give every object a comonoid,
\begin{equation} \delta _A:A\to A\otimes A, \qquad \epsilon _A:A\to I, \tag{21315}\end{equation}
coassociative, counital and commutative.
Fox’s theorem.\(\otimes \) is the cartesian product, and \(I\) terminal, iff \(\delta \) and \(\epsilon \) are natural:
Indeed,
given natural \(\delta ,\epsilon \), the projections are \(\pi _1=(1\otimes \epsilon )\) and \(\pi _2=(\epsilon \otimes 1)\), and the pairing is \(\langle f,g\rangle =(f\otimes g)\circ \delta \). Uniqueness of the pairing is
naturality. Conversely, products give \(\delta =\langle \mathrm {id},\mathrm {id}\rangle \). A cartesian category is one in which the diagonal of the
floor is natural on every object.
Closure and logic. A cartesian category is closed when \(-\times A\) has a right adjoint \(A\Rightarrow -\):
which is
currying. Cartesian closed categories, simply typed \(\lambda \)-calculus and intuitionistic propositional
logic are three presentations of one structure:
objects are propositions or types;
morphisms are proofs or terms;
\(\times \) is conjunction and \(\Rightarrow \) is implication;
the unit and counit of currying are \(\lambda \)-abstraction and application.
Contraction lets a hypothesis be used twice, and weakening lets it go unused.
Toposes. A topos adds a subobject classifier \(\Omega \), the object of cuts: subobjects of \(A\) are maps \(A\to \Omega \).
In \(\mathbf {Set}\), \(\Omega =\mathbf 2\) and the cuts are idempotent indicators. A topos is Boolean iff \(\neg \neg =\mathrm {id}\) on \(\Omega \), the involution of
Section 3.
344.3 Linear logic
Removing contraction and weakening. Each hypothesis must then be used exactly once.
The connectives split:
Connective
Meaning
Categorical
\(A\otimes B\)
both, used together
monoidal product
\(A\multimap B\)
consume \(A\), produce \(B\)
internal hom, \(-\otimes A\dashv A\multimap -\)
\(A\mathbin {\& }B\)
either, chosen by the user
product
\(A\oplus B\)
either, chosen by the provider
coproduct
\(A^\perp \)
linear negation
dual object
\(A\parr B\)
\((A^\perp \otimes B^\perp )^\perp \)
De Morgan dual of \(\otimes \)
\(!A\)
reusable \(A\)
comonoid modality
Involutive negation. Linear negation is an involution,
so classical linear logic has
involutive negation without the explosion of resources that contraction would bring. Models are
\(\ast \)-autonomous categories.
The exponential.\(!A\) carries a comonoid, so contraction and weakening hold for it:
\begin{equation} !A\vdash \,!A\otimes !A, \qquad !A\vdash I . \tag{21319}\end{equation}
Intuitionistic logic embeds by Girard’s translation,
\begin{equation} A\Rightarrow B\ \longmapsto \ !A\multimap B , \tag{21320}\end{equation}
which is the cartesian regime recovered by
putting the diagonal back on selected objects.
Compact closure. When \(\otimes =\parr \), every object has a dual \(A^{*}\) with a cup and a cap,
\begin{equation} \eta _A:I\to A^{*}\otimes A, \qquad \varepsilon _A:A\otimes A^{*}\to I, \tag{21321}\end{equation}
which make \(A\otimes -\dashv A^{*}\otimes -\) an adjunction (Section 232).
344.4 The quantum regime
The category.\(\mathbf {FHilb}\), finite-dimensional Hilbert spaces and linear maps, is dagger compact:
the dagger is the adjoint, an involution \(f^{\dagger \dagger }=f\);
\(I=\mathbb C\);
the cup is \(\eta =\sum _i|ii\rangle \);
the cap is \(\varepsilon =\eta ^\dagger \).
States are maps \(I\to A\), effects are maps \(A\to I\), and scalars are maps \(I\to I\).
No natural diagonal. Suppose \(\delta _A:A\to A\otimes A\) were natural. Applied to the states \(\psi ,\phi \) and \(\psi +\phi \), naturality
would give \(\delta (\psi )=\psi \otimes \psi \) for every state, but
when \(\psi ,\phi \neq 0\). So no natural diagonal exists: this is no-cloning. More
generally, a dagger compact category with a natural diagonal is degenerate, its scalars
collapsing.
Discard. On mixed states (below) the trace \(\operatorname {Tr}:\rho \mapsto \operatorname {Tr}\rho \) is natural for trace-preserving maps, \(\operatorname {Tr}\circ \Phi =\operatorname {Tr}\). This
causality condition is no-signalling: discarding is allowed and copying is not. The quantum
regime is affine but not cartesian.
344.5 Classical structures are bases
Definition. A classical structure on \(A\) is a special commutative dagger-Frobenius algebra: a
comonoid \((\delta ,\epsilon )\) with \(\mu =\delta ^\dagger \), satisfying
Proof sketch.\(\mu \) makes \(A\) a commutative algebra. The Frobenius law and \(\mu \circ \delta =1\) make it a
commutative C\(^{*}\)-algebra, hence \(\cong \mathbb C^n\). Its minimal idempotents \(\Pi _i\) are orthogonal, \(\Pi _i\Pi _j=\delta _{ij}\Pi _i\) and \(\sum \Pi _i=1\), and their
images give the basis. \(\square \)
Copyable states. The copyable states of \(\delta \), those with \(\delta \psi =\psi \otimes \psi \), are exactly the basis vectors: the
diagonal of the floor survives, but only on one basis at a time. A basis is a choice of what may
be copied.
Measurement and dephasing. Measurement in the basis is the map from
quantum to classical data given by \(\delta \). Its effect on a density matrix, writing \(\rho \) on the
doubled system, is
copying the basis label into the environment and discarding the
copy.
344.6 Qubits and circuits in the ZX-calculus
Two complementary structures. On \(A=\mathbb C^2\) take the \(Z\) structure for \(\{|0\rangle ,|1\rangle \}\) and the \(X\) structure for \(\{|+\rangle ,|-\rangle \}\). They
are complementary: each basis vector of one is unbiased with respect to the other,
\(|\langle i|\pm \rangle |^2=\tfrac 12\).
Spiders. Composites of \(\delta ,\mu ,\epsilon ,\epsilon ^\dagger \) for one structure, with a phase, depend only on the numbers of
inputs and outputs:
a \(Z\)-copy of the control joined to an \(X\)-merge on the target.
CZ is the same with a Hadamard on the connecting wire. Complementarity gives
the bialgebra law: an \(X\)-merge followed by a \(Z\)-copy equals two \(Z\)-copies, a crossing, and
two \(X\)-merges. On basis states both sides send \(|a,b\rangle \mapsto |a\oplus b,\ a\oplus b\rangle \), which is the copying behaviour of
CNOT.
Fragments.
phases in \(\tfrac \pi 2\mathbb Z\) give the Clifford fragment, efficiently simulable;
phases in \(\tfrac \pi 4\mathbb Z\) give Clifford\(+T\), approximately universal;
arbitrary phases give all linear maps between qubits.
Complete rule sets exist for each fragment and for the full calculus: every true equation between
diagrams is derivable.
344.7 Entanglement and teleportation from the triangle identity
Bell state and effect. The cup \(\eta =|00\rangle +|11\rangle \) is the unnormalised Bell state, and the cap \(\varepsilon =\eta ^\dagger \) is the Bell
effect.
says: prepare a Bell pair, measure the
input together with one half in the Bell basis, and the input reappears on the other
half.
Corrections. The other Bell outcomes are \((\sigma \otimes 1)^\dagger \varepsilon \) for a Pauli \(\sigma \), and sliding \(\sigma \) along the wire leaves
it on the output, where the correction \(\sigma ^{-1}\) removes it. Teleportation is the unit–counit identity of
the adjunction \(A\otimes -\dashv A^{*}\otimes -\).
Map–state duality. Bending wires, \(f\mapsto (1\otimes f)\circ \eta \), is the bijection between maps \(A\to B\) and states of \(A^{*}\otimes B\), the
Choi–Jamiołkowski isomorphism.
344.8 Mixed states and the Born rule
Doubling. Mixed states and channels form the category \(\mathrm {CPM}(\mathbf {FHilb})\), whose morphisms are maps of the
form
a map paired with its conjugate across the involution.
Pure states and the Born rule. A pure state \(\psi \) becomes \(\psi \otimes \bar \psi =|\psi \rangle \langle \psi |\), a projector. The Born
weight of an effect \(\langle e|\) is the doubled scalar
positive because it pairs a scalar with its
conjugate.
344.9 Summary
Cartesian
Linear
Quantum (\(\mathbf {FHilb}\))
identity \(A\vdash A\)
yes
yes
yes
exchange
yes
yes
yes
contraction (copy)
natural
only under \(!\)
per basis
weakening (discard)
natural
only under \(!\)
natural (trace)
negation
\(\neg \neg \neq \mathrm {id}\) (intuitionistic)
\(A^{\perp \perp }=A\)
dagger \(f^{\dagger \dagger }=f\)
duals
—
\(\ast \)-autonomous
compact, \(\otimes =\parr \)
logic
intuitionistic
linear
categorical QM
models
\(\mathbf {Set}\), toposes
coherence spaces
\(\mathbf {FHilb}\), \(\mathrm {CPM}\)
Circuit element
ZX form
From
qubit
\(\mathbb C^2\) with \(Z\) and \(X\) structures
two bases
basis
classical structure
idempotents \(\Pi _i\)
copy of basis states
\(\delta |i\rangle =|ii\rangle \)
diagonal per basis
\(R_Z\), \(R_X\)
\(Z(\alpha )\), \(X(\alpha )\)
phases on spiders
Paulis, \(S\), \(T\)
\(\pi \), \(\tfrac \pi 2\), \(\tfrac \pi 4\)
phases
Hadamard
colour change, \(Z X Z\) Euler
complementarity
CNOT
\(Z\)-copy then \(X\)-merge
bialgebra
CZ
\(Z\)–\(H\)–\(Z\)
colour change
measurement, dephasing
\(\delta \), \(\sum \Pi _i\rho \Pi _i\)
classical structure
Bell pair
cup \(\eta \)
compact closure
teleportation
triangle identity
adjunction
no-cloning
no natural \(\delta \)
linearity
Born rule
doubled scalar
CPM
Figure 285: Z (green) and X (red) spiders with \(n\) inputs, \(m\) outputs and phase \(\alpha \). The Z spider
is \(|0\cdots 0\rangle \langle 0\cdots 0|+e^{i\alpha }|1\cdots 1\rangle \langle 1\cdots 1|\); the X spider is the same in the \(|\pm \rangle \) basis.
Figure 286: Spider fusion: connected spiders of one colour merge into one, and their
phases add, \(Z(\alpha )\circ Z(\beta )=Z(\alpha +\beta )\).
Figure 287: Colour change: a Hadamard (yellow box) on every leg turns a Z spider into
an X spider with the same phase.
Figure 288: Single-qubit gates as one-input, one-output spiders, up to global phase: \(R_Z(\alpha )=Z(\alpha )\), \(R_X(\alpha )=X(\alpha )\),
Paulis at phase \(\pi \), \(S\) and \(T\) at \(\pi /2\) and \(\pi /4\), and the Hadamard box.
Figure 289: Euler decomposition of the Hadamard, \(H\propto Z(\pi /2)\,X(\pi /2)\,Z(\pi /2)\), the same \(R_Z\sqrt {X}R_Z\) pattern used for native
gates in Section 342.
Figure 290: CNOT is a Z-copy on the control joined to an X-merge on the target; CZ
joins two Z spiders through a Hadamard. Both agree with the circuit symbols up to a
nonzero scalar.
Figure 291: Bialgebra law from complementarity: an X-merge followed by a Z-copy equals
two Z-copies, a crossing and two X-merges. Both sides send \(|a,b\rangle \mapsto |a\oplus b,\,a\oplus b\rangle \).
Figure 292: Copying: the Z spider copies the states \(X(0)\propto |0\rangle \) and \(X(\pi )\propto |1\rangle \), its own basis states, and no
others. The diagonal survives on one basis at a time.
Figure 293: Measurement as a classical structure: copying in the Z basis and discarding
the copy, on doubled wires, is the dephasing map \(\rho \mapsto \sum _i\Pi _i\rho \Pi _i\).
Figure 294: Snake identity \((\varepsilon \otimes 1)\circ (1\otimes \eta )=1\): a Bell pair followed by a Bell effect is a plain wire. This is
teleportation, with Pauli corrections sliding along the wire to the output.
344.10 Post’s Theorem and NAND from \(x^2=x\)
Setup. From \(x^2=x\): \(x\in \{0,1\}\), \(x^c:=1-x\), \(x\oplus y:=x+y-2xy\), \(f:\{0,1\}^n\to \{0,1\}\).
Remark 344.1 (Post’s theorem as \(x^2=x\)).Post’s five classes are five ways \(x^2=x\)can be restricted: \(T_0\)fixes \(f(0)=0\)(identity at \(0\)), \(T_1\)fixes \(f(1)=1\)(identity at \(1\)), \(M\)preserves the order \(x(1-y)=0\), \(L\)preserves XOR (\(\oplus \)), \(S\)enforces
self-duality \(f(x)+f(1-x)=1\). Each constraint is \(x^2=x\)with an additional symmetry imposed. A gate set escaping
all five can generate \(x^2=x\)in every form — it reaches \(T=1\), which is \(A=A\). NAND\(=1-xy\)violates all five because
it is the complement of the product: it negates \(0\)-preservation (\(\mathrm {NAND}(0,0)=1\)), \(1\)-preservation (\(\mathrm {NAND}(1,1)=0\)), and
monotonicity, linearity, and self-duality simultaneously. This is the algebraic expression
of \(\neg (A\wedge A)=\neg A=1-A\): NAND is \(A=A\)negated, which is why it generates \(A=A\)in all its forms.
344.11 NAND from \(\Pi _O+\Pi _U=I\)
Thesis. NAND\((x,y)=1-xy\) is not a primitive gate. It is the partition complement \(\Pi _U^{(xy)}=I-\Pi _O^{(x)}\Pi _O^{(y)}\), forced by
\(\Pi _O+\Pi _U=I\).
Remark 344.2 (NAND as partition complement).NAND is not a primitive logical
operation chosen by convention. It is the partition complement: the U-sector of the joint
O-projection \(\Pi _O^{(x)}\Pi _O^{(y)}\). \(\Pi _O+\Pi _U=I\)forces the complement \(I-\Pi _O^{(x)}\Pi _O^{(y)}\)to exist for every product of projectors, and this
complement is exactly \(\mathrm {NAND}(x,y)=1-xy\).
The De Morgan law \(\neg (x\wedge y)=\neg x\vee \neg y\)is the partition identity \(I-\Pi _O^{(x)}\Pi _O^{(y)}=(I-\Pi _O^{(x)})+(I-\Pi _O^{(y)}) -(I-\Pi _O^{(x)})(I-\Pi _O^{(y)})\), which is inclusion-exclusion on the
U-sectors.
Since NAND violates all five Post classes (Section 344.10), and NAND is forced by \(\Pi _O+\Pi _U=I\),
the functional completeness of NAND is the completeness of the partition: \(\Pi _O+\Pi _U=I\)generates all
Boolean functions, which is \(T=1\), which is \(A=A\).
Remark 344.3 (De Morgan as partition complement).The De Morgan laws are the projector
expressions of \(\Pi _O+\Pi _U=I\):
De Morgan 1: the complement of a product is a sum of complements. In partition
language: the U-sector of \(\Pi _A\Pi _B\)equals the union of the U-sectors of \(\Pi _A\)and \(\Pi _B\),
De Morgan 2: the complement of a sum is a product of complements. In partition
language: the U-sector of \(\Pi _A+\Pi _B-\Pi _A\Pi _B\)is the product of the U-sectors,
Both identities follow from a single algebraic fact: \((I-\Pi _A)(I-\Pi _B)=I-\Pi _A-\Pi _B+\Pi _A\Pi _B\), which is the expansion of the product of two
complements, forced by \(\Pi _O+\Pi _U=I\). De Morgan is \(\Pi _O+\Pi _U=I\)applied twice, which is \(A+\neg A=1\).