
Show HN: Quantum suicide in Python - karldray
https://github.com/karldray/quantum
======
unwind
I'm just reading
[https://en.wikipedia.org/wiki/Our_Mathematical_Universe](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.

~~~
Artoemius
I never read in my original language anymore. Seems like the whole universe
writes in English now.

~~~
mpnordland
Apparently quantum.fail() was called in all the others.

------
ridiculous_fish
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...](https://mitpress.mit.edu/sicp/full-text/book/book-
Z-H-28.html#%_sec_4.3.1)

~~~
dangirsh
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...

------
stared
To some extent it reminds me a story "All paths to happiness"
[https://physicsnapkins.wordpress.com/2013/05/20/all-paths-
to...](https://physicsnapkins.wordpress.com/2013/05/20/all-paths-to-
happiness/) \- 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...](https://en.wikipedia.org/wiki/Quantum_suicide_and_immortality))
- 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).

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

~~~
stared
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](https://www.youtube.com/watch?v=vBkBS4O3yvY)

~~~
ikeboy
I don't understand your design. How does the fact as to whether you won cause
the photon to activate the explosive?

~~~
stared
There are two different detectors and a single photon. It can be detected only
in one place at a time.

~~~
ikeboy
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?

~~~
stared
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.

~~~
ikeboy
How do you win? Nothing in your comment explains that. Give a detailed model,
as I did.

~~~
stared
Setting is here: [http://imgur.com/qwpukly](http://imgur.com/qwpukly) You win
if the photon is measured by the win-detector, as depicted here:
[http://imgur.com/STjajMp](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.

~~~
ikeboy
Who would bet on someone's death? This doesn't seem plausible.

~~~
stared
It's a thought experiment.

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

~~~
ikeboy
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.

~~~
stared
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?)

~~~
ikeboy
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.

------
nudpiedo
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

~~~
pschanely
You should certainly check out the code. It's very ... cute.

~~~
nudpiedo
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.

~~~
humbledrone
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](https://github.com/logpy/logpy) [2]
[https://github.com/swannodette/logic-
tutorial](https://github.com/swannodette/logic-tutorial) [3]
[https://gist.github.com/swannodette/3217582](https://gist.github.com/swannodette/3217582)

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

------
andrewchambers
So this looks like prolog and logic programming to me.

------
Arqwer
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 :)

~~~
mdpopescu
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.

------
plugnburn
371 bytes in Python. Not minified. Bravo!

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

~~~
Frenchgeek
"Out of cheese error : please reboot universe"

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

------
jrussino
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](https://en.wikipedia.org/wiki/Greg_Egan)

------
yyhhsj0521
Sounds like Haskell's list monads to me.

~~~
throweway
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.

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

------
pyeng
Are we sure a bug in your code won't destroy the universe?

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

------
amelius
How is this different from an ordinary breadth-first search (with pruning)?

~~~
Arqwer
This is supposed to run on computers with hardware support of destroying a
universe.

~~~
HCIdivision17
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#_=_](https://github.com/drocta/TILDE-
ATH#_=_)

~~~
XaspR8d
I'm sad this doesn't support the canon of having syntactically-functional text
colors (and multiple parallel colored "documents").

~~~
HCIdivision17
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...](http://vignette4.wikia.nocookie.net/mspaintadventures/images/d/de/Virus.gif/revision/latest?cb=20100625045237)

------
gaze
This is not at all how proposed quantum computer or algorithms work. It's a
cute experiment but it's more anthropic than quantum.

------
gravypod
What is this used for? Why would this be important?

~~~
throweway
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

