I'm surprised (oops, no pun intended) that there hasn't been more discussion of this here, or in the node the unexpected hanging, which also just states the paradox. A lot has been said about it in the literature, but as it's phrased, no-one I've seen has come up with a satisfactory resolution.

So I think I'm making a nontrivial claim when I say I've invented an equivalent (I think) formulation where the solution can be worked out clearly.

There are two big confusing things in it, the passage of time and what it is to expect something. You could stiffen the notion of expectation by saying the student or prisoner has a vote to cast, one only, which they can use only at the beginning of a day. If they click the checkbox on Tuesday, that's it, they're expecting it on Tuesday. Or: if they click it, for Tuesday, in advance of Tuesday, they're saying I now (Monday) expect it will happen on this future day. Well, others may wish to amplify on these possibilities; I leave it to them.

I recast the problem as a spatial one, and instead of expectation there is direct visual knowledge. This removes all uncertainties that confuse us.

Problem

Consider five people in a row, call them Alfie, Bert, Charlie, Dickie, and Eric. Alfie is facing the front and cannot see the others. Bert is behind Alfie and can see his back. Charlie is behind Bert and can see Alfie's and Bert's backs. And so on, the last person can clearly observe the backs of everyone in front. But no-one can inspect their own.

The experimenter has, let's say, a large gold star made of felt, adhesive on on side. She walks down the row clapping each person on the back. Each person feels the same sensation. For one of them, the experimenter twists her wrist so that the gold star adheres to that person's back. When she gets to the end she returns to the front where they can all see her, devoid of gold star. All know that one of them has the star; and anyone behind the star-bearer has clear sight of it; but none of them can see or feel if they themselves or someone behind them has the star. This situation is, I hope, clear. And it can be made clear to the participants in practice runs, if need be.

Now the star-less experimenter makes the unexpected hanging/test statement: "One of you has the star, but that person will not be able to work out if they have it."

Eric knows whether he's got it. Obviously he could see it if he hadn't got it. Dickie either knows who's got it, ahead of him, or reasons that if Eric had it Eric would be able to falsify the experimenter's statement, so he Dickie must have it: but this also falsifies the experimenter's claim. And so on up the line.

But Bertie, say, having just worked out that Eric can't have it, therefore Dickie can't have it, therefore Charlie can't have it, therefore he Bertie must have it - plainly has no idea where it is. And so the experimenter's claim about not being able to know where it is, seems to be true. Paradox.

Solution

Couched in this way, the fallacy is more easily seen. Here's what seems to be happening: Each of them works out that the experimenter's claim (equivalent to the judge's sentence or the professor's announcement) must be false. Yet jointly all of these conclusions yield the contrary conclusion that it is in fact true.

Here's what is actually happening. The experimenter's claim in English is that "Whoever has the star... they will not know...". The relative scope of the quantifiers is being misinterpreted. What it actually means is

```    forAll X (X has-star -> not (X knows-has-star))
```
of which the negation is
```    Exists X (not (X has-star -> not (X knows-has-star)))
<=> Exists X ((X has star) and not (X knows-has-star))
```
or back in English, one of them has the star, but doesn't know it.

Is this true or not? Well it's true if X is Alfie to Dickie, but false for Eric. So the experimenter's universal statement is false.

In the temporal case however you don't start thinking on Friday, you start on Monday. And you think of yourself as the same person on each day. So you tackle the problem on Monday as Alfie. And Alfie, of course can't tell whether they have the star. The conclusion seems to be that "I can't tell", where "I" ranges over all five days.

Let U(d) be the claim that on day d, the test or hanging will occur and be unexpected. The teacher or judge asserts that forAll d U(d). The paradox logic first deduces that U(5) is impossible. Then it works back through U(4) to U(1), all of which turn out to be false, so the forAll must also be false.

But of course U(d) is true for d = 1 to 4. On those days you don't know which day you're to be hanged/tested. Only for d = 5 is it actually false. So the judge's/teacher's statement of forAll is false. Therefore its negation is true, but its negation is merely that for some d, U(d) is true. And indeed this is true for four of the five d.

In this case, why do we mistakenly conclude U(d) for every d?

On day d = 5, we know with certainty not U(1) & ... & not U(4). Therefore also if we are to be hanged/tested at all, then not U(5). That is, if we assume the claim forAll d U(d). If we do, we derive a contradiction, so we deduce the original premiss is false. But on day 5 we know U(5) whether or not the claim is true. If we are hanged, it will not be unexpected; or we will not be hanged. It is not derived from the universal.

On day d = 4, we know with certainty not U(1) & not U(2) & not U(3). We begin by not knowing whether U(4) is true. But U(5) is true absolutely. This still does not prove U(4). If we further assume the judge's/teacher's claim, then U(4) follows. But it does not follow from U(5).

In that case the chain of reasoning simply stops. You can deduce U(5), you can't go further back. If it were true what the judge/teacher said that it would be unexpected whenever it was, then you could conclude U(4) to U(1) and derive a contradiction. But phrasing it as the row from Alfie to Eric clearly shows that it is not true. And that's fine: that's our common sense understanding.

Back to the future

To answer kelrin's final remark in answer to this, and to take it back to a time-based situation, there is nothing paradoxical about surprises, nor of someone telling you in advance that there will be a surprise. It's true, this happens all the time. And we are indeed usually surprised when the thing happens. The only thing that's ruled out is someone telling you that you will be surprised no matter what day it happens.

Think of a fire drill. There is a legal requirement to hold a fire drill once a year, and a memo comes around the office to this effect in late October; and to be useful, the fire drill will be a surprise. If you get to 31 December and it hasn't happened yet, you know it must happen today (is legally required to), and that therefore it won't be a surprise. So the bit in the original announcement about its being a surprise was false, in this case, for this day.

But on 30 December you know it must happen today or tomorrow, but you don't know which, and also therefore you don't yet know whether it'll be a surprise. If it happens today, it'll be a surprise. In fact the fire alarm goes off suddenly on 17 November, fulfilling both the legal requirement and the announcement of a surprise.

My spatial reasoning shows that the case of the last day is different. For that day only, there is no uncertainty, and so if you get to that position, then part of the original statement proves false. They can't state it will be a surprise; but they can quite reasonably state that it probably will be.