I find it awesome! I've never seen something like that.
I would like to know more details about this kind of programming (does it have to do with loud programming?) and to know whether is possible to use for real life problem solving without abusing it.
I couldn't resist to take a fast look online... and yes, it's very pragmatic. Even I would say funny/elegant, just expensive.
HOWEVER simple and easy solutions often are better, so based on the same simple idea the same experiment could be reimplemented with green threads and separate/cloned python environments in order to ensure that there is no shared memory.
In my opinion it is still a genius work, just missing compiler support for such construct.
If you find this kind of thing interesting, there is actually a branch of computer science called "logic programming" that is very similar, but actually useful for practical applications (as it's not a joke).
A really simple example would be something like logpy [1]. You give it a set of variables, and a set of constraints, and it will try to efficiently solve for values that meet all the constraints.
A more professional-grade logic solver might be Clojure's core.logic [2], which has been used in many real-world applications. Compare the core.logic Sudoku solver [3] with the quantum version. They are similar, in that they each set the constraints for a solved board, but core.logic is vastly, vastly more efficient.
Well, this is sort of similar to how Prolog solves things,
you can assert that, for example, the length of list is 6 and magically your input will be of length 6.
Amb is implemented with a backtracking evaluator and supports a try-again operation for requesting all valid outputs (universes). This library just forks the process for each "universe" and kills the ones where fail is called (including failing assertions). It can only return the first valid value.
This library is significantly less useful than amb for non-deterministic computing, but that doesn't seem to be the goal...
Yes, this is exactly what I was thinking about looking at the quantum example. For the end-user, it's the same high-level concept, but in the background the implementation is different. The quantum one create a new fork for each possible choice rather than using backtracking.
The quantum example is interesting because it gives us a sneak peek into the future for where it will be possible to write similar code in O(1) time!!
For quantum suicide (as in https://en.wikipedia.org/wiki/Quantum_suicide_and_immortalit...) - it still makes me think. Maybe it makes sense to gamble with others (using photons in superposition), putting my life at stake. And e.g. in the only 1/1024 universes I live I have x1024 money (and other universes do not matter to me).
That makes for an interesting interpretation of all those action movies where the protagonist seems to risk his life so frequently. We're only watching the most interesting one.
Or for a more commonplace example, old successful people telling young people to "take risks" and "follow your dreams". Of course they think it works in general because it worked for them.
Notice that for this to work reliably (assuming the Many World Interpretation is correct), you need a suicide method with a failure rate orders of magnitude below the probability of winning the bet. Otherwise you may end up in a universe where the suicide method failed instead of one where you win the bet. Failures that cause you a severe disability instead of killing you are particularly worrying.
The lower the probability of winning a bet (and so, the higher the potential gain), the more reliable you need your suicide system to be. For relevant gains, this becomes a non-trivial engineering problem. (e.g. suppose you need a gun that only jams for one in every billion shots, or a computer that can run for billions of seconds without crashing or malfunctioning).
This reliability is not that hard: take a photon and split it though a beamsplitter. One path leads to a detector with "you won" and the other - a detector igniting an explosive.
So why there may be problems (like: photon was not detected due to finite sensitivity) in this setting the wounded-but-not-dead outcome is negligible. In general, it is easy to amplify quantum effect with such avalanche reactions.
When it comes to MWI - it is the hard part. I am not sure if I believe it; or what is it's interpretations (maybe it's still unethical to having mourning families and friends in 1-\epsilon worlds). Also: even if I gamble many times, and I find myself alive - does it mean is it correct? And even if - there is no way of announcing it.
The usual design of quantum suicide involves the following:
1. Something in the world depends on a choice you make. If you choose correctly, you win. Ideally, there are a large number of choices, e.g. lottery, stock, bitcoin private keys, whatever.
2. You use quantum randomness to make the choice
3. The machine you constructed checks whether you won
4. If you did not win, it kills you
So you need to have a machine that reliably checks for a win, and kills you if it doesn't find one. How does having two detectors for the proton help?
In any case, I presented a simple, concrete implementation. Checking is built-in - if the photon goes path with bomb, then I am dead (due to this bomb). If goes the path where is a detector - then I won. No need to create a "checking machine" distinct from the one generating quantum states.
Setting is here: http://imgur.com/qwpukly
You win if the photon is measured by the win-detector, as depicted here: http://imgur.com/STjajMp (it can light a green led, make sound or, I don't know, launch confetti). People pay money, as it was a bet.
It makes it far less plausible as a thought experiment than the standard model, and also means you can't do it in secret, which brings legal and practical issues into play.
Let's finish this discussion, because I find your arguments perpendicular to mine. E.g. what is the problem with legality? Trolley problem is also unethical and illegal - and so what?
The point is that QI is generally presented as something that's not terribly difficult for someone to test out. The biggest barrier to entry is understanding enough physics to create the quantum noise, but after that it's basic robotics that can be done cheaply and by a single person.
Changing the experiment to require 1. illegal acts i.e. betting on someone's death, 2. knowledge by others, introducing an interference factor, etc changes the thought experiment. Of course, it may be valid as a thought experiment if it adds an interesting new complication, or removes a complication that wasn't essential to the paradox.
But remember, the objection you proposed your scenario to avoid was the possibility of something going wrong with the suicide attempt. Changing the entire scenario to be less plausible seems a bit too much for a staightforward objection like that.
I'm just reading https://en.wikipedia.org/wiki/Our_Mathematical_Universe [0] during my daily commute, this was very well-timed and thanks to the book I even "get it", kind of. Very nice! Now all we need is an actual quantum computer to run stuff like this on. Oh, and negotiate with the rest of the CS universe for the rights to the name "qsort()".
[0] BTW, it's annoying to read a book by a Swedish author, in Swedish, that has translation issues. The author is Swedish-American, so the book was written in English and translated by someone else.
Makes one wonder if it would translate nicely into ~ATH. At the very least, ~ATH's concurrency and async support would be a bit better.
Immediate edit: So on a lark I looked up "tilde ath" and found someone actually implemented some of it [0]. It's more focused on bifurcation than threading, and I think it might be improved by something like OP's `quantum`. At least we could simulate the plot a bit.
I'm actually surprised this doesn't come up more often. Considering how popular syntax highlighting is, it would be neat to be able to color stuff based on context. I guess it would be some sort of bizarre unicode monster that encoded the glyph as well as color?
Regardless, I was sad about that as well. You just can't appreciate the MRDV properly without it. [1] Or without the ensuing War & Peace-sized volumes of comic/chatlog either, I guess.
Another idea that's not supported is the pathological way function scope is interpreted. The two dang functions in the MRDV flow past each other, like a case fall-through [2], but for function scopes. It makes sense artistically in the comic, but I'm not super clear on what it would even mean in terms of a real program.
[2] Only Duff's Device comes to mind here, but I think we're looking at something more pathological with the MRDV
That code is pretty dangerous. I don't like the idea that I can become wounded-not-dead just because of a bug in the code. May be it worth to create a constant of safe malfunctioning, like eps=1e-10, and destroy the universe only with probability 1-eps, otherwise rise an exception? So during debug I would never risk to be wounded by meteorite, since it's probability is way below eps.
QS might be much more powerful than just fast calculations. We can predict future, or even fixate future. For example, program like
r = qrandom()
print(r)
wait(10 minutes)
if(EUR/USD != r) then fail()
will predict, what exchange rate of EUR/USD would be after 10 minutes. And if instead of r = qrandom() we put r = 1.5, than we force EUR/USD to be 1.5.
Another nice thing I'd like to try is webcam that looks to the future using the same principle :)
I believe that's exactly the reason why some people believe that quantum computing would be no more powerful than classical computing: it leads to all kinds of weird implications.
Yes thus feels like functional programming and you kind of get this for free using predicates and Haskells lazy evaluation. Infact the list comprehensions are similar and of course what are they... they are sugar for the list monad.
So it's basically amb, but with using threading instead of backtracking. So probably faster than the classic amb implementation, esp. on multiprocessor architectures, but also much more resource intensive.
I imagine generating cases for property based testing this could be quite useful. Also solving problems with brute force where effeciency doesnt matter. Eg proving a theorem on you machine but that code doest need to run in production. Or suduko fwiw
For anybody who finds ideas like this to be thought-provoking I highly recommend reading the novels & short stories of Greg Egan.
https://en.wikipedia.org/wiki/Greg_Egan
52 comments
[ 4.6 ms ] story [ 379 ms ] threadI will check out later the code
HOWEVER simple and easy solutions often are better, so based on the same simple idea the same experiment could be reimplemented with green threads and separate/cloned python environments in order to ensure that there is no shared memory.
In my opinion it is still a genius work, just missing compiler support for such construct.
A really simple example would be something like logpy [1]. You give it a set of variables, and a set of constraints, and it will try to efficiently solve for values that meet all the constraints.
A more professional-grade logic solver might be Clojure's core.logic [2], which has been used in many real-world applications. Compare the core.logic Sudoku solver [3] with the quantum version. They are similar, in that they each set the constraints for a solved board, but core.logic is vastly, vastly more efficient.
[1] https://github.com/logpy/logpy [2] https://github.com/swannodette/logic-tutorial [3] https://gist.github.com/swannodette/3217582
Didn't get what does the exit code 55 mean though.
( https://en.wikipedia.org/wiki/Hex_(Discworld) )
https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-28.htm...
This library is significantly less useful than amb for non-deterministic computing, but that doesn't seem to be the goal...
The quantum example is interesting because it gives us a sneak peek into the future for where it will be possible to write similar code in O(1) time!!
For quantum suicide (as in https://en.wikipedia.org/wiki/Quantum_suicide_and_immortalit...) - it still makes me think. Maybe it makes sense to gamble with others (using photons in superposition), putting my life at stake. And e.g. in the only 1/1024 universes I live I have x1024 money (and other universes do not matter to me).
For the reasons it seems that it is good to be brave in danger - for all brave succeed. Except for ones that did not and won't tell their stories.
The lower the probability of winning a bet (and so, the higher the potential gain), the more reliable you need your suicide system to be. For relevant gains, this becomes a non-trivial engineering problem. (e.g. suppose you need a gun that only jams for one in every billion shots, or a computer that can run for billions of seconds without crashing or malfunctioning).
So why there may be problems (like: photon was not detected due to finite sensitivity) in this setting the wounded-but-not-dead outcome is negligible. In general, it is easy to amplify quantum effect with such avalanche reactions.
When it comes to MWI - it is the hard part. I am not sure if I believe it; or what is it's interpretations (maybe it's still unethical to having mourning families and friends in 1-\epsilon worlds). Also: even if I gamble many times, and I find myself alive - does it mean is it correct? And even if - there is no way of announcing it.
And also, on a funnier note - Everettian dating: https://www.youtube.com/watch?v=vBkBS4O3yvY
1. Something in the world depends on a choice you make. If you choose correctly, you win. Ideally, there are a large number of choices, e.g. lottery, stock, bitcoin private keys, whatever. 2. You use quantum randomness to make the choice 3. The machine you constructed checks whether you won 4. If you did not win, it kills you
So you need to have a machine that reliably checks for a win, and kills you if it doesn't find one. How does having two detectors for the proton help?
For practical things: I won't. But I bet some people would.
(BTW: Did you actually learn QM?)
Changing the experiment to require 1. illegal acts i.e. betting on someone's death, 2. knowledge by others, introducing an interference factor, etc changes the thought experiment. Of course, it may be valid as a thought experiment if it adds an interesting new complication, or removes a complication that wasn't essential to the paradox.
But remember, the objection you proposed your scenario to avoid was the possibility of something going wrong with the suicide attempt. Changing the entire scenario to be less plausible seems a bit too much for a staightforward objection like that.
[0] BTW, it's annoying to read a book by a Swedish author, in Swedish, that has translation issues. The author is Swedish-American, so the book was written in English and translated by someone else.
Immediate edit: So on a lark I looked up "tilde ath" and found someone actually implemented some of it [0]. It's more focused on bifurcation than threading, and I think it might be improved by something like OP's `quantum`. At least we could simulate the plot a bit.
[0] https://github.com/drocta/TILDE-ATH#_=_
Regardless, I was sad about that as well. You just can't appreciate the MRDV properly without it. [1] Or without the ensuing War & Peace-sized volumes of comic/chatlog either, I guess.
[1] http://vignette4.wikia.nocookie.net/mspaintadventures/images...
[2] Only Duff's Device comes to mind here, but I think we're looking at something more pathological with the MRDV
https://en.wikipedia.org/wiki/Duff%27s_device
r = qrandom()
print(r)
wait(10 minutes)
if(EUR/USD != r) then fail()
will predict, what exchange rate of EUR/USD would be after 10 minutes. And if instead of r = qrandom() we put r = 1.5, than we force EUR/USD to be 1.5. Another nice thing I'd like to try is webcam that looks to the future using the same principle :)
Incidentally, that sounds like a great idea for a novel!