The general convention is that, in a given problem, any side has the
right to castle provided it is not possible to prove it has lost this
castling right. (See "Castling" in the glossary.)

Now it is sometimes possible to prove that some castlings right are
mutually exclusive. M. Havel was the first to notice and use
this, in 1922.

Here Black and White can't be both allowed to castle. Indeed, consider
the Rook on d4. If it is the original QR, then obviously White can't
castle anymore. If it is the original KR, then the wh. King had to let
it out of the SE corner, and he can't castle anymore.

Another (real) possibility is that the Rd4 is a promoted R. Then it
must have left the 8th rank through square d8, or f8, or h8. In any
case the bK (or the bKR) must have moved and B can't castle anymore.

In conclusion: it can be proved that the two castlings are mutually
exclusive, but none may be proven impossible in itself.

Now, who can castle?

In such a case, the general default convention is that whoever
castles first is allowed. Once this is done, the other castling
becomes forbidden because, then, it can be proven impossible).

Lapierre's problem is a very pedagogical illustration. The try 1.
Rad1?, threatening 2. Rd8 mate fails on 1 ... O-O! The solution is
1. O-O-O! and now 2. Rd8 mate can't be avoided because
1 ... O-O? is illegal.

Sometimes another convention, Retro-Variants,
is assumed. In this case, it is required to mention "(RV)" under the
diagram.