CS 290N

Lab 1

Due Jan 31, 2006rd

The purpose of this lab is to become familiar with QCL, an interpreted language that supports mixed quantum/classical computation.

First, some useful information:

QCL can be obtained online from: http://tph.tuwien.ac.at/~oemer/qcl.html, but a precompiled version can be obtained locally from here .

I suggest that you edit files outside of QCL, rather than using the command line interface that QCL provides.

You can make QCL read in your text file prior to presenting you with a command prompt by executing it as:
qcl -i filename.qcl

Finally, although you should not need to for this assignment (you may for the next), you can increase the number of simulated qubits that QCL supports by using the -b command line option.

For instance, to simulate 64 qubits:

qcl -b 64 -i filename.qcl

Note that you cannot simulate a large number of qubits.

Simulating a quantum system is an O(2^n) problem!

Very quickly your simulation will consume tons of memory, and run "forever" if you try to tackle large problems.
To give you an idea, the source includes an implementation of Shor's algorithm.
I have successfully used this example to factor 77 (and that takes awhile). I would not try a larger number unless you are very patient.
Some useful QCL commands:
qureg x[2]; // declares 2 qubits x[0] and x[1]
int i; // declares a classical integer

real r; // declares a classical floating point number

measure x, i; // measures qubit states and places the result in i

dump x; // dump qubit probabilities

reset; // resets all qubits in the system back to zero.

Mix(source1); // H gate

CNot(target, source1 & source2); // Toffoli gate.

Problem 1) Teleportation

Write a QCL procedure teleport(qureg source, qureg destination, qureg scratch).

The procedure should teleport a qubit (source) into the destination qubit.  It will use the scratch qubit as part of the teleportation process.  After writing this procedure, test it by running it on a few arbitrary source qubit states (you can make some interesting qubit states for testing, by using the Rot(pi/y, source) function. Choose y to be some real number). Use the "dump" QCL command to demonstrate that the source qubit state is successfully teleported into the destination qubit.  Print these tests out and hand in the source to teleport and the screen dumps to show that it works.

Problem 2) Super-dense coding

Write a QCL procedure EPR(qubit q1, qubit q2) that creates an EPR state on qubits q1 and q2.

Write a QCL procedure Send(int bit0, int bit1, qureg q1) that encodes bit0 and bit1 into qubit q1.

Write a QCL procedure Receive(qureg q1, qureg q2) that decodes classical information bit0 and bit1 out of qubits q1 and q2.

Make this procedure print out bit0 and bit1.  Similar to problem 1, demonstrate that your procedure works. Do so by sending 00, 01, 10, and 11 through the quantum communication channel (qubit q1). Print out the source code, and screen captures of the relevant tests.