|White moves; Black mates.|
Raymond Smullyan, in The Chess Mysteries of Sherlock Holmes (pp. 76-79 of the 2012 Dover edition; originally published 1980) notes that in the 19th century and later -- indeed, until FIDE changed (or perhaps clarified) the rules of promotion relatively recently-- it was de jure legal to promote to a piece of the opponent's color. This would allow a promotion of White's a7 pawn to a Black rook on a8. Smullyan wonders: is castling possible in that case?
Whether one intuitively thinks it should, or should not, depends on how one views the pieces, notes Smullyan. Is 'queen's rook which has not moved from its original square' meant to apply only to rook on the board at the beginning of the game, or to include a piece created by promotion?
I suspect most players would take an inclusive view here, arguing that castling should be legal -- under the principle that, as all other laws of chess apply equally to promoted pieces, the same should hold for castling. This view, incidentally, is implict in Krabbe's and Pam's argument for the legality of 'extra long' castling.
Should it be Legal?
Smullyan thinks most players would consider this castling perfectly legal due to the fact that most players have a "Platonist" view of chess -- that the physical pieces are not what makes a 'chess piece', but the way they move or are treated by the rules.
While true, I think the explanation is simpler. In most games (as opposed to sports), the tokens used to designate the pieces do not matter, and what makes a piece a piece is what it can or cannot do according to the laws of the game. One can play Whist, say, with blank pieces of paper as long as one remembers which card is which, or for that matter, it's perfectly possible to play chess (or most other games) sans voir and without any physical tokens.
In this respect all physical game tokens are mere manifestation of the "ideal" pieces, and the game itself is merely (and not necessarily, at that) represented by the movement of physical objects. If this is Platonism -- or, more seriously, a clever way to illustrate Platonism, by analogy, to philosophical novices -- so be it. But there is nothing in this that determines whether the laws of the game should treat a promoted piece, for example, differently than a "regular" piece. Or for that matter allow (say) the h-pawn to move differently than the a-pawn. This question has nothing to do with what physical object represents either piece in a particular game.
The reason most chess players, I suspect, would consider castling legal in this case has nothing to do with Platonism, but with simplicity and harmony. Most players see it as an aesthetic virtue that the laws of the game of chess do not treat promoted pieces any differently than regular pieces. One of the later changes to the laws of chess, in the 18th and 19th century, was the disappearances of special requirements of rules for promotion. It is no longer required the promoted piece be one that was already taken, or one found on the file on which it promotes in the array. A promoted piece need no longer "rest" motionless for a turn.
These and similar laws (or local variations of them) became obsolete since streamlining promotion in this way simplified the laws of the game while enriching the possibilities and depth in endgame play: more from less. So unless there is a very good reason for it, most players would agree that the promoted rook should be treated equally with the original one in the case of castling as well as in other cases.
Is it Legal?
Whatever one thinks about whether castling should be legal in this case, the letter of the law about castling makes no distinction between promoted and non-promoted pieces, so it seems that it is legal, or at least was until it was formally made illegal to promote a piece to the opposite color. The promoted rook is on (Black's) first rank (which, incidentally, was the official change made to the rules of castling in the 1970s, to prevent '0-0-0-0' cases...), neither the king (we assume) nor the rook have moved, it is Black's turn, and neither e8, d8, or c8 are attacked by any of White's pieces.
So it seems that the following moves meet the stipulation:
1. a8=Black R?!? Castles QS#
It seems that yet another type of castling not imagined by the official laws of the game is, or at least used to be, possible. Perhaps it should be designated 0-0-0-0-0 (to distinguish it from Krabbe's 0-0-0-0 as well as from regular castling); after all, unlike 0-0-0 or 0-0, such castling could occur even after both original rooks moved, or, for that matter, if they were taken.
0-0-0-0-0 or 0-0-0?
To be sure, one may with equal plausibility argue this is simply an unusual case of queen side castling, 0-0-0, which doesn't need a special notation any more than any other move with any other promoted piece does. Perhaps most chess players would argue just this for the same reason that they would consider such castling legal in the first place: if the same rules apply to promoted pieces, surely the same notation should as well?
However, this is a purely linguistic matter, which does not affect the legality of the new castling, nor the fact that it is a very unusual kind of castling not foreseen by the laws, but merely what name it should be given.
Yes, there is of course a "cook" to this "problem" (1. a8 = Black Q), as well as a "side variation" to the original solution (1. a8 = Black R Rd8#) but that is hardly its point...