ψQuantum PL WIKITHE LANGUAGE OF QUANTUM COMPUTATION中文
VOLUME III · Program semantics

Denotational Semantics

Denotational Semantics

Terminating-path sums, quantum operations, and least fixed points give meanings to quantum while programs, local variables, and classical recursion.

Denotational semantics assigns a mathematical map ⟦S⟧\llbracket S\rrbracket to a program SS. In Chapter 5's quantum while model, this map collects partial density operators from terminating executions, recording both output state and termination probability. Quantum Programming Languages introduces syntax and small-step execution; this entry connects them to compositional meanings.

Prerequisites and state spaces

The prerequisites are density operators and quantum operations, tensor products, trace, and function composition. Partial density operators satisfy ρ⪰0\rho\succeq0 and tr⁡(ρ)≤1\operatorname{tr}(\rho)\leq1. Quantum operations are completely positive, trace-nonincreasing linear maps (CPTNI). Complete positivity preserves positivity under identity extension to arbitrary ancillary registers.

Examples below primarily use finite-dimensional registers. The textbook also permits the countable-dimensional integer type; that case requires trace-class states, appropriate operator convergence, and the domain-theoretic results in Section 5.3.2. Finite matrix algorithms do not by themselves establish those infinite-dimensional results.

From execution paths to denotations

Definition 5.6 (p. 72) sums outputs over all finite terminating executions:

⟦S⟧(ρ)=∑π: ⟨S,ρ⟩→∗⟨↓,ρπ⟩ρπ.\llbracket S\rrbracket(\rho) =\sum_{\pi:\,\langle S,\rho\rangle\to^*\langle\downarrow,\rho_\pi\rangle}\rho_\pi.

The sum counts execution paths with multiplicity: two paths producing the same output operator both contribute. It is neither a sum over deduplicated terminal states nor a sum of normalized branches. Infinite executions contribute no terminal output; their probability appears as missing output trace. This construction directly connects operational and denotational semantics without assuming termination.

For example, a feedback program whose measurement branches execute skip and X can yield two copies of 12∣0⟩⟨0∣\tfrac12|0\rangle\langle0|. Summing gives ∣0⟩⟨0∣|0\rangle\langle0|; deduplicating would incorrectly halve the termination probability.

Basic constructs and composition

Lemma 5.1 establishes linearity on mixtures of partial density operators. Proposition 5.1 (p. 73) gives the structural equations:

⟦skip⟧(ρ)=ρ,⟦q:=∣0⟩⟧(ρ)=∑j∣0⟩q⟨j∣ρ∣j⟩q⟨0∣,⟦U[qˉ]⟧(ρ)=UρU†,⟦S1;S2⟧=⟦S2⟧∘⟦S1⟧,⟦if M[qˉ]=m→Sm fi⟧(ρ)=∑m⟦Sm⟧(MmρMm†).\begin{aligned} \llbracket\mathrm{skip}\rrbracket(\rho)&=\rho,\\ \llbracket q:=|0\rangle\rrbracket(\rho)&=\sum_j |0\rangle_q\langle j|\rho|j\rangle_q\langle0|,\\ \llbracket U[\bar q]\rrbracket(\rho)&=U\rho U^\dagger,\\ \llbracket S_1;S_2\rrbracket&=\llbracket S_2\rrbracket\circ\llbracket S_1\rrbracket,\\ \llbracket\mathrm{if}\ M[\bar q]=m\to S_m\ \mathrm{fi}\rrbracket(\rho) &=\sum_m\llbracket S_m\rrbracket(M_m\rho M_m^\dagger). \end{aligned}

The reset sum ranges over the variable's computational basis; local operators are identity-extended. Composition order matters: first S1S_1, then S2S_2. Measurement branches combine as density operators, not amplitudes. The core language uses an outcome to select a branch but does not additionally output a result register. Specifications retaining the outcome need a classical-quantum extension, such as ∑m∣m⟩⟨m∣⊗MmρMm†\sum_m|m\rangle\langle m|\otimes M_m\rho M_m^\dagger.

For H; measure_z on ∣0⟩|0\rangle, forgetting the outcome gives I/2I/2. Reversing the commands gives ∣+⟩⟨+∣|+\rangle\langle+|. Both states produce uniform computational-basis outcomes, but their quantum states and denotations differ.

Quantum domains and the loop least fixed point

The Löwner order A⪯BA\preceq B means that B−AB-A is positive semidefinite. Partial density operators have a least element 0 and suprema of increasing chains; continuous maps preserve those suprema. Section 5.3.2 also orders quantum operations pointwise: E⪯F\mathcal E\preceq\mathcal F when E(ρ)⪯F(ρ)\mathcal E(\rho)\preceq\mathcal F(\rho) for every input. Lemmas 5.2–5.4 supply the complete partial orders (CPOs) and continuity needed for loops.

Write W=while M[qˉ]=1 do S odW=\texttt{while }M[\bar q]=1\texttt{ do }S\texttt{ od}, Ei(ρ)=MiρMi†\mathcal E_i(\rho)=M_i\rho M_i^\dagger, and B=⟦S⟧\mathcal B=\llbracket S\rrbracket. Definition 5.12 starts finite approximation with abort, the zero map representing no terminating output, not normal exit. The next approximation branches to skip on outcome 0 and S; W^(k) on outcome 1.

