News for hackers. Stuff that matters.
Re:Show HN: Quantum suicide in Python by unwind on Thursday March 24, 2016 @05:28AM (#11351516)
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.

Re:Show HN: Quantum suicide in Python by Artoemius on Thursday March 24, 2016 @06:00AM (#11351637)
I never read in my original language anymore. Seems like the whole universe writes in English now.
Re:Show HN: Quantum suicide in Python by mpnordland on Thursday March 24, 2016 @08:52AM (#11352341)
Apparently quantum.fail() was called in all the others.
Re:Show HN: Quantum suicide in Python by ridiculous_fish on Thursday March 24, 2016 @03:28AM (#11351154)
Is this the same as the amb form, as seen in SICP?

https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-28.htm...

Re:Show HN: Quantum suicide in Python by dangirsh on Thursday March 24, 2016 @04:37AM (#11351352)
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...

Re:Show HN: Quantum suicide in Python by d0m on Thursday March 24, 2016 @08:29AM (#11352226)
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!!

Re:Show HN: Quantum suicide in Python by stared on Thursday March 24, 2016 @04:20AM (#11351309)
To some extent it reminds me a story "All paths to happiness" https://physicsnapkins.wordpress.com/2013/05/20/all-paths-to... - without spoiling it too much, also about trying all combinatorial possibilities.

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).

Re:Show HN: Quantum suicide in Python by TelmoMenezes on Thursday March 24, 2016 @05:19AM (#11351481)
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).

Re:Show HN: Quantum suicide in Python by stared on Thursday March 24, 2016 @05:43AM (#11351582)
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.

And also, on a funnier note - Everettian dating: https://www.youtube.com/watch?v=vBkBS4O3yvY

Re:Show HN: Quantum suicide in Python by ikeboy on Thursday March 24, 2016 @09:08AM (#11352404)
I don't understand your design. How does the fact as to whether you won cause the photon to activate the explosive?
Re:Show HN: Quantum suicide in Python by stared on Thursday March 24, 2016 @12:21PM (#11354069)
There are two different detectors and a single photon. It can be detected only in one place at a time.
Re:Show HN: Quantum suicide in Python by ikeboy on Thursday March 24, 2016 @12:33PM (#11354203)
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?

Re:Show HN: Quantum suicide in Python by stared on Thursday March 24, 2016 @12:43PM (#11354293)
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.
Re:Show HN: Quantum suicide in Python by ikeboy on Thursday March 24, 2016 @12:56PM (#11354404)
How do you win? Nothing in your comment explains that. Give a detailed model, as I did.
Re:Show HN: Quantum suicide in Python by stared on Thursday March 24, 2016 @01:17PM (#11354587)
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.
Re:Show HN: Quantum suicide in Python by ikeboy on Thursday March 24, 2016 @01:22PM (#11354619)
Who would bet on someone's death? This doesn't seem plausible.
Re:Show HN: Quantum suicide in Python by stared on Thursday March 24, 2016 @02:55PM (#11355364)
It's a thought experiment.

For practical things: I won't. But I bet some people would.

Re:Show HN: Quantum suicide in Python by ikeboy on Thursday March 24, 2016 @03:34PM (#11355737)
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.
Re:Show HN: Quantum suicide in Python by stared on Thursday March 24, 2016 @03:48PM (#11355861)
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?

(BTW: Did you actually learn QM?)

Re:Show HN: Quantum suicide in Python by ikeboy on Thursday March 24, 2016 @05:16PM (#11356511)
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.

Re:Show HN: Quantum suicide in Python by Chris2048 on Thursday March 24, 2016 @07:46AM (#11352030)
malfunctioning detector?
Re:Show HN: Quantum suicide in Python by msellout on Thursday March 24, 2016 @05:15AM (#11351467)
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.
Re:Show HN: Quantum suicide in Python by stared on Thursday March 24, 2016 @05:30AM (#11351537)
But then it's not quantum mechanics, but statistical mechanics. Also known as survival bias.

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.

Re:Show HN: Quantum suicide in Python by taneq on Thursday March 24, 2016 @11:00AM (#11353307)
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.
Re:Show HN: Quantum suicide in Python by nudpiedo on Tuesday March 22, 2016 @04:09AM (#11335034)
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 will check out later the code

Re:Show HN: Quantum suicide in Python by pmalynin on Thursday March 24, 2016 @03:05AM (#11351089)
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.
Re:Show HN: Quantum suicide in Python by pschanely on Tuesday March 22, 2016 @04:18AM (#11335059)
You should certainly check out the code. It's very ... cute.
Re:Show HN: Quantum suicide in Python by nudpiedo on Tuesday March 22, 2016 @05:45AM (#11335381)
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.

Re:Show HN: Quantum suicide in Python by humbledrone on Thursday March 24, 2016 @03:08AM (#11351103)
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.

[1] https://github.com/logpy/logpy [2] https://github.com/swannodette/logic-tutorial [3] https://gist.github.com/swannodette/3217582

Re:Show HN: Quantum suicide in Python by Arqwer on Thursday March 24, 2016 @07:41AM (#11352002)
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.
Re:Show HN: Quantum suicide in Python by andrewchambers on Thursday March 24, 2016 @06:19AM (#11351698)
So this looks like prolog and logic programming to me.
Re:Show HN: Quantum suicide in Python by Arqwer on Thursday March 24, 2016 @07:53AM (#11352064)
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 :)

Re:Show HN: Quantum suicide in Python by mdpopescu on Thursday March 24, 2016 @11:26AM (#11353540)
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.
Re:Show HN: Quantum suicide in Python by OnLookAStar on Thursday March 24, 2016 @02:04PM (#11354958)
Be careful! If there is no universe in which EUR/USD = R, you are destroying every universe.
Re:Show HN: Quantum suicide in Python by plugnburn on Tuesday March 22, 2016 @08:35AM (#11336010)
371 bytes in Python. Not minified. Bravo!

Didn't get what does the exit code 55 mean though.

Re:Show HN: Quantum suicide in Python by Frenchgeek on Thursday March 24, 2016 @04:35AM (#11351344)
"Out of cheese error : please reboot universe"

( https://en.wikipedia.org/wiki/Hex_(Discworld) )

Re:Show HN: Quantum suicide in Python by cyphar on Thursday March 24, 2016 @03:07AM (#11351097)
ENOSUCHUNIVERSE, probably.
Re:Show HN: Quantum suicide in Python by jrussino on Thursday March 24, 2016 @03:38PM (#11355766)
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
Re:Show HN: Quantum suicide in Python by yyhhsj0521 on Thursday March 24, 2016 @09:32AM (#11352557)
Sounds like Haskell's list monads to me.
Re:Show HN: Quantum suicide in Python by throweway on Thursday March 24, 2016 @06:06PM (#11356876)
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.
Re:Show HN: Quantum suicide in Python by qwertyuiop924 on Thursday March 24, 2016 @11:57AM (#11353829)
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.
Re:Show HN: Quantum suicide in Python by pyeng on Thursday March 24, 2016 @10:53AM (#11353242)
Are we sure a bug in your code won't destroy the universe?

Incidentally, that sounds like a great idea for a novel!

Re:Show HN: Quantum suicide in Python by amelius on Thursday March 24, 2016 @07:35AM (#11351976)
How is this different from an ordinary breadth-first search (with pruning)?
Re:Show HN: Quantum suicide in Python by Arqwer on Thursday March 24, 2016 @08:18AM (#11352173)
This is supposed to run on computers with hardware support of destroying a universe.
Re:Show HN: Quantum suicide in Python by HCIdivision17 on Thursday March 24, 2016 @11:02AM (#11353316)
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.

[0] https://github.com/drocta/TILDE-ATH#_=_

Re:Show HN: Quantum suicide in Python by XaspR8d on Thursday March 24, 2016 @02:09PM (#11354996)
I'm sad this doesn't support the canon of having syntactically-functional text colors (and multiple parallel colored "documents").
Re:Show HN: Quantum suicide in Python by HCIdivision17 on Thursday March 24, 2016 @02:16PM (#11355048)
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.

[1] http://vignette4.wikia.nocookie.net/mspaintadventures/images...

Re:Show HN: Quantum suicide in Python by HCIdivision17 on Thursday March 24, 2016 @02:22PM (#11355091)
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

https://en.wikipedia.org/wiki/Duff%27s_device

Re:Show HN: Quantum suicide in Python by gaze on Thursday March 24, 2016 @10:13PM (#11358069)
This is not at all how proposed quantum computer or algorithms work. It's a cute experiment but it's more anthropic than quantum.
Re:Show HN: Quantum suicide in Python by gravypod on Thursday March 24, 2016 @01:45PM (#11354797)
What is this used for? Why would this be important?
Re:Show HN: Quantum suicide in Python by throweway on Thursday March 24, 2016 @06:02PM (#11356848)
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