
What would a very simple quantum program look like? - tangue
https://cstheory.stackexchange.com/questions/9381/what-would-a-very-simple-quantum-program-look-like
======
api
"The result is that qubit 2 now contains the state of qubit 1 after Hadamard
operation."

This is really going to be a barrier to understanding.

When I was a little kid I could not only grasp but very easily _remember_ what
OR, AND, NOT, NOR, and XOR gates did. They take two inputs and tell you what
input 1 OR input 2 would be, etc. Addition, subtraction, multiplication, and
division are likewise easy to remember once you get the concept. These
operations add, subtract, multiply, and divide, respectively.

What is Hadamarding? What does it mean to Hadamard something? Do we really
have to use language studded with totems to dead people in place of clear
conceptual descriptions of things?

Math itself has the same problem once you get beyond concepts that were
discovered by people we no longer remember.

It's fine to memorialize great minds, but not at the expense of understanding
for future generations.

~~~
mikeash
Do you have the same objection to grouping the simple gates you mention under
the name of "boolean logic"?

I know almost nothing about quantum computing (aside from the fact that it's
not just a matter of trying all possible values simultaneously), but looking
up the Hadamard transform on Wikipedia, I'm pretty sure the barrier to
understanding is going to be the fact that it's a highly complicated
operation, not the three-syllable name.

~~~
Joe-Z
>Do you have the same objection to grouping the simple gates you mention under
the name of "boolean logic"?

Why wouldn't he? Wouldn't a term like 'switch logic' be much more intuitive? A
switch is either on or off, true or false.

~~~
mikeash
I don't know, I'm just wondering if they're consistent about it, or if they've
internalized terms like "boolean" to the point where they forget that they're
named in the same way. Given how common such things are in many fields, it
strikes me as weird to single out this particular instance.

Along those lines, I also wonder if they object to measuring the power
consumption of their boolean gates in "watts."

------
wzeng
There are libraries todat that let you do quantum programming! A simple Python
library to get started with quantum programming is
[https://pyquil.readthedocs.io/en/latest/overview.html](https://pyquil.readthedocs.io/en/latest/overview.html)

The Python library allows you to construct quantum programs and output in a
quantum/classical shared memory instruction set called Quil.

------
devrandomguy
TL:DR QM programs can be represented by a Lisp DSL, like everything else in
life. It's all brackets, all the way down /s

~~~
dexen
Obligatory xkcd: [https://www.xkcd.com/224/](https://www.xkcd.com/224/)

------
Strilanc
My guess is that at first it will look like existing programming languages,
but with some extra commands (apply Hadamard or QFT or whatever to a
register). Over time, people will find good ways to incorporate concepts like
reversibility, coherent conditions, phasing, and mixing quantum/classical data
deep into the language semantics.

For example, Grover's algorithm could be written like this:

    
    
        def grover_search_sample(bit_count, predicate):
            qureg = qalloc(bit_count)
            apply X to qureg
            apply H to qureg
            n = pi/4 * 2**(bit_count/2)
            for _ < n:
                if predicate(qureg):
                    phase_by pi
                if all(x_axis(qureg)):
                    phase_by pi
            return measure qureg

------
yellowapple
I really like how Perl's Quantum::Entanglement [0] looks/feels/works. Said
package's documentation also has some nifty examples of how it (and _actual_
quantum programming) could be used. In particular:

    
    
        $gas = entangle(1, 'bottled', 1, 'released');
          # gas now in states |bottled> + |released>
        
        $cat_health = p_op($gas, 'eq', 'released',
                                sub {'Dead'},
                                sub {'Alive'});
          # cat,gas now in states |Alive, bottled> + |Dead, released>
        
        if ($cat_health eq 'Dead') {# again, outcome is probabilistic
          # thus gas = |released>
        }
        else {
          # thus gas = |bottled>
        }
    

I don't know if this is "real" quantum programming, but it's pretty cool
regardless.

[0]: [http://search.cpan.org/~ajgough/Quantum-
Entanglement-0.32/En...](http://search.cpan.org/~ajgough/Quantum-
Entanglement-0.32/Entanglement.pm)

