ψQuantum PL WIKITHE LANGUAGE OF QUANTUM COMPUTATION中文
VOLUME II · Languages & types

Quantum Programming Languages

Quantum Programming Languages

Quantum languages combine quantum operations with classical computation, explicit resource management, and well-defined measurement behavior.

A quantum programming language combines quantum operations with classical computation. Typical constructs include qubit allocation, gates, measurement, conditional branches, and sometimes loops or recursion. A compiler may generate quantum circuits, while a runtime coordinates classical feedback and device execution. Language designs include embedded domain-specific languages, circuit generators, and independent programming languages.

A program's syntax must be accompanied by rules explaining resource ownership and observable behavior. These rules determine whether a qubit remains available after measurement, how classical results are stored, and which operations a target can execute.

Example: measurement with feedback

The following introductory pseudocode assumes that computational-basis measurement retains the measured qubit:

q := new_qubit(0)
H(q)
b := measure_z(q)
if b == 1 then X(q)
return q

After the Hadamard, qq is in ∣+⟩\lvert+\rangle. Measurement returns each bit with probability 1/21/2 and leaves qq in ∣b⟩\lvert b\rangle. The conditional XX sends the outcome-one branch to ∣0⟩\lvert0\rangle, so the returned qubit is always in ∣0⟩\lvert0\rangle under ideal semantics.

Writing Pb=∣b⟩⟨b∣P_b=\lvert b\rangle\langle b\rvert, the measurement-and-correction suffix has the channel

R(ρ)=P0ρP0+XP1ρP1X†=tr(ρ)∣0⟩⟨0∣.\mathcal R(\rho)=P_0\rho P_0+XP_1\rho P_1X^\dagger =\mathrm{tr}(\rho)\lvert0\rangle\langle0\rvert.

This reset operation is not unitary. If the program also returns b, its full semantics must include that classical output. A language with destructive measurement would require a different program or interface.

Types and semantics

A qubit handle identifies a resource; it does not reveal its amplitudes. Classical measurement results can usually be copied. Linear type systems offer one way to express this distinction, although language implementations use different ownership disciplines.

Denotational semantics can interpret commands as completely positive maps. Retained measurement outcomes require a classical-quantum state, and potentially nonterminating programs require explicit treatment of termination probability. Clear semantics makes source transformations and specifications mathematically meaningful.

Implementations and limitations

Quipper demonstrates a functional, embedded approach to scalable circuit description. Microsoft's Q# documentation describes a language with qubit management, measurements, and classical computation. These examples illustrate different design choices; they do not establish that every target supports every language feature.

Mid-circuit measurement, feedback latency, dynamic allocation, and available gates depend on the backend. Compilation success, simulation, and hardware execution are distinct from a proof of correctness. This demonstration states ideal behavior and does not claim certification of a compiler, device, or algorithm.

References

  • Alexander S. Green, Peter LeFanu Lumsdaine, Neil J. Ross, Peter Selinger, and Benoît Valiron. Quipper: A Scalable Quantum Programming Language (2013). arXiv:1304.3390.
  • Microsoft. Introduction to the quantum programming language Q#. Microsoft Learn.
An introductory guide. Consult the original references for technical details and formal citations.
READ NEXTDenotational Semantics→

Search the collection