He also finds out that the envelope wasn't empty. If the envelopes are positively correlated -- knowing that one envelope has money increases the probability that another envelope has money -- then this can counteract the effect of replacing this envelope. The trick is to make the correlations be such that the two effects cancel out exactly.
Yeah, that's the solution. And one that should be obvious to anyone familiar with Jaynes. Probabilities are about states of knowledge, not about physical propensity.
Unfortunately, although I'm familiar with Jaynes, I jumped to a propensity interpretation. Fewer coins must mean a lower chance of picking a coin - which it obviously would, for someone whose estimate of the total number of coins doesn't change. And then I spent my energy marshaling the arguments why these wackos must be wrong and don't know diddley.
My takeaway is that it is usually more useful...
This went over well in the xkcd logic puzzle forum (my hand was not removed), so I thought I'd try it here. It came to me in a dream, so by solving it you may be helping to summon an elder god or something.
Bob replies, "That depends on what random function you used to choose how many envelopes to fill. If you, say, flipped m coins and put each one that came up heads in an envelope, the expected value is $.50."
Alice explains what her random function was, and Bob calculates the expected value. For kicks, he pays her that amount, and she lets him pick a random envelope. It has a coin in it! Bob pockets the coin. Alice then takes the now-empty envelope back, and shuffles it into the others. "Congratulations," she says. "So, what's the expected value of playing the game again, now that there's one fewer coin?"
"Same as before," Bob replies.
Problem 1: Give a value for m and a random function for which this makes sense (there are many).