The Retrograde Analysis Corner
J. Keeble was the first to notice that there exists a weird way
to combine the different conventions for en
passant captures and castlings.
Sometimes they can be subordinated, e.g. when a retrograde analysis
of the position shows that if castling is still possible, then
the last move must have been a double step by a Pawn so that
this Pawn can be taken en passant.
See also Werner Keym's article
En-passant capture in the Codex 2009
4th Prize Europe Echecs 1966-68
13+14. (AP) Mate in 2
Black captured with axb, b3xc2, and the wKB at home. White captured
the bQ and one bR by f6xe7 and h4xg5. When f6xe7 was played, the bKBP
was still on f7.
Any possible last move by Black must have been preceded by a White
move played with Ke1 or Rh1, so that White can't castle. There are two
exceptions. First 0 ... Na3 -1. a3-a4 is possible, but once the a4 pawn
is on a3, the wQR could only leave its SW cage after the wK left e1:
castling is still forbidden.
The other exception is if Black's last move was 0 ... f7-f5. Now White
can retract -1. f6xe7 and retains his castling right.
Therefore, we can say that if O-O is possible, then the last move
was 0 ... f7-f5 and then 1. g5xf6ep is legal.
The A Posteriori rule allows us to pick this as a key move, provided
White castles later. This is the solution of the problem.
Now after any Black move, White follows with 2. O-O#.
2. Kf2 (or other "checkmating" moves) would not suffice because White
has to provide the a posteriori justification of his 1st move.
Notice that, in such problems, a Black defense after the key move
could well be anything that forbids White's O-O, even if it exposes
the bK to other mating moves. This can be used to great effect !
Some people still oppose this rule and argue that it should certainly
not be the default convention. Thus it is common to see "(AP)" written
in the stipulation of problems using it, as a reminder.