We know that a (absolutely) pinned piece can move and give a check, and the check can even be a mate.
The following is an example for such a checkmate.
[FEN "8/8/2k5/8/4p2b/r7/3RKPBr/q7 w - - 0 1"] 1. f4 exf3#
Source: A. Skodras, Quora
I am interested in knowing whether this has ever occurred in a master game; say, both opponents are rated 2000+ and the game was competitive (e.g., in a tournament).
I suppose this happening in a game would be rare, let alone in a master game. But, the first impression (I had) that "moving a pinned piece and giving check cannont be a good move" is wrong.
[Title "Schatz vs. Giegold, Hof (1928)"] [FEN "7k/pb5q/1p3p2/2p1p1p1/6P1/QP4KR/P4PP1/1B5r b - - 0 1"] 1... Qh4+
Source: Martin Weteschnik, Understanding Chess Tactics (btw, this is one of the best books on how tactics work).
Here, the move 1... Qh4+ is the best move (along with 1... Rxh3+ which is a slightly slower mate).
CQL may be the best solution for questions of this type. One way I can think of to form a cql query is the following (and its flipcolour variant):
- white gives check (and mates black) in the current position,
- the piece last moved is X,
- if piece X is removed from previous position, then white is in check.
I don't know how (or whether) step 3 can be expressed in cql.