⟦W(k)⟧=∑n=0k−1E0∘(B∘E1)n,⟦W⟧=sup⁡k⟦W(k)⟧.\llbracket W^{(k)}\rrbracket =\sum_{n=0}^{k-1}\mathcal E_0\circ(\mathcal B\circ\mathcal E_1)^n, \qquad \llbracket W\rrbracket=\sup_k\llbracket W^{(k)}\rrbracket.

The empty sum is the zero map. Each term describes exiting after nn continuing iterations. Proposition 5.2 and Corollary 5.1 (p. 76) yield

⟦W⟧=∑n=0∞E0∘(B∘E1)n=μF,F(X)=E0+X∘B∘E1.\llbracket W\rrbracket =\sum_{n=0}^{\infty}\mathcal E_0\circ(\mathcal B\circ\mathcal E_1)^n =\mu F,\qquad F(X)=\mathcal E_0+X\circ\mathcal B\circ\mathcal E_1.

Here μF\mu F is the least fixed point obtained by iteration from the zero map. An arbitrary solution of X=F(X)X=F(X) does not determine the intended meaning; the least solution is essential.

Termination, variable access, and local blocks

Proposition 5.4 gives tr⁡(⟦S⟧(ρ))≤tr⁡(ρ)\operatorname{tr}(\llbracket S\rrbracket(\rho))\leq\operatorname{tr}(\rho). For normalized input, output trace is termination probability and 1−tr⁡(⟦S⟧(ρ))1-\operatorname{tr}(\llbracket S\rrbracket(\rho)) is divergence probability. Resetting or forgetting measurement outcomes need not lose trace: they can discard information while preserving probability mass. Postselection can also lose trace, but should not be equated with nontermination without specifying the model.

Let V=var⁡(S)V=\operatorname{var}(S). Local meanings extend by identity on external systems. Proposition 5.3 (p. 77) distinguishes two properties:

  • When trace is preserved on the input, the untouched subsystem's reduced state is unchanged: tr⁡V(⟦S⟧(ρ))=tr⁡V(ρ)\operatorname{tr}_{V}(\llbracket S\rrbracket(\rho))=\operatorname{tr}_{V}(\rho).
  • Inputs with the same reduced state on VV produce outputs with the same reduced state on VV.

The first statement has a trace-preservation premise. With entangled inputs, retaining a selected local measurement branch can change the external system's conditional state. Identity extension alone does not justify invariance of every external reduced state under arbitrary CPTNI maps.

Definition 5.13 (p. 80) introduces begin local qbar : S end, which discards local ancillary registers after execution:

⟦begin local qˉ:S end⟧(ρ)=tr⁡qˉ(⟦S⟧(ρ)).\llbracket\mathrm{begin\ local}\ \bar q:S\ \mathrm{end}\rrbracket(\rho) =\operatorname{tr}_{\bar q}(\llbracket S\rrbracket(\rho)).

The body SS performs any required initialization; this partial-trace formula does not implicitly initialize or allocate the variables. Proposition 5.5 identifies program denotations as quantum operations. Conversely, Proposition 5.6 represents quantum operations using ancillas, initialization, unitaries, measurement, and an abort branch when needed. This expressiveness result allows the requisite unitaries; restricting programs to a finite elementary gate set generally gives approximation instead.

Denotations of classical recursion

Section 5.5 uses the same terminating-path sum for declarations D={Xi⇐Si}D=\{X_i\Leftarrow S_i\}. Finite unfoldings start with abort and simultaneously replace procedure calls with the previous approximations. Proposition 5.8 expresses the full recursive denotation as their supremum.

A declaration induces a continuous functional FDF_D on tuples of quantum operations. Its least fixed point (E1∗,…,En∗)=μFD(\mathcal E_1^*,\ldots,\mathcal E_n^*)=\mu F_D supplies the procedure meanings. Theorem 5.2 (p. 88) identifies the main statement's denotation with its interpretation using these maps for calls. This is recursion with classical control, not coherent quantum-controlled recursion.

Connections to proofs and tools

Weakest Preconditions uses the adjoint of the denotation to propagate assertions backward. Quantum Hoare Logic states partial and total correctness through trace inequalities. Grover's loop representation illustrates algorithm syntax; its Hoare proof additionally establishes success and termination properties.

This entry explains the textbook mathematical model. Compiler implementations, numerical approximations, and hardware noise need separate justification. A compositional semantics does not itself certify an implementation. Domain-theoretic proofs, full algorithm derivations, and exercises remain in the source chapter.

References

  • Mingsheng Ying. Foundations of Quantum Programming, second edition (2024), Chapter 5, Sections 5.3–5.5: Definitions 5.6, 5.12–5.13 and 5.19–5.21, Propositions 5.1–5.9, and Theorem 5.2.
  • Peter Selinger. Towards a Quantum Programming Language (2004). DOI.
  • Samson Abramsky and Bob Coecke. A Categorical Semantics of Quantum Protocols (2004). arXiv:quant-ph/0402130.
An introductory guide. Consult the original references for technical details and formal citations.
READ NEXTQuantum While Programs: Syntax and Execution→

Search the collection