You are to write the following QCL procedures:
Encode7(qureg source, qureg dest): This procedure takes in an arbitrary qubit source and outputs an encoded logical qubit in the physical qubits dest. This routine is for testing purposes and need not be fault-tolerant.
FT7(qureg logicalqubit): This procedure measures the stabilizers above and applies fixup Z and X gates if required. It should do this in a fault-tolerant manner (redundant measurement and no error distribution across logical qubits). Also, when this procedure applies a fixup Z or X gate, print out a message to that effect.
X7(qureg logicalqubit): This procedure applies the logical X gate in a fault-tolerant manner.
Z7(qureg logicalqubit): This procedure applies the logical Z gate in a fault-tolerant manner.
H7(qureg logicalqubit): This procedure applies the logical H gate in a fault-tolerant manner.
CNot7(qureg logicalqubittarget, qureg logicalqubitsource) : This procedure applies the logical CNot gate in a fault-tolerant manner.
MakeCATState(qureg anc, qureg ver): Prepare an n-qubit ancilliary cat state, |00...0> + |11...1>, for use in syndrome measurement. The ancilliary state is used to make the syndrome measurement fault-tolerant. For the above parity measurements, n will be 4. The ver qubit(s) are for verification of the cat state (see Nielsen-Chuang p. 490 or Oskin Fig 26). Oskin Fig 26 shows a redundant measurement for one pair of ancilla (middle of the figure). You should really perform this measurement THREE times, and for every possible pair in the ancilla. A four-qubit cat state requires six pairwise measurements (four choose two).
Clear(qubit x): Clear qubits x. Do this by measuring them and if you measure a logical 1 apply an X gate to make it a zero. (See QCL example code.)
To demonstrate that your procedures work, do the following tests:
Make a logic |0> state (use your encoding routine). Apply the fault-tolerant H gate to this state. Create a slight error in 1 of the physical qubits (any one of the 7 will do). Create this error in this way: Rot(pi/9, qubit[i]). Now, apply the FT7 procedure to this logical qubit. Dump the state of 7 qubits prior to, and after syndrome measurement and recovery. Repeat this a few times. You should observe that the syndrome measurement and recover procedure does not always need to apply the Z and X gates, but the error code is always fixed after this procedure.
Demonstrate that a single error during cat-state generation and verification results in no more than a single error in the resulting corrected code word. You may want to add an additional argument to MakeCATState to allow you to trigger a specific error, such as a bit flip or phase flip. You don't need to show every possible error, just the important ones. What to hand in: As in the first lab, please hand in print outs of your code, and screen dumps of the above tests. Note: the circuits on Pages 474-475 of the Nielsen-Chuang use a re-ordering of the stabilizers described in this lab (and listed in the book). This puts the stabilizers into a canonical form that makes certain constructions easier. But, none the less, use the stabilizers, and not the sample circuit.
Note: the procedure gates to be implemented in this lab can all be implemented transversally. A final note: In this lab you have almost created a universal set for fault tolerant quantum computation. The only thing missing is the logical T gate. This gate is not simple to create (it is about as much work as this lab combined). But, if you're in the mood sometime, and want to play with QCL, try implementing this gate! The T gate cannot be implemented transversally. See pages 485-491 of Nielsen-Chuang for details.
One last final note: Although this lab is due Feb 21st, please start early. This lab is much more difficult than the first.