6.4.5 An Example

To close out this section, we present a simple example that helps us to understand the semantic notions introduced here.

Example 6.4.1

Let q be a qubit variable and x,y two classical variables. Consider the QuGCL program

Pqif|0H[q];ifM(0)[q:x]=0X[q];1Y[q]fi|1S[q];ifM(1)[q:x]=0Y[q]1Z[q]fi;X[q];ifM(0)[q:y]=0Z[q]1X[q]fifiq

si342_e

where M(0),M(1) are the measurements on a qubit in computational basis |0〉,|1〉 and basis |±〉, respectively (see Example 6.3.3), H is the Hadamard gate, X,Y,Z are the Pauli matrices, and S is the phase gate (see Examples 2.2.1 and 2.2.2). The program P is a quantum case statement between two subprograms ...

Get Foundations of Quantum Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.