Slashdot Mirror


Quantum Programming with Perl

moyix writes: "There's an article over at perl.com that describes how to use a perl module called Quantum::Entanglement. Using this module, one can simulate programming for a quantum computer. Developers looking to keep their skills current well into the next decade should check this out ;) Debian folks can grab libquantum-entanglement-perl and libquantum-superpositions-perl."

16 of 177 comments (clear)

  1. Shave and a haircut, qubits! by Anonymous Coward · · Score: 4, Funny

    I always wondered how Larry Wall was seemingly in 10 different newsgroups at one time. I guess he's been using quantum physics all along...

  2. No fair! by orkysoft · · Score: 4, Funny

    "No fair! You changed the outcome by measuring it!" -- Professor Farnsworth from Futurama.

    --

    I suffer from attention surplus disorder.
  3. Entanglement? by questionlp · · Score: 5, Funny
    Blockquoth the submission:
    There's an article over at perl.com that describes how to use a perl module called Quantum::Entanglement
    Why would I need a Perl module to help entangle Perl code even more? Isn't that part of the language ;-)
  4. Quantum::Superpositions by ilkahn · · Score: 5, Interesting

    Anyone interested in doing any type of quantum computing should check out Dr. Damian Conway's excellent Quantum::Superpositions. It is an extension to the perl language which adds the operators "any" and "all"... it's lets you do *incredible* things like:

    use Quantum::Superpositions;

    if ($x == any($a, $b, $c)) { ... }

    while ($nextval < all(@thresholds)) { ... }

    $max = any(@value) < all(@values);

    A good place to go and discuss the in's and out's of the cooler aspects of the perl community is perlmonks.org, check it out some time...

    1. Re:Quantum::Superpositions by Flubu! · · Score: 4, Interesting

      I heard Dr. Conway talk at the OReilly BioInformatics Conference in Tucson, AZ. He gave a talk about the Quantum::Superpositions module. It was hilarious. He started his talk with the premise that, if we could program on quantum computers in infinite multiple universes and constant time, this is how it should look like. As the talk progressed, the audience really started to get into it.

      I have to say that Conway is a brilliant speaker and truly funny. When he announced after a 3 hour talk that what he just spoke about isn't just a nice concept in theory but an actual perl module (only in a single universe and in real, often exponential time), the crowd just lost it and ROTFLed :)

      --
      Give me liberty, or a ham sandwich!
      See me at: www.flubu.com
  5. This is new? by bluntmanspam · · Score: 4, Funny
    This still leaves us with plenty of ways to make Perl behave in a thoroughly unpredictable fashion.

    For some of us, this is nothing new.

  6. Quantum Perl.... by Jace+of+Fuse! · · Score: 4, Funny

    Quantum Perl - "No longer will there be more than one way to do something, but rather there are an infinite number of ways to do everything!"

    --

    "Everything you know is wrong. (And stupid.)"

    Moderation Totals: Wrong=2, Stupid=3, Total=5.
  7. Hmmm.... by Quixote · · Score: 4, Funny

    use Quantum; my $jump = Quantum::Leap->new(); # nothing happens... Damn! Why doesn't it work??

  8. Not only for Perl by Anonymous Coward · · Score: 4, Informative

    There's a C++ version of the library here.

    Just thought you'd want to know

  9. Finally by Paul+Komarek · · Score: 4, Funny

    Finally, an application which Perl can't make more confusing.

    -Paul Komarek

  10. "Quantum" programming in Perl, oh brother.. by amitola · · Score: 5, Informative

    Although I can't get to the article right now, I do know a little about quantum computing thanks to having just finished a thesis on the subject.

    Studying the actual research in the field reveals that a real quantum device does not at all resemble a superintelligent "infinitely-faster-than-my-Pentium-4" computer of the future. To understand the difference requires understanding the fundamental nature of a quantum device and how it differs from a digital device.

    The atomic unit of a quantum computer is a physical system of some sort that exhibits quantum behavior, such as a single electron and its spin. Whatever the implementation, the unit is called a qubit. A single qubit contains information sometimes described as a vector of complex numbers.

    A digital computer, of course, operates on bits which allow only two states, the most common implementation of which is a high or low voltage at some defined point in an electrical circuit.

    Some operations are natural and easy to perform on bits; these are AND, OR, NOT, XOR, and their Boolean friends. These operations, in turn, lend themselves to an easy and natural implementation of integer math. Other operations do not have a natural representation in digital computers, such as real-number arithmetic. For the relatively few occasions that call for irrational numbers, we make do with approximations and call it "floating-point" math.

    The qubit's advantage is that, thanks to quantum mechanics, some operations which are very difficult for a digital computer are easy and natural for qubits. Notably, a set of qubits can perform a Fourier transformation in near constant time--an astounding operation that is so far believed to be impossible on any kind of Turing machine.

    The other side of the coin, which is rarely understood by mainstream news reporters, is that the qubit is completely unable to address most of the rest of our favorite operations, such as integer addition. To ask a qubit to count from 0 to 9 is extremely difficult, maybe physically impossible.

    If that weren't bad enough, quantum algorithms have to deal with other constraints such as the prohibition against creating a copy of an unknown quantum state. Therefore, your quantum Perl is going to have to start by doing away with the assignment operator. Qubits also have a nasty tendency to occasionally do things completely unexpected and unpredictable; this requires massively redundant calculations to reduce the probability of error to something acceptably small. (Of course digital computers suffer from random bit rot as well; it is solved with similar error detection and correction algorithms.)

    All these obstacles discouraged any serious interest in quantum devices for some time. However, recently (1997?) Peter Shor published the first important quantum algorithm, which factors large composite numbers in polynomial time. In case you don't know, a computer with such a capability would have staggering implications. Much of the world's data protection is based on the RSA algorithm which relies on the difficulty of factoring large numbers.

    Hence, the last few years have seen no shortage of funding or interest in quantum computing. Unfortunately, the mainstream media has caught just enough of the conversation to get the false idea that quantum computers are going to blow away all of the digital technology in existence, coming soon to a Best Buy near you.

    Anyway, the moral of the story is, don't start saving for that Pentium-Q just yet; not only is a quantum device completely inappropriate for the overwhelming majority of computing tasks, but the current state of the art is a machine on the order of 10 qubits or so. (A few hundred qubits will be needed before Shor's algorithm presents a threat to current encryption.)

    More realistically, you might expect to see one day in your lifetime a "quantum processing unit" that exists as a special-purpose extension to your digital processor--think along the lines of the 80287 floating point coprocessor. Even this kind of application is decades away at best.

  11. The real use of this... by Fnkmaster · · Score: 5, Informative
    I think this seems to be a bit lost on some people here. Obviously, it takes exponential time to simulate a lot of interesting things that would take polynomial time on a real quantum computer. This Perl simulator module is cool, but it's not going to prove or disprove P==NP.


    The real use of this is for people who want to experiment with quantum _algorithms_ on small data sets and learn and understand better how quantum computers work and how quantum calculations are put together. Writing quantum algorithms is hard and confusing to somebody familiar with classical computation, even if you are familiar with quantum mechanics. There are very few useful quantum algorithms (Gover's search and Shor's factorization algorithms are the two most famous and interesting IMHO). This module might encourage more people to come up with and experiment with quantum algorithms that take advantage of the "inherently parallel" nature of quantum computing.


    Note that though I am no expert, I did actually write something modestly similar to this Perl - an interpreter that read a series of meta-language commands and turned them into physical magnet pulses for spin flipping on an NMR quantum computer we had at MIT. We never bothered to write a simulator for it, but now that I think about it, it would be cool to have this. Kudos to these guys for doing this.


    Now if somebody could just make a quantum computer with, say, 20 or 30 qubits I might be convinced that quantum computing could eventually do useful calculations and that the decoherence problems and setup problems for a large number of weakly coupled qubit units are not intractable. Perhaps an alternative to NMR as the substrate for quantum computing might get farther.

  12. Re:thats nice but.. by Uller-RM · · Score: 4, Interesting

    Try to learn at least one of the theories of quantum mechanics before you start throwing around principles, okay?

    For one thing, QCs do exist - in fact, they demonstrated Peter Shor's 1994 factoring algorithm on a recently built 7-qubit box, factoring 15 into 3 and 7. You may say big deal, but it can factor ANY such integer in polynomial time. Usually the NSA is about 10 years ahead of the private sector, so I figure they've got at least 10 qubits by now. You should be worried - most public-key encryption methods rely on the intractibility of factoring.

    Secondly, the Heisenberg uncertainty principle only states that you can't predict with 100% accuracy which eigenstate a qubit will collapse into upon measurement. You can, however, compute a probability amplitude (which ends up being a complex number) that it'll be a 0 and another probability that it will be a 1. And it is possible to perform operations upon one or more qubits without measuring it - the idea of creating an operation that doesn't collapse the state is the crux of Quantum Computing.

    Unlike macroscopic physics, we don't know WHY things work on the quantum level the way they do. We've gotten relatively decent at predicting the end results though. So, we're just as confused as before... but we're capable of doing useful stuff with it. Don't knock it.

  13. Re:thats nice but.. by Anonymous Coward · · Score: 4, Funny
    in fact, they demonstrated Peter Shor's 1994 factoring algorithm on a recently built 7-qubit box, factoring 15 into 3 and 7.

    Incoming message for Mr. Shor: Your algorithm doesn't work.

    (ob. H2G2 ref.) Wait a minute ... *slaps forehead* Now I understand! 42! It all makes perfect sense now!

  14. QCL by Ignatius · · Score: 5, Interesting

    Another way to play around with nonclassical algorithms and get your feet wet with quantum programming would be QCL.

    QCL is a procedural quantum programming language which provides nonclassical language elements such as unitary operators, running code in reverse, scratch space management, etc. A Linux interpreter (GPL) which simulates a quantum computer with an arbitrary number of qubits is available here.

  15. Re:thats nice but.. by nihilogos · · Score: 4, Insightful

    For one thing, QCs do exist - in fact, they demonstrated Peter Shor's 1994 factoring algorithm on a recently built 7-qubit box, factoring 15 into 3 and 7.

    I wouldn't get too exited about this. Shor's factoring algorithm is a probabilistic algorithm, and for a small number such as 15 you could replace the entire quantum part by rolling some dice and still manage to find factors. So it's possible that the demonstration you refer to messed up somewhere but still managed to factor 15.

    Also, NMR quantum computing (which was used for that demonstration) is fundamentally limited to a maximum of around 12 qubits, and I seriously doubt the NSA has got anywhere near 10.

    Secondly, the Heisenberg uncertainty principle only states that you can't predict with 100% accuracy which eigenstate a qubit will collapse into upon measurement

    This is not the Uncertainty principle. This is the measurement postulate.

    The Heisenberg uncertaintly principle says things like " if you know the position of a particle precisely then you can't know anything about it's momentum" etc. Or, to wax technical, the products of the "errors" for position and momentum being greater than half the expectation value of the commutator of the operators represneting position and momentum.

    --
    :wq