July 14, 2026
Quantum weakest preconditions are a fundamental tool for program verification of quantum programs. Many variations have been reported in the literature. We revisit quantum weakest preconditions from the perspective of expected runtime analysis of quantum programs and introduce a novel pre-expectation framework that enables to reason about the preconditions of quantum programs without the need of an upper bound. This is particularly interesting for quantum programs involving reward statements. The overall goal is to analyze runtime behavior even in the case of programs with potentially infinite expected runtime. This paper presents several ways to do so, e.g., a program transformation such that the expected runtime of a quantum program can be expressed using the weakest pre-expectation calculus with rewards.
Quantum programming is an emerging field that combines the principles of quantum mechanics with computer science to develop algorithms and software for quantum computers. As quantum computing continues to advance, there is a growing need for rigorous methods to analyze and verify quantum programs. Besides of correctness, runtime analysis is an important factor in quantum algorithms, as many of them are designed to solve problems more efficiently than classical algorithms. One fundamental principle in this area is deductive verification, in particular the concept of weakest preconditions, which allows to reason about the behavior of quantum programs and their expected outcomes. The notion of (quantitative) weakest preconditions in the quantum setting was first introduced by D’Hondt and Panangaden in [1] and since then there have been many variations and extensions, but all of them require the weakest preconditions to be bounded. In this paper, we challenge this requirement and introduce a novel framework for reasoning about quantum weakest preconditions without the need for an upper bound. Our approach is motivated by the analysis of expected runtimes of quantum programs as in [2] but we do not want to restrict ourselves to (1) finite dimensional Hilbert spaces and (2) almost surely terminating (AST) programs. By allowing infinite-dimensions and unbounded operators, we can analyze a wider range of quantum programs and provide insights into their expected runtimes. An interesting phenomenon that arises in the infinite-dimensional context only is that there can be programs which are almost surely terminating but that still have an infinite expected runtime (an example can be found in Section 8 and the equivalence for finite-dimensions in [2]). The expected runtime of a (non-AST) program cannot be expressed naively using weakest preconditions and a counter-variable as this small example illustrates: \(q:= \ket{0}; \boldsymbol{while } \boldsymbol{I}[q] \boldsymbol{ do }\{ \boldsymbol{skip}\}\). This program has an expected runtime of \(\infty\) but the weakest precondition of the loop is \(\boldsymbol{0}\) (as it never terminates) and thus of the whole program as well. This shows the need for a more general framework to analyze expected runtimes of quantum programs that are not almost surely terminating.
A more interesting example is the following variation of the quantum walk which cannot be analyzed using existing work like [2], [3]. We have a quantum integer variable \(q\) which tracks the current position and a qubit \(c\) which is used to control the speed of the walk. \[\begin{align} & c:= \ket{0}; \\ & \boldsymbol{while } M[q] \boldsymbol{ do }\{ \\ &c := H c; \\ &q c := S q c; \\ & \} \end{align}\] with \(M_0 = \ket{0}\bra{0}\), \(M_1 = \boldsymbol{I}- \ket{0}\bra{0}\) and the (controlled) shift operator \(S\ket{n}\ket{0} = \ket{n-1}\ket{0}, S\ket{n}\ket{1} =\ket{n}\ket{1}\). In comparison to the quantum walk, the shift operator \(S\) does not shift in both directions but instead either shifts to the left (decrease the value of \(q\)) or stays in the same position depending on the value of \(c\). The program terminates as soon as \(q\) reaches \(\ket{0}\). For states \(\ket{n}\) with \(n\geq 0\) this program is almost surely terminating, as it will eventually reach the state \(\ket{0}\) with probability 1. In Section 8 we will see that the expected runtime for \(\ket{n}\) is finite for all \(n\geq 0\). In contrast to the probabilistic setting, where this implies that the expected runtime is finite for all possible states, we have to be more careful here: for superpositions the expected runtime can still be infinite. This shows that we cannot carry over all methods and results from the probabilistic setting to the quantum setting and that we need to generalize the framework to analyze expected runtimes of quantum programs like this.
As we want to provide a comprehensive and expressive framework for analyzing the expected runtime of quantum programs, we do this in terms of weakest pre-expectations using reward statements. This allows not only to express expected runtimes but also to reason about expected values of other observables.
Our main contributions can be summarized as follows:
We define semantic properties for quantum programs with rewards in infinite-dimensional spaces and give a concrete syntax and denotational semantics for qrWhile programs with rewards.
We define weakest pre-expectations both semantically and syntactically for qrWhile programs. We drop the boundedness condition of predicates which was required in previous work and thus, our expectations are strictly more expressive.
As we consider unbounded expectations, we can analyze expected runtimes without restricting to almost surely terminating programs. We show different ways to compute the expected runtime using syntactical transformations and weakest pre-expectations, giving a concrete forward and backward reasoning approach and show that all of them coincide.
We give some simple rules to bound both the weakest preconditions and the expected runtimes of loops that apply in the bounded case as well.
We consider example programs and analyze their expected runtime and termination probability using the tools we developed which would not have been possible using existing work.
We allow infinite-dimensional Hilbert spaces to enable the analysis of a wider range of quantum programs, e.g., we also allow quantum integers and not only qubits. As mentioned before, this is particularly interesting for expected runtime analysis, as there are programs which are almost surely terminating but have an infinite expected runtime.
Extending the previous work to unbounded operators is not straightforward and requires several technical challenges to be overcome. One of the most important differences between bounded and unbounded operators is that the latter may not be defined on the entire Hilbert space, i.e., one has to deal with states outside of the domain. Properties like Hermitian or self-adjoint are equivalent for bounded operators and are used as observables / predicates. However, in the unbounded case, these properties do not coincide and one has to carefully choose the right operator class to ensure desired properties like convergence and expected values. The biggest technical challenge is to find a set of operators that is expressive enough, in the best case includes all bounded predicates and is \(\omega\)-complete together with a natural order. The last property is needed to express the weakest pre-expectation of a while-loop. This set of operators should be closed under the weakest pre-expectation of all program statements, which is not trivial to show, as one needs, e.g., a special kind of addition to ensure that self-adjointness is preserved. Additionally, those operators should induce a natural expected value which satisfies our requirements, i.e., its value should be in \(\mathbb{R}_{\geq 0}^\infty\).
Weakest preconditions for classical programs were first developed by Dijkstra [4], [5], then extended to probabilistic programs by [6], [7] and later to quantum programs by [1]. As mentioned above, D’Hondt and Panangaden [1] considered quantitative predicates bounded by \(\boldsymbol{I}\). Ying [8] extended this approach to capture partial correctness and gave an explicit representation of the predicate transformer for the quantum qWhile language. Alternatively, a qualitative approach that allows simpler reasoning is given by [9]. Several extensions of weakest preconditions like adding classical variables [10], [11], non-determinism [12] or conditional statements [13] have been considered.
Expected runtime analysis using weakest precondition style was developed first in the probabilistic setting [14], [15] and later extended to quantum programs [2], [3]. Liu et al. [2] defined a real-valued function \(ERT\) that determines the expected runtime of a program on input state \(\rho\). They also gave a weakest precondition style calculus \(ert\) to compute \(ERT(\rho)\) and showed that it coincides with the definition of \(ERT\). Their approach is limited to finite-dimensional Hilbert spaces and \(ert\) is only defined for almost surely terminating programs. In contrast, our approach allows us to analyze expected runtimes in infinite-dimensional Hilbert spaces and for non-terminating programs, which can give rise to infinite expected runtimes. This was already mentioned in [2] as an interesting topic for future research: "the infinite-dimensional case is certainly an interesting (and challenging, we believe) topic for future research". Similarly, Olmedo and Díaz-Caro [3] define expected runtimes for quantum programs but consider only finite-dimensional Hilbert spaces. They do not define weakest preconditions in an observable way but rather use a more probabilistic approach where observables are functions from states to real numbers.
Another different way of reasoning about expected runtimes and more general expected values is given in [16]. They define a quantum expectation transformer \(qet\) for classical-quantum programs that does not depend on the denotational semantics. Their expectations do not operate on density operators but instead on the cost structure. However, their approach is also limited to qubits, i.e., to finite-dimensional Hilbert spaces.
Barthe et al. [17], [18] define a relational Hoare logic for quantum programs. They also allow for infinite-valued predicates but only on finite-dimensional Hilbert spaces. Their approach is restricted to AST programs. They mention that the approach can be extended to the infinite-dimensional case but further details are not provided. At the same time as we finished this paper, [19] was published which captures the infinite-dimensional case. However, they still restrict to AST programs ("The restriction to AST programs applies to all logics in the paper") and they consider neither expected runtimes nor reward statements. The weakest precondition calculus is only stated for the bounded case and they decided to not use unbounded operators as predicates but instead relations on the state spaces.
The rest of the paper is structured as follows. In Section 2, we give some preliminaries on quantum computing and the mathematical background. Section 3 introduces the notion of expectations, the expected value and their properties. In Section 4, we define the syntax and semantics of quantum programs with rewards. In Section 5, we define the weakest pre-expectation semantics for quantum programs with rewards and give a syntactic weakest precondition calculus for our concrete qrWhile language. In Section 6, we show how to analyze expected runtimes of quantum programs by transforming the program syntactically and using our weakest pre-expectation framework. Section 7 continues with runtime analysis, here we give concrete ERT transformers. In Section 8, we give two example programs and analyze their expected runtimes and termination probabilities using the tools we developed. Finally, in Section 9, we summarize our contributions and discuss future work.
This section introduces the mathematical background and notation used in the paper. We advise the reader to skip this section on the first read and refer back to it when necessary.
We use \(\mathbb{R}\) for the real numbers and \(\mathbb{R}_{\geq 0}^\infty\) for the set of non-negative extended real numbers, i.e., including infinity. \(\mathbb{C}\) denotes the set of complex numbers and we write \(\overline{x+yi}=x-yi\) for the complex conjugate of \(x+yi \in \mathbb{C}\). The infinite sum \(\sum_{i \in I} u_i\) in a topological additive semigroup \(V\) is \(u \in V\) iff for every open neighborhood \(U\) of \(V\) there exists a finite \(J \subseteq I\) such that \(\sum_{i \in K} u_i \in U\) for every finite \(K \subseteq I\) with \(J \subseteq K\) [20]. Then we call \(I\) summable. (This includes \(\mathbb{R}, \mathbb{R}_{\geq 0}^\infty\), and all vector spaces we consider in this work.)
The inner product over a vector space \(\mathcal{V}\) is denoted by \(\langle \cdot \mid \cdot \rangle\) and the norm (or length) of a vector \(u \in \mathcal{V}\) is defined by \(\Vert u \Vert:= \sqrt{\langle u \mid u \rangle}\). When \(\Vert u \Vert = 1\) holds, \(u\) is a unit vector. Vectors \(u,v \in \mathcal{V}\) are orthogonal (denoted \(u \bot v\)) if \(\langle u \mid v \rangle = 0\).
If for any \(\epsilon>0\), there exists a positive integer \(N\) such that \(\Vert u_n - u_m \Vert < \epsilon\) for all \(n,m\geq N\) then the sequence \(\{u_i\}_{i \in \mathbb{N}} \subseteq \mathcal{V}\) is a Cauchy sequence. The limit \(\lim_{i \to \infty} u_i\) of such a sequence is \(u\) if for any \(\epsilon >0\), there exists a positive integer \(N\) such that \(\Vert u_n - u \Vert < \epsilon\) for all \(n \geq N\).
A complete inner product space \(\mathcal{H}\) is a Hilbert space, i.e., a vector space with inner product where every Cauchy sequence of vectors in \(\mathcal{H}\) has a limit [8].
An orthonormal basis of a Hilbert space \(\mathcal{H}\) is a (possibly infinite) family \(\{u_i\}_{i \in I}\) of pairwise orthogonal unit vectors such that every \(v\in \mathcal{H}\) can be written as \(v = \sum_{i \in I} \langle u_i \mid v\rangle \cdot u_i\). By \(\abs{I}\) (the cardinality of \(I\)) we denote the dimension of \(\mathcal{H}\). We consider only separable Hilbert spaces, i.e., those with a countable (but potentially infinite) orthonormal basis. Hilbert spaces and their elements can be combined using the tensor product \(\otimes\) [21].
Example 1. For a set \(X\), the space \[\begin{align} l^2(X) = \{\sum_{n\in X} \alpha_n \ket{n}\mid \alpha_n \in \mathbb{C} \text{ for all }n\in X\text{ and } \sum_{n\in X} \abs{\alpha_n}^2 < \infty\} \end{align}\] is a Hilbert space with the inner product defined as \(\langle\sum_{n\in X} \alpha_n \ket{n} \mid \sum_{n\in X}\alpha'_n \ket{n}\rangle := \sum_{n\in X} \overline{\alpha_n} \alpha'_n\). An orthonormal basis, the computational basis, is \(\{\ket{n}\mid n\in X\}\). The infinite-dimensional space \(l^2(\mathbb{Z})\) can be used for quantum integers and is also denoted \(\mathcal{H}_\infty\). For qubits, we use the finite-dimensional space \(l^2(\{0,1\})\) and denote it as \(\mathcal{H}_2\).
In the following, all vector spaces will be over \(\mathbb{C}\). A function \(f:\mathcal{V}\to \mathcal{W}\) between vector spaces \(\mathcal{V}\) and \(\mathcal{W}\) is called linear if \(f(ax+y)=af(x)+f(y)\) for \(x,y\in \mathcal{V}\) and \(a\in \mathbb{C}\).
Let \(\mathcal{V}, \mathcal{W}\) be normed vector spaces. Then \(f\) is called bounded linear if \(f\) is linear and \(\norm{f(x)} \leq c \cdot \norm{x}\) for some constant \(c \geq 0\) for all \(x \in \mathcal{V}\). If \(\mathcal{V} = \mathcal{W}\) is a Hilbert space, we call \(f\) a bounded operator. We use \(A\ket{\phi}\) to denote the result of applying operator \(A\) to \(\ket{\phi}\in \mathcal{H}\).
The identity operator \(\boldsymbol{I}_{\mathcal{H}}\) on \(\mathcal{H}\) is defined by \(\boldsymbol{I}_{\mathcal{H}} \ket{\phi}=\ket{\phi}\). The zero operator on \(\mathcal{H}\), denoted by \(\boldsymbol{0}_{\mathcal{H}}\), maps every vector to the zero vector. We omit \(\mathcal{H}\) if it is clear from the context.
A bounded operator \(A\) on \(\mathcal{H}\) is called positive if \(\bra{\psi}A\ket{\psi}\geq 0\) for all \(\ket{\psi}\in \mathcal{H}\) and completely positive if for every Hilbert space \(\mathcal{H}'\), the operator \(\boldsymbol{I}_{\mathcal{H}'}\otimes A\) is positive on \(\mathcal{H}' \otimes \mathcal{H}\) [22].
Now we consider special kinds of bounded operators: A unitary operator \(U\) is an operator where \(U^\dagger U = \boldsymbol{I}\) and \(U U^\dagger = \boldsymbol{I}\). \(A\) is a trace class operator if there exists an orthonormal basis \(\{\ket{\psi_i}\}_{i \in I}\) such that \(\{\bra{\psi_i} \cdot \abs{A} \cdot \ket{\psi_i} \}_{i \in I}\) is summable where \(\abs{A}\) is the unique positive operator \(B\) with \(B^\dagger B = A^\dagger A\). The set of all trace class operators on \(\mathcal{H}\) is denoted by \(\mathcal{T}(\mathcal{H})\). Then the trace of \(A\) is defined as \(tr(A) = \sum_{i \in I} \bra{\psi_i} \cdot A \cdot \ket{\psi_i}\) where \(\{\ket{\psi_i}\}_{i \in I}\) is an orthonormal basis. It can be shown that \(tr(A)\) is independent of the chosen basis [8]. The trace is cyclic, i.e., \(tr(AB)=tr(BA)\) [23], linear, i.e., \(tr(A+B) = tr(A) + tr(B)\), scalar, i.e., \(tr(cA) = c\cdot tr(A)\) for a constant \(c\) [24], and multiplicative, i.e., \(tr(A \otimes B)= tr(A)tr(B)\) [23]. A positive trace class operator \(\rho\) with \(tr(\rho)\leq 1\) is called density operator (sometimes also referred to as partial density operator). The set of density operators is denoted by \(\mathcal{D}(\mathcal{H})\). Every trace class operator can be written as a linear combination of density operators [25]. In the following we define semantics etc. on density operators but we implicitly mean the extensions of them to trace class operators by linearity. Any density operator can be written as a weighted sum, i.e. \(\rho = \sum_i p_i \ket{\psi_i}\bra{\psi_i}\) by the spectral decomposition (where the sum is usually meant w.r.t. (trace) norm topology but the topologies coincide in this case [23]). The decomposition is not unique in general.
To order bounded operators, the Loewner order is used: for operators \(A,B\), \(A\sqsubseteq B\) holds iff \(B-A\) is a positive operator. This is equivalent to \(tr(A\rho)\leq tr(B \rho)\) for all density operators \(\rho \in \mathcal{D}(\mathcal{H})\) [8]. It is a partial order. The Loewner order is compatible w.r.t. addition (also known as monotonic), i.e., \(A \sqsubseteq B\) implies \(A+C \sqsubseteq B+C\) for any \(C\), and w.r.t. multiplication of non-negative scalars, i.e., \(A\sqsubseteq B\) implies \(c A \sqsubseteq c B\) for \(c \geq 0\) [26]. The Loewner partial order is an \(\omega\)-complete partial order (\(\omega\)-cpo) on the set of partial density operators [27], i.e., each increasing sequence of partial density operators has a least upper bound.
An (unbounded) operator \(A:\mathfrak{D}(A) \to \mathcal{H}\) is a linear function from a linear subspace \(\mathfrak{D}(A)\subseteq \mathcal{H}\) to Hilbert space \(\mathcal{H}\). We call \(\mathfrak{D}(A)\) the domain of \(A\). The range of an operator \(A\) is defined as \(ran(A) = \{A\ket{\psi} \mid \ket{\psi} \in \mathfrak{D}(A)\}\).
Let \(A: \mathfrak{D}(A) \to \mathcal{H}, B: \mathfrak{D}(B) \to \mathcal{H}\). We can define the (operator) sum, the multiplication with a scalar and the product of \(A\) and \(B\) as follows [28]: \[\begin{align} (A+B)\ket{\psi} &= A\ket{\psi} + B\ket{\psi} \text{ for }\ket{\psi} \in \mathfrak{D}(A+B) = \mathfrak{D}(A) \cap \mathfrak{D}(B),\\ (cA)\ket{\psi} &= c \cdot A\ket{\psi} \text{ for }\ket{\psi} \in \mathfrak{D}(cA) = \mathfrak{D}(A),\\ (AB)\ket{\psi} &= A(B\ket{\psi}) \text{ for }\ket{\psi} \in \mathfrak{D}(AB) = \{\ket{\psi} \in \mathfrak{D}(B) \mid B\ket{\psi} \in \mathfrak{D}(A)\}. \end{align}\]
An operator \(A: \mathfrak{D}(A) \to \mathcal{H}\) is called densely defined if \(\mathfrak{D}(A)\) is dense in \(\mathcal{H}\), i.e., for every \(\ket{\psi} \in \mathcal{H}\) there exists a sequence \(\{\ket{\psi_n}\}_{n\in \mathbb{N}}\) in \(\mathfrak{D}(A)\) such that \(\lim_{n\to \infty} \ket{\psi_n} = \ket{\psi}\). This is equivalent to say that the closure of \(\mathfrak{D}(A)\) is equal to \(\mathcal{H}\) where the closure of a subset \(X \subseteq \mathcal{H}\) is the smallest closed set \(\overline{X}\) with \(X \subseteq \overline{X} \subseteq \mathcal{H}\).
If \(A: \mathfrak{D}(A) \to \mathcal{H}, B: \mathfrak{D}(B) \to \mathcal{H}\) are densely defined, then \(A\otimes B: \mathfrak{D}(A \otimes B) \to \mathcal{H}\) is dense in \(\mathcal{H}\otimes \mathcal{H}\) where \(\mathfrak{D}(A \otimes B)\) contains all finite linear combinations of vectors \(\psi \otimes \phi\) with \(\psi \in \mathfrak{D}(A)\) and \(\phi \in \mathfrak{D}(B)\). It is \((A\otimes B)(\psi \otimes \phi) = A\psi \otimes B\phi\), extended by linearity. If \(A\) and \(B\) are closeable, then \(A\otimes B\) is closable as well [29].
Let \(A: \mathfrak{D}(A) \to \mathcal{H}\) be a densely defined operator. Then we set \(\mathfrak{D}(A^\dagger) = \{\psi \in \mathcal{H}\mid \exists u \in \mathcal{H}: \braket{A\phi}{\psi} = \braket{\phi}{u} \text{ for }\phi \in \mathfrak{D}(A)\}\). As \(\mathfrak{D}(A)\) is dense, \(u\) is uniquely defined by \(\psi\). Then we define the adjoint operator \(A^\dagger: \mathfrak{D}(A^\dagger) \to \mathcal{H}\) by \(A^\dagger \psi = u\). \(A^\dagger\) is a linear operator [30].
A densely defined operator \(A\) is called symmetric if \(A \subseteq A^\dagger\), that means \(\langle A\psi \mid \phi \rangle = \langle \psi \mid A \phi\rangle\) for all \(\psi,\phi \in \mathfrak{D}(A)\) [30]. A symmetric operator \(A\) is called positive (written \(A \geq 0\)) if \(\langle \psi \mid A \mid \psi \rangle \geq 0\) for all \(\psi \in \mathfrak{D}(A)\) [30]. A densely defined operator \(A\) is called self-adjoint if \(A = A^\dagger\) [30]. In the bounded case, self-adjointness and symmetry coincide, in the unbounded case self-adjointness implies symmetry.
According to the spectral theorem for unbounded self-adjoint operators [30], for every self-adjoint operator \(A: \mathfrak{D}(A) \to \mathcal{H}\) there exists a unique spectral measure \(E\) on the Borel \(\sigma\)-algebra \(B(\mathbb{R})\) such that \(A = \int_{\mathbb{R}}\lambda d E_\lambda\). By [31], the spectral measure \(E\) is a projection-valued measure, i.e. \(E_\lambda\) are projections by definition of the spectral measure.
For a positive self-adjoint operator on \(\mathcal{H}\), there exists a unique positive self-adjoint operator \(A^{\frac{1}{2}}\) on \(\mathcal{H}\) such that \(A^{\frac{1}{2}} A^{\frac{1}{2}} = A\) [30] and \(\mathfrak{D}(A) \subseteq \mathfrak{D}(A^{\frac{1}{2}})\) [30]. \(A^{\frac{1}{2}}\) is called the square root of \(A\).
Similar as we introduced \(\boldsymbol{0}\) and \(\boldsymbol{I}\) as special bounded operators, we use \(\boldsymbol{\infty}\) to denote the unbounded operator defined by \(\mathfrak{D}(\boldsymbol{\infty}) = \{0\}\) and \(\boldsymbol{\infty}0 = 0\).
Let \(\mathcal{H}\) be a Hilbert space. Then a sesquilinear form (or form) \(a: \mathfrak{D}(a) \times \mathfrak{D}(a) \to \mathbb{C}\) with \(\mathfrak{D}(a) \subseteq \mathcal{H}\) is a function that is linear in the second and conjugate linear in the first argument [30].
\(a[u] = a[u,u]\) is called the quadratic form associated with \(a\). \(a[u]\) determines \(a[u,v]\) uniquely by the polarization identity [28] and [30].
For forms \(a,b\) and \(c \in \mathbb{C}\) the sum and multiplication with a scalar are defined as in [30]: \[\begin{align} (a+b)[u,v] &= a[u,v] + b[u,v] \text{ for all }u,v \in \mathfrak{D}(a+b) =\mathfrak{D}(a) \cap \mathfrak{D}(b),\\ (ca)[u,v] &= c \cdot a[u,v] \text{ for all }u,v \in \mathfrak{D}(ca) = \mathfrak{D}(a). \end{align}\]
A form \(a\) is called densely defined if \(\mathfrak{D}(a)\) is dense in \(\mathcal{H}\) [28].
The adjoint \(a^\dagger\) of a form \(a\) is defined by \(a^\dagger[u,v] = \overline{a[v,u]}\) for all \(u,v \in \mathfrak{D}(a)\) [28]. \(a\) is called symmetric if \(a=a^\dagger\), i.e. \(a[u,v] = a^\dagger[v,u]\) for all \(u,v \in \mathfrak{D}(a)=\mathfrak{D}(a^\dagger)\) [28]. A symmetric form \(a\) is called lower semi-bounded if \(a[u] \geq c\cdot \norm{u}^2\) for all \(u \in \mathfrak{D}(a)\) with \(\norm{u} = 1\) [28] with \(c\in \mathbb{R}\). If \(c=0\), we call the form \(a\) non-negative or positive [28].
A form \(a\) is called closed if for every sequence \(\{u_n\}_{n\in \mathbb{N}}\) in \(\mathfrak{D}(a)\) with \(u_n \to u\) and \(\lim_{n,m \to \infty} a[u_n-u_m] = 0\), we have \(u \in \mathfrak{D}(a)\) and \(\lim_{n\to\infty} a[u_n-u] = 0\) [30].
For closed symmetric forms \(a,b\) on the same Hilbert space, \(a\leq b\) is defined as \(\mathfrak{D}(b)\subseteq \mathfrak{D}(a)\) and \(\forall x \in \mathfrak{D}(b): a[x] \leq b[x]\) [28].
We define a special case, the zero form \(0\) with \(0[u,v] = 0\) for all \(u,v \in \mathfrak{D}(0) = \mathcal{H}\).
The state space of a quantum system can be described as a Hilbert space where states correspond to unit vectors [8]. We consider only separable Hilbert spaces. A quantum state is called pure if it can be described by a vector in the Hilbert space; otherwise mixed, i.e., it is a probability distribution over pure states. We use density operators (see Section 2.2.1) to describe (mixed) states, in particular to capture the current state of a program. If a quantum system is in a pure state \(\ket{\psi_i}\) with probability \(p_i\) (with \(\sum_i p_i \leq 1\)), then this is represented by the density operator \(\rho=\sum_i p_i \ket{\psi_i}\bra{\psi_i}\)1.
In quantum mechanics, a measurement can impact the current state of a quantum system. Formally, a measurement is a (possibly countably infinite) family of operators \(\{M_m\}_{m\in I}\) where \(m\) is the measurement outcome and \(\sum_{m\in I} M_m^\dagger M_m = \boldsymbol{I}\) 1. If the current state of a quantum system is \(\rho\) before the measurement \(\{M_m\}\), then the probability for obtaining result \(m\) is \(p(m)=tr(M_m \rho M^\dagger_m)\) and the post-measurement state is \(\rho_m = \frac{M_m\rho M^\dagger_m}{p(m)}\).
We call \(f: \mathcal{D}(\mathcal{H}) \to \mathcal{D}(\mathcal{H})\) a quantum subchannel if it is a (linear, bounded) completely positive and trace non-increasing map. Completely positive is defined according to [21]. Trace non-increasing means that \(tr(f(\rho)) \leq tr(\rho)\) for all \(\rho \in \mathcal{D}(\mathcal{H})\). According to [32], an equivalent definition (for separable Hilbert spaces) of a quantum subchannel is that it can be represented using Kraus operators, i.e., there exists a family of bounded operators \(\{E_j\}\) such that \(\sum_{j = 1}^\infty E_j^\dagger E_j \sqsubseteq\boldsymbol{I}\) and \(f(\rho) = \sum_{j = 1}^\infty E_j \rho E_j^\dagger\) for all \(\rho \in \mathcal{D}(\mathcal{H})\)2.
One of the important notions in deductive verification is the concept of a predicate or an expectation [1], [7], [33]. Those predicates are used to express properties that we are interested in, i.e., that we want to verify. Allowing a broader class of predicates allows us to express more properties. In this paper we want to express unbounded expectation values, thus we need to change the definition from predicates to expectations. However, this leads to some technical challenges that we will address in this section.
A predicate is a \(1\)-bounded positive (hence self-adjoint) operator [1]. Simply dropping the bound-condition does not work as the set of positive self-adjoint operators is not an \(\omega\)-cpo with respect to \(\sqsubseteq\) (meaning the order for unbounded operators) which we need for defining the weakest precondition of the while-loop. This was already noted in [1]: "We need to restrict to positive operators and – in order to obtain least upper bounds for increasing sequences – we need to bound them." To overcome this issue, we introduce a novel definition of expectations that enables to capture unbounded expectation values and show that the set of expectations forms an \(\omega\)-cpo with respect to \(\sqsubseteq\).
There are equivalent definitions in the bounded case that describe the same class of operators (self-adjoint, symmetric) which are distinct for unbounded operators. We thus first need to figure out which of those definitions lead to the desired properties (e.g., we always want the expected value to be a positive real number or infinite).
Omitted proofs of this section can be found in Appendix 10.
A first naive attempt would be to require the unbounded operator to be self-adjoint. That implies a dense domain and we actually want to allow operators with non-dense domains as well. This is why we introduce the notion of \(\infty\)-self-adjointness. This is a weaker condition than self-adjointness but still ensures that the expected value is a real number or infinite:
Definition 1. Let \(\mathcal{H}\) be a Hilbert space and \(A: \mathfrak{D}(A) \to \mathcal{H}\) an operator.
\(A\) is \(\infty\)-square* if \(ran(A)\subseteq \overline{\mathfrak{D}(A)}\).*
If \(A\) is \(\infty\)-square, its \(\infty\)-restriction* is the operator \(A_\infty: \mathfrak{D}(A_\infty) \to \overline{\mathfrak{D}(A)}\) with \(\mathfrak{D}(A_\infty) = \mathfrak{D}(A)\) and \(A_\infty \psi = A\psi\) for all \(\psi \in \mathfrak{D}(A_\infty)\).*
\(A\) is called \(\infty\)-self-adjoint* if its \(\infty\)-restriction \(A_\infty\) is self-adjoint.*
Intuitively speaking, we require \(\infty\)-square and the \(\infty\)-restriction to properly define self-adjointness without requiring the operator to be dense. The \(\infty\)-restriction of an \(\infty\)-square operator is the part of the operator that is well-defined and thus can be used to define the expected value. \(\infty\)-self-adjointness ensures that the expected value is a real number or infinite. To define expectations, we add the condition that the operator is positive to ensure that the expected value is non-negative:
Definition 2. The set of expectations* over a Hilbert space \(\mathcal{H}\) is the set of all positive, \(\infty\)-self-adjoint operators on \(\mathcal{H}\), denoted by \(\mathcal{E}(\mathcal{H})\).*
Expectations together with a suitable order need to form an \(\omega\)-cpo to handle while-loops correctly. To establish this, we define an order for expectations and show that \(\mathcal{E}(\mathcal{H})\) forms an \(\omega\)-cpo with respect to this order. The order is strongly inspired by [30] and is a naive extension of the Loewner order for bounded operators.
The Loewner order for bounded operators is defined by \(A \sqsubseteq B\) if \(\bra{\psi}A\ket{\psi} \leq \bra{\psi}B\ket{\psi}\) for all \(\ket{\psi} \in \mathcal{H}\). This definition is not applicable to unbounded operators as \(\bra{\psi}A\ket{\psi}\) is not well-defined for all \(\ket{\psi} \in \mathcal{H}\) if \(\ket{\psi} \notin \mathfrak{D}(A)\).
For unbounded self-adjoint operators, a constraint regarding the domain must be added. We adapt the order from [30] to order expectations:
Definition 3. Let \(A, B \in \mathcal{E}(\mathcal{H})\) be expectations with self-adjoint \(\infty\)-restrictions \(A_\infty, B_\infty\). Then \(A \sqsubseteq B\) iff \(\mathfrak{D}(B_\infty^{\frac{1}{2}}) \subseteq \mathfrak{D}(A_\infty^{\frac{1}{2}})\) and \(\norm{A_\infty^{\frac{1}{2}}\ket{\psi}}^2 \leq \norm{B_\infty^{\frac{1}{2}}\ket{\psi}}^2\) for all \(\psi \in \mathfrak{D}(B_\infty^{\frac{1}{2}})\).
Note that \(A_\infty^{\frac{1}{2}}\) means \((A_\infty)^{\frac{1}{2}}\) and not \((A^{\frac{1}{2}})_\infty\) and that the domain set-inclusion holds in the opposite direction. In the bounded case, this order coincides with the standard Loewner order.
The aim is to show that the set of expectations over \(\mathcal{H}\) forms an \(\omega\)-cpo with respect to \(\sqsubseteq\). To that end, we introduce form-expectations, show their equivalence to expectations and then use Kato’s theorem [28] to show that the limit of an increasing sequence of form-expectations exists and is a form-expectation. We start by defining form-expectations:
Definition 4. A form-expectation* is a closed, symmetric and positive form \(a: \mathfrak{D}(a) \times \mathfrak{D}(a) \to \mathbb{C}\). The set of form-expectations over \(\mathcal{H}\) is denoted by \(\mathcal{F}(\mathcal{H})\).*
Every expectation is equivalent to a form-expectation:
For every expectation \(A\in \mathcal{E}(\mathcal{H})\), there is a corresponding form-expectation \(a \in \mathcal{F}(\mathcal{H})\) with \(a[x,y] = \langle A_\infty^{\frac{1}{2}}x, A_\infty^{\frac{1}{2}}y\rangle\) for all \(x,y \in \mathfrak{D}(a) = \mathfrak{D}(A_\infty^{\frac{1}{2}})\) and the other way round.
Proof Sketch. The main ingredient of the proof is the following theorem ([28] and [30]): "For every positive self-adjoint operator \(A\), there is a corresponding densely defined, closed, symmetric, positive form \(a: \mathfrak{D}(a) \times \mathfrak{D}(a) \to \mathbb{C}\) with \(a[x,y] = \langle A^{\frac{1}{2}}x, A^{\frac{1}{2}}y\rangle\) for all \(x,y \in \mathfrak{D}(a) = \mathfrak{D}(A^{\frac{1}{2}})\) and the other way round". ◻
The next step is to show that the order of expectations as defined in Definition 3 corresponds to the order for form-expectations. Recall that forms are ordered by \(a \leq b\) if \(\mathfrak{D}(b) \subseteq \mathfrak{D}(a)\) and \(a[x] \leq b[x]\) for all \(x \in \mathfrak{D}(b)\) where \(a[x] = a[x,x]\).
Let \(A,B\in \mathcal{E}(\mathcal{H})\) and \(a,b\) be their corresponding form-expectations. Then \(a \leq b\) if and only if \(A \sqsubseteq B\).
Proof. Follows immediately from the definitions: \[\begin{align} a \leq b \Leftrightarrow & \text{ }\forall x \in \mathfrak{D}(b): a[x] \leq b[x] \land \mathfrak{D}(b) \subseteq \mathfrak{D}(a) \\ \Leftrightarrow & \text{ }\forall \psi \in \mathfrak{D}(B_\infty^{\frac{1}{2}}): \norm{A_\infty^{\frac{1}{2}}\ket{\psi}}^2 \leq \norm{B_\infty^{\frac{1}{2}}\ket{\psi}}^2 \land \mathfrak{D}(B_\infty^{\frac{1}{2}}) \subseteq \mathfrak{D}(A_\infty^{\frac{1}{2}}) \Leftrightarrow A \sqsubseteq B \qedhere \end{align}\] ◻
We now establish that \(\mathcal{E}(\mathcal{H})\) constitutes an \(\omega\)-complete partial order w.r.t. \(\sqsubseteq\):
Theorem 1. An increasing sequence of expectations \(\{A_n\}_n\) with \(A_n: \mathfrak{D}(A_n) \to \mathcal{H}\) converges to an expectation \(A: \mathfrak{D}(A) \to \mathcal{H}\) which is also the least upper bound of the sequence, i.e., \(A = \bigvee_{n} A_n = \lim_{n \to \infty} A_n\)3. Thus \(\mathcal{E}(\mathcal{H})\) is an \(\omega\)-cpo w.r.t. \(\sqsubseteq\).
Proof Sketch. The increasing sequence of expectations \(\{A_n\}_n\) corresponds to an increasing sequence of form-expectations \(\{a_n\}_n\) by Propositions [prop:OpstoForms] and [prop:orderEquivalence]. By Kato’s theorem, the limit form \(a\) of the sequence \(\{a_n\}_n\) exists and is a form-expectation. Then we can construct the corresponding expectation \(A\) from the limit form \(a\) by Proposition [prop:OpstoForms]. Finally, we show that \(A\) is indeed the least upper bound of the sequence \(\{A_n\}_n\). ◻
Thus, our definition of expectations provides the foundation for defining the semantics of while-loops in the presence of unbounded expectation values.
In this section we give some technical results about operations on expectations as, for example, the (operator) sum of two self-adjoint operators is not self-adjoint again, so we cannot define the sum of two expectations as usual. Instead we define addition, scalar multiplication and bounded operator application of expectations via their form-expectations. Addition and scalar multiplication of forms are defined in Section 2.3 ([30]) and application of bounded operator \(M\) on form \(a\) we define as \[a_M[u, v] = a[M u, M v] \text{ for all }u,v \in \mathfrak{D}(a_M) = \{u \mid M u \in \mathfrak{D}(a)\}.\] Note that it suffices to consider the quadratic form \(a_M[u] = a[M u, M u] = a[Mu]\). We start by showing that form-expectations are closed under those operations:
For \(a,b \in \mathcal{F}(\mathcal{H}),\alpha \geq 0\) and bounded operator \(M\) is \(a+b, \alpha \cdot a, a_M \in \mathcal{F}(\mathcal{H})\).
Proof Sketch. For each operation, we show that the resulting form is closed, symmetric and positive, thus a form-expectation. ◻
Using these operations we can define addition, scalar multiplication and bounded operator application on expectations such that the resulting operators are still expectations:
Definition 5. Let \(A,B \in \mathcal{E}(\mathcal{H})\) with corresponding form-expectations \(a,b\). Let:
\(A \oplus B \in \mathcal{E}(\mathcal{H})\) be the expectation that corresponds to form \(a+b\),
\(\alpha \cdot A \in \mathcal{E}(\mathcal{H})\) (with \(\alpha \geq 0\)) be the expectation that corresponds to the form \(\alpha \cdot a\), and
\(M^\dagger \odot A \odot M \in \mathcal{E}(\mathcal{H})\) (with bounded operator \(M\) on \(\mathcal{H}\)) be the expectation that corresponds to the form \(a_M\).
We use \(\sum A_n\) or similar for \(A_n \in \mathcal{E}(\mathcal{H})\) to refer to the sum \(\oplus\) as defined in Definition 5. The fact that these operations are well-defined, i.e., that the resulting forms correspond to expectations, follows immediately from Propositions [prop:OpstoForms] and [prop:FormAddMult]. This generalizes to infinite sums:
Lemma 1. Let \(A_n \in \mathcal{E}(\mathcal{H})\) for all \(n\). Then \(\sum_{n=0}^\infty A_n \in \mathcal{E}(\mathcal{H})\)4.
This also carries over to infinite sums of form-expectations, i.e., \(\sum_{n=0}^\infty a_n = a \in \mathcal{F}(\mathcal{H})\) for \(a_n \in \mathcal{F}(\mathcal{H})\).
We can also show continuity and distributivity of our newly defined operations:
Let \(A, A_n, B, B_n \in \mathcal{E}(\mathcal{H})\) with \(A_{n-1}\sqsubseteq A_n, B_{n-1} \sqsubseteq B_n\) and \(M\) be a bounded operator on \(\mathcal{H}\). Then \[\begin{align} & \left(\bigvee_n A_n \right)\oplus B = \bigvee_n \left(A_n \oplus B\right) \\ & B \oplus\left(\bigvee_n A_n \right) = \bigvee_n \left(B \oplus A_n \right) \\ & \left(\bigvee_n A_n \right)\oplus\left( \bigvee_n B_n \right) = \bigvee_n \left(A_n \oplus B_n \right) \\ & M^\dagger \odot \left(\bigvee_n A_n \right) \odot M = \bigvee_n \left(M^\dagger \odot A_n \odot M \right)\\ & M^\dagger \odot (A \oplus B) \odot M = M^\dagger \odot A \odot M \oplus M^\dagger \odot B \odot M \end{align}\]
Note that for an increasing sequence \(A_n\) of expectations, the supremum \(\bigvee_n A_n\) is the limit of the sequence and an expectation according to Theorem 1.
We also have that distributivity applies to infinite sums:
Lemma 2. Let \(A_n\in \mathcal{E}(\mathcal{H})\). Then \(M^\dagger \odot (\sum_{n=0}^\infty A_n) \odot M = \sum_{n=0}^\infty M^\dagger \odot A_n \odot M\).
All definitions above coincide with the usual notions for bounded expectations:
Addition, scalar multiplication and application of bounded operators as defined in Definition 5 coincide with the usual operations for bounded expectations.
Now we show some technical properties of the order \(\sqsubseteq\) that we defined on expectations (Definition 3). In particular, we show that it is a partial order and that it is preserved under addition and the application of bounded operators.
Let \(A,B \in \mathcal{E}(\mathcal{H})\).
\(\sqsubseteq\) is a partial order, i.e., antisymmetric, reflexive and transitive.
\(A \sqsubseteq B \Rightarrow A\oplus C \sqsubseteq B \oplus C\) for any \(C \in \mathcal{E}(\mathcal{H})\).
\(A \sqsubseteq B \Rightarrow M^\dagger \odot A \odot M \sqsubseteq M^\dagger \odot B \odot M\) for any bounded operator \(M\) on \(\mathcal{H}\).
So far, we considered expectation values in an abstract way, i.e., we only required them to be positive, real and possibly infinite. Now we give a concrete definition of the expectation value for a given state based on the spectral measure of the corresponding operator. We adapt the definition from [34]:
Definition 6. Let \(A \in \mathcal{E}(\mathcal{H})\) and \(A_\infty\) be its \(\infty\)-restriction. We define the expectation value \(\mathbb{E}_A: \mathcal{D}(\mathcal{H}) \to \mathbb{R}_{\geq 0}^\infty\) for \(\rho \in \mathcal{D}(\mathcal{H})\) as \[\mathbb{E}_{A}\left(\rho\right) = \begin{cases} \int \lambda d (tr(E_\lambda \rho)) & \text{if } \int \abs{\lambda} d (tr(E_\lambda \rho)) < \infty \\ \infty & \text{otherwise} \end{cases}\] where \(E_\lambda\) is the spectral measure of \(A_\infty\).
For (bounded) expectation \(A \sqsubseteq\boldsymbol{I}\), the integral always exists and the expectation value is equivalent to \(tr(A\rho)\) [34], the satisfaction of a predicate as in [1].
As this is a quite technical definition, we present two equivalent definitions of \(\mathbb{E}_A\) which are more intuitive and easier to use in proofs (e.g., in the proof of Lemma 4). The first one is based on \(A^{\frac{1}{2}}\) and aligns with the definition of the order \(\sqsubseteq\); the second one is based on the corresponding form-expectation.
Lemma 3. Let \(A \in \mathcal{E}(\mathcal{H})\) with form \(a\). Let \(\rho = \sum_i p_i \ket{\psi_i}\bra{\psi_i}\in\mathcal{D}(\mathcal{H})\) be a decomposition with \(p_i > 0\). Then \(\mathbb{E}_A(\rho) = \sum_i p_i \mathbb{E}_{A}\left(\ket{\psi_i}\bra{\psi_i}\right)\) where either
\[\mathbb{E}_{A}\left(\ket{\psi}\bra{\psi}\right) = \begin{cases} \norm{A_\infty^{\frac{1}{2}} \ket{\psi}}^2 & \text{if } \ket{\psi} \in \mathfrak{D}(A_\infty^{\frac{1}{2}}) \\ \infty & \text{otherwise} \end{cases} \text{ or }\]
\[\mathbb{E}_{A}\left(\ket{\psi}\bra{\psi}\right) = \begin{cases} a[\ket{\psi}] & \text{if } \ket{\psi} \in \mathfrak{D}(a) \\ \infty & \text{otherwise.} \end{cases}\]
Note that whenever \(\ket{\psi} \in \mathfrak{D}(A)\), then \(\mathbb{E}_{A}\left(\ket{\psi}\bra{\psi}\right) = \bra{\psi} A \ket{\psi}\) [34].
The Loewner order on 1-bounded expectations can be characterized using expected values, i.e., \(A \sqsubseteq B\) if \(tr(A\rho) \leq tr(B\rho)\) for all \(\rho\) [1]. This also holds for our definition of expectation values:
Lemma 4. For \(A , B \in \mathcal{E}(\mathcal{H})\): \[\begin{align} A \sqsubseteq B \Leftrightarrow \text{ for all } \rho \in \mathcal{D}(\mathcal{H}) : \mathbb{E}_{A}\left(\rho\right) \leq \mathbb{E}_{B}\left(\rho\right) \end{align}\]
The correspondence to expected values is a healthiness condition indicating that our order \(\sqsubseteq\) is indeed the right order to use for expectations.
Using this result, it follows that \(\boldsymbol{0}\) and \(\boldsymbol{\infty}\) are the least and greatest element of \(\mathcal{E}(\mathcal{H})\) with respect to \(\sqsubseteq\) as \(\mathbb{E}_{\boldsymbol{0}}\left(\rho\right) = 0 \leq \mathbb{E}_{A}\left(\rho\right) \leq \mathbb{E}_{\boldsymbol{\infty}}\left(\rho\right) = \infty\) for all \(A \in \mathcal{E}(\mathcal{H}), \rho \in \mathcal{D}(\mathcal{H})\) (\(\rho \neq 0\), otherwise \(\mathbb{E}_{\boldsymbol{\infty}}\left(\rho\right) = 0 = \mathbb{E}_{A}\left(\rho\right)\)).
Now that we have established expectation values we can show that they are linear and continuous in both the expectation and the state:
Expectation values are linear (in expectation and state), i.e., \(\mathbb{E}_{A\oplus B}\left(\rho\right) = \mathbb{E}_{A}\left(\rho\right) + \mathbb{E}_{B}\left(\rho\right)\) and \(\mathbb{E}_{A}\left(\rho + \sigma\right) = \mathbb{E}_{A}\left(\rho\right) + \mathbb{E}_{A}\left(\sigma\right)\) for \(A, B \in \mathcal{E}(\mathcal{H})\) and \(\rho, \sigma \in \mathcal{D}(\mathcal{H})\) such that \(\rho+\sigma \in \mathcal{D}(\mathcal{H})\).
Expectation values are scalar multiplicative (in expectation and state), i.e., \(\mathbb{E}_{cA}\left(\rho\right) = c \cdot \mathbb{E}_{A}\left(\rho\right)\) and \(\mathbb{E}_{A}\left(c\rho\right) = c \cdot \mathbb{E}_{A}\left(\rho\right)\) for \(c \geq 0, \rho, \sigma \in \mathcal{D}(\mathcal{H})\) such that \(c \rho, \rho+\sigma \in \mathcal{D}(\mathcal{H})\).
Expectation values are continuous (in expectation and state), i.e., \(\mathbb{E}_{\bigvee_i A_i}\left(\rho\right) = \bigvee_i \mathbb{E}_{A_i}\left(\rho\right)\) and \(\mathbb{E}_{A}\left(\bigvee_i \rho_i\right) = \bigvee_i \mathbb{E}_{A}\left(\rho_i\right)\) for an increasing chain of expectations \(\{A_i\}_i \subseteq \mathcal{E}(\mathcal{H})\) and states \(\{\rho_i\}_i \subseteq \mathcal{D}(\mathcal{H})\) respectively.
Linearity can also be extended to infinite sums analogously to before:
Lemma 5. Let \(A_n \in \mathcal{E}(\mathcal{H})\) and \(\rho_n \in \mathcal{D}(\mathcal{H})\), for all \(n\). Then \(\mathbb{E}_{\sum_n A_n}\left(\rho\right) = \sum_n \mathbb{E}_{A_n}\left(\rho\right)\) for all \(\rho \in \mathcal{D}(\mathcal{H})\) and \(\mathbb{E}_{A}\left(\sum_n \rho_n\right) = \sum_n \mathbb{E}_{A}\left(\rho_n\right)\) for all \(A \in \mathcal{E}(\mathcal{H})\) and \(\rho_n, \sum_n \rho_n \in \mathcal{D}(\mathcal{H})\).
We conclude with a result that will be useful in the following sections:
Let \(A \in \mathcal{E}(\mathcal{H})\) and \(M\) a bounded operator on \(\mathcal{H}\). Then \(\mathbb{E}_{M^\dagger \odot A \odot M}\left(\rho\right) = \mathbb{E}_{A}\left(M \rho M^\dagger\right)\) for all \(\rho \in \mathcal{D}(\mathcal{H})\).
Our aim is to extend existing quantum while languages to include rewards to enable reasoning about costs such as runtime. In this section, we first present some desirable properties about the semantics of such a programming language. Then we define the programming language qrWhile and show that it satisfies these properties. Omitted proofs can be found in Appendix 11.
We consider a separable Hilbert space \(\mathcal{H}\) as the state space of our quantum programs and positive (real) rewards only. Our aim is to define a semantics for quantum programs \(S\) as two separate maps \(\llbracket S \rrbracket_D: \mathcal{D}(\mathcal{H}) \to \mathcal{D}(\mathcal{H})\) and \(\llbracket S \rrbracket_{R}: \mathcal{D}(\mathcal{H}) \to \mathbb{R}_{\geq 0}^\infty\), where \(\mathcal{D}(\mathcal{H})\) is the set of density operators on \(\mathcal{H}\). The map \(\llbracket S \rrbracket_D\) describes how the quantum state changes during the execution of the program (the usual denotational semantics), while \(\llbracket S \rrbracket_{R}\) describes the expected reward collected during the program execution. The use of two separate maps is similar to [13] and allows us to reason about the expected reward without modifying the quantum state. If we would integrate the expected reward as a variable into the quantum state, we have to be careful about diverging loops similar to the first example from the introduction (these problems occur in the probabilistic setting as well [35]). Desirable properties of these two maps are:
Definition 7. A semantics for quantum programs with rewards is a pair of maps \(\llbracket S \rrbracket_D: \mathcal{D}(\mathcal{H}) \to \mathcal{D}(\mathcal{H})\) and \(\llbracket S \rrbracket_{R}: \mathcal{D}(\mathcal{H}) \to \mathbb{R}_{\geq 0}^\infty\) such that
\(\llbracket S \rrbracket_D\) is linear, trace non-increasing and completely positive
if \(S\) is reward-free, then \(\llbracket S \rrbracket_{R}(\rho) = 0\) for all \(\rho \in \mathcal{D}(\mathcal{H})\)
\(\llbracket S \rrbracket_{R}\) is linear
the form \(a\) defined by \(a[\ket{\psi}] = \llbracket S \rrbracket_{R}(\ket{\psi}\bra{\psi})\) with \(\mathfrak{D}(a) =\{\ket{\psi} \mid \llbracket S \rrbracket_{R}(\ket{\psi}\bra{\psi}) < \infty\}\) is a positive, symmetric, closed form.
Note that we implicitly mean the extensions to trace class operators \(\mathcal{T}(\mathcal{H})\) and \(\mathbb{C}\). The set of all quantum programs over \(\mathcal{H}\) with such a semantics is denoted by \(Prog(\mathcal{H})\).
Requiring \(\llbracket S \rrbracket_D\) to be linear, trace non-increasing and completely positive are the common properties that we expect from the denotational semantics of quantum programs / a quantum channel (see, e.g., [8] and [13]). This also implies that \(\llbracket S \rrbracket_D\) can be represented as a Kraus decomposition [32]. The second constraint \(\llbracket S \rrbracket_{R}(\rho) = 0\) for reward-free \(S\) asserts that the expected reward is zero if the program does not contain any reward statements, and is quite natural. Similarly, the third constraint, that \(\llbracket S \rrbracket_{R}\) is linear, is also natural as the expected reward should be linear in the input state. The last constraint probably needs more motivation. For finite programs (e.g., without loops), the expected reward \(\llbracket S \rrbracket_{R}^{fin}: \mathcal{D}(\mathcal{H}) \to \mathbb{R}_{\geq 0}^\infty\) can be computed as \(\llbracket S \rrbracket_{R}^{fin}(\rho) = tr(A_R \rho)\) which is a positive functional where \(A_R\) corresponds to the observable that keeps track of the earned reward5. The expected reward for infinite programs (e.g., with loops) can then be defined as a least upper bound of the expected rewards of all its finite approximations (i.e., abort the program after a finite number of steps). Such a least upper bound corresponds to a positive, symmetric and closed form, thus we require this property for \(\llbracket S \rrbracket_{R}\):
Let \(g_i: \mathcal{D}(\mathcal{H}) \to \mathbb{R}_{\geq 0}\) be a (pointwise) increasing sequence of maps. Then \(g: \mathcal{D}(\mathcal{H}) \to \mathbb{R}_{\geq 0}^\infty\) defined by \(g(\rho) = \sup_i g_i(\rho)\) corresponds to a positive, symmetric and closed form.
In this section we present a concrete programming language, called qrWhile, and show that it satisfies the properties defined in the previous section (Definition 7). The syntax and semantics of qrWhile is based on [8] but we extend it by reward statements inspired by [16], [35], [36].
We assume a countable number of variables that are either qubits or quantum integers. Qubits are represented by the 2-dimensional Hilbert space \(\mathcal{H}_2\), quantum integers by infinite-dimensional Hilbert spaces \(\mathcal{H}_\infty\) as defined in Example 1. The state space \(\mathcal{H}\) of a quantum program is the tensor product of the Hilbert spaces of all its variables.
Additionally to the usual program statements as in [8] we introduce a reward statement that collects rewards during the execution of the program and allows us to reason about expected rewards and expected runtime, similar to the consume statement in [16]. Note that in comparison to [16], we do not have a separate (classical) variable to store the reward and we also allow infinite values. We allow rewards from a countable set \(R \subseteq \mathbb{R}_{\geq 0}^\infty\).
The \(\boldsymbol{reward} ( c)\) statement does not change the quantum state (as it does not correspond to any operation on the quantum computer), but adds \(c \cdot p\) to the expected reward where \(p\) is the probability of the current execution.
Definition 8. The syntax of qrWhile programs \(S\) over the Hilbert space \(\mathcal{H}\) is defined as follows: \[S ::= \boldsymbol{skip}\mid q:=0\mid \overline{q}:= U\overline{q}\mid \boldsymbol{reward} ( c)\mid \boldsymbol{measure } M[\overline{q}]:\overline{S}\mid S_1;S_2\mid \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S\] where
\(\boldsymbol{skip}\) is the skip statement
\(q:=0\) initializes the quantum variable \(q\) to the basis state \(\ket{0}\)
\(\overline{q}:= U\overline{q}\) applies the unitary operator \(U\) to the quantum variables \(\overline{q}\)
\(\boldsymbol{reward} ( c)\) adds a reward \(c \in R\)
\(\boldsymbol{measure } M[\overline{q}]:\overline{S}\) performs a measurement \(M = \{M_m\}\) on the quantum variables \(\overline{q}\) and executes the subprogram \(S_m \in \overline{S}\) according to the measurement outcome \(m\)
\(S_1;S_2\) is the sequential composition of programs \(S_1\) and \(S_2\)
\(\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S\) is a while-loop that measures the quantum variables \(\overline{q}\) with the measurement \(M = \{M_0, M_1\}\) and executes the body \(S\) if the outcome is \(1\), otherwise it terminates.
The denotational semantics of qrWhile is defined as follows. We need to handle the rewards separately, yielding pairs (similar as in [13]). The first element is the density operator (as in [8], [13]), the second element is the expected reward collected during the program execution. We denote \(\llbracket S \rrbracket(\rho) = (\llbracket S \rrbracket_D(\rho), \llbracket S \rrbracket_{R}(\rho))\):
Definition 9. The denotational semantics* of a qrWhile program \(S\) is given by a map \(\llbracket S \rrbracket: \mathcal{D}(\mathcal{H}) \to \mathcal{D}(\mathcal{H}) \times \mathbb{R}_{\geq 0}^\infty\):*
\(\llbracket \boldsymbol{skip} \rrbracket(\rho) = (\rho,0)\)
\(\llbracket q:=0 \rrbracket(\rho) = (\sum_{n=0}^\infty \ket{0}\bra{n} \rho \ket{n}\bra{0}, 0)\)
\(\llbracket \overline{q}:= U\overline{q} \rrbracket(\rho) = (U \rho U^\dagger,0)\)
\(\llbracket \boldsymbol{reward} ( c) \rrbracket(\rho) = (\rho, c \cdot tr(\rho))\)
\(\llbracket S_1; S_2 \rrbracket(\rho) = (\llbracket S_2 \rrbracket_D(\llbracket S_1 \rrbracket_D(\rho)), \llbracket S_2 \rrbracket_{R}(\llbracket S_1 \rrbracket_D(\rho)) + \llbracket S_1 \rrbracket_{R}(\rho))\)
\(\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S} \rrbracket(\rho) = \sum_m \llbracket S_m \rrbracket(M_m \rho M_m^\dagger)\)
\(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket(\rho) =\)
\((\bigvee_{i=0}^\infty \llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^i \rrbracket_D(\rho), \lim_{i \to \infty} \llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^i
\rrbracket_{R}(\rho))\) where \[\begin{align} \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^0 &= \Omega \text{ with } \llbracket \Omega \rrbracket(\rho) = (\boldsymbol{0},0)\\ \boldsymbol{while }
M[\overline{q}]=1 \boldsymbol{ do } S^{i+1} &= \boldsymbol{measure } M[\overline{q}]:\overline{S}\\ & \text{ with } S_0 = \boldsymbol{skip}\\ & \text{ and } S_1 = S; \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^i
\end{align}\]
where addition is entry-wise. Well-definedness follows from [8] and the fact that \(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^i \rrbracket_{R}(\rho)\) is increasing.
When considering programs without reward statements, the semantics is the same as in [8]. This follows immediately from the definition.
For all qrWhile programs \(S\) without reward statements and all \(\rho \in \mathcal{D}(\mathcal{H})\), it holds that \(\llbracket S \rrbracket(\rho) = (\llbracket S \rrbracket_{\text{orig}}(\rho), 0)\) where \(\llbracket S \rrbracket_{\text{orig}}\) is the semantics defined in [8].
The following healthiness properties hold:
Let \(S\) be a qrWhile program. Then:
\(\llbracket S \rrbracket_D\) is linear
\(\llbracket S \rrbracket_D\) is trace non-increasing, i.e., \(tr(\llbracket S \rrbracket_D(\rho)) \leq tr(\rho)\) for all \(\rho \in \mathcal{D}(\mathcal{H})\)
\(\llbracket S \rrbracket_D\) is completely positive
\(\llbracket S \rrbracket_{R}\) is linear
\(a[\ket{\psi}] := \llbracket S \rrbracket_{R}(\ket{\psi} \bra{\psi})\) for all \(\ket{\psi} \in \mathfrak{D}(a) = \{\ket{\psi} \in \mathcal{H}\mid \llbracket S \rrbracket_{R}(\ket{\psi} \bra{\psi}) < \infty \}\) is a symmetric, positive and closed form.
Thus our concrete semantics defined in Definition 9 satisfies the requirements of Definition 7 and thus it is a semantics for quantum programs with rewards.
Theorem 2. The semantics defined in Definition 9 satisfies the properties in Definition 7 and thus every qrWhile program is an element of \(Prog(\mathcal{H})\).
Proof. Follows immediately from Propositions [prop:rewardFreeOriginalSem] and [prop:semanticsProperties]. ◻
Another choice for the reward statement would have been to allow expectations (or other real valued measurements) in the reward statement, but they induce an implicit measurement which changes the quantum state and thus we only consider constants. Note that this is not a restriction as we could measure and then add the reward based on the measurement outcome (using the measurement statement) and thus we can also add rewards that depend on the program state.
In this section we first define Hoare triples and the weakest pre-expectation in terms of general quantum programs and give a concrete syntactic way of computing them for qrWhile programs. Omitted proofs can be found in Appendix 12.
The correctness of Hoare triples with respect to a program \(S\in Prog(\mathcal{H})\) and expectations is defined as follows:
Definition 10. Let \(S \in Prog(\mathcal{H})\) and \(A,B \in \mathcal{E}(\mathcal{H})\). A Hoare triple \(\{A\} S \{B\}\) is
**totally correct* if for all \(\rho \in \mathcal{D}(\mathcal{H})\): \[\mathbb{E}_{A}\left(\rho\right) \leq \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho)\]*
**partially correct* if \(A,B \sqsubseteq\boldsymbol{I}\), \(S\) is reward-free and for all \(\rho \in \mathcal{D}(\mathcal{H})\): \[\mathbb{E}_{A}\left(\rho\right) \leq \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\rho)\right) + \underbrace{[tr(\rho) - tr(\llbracket S \rrbracket_D(\rho))]}_{\substack{\text{probability of non-termination}}}\]*
Note that the last definition (partial correctness) requires \(1-\)bounded expectations \(A,B \sqsubseteq\boldsymbol{I}\) as otherwise adding the term \([tr(\rho) - tr(\llbracket S \rrbracket_D(\rho))]\) does not make sense. Similarly, for partial correctness we only consider reward-free programs (and not add the term \(\llbracket S \rrbracket_{R}(\rho)\)). Otherwise we add probabilities and expected values (possibly \(>1\)). Thus, partial correctness coincides with the definition in [8] and is therefore not further considered in this paper.
We obtain similar results as [8] but often the restriction to reward-free programs is necessary:
For \(S \in Prog(\mathcal{H})\) and \(A,B \in \mathcal{E}(\mathcal{H})\):
If a Hoare triple is totally correct, \(S\) reward-free and \(A,B \sqsubseteq\boldsymbol{I}\), it is also partially correct.
The Hoare triple \(\{\boldsymbol{0}\} S \{A\}\) is totally correct.
For all reward-free \(S\) and \(A \sqsubseteq\boldsymbol{I}\), the Hoare triple \(\{A\} S \{ \boldsymbol{I}\}\) is partially correct.
As our aim is to keep the wp-calculus as close as possible to [1], we define the weakest pre-expectation as follows:
Definition 11. Let \(S \in Prog(\mathcal{H})\). The weakest pre-expectation* with respect to a post-expectation \(B \in \mathcal{E}(\mathcal{H})\) is the expectation \(wp\llbracket S \rrbracket (B) = \sup\{A \mid \{A\} S \{B\}\}\) (if it exists).*
The existence of the weakest pre-expectation is shown in Theorems 3 and 4 below. An alternative condition to check for weakest pre-expectations is:
Lemma 6. Let \(B, C \in \mathcal{E}(\mathcal{H})\) and \(S \in Prog(\mathcal{H})\). If \(\text{ }\mathbb{E}_{C}\left(\rho\right) = \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho)\) holds for all \(\rho\in \mathcal{D}(\mathcal{H})\), then \(C\) is the weakest pre-expectation.
Proof. \(\mathbb{E}_{C}\left(\rho\right) = \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho)\) implies that \(C\) is a pre-expectation of \(B\) and if there was another pre-expectation \(A\) with \(C \sqsubseteq A\), it would hold that \(\mathbb{E}_{A}\left(\rho\right) > \mathbb{E}_{C}\left(\rho\right) = \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho)\) for some \(\rho\) which contradicts that \(A\) is a pre-expectation. ◻
In the case of bounded operators and reward-free programs, these definitions coincide with [1], [8].
We can also directly state some properties of weakest pre-expectations that hold whenever the premise in Lemma 6 holds. Note that the first two properties only hold for reward-free programs.
Let \(S \in Prog(\mathcal{H})\) and \(B \in \mathcal{E}(\mathcal{H})\) such that \(\mathbb{E}_{wp\llbracket S \rrbracket (B)}\left(\rho\right) = \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho)\). Then
\(wp\llbracket S \rrbracket (\boldsymbol{0}_{\mathcal{H}}) = \boldsymbol{0}_{\mathcal{H}}\) for reward-free programs \(S\)
Linearity: For reward-free programs, \(c \geq 0\) with \(cB \in \mathcal{E}(\mathcal{H})\) it is \(wp\llbracket S \rrbracket (c B) = c \cdot wp\llbracket S \rrbracket (B)\) and for \(B_1, B_2 \in \mathcal{E}(\mathcal{H})\) it is \(wp\llbracket S \rrbracket (B_1 \oplus B_2) = wp\llbracket S \rrbracket (B_1) \oplus wp\llbracket S \rrbracket (B_2)\)
Monotonicity: If \(B_1, B_2 \in \mathcal{E}(\mathcal{H})\) with \(B_1 \sqsubseteq B_2\), then \(wp\llbracket S \rrbracket (B_1) \sqsubseteq wp\llbracket S \rrbracket (B_2)\)
Order-continuity: For an increasing chain of expectations \(\{B_n\}_n \subseteq \mathcal{E}(\mathcal{H})\) is \(wp\llbracket S \rrbracket (\bigvee_n B_n) = \bigvee_n wp\llbracket S \rrbracket (B_n)\)
Now we can prove the existence of the weakest pre-expectation (the supremum) for all quantum programs in \(Prog(\mathcal{H})\) based on forms. It can be seen as a kind of Schrödinger-Heisenberg duality for unbounded operators, as we show the expectation value equivalence in the proof. In fact, this proposition not only holds for our qrWhile semantics but for all quantum programs in \(Prog(\mathcal{H})\), i.e., all quantum programs with semantics that satisfy the properties of Definition 7.
Theorem 3. Let \(S \in Prog(\mathcal{H})\) and \(b\in \mathcal{F}(\mathcal{H})\) with corresponding expectation \(B \in \mathcal{E}(\mathcal{H})\). Then: \[\begin{align} wp_f\llbracket S \rrbracket (b) &:= \lambda \psi. b[\llbracket S \rrbracket_D(\ket{\psi} \bra{\psi})] + \llbracket S \rrbracket_{R}(\ket{\psi}\bra{\psi}) \in \mathcal{F}(\mathcal{H}) \end{align}\] and \(wp\llbracket S \rrbracket (B)\) (as defined in Definition 11) is its corresponding expectation. Note that we abuse notation and write \(b[\rho]\) to mean \(\sum_i p_i b[\ket{\phi_i}]\) for \(\rho = \sum_i p_i \ket{\phi_i}\bra{\phi_i}\).
As mentioned above, this result for forms gives us also the existence of the weakest pre-expectation in the operator form:
Theorem 4. Let \(S\in Prog(\mathcal{H})\) and \(B \in \mathcal{E}(\mathcal{H})\). Then \(wp\llbracket S \rrbracket (B) \in \mathcal{E}(\mathcal{H})\) exists with \(\mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho)= \mathbb{E}_{wp\llbracket S \rrbracket (B)}\left(\rho\right)\) for all \(\rho \in \mathcal{D}(\mathcal{H})\).
For qrWhile programs, we give a concrete representation in Table 1 which shows how to compute the weakest pre-expectation for a given program and post-expectation. The correctness of this representation is given by:
Let \(S\) be a qrWhile program. The transformer \(wp \llbracket S \rrbracket\) as given in Table 1 is well-defined, i.e., \(wp\llbracket S \rrbracket (B) \in \mathcal{E}(\mathcal{H})\) for post-expectation \(B \in \mathcal{E}(\mathcal{H})\) and \(\mathbb{E}_{wp\llbracket S \rrbracket (B)}\left(\rho\right) = \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho)\) for all \(\rho \in \mathcal{D}(\mathcal{H})\). That is, \(wp\llbracket S \rrbracket (B)\) is the weakest pre-expectation of \(S\) with respect to \(B\).
Proof Sketch. We show by simultaneous induction on the structure of \(S\):
\(wp\llbracket S \rrbracket (B)\) is an expectation, and
\(\mathbb{E}_{wp\llbracket S \rrbracket (B)}\left(\rho\right) = \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho)\) for all \(\rho \in \mathcal{D}(\mathcal{H})\).
◻
| \(\skipbf\) | \(B\) |
| \(\qzero\) | \(\displaystyle \sum_{n=0}^\infty \ket{n}\bra{0} \odot B \odot \ket{0}\bra{n}\) |
| \(\Uq\) | \(\formsandwich{U}{B}\) |
| \(\rewardR\) | \(B \sumform c \cdot \identityOp\) |
| \(\concat\) | \(\qwp{S_1}{\qwp{S_2}{B}}\) |
| \(\measurePrime\) | \(\displaystyle \sum_{m} \formsandwich{M_m}{\qwp{S_m'}{B}}\) |
| \(\while'\) | \(\displaystyle \bigvee_n A_n \quad \text{where } A_0 = \zeroOp,\; A_{n+1} = \formsandwich{M_0}{B} \sumform \formsandwich{M_1}{\qwp{S'}{A_n}}\) |
8pt
Finally, if we remove the reward from the qrWhile programs and consider only \(1-\)bounded expectations, the calculus presented above coincides with the standard one [8]:
If \(A \sqsubseteq\boldsymbol{I}\) is \(1-\)bounded and qrWhile program \(S\) is reward-free, then our weakest precondition calculus and definitions are equivalent to [1], [8] as in this case, \(\mathbb{E}_{A}\left(\rho\right) = tr(A\rho)\) for all partial density operators \(\rho \in \mathcal{D}(\mathcal{H})\).
The reasoning about loops is typically facilitated by proof rules. These rules provide sufficient conditions under which bounds for qrWhile programs can be proven. Those rules also hold in the bounded case [8]. First, we define the characteristic function of a loop:
Definition 12. The characteristic function \(\psi_B: \mathcal{E}(\mathcal{H})\to \mathcal{E}(\mathcal{H})\) of \(\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S\) w.r.t. post-expectation \(B \in \mathcal{E}(\mathcal{H})\) is defined for \(A \in \mathcal{E}(\mathcal{H})\) by: \[\begin{align} \psi_B(A) = M_0^\dagger \odot B \odot M_0 \oplus M_1^\dagger \odot wp\llbracket S \rrbracket (A) \odot M_1 \end{align}\]
Based on this, we obtain the quantum version of Park induction [37], which is a well-known proof rule for upper bounds of wp in the probabilistic case:
Let \(\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S\) be a loop in qrWhile, \(A,B \in \mathcal{E}(\mathcal{H})\) and \(\psi_B\) its characteristic function then \[\psi_B(A)\sqsubseteq A \Rightarrow wp\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (B) \sqsubseteq A\]
Analogously we obtain a dual version for lower bounds of wlp as defined in [8]:
Let \(\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S\) be a loop in qrWhile, \(A,B \in \mathcal{E}(\mathcal{H})\) with \(A,B \sqsubseteq\boldsymbol{I}\) and \(\phi_B(A) = M_0^\dagger \odot B \odot M_0 + M_1^\dagger \odot wlp\llbracket S \rrbracket (A) \odot M_1\), then \[A \sqsubseteq\phi_B(A) \Rightarrow A \sqsubseteq wlp\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (B)\]
In this section we show how to use the weakest pre-expectation to obtain the expected runtime – the number of executed statements as in [2] – of quantum programs. The main idea is to use expected rewards. Thus this section only handles programs without rewards, as we want to use the reward statements to track the runtime.
Remark 1. There are many different ways to track the expected runtime in a program (e.g., we could also add a tick variable that is incremented in each statement or define a forward transformer that simply counts the number of statements as done in [2]), but we choose this transformation using reward statements to make our approach flexible: it is easy to change the notion of runtime, e.g., count the number of iterations in a while-loop instead (then only the program transformation must be changed). More reasons for using reward statements (in the probabilistic case) can be found in [35], they also give examples why using counter variables do not work as expected.
[2] presents an expected runtime transformer for quantum programs with bounded operators only (and finite dimensional spaces), the extension to unbounded operators is one instance of our weakest pre-expectation framework (see Theorems 6 and 7). To do so, we transform (reward-free) programs syntactically by adding \(\boldsymbol{reward} (1)\) statements as shown in Table 2. Intuitively, we add a \(\boldsymbol{reward} (1)\) statement in front of each statement to count the number of executed statements. For the while-loop, we add a reward statement for each measurement, that means we do it once in the beginning and then after the loop body to account for the next measurement. Omitted proofs can be found in Appendix 13.
| \(\skipbf\) | \(\skipbf\) |
| \(\qzero\) | \(\reward{1}; \qzero\) |
| \(\Uq\) | \(\reward{1}; \Uq\) |
| \(\concat\) | \(\transform{S_1}; \transform{S_2}\) |
| \(\measure\) | \(\reward{1}; \textbf{measure } M[\overline{q}]:\overline{\transform{S}}\) |
| \(\while\) | \(\reward{1}; \textbf{while } M[\overline{q}]=1 \textbf{ do } \{\transform{S}; \reward{1}\}\) |
8pt
Definition 13. For a reward-free qrWhile program \(S\), the program \(T({S})\) is inductively defined in Table 2.
The added reward statements do not change the quantum state, i.e., \(T({S})\) is semantically equivalent to \(S\) in terms of the quantum state. They enable to track the expected reward which will be used to define the expected runtime of \(S\).
Lemma 7. Let \(S\) be a reward-free qrWhile program. Then \(\llbracket T({S}) \rrbracket_D(\rho) =\llbracket S \rrbracket_D(\rho)\).
Proof. Follows immediately from the definition of \(\llbracket \boldsymbol{reward} (r) \rrbracket_D\) and we only add finite many reward statements to each statement of \(S\), i.e., we do not create non-termination by adding those reward statements. ◻
Finally we define the expected runtime of a reward-free program \(S\) using the expected reward of the transformed program \(T({S})\):
Definition 14. Let \(S\) be a reward-free qrWhile program. Then the expected runtime* of \(S\) on input state \(\rho\) is defined as \(\llbracket T({S}) \rrbracket_{R}(\rho)\).*
One of the main results of this section is, that we can now characterize the expected runtime using weakest preconditions. This brings the usual advantages of weakest preconditions, e.g., we can determine the expected runtime for all input states at once.
Theorem 5. The expected runtime of a reward-free qrWhile program \(S\) on input state \(\rho\) is given by \(\mathbb{E}_{wp\llbracket T({S}) \rrbracket (\boldsymbol{0})}\left(\rho\right)\).
Proof. It is \(\mathbb{E}_{\boldsymbol{0}}\left(\llbracket T({S}) \rrbracket_D(\rho)\right) = 0\), thus \[\mathbb{E}_{wp\llbracket T({S}) \rrbracket (\boldsymbol{0})}\left(\rho\right) = \mathbb{E}_{\boldsymbol{0}}\left(\llbracket T({S}) \rrbracket_D(\rho)\right) + \llbracket T({S}) \rrbracket_{R}(\rho) = \llbracket T({S}) \rrbracket_{R}(\rho). \qedhere\] ◻
In runtime analysis, we are often interested in determining whether a program terminates with probability 1. This property is called almost sure termination [38] and can be defined for quantum programs as in [2]:
Definition 15. The set of states on which a program \(S\) is almost surely terminating* (AST) is \(\{\rho \in \mathcal{D}(\mathcal{H}) \mid tr(\llbracket S \rrbracket_D(\rho)) = tr(\rho)\}\). If \(S\) is AST on all input states, we say that \(S\) is AST.*
One main difference to [2] is, that we consider infinite-dimensional Hilbert spaces. Thus, a program can be AST but has an infinite expected runtime. As in the finite-dimensional case, AST and finite expected runtime coincide [2], the restriction to AST in [2] has the limitation to be unable to deal with infinite runtimes. In presence of possible infinite expected runtimes, we consider positive almost sure termination analogous to [39]:
Definition 16. The set of states on which a reward-free program \(S\) is positive almost surely terminating* (PAST) is defined as \(\{\rho \in \mathcal{D}(\mathcal{H}) \mid \llbracket T({S}) \rrbracket_{R}(\rho) < \infty\}\). If \(S\) is PAST on all input states, we say that \(S\) is PAST.*
We can also give alternative characterizations for reward-free programs of AST and PAST using the weakest pre-expectation similar to [14]:
Let \(S\) be a reward-free qrWhile program. Then
\(S\) is AST if and only if \(wp\llbracket S \rrbracket (\boldsymbol{I}) = \boldsymbol{I}\).
\(S\) is PAST if and only if \(\mathfrak{D}(wp\llbracket T({S}) \rrbracket (\boldsymbol{0})) = \mathcal{H}\).
These two characterizations are especially interesting in the quantum case. We know that the space of states for which a program is AST is a closed subspace of the Hilbert space as it can be characterized by the 1-Eigenspace of the operator \(wp\llbracket S \rrbracket (\boldsymbol{I})\). In contrast, the space of states for which a program is PAST is a subspace but not necessarily closed (as it can be characterized by the domain of the bounded operator \(wp\llbracket T({S}) \rrbracket (\boldsymbol{0})^{\frac{1}{2}}_\infty\)). An example of a non-closed subspace is given in Section 8.
This section generalizes the transformers in [2] by lifting the restriction to finite dimensional Hilbert spaces, AST programs and bounded operators. First, we give a forward transformer \(ERT\llbracket S \rrbracket\) of the expected runtime. Then we give an alternative backward transformer of the expected runtime \(ert\llbracket S \rrbracket\) that maps an operator \(A\) to an operator that gives the expected runtime plus the "post" \(A\) after termination. Finally, we show that this backward definition is equivalent to the forward definition and also to the weakest pre-expectation of the transformed program \(T({S})\) defined in Table 2. Proofs can be found in Appendix 14.
First, we adapt Definition 3.1 from [2] to our infinite-dimensional setting:
Lemma 8. The forward expected runtime of reward-free qrWhile program \(S\) on input \(\rho \in \mathcal{D}(\mathcal{H})\) is given by \(ERT\llbracket S \rrbracket (\rho)\) where \(ERT\llbracket S \rrbracket (\cdot): \mathcal{D}(\mathcal{H}) \to \mathbb{R}_{\geq 0}^\infty\) is defined by:
\(ERT\llbracket \boldsymbol{skip} \rrbracket (\rho) = 0\)
\(ERT\llbracket q:=0 \rrbracket (\rho) = tr(\rho)\)
\(ERT\llbracket \overline{q}:= U\overline{q} \rrbracket (\rho) = tr(\rho)\)
\(ERT\llbracket S_1;S_2 \rrbracket (\rho) = ERT\llbracket S_1 \rrbracket (\rho) + ERT\llbracket S_2 \rrbracket (\llbracket S_1 \rrbracket_D(\rho))\)
\(ERT\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S} \rrbracket (\rho) = tr(\rho) + \sum_{m} ERT\llbracket S_m \rrbracket (M_m \rho M_m^\dagger)\)
\(ERT\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (\rho) = \lim_{n \to \infty} ERT\llbracket while^{[n]} \rrbracket (\rho)\) where \[\begin{align} while^{[0]} &= \boldsymbol{skip}\\ while^{[n+1]} &= \boldsymbol{measure } M[\overline{q}]:\overline{S}\text{ with } S_0 = \boldsymbol{skip}\text{ and } S_1 = S;while^{[n]} \end{align}\]
Based on this forward transformer, we can also give a backward definition of the expected runtime using the same idea as used in weakest preconditions analogous to probabilistic expected runtime transformers [14]6. The transformer \(ert\llbracket S \rrbracket\) as defined in Table 3 maps an operator \(A\) to an operator that gives the expected runtime plus the "post" \(A\) after termination, in this case we set \(A=\boldsymbol{0}\) initially.
| \(\skipbf\) | \(B\) |
| \(\qzero\) | \(\displaystyle \identityOp \sumform \sum_{n=0}^\infty \ket{n}\bra{0} \odot B \odot \ket{0}\bra{n}\) |
| \(\Uq\) | \(\identityOp\sumform \formsandwich{U}{B}\) |
| \(\concat\) | \(\ert{S_1}{\ert{S_2}{B}}\) |
| \(\measurePrime\) | \(\displaystyle \identityOp \sumform \left(\sum_{m} \formsandwich{M_m}{\ert{S_m'}{B}} \right)\) |
| \(\while'\) | \(\displaystyle \bigvee_n F_n \quad \text{where }\) |
| \(F_0 = \zeroOp,\; F_{n+1} = \formsandwich{M_0}{B} \sumform \formsandwich{M_1}{\ert{S'}{F_n}} \sumform \identityOp\) | |
8pt
Now we show healthiness properties of the expected runtime transformer:
Let \(S\) be a reward-free qrWhile program, \(A,B \in \mathcal{E}(\mathcal{H})\) and \(c\geq 0\). The expected runtime transformer \(ert\) satisfies:
Well-definedness: \(ert\llbracket S \rrbracket (A) \in \mathcal{E}(\mathcal{H})\)
Connection to wp: \(ert\llbracket S \rrbracket (A) = wp\llbracket S \rrbracket (A) \oplus ert\llbracket S \rrbracket (\boldsymbol{0})\)
Monotonicity: \(A \sqsubseteq B\) implies \(ert\llbracket S \rrbracket (A) \sqsubseteq ert\llbracket S \rrbracket (B)\)
Continuity: \(ert\llbracket S \rrbracket (\bigvee_i A_i) = \bigvee_i ert\llbracket S \rrbracket (A_i)\) for any increasing chain \(\{A_i\}_i\) of expectations.
Constant propagation: \(ert\llbracket S \rrbracket (c\cdot A) = c\cdot A \oplus ert\llbracket S \rrbracket (\boldsymbol{0})\)
Preservation of infinity: \(ert\llbracket S \rrbracket (\boldsymbol{\infty}) = \boldsymbol{\infty}\)
Now we can show that the expected runtime transformer actually computes the expected runtime of a program as defined in Definition 14 (i.e., that it is equivalent to the weakest pre-expectation of the transformed program \(T({S})\) as in Theorem 5):
Theorem 6. Let \(ert\llbracket S \rrbracket: \mathcal{E}(\mathcal{H})\to \mathcal{E}(\mathcal{H})\) be defined as in Table 3 and \(A \in \mathcal{E}(\mathcal{H})\). Then \(ert\llbracket S \rrbracket (A)= wp\llbracket T({S}) \rrbracket (A)\) for any reward-free qrWhile program \(S\).
We can also show the consistency between Table 3 and Lemma 8 (analogous to [2]):
Theorem 7. Let \(S\) be a reward-free qrWhile program and \(\rho \in \mathcal{D}(\mathcal{H})\). Then \(\mathbb{E}_{ert\llbracket S \rrbracket (\boldsymbol{0})}\left(\rho\right) = ERT\llbracket S \rrbracket (\rho)\).
This result together with [2] shows that our operator-based definition of the expected runtime transformer coincides with the operator-based definition [2] for finite-dimensional, reward-free AST programs.
Using the equivalences above, we can show that whenever the expected runtime of a program is finite (i.e., the program is PAST), it terminates with probability 1 and thus is AST as well:
Lemma 9. Let \(S\) be a reward-free qrWhile program and \(\rho \in \mathcal{D}(\mathcal{H})\). If \(\text{ }S\) is PAST on \(\rho\), then \(S\) is AST on \(\rho\).
The other direction does not hold, as there are programs that are AST on a state but not PAST on the same state (e.g., the examples presented in Section 8).
Similar as in [14] for the probabilistic case, we can use the idea of Park Induction (Proposition [prop:park]) for bounds of the expected runtime. First we define the characteristic functional for the while-loop \(\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S\): \[\Psi_B (A) = \boldsymbol{I}\oplus M_0^\dagger \odot B \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S \rrbracket (A) \odot M_1\]
Based on this, we can consider Park induction for expected runtime. Intuitively, it means that if we can find an operator \(A\) such that \(\Psi_B(A) \sqsubseteq A\) holds, then \(A\) is an upper bound on the expected runtime of the while-loop. This can be used to give upper bounds on the expected runtime without having to compute the exact least upper bound, which is often more difficult.
Let \(\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S\) be a reward-free while-loop in qrWhile and \(A, B \in \mathcal{E}(\mathcal{H})\). If \(\Psi_B(A) \sqsubseteq A\), then \(ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (B) \sqsubseteq A\).
In this section we present two example programs and analyze their expected runtime and termination behavior. The first example is a program with infinite expected runtime but that terminates with probability 1 which consists of two while-loops executed after each other. We will also analyze the runtime of both while-loops separately.
The second example is a variant of the infinite quantum walk where the walker can only move in one direction or stay at its position. We will analyze the expected runtime of this program and show that it is partially non-AST, partially AST but not PAST and partially PAST, i.e., there are input states where the probability of termination is smaller than \(1\), there are other states that terminate with probability \(1\) but have infinite expected runtime and there are states that terminate with probability \(1\) and have finite expected runtime.
Omitted calculations can be found in Appendix 15. Note that in this section we write \(+\) instead of \(\oplus\) and leave \(\odot\) out for better readability.
As mentioned earlier, there are programs in the infinite-dimensional setting with infinite expected runtime but that terminate with probability 1. In this section, we present an example of such a program and analyze its expected runtime and termination behavior.
We adapt the probabilistic program from [14] to the quantum setting. It is used to illustrate that probabilistic PAST is not preserved under sequential composition. In the quantum analog we have two variables, one is a qubit \(q_2\) that we use to simulate the coin flip and the other one is a quantum integer \(q_1\) that we use as integer variable (allowing only non-negative values). The quantum program can be found in Figure 1.
None
Figure 1: A quantum program where \(U_2\) maps \(\ket{n}\) to \(\ket{2n}\) and \(U_{-1}\) maps \(\ket{n}\) to \(\ket{n-1}\) (to make them unitary, one can for example add ancilla qubits which we omit to not complicate the analysis). The measurement operators are \(M_0 = \ket{0}\bra{0}\), \(M_1 = \ket{1}\bra{1}\) for the first loop on variable \(q_2\) and \(M_0 = \ket{0}\bra{0}\), \(M_1 = \boldsymbol{I}- \ket{0}\bra{0}\) for the second loop on variable \(q_1\)..
First we consider the sub programs and analyze their expected runtime. Computing the concrete runtime of a while-loop is quite complex as it involves computing the least upper bound of a sequence, so we use Park induction.
We start with the first while-loop \(L_1\). The characteristic functional is given by \[\begin{align} \Psi_\boldsymbol{0}(A) =&\text{ } \boldsymbol{I}+ M_0^\dagger \boldsymbol{0}M_0 + M_1^\dagger ert\llbracket S \rrbracket (A) M_1 \\ =&\text{ } \boldsymbol{I}+ 2 \boldsymbol{I}\otimes \ket{1}\bra{1} + (\boldsymbol{I}\otimes \ket{1}\bra{1})(U_2^\dagger \otimes H^\dagger) A (U_2 \otimes H) (\boldsymbol{I}\otimes\ket{1}\bra{1}) \end{align}\]
For the loop invariant \(A= \boldsymbol{I}+ 6(\boldsymbol{I}\otimes \ket{1}\bra{1})\), we have \[\begin{align} \Psi_\boldsymbol{0}(A) = &\text{ } \boldsymbol{I}+ 2 \boldsymbol{I}\otimes \ket{1}\bra{1} + (\boldsymbol{I}\otimes \ket{1}\bra{1})(U_2^\dagger \otimes H^\dagger) (\boldsymbol{I}+ 6(\boldsymbol{I}\otimes \ket{1}\bra{1})) (U_2 \otimes H) (\boldsymbol{I}\otimes\ket{1}\bra{1}) \\ =&\text{ } \boldsymbol{I}+ 6(\boldsymbol{I}\otimes \ket{1}\bra{1}) = A \end{align}\] So we have \(\Psi_\boldsymbol{0}(A) \sqsubseteq A\) and thus by Park induction \(ert\llbracket L_1 \rrbracket (\boldsymbol{0}) \sqsubseteq A\). That means for every initial state with \(\ket{1}\) on the second variable, the expected runtime of the first while-loop is at most 7, with \(\ket{0}\) on the second variable it is at most \(1\). If we assume the initialization to be part of this program, we are in the first case. In any case, the expected runtime is finite, i.e., the subprogram is PAST.
Similarly, we can analyze the second while-loop \(L_2\) where we only need to consider one variable. The characteristic functional is given by \[\begin{align} \Psi_\boldsymbol{0}(A) =&\text{ } \boldsymbol{I}+ M_0^\dagger \boldsymbol{0}M_0 + M_1^\dagger ert\llbracket S \rrbracket (A) M_1 = \boldsymbol{I}+ (\boldsymbol{I}- \ket{0}\bra{0}) + (\boldsymbol{I}- \ket{0}\bra{0}) U_{-1}^\dagger A U_{-1} (\boldsymbol{I}- \ket{0}\bra{0}) \end{align}\] Using the loop invariant \(A = \sum_{k=0}^{\infty} (2k+1) \ket{k}\bra{k}\), we have \[\begin{align} \Psi_\boldsymbol{0}(A) =&\text{ } \boldsymbol{I}+ (\boldsymbol{I}- \ket{0}\bra{0}) + (\boldsymbol{I}- \ket{0}\bra{0}) U_{-1}^\dagger \left(\sum_{k=0}^{\infty} (2k+1) \ket{k}\bra{k}\right) U_{-1} (\boldsymbol{I}- \ket{0}\bra{0})\\ =& \sum_{k=0}^{\infty} \ket{k}\bra{k} + \sum_{k=1}^{\infty} \ket{k}\bra{k} + \sum_{k=1}^{\infty} (2k - 1) \ket{k}\bra{k} = \sum_{k=0}^{\infty} (2k+1) \ket{k}\bra{k} = A \end{align}\] By Park induction \(ert\llbracket L_2 \rrbracket (\boldsymbol{0}) \sqsubseteq A\). This operator is unbounded in general, that means the program is not PAST (or at least we cannot show it with this invariant). In the probabilistic setting we get a finite runtime because for every (classical) basis state \(\ket{n}\), we have \(\mathbb{E}_{A}\left(\ket{n}\bra{n}\right) = 2n+1\) which is a finite upper bound on the runtime. As in this algorithm, \(q_1\) will always have a classical value (something like \(\ket{n}\)), we can conclude that the expected runtime of the second while-loop is finite for every reachable state. The difference is that in the quantum setting, the expected runtime can still be infinite for certain superpositions, e.g., for a state \(\sum_{n=1}^{\infty} \frac{\alpha}{n^2} \ket{n}\bra{n}\) (with suitable \(\alpha\)), the expected runtime could be infinite as shown in the next example.
We now show that the whole program has infinite expected runtime. Park induction would only give us an upper bound on the expected runtime, so we have to compute the expected runtime of the whole program directly to show that it is infinite. To start the analysis, we determine \(ert\llbracket L_2 \rrbracket (\boldsymbol{0}) = \bigvee_n P_n\). Intuitively, \(L_2\) decrements the quantum integer \(q_1\) until it reaches \(\ket{0}\), i.e. its runtime is the current value of \(q_1\). As shown in Appendix 15.1, we have \[ert\llbracket L_2 \rrbracket (\boldsymbol{0}) = \bigvee_{n=0}^\infty P_n = \lim_{n\to\infty} \left((n+1)\boldsymbol{I}- \sum_{k=0}^{n-1} (n-k)\ket{k}\bra{k}\right):= W_1\] To compute this limit, we can look at the expectation value on a basis state \(\ket{m}\): \[\begin{align} \mathbb{E}_{ert\llbracket L_2 \rrbracket (\boldsymbol{0})}\left(\ket{m}\bra{m}\right) &= \lim_{n\to\infty} \left((n+1) - (n-m)\right) = \lim_{n\to\infty} (m+1) = m+1 \end{align}\] This coincides with the result one would expect intuitively, as the runtime of the loop is exactly the current value of \(q_1\) plus one for the final check. Note that so far we only considered the variable \(q_1\), the other variable \(q_2\) did not matter for this loop, so we have \(\boldsymbol{I}\) on the other variable.
Now we can analyze the first while-loop \(L_1\). As shown in Appendix 15.1, we have \[\begin{align} &ert\llbracket L_1 \rrbracket (W_1 \otimes \boldsymbol{I}) = \bigvee_{n=0}^\infty Q_n \\ =& \lim_{n\to\infty} \left( \left(\left(6 - \frac{8}{2^n} \right) \boldsymbol{I}+ \sum_{k=1}^{n-1} (\frac{1}{2} U_2^\dagger)^k W_1 U_2^k \right)\otimes \ket{1}\bra{1} + \boldsymbol{I}+ W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \right) := W_2 \end{align}\]
Before this loop, the program only sets \(q_1\) and \(q_2\) to \(\ket{1}\). To get the expected runtime of the entire program, we determine \(ert\llbracket q_1:= \ket{1}; q_2:= \ket{1} \rrbracket (W_2)\) or, equivalently, the expected runtime of the program afterwards with fixed input \(\ket{1}\) for both variables which is simpler in this case. That means the expected runtime of the full program is given by \(W_2\) evaluated on the state \(\ket{1}\otimes \ket{1}\). To compute this, we can look at the expectation value: \[\begin{align} &\mathbb{E}_{ert\llbracket L_1 \rrbracket (\boldsymbol{0})}\left(\ket{1}\bra{1} \otimes \ket{1}\bra{1}\right) = \lim_{n\to\infty} 7 - \frac{8}{2^n} + n-2 + \frac{1}{2^{n-1}} = \infty. \end{align}\] Overall, the expected runtime of this program is infinite. If we would have other initial values of \(q_1\) and \(q_2\), computing the expected runtime would influence only the last equation in comparison to [2] where the whole calculation would need to be redone.
To complete our analysis, we show the program to be AST by using the fact that \(wp\llbracket S \rrbracket (\boldsymbol{I}) = \boldsymbol{I}\) implies AST. We compute \(wp\llbracket L_2 \rrbracket (\boldsymbol{I}) = \bigvee_n P_n\) first only for \(q_1\) with \[\begin{align} P_0 &= \boldsymbol{0}\\ P_{n+1} &= M_0^\dagger \boldsymbol{I}M_0 + M_1^\dagger wp\llbracket S \rrbracket (P_n) M_1 \\ &= \ket{0}\bra{0} + (\boldsymbol{I}- \ket{0}\bra{0}) wp\llbracket q_1 := U_{-1} q_1 \rrbracket (P_n) (\boldsymbol{I}- \ket{0}\bra{0}) \\ &= \ket{0}\bra{0} + (\boldsymbol{I}- \ket{0}\bra{0}) U_{-1}^\dagger P_n U_{-1} (\boldsymbol{I}- \ket{0}\bra{0}) \end{align}\] Then we obtain \(P_n = \ket{0}\bra{0} + \ket{1}\bra{1} + \dots + \ket{n-1}\bra{n-1}\) and overall we have \(wp\llbracket L_2 \rrbracket (\boldsymbol{I}) = \bigvee_n P_n = \boldsymbol{I}\).
For the first while loop, we have \(wp\llbracket L_1 \rrbracket (\boldsymbol{I}\otimes \boldsymbol{I}) = \bigvee_n P_n\) with \[\begin{align} P_0 &= \boldsymbol{0}\\ P_{n+1} &= M_0^\dagger \boldsymbol{I}M_0 + M_1^\dagger wp\llbracket S \rrbracket (P_n) M_1 \\ &= \boldsymbol{I}\otimes \ket{0}\bra{0} + (\boldsymbol{I}\otimes \ket{1}\bra{1} ) wp\llbracket q := H q; q_1 := U_2 q_1 \rrbracket (P_n) (\boldsymbol{I}\otimes \ket{1}\bra{1}) \\ &= \ket{0}\bra{0} \otimes \boldsymbol{I}+ (\boldsymbol{I}\otimes \ket{1}\bra{1}) ( U_2^\dagger \otimes H^\dagger) P_n (U_2 \otimes H) (\boldsymbol{I}\otimes \ket{1}\bra{1}) \end{align}\] with the closed form being \(P_n = \boldsymbol{I}\otimes \left(\ket{0}\bra{0} + \left(1 - \frac{1}{2^n}\right) \ket{1}\bra{1}\right)\) and overall \(wp\llbracket L_1 \rrbracket (\boldsymbol{I}) = \bigvee_n P_n = \boldsymbol{I}\). Together with the first two initializations, \(wp\llbracket S \rrbracket (\boldsymbol{I}) = \boldsymbol{I}\).
In this section we present a variant of the quantum walk on an one-side bounded infinite line that, in comparison to the standard version, does not spread in both direction but only in one direction or stays at its position. The program consists of two variables, one is a quantum integer \(q\) (that can also take negative values now) that we use to simulate the position of the walker and the other one is a qubit \(c\) that we use to simulate the coin flip. We define the (controlled) shift operator \(S\) as follows: \(S\ket{n}\ket{0} = \ket{n-1}\ket{0}, S\ket{n}\ket{1} =\ket{n}\ket{1}\). Then we can define the program \(P_1\) as follows: \[\begin{align} & c:= \ket{0}; \\ & \boldsymbol{while } M[q] \boldsymbol{ do }\{ \\ &c := H c; \\ &q c := S q c; \\ & \} \end{align}\] with \(M_0 = \ket{0}\bra{0}\), \(M_1 = \boldsymbol{I}- \ket{0}\bra{0}\). In each iteration, we apply a Hadamard gate to the coin to create an equal superposition of \(\ket{0}\) and \(\ket{1}\) and then apply the shift operator to move left or do nothing according to the coin.
Intuitively, if the program starts in a state \(\ket{n}\) with \(n<0\), it will never terminate as the walker will always move left and never reach \(\ket{0}\). This also holds for superpositions or mixed states that have a non-zero probability of being in a state \(\ket{n}\) with \(n<0\). We can show that the program is non-AST for those states and AST for all other states by calculating \(wp\llbracket P_1 \rrbracket (\boldsymbol{I})\). The characteristic function is given by \[\begin{align} \psi_\boldsymbol{I}(A) =&\text{ } M_0^\dagger \boldsymbol{I}M_0 + M_1^\dagger (\boldsymbol{I}\otimes H)S^\dagger A S (\boldsymbol{I}\otimes H) M_1 \\ =&\ket{0}\bra{0} \otimes \boldsymbol{I}+ ((\boldsymbol{I}- \ket{0}\bra{0})\otimes H)S^\dagger A S ((\boldsymbol{I}- \ket{0}\bra{0}) \otimes H) \end{align}\] We can show that \(A = (\boldsymbol{0}_{<0} + \boldsymbol{I}_{\geq 0}) \otimes \boldsymbol{I}= \boldsymbol{I}_{\geq 0} \otimes \boldsymbol{I}\) is a fixed point of \(\psi_\boldsymbol{I}\) (see Appendix 15.2). Thus \(wp\llbracket P_1 \rrbracket (\boldsymbol{I}) \sqsubseteq (\boldsymbol{0}_{<0} + \boldsymbol{I}_{\geq 0}) \otimes \boldsymbol{I}\) and thus it cannot be AST for states \(\ket{n}\) with \(n<0\). For states \(\ket{n}\) with \(n\geq 0\), we have just shown \(\boldsymbol{I}\) to be an upper bound, thus we cannot follow directly that the program is AST for those states. However, we show now that the expected runtime is finite for states \(\ket{n}\) with \(n\geq 0\) thus the program is AST for those states and automatically for all superpositions of those as well. To do so, we use the ert-calculus with Park induction. The characteristic functional is given by \[\begin{align} \Psi_\boldsymbol{0}(A) =& \text{ }\boldsymbol{I}+ M_0^\dagger \boldsymbol{0}M_0 + M_1^\dagger ert\llbracket S \rrbracket (A) M_1 \\ =& \text{ }3 \boldsymbol{I}- 2 \ket{0}\bra{0} \otimes \boldsymbol{I}+ ((\boldsymbol{I}- \ket{0}\bra{0})\otimes H)S^\dagger A S ((\boldsymbol{I}- \ket{0}\bra{0}) \otimes H) \end{align}\]
Now we want to find \(A\) such that \(\Psi_\boldsymbol{0}(A) \sqsubseteq A\). To do so, we consider the ansatz7 \[\begin{align} A = \sum_{n=0}^\infty a_n \ket{n}\bra{n} \otimes \ket{0}\bra{0} + \sum_{n=0}^\infty b_n \ket{n}\bra{n} \otimes \ket{1}\bra{1} + \boldsymbol{0}|_{\geq 0} \end{align}\] where \(\boldsymbol{0}|_{\geq 0} = (\sum_{n=-\infty}^{-1} \infty \ket{n}\bra{n}+\sum_{n=0}^\infty 0\ket{n}\bra{n}) \otimes \boldsymbol{I}\) is added to ensures that negative values are handled correctly as we know that their expected runtime is infinite. Besides of that part, we choose a diagonal ansatz to keep it simple and figured out that \(\sum_{n=0}^\infty a_n \ket{n}\bra{n} \otimes \boldsymbol{I}\) does not work, so we split the qubit into the two cases of \(\ket{0}\) and \(\ket{1}\), which makes sense as \(S\) depends on the value of the qubit. We used the ansatz and solved \(\Psi_\boldsymbol{0}(A) \sqsubseteq A\) for the minimal solution of \(a_n \geq 0\) which is \(2n(6+3\sqrt{2}) +1\). For this choice of \(a_n\), \((2n-1)(6+3\sqrt{2}) +1\) is the only choice for \(b_n\). Details can be found in Appendix 15.2. As these values are surprisingly high (i.e., \(a_1>20\) which means that on average we need more than 20 steps to go from \(\ket{1}\) to \(\ket{0}\) where each loop-iteration takes \(3\) steps), we suspect that there is a better invariant using a different ansatz. As for our purpose it is enough to show that the expected runtime is finite, we did not further optimize this invariant.
Using \(A\) with the values from above and Park induction, we get \(\mathbb{E}_{ert\llbracket P_1 \rrbracket (\boldsymbol{0})}\left(\ket{n}\bra{n} \otimes \ket{\psi}\bra{\psi}\right) \leq 2n(6+3\sqrt{2}) + 2\) for \(n \geq 0\) and any state \(\psi\), i.e., the expected runtime is finite for all states where \(q = \ket{n}\) with \(n \geq 0\).
It is \(B = \sum_{n=0}^{\infty}n \ket{n}\bra{n} \otimes \boldsymbol{I}\sqsubseteq ert\llbracket P_1 \rrbracket (\boldsymbol{0})\) (see Appendix 15.2), so the runtime (even besides the negative part) is not bounded. In fact, the same phenomenon occurs as in the previous example: The expected runtime is finite for all basis states \(\ket{n}\) with \(n>0\) but still infinite for (some) superpositions of these. The expected runtime of state \(\sum_{n=1}^{\infty} \frac{\alpha}{n^2} \ket{n}\bra{n}\) (with suitable \(\alpha\)) is lower bounded by \[\begin{align} \mathbb{E}_{B}\left(\sum_{n=0}^{\infty} \frac{\alpha}{n^2} \ket{n}\bra{n} \otimes \ket{0}\bra{0}\right) = \sum_{n=0}^{\infty} \frac{\alpha n}{n^2} \to \infty \end{align}\]
Thus we have shown that the program is non-AST for states \(\ket{n}\) with \(n<0\) (and superpositions including those states), PAST and AST for states \(\ket{n}\) with \(n\geq 0\) and AST (but not PAST) for all superpositions of those states.
If we consider an AST variant of the program where the loop is only entered with states \(\ket{n}\) with \(n> 0\), i.e., we change the behavior on the negative positions, we would change the loop guard to \(M_0 = \sum_{n=-\infty}^0 \ket{n}\bra{n}\) and \(M_1 = \sum_{n=1}^{\infty} \ket{n}\bra{n}\). Then we can still reuse the same invariant by removing \(\boldsymbol{0}|_{\geq 0}\) and obtain similar results (except for the negative part where the runtime would be finite).
We considered quantum programs with rewards in infinite-dimensional spaces and defined semantic properties that should hold in this setting. We gave a concrete syntax and denotational semantics for qrWhile programs with rewards. The main contribution of this paper is the definition of weakest pre-expectations both semantically for quantum programs with rewards and syntactically for qrWhile programs. We dropped the condition of boundedness of the expectation which was required in previous work and this more general definition allows us to reason about runtimes without restricting to finite expected runtimes. We gave some simple loop rules to bound both the weakest preconditions and the expected runtimes of loops to avoid heavy calculations. Finally, we considered two example programs and analyzed their expected runtime and termination probability using the tools we developed which would not have been possible using existing work. Our goal was to keep the same style of weakest preconditions as in the finite-dimensional case [1] and thus allow for unbounded operators as expectations in comparison to [19]. This allows us to capture expected runtimes and reward statements in a natural way.
For future work, it would be interesting to consider more general semantic properties of quantum programs with rewards, e.g., not only track the expected reward but instead the distribution of rewards. An approach as [35] allows to analyze higher moments of the reward distribution which gives more information about the behavior of the program.
Of course, it is also interesting to combine our weakest pre-expectations approach and the runtime analysis methods with other features of quantum programming languages, e.g., non-determinism [12], classical variables [11], observations [13], etc. for which we already know how to define semantics and (bounded) weakest preconditions. Another interesting direction is to find a suitable representation language for expectations which is one of the first steps towards developing an automated tool.
This work is supported by the European Union’s Horizon 2020 research and innovation programme under the Marie Skłodowska-Curie grant agreement No. 101008233 (MISSION), and the Interdisciplinary Doctoral Program in Quantum Systems Integration funded by the BMW group.
In this section we give additional proof details about expectations and expectation values.
Proof of Proposition [prop:OpstoForms]:
Proof. We use the following theorem ([28] and [30]): "For every positive self-adjoint operator \(A\), there is a corresponding densely defined, closed, symmetric, positive form \(a: \mathfrak{D}(a) \times \mathfrak{D}(a) \to \mathbb{C}\) with \(a[x,y] = \langle A^{\frac{1}{2}}x, A^{\frac{1}{2}}y\rangle\) for all \(x,y \in \mathfrak{D}(a) = \mathfrak{D}(A^{\frac{1}{2}})\) and the other way round."
We show that this theorem implies the proposition:
\(\Rightarrow\): For every expectation \(A\) there is the positive, self-adjoint \(\infty\)-restriction \(A_\infty\). By the above theorem, there is a corresponding densely defined, closed, symmetric, positive form \(a\), thus also a form-expectation.
\(\Leftarrow\): For every form-expectation \(a\), we can construct a densely defined form by extending \(a\) to the closure of its domain (that means \(\mathfrak{D}(a)\) is dense in \(\overline{\mathfrak{D}(a)}\)). By the above theorem, there is a corresponding positive self-adjoint operator \(A_\infty\). We obtain \(A \in \mathcal{E}(\mathcal{H})\) by extending the \(\infty\)-restriction \(A_\infty\) to \(\mathcal{H}\).
◻
Proof of Theorem 1:
Proof. Let \(\{A_n\}_n\) be an increasing sequence of expectations over \(\mathcal{H}\). That means every \(A_n\) is positive and \(\infty\)-self-adjoint and \(A_n \sqsubseteq A_{n+1}\) holds for all \(n\).
For each \(A_n\), there is the corresponding form-expectation \(a_n\) by Proposition [prop:OpstoForms].
\(a_n \leq a_{n+1}\) holds exactly if \(A_n \sqsubseteq A_{n+1}\) by Proposition [prop:orderEquivalence]. Thus \(\{a_n\}_n\) is a monotone non-decreasing sequence of closed, symmetric forms bounded from below.
We use Kato’s theorem [28]: "Let \(a_1 \leq a_2 \leq ...\) be a monotone non-decreasing sequence of closed symmetric forms bounded from below. Set \(a[x] = \lim a_n[x]\) whenever the finite limit exists. \(a\) is a closed symmetric form bounded from below." As each \(a_n\) is positive, \(a\) is positive as well. Thus \(a \in \mathcal{F}(\mathcal{H})\). Note that \(\mathfrak{D}(a)\) might not be dense in \(\mathcal{H}\), but it is dense in \(\overline{\mathfrak{D}(a)}\).
We use this limit form and define the corresponding expectation \(A\) according to Proposition [prop:OpstoForms].
Then \(A_\infty\) is the self-adjoint operator that corresponds to the limit form [28] and as each \(A_n\) is positive, it is also positive.
Then \(A\) is an expectation with \(A x = A_\infty x\) for all \(x \in \mathfrak{D}(A) = \mathfrak{D}(A_\infty)\).
Now we show that \(A\) is indeed the least upper bound of the sequence \(A_n\):
By [enum46order], we have \(A_n \sqsubseteq A\) for all \(n\) because \(a_n \leq a\) for all \(n\). That means \(A\) is an upper bound of the sequence \(A_n\).
Now it remains to show that it is the least upper bound. Let \(B: \mathfrak{D}(B) \to \mathcal{H}\) be another expectation with \(A_n \sqsubseteq B\) for all \(n\) (a possible other smaller upper bound). Then by [enum46order], it is \(a_n \leq b\) for all \(n\) where \(b\) is the form-expectation that corresponds to \(B\). Thus, by the definition of the limit form, it is \(a \leq b\). Again by [enum46order], this implies \(A \sqsubseteq B\).
Convergence on the form-level is pointwise convergence, i.e., \(a[x] = \lim_n a_n[x]\) for all \(x \in \mathfrak{D}(a)\). For the corresponding expectations, this implies convergence in WOT: \[\begin{align} &\text{ }\forall x \in \mathfrak{D}(A): a_n[x] \to a[x] \\ \Rightarrow & \text{ }\forall x,y \in \mathfrak{D}(A): a_n[x,y] \to a[x,y] \\ \Rightarrow &\text{ }\forall x,y \in \mathfrak{D}(A): \langle x, A_n y\rangle \to \langle x, A y\rangle \\ \Rightarrow &\text{ }A_n \to A \text{ in WOT} \end{align}\]
Overall, the proof steps are visualized in the diagram in Figure 2.
◻
Proof of Proposition [prop:FormAddMult]:
Proof.
To show: \(a+b\) is a form-expectation. Recall, \(a+b\) is defined as the form \(c: \mathfrak{D}(c) \times \mathfrak{D}(c) \to \mathbb{C}\) with \[\begin{align} \mathfrak{D}(c) = \mathfrak{D}(a) \cap \mathfrak{D}(b), c[x,y] = a[x,y] + b[x,y] \end{align}\] The definition of the sum is the same as in [28] (called ‘generalized sum’). By [28] is \(c\) closed. Symmetry follows from the symmetry of \(a\) and \(b\) and positivity from the positivity of \(a\) and \(b\).
To show: \(\alpha \cdot a\) is a form-expectation. Recall, \(\alpha \cdot a\) is defined as the form \(\alpha \cdot a: \mathfrak{D}(\alpha \cdot a) \times \mathfrak{D}(\alpha \cdot a) \to \mathbb{C}\) with \[\begin{align} \mathfrak{D}(\alpha \cdot a) = \mathfrak{D}(a),(\alpha \cdot a)[x,y] = \alpha \cdot a[x,y] \end{align}\]
Symmetry follows from the symmetry of \(a\), as \((\alpha \cdot a)[x,y] = \alpha \cdot a[x,y] = \alpha \cdot \overline{a[y,x]} = \overline{(\alpha \cdot a)[y,x]}\) and \(\alpha\) is real.
Positivity follows from the positivity of \(a\), as \((\alpha \cdot a)[x] = \alpha \cdot a[x] \geq 0\) for all \(x \in \mathfrak{D}(\alpha \cdot a)\) and \(\alpha \geq 0\).
Closeness follows from the closeness of \(a\) as every sequence \(\{x_n\}_n\) in \(\mathfrak{D}(\alpha \cdot a)\) with \(x_n \underset{t}{\to} x\) also is a sequence in \(\mathfrak{D}(a)\) with \(x_n \underset{t}{\to} x\). Thus we have \(x\in \mathfrak{D}(\alpha \cdot a) = \mathfrak{D}(a)\) and \((\alpha \cdot a)[x_n - x_m] = \alpha \cdot a[x_n - x_m]\to 0\) for \(n,m \to \infty, \alpha\geq 0\). Thus \(\alpha \cdot a\) is closed.
To show: \(a_M\) is a form-expectation. Recall, \(a_M\) is defined as the form \(a_M: \mathfrak{D}(a_M) \times \mathfrak{D}(a_M) \to \mathbb{C}\) with \[\begin{align} \mathfrak{D}(a_M) = \{ \psi \in \mathcal{H}\mid M\psi \in \mathfrak{D}(a)\}, a_M[x,y] = a[Mx, My] \end{align}\] Note that \(\bra{\psi} M^\dagger \odot A \odot M \ket{\psi} = \bra{M\psi} A \ket{M\psi}\).
Symmetry follows from the symmetry of \(a\), as \(a_M[x,y] = a[Mx, My] = \overline{a[My, Mx]} = \overline{a_M[y,x]}\).
Positivity follows from the positivity of \(a\), as \(a_M[x] = a[Mx] \geq 0\) for all \(x \in \mathfrak{D}(a_M)\).
Closeness follows from the closeness of \(a\): Let \(\{x_n\}_n\) be a sequence in \(\mathfrak{D}(a_M)\) with \(x_n \underset{t}{\to} x\). That means \(x_n \in \mathfrak{D}(a_M)\), \(x_n \to x\) and \(a_M[x_n - x_m] \to 0\) for \(n,m \to \infty\). We need to show that \(x \in \mathfrak{D}(a_M)\) and \(a_M[x_n - x] \to 0\) for \(n \to \infty\). It is \(a_M[x_n - x_m]=a[M(x_n-x_m)]\), so \(a[x_n-M x_m] \to 0\) and \(Mx_n \in \mathfrak{D}(a)\) for all \(n\). As \(M\) is bounded (thus continuous), \(Mx_n \to Mx\). By the closeness of \(a\), it is \(Mx \in \mathfrak{D}(a)\) and \(a[Mx_n - Mx] \to 0\) for \(n \to \infty\). Thus \(x \in \mathfrak{D}(a_M), Mx_n \to Mx\) and \(a_M[x_n - x] \to 0\) for \(n \to \infty\). By the closeness of \(a\), we get \(Mx \in \mathfrak{D}(a)\) and thus \(x \in \mathfrak{D}(a_M)\). Thus \(a_M\) is closed.
◻
Proof of Lemma 1:
Proof. As \(A_n \in \mathcal{E}(\mathcal{H})\), each \(A_n\) is positive. Thus \(\{\sum_{n=0}^N A_n \}_N\) with \(\sum_{n=0}^N A_n = A_0 \oplus A_1 \oplus... \oplus A_N\) is an increasing sequence. All sums are finite and thus in \(\mathcal{E}(\mathcal{H})\) by Definition 5. By Theorem 1, this sequence has a least upper bound/limit \(\lim_{N \to \infty} \sum_{n=0}^N A_n \in \mathcal{E}(\mathcal{H})\). As convergence in WOT considers sequences of (extended) reals, this limit coincides with \(\sum_{n=0}^\infty A_n\) and as the limit is an expectation, \(\sum_{n=0}^\infty A_n \in \mathcal{E}(\mathcal{H})\). ◻
Proof of Proposition [prop:ContinuityDistributivityFormSum]:
Proof. Let \(a, a_n, b, b_n\) be the corresponding form-expectations of \(A, A_n, B, B_n\).
\(\left(\bigvee A_n \right)\oplus B = \bigvee \left(A_n \oplus B\right)\):
Let \(\bigvee A_n = A\). By Proposition [prop:orderEquivalence], \(a_n \leq a_{n+1}\) for all \(n\) and \(\bigvee a_n = a\) by the definition of the limit form. It is \(\mathfrak{D}(a) = \{x \in \bigcap_n \mathfrak{D}(a_n) \mid \bigvee a_n[x] < \infty\}\) and \(a[x,y] = \bigvee a_n[x,y]\). We show that both sides correspond to the same form and thus to the same operator by Proposition [prop:OpstoForms]:
The form that corresponds to \(\left(\bigvee A_n \right)\oplus B = A \oplus B\) is \(c: \mathfrak{D}(c) \times \mathfrak{D}(c) \to \mathbb{C}\) with \[\begin{align} \mathfrak{D}(c) &= \mathfrak{D}(a) \cap \mathfrak{D}(b)\\ c[x,y] &= a[x,y] + b[x,y] \end{align}\]for all \(x,y \in \mathfrak{D}(c)\).
The form that corresponds to \(\bigvee \left(A_n \oplus B\right)\) is \(d: \mathfrak{D}(d) \times \mathfrak{D}(d) \to \mathbb{C}\) with \[\begin{align} \mathfrak{D}(d) &= \{x \in \bigcap_n \mathfrak{D}(a_n) \cap \mathfrak{D}(b) \mid \bigvee a_n[x] < \infty\}\\ d[x,y] &= \bigvee a_n[x,y] + b[x,y] \end{align}\] for all \(x,y \in \mathfrak{D}(d)\). Then \[\begin{align} \mathfrak{D}(c) &= \mathfrak{D}(a) \cap \mathfrak{D}(b) = \{x \in \bigcap_n \mathfrak{D}(a_n) \cap \mathfrak{D}(b) \mid \bigvee a_n[x] < \infty\} = \mathfrak{D}(d),\\ c[x,y] &= a[x,y] + b[x,y] = \bigvee a_n[x,y] + b[x,y] = d[x,y] \end{align}\] for all \(x,y \in \mathfrak{D}(c) = \mathfrak{D}(d)\), so both sides correspond to the same form and thus to the same operator.
\(B \oplus\left(\bigvee A_n \right) = \bigvee \left(B \oplus A_n \right)\): Analogous to the previous case.
\(\left(\bigvee A_n \right)\oplus\left( \bigvee B_n \right) = \bigvee \left(A_n \oplus B_n \right)\):
Let \(\bigvee A_n = A\) and \(\bigvee B_n = B\). It is \(\mathfrak{D}(a) = \{x \in \bigcap_n \mathfrak{D}(a_n) \mid \bigvee a_n[x] < \infty\}\), \(\mathfrak{D}(b) = \{x \in \bigcap_n \mathfrak{D}(b_n) \mid \bigvee b_n[x] < \infty\}\) and \(a[x,y] = \bigvee a_n[x,y], b[x,y] = \bigvee b_n[x,y]\). We show that both sides correspond to the same form and thus to the same operator by Proposition [prop:OpstoForms]:
The form that corresponds to \(\left(\bigvee A_n \right)\oplus\left( \bigvee B_n \right) = A \oplus B\) is \(c: \mathfrak{D}(c) \times \mathfrak{D}(c) \to \mathbb{C}\) with \[\begin{align} \mathfrak{D}(c) &= \mathfrak{D}(a) \cap \mathfrak{D}(b)\\ c[x,y] &= a[x,y] + b[x,y] \end{align}\]for all \(x,y \in \mathfrak{D}(c)\).
The form that corresponds to \(\bigvee \left(A_n \oplus B_n \right)\) is \(d: \mathfrak{D}(d) \times \mathfrak{D}(d) \to \mathbb{C}\) with \[\begin{align} \mathfrak{D}(d) &= \{x \in \bigcap_n \mathfrak{D}(a_n)\cap \mathfrak{D}(b_n) \mid \bigvee a_n[x]+ b_n[x] < \infty\} \\ d[x,y] &= \bigvee a_n[x,y] + b_n[x,y] \end{align}\] for all \(x,y \in \mathfrak{D}(d)\).
As \(a_n\) and \(b_n\) are monotone non-decreasing sequences of forms, it is \(\bigvee a_n[x] + b_n[x] = \bigvee a_n[x] + \bigvee b_n[x]\) for all \(x \in \bigcap_n \mathfrak{D}(a_n) \cap \mathfrak{D}(b_n)\).
Then \[\begin{align} &\mathfrak{D}(c) = \mathfrak{D}(a) \cap \mathfrak{D}(b) = \{x \in \bigcap_n \mathfrak{D}(a_n) \cap \mathfrak{D}(b_n) \mid \bigvee a_n[x] < \infty \land \bigvee b_n[x] < \infty\} = \mathfrak{D}(d),\\ & c[x,y] = a[x,y] + b[x,y] = \bigvee a_n[x,y] + \bigvee b_n[x,y] = \bigvee a_n[x,y] + b_n[x,y] = d[x,y] \end{align}\] for all \(x,y \in \mathfrak{D}(c) = \mathfrak{D}(d)\), so both sides correspond to the same form and thus to the same operator.
\(M^\dagger \odot \left(\bigvee A_n \right) \odot M = \bigvee \left(M^\dagger \odot A_n \odot M \right)\): Let \(\bigvee A_n = A\). By Proposition [prop:orderEquivalence], \(a_n \leq a_{n+1}\) for all \(n\) and \(\bigvee a_n = a\) by the definition of the limit form. It is \(\mathfrak{D}(a) = \{x \in \bigcap_n \mathfrak{D}(a_n) \mid \bigvee a_n[x] < \infty\}\) and \(a[x,y] = \bigvee a_n[x,y]\). We show that both sides correspond to the same form and thus to the same operator by Proposition [prop:OpstoForms]:
The form that corresponds to \(M^\dagger \odot \left(\bigvee A_n \right) \odot M = M^\dagger \odot A \odot M\) is \(c: \mathfrak{D}(c) \times \mathfrak{D}(c) \to \mathbb{C}\) with \[\begin{align} \mathfrak{D}(c) &= \{x \in \mathcal{H}\mid Mx \in \mathfrak{D}(a)\}\\ c[x,y] &= a[Mx, My] \end{align}\]for all \(x,y \in \mathfrak{D}(c)\).
The form that corresponds to \(\bigvee \left(M^\dagger \odot A_n \odot M \right)\) is \(d: \mathfrak{D}(d) \times \mathfrak{D}(d) \to \mathbb{C}\) with \[\begin{align} \mathfrak{D}(d) &= \{x \in \mathcal{H}\mid Mx \in \bigcap_n \mathfrak{D}(a_n) \text{ and } \bigvee a_n[Mx] < \infty\}\\ d[x,y] &= \bigvee a_n[Mx, My] \end{align}\] for all \(x,y \in \mathfrak{D}(d)\). Then \[\begin{align} &\mathfrak{D}(c) = \{x \in \mathcal{H}\mid Mx \in \mathfrak{D}(a)\} = \{x \in \mathcal{H}\mid Mx \in \bigcap_n \mathfrak{D}(a_n) \text{ and } \bigvee a_n[Mx] < \infty\} = \mathfrak{D}(d),\\ & c[x,y] = a[Mx, My] = \bigvee a_n[Mx, My] = d[x,y] \end{align}\] for all \(x,y \in \mathfrak{D}(c) = \mathfrak{D}(d)\), so both sides correspond to the same form and thus to the same operator.
\(M^\dagger \odot (A \oplus B) \odot M = M^\dagger \odot A \odot M \oplus M^\dagger \odot B \odot M\): The form that corresponds to \(M^\dagger \odot (A \oplus B) \odot M\) is \(c: \mathfrak{D}(c) \times \mathfrak{D}(c) \to \mathbb{C}\) with \[\begin{align} \mathfrak{D}(c) &= \{x \in \mathcal{H}\mid Mx \in \mathfrak{D}(a) \cap \mathfrak{D}(b)\}\\ c[x,y] &= a[Mx, My] + b[Mx, My] \end{align}\]for all \(x,y \in \mathfrak{D}(c)\).
The form that corresponds to \(M^\dagger \odot A \odot M \oplus M^\dagger \odot B \odot M\) is \(d: \mathfrak{D}(d) \times \mathfrak{D}(d) \to \mathbb{C}\) with \[\begin{align} \mathfrak{D}(d) &= \{x \in \mathcal{H}\mid Mx \in \mathfrak{D}(a) \} \cap \{x \in \mathcal{H}\mid Mx \in \mathfrak{D}(b)\}\\ d[x,y] &= a[Mx, My] + b[Mx, My] \end{align}\] for all \(x,y \in \mathfrak{D}(d)\). Then \[\begin{align} \mathfrak{D}(c) &= \{x \in \mathcal{H}\mid Mx \in \mathfrak{D}(a) \cap \mathfrak{D}(b)\} = \mathfrak{D}(d),\\ c[x,y] &= a[Mx, My] + b[Mx, My] = d[x,y] \end{align}\] for all \(x,y \in \mathfrak{D}(c) = \mathfrak{D}(d)\), so both sides correspond to the same form and thus to the same operator.
◻
Proof of Lemma 2:
Proof. Similar to the proof of Lemma 1, we consider finite sums first, i.e., \(\sum_{n=0}^N A_n\). By Proposition [prop:ContinuityDistributivityFormSum], it is \(M^\dagger \odot \sum_{n=0}^N A_n \odot M = \sum_{n=0}^N M^\dagger \odot A_n \odot M\) for all \(N\).
By Theorem 1, there is a least upper bound of the sequence \(\{\sum_{n=0}^N A_n\}_{N}\), which is exactly \(\sum_{n=0}^\infty A_n\). Using Proposition [prop:ContinuityDistributivityFormSum], it is \[\begin{align} M^\dagger \odot (\sum_{n=0}^\infty A_n) \odot M =& \text{ }M^\dagger \odot \left(\bigvee_{N} \sum_{n=0}^N A_n\right) \odot M \\ =& \bigvee_N M^\dagger \odot \sum_{n=0}^N A_n \odot M \\ =& \bigvee_N \sum_{n=0}^N M^\dagger \odot A_n \odot M \\ =& \sum_{n=0}^\infty M^\dagger \odot A_n \odot M\qedhere \end{align}\] ◻
Proof of Proposition [prop:BoundedAddition]:
Proof. Let \(A,B \in \mathcal{E}(\mathcal{H})\) be bounded expectations over \(\mathcal{H}\), \(\alpha\geq 0\) and \(M\) be a bounded operator on \(\mathcal{H}\). As \(A,B\) are bounded, their \(\infty\)-restrictions \(A_\infty, B_\infty\) are bounded and thus defined on \(\mathcal{H}\). Thus the forms \(a,b\) that correspond to \(A_\infty, B_\infty\) are defined on \(\mathcal{H}\) as well (and bounded by [28]). We have \(a[x,y] = \bra{x} A \ket{y}\) and \(b[x,y] = \bra{x} B \ket{y}\) for all \(x,y \in \mathcal{H}\). Then
Addition: \(\mathfrak{D}(c) = \mathcal{H}\) with \(c[x,y] = a[x,y] + b[x,y] = \bra{x} A+B \ket{y}\) for all \(x,y \in \mathcal{H}\).
Scalar multiplication: \(\mathfrak{D}(\alpha \cdot a) = \mathcal{H}\) with \((\alpha \cdot a)[x,y] = \alpha \cdot a[x,y] = \bra{x} \alpha \cdot A \ket{y}\) for all \(x,y \in \mathcal{H}\).
Application of bounded operator: \(\mathfrak{D}(a_M) = \mathcal{H}\) with \(a_M[x,y] = a[Mx, My] = \bra{Mx} A \ket{My} = \bra{x} M^\dagger A M \ket{y}\) for all \(x,y \in \mathcal{H}\).
◻
Proof of Proposition [prop:orderproperties]:
Proof. Assume \(A,B,C \in \mathcal{E}(\mathcal{H})\) and \(M\) bounded.
Antisymmetric: \(A \sqsubseteq B \land B \sqsubseteq A \Rightarrow A=B\).
\(A \sqsubseteq B\) implies \(\mathfrak{D}(B_\infty^{\frac{1}{2}}) \subseteq \mathfrak{D}(A_\infty^{\frac{1}{2}})\) and the other way round, so \(\mathfrak{D}(A_\infty^{\frac{1}{2}}) = \mathfrak{D}(B_\infty^{\frac{1}{2}})\). Also \(\norm{A_\infty^{\frac{1}{2}} \psi}^2 = \norm{B_\infty^{\frac{1}{2}} \psi}^2\) for all \(\ket{\psi} \in \mathfrak{D}(B_\infty^{\frac{1}{2}})\), so \(A=B\).
Reflexive: It is \(A \sqsubseteq A\).
Clearly \(\mathfrak{D}(A_\infty^{\frac{1}{2}}) \subseteq \mathfrak{D}(A_\infty^{\frac{1}{2}})\) and \(\norm{A_\infty^{\frac{1}{2}} \psi}^2 \leq \norm{A_\infty^{\frac{1}{2}} \psi}^2\), so \(A \sqsubseteq A\).
Transitive: \(A \sqsubseteq B \land B \sqsubseteq C \Rightarrow A \sqsubseteq C\).
\(A \sqsubseteq B\) means \(\mathfrak{D}(B_\infty^{\frac{1}{2}}) \subseteq \mathfrak{D}(A_\infty^{\frac{1}{2}})\) and \(\norm{A_\infty^{\frac{1}{2}} \psi}^2 \leq \norm{B_\infty^{\frac{1}{2}} \psi}^2\) for all \(\ket{\psi} \in \mathfrak{D}(B_\infty^{\frac{1}{2}})\). \(B \sqsubseteq C\) means \(\mathfrak{D}(C_\infty^{\frac{1}{2}}) \subseteq \mathfrak{D}(B_\infty^{\frac{1}{2}})\) and \(\norm{B_\infty^{\frac{1}{2}} \psi}^2 \leq \norm{C_\infty^{\frac{1}{2}} \psi}^2\) for all \(\ket{\psi} \in \mathfrak{D}(C_\infty^{\frac{1}{2}})\).
So we have \(\mathfrak{D}(C_\infty^{\frac{1}{2}}) \subseteq \mathfrak{D}(B_\infty^{\frac{1}{2}}) \subseteq \mathfrak{D}(A_\infty^{\frac{1}{2}})\) (in particular \(\mathfrak{D}(C_\infty^{\frac{1}{2}})\subseteq \mathfrak{D}(A_\infty^{\frac{1}{2}})\)) and \(\norm{A_\infty^{\frac{1}{2}} \psi}^2 \leq \norm{B_\infty^{\frac{1}{2}} \psi}^2 \leq \norm{C_\infty^{\frac{1}{2}} \psi}^2\) for all \(\ket{\psi} \in \mathfrak{D}(C_\infty^{\frac{1}{2}})\). Thus \(A \sqsubseteq C\).
Let \(a,b,c\) be the forms that correspond to \(A_\infty, B_\infty, C_\infty\) and \(A \sqsubseteq B\). Then \(\mathfrak{D}(b) = \mathfrak{D}(B_\infty^{\frac{1}{2}}) \subseteq \mathfrak{D}(A_\infty^{\frac{1}{2}}) = \mathfrak{D}(a)\) and \(\norm{A_\infty^{\frac{1}{2}} \psi}^2 \leq \norm{B_\infty^{\frac{1}{2}} \psi}^2\) for all \(\ket{\psi} \in \mathfrak{D}(B_\infty^{\frac{1}{2}})\).
It is \(\mathfrak{D}((B \oplus C)_\infty^{\frac{1}{2}}) = \mathfrak{D}(b) \cap \mathfrak{D}(c) \subseteq \mathfrak{D}(a) \cap \mathfrak{D}(c) = \mathfrak{D}((A \oplus C)_\infty^{\frac{1}{2}})\). For all \(\ket{\psi} \in \mathfrak{D}((B \oplus C)_\infty^{\frac{1}{2}})\) it is \[\begin{align} \norm{(A \oplus C)_\infty^{\frac{1}{2}} \psi}^2 &= a[\psi]+ c[\psi] \leq b[\psi] + c[\psi] = \norm{(B \oplus C)_\infty^{\frac{1}{2}} \psi}^2 \end{align}\] Thus \(A \oplus C \sqsubseteq B \oplus C\).
Let \(a,b\) be the forms that correspond to \(A_\infty, B_\infty\) and \(A \sqsubseteq B\). That means \(a\leq b\), i.e., \(\mathfrak{D}(b) \subseteq \mathfrak{D}(a)\) and \(a[x] \leq b[x]\) for all \(x \in \mathfrak{D}(b)\) by Proposition [prop:orderEquivalence]. Then \(\mathfrak{D}(b_M) = \{ \psi \in \mathcal{H}\mid M\psi \in \mathfrak{D}(b)\} \subseteq \{ \psi \in \mathcal{H}\mid M\psi \in \mathfrak{D}(a)\} = \mathfrak{D}(a_M)\). For all \(\psi \in \mathfrak{D}(b_M)\) it is \(a_M[\psi] = a[M\psi] \leq b[M\psi] = b_M[\psi]\), thus \(a_M \leq b_M\) and thus \(M^\dagger \odot A \odot M \sqsubseteq M^\dagger \odot B \odot M\) by Proposition [prop:orderEquivalence].
◻
Proof of Lemma 3:
Proof. In this proof we use \(\mathbb{E}_{A}\left(\rho\right)\) to denote the expectation value defined via the spectral measure in Definition 6 and \(\mathbb{E}_{A_1}\left(\rho\right)\) and \(\mathbb{E}_{A_2}\left(\rho\right)\) to denote the two equations in this lemma.
We first show the statement for pure states \(\rho = \ket{\psi}\bra{\psi}\).
It is \(\mathfrak{D}(A_\infty^{\frac{1}{2}})=\{ \ket{\psi} \mid \int \abs{\lambda} d (tr(E_\lambda \ket{\psi}\bra{\psi})) < \infty\}\) by [30].
If \(\ket{\psi} \not \in \mathfrak{D}(A_\infty^{\frac{1}{2}}) = \mathfrak{D}(a)\), then \(\int \abs{\lambda} d (tr(E_\lambda \ket{\psi}\bra{\psi})) = \infty\) and thus \(\mathbb{E}_{A}\left(\ket{\psi}\bra{\psi}\right) = \infty\) in all cases.
If \(\ket{\psi} \in \mathfrak{D}(A_\infty^{\frac{1}{2}})\), then \(\int \abs{\lambda} d (tr(E_\lambda \ket{\psi}\bra{\psi}))= \int \abs{\lambda} d (\bra{\psi}E_\lambda \ket{\psi})< \infty\). First we show equivalence between \(\mathbb{E}_{A}\left(\ket{\psi}\bra{\psi}\right)\) and \(\mathbb{E}_{A_1}\left(\ket{\psi}\bra{\psi}\right)\):
We define \(I_n(x)=\begin{cases} x & \text{if } x \leq n \\ 0 & \text{otherwise} \end{cases}\) for all \(n >0\). Then \(I_n(A_\infty),I_n(A_\infty^{\frac{1}{2}})\) is a bounded operator for all \(n >0\) and \(I_n(A_\infty) \to A_\infty, I_n(A_\infty^{\frac{1}{2}}) \to A_\infty^{\frac{1}{2}}\) strongly. \[\begin{align} & \norm{A_\infty^{\frac{1}{2}} \ket{\psi}}^2 && (I_n(A_\infty^{\frac{1}{2}}) \to A_\infty^{\frac{1}{2}}\text{ strongly})\\ =& \lim_{n\to \infty} \norm{I_n(A_\infty^{\frac{1}{2}}) \ket{\psi}}^2 \\ =& \lim_{n\to \infty} \norm{(I_{n^2}(A_\infty))^{\frac{1}{2}} \ket{\psi}}^2 && (\text{def. norm})\\ =& \lim_{n\to \infty} \bra{\psi} ((I_{n^2}(A_\infty))^{\frac{1}{2}})^2 \ket{\psi} \\ =& \lim_{n\to \infty} \bra{\psi} I_{n^2}(A_\infty) \ket{\psi} \\ =& \lim_{n\to \infty} \int I_{n^2}(\lambda) d (\bra{\psi}E_\lambda \ket{\psi}) && (\text{dominated convergence theorem})\\ =& \int \lim_{n\to \infty} I_{n^2}(\lambda) d (\bra{\psi}E_\lambda \ket{\psi}) \\ =& \int \lambda d (\bra{\psi}E_\lambda \ket{\psi}) \\ =& \int \lambda d (tr(E_\lambda \ket{\psi}\bra{\psi})) \end{align}\] The dominated convergence theorem applies as \(\abs{I_{n^2}(x)} \leq x\) for all \(n>0, x\) because \(\lim_{n \to \infty} I_{n^2}(x) = x\) for all \(x\). Also \(\int \abs{\lambda} d (\bra{\psi}E_\lambda \ket{\psi}) < \infty\) because \(\ket{\psi} \in \mathfrak{D}(A_\infty^{\frac{1}{2}})\).
The equivalence between \(\mathbb{E}_{A_1}\left(\ket{\psi}\bra{\psi}\right)\) and \(\mathbb{E}_{A_2}\left(\ket{\psi}\bra{\psi}\right)\) follows from the definition of the form \(a\) that corresponds to \(A_\infty\) as \(a[\ket{\psi}] = \norm{A_\infty^{\frac{1}{2}} \ket{\psi}}^2\) for all \(\ket{\psi} \in \mathfrak{D}(a)\).
Now we consider the case of mixed states \(\rho = \sum_i p_i \ket{\psi_i}\bra{\psi_i}\) with \(p_i > 0\). If any \(\ket{\psi_i}\) is not in \(\mathfrak{D}(A_\infty^{\frac{1}{2}})\), then \(\int \abs{\lambda} d (tr(E_\lambda \ket{\psi_i}\bra{\psi_i})) = \infty\) and thus \(\mathbb{E}_{A}\left(\rho\right) = \infty\) in all cases.
If \(\ket{\psi_i} \in \mathfrak{D}(A_\infty^{\frac{1}{2}}) = \mathfrak{D}(a)\) for all \(i\), then by [34] \[\begin{align} \mathbb{E}_{A}\left(\rho\right) = \sum_i p_i \mathbb{E}_{A}\left(\ket{\psi_i}\bra{\psi_i}\right) = \sum_i p_i \int \lambda d (tr(E_\lambda \ket{\psi_i}\bra{\psi_i})) \end{align}\] As both \(\mathbb{E}_{A_1}\left(\rho\right)\) and \(\mathbb{E}_{A_2}\left(\rho\right)\) are defined as \(\sum_i p_i \mathbb{E}_{A_1}\left(\ket{\psi_i}\bra{\psi_i}\right)\) and \(\sum_i p_i \mathbb{E}_{A_2}\left(\ket{\psi_i}\bra{\psi_i}\right)\) respectively, and we have already shown the equivalence for pure states, we are done. ◻
Proof of Lemma 4:
Proof. \(\Rightarrow\): Assume \(A \sqsubseteq B\). Then \(\mathfrak{D}(B_\infty^{\frac{1}{2}}) \subseteq \mathfrak{D}(A_\infty^{\frac{1}{2}})\) and \(\norm{A_\infty^{\frac{1}{2}} \psi}^2 \leq \norm{B_\infty^{\frac{1}{2}} \psi}^2\) for all \(\ket{\psi} \in \mathfrak{D}(B_\infty^{\frac{1}{2}})\). Let \(\rho \in \mathcal{D}(\mathcal{H})\) be a density operator with decomposition \(\rho = \sum_i p_i \ket{\psi_i}\bra{\psi_i}\). If there is any \(\ket{\psi_i} \not \in \mathfrak{D}(B_\infty^{\frac{1}{2}})\), then \(\mathbb{E}_{B}\left(\rho\right) = \infty\) and thus \(\mathbb{E}_{A}\left(\rho\right) \leq \mathbb{E}_{B}\left(\rho\right)\). Otherwise, it is \[\begin{align} \mathbb{E}_{A}\left(\rho\right) =& \sum_i p_i \mathbb{E}_{A}\left(\ket{\psi_i}\bra{\psi_i}\right) = \sum_i p_i \norm{A_\infty^{\frac{1}{2}} \ket{\psi_i}}^2 \\ \leq& \sum_i p_i \norm{B_\infty^{\frac{1}{2}} \ket{\psi_i}}^2 = \sum_i p_i \mathbb{E}_{B}\left(\ket{\psi_i}\bra{\psi_i}\right) = \mathbb{E}_{B}\left(\rho\right) \end{align}\] \(\Leftarrow\): Assume that for all \(\rho \in \mathcal{D}(\mathcal{H})\) it is \(\mathbb{E}_{A}\left(\rho\right) \leq \mathbb{E}_{B}\left(\rho\right)\). Let \(\ket{\psi} \in \mathfrak{D}(B_\infty^{\frac{1}{2}})\) and consider the density operator \(\rho = \ket{\psi}\bra{\psi}\). Then it is \[\begin{align} \mathbb{E}_{A}\left(\ket{\psi}\bra{\psi}\right) \leq \mathbb{E}_{B}\left(\ket{\psi}\bra{\psi}\right) \end{align}\] by assumption. As \(\ket{\psi} \in \mathfrak{D}(B_\infty^{\frac{1}{2}})\), it is \(\mathbb{E}_{B}\left(\ket{\psi}\bra{\psi}\right) = \norm{B_\infty^{\frac{1}{2}} \ket{\psi}}^2 < \infty\), thus \(\mathbb{E}_{A}\left(\ket{\psi}\bra{\psi}\right) < \infty\) and thus \(\ket{\psi} \in \mathfrak{D}(A_\infty^{\frac{1}{2}})\), i.e., \(\mathfrak{D}(B_\infty^{\frac{1}{2}}) \subseteq \mathfrak{D}(A_\infty^{\frac{1}{2}})\). Furthermore, it is \[\begin{align} \norm{A_\infty^{\frac{1}{2}} \ket{\psi}}^2 = \mathbb{E}_{A}\left(\ket{\psi}\bra{\psi}\right) \leq \mathbb{E}_{B}\left(\ket{\psi}\bra{\psi}\right) = \norm{B_\infty^{\frac{1}{2}} \ket{\psi}}^2 \end{align}\] Overall, we have \(\mathfrak{D}(B_\infty^{\frac{1}{2}}) \subseteq \mathfrak{D}(A_\infty^{\frac{1}{2}})\) and \(\norm{A_\infty^{\frac{1}{2}} \psi}^2 \leq \norm{B_\infty^{\frac{1}{2}} \psi}^2\) for all \(\ket{\psi} \in \mathfrak{D}(B_\infty^{\frac{1}{2}})\), thus \(A \sqsubseteq B\). ◻
Proof of Proposition [prop:expectationProperties]:
Proof. Linearity: First we consider the sum of two expectations. Let \(A,B \in \mathcal{E}(\mathcal{H})\) and \(\rho= \sum_i p_i \ket{\psi_i}\bra{\psi_i} \in \mathcal{D}(\mathcal{H})\). We distinguish two cases:
There is at least one \(\ket{\psi_i} \not \in \mathfrak{D}((A \oplus B)_\infty^{\frac{1}{2}})\). If there is any \(\ket{\psi_i} \not \in \mathfrak{D}((A \oplus B)_\infty^{\frac{1}{2}})\), then \(\mathbb{E}_{A\oplus B}\left(\rho\right) = \infty\). \(\ket{\psi_i} \not \in \mathfrak{D}((A\oplus B)_\infty^{\frac{1}{2}}) = \mathfrak{D}(A_\infty^{\frac{1}{2}})\cap \mathfrak{D}(B_\infty^{\frac{1}{2}})\) implies \(\ket{\psi_i} \not \in \mathfrak{D}(A_\infty^{\frac{1}{2}})\) or \(\ket{\psi_i} \not \in \mathfrak{D}(B_\infty^{\frac{1}{2}})\) and thus \(\mathbb{E}_{A}\left(\rho\right) = \infty\) or \(\mathbb{E}_{B}\left(\rho\right) = \infty\). Thus \(\mathbb{E}_{A}\left(\rho\right) + \mathbb{E}_{B}\left(\rho\right) = \infty\).
All \(\ket{\psi_i} \in \mathfrak{D}((A \oplus B)_\infty^{\frac{1}{2}})\). We consider the forms \(a,b\) that correspond to \(A_\infty, B_\infty\) and \(c\) for \((A \oplus B)_\infty\). Then it is \(\ket{\psi_i} \in \mathfrak{D}(a)\) and \(\ket{\psi_i} \in \mathfrak{D}(b)\) for all \(i\) and thus \[\begin{align} \mathbb{E}_{A\oplus B}\left(\rho\right) =& \sum_i p_i \mathbb{E}_{A\oplus B}\left(\ket{\psi_i}\bra{\psi_i}\right) = \sum_i p_i c[\psi_i] = \sum_i p_i \left( a[\psi_i] + b[\psi_i] \right) \\ =& \sum_i p_i a[\psi_i] + \sum_i p_i b[\psi_i] = \mathbb{E}_{A}\left(\rho\right) + \mathbb{E}_{B}\left(\rho\right) \end{align}\]
The linearity w.r.t. states follow from the definition (more details in the proof of Lemma 3).
Scalar multiplication: For states it follows again from the definition of the expectation value (more details in the proof of Lemma 3).
For the expectation, we distinguish two cases again. Let \(A \in \mathcal{E}(\mathcal{H})\) with corresponding form \(a\) and \(cA\) the form corresponding to \(cA\) and \(\rho= \sum_i p_i \ket{\psi_i}\bra{\psi_i} \in \mathcal{D}(\mathcal{H})\).
There is at least one \(\ket{\psi_i} \not \in \mathfrak{D}(A_\infty^{\frac{1}{2}}) = \mathfrak{D}(a) = \mathfrak{D}(ca) = \mathfrak{D}(cA_\infty^{\frac{1}{2}})\). Then \(\mathbb{E}_{cA}\left(\rho\right) = \infty = \mathbb{E}_{A}\left(\rho\right)\).
All \(\ket{\psi_i} \in \mathfrak{D}(A_\infty^{\frac{1}{2}}) = \mathfrak{D}(cA_\infty^{\frac{1}{2}})\). Then it is \[\begin{align} \mathbb{E}_{cA}\left(\rho\right) =& \sum_i p_i \cdot \mathbb{E}_{cA}\left(\ket{\psi_i}\bra{\psi_i}\right) = \sum_i p_i \cdot ca[\psi_i] = \sum_i p_i c\cdot a[\psi_i] \\ =& \sum_i p_i \cdot c \cdot \mathbb{E}_{A}\left(\ket{\psi_i}\bra{\psi_i}\right) \\ =& \text{ } c \cdot \sum_i p_i \cdot \mathbb{E}_{A}\left(\ket{\psi_i}\bra{\psi_i}\right) = c \cdot \mathbb{E}_{A}\left(\rho\right) \end{align}\]
Continuity: We start with the sequence of expectations: Let \(\{A_i\}_i \subseteq \mathcal{E}(\mathcal{H})\) be an increasing chain of expectations, \(\rho \in \mathcal{D}(\mathcal{H})\) and \(A = \bigvee_i A_i\) (existence follows by Theorem 1). Let \(\rho = \sum_j p_j \ket{\psi_j}\bra{\psi_j}\) be a decomposition of \(\rho\) with \(p_j > 0\). We distinguish two cases:
There is at least one \(\ket{\psi_j} \not \in \mathfrak{D}(A_\infty^{\frac{1}{2}}) = \mathfrak{D}(a)\). Then \(\mathbb{E}_{A}\left(\rho\right) = \infty\). It also means that \(a[\psi_j] = \lim_i a_i[\psi_j] = \infty\) as otherwise \(\ket{\psi_j} \in \mathfrak{D}(a)\). If \(\ket{\psi_j}\) not in \(\mathfrak{D}(a_i)\) for at least one \(i\), then \(\mathbb{E}_{A_i}\left(\rho\right) = \infty\) and thus \(\bigvee_i \mathbb{E}_{A_i}\left(\rho\right) = \infty\). Otherwise, it is \(\ket{\psi_j} \in \mathfrak{D}(a_i)\) for all \(i\) and thus \(\mathbb{E}_{A_i}\left(\ket{\psi_j}\bra{\psi_j}\right) = a_i[\psi_j] \not = \infty\) for all \(i\). As \(\lim_i a_i[\psi_j] = \infty\), it is \(\bigvee_i p_j \mathbb{E}_{A_i}\left(\ket{\psi_j}\bra{\psi_j}\right) = \infty\) and thus \(\bigvee_i \mathbb{E}_{A_i}\left(\rho\right) \geq \bigvee_i p_j \mathbb{E}_{A_i}\left(\ket{\psi_j}\bra{\psi_j}\right) = \infty\).
All \(\ket{\psi_j} \in \mathfrak{D}(A_\infty^{\frac{1}{2}})\). Then it is \[\begin{align} \mathbb{E}_{A}\left(\rho\right) \overset{Lem. \ref{lem:expectAlternativeDef}}{=}& \sum_j p_j a[\psi_j] \\ \overset{Def}{=}& \sum_j p_j \lim_i a_i[\psi_j]\\ =& \sum_j \lim_i p_j a_i[\psi_j]\\ \overset{*}{=}& \lim_i \sum_j p_j a_i[\psi_j] \\ \overset{Lem. \ref{lem:expectAlternativeDef}}{=}& \lim_i \sum_j p_j \mathbb{E}_{A_i}\left(\ket{\psi_j}\bra{\psi_j}\right) \\ \overset{Incr. Seq.}{=}& \bigvee_i \sum_j p_j \mathbb{E}_{A_i}\left(\ket{\psi_j}\bra{\psi_j}\right) \\ \overset{Lem. \ref{lem:expectAlternativeDef}}{=}& \bigvee_i \mathbb{E}_{A_i}\left(\rho\right) \end{align}\] where the step marked with \(*\) follows by the monotone convergence theorem as supremum and limit coincide here because \(a_i[\psi_j]\leq a_{i+1}[\psi_j]\) for all \(i,j\).
Now we consider the sequence of states: Let \(\{ \rho_i \}_i \subseteq \mathcal{D}(\mathcal{H})\) be an increasing chain of density operators, \(A \in \mathcal{E}(\mathcal{H})\) and \(\rho = \bigvee_i \rho_i\) (existence follows by [27]). To show: \(\mathbb{E}_{A}\left(\rho\right) = \bigvee_i \mathbb{E}_{A}\left(\rho_i\right)\).
For each \(n\), define \(A_n = \int_0^n \lambda d E_\lambda\) where \(E_\lambda\) is the spectral measure of \(A_\infty\). Then \(A_n\) is a bounded operator for all \(n\) and \(A_n \to A_\infty\) strongly. We have \(\mathbb{E}_{A_n}\left(\rho\right) = tr(A_n \rho)\) and \(\mathbb{E}_{A_n}\left(\rho_i\right) = tr(A_n \rho_i)\) for all \(i,n\). This will be denoted by (1). As \(\rho_i \to \rho\) in trace norm, it is \(tr(A_n \rho_i) \to tr(A_n \rho)\) for all \(n\), denoted by (2)
As the expectation value is continuous in the expectation, it is \(\mathbb{E}_{A}\left(\rho\right) = \bigvee_n \mathbb{E}_{A_n}\left(\rho\right)\) and \(\mathbb{E}_{A}\left(\rho_i\right) = \bigvee_n \mathbb{E}_{A_n}\left(\rho_i\right)\) for all \(i\). This will be denoted by (3). Overall we have \[\begin{align} \mathbb{E}_{A}\left(\bigvee_i \rho_i\right) \overset{(3)}{=}& \bigvee_n \mathbb{E}_{A_n}\left(\bigvee_i \rho_i\right) \\ \overset{(1)}{=}& \bigvee_n tr(A_n \bigvee_i \rho_i) \\ \overset{(2)}{=}& \bigvee_n \bigvee_i tr(A_n \rho_i) \\ =& \bigvee_i \bigvee_n tr(A_n \rho_i) \\ \overset{(1)}{=}& \bigvee_i \bigvee_n \mathbb{E}_{A_n}\left(\rho_i\right) \\ \overset{(3)}{=}& \bigvee_i \mathbb{E}_{A}\left(\rho_i\right) \end{align}\] Exchanging the suprema is possible as both sequences (fixed i, varying n and fixed n, varying i) are increasing. ◻
Proof of Lemma 5:
Proof. We show the first statement. We consider finite sums \(\sum_{n=0}^N A_n\), then \(\sum_n A_n\) is \(\bigvee_N \sum_{n=0}^N A_n\). \[\begin{align} \mathbb{E}_{\sum_n A_n}\left(\rho\right) =&\text{ } \mathbb{E}_{\bigvee_N \sum_{n=0}^N A_n}\left(\rho\right) \\ =& \bigvee_N \mathbb{E}_{\sum_{n=0}^N A_n}\left(\rho\right) && (\text{continuity of the expectation})\\ =& \bigvee_N \sum_{n=0}^N \mathbb{E}_{A_n}\left(\rho\right) && (\text{linearity of the expectation})\\ =& \sum_n \mathbb{E}_{A_n}\left(\rho\right) \end{align}\]
The second statement follows analogously with finite sums \(\sum_{n=0}^N \rho_n\). ◻
Proof of Proposition [prop:boundedOpinExpectation]:
Proof. Let \(a\) be the form-expectation of \(A\) and \(a_M\) the one of \(M^\dagger \odot A \odot M\). Let \(\rho = \sum_i p_i \ket{\psi_i}\bra{\psi_i}\) be a decomposition with \(p_i > 0\).
If \(\ket{\psi_i} \not \in \mathfrak{D}(a_M)\) for at least one \(i\), then \(\mathbb{E}_{M^\dagger \odot A \odot M}\left(\rho\right) = \infty\). As \(\ket{\psi_i} \not \in \mathfrak{D}(a_M) = \{ \psi \in \mathcal{H}\mid M\psi \in \mathfrak{D}(a)\}\), it is \(M\ket{\psi_i} \not \in \mathfrak{D}(a)\) and thus \(\mathbb{E}_{A}\left(M\rho M^\dagger\right) = \infty\). Thus \(\mathbb{E}_{M^\dagger \odot A \odot M}\left(\rho\right) = \mathbb{E}_{A}\left(M\rho M^\dagger\right)\).
Otherwise, \(\mathbb{E}_{M^\dagger \odot A \odot M}\left(\rho\right) = \sum_i p_i a_M[\psi_i] = \sum_i p_i a[M\psi_i] = \mathbb{E}_{A}\left(M \rho M^\dagger\right)\). ◻
Proof of Proposition [prop:supCPmaps]:
Proof. We show that each \(g_i\) corresponds to a positive, symmetric and closed form \(a_i\) and then we can write \(g\) as a least upper bound of the \(a_i\) and thus it is also a positive, symmetric and closed form by Proposition [prop:OpstoForms] and Theorem 1.
It is \(a_i[\ket{\psi}] = g_i(\ket{\psi}\bra{\psi})\) for all \(\ket{\psi} \in \mathcal{H}\) (using \(\mathfrak{D}(a_i) = \mathcal{H}\) as \(g_i\), and thus \(a\), is bounded). Positivity and symmetry follow immediately from the co-domain of \(g_i\). It remains to show that \(a_i\) is closed. Let \(\ket{\psi_n}\) be a sequence in \(\mathcal{H}\) such that \(\lim_{n \to \infty} \ket{\psi_n} = \ket{\psi}\) and \(\lim_{n,m \to \infty}a_i[\ket{\psi_n} - \ket{\psi_m}] = 0\). As \(a_i\) is bounded, \(\ket{\psi} \in \mathcal{H}= \mathfrak{D}(a_i)\). It remains to show that \(\lim_{n\to\infty} a_i[\ket{\psi_n} - \ket{\psi}] = 0\): \[\begin{align} & \lim_{n\to\infty}\ket{\psi_n} = \ket{\psi}\\ \Rightarrow & \lim_{n\to\infty} \ket{\psi_n} - \ket{\psi} = 0\\ \Rightarrow & \lim_{n\to \infty} (\ket{\psi_n} - \ket{\psi})(\ket{\psi_n} - \ket{\psi})^\dagger = 0\\ \Rightarrow & \lim_{n\to \infty} g_i((\ket{\psi_n} - \ket{\psi})(\ket{\psi_n} - \ket{\psi})^\dagger) = g_i(0)\\ \Rightarrow & \lim_{n\to \infty} a_i[\ket{\psi_n} - \ket{\psi}] = 0 \end{align}\] because \(g_i\) is continuous as it is bounded and positive. ◻
Proof of Proposition [prop:semanticsProperties]:
Proof.
See [8] as \(\boldsymbol{reward} ( c)\) behaves like \(\boldsymbol{skip}\).
See [8] as \(\boldsymbol{reward} ( c)\) behaves like \(\boldsymbol{skip}\).
We already know that \(\llbracket S \rrbracket_D\) is linear and trace non-increasing. Now we do an induction over the structure to show that it can be represented in Kraus form, which implies complete positivity.
For \(\boldsymbol{skip}, q:=0, \overline{q}:= U\overline{q}\) and \(\boldsymbol{reward} ( c)\), the semantics have Kraus form directly.
For \(S_1;S_2\), if \(\llbracket S_1 \rrbracket_D\) and \(\llbracket S_2 \rrbracket_D\) can be represented in Kraus form with operators \(E_i\) and \(F_j\) respectively, then \(\llbracket S_2 \rrbracket_D(\llbracket S_1 \rrbracket_D(\rho)) = \sum_{i,j} F_j E_i \rho E_i^\dagger F_j^\dagger\) is a Kraus representation of \(\llbracket S_1;S_2 \rrbracket\).
For \(\boldsymbol{measure } M[\overline{q}]:\overline{S}\), if \(\llbracket S_m \rrbracket_D\) can be represented in Kraus form with operators \(E_{m,i}\) for all \(m\), then we obtain a Kraus representation by \[\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S} \rrbracket_D(\rho) = \sum_{m,i} E_{m,i} M_m \rho M_m^\dagger E_{m,i}^\dagger.\]
For \(\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S\), we define \(\mathcal{M}_0(\rho) = M_0 \rho M_0^\dagger\) and \(\mathcal{M}_1(\rho) = M_1 \rho M_1^\dagger\) for all \(\rho \in \mathcal{D}(\mathcal{H})\). Then we define \[\begin{align} W_0 =& \text{ }\Omega = 0\\ W_{i+1} =& \text{ }\llbracket \boldsymbol{if }M[\overline{q}]=1 \boldsymbol{ then } S; W_i \rrbracket_D \\ =& \text{ }\mathcal{M}_1 \circ \llbracket S \rrbracket_D \circ W_i + \mathcal{M}_0 \end{align}\] Intuitively, \(W_i\) corresponds to the semantics of the program that executes at most \(i\) iterations of the loop and then terminates. Then we can show \(W_i = \sum_{k=0}^{i-1} (\mathcal{M}_1 \circ \llbracket S \rrbracket_D)^k \circ \mathcal{M}_0\) by induction over \(i\).
\(i=1\): \(W_1 = \mathcal{M}_1 \circ \llbracket S \rrbracket_D \circ W_0 + \mathcal{M}_0 = \mathcal{M}_0 = \sum_{k=0}^0 (\mathcal{M}_1 \circ \llbracket S \rrbracket_D)^k \circ \mathcal{M}_0\).
\(i \to i+1\): We have \[\begin{align} W_{i+1} =& \text{ }\mathcal{M}_1 \circ \llbracket S \rrbracket_D \circ W_i + \mathcal{M}_0 \\ =& \text{ }\mathcal{M}_1 \circ \llbracket S \rrbracket_D \circ \sum_{k=0}^{i-1} (\mathcal{M}_1 \circ \llbracket S \rrbracket_D)^k \circ \mathcal{M}_0 + \mathcal{M}_0 \\ =& \sum_{k=1}^{i} (\mathcal{M}_1 \circ \llbracket S \rrbracket_D)^k \circ \mathcal{M}_0 + \mathcal{M}_0 \\ =& \sum_{k=0}^{i} (\mathcal{M}_1 \circ \llbracket S \rrbracket_D)^k \circ \mathcal{M}_0 \end{align}\]
As \(\mathcal{M}_1\) and \(\llbracket S \rrbracket_D\) can be represented in Kraus form, \(W_i\) can be represented in Kraus form as well by the previous cases, i.e., it is completely positive. We can show that \(W_{i+1}-W_i\) can be represented in Kraus form as well: \[\begin{align} W_{i+1} - W_i =& \sum_{k=0}^{i} (\mathcal{M}_1 \circ \llbracket S \rrbracket_D)^k \circ \mathcal{M}_0 - \sum_{k=0}^{i-1} (\mathcal{M}_1 \circ \llbracket S \rrbracket_D)^k \circ \mathcal{M}_0 \\ =& \text{ }(\mathcal{M}_1 \circ \llbracket S \rrbracket_D)^i \circ \mathcal{M}_0 \end{align}\] which can be represented in Kraus form by the previous cases as it is finite concatenation of Kraus-representable maps.
Then we have \(\bigvee_{i=0}^\infty W_i = \sum_{i=0}^{\infty} W_{i+1}-W_i\) where each summand \(W_{i+1}-W_i\) can be represented in Kraus form, which implies that \(\sum_{i=0}^\infty W_{i+1}-W_i\) can be represented in Kraus form as well by taking the union of the Kraus operators for all \(i\) [40].
\(\llbracket S \rrbracket_{R}(\rho)\) is linear in \(\rho\) can be shown by induction over the structure of \(S\). Let \(\rho, \sigma \in \mathcal{D}(\mathcal{H})\) and \(\alpha, \beta \in \mathbb{C}\) such that \(\alpha \rho, \beta \sigma, \alpha \rho + \beta \sigma \in \mathcal{D}(\mathcal{H})\).
For \(\boldsymbol{skip}, q:=0, \overline{q}:= U\overline{q}\) it follows immediately from the definition (\(=0\) always).
For \(\boldsymbol{reward} ( c)\), we have \[\begin{align} & \text{ }\llbracket \boldsymbol{reward} ( c) \rrbracket_{R}(\alpha \rho + \beta \sigma) \\ =& \text{ }c \cdot tr(\alpha \rho + \beta \sigma) \\ =& \text{ }c\cdot (\alpha tr(\rho) + \beta tr(\sigma)) \\ = & \text{ }\alpha \cdot \llbracket \boldsymbol{reward} ( c) \rrbracket_{R}(\rho) + \beta \cdot \llbracket \boldsymbol{reward} ( c) \rrbracket_{R}(\sigma) \end{align}\] as the trace is linear.
For \(S_1;S_2\), we have \[\begin{align} &\text{ }\llbracket S_1;S_2 \rrbracket_{R}(\alpha \rho + \beta \sigma) \\ =& \text{ }\llbracket S_2 \rrbracket_{R}(\llbracket S_1 \rrbracket_D(\alpha \rho + \beta \sigma)) + \llbracket S_1 \rrbracket_{R}(\alpha \rho + \beta \sigma) \\ =& \text{ }\llbracket S_2 \rrbracket_{R}(\alpha \llbracket S_1 \rrbracket_D(\rho) + \beta \llbracket S_1 \rrbracket_D( \sigma)) + \llbracket S_1 \rrbracket_{R}(\alpha \rho + \beta \sigma) \\ =& \text{ }\alpha\llbracket S_2 \rrbracket_{R}( \llbracket S_1 \rrbracket_D(\rho)) + \beta \llbracket S_2 \rrbracket_{R}(\llbracket S_1 \rrbracket_D( \sigma)) + \alpha \llbracket S_1 \rrbracket_{R}(\rho) + \beta \llbracket S_1 \rrbracket_{R}(\sigma) \\ =& \text{ }\alpha \cdot \llbracket S_2 \rrbracket_{R}(\llbracket S_1 \rrbracket_D(\rho),\llbracket S_1 \rrbracket_{R}(\rho)) + \beta \cdot \llbracket S_2 \rrbracket_{R}(\llbracket S_1 \rrbracket_D( \sigma),\llbracket S_1 \rrbracket_{R}(\sigma)) \\ =& \text{ }\alpha \cdot \llbracket S_1;S_2 \rrbracket_{R}(\rho) + \beta \cdot \llbracket S_1;S_2 \rrbracket_{R}(\sigma) \end{align}\]
For \(\boldsymbol{measure } M[\overline{q}]:\overline{S}\), we have \[\begin{align} &\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S} \rrbracket_{R}(\alpha \rho + \beta \sigma) \\ =& \sum_m \llbracket S_m \rrbracket_{R}(M_m (\alpha \rho + \beta \sigma) M_m^\dagger) \\ =& \sum_m \llbracket S_m \rrbracket_{R}(\alpha M_m \rho M_m^\dagger + \beta M_m \sigma M_m^\dagger) \\ =& \sum_m [\alpha\llbracket S_m \rrbracket_{R}(M_m \rho M_m^\dagger) + \beta\llbracket S_m \rrbracket_{R}(M_m \sigma M_m^\dagger)]\\ =&\text{ } \alpha\sum_m\llbracket S_m \rrbracket_{R}(M_m \rho M_m^\dagger) + \beta\sum_m\llbracket S_m \rrbracket_{R}(M_m \sigma M_m^\dagger)\\ =& \text{ } \alpha\cdot\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S} \rrbracket_{R}(\rho) + \beta\cdot\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S} \rrbracket_{R}(\sigma) \end{align}\]
For \(\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S\), we have \[\begin{align} &\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket_{R}(\alpha \rho + \beta \sigma) \\ =& \lim_{i \to \infty} \llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^i \rrbracket_{R}(\alpha \rho + \beta \sigma) \\ =& \lim_{i \to \infty} \alpha\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^i \rrbracket_{R}(\rho) + \beta\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^i \rrbracket_{R}(\sigma) \\ =& \text{ }\alpha\cdot\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket_{R}(\rho) + \beta\cdot\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket_{R}(\sigma) \end{align}\] by induction hypothesis (for \(\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^i\)) and the fact that limits preserve linearity for positive sequences.
\(a[\ket{\psi}] := \llbracket S \rrbracket_{R}(\ket{\psi} \bra{\psi})\) for all \(\ket{\psi} \in \mathfrak{D}(a) = \{\ket{\psi} \in \mathcal{H}\mid \llbracket S \rrbracket_{R}(\ket{\psi} \bra{\psi}) < \infty \}\) is a symmetric, positive and closed form. Positivity follows immediately from the previous points and symmetry follows from the co-domain of \(\llbracket S \rrbracket_{R}\). We show closeness by induction over the structure of \(S\):
For \(\boldsymbol{skip}, q:=0\) and \(\overline{q}:= U\overline{q}\) is \(a\) exactly the zero form, which is closed.
For \(\boldsymbol{reward} ( c)\), we distinguish between \(c < \infty\) and \(c = \infty\). If \(c < \infty\), then \(a\) is defined on \(\mathcal{H}\) and is closed (e.g., by Proposition [prop:OpstoForms]as it corresponds to the self-adjoint operator \(c\boldsymbol{I}\)). If \(c = \infty\), then \(a\) is the infinity form that is zero on the zero vector and \(\infty\) everywhere else, which is also closed.
For \(S_1;S_2\), let \(a_1\) and \(a_2\) be the (closed, positive, symmetric) forms corresponding to \(S_1\) and \(S_2\) respectively. We know that \(\llbracket S_1 \rrbracket_D\) has a Kraus representation by the previous points and thus we can write \(\llbracket S_1 \rrbracket_D(\ket{\psi}\bra{\psi}) = \sum_i E_i \ket{\psi}\bra{\psi} E_i^\dagger\). Then we have \(a[\ket{\psi}] = \llbracket S_1 \rrbracket_{R}(\ket{\psi}\bra{\psi}) + \llbracket S_2 \rrbracket_{R}(\llbracket S_1 \rrbracket_D(\ket{\psi}\bra{\psi})) = a_1[\ket{\psi}] + \sum_i a_2[E_i \ket{\psi}]\). Then \(a\) is closed by Proposition [prop:FormAddMult] and Lemma 1.
For \(\boldsymbol{measure } M[\overline{q}]:\overline{S}\), let \(a_m\) be the (closed, positive, symmetric) form corresponding to \(S_m\) for all \(m\). We have \(a[\ket{\psi}] = \sum_m a_m[M_m \ket{\psi}]\). Then \(a\) is closed by Proposition [prop:FormAddMult] and Lemma 1.
For \(\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S\), we have \(a[\ket{\psi}] = \lim_{i \to \infty} a_i[\ket{\psi}]\) where \(a_i\) is the form corresponding to \(\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^i\). We can write \(a_i\) as a sum of forms corresponding to sequences of program statements (by induction hypothesis)without loops and thus we can write \(a_i\) as a least upper bound of an increasing sequence of closed forms by Proposition [prop:OpstoForms] and Theorem 1.
◻
Proof of Proposition [prop:hoareProperties]:
Proof.
By definition and because \(\llbracket S \rrbracket_D\) is trace non-increasing (thus the term in square brackets is non-negative) and for reward-free programs is \(\llbracket S \rrbracket_{R}(\rho)= 0\).
\(\mathbb{E}_{\boldsymbol{0}}\left(\rho\right) = 0 \leq \mathbb{E}_{A}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho)\) for all \(\rho\).
\[\begin{align} &\mathbb{E}_{A}\left(\rho\right) \leq \mathbb{E}_{\boldsymbol{I}}\left(\rho\right) = tr(\rho) \\ \Rightarrow \text{ }&\mathbb{E}_{A}\left(\rho\right) \leq tr(\rho) = tr(\llbracket S \rrbracket_D(\rho)) + [tr(\rho) - tr(\llbracket S \rrbracket_D(\rho))] \\ \Rightarrow \text{ }&\mathbb{E}_{A}\left(\rho\right) \leq \mathbb{E}_{\boldsymbol{I}}\left(\llbracket S \rrbracket_D(\rho)\right) + [tr(\rho) - tr(\llbracket S \rrbracket_D(\rho))]\qedhere \end{align}\]
◻
Proof of Proposition [prop:wpProperties]:
Proof.
It is \(\mathbb{E}_{\boldsymbol{0}_{\mathcal{H}}}\left(\llbracket S \rrbracket_D(\rho)\right) = 0 = \mathbb{E}_{wp\llbracket S \rrbracket (\boldsymbol{0}_{\mathcal{H}})}\left(\rho\right)\) for all \(\rho\), so \(wp\llbracket S \rrbracket (\boldsymbol{0}_{\mathcal{H}}) = \boldsymbol{0}_{\mathcal{H}}\) as \(\llbracket S \rrbracket_{R}(\rho) = 0\) for reward-free programs.
Follows by the linearity of expectation values (Proposition [prop:expectationProperties]): \[\begin{align} \mathbb{E}_{wp\llbracket S \rrbracket (c B)}\left(\rho\right) &= \mathbb{E}_{c B}\left(\llbracket S \rrbracket_D(\rho)\right) = c \cdot \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\rho)\right) \\ &= c \cdot \mathbb{E}_{wp\llbracket S \rrbracket (B)}\left(\rho\right) = \mathbb{E}_{c \cdot wp\llbracket S \rrbracket (B)}\left(\rho\right) \\ \mathbb{E}_{wp\llbracket S \rrbracket (B_1 \oplus B_2)}\left(\rho\right) &= \mathbb{E}_{B_1 \oplus B_2}\left(\llbracket S \rrbracket_D(\rho)\right) = \mathbb{E}_{B_1}\left(\llbracket S \rrbracket_D(\rho)\right) + \mathbb{E}_{B_2}\left(\llbracket S \rrbracket_D(\rho)\right) \\ &= \mathbb{E}_{wp\llbracket S \rrbracket (B_1)}\left(\rho\right) + \mathbb{E}_{wp\llbracket S \rrbracket (B_2)}\left(\rho\right) \\ & = \mathbb{E}_{wp\llbracket S \rrbracket (B_1) \oplus wp\llbracket S \rrbracket (B_2)}\left(\rho\right) \end{align}\] This holds for all \(\rho \in \mathcal{D}(\mathcal{H})\) and we conclude that \(wp\llbracket S \rrbracket (c B) = c \cdot wp\llbracket S \rrbracket (B)\) and \(wp\llbracket S \rrbracket (B_1 \oplus B_2) = wp\llbracket S \rrbracket (B_1) \oplus wp\llbracket S \rrbracket (B_2)\) by Lemma 4 and because \(\sqsubseteq\) is a partial order and thus in particular antisymmetric. Note that this property does not hold for programs with rewards as the reward term \(\llbracket S \rrbracket_{R}(\rho)\) is not \(0\) then.
Follows by Lemma 4: \[\begin{align} &B_1 \sqsubseteq B_2 \\ \Rightarrow &\text{ } \forall \rho \in \mathcal{D}(\mathcal{H}) : \mathbb{E}_{B_1}\left(\llbracket S \rrbracket_D(\rho)\right) \leq \mathbb{E}_{B_2}\left(\llbracket S \rrbracket_D(\rho)\right) \\ \Rightarrow & \text{ }\forall \rho \in \mathcal{D}(\mathcal{H}) : \mathbb{E}_{wp\llbracket S \rrbracket (B_1)}\left(\rho\right) + \llbracket S \rrbracket_{R}(\rho) \leq \mathbb{E}_{wp\llbracket S \rrbracket (B_2)}\left(\rho\right) + \llbracket S \rrbracket_{R}(\rho)\\ \Rightarrow & \text{ }\forall \rho \in \mathcal{D}(\mathcal{H}) : \mathbb{E}_{wp\llbracket S \rrbracket (B_1)}\left(\rho\right) \leq \mathbb{E}_{wp\llbracket S \rrbracket (B_2)}\left(\rho\right)\\ \Rightarrow & \text{ }wp\llbracket S \rrbracket (B_1) \sqsubseteq wp\llbracket S \rrbracket (B_2) \end{align}\]
The existence of both suprema follows by Theorem 1 and the monotonicity. The equivalence follows by continuity of expectation values (Proposition [prop:expectationProperties]): \[\begin{align} \mathbb{E}_{wp\llbracket S \rrbracket (\bigvee_n B_n)}\left(\rho\right) &= \mathbb{E}_{\bigvee_n B_n}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho) \\ &= \bigvee_n \mathbb{E}_{B_n}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho) \\ &= \bigvee_n \mathbb{E}_{wp\llbracket S \rrbracket (B_n)}\left(\rho\right) = \mathbb{E}_{\bigvee_n wp\llbracket S \rrbracket (B_n)}\left(\rho\right) \end{align}\] and the same argument as given in the proof of linearity.
◻
Proof of Theorem 3:
Proof. In the following we will use \(a\) (and later \(A\)) for the precondition and \(b\) (and \(B\)) for the postcondition.
By Definition 7, we can use the Kraus representation of \(\llbracket S \rrbracket_D\) and write \(\llbracket S \rrbracket_D(\rho) = \sum_i E_i \rho E_i^\dagger\) as a sum for some bounded operators \(E_i\). They are not unique, but for now we fix one family \(E_i\) (later we will show that it does not matter which representation we choose). Then we define \[\begin{align} a_i &= \lambda \psi. b_{E_i}[\ket{\psi}]+ \llbracket S \rrbracket_{R}(\ket{\psi}\bra{\psi})\\ \hat{a_j} &= \sum_{i\leq j} a_i\\ a &= \bigvee_j \hat{a_j} \end{align}\] As \(b\in \mathcal{F}(\mathcal{H})\), \(b_{E_i} \in \mathcal{F}(\mathcal{H})\) by Proposition [prop:FormAddMult] as it is just applying a bounded operator \(E_i\). \(\llbracket S \rrbracket_{R}(\ket{\psi}\bra{\psi})\) corresponds also to a form-expectation by Definition 7. Thus \(a_i\) (as the sum of two form-expectations) is a form-expectation by Proposition [prop:FormAddMult].
\(\hat{a_j}\) is a finite sum, we can apply Proposition [prop:FormAddMult] again and obtain that \(\hat{a_j} \in \mathcal{F}(\mathcal{H})\) for all \(j\) again. As \(a_i\) is positive for all \(i\) , \(\hat{a_j}\) is increasing in \(j\).
Then we can also consider the corresponding expectations \(\hat{A}_j\) for each \(j\). They form an increasing chain of expectations by Proposition[prop:orderEquivalence], thus the corresponding least upper bound \(\bigvee_j \hat{A}_j\) exists by Theorem 1 and is an expectation and \(a\) is its corresponding form, so \(a \in \mathcal{F}(\mathcal{H})\).
Now we show that \(wp\llbracket S \rrbracket (B)\) is the corresponding expectation of \(a = wp_f\llbracket S \rrbracket (b)\). By the above part, we know that there exists a corresponding expectation \(A\) to \(a\).
First we show that \(\mathbb{E}_{B}\left(\llbracket S \rrbracket(\ket{\psi}\bra{\psi})\right) + \llbracket S \rrbracket_{R}(\ket{\psi}\bra{\psi})= \mathbb{E}_{A}\left(\ket{\psi}\bra{\psi}\right)\) holds for all \(\ket{\psi}\). Let \(\ket{\psi}\in \mathcal{H}\). Then \(\llbracket S \rrbracket(\ket{\psi}\bra{\psi}) = \sum_i E_i \ket{\psi}\bra{\psi} E_i^\dagger\).
If there is at least one \(E_i \ket{\psi} \not \in \mathfrak{D}(B)\) then \(\ket{\psi} \not \in \mathfrak{D}(a)\) and both sides are \(\infty\).
If all \(E_i \ket{\psi} \in \mathfrak{D}(B)\), then \[\begin{align} &\text{ } \mathbb{E}_{B}\left(\llbracket S \rrbracket(\ket{\psi}\bra{\psi})\right) + \llbracket S \rrbracket_{R}(\ket{\psi}\bra{\psi})\\ =& \text{ }\mathbb{E}_{B}\left(\sum_i E_i \ket{\psi} \bra{\psi}E_i^\dagger\right) + \llbracket S \rrbracket_{R}(\ket{\psi}\bra{\psi})\\ =& \sum_i \mathbb{E}_{B}\left(E_i \ket{\psi} \bra{\psi}E_i^\dagger\right) + \llbracket S \rrbracket_{R}(\ket{\psi}\bra{\psi})\\ =& \sum_i b[E_i \ket{\psi}]+ \llbracket S \rrbracket_{R}(\ket{\psi}\bra{\psi})\\ & = \sum_i a_i[\ket{\psi}] = a[\ket{\psi}] =\mathbb{E}_{A}\left(\ket{\psi}\bra{\psi}\right) \end{align}\]
We can conclude that \(\mathbb{E}_{A}\left(\rho\right) = \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho)\) for all \(\rho = \sum_i p_i \ket{\psi_i}\bra{\psi_i}\): \[\begin{align} \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho) &= \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\sum_i p_i \ket{\psi_i}\bra{\psi_i})\right) + \llbracket S \rrbracket_{R}(\sum_i p_i\ket{\psi_i}\bra{\psi_i})\\ &= \mathbb{E}_{B}\left(\sum_i p_i \llbracket S \rrbracket_D(\ket{\psi_i}\bra{\psi_i})\right)+ \sum_i p_i \llbracket S \rrbracket_{R}(\ket{\psi_i}\bra{\psi_i})\\ &= \sum_i p_i \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\ket{\psi_i}\bra{\psi_i})\right) + \sum_i p_i \llbracket S \rrbracket_{R}(\ket{\psi_i}\bra{\psi_i})\\ &= \sum_i p_i \left(\mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\ket{\psi_i}\bra{\psi_i})\right) + \llbracket S \rrbracket_{R}(\ket{\psi_i}\bra{\psi_i})\right)\\ &= \sum_i p_i \mathbb{E}_{A}\left(\ket{\psi_i}\bra{\psi_i}\right) = \mathbb{E}_{A}\left(\sum_i p_i \ket{\psi_i}\bra{\psi_i}\right) \\ &= \mathbb{E}_{A}\left(\rho\right) \end{align}\] as \(\llbracket S \rrbracket_D, \llbracket S \rrbracket_{R}\) and \(\mathbb{E}\) are linear.
In the beginning, we fixed one Kraus representation \(E_i\). Now lets assume there is another one \(F_j\) with \(\llbracket S \rrbracket_D^F(\rho) := \sum_j F_j \rho F_j^\dagger =\llbracket S \rrbracket_D(\rho)= \sum_i E_i \rho E_i^\dagger =: \llbracket S \rrbracket_D^E(\rho)\) for all \(\rho\). Let \(A_F\) and \(A_E\) be the corresponding expectations to \(wp_f\llbracket S_F \rrbracket (a)\) and \(wp_f\llbracket S_E \rrbracket (a)\) respectively. Then for all \(\rho\) \[\begin{align} \mathbb{E}_{A_F}\left(\rho\right) = \mathbb{E}_{B}\left(\llbracket S \rrbracket_D^F(\rho)\right) + \llbracket S \rrbracket_{R}(\rho) = \mathbb{E}_{B}\left(\llbracket S \rrbracket_D^E(\rho)\right) + \llbracket S \rrbracket_{R}(\rho) = \mathbb{E}_{A_E}\left(\rho\right). \end{align}\] Together with the fact that \(\sqsubseteq\) is a partial order and thus antisymmetric by Proposition [prop:orderproperties] and Lemma 4, we conclude \(wp_f\llbracket S_F \rrbracket (a) = wp_f\llbracket S_E \rrbracket (a)\) and thus the definition does not depend on the choice of Kraus operators. ◻
Proof of Proposition [prop:wpDefinition]:
Proof. We have to check two things:
\(wp\llbracket S \rrbracket (B)\) is an expectation, and
\(\mathbb{E}_{wp\llbracket S \rrbracket (B)}\left(\rho\right) = \mathbb{E}_{B}\left(\llbracket S \rrbracket_D(\rho)\right) + \llbracket S \rrbracket_{R}(\rho)\) for all \(\rho \in \mathcal{D}(\mathcal{H})\).
We show both statements together by an induction on the structure of \(S\). Let \(\rho = \sum_i p_i \ket{\psi_i}\bra{\psi_i} \in \mathcal{D}(\mathcal{H})\) with \(p_i>0\) and \(B\in \mathcal{E}(\mathcal{H})\) with corresponding form \(b \in \mathcal{F}(\mathcal{H})\).
\(S = \boldsymbol{skip}\): Trivial as \(wp\llbracket \boldsymbol{skip} \rrbracket (B) = B\) and \(\llbracket \boldsymbol{skip} \rrbracket_D(\rho)=\rho\), \(\llbracket \boldsymbol{skip} \rrbracket_{R}(\rho) = 0\) for all \(\rho \in \mathcal{D}(\mathcal{H})\).
\(S = q:=0\):
\(wp\llbracket q:=0 \rrbracket (B) \in \mathcal{E}(\mathcal{H})\) by Definition 5 as \(\ket{n}\bra{0}\) are bounded operators. The sum is infinite and by Lemma 1 in \(\mathcal{E}(\mathcal{H})\).
It is \[\begin{align} \mathbb{E}_{wp\llbracket q:=0 \rrbracket (B)}\left(\rho\right) =& \text{ }\mathbb{E}_{\sum_n \ket{n}\bra{0} \odot B \odot \ket{0}\bra{n}}\left(\rho\right) \\ =& \sum_n \mathbb{E}_{\ket{n}\bra{0} \odot B \odot \ket{0}\bra{n}}\left(\rho\right) \\ =& \sum_n \mathbb{E}_{B}\left(\ket{0}\bra{n} \rho \ket{n}\bra{0}\right) \\ =& \text{ }\mathbb{E}_{B}\left(\sum_n \ket{0}\bra{n} \rho \ket{n}\bra{0}\right) \\ =& \text{ }\mathbb{E}_{B}\left(\llbracket q:=0 \rrbracket_D(\rho)\right) \end{align}\] as \(\mathbb{E}\) is linear in both the state and the expectation (Lemma 5) and we can move bounded operators from the expectation to the density operator by Proposition [prop:boundedOpinExpectation]. As \(\llbracket q:=0 \rrbracket_{R}(\rho) = 0\) for all \(\rho\), we have \(\mathbb{E}_{wp\llbracket q:=0 \rrbracket (B)}\left(\rho\right) = \mathbb{E}_{B}\left(\llbracket q:=0 \rrbracket_D(\rho)\right) + \llbracket q:=0 \rrbracket_{R}(\rho)\).
\(S = \overline{q}:= U\overline{q}\):
\(wp\llbracket \overline{q}:= U\overline{q} \rrbracket (B)\in \mathcal{E}(\mathcal{H})\) by Definition 5 as \(U\) is a bounded operator.
Let \(wp\) the corresponding form of \(wp\llbracket \overline{q}:= U\overline{q} \rrbracket (B)_\infty\). It is \(\mathfrak{D}(wp) = \{\ket{\psi} \in \mathcal{H}\mid U\ket{\psi} \in \mathfrak{D}(b)\}\).
If there is (at least) one \(\ket{\psi_i}\not \in \mathfrak{D}(wp)\), then \(\mathbb{E}_{wp\llbracket S \rrbracket (B)}\left(\rho\right) = \infty\). By the definition of \(\mathfrak{D}(wp)\), we have \(\mathbb{E}_{B}\left(\llbracket \overline{q}:= U\overline{q} \rrbracket_D(\ket{\psi_i}\bra{\psi_i})\right) = \infty\). Overall it is \(\mathbb{E}_{wp\llbracket \overline{q}:= U\overline{q} \rrbracket (B)}\left(\rho\right) =\infty = \mathbb{E}_{B}\left(\llbracket \overline{q}:= U\overline{q} \rrbracket_D(\rho)\right)\) by linearity.
If \(\ket{\psi_i} \in \mathfrak{D}(wp)\) for all \(i\), then \[\begin{align} \mathbb{E}_{wp\llbracket \overline{q}:= U\overline{q} \rrbracket (B)}\left(\rho\right) & = \sum_i p_i wp[\ket{\psi_i}]\\ &= \sum_i p_i b[U\ket{\psi_i}] \\ &= \sum_i p_i \mathbb{E}_{B}\left(\llbracket \overline{q}:= U\overline{q} \rrbracket_D(\ket{\psi_i}\bra{\psi_i})\right) \\ &= \mathbb{E}_{B}\left(\llbracket \overline{q}:= U\overline{q} \rrbracket_D(\rho)\right) \end{align}\]
Overall we have \(\mathbb{E}_{wp\llbracket \overline{q}:= U\overline{q} \rrbracket (B)}\left(\rho\right) = \mathbb{E}_{B}\left(\llbracket \overline{q}:= U\overline{q} \rrbracket_D(\rho)\right) + \llbracket \overline{q}:= U\overline{q} \rrbracket_{R}(\rho)\) as \(\llbracket \overline{q}:= U\overline{q} \rrbracket_{R}(\rho) = 0\) for all \(\rho\).
\(S = \boldsymbol{reward} ( c)\):
\(wp\llbracket \boldsymbol{reward} ( c) \rrbracket (B) = B \oplus c \cdot \boldsymbol{I}\) is in \(\mathcal{E}(\mathcal{H})\) by Definition 5.
It is \(\mathbb{E}_{wp\llbracket \boldsymbol{reward} ( c) \rrbracket (B)}\left(\rho\right) = \mathbb{E}_{B}\left(\llbracket \boldsymbol{reward} ( c) \rrbracket_D(\rho)\right) + \llbracket \boldsymbol{reward} ( c) \rrbracket_{R}(\rho)\) as \[\begin{align} \mathbb{E}_{wp\llbracket \boldsymbol{reward} ( c) \rrbracket (B)}\left(\rho\right) &= \mathbb{E}_{B \oplus c \cdot \boldsymbol{I}}\left(\rho\right) \\ & = \mathbb{E}_{B}\left(\llbracket \boldsymbol{reward} ( c) \rrbracket_D(\rho)\right) + \mathbb{E}_{c \cdot \boldsymbol{I}}\left(\rho\right) \\ &= \mathbb{E}_{B}\left(\llbracket \boldsymbol{reward} ( c) \rrbracket_D(\rho)\right) + c \cdot tr(\rho) \\ &= \mathbb{E}_{B}\left(\llbracket \boldsymbol{reward} ( c) \rrbracket_D(\rho)\right) + \llbracket \boldsymbol{reward} ( c) \rrbracket_{R}(\rho) \end{align}\] by linearity of expectation values (Proposition [prop:expectationProperties]).
\(S = S_1;S_2\):
\(wp\llbracket S_1 \rrbracket (wp\llbracket S_2 \rrbracket (B)) \in \mathcal{E}(\mathcal{H})\) follows immediately from the induction hypothesis.
\[\begin{align} \mathbb{E}_{wp\llbracket S_1;S_2 \rrbracket (B)}\left(\rho\right) & = \mathbb{E}_{wp\llbracket S_1 \rrbracket (wp\llbracket S_2 \rrbracket (B))}\left(\rho\right) \\ &\overset{IH}{=} \mathbb{E}_{wp\llbracket S_2 \rrbracket (B)}\left(\llbracket S_1 \rrbracket_D(\rho)\right) + \llbracket S_1 \rrbracket_{R}(\rho) \\ &\overset{IH}{=} \mathbb{E}_{B}\left(\llbracket S_2 \rrbracket_D(\llbracket S_1 \rrbracket_D(\rho))\right) + \llbracket S_2 \rrbracket_{R}(\llbracket S_1 \rrbracket_D(\rho)) + \llbracket S_1 \rrbracket_{R}(\rho) \\ &= \mathbb{E}_{B}\left(\llbracket S_1;S_2 \rrbracket_D(\rho)\right) + \llbracket S_1;S_2 \rrbracket_{R}(\rho) \end{align}\]
\(S = \boldsymbol{measure } M[\overline{q}]:\overline{S'}\):
By induction hypothesis, \(wp\llbracket S_m' \rrbracket (B) \in \mathcal{E}(\mathcal{H})\) for all \(m\). Then by Definition 5, \(M_m^\dagger \odot wp\llbracket S_m' \rrbracket (B) \odot M_m \in \mathcal{E}(\mathcal{H})\) for all \(m\) as \(M_m\) are bounded operators. We can define \(\hat{f}_n = \sum_{m\leq n} M_m^\dagger \odot wp\llbracket S_m' \rrbracket (B) \odot M_m\). As each \(M_m^\dagger \odot wp\llbracket S_m' \rrbracket (B) \odot M_m \in \mathcal{E}(\mathcal{H})\), \(\hat{f}_n \in \mathcal{E}(\mathcal{H})\) for all \(n\) as it is a finite sum by Definition 5. As \(\hat{f}_n\) is an increasing chain (each \(M_m^\dagger \odot wp\llbracket S_m' \rrbracket (B) \odot M_m\) is positive), by Theorem 1, the least upper bound \(\bigvee_n \hat{A}_n\) exists and corresponds to \(\sum_m M_m^\dagger \odot wp\llbracket S_m' \rrbracket (B) \odot M_m\).
Let \(wp\) be the form-expectation of \(wp\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket (B)\) and \(wp_m\) the one of \(wp\llbracket S_m' \rrbracket (B)\). It is \(\mathfrak{D}(wp) = \bigcap_m \{\ket{\psi}\mid M_m \ket{\psi} \in \mathfrak{D}(wp_m)\}\).
If there is an \(i\) such that \(\ket{\psi_i}\not \in \mathfrak{D}(wp)\), then there must be a \(j\) such that \(M_j \ket{\psi_i} \not \in \mathfrak{D}(wp_j)\) and thus \[\begin{align} \infty =& \mathbb{E}_{wp\llbracket S_j' \rrbracket (B)}\left(\ket{M_j \psi_i}\bra{M_j \psi_i}\right) \\ \overset{IH}{=}&\mathbb{E}_{B}\left(\llbracket S_j' \rrbracket_D(\ket{M_j \psi_i}\bra{M_j \psi_i})\right) + \llbracket S_j' \rrbracket_{R}(\ket{M_j \psi_i}\bra{M_j \psi_i}) \end{align}\] By linearity of semantics (Proposition [prop:semanticsProperties]) and expectation values (Proposition [prop:expectationProperties], Lemma 5): \[\begin{align} &\mathbb{E}_{B}\left(\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket_D(\rho)\right) + \llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket_{R}(\rho)\\ =& \infty = \mathbb{E}_{wp\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S} \rrbracket (B)}\left(\rho\right). \end{align}\]
Assume \(\ket{\psi_i} \in \mathfrak{D}(wp)\) for all \(i\), then \(M_m \ket{\psi_i} \in \mathfrak{D}(wp_m)\) for all \(i,m\). Then \[\begin{align} &\mathbb{E}_{wp\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S} \rrbracket (B)}\left(\rho\right) \\ =& \sum_{m} \mathbb{E}_{M_m^\dagger \odot wp\llbracket S_m' \rrbracket (B) \odot M_m}\left(\rho\right) \\ = & \sum_{m} \sum_i p_i wp_m[M_m \ket{\psi_i}] \\ \overset{IH}{=} &\sum_{m} \sum_i p_i \mathbb{E}_{B}\left(\llbracket S_m' \rrbracket_D(\ket{M_m \psi_i}\bra{M_m \psi_i})\right) + \llbracket S_m' \rrbracket_{R}(\ket{M_j \psi_i}\bra{M_j \psi_i}) \\ = &\sum_i p_i \sum_{m} \mathbb{E}_{B}\left(\llbracket S_m' \rrbracket_D(\ket{M_m \psi_i}\bra{M_m \psi_i})\right) + \llbracket S_m' \rrbracket_{R}(\ket{M_j \psi_i}\bra{M_j \psi_i})\\ =& \sum_i p_i \mathbb{E}_{B}\left(\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket_D(\ket{\psi_i}\bra{\psi_i})\right) \\ & +\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket_{R}(\ket{\psi_i}\bra{\psi_i}) \\ =& \mathbb{E}_{B}\left(\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket_D(\rho)\right) + \llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket_{R}(\rho) \end{align}\] As \(\mathbb{E}_{B}\left(\ket{\psi}\bra{\psi}\right), \llbracket S \rrbracket_{R}(\ket{\psi}\bra{\psi})\) and \(p_i\) are non-negative for all \(\ket{\psi}, S\), we can switch the sums in the forth step due to Fubini’s theorem for infinite series. We also use linearity of semantics (Proposition [prop:semanticsProperties]) and expectation values (Proposition [prop:expectationProperties], Lemma 5).
\(S = \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S'\): In this case we prove both parts together. First of all, we show \(wp\llbracket S' \rrbracket (A_n) \in \mathcal{E}(\mathcal{H})\) for all \(n\). Each \(A_n \in \mathcal{E}(\mathcal{H})\) because it is defined via sums and applications of bounded operators on expectations (see Definition 5). Now it reminds to show that \(\{A_n\}_n\) is an increasing chain, then the least upper bound \(\bigvee_n A_n\) exists by Theorem 1 and is in \(\mathcal{E}(\mathcal{H})\).
First we show \[\begin{align} \label{align:expectAn} \mathbb{E}_{A_n}\left(\rho\right) = \mathbb{E}_{B}\left(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_D(\rho)\right) + \llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_{R}(\rho) \end{align}\tag{1}\] by induction on \(n\):
\(n=0\): \[\begin{align} \mathbb{E}_{A_0}\left(\rho\right) =& \text{ }\mathbb{E}_{\boldsymbol{0}}\left(\rho\right) = 0 \\ =& \text{ }\mathbb{E}_{B}\left(\llbracket \Omega \rrbracket_D(\rho)\right) + \llbracket \Omega \rrbracket_{R}(\rho) \\ =& \text{ }\mathbb{E}_{B}\left(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^0 \rrbracket(\rho)\right) + \llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^0 \rrbracket_{R}(\rho) \end{align}\]
\(n \to n+1\): Let \(wp_n\) be the form corresponding to \(wp\llbracket S' \rrbracket (A_n)\), \(b\) to \(B_\infty\) and \(a_{n}\) the form corresponding to \({A_n}_\infty\). Then \(\mathfrak{D}(a_{n+1}) = \{\psi \mid M_0 \psi \in \mathfrak{D}(b)\} \cap \{\psi \mid M_1 \psi \in \mathfrak{D}(wp_n)\}\). Let \(\rho = \sum_i p_i \ket{\psi_i}\bra{\psi_i}\) be a decomposition of \(\rho\) into pure states. We show the statement for each \(\ket{\psi_i}\bra{\psi_i}\), then we can conclude it for \(\rho\) by linearity of expectation values and the semantics (Proposition [prop:expectationProperties], Lemma 5 and Proposition [prop:semanticsProperties]). We distinguish two cases:
Assume there is an \(i\) such that \(\ket{\psi_i} \not \in \mathfrak{D}(a_{n+1})\), then \(\mathbb{E}_{A_{n+1}}\left(\rho\right) = \infty\).
If \(M_0 \ket{\psi_i} \not \in \mathfrak{D}(b)\), then \(\mathbb{E}_{B}\left(M_0 \ket{\psi_i}\bra{\psi_i} M_0^\dagger\right) = \infty\) and thus by linearity of expectation values and semantics (Proposition [prop:expectationProperties], Lemma 5, Proposition [prop:semanticsProperties]), we get \(\mathbb{E}_{B}\left(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^{n+1} \rrbracket_D(\rho)\right) = \infty\), thus the sum with \(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^{n+1} \rrbracket_{R}(\rho)\) is \(\infty\) as well.
If \(M_1 \ket{\psi_i} \not \in \mathfrak{D}(wp_n)\), then \[\begin{align} \infty &= \mathbb{E}_{wp\llbracket S' \rrbracket (A_n)}\left(\ket{M_1 \psi_i}\bra{M_1 \psi_i}\right) \\ & =
\mathbb{E}_{A_n}\left(\llbracket S' \rrbracket_D(\ket{M_1 \psi_i}\bra{M_1 \psi_i})\right) \\ &= \mathbb{E}_{B}\left(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_D(\llbracket S' \rrbracket_D(\ket{M_1
\psi_i}\bra{M_1 \psi_i}))\right)
\end{align}\] By linearity (Proposition [prop:expectationProperties], Lemma 5 and Proposition [prop:semanticsProperties]), we have
\(\mathbb{E}_{B}\left(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^{n+1} \rrbracket_D(\rho)\right) = \infty\) and thus the same for the addition with \(\llbracket
\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^{n+1} \rrbracket_{R}(\rho)\).
Assume \(\ket{\psi_i} \in \mathfrak{D}(a_{n+1})\) for all \(i\). \[\begin{align} \mathbb{E}_{A_{n+1}}\left(\ket{\psi_i}\bra{\psi_i}\right) =& \text{ } \mathbb{E}_{M_0^\dagger \odot B \odot M_0}\left(\ket{\psi_i}\bra{\psi_i}\right) + \mathbb{E}_{M_1^\dagger \odot wp\llbracket S' \rrbracket (A_n) \odot M_1}\left(\ket{\psi_i}\bra{\psi_i}\right) \\ =&\text{ } b[M_0 \ket{\psi_i}] + wp_n[M_1 \ket{\psi_i}] \\ =&\text{ } \mathbb{E}_{B}\left(\ket{M_0 \psi_i}\bra{M_0 \psi_i}\right) + \mathbb{E}_{wp\llbracket S' \rrbracket (A_n)}\left(\ket{M_1 \psi_i}\bra{M_1 \psi_i}\right) \\ =&\text{ } \mathbb{E}_{B}\left(\ket{M_0 \psi_i}\bra{M_0 \psi_i}\right) \\ &+ \mathbb{E}_{A_n}\left(\llbracket S' \rrbracket_D(\ket{M_1 \psi_i}\bra{M_1 \psi_i})\right) + \llbracket S' \rrbracket_{R}(\ket{M_1 \psi_i} \bra{M_1 \psi_i})\\ =&\text{ } \mathbb{E}_{B}\left(\ket{M_0 \psi_i}\bra{M_0 \psi_i}\right) \\ &+ \mathbb{E}_{B}\left(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_D(\llbracket S' \rrbracket_D(\ket{M_1 \psi_i}\bra{M_1 \psi_i}))\right) \\ &+ \llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_{R}(\llbracket S' \rrbracket_D(\ket{M_1 \psi_i}\bra{M_1 \psi_i})) \\ & + \llbracket S' \rrbracket_{R}(\ket{M_1 \psi_i} \bra{M_1 \psi_i}) \\ =&\text{ } \mathbb{E}_{B}\left(\llbracket \boldsymbol{skip} \rrbracket_D(\ket{M_0 \psi_i}\bra{M_0 \psi_i})\right) \\ &+ \mathbb{E}_{B}\left(\llbracket S'; \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_D(\ket{M_1 \psi_i}\bra{M_1 \psi_i})\right) \\ &+ \llbracket \boldsymbol{skip} \rrbracket_{R}(\ket{M_0 \psi_i}\bra{M_0 \psi_i}) \\ &+ \llbracket S'; \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_{R}(\ket{M_1 \psi_i}\bra{M_1 \psi_i}) \\ =&\text{ } \mathbb{E}_{B}\left(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_D(\ket{\psi_i}\bra{ \psi_i})\right) \\ &+ \llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_{R}(\ket{ \psi_i}\bra{ \psi_i}) \end{align}\]
Now we can show that \(\{A_n\}_n\) is an increasing chain:
\(n=0\): \(A_0 = \boldsymbol{0}\sqsubseteq A_1\) and \(\mathfrak{D}(A_1) \subseteq \mathcal{H}=\mathfrak{D}(\boldsymbol{0})\)
\(n \to n+1\): \(A_{n+1} = M_0^\dagger \odot B \odot M_0 + M_1^\dagger \odot wp\llbracket S' \rrbracket (A_n) \odot M_1\) \[\begin{align} & \text{ }A_{n-1} \sqsubseteq A_n \\ \Rightarrow & \text{ }wp\llbracket S' \rrbracket (A_{n-1}) \sqsubseteq wp\llbracket S' \rrbracket (A_n) \\ \Rightarrow & \text{ } M_1^\dagger \odot wp\llbracket S' \rrbracket (A_{n-1}) \odot M_1 \sqsubseteq M_1^\dagger \odot wp\llbracket S' \rrbracket (A_n) \odot M_1 \\ \Rightarrow & \text{ } M_0^\dagger \odot B \odot M_0 + M_1^\dagger \odot wp\llbracket S' \rrbracket (A_{n-1}) \odot M_1\\ & \sqsubseteq M_0^\dagger \odot B \odot M_0 + M_1^\dagger \odot wp\llbracket S' \rrbracket (A_n) \odot M_1 \\ \Rightarrow & \text{ } A_n \sqsubseteq A_{n+1} \end{align}\]
The first step holds by the monotonicity of \(wp\) (shown in Proposition [prop:wpProperties]). The next two steps hold by Proposition [prop:orderproperties]. Thus we have shown \(\bigvee_n A_n \in \mathcal{E}(\mathcal{H})\).
Finally, we can conclude the second part of the proof based on the previous results: \[\begin{align} & \mathbb{E}_{wp\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (B)}\left(\rho\right) \\ & = \mathbb{E}_{\bigvee_n A_n}\left(\rho\right)\\ &= \bigvee_n \mathbb{E}_{A_n}\left(\rho\right) \\ &\overset{Eq. \ref{align:expectAn}}{=} \bigvee_n [\mathbb{E}_{B}\left(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_D(\rho)\right) + \llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_{R}(\rho)]\\ & = \bigvee_n \mathbb{E}_{B}\left(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_D(\rho)\right) + \lim_n \llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_{R}(\rho)\\ &= \mathbb{E}_{B}\left(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket_D(\rho)\right) + \llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket_{R}(\rho) \end{align}\] because both \(\mathbb{E}_{B}\left(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_D(\rho)\right)\) and \(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S^n \rrbracket_{R}(\rho)\) are increasing in \(n\).
◻
Proof of Proposition [prop:wpBoundedEquiv]:
Proof.
First of all note that if \(A \sqsubseteq\boldsymbol{I}\) is bounded, then \(\mathbb{E}_{A}\left(\rho\right) = tr(A\rho)\) for all partial density operators \(\rho \in \mathcal{D}(\mathcal{H})\) as \(\mathfrak{D}(A) = \mathcal{H}\) for bounded operators.
Then the definition of total and partial correctness are exactly the same as in [8] for reward-free programs \(S\) as \(\llbracket S \rrbracket_{R}(\rho) = 0\) for all \(\rho\).
The definition of weakest pre-expectation is also the same as in [1].
Finally, the concrete representation of the weakest pre-expectation transformer \(wp\) differs only by the addition and multiplication but for bounded operators they coincide by Proposition [prop:BoundedAddition].
◻
Proof of Proposition [prop:park]:
Proof. As a technical result, we can show that the weakest pre-expectation of a loop is equivalent to the least upper bound of its characteristic function: Let \(\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S\) be a loop in qrWhile and \(B \in \mathcal{E}(\mathcal{H})\) be a post-expectation. Then \(wp\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (B) = \bigvee_n \psi_B^n(0)\).
To show this equivalence, we show \(\psi_B^n(0) = A_n\) for all \(n\) where \(A_n\) is defined as in Table 1:
\(n=0\): \(\psi_B^0(0) = 0 = A_0\)
\(n \to n+1\):
\[\begin{align} \psi_B^{n+1}(0) &= \psi_B(\psi_B^n(0)) \\ &= M_0^\dagger \odot B \odot M_0 \oplus M_1^\dagger \odot wp\llbracket S \rrbracket (\psi_B^n(0)) \odot M_1 \\ &= M_0^\dagger \odot B \odot M_0 \oplus
M_1^\dagger \odot wp\llbracket S \rrbracket (A_n) \odot M_1 \\ &= A_{n+1}
\end{align}\]
Now we continue by showing that \(\psi_B\) is monotone: Let \(A_1, A_2 \in \mathcal{E}(\mathcal{H})\) with \(A_1 \sqsubseteq A_2\), then \[\begin{align} A_1 &\sqsubseteq A_2 \\ \overset{Prop. \ref{prop:wpProperties}}{\Rightarrow} wp\llbracket S \rrbracket (A_1) &\sqsubseteq wp\llbracket S \rrbracket (A_2) \\ \overset{Prop. \ref{prop:orderproperties}}{\Rightarrow} M_1^\dagger \odot wp\llbracket S \rrbracket (A_1) \odot M_1 &\sqsubseteq M_1^\dagger \odot wp\llbracket S \rrbracket (A_2) \odot M_1 \\ \overset{Prop. \ref{prop:orderproperties}}{\Rightarrow} M_0^\dagger \odot B \odot M_0 \oplus M_1^\dagger \odot wp\llbracket S \rrbracket (A_1) \odot M_1 &\sqsubseteq M_0^\dagger \odot B \odot M_0 \oplus M_1^\dagger \odot wp\llbracket S \rrbracket (A_2) \odot M_1 \\ \Rightarrow \psi_B(A_1) &\sqsubseteq\psi_B(A_2) \end{align}\]
We can show that \(\psi_B(A)\sqsubseteq A\) implies \(\psi^n_B(0) \sqsubseteq A\) for all \(n\in \mathbb{N}\) by induction over \(n\):
\(n=0\): \(\psi^0_B(0) = 0 \sqsubseteq A\) as \(A\) is positive.
\(n \to n+1\): \[\begin{align} \psi_B(A) &\sqsubseteq A \\ \overset{IH}{\Rightarrow} \psi^n_B(0) &\sqsubseteq A \\ \Rightarrow \psi_B(\psi^n_B(0)) &\sqsubseteq\psi_B(A) \\ \Rightarrow \psi^{n+1}_B(0) &\sqsubseteq\psi_B(A) \\ \Rightarrow \psi^{n+1}_B(0) &\sqsubseteq A \end{align}\] where the second step holds by monotonicity of \(\psi_B\) and the last step holds by the assumption \(\psi_B(A) \sqsubseteq A\) and the transitivity of \(\sqsubseteq\) (Proposition [prop:orderproperties]).
Finally, we can show that whole statement: \[\begin{align} \psi_B(A)\sqsubseteq A &\Rightarrow \forall n\in \mathbb{N}: \psi^n_B(0) \sqsubseteq A \\ & \Rightarrow \bigvee_n \psi^n_B(0) \sqsubseteq A \\ & \Rightarrow wp\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (B) \sqsubseteq A \end{align}\] where the first step holds by the above induction, the second one by the definition of \(\bigvee\) and the last one by the technical result at the beginning of the proof. ◻
The proof of Proposition [prop:parkWLP] works completely analogous.
Proof of Proposition [prop:AstPastUsingWp]:
Proof.
\(\forall \rho \in \mathcal{D}(\mathcal{H})\) is \(\llbracket S \rrbracket_{R}(\rho) = 0\), thus \[\begin{align} tr(\llbracket S \rrbracket_D(\rho)) = tr(\boldsymbol{I}\llbracket S \rrbracket_D(\rho)) = tr(wp\llbracket S \rrbracket (\boldsymbol{I}) \rho) = tr(\boldsymbol{I}\rho) = tr(\rho). \end{align}\]
\(\mathfrak{D}(wp\llbracket T({S}) \rrbracket (\boldsymbol{0})) = \mathcal{H}\) means that \(\mathbb{E}_{wp\llbracket T({S}) \rrbracket (\boldsymbol{0})}\left(\rho\right) < \infty\) for all \(\rho \in \mathcal{D}(\mathcal{H})\), thus it is \(\llbracket T({S}) \rrbracket_{R}(\rho) < \infty\) for all \(\rho \in \mathcal{D}(\mathcal{H})\) and thus \(S\) is PAST. Conversely, if \(S\) is PAST, then \(\llbracket T({S}) \rrbracket_{R}(\rho) < \infty\) for all \(\rho \in \mathcal{D}(\mathcal{H})\), thus \(\mathbb{E}_{wp\llbracket T({S}) \rrbracket (\boldsymbol{0})}\left(\rho\right) < \infty\) for all \(\rho \in \mathcal{D}(\mathcal{H})\) and thus \(\mathfrak{D}(wp\llbracket T({S}) \rrbracket (\boldsymbol{0})) = \mathcal{H}\).
◻
Proof of Proposition [prop:ERTProperties]:
Proof. Let \(S\) be a reward-free qrWhile program, \(A,B \in \mathcal{E}(\mathcal{H})\) and \(c\geq 0\).
Well-definedness & Connection to wp & Monotonicity: We show this together by induction over the structure of \(S\). The connection to wp is shown by induction over the structure of \(S\) as well, and monotonicity follows immediately from the connection to wp and the monotonicity of wp: Let \(A \sqsubseteq B\). We show \(ert\llbracket S \rrbracket (A) \sqsubseteq ert\llbracket S \rrbracket (B)\) based on 2. and the monotonicity of wp (Proposition [prop:wpProperties]): \[\begin{align} &ert\llbracket S \rrbracket (A) \\ &\overset{2.}{=} wp\llbracket S \rrbracket (A) \oplus ert\llbracket S \rrbracket (\boldsymbol{0}) \\ &\sqsubseteq wp\llbracket S \rrbracket (B) \oplus ert\llbracket S \rrbracket (\boldsymbol{0}) \\ &\overset{2.}{=} ert\llbracket S \rrbracket (B) \end{align}\] Induction over the structure of \(S\):
\(S = \boldsymbol{skip}\): Clearly \(ert\llbracket \boldsymbol{skip} \rrbracket (A) \in \mathcal{E}(\mathcal{H})\). \[\begin{align} ert\llbracket \boldsymbol{skip} \rrbracket (A) = A = A + \boldsymbol{0}= wp\llbracket \boldsymbol{skip} \rrbracket (A) \oplus ert\llbracket \boldsymbol{skip} \rrbracket (\boldsymbol{0}) \end{align}\]
\(S = q:=0\): It is \(ert\llbracket q:=0 \rrbracket (A) \in \mathcal{E}(\mathcal{H})\) by Definition 5 as \(\ket{n}\bra{0}\) are bounded operators. The sum is infinite and by Lemma 1 in \(\mathcal{E}(\mathcal{H})\). \[\begin{align} &ert\llbracket q:=0 \rrbracket (A) \\ &= \boldsymbol{I}\oplus\sum_{n=0}^\infty \ket{n}\bra{0} \odot A \odot \ket{0}\bra{n} \\ &= \boldsymbol{I}\oplus wp\llbracket q:=0 \rrbracket (A) \\ &= wp\llbracket q:=0 \rrbracket (A) \oplus ert\llbracket q:=0 \rrbracket (\boldsymbol{0}) \end{align}\]
\(S = \overline{q}:= U\overline{q}\): It is \(ert\llbracket \overline{q}:= U\overline{q} \rrbracket (A) \in \mathcal{E}(\mathcal{H})\) as \(\mathcal{E}(\mathcal{H})\) is closed under \(\oplus\) and bounded-operator application. \[\begin{align} ert\llbracket \overline{q}:= U\overline{q} \rrbracket (A) = U^\dagger \odot A \odot U \oplus\boldsymbol{I}= wp\llbracket \overline{q}:= U\overline{q} \rrbracket (A) \oplus ert\llbracket \overline{q}:= U\overline{q} \rrbracket (\boldsymbol{0}) \end{align}\]
\(S = S_1;S_2\): It is \(ert\llbracket S_1;S_2 \rrbracket (A)\in \mathcal{E}(\mathcal{H})\) by induction hypothesis. \[\begin{align} ert\llbracket S_1;S_2 \rrbracket (A) &= ert\llbracket S_1 \rrbracket (ert\llbracket S_2 \rrbracket (A)) \\ &\overset{IH}{=} ert\llbracket S_1 \rrbracket (wp\llbracket S_2 \rrbracket (A) \oplus ert\llbracket S_2 \rrbracket (\boldsymbol{0})) \\ &\overset{IH}{=} wp\llbracket S_1 \rrbracket (wp\llbracket S_2 \rrbracket (A) \oplus ert\llbracket S_2 \rrbracket (\boldsymbol{0})) \oplus ert\llbracket S_1 \rrbracket (\boldsymbol{0}) \\ &= wp\llbracket S_1 \rrbracket (wp\llbracket S_2 \rrbracket (A)) \oplus wp\llbracket S_1 \rrbracket (ert\llbracket S_2 \rrbracket (\boldsymbol{0})) \oplus ert\llbracket S_1 \rrbracket (\boldsymbol{0}) \\ &\overset{IH}{=}wp\llbracket S_1 \rrbracket (wp\llbracket S_2 \rrbracket (A)) \oplus ert\llbracket S_1 \rrbracket (ert\llbracket S_2 \rrbracket (\boldsymbol{0}))\\ &= wp\llbracket S_1;S_2 \rrbracket (A) \oplus ert\llbracket S_1;S_2 \rrbracket (\boldsymbol{0}) \end{align}\]
\(S = \boldsymbol{measure } M[\overline{q}]:\overline{S'}\):
To show \(ert\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket (A) \in \mathcal{E}(\mathcal{H})\): It is \(M_m^\dagger \odot ert\llbracket S_m' \rrbracket (A) \odot M_m \in \mathcal{E}(\mathcal{H})\) for all \(m\) as \(\mathcal{E}(\mathcal{H})\) is closed under bounded-operator application and \(ert\llbracket S_m' \rrbracket (A) \in \mathcal{E}(\mathcal{H})\) by induction hypothesis. The sum is infinite and in \(\mathcal{E}(\mathcal{H})\) by Lemma 1. Adding \(\boldsymbol{I}\) is also fine as \(\mathcal{E}(\mathcal{H})\) is closed under \(\oplus\). \[\begin{align} &ert\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket (A) \\ &= \boldsymbol{I}\oplus\left(\sum_{m} M_m^\dagger \odot ert\llbracket S_m' \rrbracket (A) \odot M_m \right) \\ &\overset{IH}{=} \boldsymbol{I}\oplus\left(\sum_{m} M_m^\dagger \odot \left(wp\llbracket S_m' \rrbracket (A) \oplus ert\llbracket S_m' \rrbracket (\boldsymbol{0})\right) \odot M_m \right) \\ &= \boldsymbol{I}\oplus\left(\sum_{m} M_m^\dagger \odot wp\llbracket S_m' \rrbracket (A) \odot M_m \right) \oplus\left(\sum_{m} M_m^\dagger \odot ert\llbracket S_m' \rrbracket (\boldsymbol{0}) \odot M_m \right) \\ &= wp\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket (A) \oplus ert\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket (\boldsymbol{0}) \end{align}\] Distributivity for infinite sums holds by Lemma 2 (and for finite ones by Proposition [prop:ContinuityDistributivityFormSum]).
\(S = \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S'\): We consider three different chains: \[\begin{align} ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S' \rrbracket (A) &= \bigvee_n F_n \quad \text{where }\\ F_0 &= \boldsymbol{0},\\ F_{n+1} &= M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (F_n) \odot M_1 \oplus\boldsymbol{I}\\ ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S' \rrbracket (\boldsymbol{0}) &= \bigvee_n G_n \quad \text{where }\\ G_0 &= \boldsymbol{0},\\ G_{n+1} &= M_0^\dagger \odot \boldsymbol{0} \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (G_n) \odot M_1 \oplus\boldsymbol{I}\\ &= M_1^\dagger \odot ert\llbracket S' \rrbracket (G_n) \odot M_1 \oplus\boldsymbol{I}\\ wp\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S' \rrbracket (A) &= \bigvee_n H_n \quad \text{where }\\ H_0 &= \boldsymbol{0},\\ H_{n+1} &= M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot wp\llbracket S' \rrbracket (H_n) \odot M_1 \end{align}\] First of all, each \(F_n\in \mathcal{E}(\mathcal{H})\) by induction over \(n\) as \(\mathcal{E}(\mathcal{H})\) is closed under \(\oplus\) and \(M^\dagger \odot \cdot \odot M\) for any \(M\). We can also show that \(F_n\) is increasing in \(n\) by induction over \(n\) as well:
\(n=0\): \(F_0 = \boldsymbol{0}\sqsubseteq F_1\).
\(n \to n+1\): \[\begin{align} F_{n} &= M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (F_{n-1}) \odot M_1 \oplus\boldsymbol{I}\\ &\sqsubseteq M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (F_{n}) \odot M_1 \oplus\boldsymbol{I}= F_{n+1} \end{align}\] by Proposition [prop:orderproperties] and because \(ert\llbracket S' \rrbracket (F_{n-1}) \sqsubseteq ert\llbracket S' \rrbracket (F_{n})\) holds by the monotonicity of \(ert\llbracket S' \rrbracket (\cdot)\) which follows by induction hypothesis.
Thus \(F_n\) is an increasing sequence in \(n\) and thus \(\bigvee_n F_n\) is well-defined. (Analogously, we can show the same for \(G_n\) and \(H_n\).)
We show by induction over \(n\) that \(F_n = H_n \oplus G_n\) for all \(n\):
\(n=0\): \(F_0 = \boldsymbol{0}= H_0 \oplus G_0\).
\(n \to n+1\): \[\begin{align} F_{n+1} &= M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (F_n) \odot M_1 \oplus\boldsymbol{I}\\ &\overset{IH}{=} M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (H_n \oplus G_n) \odot M_1 \oplus\boldsymbol{I}\\ &\overset{IH}{=} M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot \left(wp\llbracket S' \rrbracket (H_n \oplus G_n) \oplus ert\llbracket S' \rrbracket (\boldsymbol{0})\right) \odot M_1 \oplus\boldsymbol{I}\\ &= M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot \left(wp\llbracket S' \rrbracket (H_n) \oplus wp\llbracket S' \rrbracket (G_n) \oplus ert\llbracket S' \rrbracket (\boldsymbol{0})\right) \odot M_1 \oplus\boldsymbol{I}\\ &\overset{IH}{=} M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot \left(wp\llbracket S' \rrbracket (H_n) \oplus ert\llbracket S' \rrbracket (G_n)\right) \odot M_1 \oplus\boldsymbol{I}\\ &= M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot wp\llbracket S' \rrbracket (H_n) \odot M_1 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (G_n) \odot M_1 \oplus\boldsymbol{I}\\ &= H_{n+1} \oplus G_{n+1} \end{align}\]
Thus we have \(F_n = H_n \oplus G_n\) for all \(n\). Finally, we can show the connection to wp: \[\begin{align} &ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S' \rrbracket (A) = \bigvee_n F_n \\ =& \bigvee_n (H_n \oplus G_n) = \bigvee_n H_n \oplus\bigvee_n G_n \\ =& \text{ }wp\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S' \rrbracket (A) \oplus ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S' \rrbracket (\boldsymbol{0}) \end{align}\]
Continuity: Let \(\{A_i\}_i\) be an increasing chain of expectations. We show \(ert\llbracket S \rrbracket (\bigvee_i A_i) = \bigvee_i ert\llbracket S \rrbracket (A_i)\): \[\begin{align} &\text{ } ert\llbracket S \rrbracket (\bigvee_i A_i)\\ =& \text{ }wp\llbracket S \rrbracket (\bigvee_i A_i) \oplus ert\llbracket S \rrbracket (\boldsymbol{0}) \\ =& \bigvee_i wp\llbracket S \rrbracket (A_i) \oplus ert\llbracket S \rrbracket (\boldsymbol{0}) \\ =& \bigvee_i \left(wp\llbracket S \rrbracket (A_i) \oplus ert\llbracket S \rrbracket (\boldsymbol{0})\right) \\ =& \bigvee_i ert\llbracket S \rrbracket (A_i) \end{align}\] where the first step holds by 2., the second one by the continuity of \(wp\llbracket S \rrbracket (\cdot)\) (Proposition [prop:wpProperties]) and the third one by the continuity of \(\oplus\) (Proposition [prop:ContinuityDistributivityFormSum]).
Constant propagation: We show \(ert\llbracket S \rrbracket (c\cdot A) = c\cdot A \oplus ert\llbracket S \rrbracket (\boldsymbol{0})\) \[\begin{align} &ert\llbracket S \rrbracket (c\cdot A) \\ &\overset{2.}{=} wp\llbracket S \rrbracket (c\cdot A) \oplus ert\llbracket S \rrbracket (\boldsymbol{0}) \\ &= c\cdot wp\llbracket S \rrbracket (A) \oplus ert\llbracket S \rrbracket (\boldsymbol{0}) \\ &\overset{2.}{=} c\cdot A \oplus ert\llbracket S \rrbracket (\boldsymbol{0}) \end{align}\] where the second step holds as wp is linear by Proposition [prop:wpProperties].
Preservation of infinity: It is \(ert\llbracket S \rrbracket (\boldsymbol{\infty}) = \boldsymbol{\infty}\) because \(M^\dagger \odot \boldsymbol{\infty} \odot M = \boldsymbol{\infty}\) for any (linear bounded) \(M\neq \boldsymbol{0}\), \(\boldsymbol{\infty}\oplus A = \boldsymbol{\infty}\) for any (linear) \(A\) and \(\bigvee \boldsymbol{\infty}= \boldsymbol{\infty}\), thus it follows by induction over the structure of \(S\) that \(ert\llbracket S \rrbracket (\boldsymbol{\infty}) = \boldsymbol{\infty}\).
◻
Proof of Theorem 6:
Proof. We show the statement by induction over the structure of \(S\):
\(S = \boldsymbol{skip}\): \[\begin{align} ert\llbracket \boldsymbol{skip} \rrbracket (A) = A = wp\llbracket \boldsymbol{skip} \rrbracket (A) = wp\llbracket T({\boldsymbol{skip}}) \rrbracket (A) \end{align}\]
\(S = q:=0\): \[\begin{align} &\text{ }ert\llbracket q:=0 \rrbracket (A) \\ =& \text{ }\boldsymbol{I}\oplus\sum_{n=0}^\infty \ket{n}\bra{0} \odot A \odot \ket{0}\bra{n} \\ =& \text{ }\boldsymbol{I}\oplus wp\llbracket q:=0 \rrbracket (A) \\ =& \text{ }wp\llbracket \boldsymbol{reward} (1) \rrbracket (wp\llbracket q:=0 \rrbracket (A))\\ =& \text{ }wp\llbracket \boldsymbol{reward} (1); q:=0 \rrbracket (A)\\ =& \text{ }wp\llbracket T({q:=0}) \rrbracket (A) \end{align}\]
\(S = \overline{q}:= U\overline{q}\): \[\begin{align} &\text{ } ert\llbracket \overline{q}:= U\overline{q} \rrbracket (A) = \boldsymbol{I}\oplus U^\dagger \odot A \odot U \\ =& \text{ }\boldsymbol{I}\oplus wp\llbracket \overline{q}:= U\overline{q} \rrbracket (A) = wp\llbracket \boldsymbol{reward} (1) \rrbracket (wp\llbracket \overline{q}:= U\overline{q} \rrbracket (A)) \\ =& \text{ }wp\llbracket T({\overline{q}:= U\overline{q}}) \rrbracket (A) \end{align}\]
\(S = S_1;S_2\): \[\begin{align} &ert\llbracket S_1;S_2 \rrbracket (A) = ert\llbracket S_1 \rrbracket (ert\llbracket S_2 \rrbracket (A)) \\ \overset{IH}{=} &wp\llbracket T({S_1}) \rrbracket (wp\llbracket T({S_2}) \rrbracket (A)) = wp\llbracket T({S_1;S_2}) \rrbracket (A) \end{align}\]
\(S = \boldsymbol{measure } M[\overline{q}]:\overline{S'}\): \[\begin{align} &\text{ }ert\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket (A) \\ =& \text{ }\boldsymbol{I}\oplus\left(\sum_{m} M_m^\dagger \odot ert\llbracket S_m' \rrbracket (A) \odot M_m \right) \\ \overset{IH}{=} &\boldsymbol{I}\oplus\left(\sum_{m} M_m^\dagger \odot wp\llbracket T({S_m'}) \rrbracket (A) \odot M_m \right) \\ =& \text{ }\boldsymbol{I}\oplus wp\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket (A) \\ =& \text{ }wp\llbracket \boldsymbol{reward} (1) \rrbracket (wp\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket (A)) \\ =& \text{ }wp\llbracket T({\boldsymbol{measure } M[\overline{q}]:\overline{S'}}) \rrbracket (A) \end{align}\]
\(S = \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S'\): For this case, we need an auxiliary result:
Lemma 10. Let \(S\) be a reward-free qrWhile program and \(A \in \mathcal{E}(\mathcal{H})\). Then \(ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (A) = \bigvee F'_n\) where \[\begin{align} F'_0 &= \boldsymbol{I}\\ F'_{n+1} &= M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S \rrbracket (F'_n) \odot M_1 \oplus\boldsymbol{I}. \end{align}\]
Proof. We have to show that \(\bigvee F'_n\) and \(\bigvee F_n\) are equal where \(F_n\) is defined as in Table 3 for \(\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S'\), i.e. \[\begin{align} F_0 &= \boldsymbol{0}\\ F_{n+1} &= M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (F_n) \odot M_1 \oplus\boldsymbol{I} \end{align}\] The only difference is the definition of \(F_0\).
Clearly \(F'_n\) is an increasing sequence as well, so we show by induction over \(n\) that \(F'_n \sqsubseteq F_{n+1}\) and \(F_n \sqsubseteq F'_{n}\) using the induction hypothesis, monotonicity of \(ert\llbracket S' \rrbracket (\cdot)\) and Proposition [prop:orderproperties]. This implies \(\bigvee_n F'_n = \bigvee_n F_n\).
\(F'_n \sqsubseteq F_{n+1}\): \[\begin{align} F'_0 =& \text{ }\boldsymbol{I}\sqsubseteq\boldsymbol{I}\oplus M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (\boldsymbol{0}) \odot M_1 = F_1\\ F'_{n+1} =& \text{ }M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (F'_n) \odot M_1 \oplus\boldsymbol{I}\\ \sqsubseteq& \text{ }M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (F_{n+1}) \odot M_1 \oplus\boldsymbol{I}= F_{n+2} \end{align}\]
\(F_n \sqsubseteq F'_{n}\) \[\begin{align} F_0 = &\text{ } \boldsymbol{0}\sqsubseteq\boldsymbol{I}= F'_0\\ F_{n+1} =& \text{ }M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (F_n) \odot M_1 \oplus\boldsymbol{I}\\ \sqsubseteq& \text{ }M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (F'_n) \odot M_1 \oplus\boldsymbol{I}= F'_{n+1} \qedhere \end{align}\]
◻
Using the auxiliary result, we can now show the statement for the while case. Recall that \(wp\llbracket T({\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S'}) \rrbracket (A) = \bigvee A_n\) where \[\begin{align} A_0 &= \boldsymbol{0},\\ A_{n+1} &= M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot wp\llbracket T({S'});\boldsymbol{reward} (1) \rrbracket (A_n) \odot M_1 \end{align}\] We show by induction over \(n\) that \(F'_n = A_n \oplus\boldsymbol{I}\) for all \(n\) which implies \(\bigvee_n F'_n = \boldsymbol{I}\oplus\bigvee_n A_n\).
\(n = 0\): \[\begin{align} F'_0 &= \boldsymbol{I}\\ A_0 &= \boldsymbol{0}\\ F'_0 &= A_0 \oplus\boldsymbol{I} \end{align}\]
\(n \to n+1\): \[\begin{align} F'_{n+1} &= M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (F'_n) \odot M_1 \oplus\boldsymbol{I}\\ &\overset{IH}{=} M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (A_n \oplus\boldsymbol{I}) \odot M_1 \oplus\boldsymbol{I}\\ &\overset{IH}{=} M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot wp\llbracket T({S'}) \rrbracket (A_n \oplus\boldsymbol{I}) \odot M_1 \oplus\boldsymbol{I}\\ &= M_0^\dagger \odot A \odot M_0 \oplus M_1^\dagger \odot wp\llbracket T({S'});\boldsymbol{reward} (1) \rrbracket (A_n) \odot M_1 \oplus\boldsymbol{I}\\ &= A_{n+1} \oplus\boldsymbol{I}\qedhere \end{align}\]
◻
Proof of Theorem 7:
Proof. We show this by induction:
\(S = \boldsymbol{skip}\): \(\mathbb{E}_{ert\llbracket \boldsymbol{skip} \rrbracket (\boldsymbol{0})}\left(\rho\right) = \mathbb{E}_{\boldsymbol{0}}\left(\rho\right) = 0 = ERT\llbracket \boldsymbol{skip} \rrbracket (\rho)\).
\(S = q:=0\): \[\begin{align} \text{ }\mathbb{E}_{ert\llbracket q:=0 \rrbracket (\boldsymbol{0})}\left(\rho\right) =& \text{ }\mathbb{E}_{\boldsymbol{I}\oplus\sum_{n=0}^\infty \ket{n}\bra{0} \odot \boldsymbol{0}\odot \ket{0}\bra{n}}\left(\rho\right) \\ =& \text{ }\mathbb{E}_{\boldsymbol{I}}\left(\rho\right) + \mathbb{E}_{\sum_{n=0}^\infty \ket{n}\bra{0} \odot \boldsymbol{0}\odot \ket{0}\bra{n}}\left(\rho\right) \\ =& \text{ }tr(\rho) + \mathbb{E}_{\boldsymbol{0}}\left(\rho\right) = tr(\rho) = ERT\llbracket q:=0 \rrbracket (\rho) \end{align}\]
\(S = \overline{q}:= U\overline{q}\): \(\mathbb{E}_{ert\llbracket \overline{q}:= U\overline{q} \rrbracket (\boldsymbol{0})}\left(\rho\right) = \mathbb{E}_{U^\dagger \odot \boldsymbol{0} \odot U \oplus\boldsymbol{I}}\left(\rho\right) = \mathbb{E}_{\boldsymbol{I}}\left(\rho\right)= tr(\rho) = ERT\llbracket \overline{q}:= U\overline{q} \rrbracket (\rho)\).
\(S = S_1;S_2\): We use the connection to \(wp\) (Proposition [prop:ERTProperties]) \[\begin{align} \mathbb{E}_{ert\llbracket S_1;S_2 \rrbracket (\boldsymbol{0})}\left(\rho\right) =&\text{ }\mathbb{E}_{ert\llbracket S_1 \rrbracket (ert\llbracket S_2 \rrbracket (\boldsymbol{0}))}\left(\rho\right) \\ =& \text{ }\mathbb{E}_{wp\llbracket S_1 \rrbracket (ert\llbracket S_2 \rrbracket (\boldsymbol{0})) \oplus ert\llbracket S_1 \rrbracket (\boldsymbol{0})}\left(\rho\right) \\ =& \text{ }\mathbb{E}_{wp\llbracket S_1 \rrbracket (ert\llbracket S_2 \rrbracket (\boldsymbol{0}))}\left(\rho\right) + \mathbb{E}_{ert\llbracket S_1 \rrbracket (\boldsymbol{0})}\left(\rho\right) \\ =& \text{ }\mathbb{E}_{ert\llbracket S_2 \rrbracket (\boldsymbol{0})}\left(\llbracket S_1 \rrbracket(\rho)\right) + \mathbb{E}_{ert\llbracket S_1 \rrbracket (\boldsymbol{0})}\left(\rho\right) \\ =& \text{ }ERT\llbracket S_2 \rrbracket (\llbracket S_1 \rrbracket(\rho)) + ERT\llbracket S_1 \rrbracket (\rho) \\ =& \text{ }ERT\llbracket S_1;S_2 \rrbracket (\rho) \end{align}\]
\(S = \boldsymbol{measure } M[\overline{q}]:\overline{S'}\): \[\begin{align} &\text{ }\mathbb{E}_{ert\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket (\boldsymbol{0})}\left(\rho\right)\\ = &\text{ }\mathbb{E}_{\boldsymbol{I}\oplus\left(\sum_{m} M_m^\dagger \odot ert\llbracket S_m' \rrbracket (\boldsymbol{0}) \odot M_m \right)}\left(\rho\right) \\ =& \text{ }\mathbb{E}_{\boldsymbol{I}}\left(\rho\right) + \mathbb{E}_{\sum_{m} M_m^\dagger \odot ert\llbracket S_m' \rrbracket (\boldsymbol{0}) \odot M_m}\left(\rho\right) \\ =& \text{ }tr(\rho) + \sum_{m} \mathbb{E}_{M_m^\dagger \odot ert\llbracket S_m' \rrbracket (\boldsymbol{0}) \odot M_m}\left(\rho\right) \\ =& \text{ }tr(\rho) + \sum_{m} \mathbb{E}_{ert\llbracket S_m' \rrbracket (\boldsymbol{0})}\left(M_m{\rho} M_m^\dagger\right) \\ =& \text{ }tr(\rho) + \sum_{m} ERT\llbracket S_m' \rrbracket (M_m \rho M_m^\dagger) \\ =& \text{ }ERT\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket (\rho) \end{align}\]
\(S= \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S'\): We show \(\mathbb{E}_{F_n}\left(\rho\right) = ERT\llbracket while^{[n]} \rrbracket (\rho)\) \[\begin{align} \mathbb{E}_{F_0}\left(\rho\right) =& \text{ }\mathbb{E}_{\boldsymbol{0}}\left(\rho\right) = 0 = ERT\llbracket while^{[0]} \rrbracket (\rho) \\ \mathbb{E}_{F_{n+1}}\left(\rho\right) =&\text{ } \mathbb{E}_{M_0^\dagger \odot \boldsymbol{0} \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S' \rrbracket (F_n) \odot M_1 \oplus\boldsymbol{I}}\left(\rho\right) \\ =& \text{ } \mathbb{E}_{\boldsymbol{0}}\left(\rho\right) + \mathbb{E}_{M_1^\dagger \odot ert\llbracket S' \rrbracket (F_n) \odot M_1}\left(\rho\right) + \mathbb{E}_{\boldsymbol{I}}\left(\rho\right) \\ =& \text{ } 0 + \mathbb{E}_{ert\llbracket S' \rrbracket (F_n)}\left(M_1 \rho M_1^\dagger\right) + tr(\rho) \\ =& \text{ }\mathbb{E}_{wp\llbracket S' \rrbracket (F_n) + ert\llbracket S' \rrbracket (\boldsymbol{0}) }\left(M_1 \rho M_1^\dagger\right) + tr(\rho) \\ =& \text{ }\mathbb{E}_{wp\llbracket S' \rrbracket (F_n)}\left(M_1 \rho M_1^\dagger\right) + \mathbb{E}_{ert\llbracket S' \rrbracket (\boldsymbol{0})}\left(M_1 \rho M_1^\dagger\right) + tr(\rho) \\ =& \text{ }\mathbb{E}_{F_n}\left(\llbracket S' \rrbracket(M_1 \rho M_1^\dagger)\right) + \mathbb{E}_{ert\llbracket S' \rrbracket (\boldsymbol{0})}\left(M_1 \rho M_1^\dagger\right) + tr(\rho) \\ =& \text{ }0 + ERT\llbracket while^{[n]} \rrbracket (\llbracket S' \rrbracket(M_1 \rho M_1^\dagger)) + ERT\llbracket S' \rrbracket (M_1 \rho M_1^\dagger) + tr(\rho) \\ =& \text{ }ERT\llbracket \boldsymbol{skip} \rrbracket (M_0 \rho M_0^\dagger) + ERT\llbracket S';while^{[n]} \rrbracket (M_1 \rho M_1^\dagger) + tr(\rho)\\ =& \text{ }ERT\llbracket while^{[n+1]} \rrbracket (\rho) \end{align}\] Then \[\begin{align} &\text{ } \mathbb{E}_{ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S' \rrbracket (\boldsymbol{0})}\left(\rho\right) \\ =& \text{ }\mathbb{E}_{\bigvee_n F_n}\left(\rho\right) = \sup_n \mathbb{E}_{F_n}\left(\rho\right) \\ =& \sup_n ERT\llbracket while^{[n]} \rrbracket (\rho) \\ =& \lim_n ERT\llbracket while^{[n]} \rrbracket (\rho) \\ =& \text{ } ERT\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S' \rrbracket (\rho) \end{align}\] where supremum and limit coincide since we have increasing sequences.
◻
Proof of Lemma 9:
Proof. Let \(S\) be reward-free and \(\rho \in \mathcal{D}(\mathcal{H})\). Assume \(S\) is PAST on \(\rho\), that means \(\llbracket T({S}) \rrbracket_{R}(\rho) < \infty\) by definition. We show by induction that \(tr(\llbracket S \rrbracket_D(\rho)) = tr(\rho)\), that means \(S\) is AST on \(\rho\).
\(S = \boldsymbol{skip}\): \(tr(\llbracket \boldsymbol{skip} \rrbracket_D(\rho)) = tr(\rho)\) by definition.
\(S = q:=0\): \[\begin{align} &tr(\llbracket q:=0 \rrbracket_D(\rho)) = tr(\sum_n \ket{0}\bra{n} \rho \ket{n}\bra{0}) \\ =& \sum_n tr( \ket{n}\bra{0} \ket{0}\bra{n} \rho ) = tr(\sum_n \ket{n}\bra{n} \rho ) = tr(\rho). \end{align}\]
\(S = \overline{q}:= U\overline{q}\): \(tr(\llbracket \overline{q}:= U\overline{q} \rrbracket_D(\rho)) = tr(U \rho U^\dagger) =tr(U^\dagger U \rho )= tr(\rho)\) as \(U\) is unitary.
\(S = S_1;S_2\): By \(\llbracket T({S_1;S_2}) \rrbracket_{R}(\rho) = \llbracket T({S_1}) \rrbracket_{R}(\rho) + \llbracket T({S_2}) \rrbracket_{R}(\llbracket S_1 \rrbracket_D(\rho)) < \infty\), we have \[\begin{align} \llbracket T({S_1}) \rrbracket_{R}(\rho) < \infty \quad \text{and} \quad \llbracket T({S_2}) \rrbracket_{R}(\llbracket S_1 \rrbracket_D(\rho)) < \infty. \end{align}\] Thus \(tr(\llbracket S_1 \rrbracket_D(\rho)) = tr(\rho)\) and \(tr(\llbracket S_2 \rrbracket_D(\llbracket S_1 \rrbracket_D(\rho))) = tr(\llbracket S_1 \rrbracket_D(\rho))\) by induction hypothesis. Overall it is \(tr(\llbracket S_1;S_2 \rrbracket_D(\rho)) = tr(\llbracket S_2 \rrbracket_D(\llbracket S_1 \rrbracket_D(\rho))) = tr(\llbracket S_1 \rrbracket_D(\rho)) = tr(\rho)\).
\(S = \boldsymbol{measure } M[\overline{q}]:\overline{S'}\): It is \(\llbracket T({\boldsymbol{measure } M[\overline{q}]:\overline{S'}}) \rrbracket_{R}(\rho) = \sum_m \llbracket T({S_m'}) \rrbracket_{R}(M_m \rho M_m^\dagger) < \infty\), thus \(\llbracket T({S_m'}) \rrbracket_{R}(M_m \rho M_m^\dagger) < \infty\) for all \(m\). Then \(tr(\llbracket S_m' \rrbracket_D(M_m \rho M_m^\dagger)) = tr(M_m \rho M_m^\dagger)\) for all \(m\) by induction hypothesis. Overall it is \[\begin{align} tr(\llbracket \boldsymbol{measure } M[\overline{q}]:\overline{S'} \rrbracket_D(\rho)) &= tr(\sum_m \llbracket S_m' \rrbracket_D(M_m \rho M_m^\dagger)) \\ &= \sum_m tr(\llbracket S_m' \rrbracket_D(M_m \rho M_m^\dagger)) \\ &\overset{IH}{=} \sum_m tr(M_m \rho M_m^\dagger) \\ &= tr(\sum_m M_m^\dagger M_m \rho) \\ &= tr(\rho) \end{align}\]
\(S = \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S'\): By \(ERT\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S' \rrbracket (\rho)< \infty\), we have \[\begin{align} \forall n:&\text{ } ERT\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{[n]} \rrbracket (\rho)\\ \leq &\lim_{n \to \infty} ERT\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{[n]} \rrbracket (\rho) \\ = & \text{ } ERT\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S' \rrbracket (\rho) < \infty \end{align}\] and thus by induction hypothesis, it is \(tr(\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{[n]} \rrbracket_D (\rho)) = tr(\rho)\) for all \(n\).
We define \(\sigma_0 = \rho\) and \(\sigma_{n+1} = \llbracket S' \rrbracket_D(M_1 \sigma_n M_1^\dagger)\) for all \(n\). Intuitively, \(\sigma_n\) is the state entering the \(n\)-th iteration of the loop. We have \[\begin{align} \infty > & \text{ }ERT\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{[n]} \rrbracket (\rho) \\ = & \text{ } tr(\rho) + ERT\llbracket \boldsymbol{skip} \rrbracket (M_0 \rho M_0^\dagger) + ERT\llbracket S'; (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{[n-1]} \rrbracket (M_1 \rho M_1^\dagger) \\ =& \text{ }tr(\rho) + ERT\llbracket S' \rrbracket (M_1 \rho M_1^\dagger) + ERT\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{[n-1]} \rrbracket (\llbracket S' \rrbracket_D(M_1 \rho M_1^\dagger))\\ \geq & \text{ }tr(\sigma_0) + ERT\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{[n-1]} \rrbracket (\sigma_1)\\ \geq &\text{ } tr(\sigma_0) + tr(\sigma_1) + ERT\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{[n-2]} \rrbracket (\sigma_2) \\ \geq & \dots \\ \geq & \text{ } tr(\sigma_0) + tr(\sigma_1) + \ldots + ERT\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{[1]} \rrbracket (\sigma_{n-1}) \geq \sum_{i=0}^{{n-1}} tr(\sigma_i) \end{align}\] Since \(\sum_{i=0}^{n} tr(\sigma_i) < \infty\) for all \(n\), \(\lim_{n \to \infty} tr(\sigma_n) = 0\).
From the equation above we get \(ERT\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{[1]} \rrbracket (\sigma_n) < \infty\) for all \(n\), thus \[\begin{align} \infty > & \text{ }ERT\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{[1]} \rrbracket (\sigma_n) \\ =& \text{ }tr(\sigma_n) + ERT\llbracket S'; \boldsymbol{skip} \rrbracket (M_1 \sigma_n M_1^\dagger) + ERT\llbracket \boldsymbol{skip} \rrbracket (M_0 \sigma_n M_0^\dagger) \\ \geq &\text{ } ERT\llbracket S' \rrbracket (M_1 \sigma_n M_1^\dagger) \end{align}\] That means \(S'\) is PAST on \(M_1 \sigma_n M_1^\dagger\) for all \(n\). By induction hypothesis for \(S'\), we have \(tr(\llbracket S' \rrbracket_D(M_1 \sigma_n M_1^\dagger)) = tr(M_1 \sigma_n M_1^\dagger)\) for all \(n\).
Then we show that \(tr(\rho) - tr(\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{n} \rrbracket_D (\rho)) = tr(\sigma_n)\) by induction over \(n\):
\(n=0\): \(tr(\rho) - tr(\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{0} \rrbracket_D (\rho)) = tr(\rho) - tr(0) = tr(\rho) = tr(\sigma_0)\)
\(n \to n+1\): It is \[\begin{align} &\text{ } tr(\rho) - tr(\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{n+1} \rrbracket_D (\rho)) \\ = & \text{ } tr(\rho) - tr(\llbracket \boldsymbol{skip} \rrbracket_D(M_0 \rho M_0^\dagger) + \llbracket S'; (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{n} \rrbracket_D(M_1 \rho M_1^\dagger)) \\ = & \text{ } tr(\rho) - tr(\llbracket \boldsymbol{skip} \rrbracket_D(M_0 \rho M_0^\dagger)) - tr(\llbracket S'; (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{n} \rrbracket_D(M_1 \rho M_1^\dagger)) \\ = & \text{ } tr(\rho) - tr(M_0 \rho M_0^\dagger) - tr(\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{n} \rrbracket_D(\llbracket S' \rrbracket_D(M_1 \rho M_1^\dagger))) \\ & + tr(\llbracket S' \rrbracket_D(M_1 \rho M_1^\dagger)) - tr(\llbracket S' \rrbracket_D(M_1 \rho M_1^\dagger))\\ =& \text{ } tr(\rho) - tr(M_0 \rho M_0^\dagger) - tr(M_1 \rho M_1^\dagger) + \\ & \left(tr(\llbracket S' \rrbracket_D(M_1 \rho M_1^\dagger)) - tr(\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{n} \rrbracket_D(\llbracket S' \rrbracket_D(M_1 \rho M_1^\dagger)))\right) \\ \overset{I.H.}{=}& 0+ tr(\sigma_{n+1}) \end{align}\] because \(\rho = \sigma_0\), thus \(tr(\llbracket S' \rrbracket_D(M_1 \rho M_1^\dagger)) = tr(M_1 \rho M_1^\dagger)\) by induction hypothesis for \(S'\). Also \(tr(\rho) - tr(M_0 \rho M_0^\dagger) - tr(M_1 \rho M_1^\dagger) = 0\) because \(M_0^\dagger M_0 + M_1^\dagger M_1 = \boldsymbol{I}\).
Overall we have shown that \(tr(\rho) - tr(\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{n} \rrbracket_D (\rho)) = tr(\sigma_n)\) for all \(n\) and as \(\lim_{n \to \infty} tr(\sigma_n) = 0\), \(\lim_{n \to \infty} tr(\llbracket (\boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S')^{n} \rrbracket_D (\rho)) = tr(\rho)\) and thus \(tr(\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S' \rrbracket_D (\rho)) = tr(\rho)\) (limit and \(\bigvee\) coincide as we have an increasing sequence of real numbers) and \(S\) is AST on \(\rho\).
◻
Proof of Proposition [prop:ertPark]:
Proof. First we show an auxiliary result that \(ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (B) = \bigvee_n \Psi_B^n(0)\) where \(\Psi_B^n\) is the \(n\)-fold composition of \(\Psi_B\):
We show by induction over \(n\) that \(\Psi_B^n(0) = F_n\) where \(F_n\) is defined as in the definition of \(ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (B)\) in Table 3:
\(n=0\): \(\Psi_B^0(0) = 0 = F_0\).
\(n \to n+1\): \[\begin{align} \Psi_B^{n+1}(0) =&\text{ } \Psi_B(\Psi_B^n(0)) \\ =& \text{ } \boldsymbol{I}\oplus M_0^\dagger \odot B \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S \rrbracket (\Psi_B^n(0)) \odot M_1 \\ =& \text{ } \boldsymbol{I}\oplus M_0^\dagger \odot B \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S \rrbracket (F_n) \odot M_1 \\ =& \text{ } F_{n+1} \end{align}\]
Thus we have \(\Psi_B^n(0) = F_n\) for all \(n\) and thus \(\bigvee_n \Psi_B^n(0) = \bigvee_n F_n = ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (B)\).
The rest of the proof is now completely analogous to the proof of Park induction for wp (Proposition [prop:park]) and thus we only give a sketch here: \(\Psi_B\) is monotonous (\(A_1 \sqsubseteq A_2 \Rightarrow \Psi_B(A_1) \sqsubseteq\Psi_B(A_2)\)) by the monotonicity of ert and by Proposition [prop:orderproperties]: \[\begin{align} A_1 \sqsubseteq A_2 &\Rightarrow M_1^\dagger \odot ert\llbracket S \rrbracket (A_1) \odot M_1 \sqsubseteq M_1^\dagger \odot ert\llbracket S \rrbracket (A_2) \odot M_1 \\ &\Rightarrow \boldsymbol{I}\oplus M_0^\dagger \odot B \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S \rrbracket (A_1) \odot M_1 \\ & \sqsubseteq\boldsymbol{I}\oplus M_0^\dagger \odot B \odot M_0 \oplus M_1^\dagger \odot ert\llbracket S \rrbracket (A_2) \odot M_1 \\ &\Rightarrow \Psi_B(A_1) \sqsubseteq\Psi_B(A_2) \end{align}\] Then \(\Psi_B(A) \sqsubseteq A\) implies \(\Psi_B^n(0) \sqsubseteq A\) completely analogous as we have the same needed properties of \(\Psi_B\) as in the wp case. Finally, we have \(ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (B) = \bigvee_n \Psi_B^n(0) \sqsubseteq A\). ◻
In this section, we provide additional details and calculations for the examples presented in Section 8.
To start the analysis, we can compute \(ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S_2 \rrbracket (\boldsymbol{0})= \bigvee_n P_n\) of the second while loop. Intuitively, this loop decrements the quantum integer \(q_1\) until it reaches \(\ket{0}\), i.e., its runtime is the current value of \(q_1\). We have: \[\begin{align} P_0 &= \boldsymbol{0}\\ P_{n+1} &= M_0^\dagger \boldsymbol{0}M_0 + M_1^\dagger ert\llbracket q_1 := U_{-1} q_1 \rrbracket (P_n) M_1 + \boldsymbol{I}\\ &= M_1^\dagger (U_{-1}^\dagger P_n U_{-1}+\boldsymbol{I}) M_1 + \boldsymbol{I} \end{align}\] Iterating this a couple of times gives: \[\begin{align} P_1 &= 2\boldsymbol{I}- \ket{0}\bra{0} \\ P_2 &= 3\boldsymbol{I}- \ket{1}\bra{1} - 2\ket{0}\bra{0} \\ P_3 &= 4\boldsymbol{I}- \ket{2}\bra{2} - 2\ket{1}\bra{1} - 3\ket{0}\bra{0} \end{align}\] We can see that \(P_n = (n+1)\boldsymbol{I}- \sum_{k=0}^{n-1} (n-k)\ket{k}\bra{k}\). Thus, we have: \[ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S_2 \rrbracket (\boldsymbol{0}) = \bigvee_{n=0}^\infty P_n = \lim_{n\to\infty} \left((n+1)\boldsymbol{I}- \sum_{k=0}^{n-1} (n-k)\ket{k}\bra{k}\right):= W_1\] To compute this limit, we can look at the expectation value on a basis state \(\ket{m}\): \[\begin{align} \mathbb{E}_{ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S_2 \rrbracket (\boldsymbol{0})}\left(\ket{m}\bra{m}\right) &= \lim_{n\to\infty} \left((n+1) - (n-m)\right) \\ &= \lim_{n\to\infty} (m+1) = m+1 \end{align}\] That means the expected runtime of the second while loop on input state \(\ket{m}\) is \(m+1\) as expected. Note that this is only about variable \(q_1\) here, the other variable do not matter for this loop, i.e., we have \(\boldsymbol{I}\) on the other variable.
Now we can analyze the first while loop. Let \(ert\llbracket while_1 \rrbracket (W_1\otimes \boldsymbol{I}) = \bigvee_n Q_n\) with \[\begin{align} Q_0 =&\text{ } \boldsymbol{0}\\ Q_{n+1} =& \text{ } (\boldsymbol{I}\otimes M_0^\dagger) (W_1 \otimes \boldsymbol{I}) (\boldsymbol{I}\otimes M_0) \\ & + (\boldsymbol{I}\otimes M_1^\dagger) ert\llbracket q_2:= Hq_2; q_1 := U_{2} q_1 \rrbracket (Q_n) (\boldsymbol{I}\otimes M_1) + \boldsymbol{I}\\ =& \text{ } W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \\ & + (\boldsymbol{I}\otimes \ket{1}\bra{1}) ert\llbracket q_2:= Hq_2; q_1 := U_{2} q_1 \rrbracket (Q_n)(\boldsymbol{I}\otimes \ket{1}\bra{1}) + \boldsymbol{I} \end{align}\] with \[\begin{align} &ert\llbracket q_2:= Hq_2; q_1 := U_{2} q_1 \rrbracket (Q_n) \\ = & \text{ } (\boldsymbol{I}\otimes H^\dagger) ((U_2^\dagger \otimes \boldsymbol{I}) Q_n (U_2 \otimes \boldsymbol{I})+ \boldsymbol{I})( \boldsymbol{I}\otimes H) + \boldsymbol{I}\\ =& \text{ } (U_2^\dagger \otimes H^\dagger) Q_n (U_2 \otimes H) + 2\boldsymbol{I} \end{align}\] Overall we have \[\begin{align} Q_{n+1} &= W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) + (\boldsymbol{I}\otimes \ket{1}\bra{1}) ((U_2^\dagger \otimes H^\dagger) Q_n (U_2 \otimes H) + 2\boldsymbol{I}) (\boldsymbol{I}\otimes \ket{1}\bra{1}) + \boldsymbol{I}\\ &= W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) + (\boldsymbol{I}\otimes \ket{1}\bra{1}) (U_2^\dagger \otimes H^\dagger) Q_n (U_2 \otimes H) (\boldsymbol{I}\otimes \ket{1}\bra{1}) + \boldsymbol{I}+ 2 \boldsymbol{I}\otimes \ket{1}\bra{1} \\ \end{align}\]
Thus we have: \[\begin{align} Q_0 =& \text{ } \boldsymbol{0}\\ Q_1 =& \text{ }W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) + (\boldsymbol{I}\otimes \ket{1}\bra{1}) (U_2^\dagger \otimes H^\dagger) \boldsymbol{0}(U_2 \otimes H) (\boldsymbol{I}\otimes \ket{1}\bra{1}) + \boldsymbol{I}+ 2 \boldsymbol{I}\otimes \ket{1}\bra{1} \\ =& \text{ } W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) + \boldsymbol{I}+ 2 \boldsymbol{I}\otimes \ket{1}\bra{1}\\ Q_2 =& \text{ } (\boldsymbol{I}\otimes \ket{1}\bra{1}) (U_2^\dagger \otimes H^\dagger) \left(W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) + \boldsymbol{I}+ 2 \boldsymbol{I}\otimes \ket{1}\bra{1}\right) (U_2 \otimes H) (\boldsymbol{I}\otimes \ket{1}\bra{1}) \\ & + \boldsymbol{I}+ 2 \boldsymbol{I}\otimes \ket{1}\bra{1} + W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \\ =& \text{ } (\boldsymbol{I}\otimes \ket{1}\bra{1}) (U_2^\dagger \otimes H^\dagger) \left(W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \right) (U_2 \otimes H) (\boldsymbol{I}\otimes \ket{1}\bra{1}) \\ & + \boldsymbol{I}+ (2+1+2\cdot \frac{1}{2}) \boldsymbol{I}\otimes \ket{1}\bra{1} + W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \\ =& \text{ } U_2^\dagger W_1 U_2 \otimes \left(\ket{1}\bra{1} H^\dagger(\boldsymbol{I}- \ket{1}\bra{1}) H \ket{1}\bra{1}\right) \\ & + \boldsymbol{I}+ 4 \boldsymbol{I}\otimes \ket{1}\bra{1} + W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \\ =& \text{ } U_2^\dagger W_1 U_2 \otimes \left(\frac{1}{2} \ket{1}\bra{1}\right) + \boldsymbol{I}+ 4 \boldsymbol{I}\otimes \ket{1}\bra{1} + W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \\ =& \left( 4 \boldsymbol{I}+ \frac{1}{2} U_2^\dagger W_1 U_2 \right)\otimes \ket{1}\bra{1} + \boldsymbol{I}+ W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \\ Q_3 =& \text{ } (\boldsymbol{I}\otimes \ket{1}\bra{1}) (U_2^\dagger \otimes H^\dagger) \left(\left( 4 \boldsymbol{I}+ \frac{1}{2} U_2^\dagger W_1 U_2 \right)\otimes \ket{1}\bra{1} + \boldsymbol{I}+ W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \right) (U_2 \otimes H) (\boldsymbol{I}\otimes \ket{1}\bra{1}) \\ & + \boldsymbol{I}+ 2 \boldsymbol{I}\otimes \ket{1}\bra{1} + W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \\ =&\text{ } U_2^\dagger\left( 4 \boldsymbol{I}+ \frac{1}{2} U_2^\dagger W_1 U_2 \right) U_2 \otimes \frac{1}{2}\ket{1}\bra{1} + U_2^\dagger W_1 U_2 \otimes \ket{1}\bra{1} H^\dagger\left(\boldsymbol{I}- \ket{1}\bra{1}\right)H\ket{1}\bra{1} \\ & + \boldsymbol{I}+ 3 \boldsymbol{I}\otimes \ket{1}\bra{1} + W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \\ =& \text{ } U_2^\dagger\left( 4 \boldsymbol{I}+ \frac{1}{2} U_2^\dagger W_1 U_2 \right) U_2 \otimes \frac{1}{2}\ket{1}\bra{1} + U_2^\dagger W_1 U_2 \otimes \frac{1}{2}\ket{1}\bra{1} + \boldsymbol{I}+ 3 \boldsymbol{I}\otimes \ket{1}\bra{1} + W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \\ =& \left(5 \boldsymbol{I}+ \frac{1}{2}U_2^\dagger\left( \frac{1}{2} U_2^\dagger W_1 U_2 +W_1 \right) U_2\right) \otimes \ket{1}\bra{1} + \boldsymbol{I}+ W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \\ Q_4 =& (\boldsymbol{I}\otimes \ket{1}\bra{1}) (U_2^\dagger \otimes H^\dagger) \\ & \left(\left(5 \boldsymbol{I}+ \frac{1}{2}U_2^\dagger\left( \frac{1}{2} U_2^\dagger W_1 U_2 +W_1 \right) U_2\right) \otimes \ket{1}\bra{1} + \boldsymbol{I}+ W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1})\right) \\ &(U_2 \otimes H) (\boldsymbol{I}\otimes \ket{1}\bra{1}) \\ & + \boldsymbol{I}+ 2 \boldsymbol{I}\otimes \ket{1}\bra{1} + W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \\ =& \text{ } U_2^\dagger \left(5 \boldsymbol{I}+ \frac{1}{2}U_2^\dagger\left( \frac{1}{2} U_2^\dagger W_1 U_2 +W_1 \right) U_2\right) U_2 \otimes \frac{1}{2}\ket{1}\bra{1} + U_2^\dagger W_1 U_2 \otimes \frac{1}{2}\ket{1}\bra{1} \\ & + \boldsymbol{I}+ 3 \boldsymbol{I}\otimes \ket{1}\bra{1} + W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \\ =& \left(5.5 \boldsymbol{I}+ \frac{1}{2} U_2^\dagger \left(\frac{1}{2}U_2^\dagger\left( \frac{1}{2} U_2^\dagger W_1 U_2 +W_1 \right) U_2 + W_1\right) U_2 \right)\otimes \ket{1}\bra{1} + \boldsymbol{I}+ W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \\ =& \left(5.5 \boldsymbol{I}+ \sum_{k=1}^3 (\frac{1}{2} U_2^\dagger)^k W_1 U_2 \right)\otimes \ket{1}\bra{1} + \boldsymbol{I}+ W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \end{align}\]
We can see a pattern emerging here. For \(n>0\), we have: \[\begin{align} Q_n = \left(a_n \boldsymbol{I}+ \sum_{k=1}^{n-1} (\frac{1}{2} U_2^\dagger)^k W_1 U_2^k \right)\otimes \ket{1}\bra{1} + \boldsymbol{I}+ W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \end{align}\] with \(a_1 = 2\), \(a_2 = 4\), \(a_3 = 5\) \(a_4 = 5.5\). The sequence continues as \(a_n = 3 + \frac{1}{2}a_{n-1}\), i.e., \(a_n = 6 - \frac{8}{2^n}\). Thus, we have: \[\begin{align} &ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S_1 \rrbracket (W_1 \otimes \boldsymbol{I}) = \bigvee_{n=0}^\infty Q_n \\ =& \lim_{n\to\infty} \left( \left(\left(6 - \frac{8}{2^n} \right) \boldsymbol{I}+ \sum_{k=1}^{n-1} (\frac{1}{2} U_2^\dagger)^k W_1 U_2^k \right)\otimes \ket{1}\bra{1} + \boldsymbol{I}+ W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \right) := W_2 \end{align}\] To compute the expected value of \(W_2\) on a basis state \(\ket{m}\otimes \ket{b}\), we need to compute the expected value of \(\sum_{k=1}^{n-1} (\frac{1}{2} U_2^\dagger)^k W_1 U_2^k\) on \(\ket{1}\bra{1}\): \[\begin{align} & \mathbb{E}_{\sum_{k=1}^{n-1} (\frac{1}{2} U_2^\dagger)^k W_1 U_2^k}\left(\ket{1}\bra{1}\right)\\ =& \sum_{k=1}^{n-1} \mathbb{E}_{(\frac{1}{2} U_2^\dagger)^k W_1 U_2^k}\left(\ket{1}\bra{1}\right) \\ =& \sum_{k=1}^{n-1} \mathbb{E}_{W_1}\left((\frac{1}{2} U_2)^k \ket{1}\bra{1} (U_2^\dagger)^k\right) \\ =& \sum_{k=1}^{n-1} \frac{1}{2^k} \mathbb{E}_{W_1}\left(\ket{2^{k}}\bra{2^{k}}\right) \\ =& \sum_{k=1}^{n-1} \frac{1}{2^k} (2^k -1) \\ =& \sum_{k=1}^{n-1} (1 - \frac{1}{2^k}) = n-1 - (1 - \frac{1}{2^{n-1}}) = n-2 + \frac{1}{2^{n-1}} \end{align}\] Overall we have: \[\begin{align} &\text{ } \mathbb{E}_{ert\llbracket L_1 \rrbracket (\boldsymbol{0})}\left(\ket{1}\bra{1} \otimes \ket{1}\bra{1}\right) \\ =& \text{ } \mathbb{E}_{W_2}\left(\ket{1}\bra{1} \otimes \ket {1}\bra{1}\right) \\ =& \text{ } \mathbb{E}_{\lim_{n\to\infty} \left( \left(\left(6 - \frac{8}{2^n} \right) \boldsymbol{I}+ \sum_{k=1}^{n-1} (\frac{1}{2} U_2^\dagger)^k W_1 U_2^k \right)\otimes \ket{1}\bra{1} + \boldsymbol{I}+ W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) \right)}\left(\ket{1}\bra{1} \otimes \ket {1}\bra{1}\right) \\ =& \lim_{n\to\infty} \mathbb{E}_{\left(6 - \frac{8}{2^n} \right) \boldsymbol{I}}\left(\ket{1}\bra{1} \otimes \ket{1}\bra{1}\right)+ \mathbb{E}_{\left( \sum_{k=1}^{n-1} (\frac{1}{2} U_2^\dagger)^k W_1 U_2^k \right)\otimes \ket{1}\bra{1}}\left(\ket{1}\bra{1} \otimes \ket{1}\bra{1}\right) \\ & + \mathbb{E}_{\boldsymbol{I}}\left(\ket{1}\bra{1} \otimes \ket {1}\bra{1}\right) + \mathbb{E}_{W_1 \otimes (\boldsymbol{I}- \ket{1}\bra{1}) }\left(\ket{1}\bra{1} \otimes \ket {1}\bra{1}\right) \\ =& \lim_{n\to\infty} 6 - \frac{8}{2^n} + \mathbb{E}_{\sum_{k=1}^{n-1} (\frac{1}{2} U_2^\dagger)^k W_1 U_2^k}\left(\ket{1}\bra{1}\right) + 1 \\ =& \lim_{n\to\infty} 7 - \frac{8}{2^n} + n-2 + \frac{1}{2^{n-1}} = \infty. \end{align}\]
For the computation of AST, we first consider the second loop. We can compute \(wp\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S_2 \rrbracket (\boldsymbol{I}) = \bigvee_n P_n\) with \[\begin{align} P_0 &= \boldsymbol{0}\\ P_{n+1} &= M_0^\dagger \boldsymbol{I}M_0 + M_1^\dagger wp\llbracket S \rrbracket (P_n) M_1 \\ &= \ket{0}\bra{0} + (\boldsymbol{I}- \ket{0}\bra{0}) wp\llbracket q_1 := U_{-1} q_1 \rrbracket (P_n) (\boldsymbol{I}- \ket{0}\bra{0}) \\ &= \ket{0}\bra{0} + (\boldsymbol{I}- \ket{0}\bra{0}) U_{-1}^\dagger P_n U_{-1} (\boldsymbol{I}- \ket{0}\bra{0}) \end{align}\] Then we have \[\begin{align} P_0 &= \boldsymbol{0}\\ P_1 &= \ket{0}\bra{0} \\ P_2 &= \ket{0}\bra{0} + (\boldsymbol{I}- \ket{0}\bra{0}) U_{-1}^\dagger \ket{0}\bra{0} U_{-1} (\boldsymbol{I}- \ket{0}\bra{0}) \\ &= \ket{0}\bra{0} + \ket{1}\bra{1} \\ P_3 &= \ket{0}\bra{0} + (\boldsymbol{I}- \ket{0}\bra{0}) U_{-1}^\dagger (\ket{0}\bra{0} + \ket{1}\bra{1}) U_{-1} (\boldsymbol{I}- \ket{0}\bra{0})\\ &= \ket{0}\bra{0} + \ket{1}\bra{1} + \ket{2}\bra{2} \\ &\dots \\ P_n &= \ket{0}\bra{0} + \ket{1}\bra{1} + \dots + \ket{n-1}\bra{n-1} \end{align}\] and overall we have \(wp\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S_2 \rrbracket (\boldsymbol{I}) = \bigvee_n P_n = \boldsymbol{I}\).
Now we can analyze the first while loop. We have \(wp\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S_1 \rrbracket (\boldsymbol{I}\otimes \boldsymbol{I}) = \bigvee_n P_n\) with \[\begin{align} P_0 &= \boldsymbol{0}\\ P_{n+1} &= M_0^\dagger \boldsymbol{I}M_0 + M_1^\dagger wp\llbracket S \rrbracket (P_n) M_1 \\ &= \boldsymbol{I}\otimes \ket{0}\bra{0} + (\boldsymbol{I}\otimes \ket{1}\bra{1}) wp\llbracket q := H q; q_1 := U_2 q_1 \rrbracket (P_n) (\boldsymbol{I}\otimes \ket{1}\bra{1}) \\ &= \boldsymbol{I}\otimes \ket{0}\bra{0} + (\boldsymbol{I}\otimes \ket{1}\bra{1}) (U_2^\dagger \otimes H^\dagger) P_n (U_2 \otimes H) (\boldsymbol{I}\otimes \ket{1}\bra{1}) \end{align}\] Iterating this, we have \[\begin{align} P_0 &= \boldsymbol{0}\\ P_1 &= \boldsymbol{I}\otimes \ket{0}\bra{0} \\ P_2 &= \boldsymbol{I}\otimes \ket{0}\bra{0} + (\boldsymbol{I}\otimes \ket{1}\bra{1}) (U_2^\dagger \otimes H^\dagger) (\boldsymbol{I}\otimes \ket{0}\bra{0}) (U_2 \otimes H) (\boldsymbol{I}\otimes \ket{1}\bra{1}) \\ &= \boldsymbol{I}\otimes \left(\ket{0} \bra{0} + \frac{1}{2} \ket{1}\bra{1}\right) \\ P_3 &= \boldsymbol{I}\otimes \ket{0}\bra{0} + (\boldsymbol{I}\otimes \ket{1}\bra{1}) (U_2^\dagger \otimes H^\dagger) \left(\boldsymbol{I}\otimes (\ket{0} \bra{0} + \frac{1}{2} \ket{1}\bra{1}) \right) (U_2\otimes H) (\boldsymbol{I}\otimes \ket{1}\bra{1}) \\ & = \boldsymbol{I}\otimes \ket{0}\bra{0} + \boldsymbol{I}\otimes \ket{1}\bra{1} H^\dagger \left((\ket{0} \bra{0} + \frac{1}{2} \ket{1}\bra{1}) \right) H \ket{1}\bra{1} \\ &= \boldsymbol{I}\otimes\left(\ket{0}\bra{0} + \frac{3}{4} \ket{1}\bra{1}\right) \\ &\dots \\ P_n &= \boldsymbol{I}\otimes \left(\ket{0}\bra{0} + \left(1 - \frac{1}{2^n}\right) \ket{1}\bra{1}\right) \end{align}\] and overall we have \(wp\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S_1 \rrbracket (\boldsymbol{I}) = \bigvee_n P_n = \boldsymbol{I}\).
For the calculation of AST, we show that \(A = (\boldsymbol{0}_{<0} + \boldsymbol{I}_{\geq 0}) \otimes \boldsymbol{I}= \boldsymbol{I}_{\geq 0} \otimes \boldsymbol{I}\) is a fix-point of \(\psi_\boldsymbol{I}\): \[\begin{align} \psi_\boldsymbol{I}(\boldsymbol{I}_{\geq 0}\otimes \boldsymbol{I}) =& \ket{0}\bra{0} \otimes \boldsymbol{I}+ ((\boldsymbol{I}- \ket{0}\bra{0})\otimes H)S^\dagger ( \boldsymbol{I}_{\geq 0} \otimes \boldsymbol{I}) S ((\boldsymbol{I}- \ket{0}\bra{0}) \otimes H)\\ =& \ket{0}\bra{0} \otimes \boldsymbol{I}+ ((\boldsymbol{I}- \ket{0}\bra{0})\otimes H) S^\dagger( \sum_{n=0}^{\infty} \ket{n}\bra{n} \otimes \ket{0}\bra{0} +\sum_{n=0}^{\infty} \ket{n}\bra{n} \otimes \ket{1}\bra{1} )S\\ &((\boldsymbol{I}- \ket{0}\bra{0}) \otimes H)\\ =& \ket{0}\bra{0} \otimes \boldsymbol{I}+ ((\boldsymbol{I}- \ket{0}\bra{0})\otimes H) ( \sum_{n=0}^{\infty} \ket{n+1}\bra{n+1} \otimes \ket{0}\bra{0} +\sum_{n=0}^{\infty} \ket{n}\bra{n} \otimes \ket{1}\bra{1} )\\ &((\boldsymbol{I}- \ket{0}\bra{0}) \otimes H)\\ =& \ket{0}\bra{0} \otimes \boldsymbol{I}+ ((\boldsymbol{I}- \ket{0}\bra{0})\otimes H)\\ & ( \sum_{n=1}^{\infty} \ket{n}\bra{n} \otimes \ket{0}\bra{0} +\sum_{n=1}^{\infty} \ket{n}\bra{n} \otimes \ket{1}\bra{1} + \ket{0}\bra{0} \otimes \ket{1}\bra{1})\\ &((\boldsymbol{I}- \ket{0}\bra{0}) \otimes H)\\ =& \ket{0}\bra{0} \otimes \boldsymbol{I}+ ((\boldsymbol{I}- \ket{0}\bra{0})\otimes H) ( \sum_{n=1}^{\infty} \ket{n}\bra{n} \otimes \boldsymbol{I}+ \ket{0}\bra{0} \otimes \ket{1}\bra{1})((\boldsymbol{I}- \ket{0}\bra{0}) \otimes H)\\ =& \ket{0}\bra{0} \otimes \boldsymbol{I}+ \sum_{n=1}^{\infty} \ket{n}\bra{n} \otimes \boldsymbol{I}= \boldsymbol{I}_{\geq 0} \otimes \boldsymbol{I} \end{align}\]
For finding the invariant for the calculation of ERT, we used the ansatz \[\begin{align} A = \sum_{n=0}^\infty a_n \ket{n}\bra{n} \otimes \ket{0}\bra{0} + \sum_{n=0}^\infty b_n \ket{n}\bra{n} \otimes \ket{1}\bra{1} + \boldsymbol{0}|_{\geq 0}. \end{align}\] This ansatz is now used to find the coefficients \(a_n \geq 0\) and \(b_n \geq 0\). We obtain: \[\begin{align} \Psi_\boldsymbol{0}(A) =& \sum_{n=0}^{\infty} \ket{n}\bra{n} \otimes T_n + \boldsymbol{0}|_{\geq 0} \\ \end{align}\] with \[\begin{align} T_n = \begin{cases} \boldsymbol{I}& n=0 \\ (a_{n-1}+3) \ket{+}\bra{+} + (b_n+3) \ket{-}\bra{-} & n>0 \end{cases} \end{align}\]
To ensure that \(\Psi_\boldsymbol{0}(A) \sqsubseteq A\), we need to ensure that \(T_n \sqsubseteq a_n \ket{0}\bra{0} + b_n \ket{1}\bra{1}\) for all \(n\). Thus, we obtain the following result:
Lemma 11. For a given \(a_n\), the smallest \(a_{n+1}\) such that \(T_{n+1} \sqsubseteq a_{n+1} \ket{0}\bra{0} + b_{n+1} \ket{1}\bra{1}\) has a solution is \(a_{n+1} = a_n + 12 + 6\sqrt{2}\). For that \(a_n\), there is only one solution for \(b_{n+1}\), which is \(b_{n+1} = a_n + 6 + 3\sqrt{2}\).
The proof of this lemma is done in Lean and can be downloaded by clicking here: or by looking in the embedded files pane, depending on your PDF viewer.
Solving this recurrence gives \[\begin{align} a_n &= 1 + 2n(6+3\sqrt{2}) \\ b_n &= \begin{cases} 1 + (2n-1)(6+3\sqrt{2}) & n>0 \\ 1 & n=0 \end{cases} \end{align}\]
Overall, we have the following invariant: \[\begin{align} A = \sum_{n=1}^\infty 2n(6+3\sqrt{2})\ket{n}\bra{n} \otimes \ket{0}\bra{0} + \sum_{n=1}^\infty (2n-1)(6+3 \sqrt{2}) \ket{n}\bra{n} \otimes \ket{1}\bra{1} + \boldsymbol{I}+ \boldsymbol{0}|_{\geq 0}. \end{align}\]
We can also show explicitly that \(A\) is an upper-invariant of \(\psi_\boldsymbol{0}\), i.e., \(\psi_\boldsymbol{0}(A) \sqsubseteq A\): \[\begin{align} \Psi_\boldsymbol{0}(A) =& \sum_{n=0}^{\infty} \ket{n}\bra{n} \otimes \boldsymbol{I}+ \sum_{n=1}^\infty 2 \ket{n}\bra{n} \otimes \boldsymbol{I}+ ((\boldsymbol{I}- \ket{0}\bra{0})\otimes H)S^\dagger \\ & \left( \sum_{n=1}^\infty 2n(6+3\sqrt{2})\ket{n}\bra{n} \otimes \ket{0}\bra{0} + \sum_{n=1}^\infty (2n-1)(6+3 \sqrt{2}) \ket{n}\bra{n} \otimes \ket{1}\bra{1} + \boldsymbol{I}+ \boldsymbol{0}|_{\geq 0} \right) \\ &S ((\boldsymbol{I}- \ket{0}\bra{0}) \otimes H) \\ =& \sum_{n=0}^{\infty} \ket{n}\bra{n} \otimes \boldsymbol{I}+ \sum_{n=1}^\infty 2 \ket{n}\bra{n} \otimes \boldsymbol{I}+ ((\boldsymbol{I}- \ket{0}\bra{0})\otimes H) \\ &\left( \sum_{n=1}^\infty 2n(6+3\sqrt{2})\ket{n+1}\bra{n+1} \otimes \ket{0}\bra{0} + \sum_{n=1}^\infty (2n-1)(6+3 \sqrt{2}) \ket{n}\bra{n} \otimes \ket{1}\bra{1} + \boldsymbol{I}\right) \\ &((\boldsymbol{I}- \ket{0}\bra{0}) \otimes H) +\boldsymbol{0}|_{\geq 0} \\ =& \sum_{n=0}^{\infty} \ket{n}\bra{n} \otimes \boldsymbol{I}+ \sum_{n=1}^\infty 2 \ket{n}\bra{n} \otimes \boldsymbol{I}+ \sum_{n =1}^\infty\ket{n}\bra{n} \otimes \boldsymbol{I}+ \\ &\sum_{n = 2}^\infty 2(n-1)(6+3\sqrt{2})\ket{n}\bra{n} \otimes \ket{+}\bra{+} + \sum_{n=1}^\infty (2n-1)(6+3 \sqrt{2}) \ket{n}\bra{n} \otimes \ket{-}\bra{-} + \boldsymbol{0}|_{\geq 0}\\ =& \text{ } \boldsymbol{I}+ \sum_{n=1}^\infty 3 \ket{n}\bra{n} \otimes \boldsymbol{I}- \sum_{n = 2}^\infty (6+3\sqrt{2})\ket{n}\bra{n} \otimes \ket{+}\bra{+} + (6+3 \sqrt{2}) \ket{1}\bra{1} \otimes \ket{-}\bra{-} +\\ &\sum_{n = 2}^\infty (2n-1)(6+3\sqrt{2})\ket{n}\bra{n} \otimes \ket{+}\bra{+} + \sum_{n=2}^\infty (2n-1)(6+3 \sqrt{2}) \ket{n}\bra{n} \otimes \ket{-}\bra{-} +\boldsymbol{0}|_{\geq 0} \\ =& \text{ } \boldsymbol{I}+ \sum_{n=1}^\infty 3 \ket{n}\bra{n} \otimes \boldsymbol{I}- \sum_{n = 2}^\infty (6+3\sqrt{2})\ket{n}\bra{n} \otimes \ket{+}\bra{+} + (6+3 \sqrt{2}) \ket{1}\bra{1} \otimes \ket{-}\bra{-} +\\ &\sum_{n=2}^\infty (2n-1)(6+3 \sqrt{2}) \ket{n}\bra{n} \otimes \boldsymbol{I}+ \boldsymbol{0}|_{\geq 0}\\ =& \text{ } \boldsymbol{I}+ \sum_{n=1}^\infty 3 \ket{n}\bra{n} \otimes \boldsymbol{I}- \sum_{n = 2}^\infty (6+3\sqrt{2})\ket{n}\bra{n} \otimes \ket{+}\bra{+} + (6+3 \sqrt{2}) \ket{1}\bra{1} \otimes \ket{-}\bra{-} +\\ &\sum_{n=2}^\infty (2n-1)(6+3 \sqrt{2}) \ket{n}\bra{n} \otimes \ket{0}\bra{0}+ \sum_{n=2}^\infty (2n-1)(6+3 \sqrt{2}) \ket{n}\bra{n} \otimes \ket{1}\bra{1} +\boldsymbol{0}|_{\geq 0} \\ =& \text{ } \boldsymbol{I}+ \sum_{n=1}^\infty 3 \ket{n}\bra{n} \otimes \boldsymbol{I}- \sum_{n = 2}^\infty (6+3\sqrt{2})\ket{n}\bra{n} \otimes \left(\ket{+}\bra{+} + \ket{0}\bra{0}\right) + \\ & (6+3 \sqrt{2}) \ket{1}\bra{1} \otimes \ket{-}\bra{-} + \sum_{n=2}^\infty 2n(6+3 \sqrt{2}) \ket{n}\bra{n} \otimes \ket{0}\bra{0}+ \\ &\sum_{n=2}^\infty (2n-1)(6+3 \sqrt{2}) \ket{n}\bra{n} \otimes \ket{1}\bra{1} +\boldsymbol{0}|_{\geq 0} \end{align}\] Now we show that \(A - \Psi_\boldsymbol{0}(A) \sqsupseteq 0\): \[\begin{align} &A - \Psi_\boldsymbol{0}(A) \\ =& \sum_{n=1}^\infty 2n(6+3\sqrt{2})\ket{n}\bra{n} \otimes \ket{0}\bra{0} + \sum_{n=1}^\infty (2n-1)(6+3 \sqrt{2}) \ket{n}\bra{n} \otimes \ket{1}\bra{1} + \boldsymbol{I}+ \boldsymbol{0}|_{\geq 0}- \\ & \boldsymbol{I}- \sum_{n=1}^\infty 3 \ket{n}\bra{n} \otimes \boldsymbol{I}+ \sum_{n = 2}^\infty (6+3\sqrt{2})\ket{n}\bra{n} \otimes (\ket{+}\bra{+} + \ket{0}\bra{0}) - (6+3 \sqrt{2}) \ket{1}\bra{1} \otimes \ket{-}\bra{-} - \\ & \sum_{n=2}^\infty 2n(6+3 \sqrt{2}) \ket{n}\bra{n} \otimes \ket{0}\bra{0}- \sum_{n=2}^\infty (2n-1)(6+3 \sqrt{2}) \ket{n}\bra{n} \otimes \ket{1}\bra{1} - \boldsymbol{0}|_{\geq 0} \\ =& \text{ } 2(6+3\sqrt{2})\ket{1}\bra{1} \otimes \ket{0}\bra{0} + (6+3 \sqrt{2}) \ket{1}\bra{1} \otimes \ket{1}\bra{1} + \\ & \sum_{n = 2}^\infty (6+3\sqrt{2})\ket{n}\bra{n} \otimes (\ket{+}\bra{+} + \ket{0}\bra{0}) - \sum_{n=1}^\infty 3 \ket{n}\bra{n} \otimes \boldsymbol{I}- (6+3 \sqrt{2}) \ket{1}\bra{1} \otimes \ket{-}\bra{-}\\ =& \text{ } (6+3\sqrt{2})\ket{1}\bra{1} \otimes \ket{0}\bra{0} + (6+3 \sqrt{2}) \ket{1}\bra{1} \otimes \boldsymbol{I}+ \sum_{n = 2}^\infty (6+3\sqrt{2})\ket{n}\bra{n} \otimes (\ket{+}\bra{+} + \ket{0}\bra{0}) - \\ & \sum_{n=1}^\infty 3 \ket{n}\bra{n} \otimes \boldsymbol{I}- (6+3 \sqrt{2}) \ket{1}\bra{1} \otimes \ket{-}\bra{-} \\ =& \text{ } (6+3\sqrt{2})\ket{1}\bra{1} \otimes \ket{0}\bra{0} + (6+3 \sqrt{2}) \ket{1}\bra{1} \otimes \ket{+}\bra{+} + \\ & \sum_{n = 2}^\infty (6+3\sqrt{2})\ket{n}\bra{n} \otimes (\ket{+}\bra{+} + \ket{0}\bra{0}) - \sum_{n=1}^\infty 3 \ket{n}\bra{n} \otimes \boldsymbol{I}\\ =& \sum_{n = 1}^\infty (6+3\sqrt{2})\ket{n}\bra{n} \otimes (\ket{+}\bra{+} + \ket{0}\bra{0}) - \sum_{n=1}^\infty 3 \ket{n}\bra{n} \otimes \boldsymbol{I}\\ =& \sum_{n = 1}^\infty 3 \ket{n}\bra{n} \otimes \left((2+\sqrt{2})(\ket{+}\bra{+} + \ket{0}\bra{0}) - \boldsymbol{I}\right) \sqsupseteq 0 \end{align}\]
We have shown that \(A\) is an upper-invariant of \(\psi_\boldsymbol{0}\). Thus, we have \(ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (\boldsymbol{0}) \sqsubseteq A\) by Park induction. To get a bound on the expected runtime of the whole program, we have to consider the initialization of \(c:= \ket{0}\): By definition and monotonicity of \(ert\), we have \[\begin{align} &ert\llbracket c:= \ket{0}; \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (\boldsymbol{0}) \\ =& \text{ } ert\llbracket c:= \ket{0} \rrbracket (ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (\boldsymbol{0})) \\ \sqsubseteq& \text{ } ert\llbracket c:= \ket{0} \rrbracket (A) \\ =&\sum_{n=1}^\infty 2n(6+3\sqrt{2})\ket{n}\bra{n} \otimes \boldsymbol{I}+ \boldsymbol{0}|_{\geq 0} + \boldsymbol{I} \end{align}\] thus we have \(\mathbb{E}_{ert\llbracket P_1 \rrbracket (\boldsymbol{0})}\left(\ket{n} \otimes \psi\right) \leq 2n(6+3\sqrt{2}) +1\) for \(n\geq 0\) and any state \(\psi\).
Additionally, we show that \(ert\llbracket P_1 \rrbracket (\boldsymbol{0})\) is not bounded from above by proving the lower bound \(B = \sum_{n=0}^\infty n \ket{n}\bra{n} \otimes \boldsymbol{I}\). This is done by considering \(ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (\boldsymbol{0}) = \bigvee_n F_n\) with \[\begin{align} F_0 &= \boldsymbol{0}\\ F_{n+1} &= M_0^\dagger \boldsymbol{0}M_0 + M_1^\dagger ert\llbracket S \rrbracket (F_n) M_1 + \boldsymbol{I}\\ &= 3 \boldsymbol{I}- 2 \ket{0}\bra{0} \otimes \boldsymbol{I}+ ((\boldsymbol{I}- \ket{0}\bra{0})\otimes H)S^\dagger F_n S ((\boldsymbol{I}- \ket{0}\bra{0}) \otimes H). \end{align}\]
We define \(G_k = \sum_{n=0}^{\infty} \min{\{n,k-1\}} \ket{n}\bra{n} \otimes \boldsymbol{I}\) and show that \(G_k \sqsubseteq F_k\) for all \(k\) by induction:
\(k=0\): \(G_0 = \boldsymbol{0}\sqsubseteq F_0 = \boldsymbol{0}\)
\(k \to k+1\): Assume \(G_k \sqsubseteq F_k\). Then we have \[\begin{align} F_{k+1} \sqsupseteq &\text{ } \boldsymbol{I}+ ((\boldsymbol{I}- \ket{0}\bra{0})\otimes H)S^\dagger G_k S ((\boldsymbol{I}- \ket{0}\bra{0}) \otimes H) \\ =& \text{ }\boldsymbol{I}+ \sum_{n=0}^{\infty} \min{\{n,k-1\}} \ket{n+1}\bra{n+1} \otimes \ket{+}\bra{+} + \sum_{n=1}^{\infty} \min{\{n,k-1\}} \ket{n}\bra{n} \otimes \ket{-}\bra{-} \\ =&\text{ } \boldsymbol{I}+ \sum_{n=1}^{\infty} \min{\{n-1,k-1\}} \ket{n}\bra{n} \otimes \ket{+}\bra{+} + \sum_{n=1}^{\infty} \min{\{n,k-1\}} \ket{n}\bra{n} \otimes \ket{-}\bra{-} \\ \sqsupseteq & \text{ } \boldsymbol{I}+ \sum_{n=1}^{\infty} \min{\{n-1,k-1\}} \ket{n}\bra{n} \otimes \boldsymbol{I}\\ \sqsupseteq & \sum_{n=0}^{\infty} \min{\{n,k\}} \ket{n}\bra{n} \otimes \boldsymbol{I}= G_{k+1}\\ \end{align}\]
As \(G_k \sqsubseteq F_k\) for all \(k\), we have \(B = \sum_{n=0}^{\infty} n \ket{n}\bra{n} \otimes \boldsymbol{I}= \bigvee_{k=0}^\infty G_k \sqsubseteq \bigvee_{k=0}^\infty F_k = ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (\boldsymbol{0})\). Again, we need to consider the initialization of \(c:= \ket{0}\): \[\begin{align} &ert\llbracket c:= \ket{0}; \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (\boldsymbol{0}) \\ =&\text{ } ert\llbracket c:= \ket{0} \rrbracket (ert\llbracket \boldsymbol{while } M[\overline{q}]=1 \boldsymbol{ do } S \rrbracket (\boldsymbol{0})) \\ \sqsupseteq& \text{ } ert\llbracket c:= \ket{0} \rrbracket (B) = \sum_{n=1}^\infty n\ket{n}\bra{n} \otimes \boldsymbol{I}+ \boldsymbol{I}\sqsupseteq B \end{align}\]
As in [23], we mean convergence of sums with respect to SOT if not stated otherwise.↩︎
Convergence w.r.t. SOT (not WOT as in [32]), see footnote 36 in [23].↩︎
Convergence in WOT.↩︎
Convergence in WOT.↩︎
As mentioned earlier, we implicitly mean the extension to \(\mathcal{T}(\mathcal{H})\to \mathbb{C}\).↩︎
Note that in comparison to the probabilistic ert calculus [14], we do not count the skip statement as a step, as it does not correspond to any operation on the quantum computer and we want to stay comparable to [2].↩︎
Convergence w.r.t. WOT, thus \(A \in \mathcal{E}(\mathcal{H})\) by Definition 5 and Lemma 1.↩︎