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

Weakest Preconditions

Weakest Preconditions

Adjoint quantum operations transform postconditions backward, with distinct weakest and weakest liberal preconditions for total and partial correctness.

A weakest-precondition transformer computes an input predicate from a desired output predicate. Let E=⟦C⟧\mathcal E=\llbracket C\rrbracket be a completely positive, trace-nonincreasing map between finite-dimensional state spaces, and let QQ be an output effect. The trace adjoint E∗\mathcal E^* is characterized by

tr(E∗(Q)ρ)=tr(QE(ρ)).\mathrm{tr}(\mathcal E^*(Q)\rho) =\mathrm{tr}(Q\mathcal E(\rho)).

This relation turns the forward state transformation of denotational semantics into backward reasoning about observations.

Total and partial correctness

For total correctness, the weakest precondition is

wpC(Q)=E∗(Q).\mathrm{wp}_C(Q)=\mathcal E^*(Q).

For partial correctness, where missing output trace represents nontermination, the weakest liberal precondition is

wlpC(Q)=E∗(Q)+I−E∗(I).\mathrm{wlp}_C(Q)=\mathcal E^*(Q)+I-\mathcal E^*(I).

The identities inside and outside E∗\mathcal E^* act on the output and input spaces respectively. Trace nonincrease ensures E∗(I)⪯I\mathcal E^*(I)\preceq I, so both transformers return effects. If the map preserves trace, E∗(I)=I\mathcal E^*(I)=I and the two transformers agree.

Under the quantitative convention used in quantum Hoare logic, a valid total triple satisfies P⪯wpC(Q)P\preceq\mathrm{wp}_C(Q); a valid partial triple satisfies P⪯wlpC(Q)P\preceq\mathrm{wlp}_C(Q). Here A⪯BA\preceq B means B−AB-A is positive semidefinite. Consequently, the conventionally named weakest precondition is the greatest admissible precondition effect in this operator order; the term should not be interpreted through an unstated Boolean implication order.

Examples: gates, measurement, and sequencing

For a unitary UU, wpU(Q)=U†QU\mathrm{wp}_U(Q)=U^\dagger QU. With U=XU=X and Q=∣1⟩⟨1∣Q=\lvert1\rangle\langle1\rvert, the result is ∣0⟩⟨0∣\lvert0\rangle\langle0\rvert.

If a measurement discards its outcome, its transformer is

wpmeas(Q)=∑mMm†QMm.\mathrm{wp}_{\mathrm{meas}}(Q)=\sum_m M_m^\dagger QM_m.

Computational-basis measurement therefore transforms the postcondition Q=∣+⟩⟨+∣Q=\lvert+\rangle\langle+\rvert into I/2I/2: after dephasing, the probability of a subsequent ++ outcome is one half for every normalized input.

For C1; C2, backward calculation reverses execution order:

wpC1;C2(Q)=wpC1(wpC2(Q)).\mathrm{wp}_{C_1;C_2}(Q) =\mathrm{wp}_{C_1}(\mathrm{wp}_{C_2}(Q)).

A never-terminating program has wp(Q)=0\mathrm{wp}(Q)=0 but wlp(Q)=I\mathrm{wlp}(Q)=I, demonstrating the role of liberal correctness.

Limitations

Retained measurement results and classical control require outcome-dependent predicates or an explicit classical-quantum state space. Loops generally need fixed-point reasoning; a closed expression need not be available. Numerical matrix comparisons require justified error bounds, especially near zero eigenvalues. This introductory calculation method does not automatically generate invariants or provide a machine-checked proof.

References

  • Ellie D'Hondt and Prakash Panangaden. Quantum Weakest Preconditions. Mathematical Structures in Computer Science (2006). arXiv:quant-ph/0501157.
  • Mingsheng Ying. Floyd-Hoare logic for quantum programs. ACM Transactions on Programming Languages and Systems 33(6), 1-49 (2011). DOI: 10.1145/2049706.2049708.
An introductory guide. Consult the original references for technical details and formal citations.
READ NEXTVerification Methods and Tools→

Search the collection