Weakest Preconditions
Weakest Preconditions
Trace adjoints, Löwner order, and fixed points transform quantum postconditions backward into wp and wlp.
A weakest precondition (wp) transformer moves a quantum postcondition effect backward through a program. Let be a completely positive trace-nonincreasing map and let be an output effect. Its trace adjoint is characterized by
This is the Schrödinger forward transformation and Heisenberg backward transformation of Denotational Semantics. Quantum Hoare Logic uses the same duality to express triples.
§6.1 Predicates, Löwner order, and semantic wp
A quantum predicate is a Hermitian effect . The Löwner order means that is positive semidefinite, equivalently
The order therefore compares satisfaction degrees on all states. The effect set is a CPO under this order but generally not a lattice; quantum predicates do not always have a usable conjunction or disjunction. As in the measurement rules on Quantum Hoare Rules, a joint specification must use a tensor product, a Kraus-weighted sum, or another explicit quantum combination.
For a quantum operation , write when
is the greatest admissible input effect: it is itself a precondition, and every other precondition satisfies . The word “weakest” follows the textbook's order convention; this greatest effect should not be read as an unstated Boolean implication.
If , then
For a unitary , . If a measurement with Kraus operators discards its outcome,
When an outcome only selects a later branch and is not an explicit output, outcome-indexed branch predicates can handle it without adding a classical register. If the outcome is explicitly retained as program state or output, the postcondition space must include a classical register; the discarded-outcome formula cannot be applied unchanged to a branching program.
Schrödinger–Heisenberg duality
The forward state and backward predicate transformers are
with
Executing the program and then observing therefore has the same satisfaction degree as observing before execution. In a Kraus representation, is completely positive; trace preservation gives , while trace nonincrease gives .
Proposition 6.4 of the textbook also gives
whenever the results remain quantum operations. With the Chapter 5 composition convention, executes first and then , so reverse composition is
The transformer also preserves suprema of increasing operation sequences in the CPO. These properties support structural program rules and loop fixed points.
A commutativity warning
Commuting do not generally imply that and commute. Unitary conjugation preserves commutativity. A discarded projective measurement requires each compressed pair and to commute; for a complete basis measurement, all weakest preconditions commute. General Kraus maps need extra assumptions, such as mutual commutativity of and commutation of each with all Kraus operators. See §6.1.2 of Quantum Hoare Logic for the more detailed sufficient conditions; wp is not an ordinary function that automatically preserves every algebraic relation between predicates.
§6.2 Total and partial correctness: wp and wlp
wp corresponds to total correctness:
Thus
The weakest liberal precondition (wlp) corresponds to partial correctness:
Since , wlp is still an effect, and
For every partial density operator ,
The final two terms together compensate for nontermination. If the program is trace-preserving, wp and wlp agree. A never-terminating program has but . Total correctness for an arbitrary precondition imposes only the corresponding weighted obligation: is what forces global termination on normalized inputs, while makes the triple trivial.
§6.3 Structural program equations
For syntax, wp (and wlp with each subprogram wp replaced by wlp) satisfies
Sequencing reverses execution order: calculate the transformer for first, then for . For Boolean initialization,
for an integer register, sum over all basis values. This preserves the full operator action on entangled and untouched registers.
Loop least and greatest fixed points
Let the loop be while M[q] = 1 do S od, with and postcondition effect . Define
Then
while
which can be approached downward from . The least fixed point collects the terminating contribution justified by finite unfoldings; the greatest fixed point also credits permitted nontermination. For every ,
These least/greatest fixed-point statements are Proposition 6.14 (printed pp. 113–114). They do not say that every loop's termination mass is automatically zero. Total correctness also needs the ranking-function obligation in §qTD of Quantum Hoare Rules or another proved termination argument.
A gate and measurement example
For the Pauli gate,
The satisfaction of “input is ” therefore equals the satisfaction of “output is ” after . If a computational-basis measurement discards its outcome, the wp of is : after dephasing, every normalized input has probability of a subsequent outcome. These are semantic calculations, not machine-checked proofs of a hardware or compiler implementation.
Relation to proof systems and scope
wp and wlp are backward proof obligations: prove for a total triple and for a partial triple. qPD and qTD use the same transformers for case, sequencing, and loop rules, providing partial and total correctness respectively; qTD additionally requires an -ranking function on the measured continuing branch. Soundness means that derivability implies semantic validity. Relative completeness depends on the assertion language, complex-field Löwner-order facts, and the ability to express the required fixed points and ranking functions; it does not mean that proofs are generated automatically.
An outcome used only to select a control branch can be handled by outcome-dependent predicates; explicitly storing or outputting the outcome requires an extended classical–quantum state space. Postselection must specify the meaning of its trace loss, and infinite-dimensional spaces require additional convergence and domain conditions. Numerical matrix comparisons need justified error bounds, especially near zero eigenvalues.
References and page index
This entry was checked against Chapter 6 of Foundations of Quantum Programming: Definitions 6.2–6.4 and Propositions 6.1–6.4 are PDF pp. 5–9 / printed pp. 95–99; commutativity Propositions 6.5–6.10 are PDF pp. 10–12 / printed pp. 100–102; correctness Definitions 6.7–6.8 are PDF pp. 13–14 / printed pp. 103–104; program Definition 6.9 and Propositions 6.12–6.14 are PDF pp. 18–24 / printed pp. 108–114. Full qPD/qTD rules, soundness and relative completeness, Grover, and auxiliary rules are summarized in Quantum Hoare Logic and Quantum Hoare Rules; long proofs and all exercises are not reproduced.
- Ellie D'Hondt and Prakash Panangaden, Quantum Weakest Preconditions, arXiv:quant-ph/0501157.
- Mingsheng Ying, Foundations of Quantum Programming, Chapter 6, 2024, DOI.
- Roman Gielerak and Marek Sawerwain, Generalised quantum weakest preconditions, arXiv:0710.5239.