# Can you take classical code and compile it to quantum code?

Is there anyway for example, to take a trivial program from C such as:

int main() { int i = 1 + 1; return 0; } 

And compile this down to some form of Quantum Abstract High-level language, i.e. Quantum C?

From what I understand, quantum arithmetic is quite tricky business that uses QFTs. My first thought was to do the following for the example above:

Initialise two qubits and set the amplitudes like following: $$0|1|0|0$$

Where 0100 = 2 in decimal.

Somehow return this quantum register.

Using the amplitudes, you could perform 32-bit arithmetic with 32 qubits?

I haven't answered the notion of creating a function or returning either.

Essentially what I'm asking is the following, can we take known quantum methods (using Unitary functions to perform calculation) and apply this to classical code and if so, how?

EDIT: I've looked further and seen a few papers on Quantum Full Adders, I assume this is the way to go for addition? Is this too much? In quantum computation books that describe quantum assembly, there is not much mention of addition.

• Probably the best way to think of a quantum programming language is a classical programming language (e.g. C) with a new data type which represents quantum memory, and a bunch of new operations that work on quantum memory (e.g. Hadamard transform, controlled not, phase rotate). In that sense, every classical program is a quantum program which just doesn't use the quantum stuff. – Pseudonym Dec 9 '15 at 0:10
• Hi Pseudonym, I seem to understand everything barring arithmetic. I'm not sure how quantum gates can accomplish arithmetic? Or perhaps because I can just straight do addition using my qubits already? – watkinsr Dec 9 '15 at 0:13
• You first have to decide on what "quantum arithmetic" actually means. Once you've defined the precise operation that you want, then just like with classical logic, you can either implement the operator, or build it out of lower-level logic operators. In a sense, you don't really "need" integer addition in a classical programming language, either; you can build it out of logic operators if you feel so inclined. – Pseudonym Dec 9 '15 at 0:59
• So essentially one could just suppose that hardware will take care of it and write it how I see fit? For instance, if we take addition, I could just suppose that hardware quantum full adders will exist and my quantum programming language could have for instance: int j = 1 + 2 ? I think the problem is I never really understood how classical assembly understands such things. – watkinsr Dec 9 '15 at 1:15