Endgame problem: How to avoid stalemate and win? I'm stuck on this problem a friend shared with me recently, with barely any pieces left and apparently white is able to force a win but I've been hitting a wall with everything I've tried so far, as everything seems to immediately lead to stalemate...! Here's the diagram of the problem, with white to move and win.

This problem was created by Josef Prokop, and published in Prager Presse in 1924.

 [title "White to move and win"]
 [fen "6k1/6P1/5BP1/p7/8/K7/p7/8 w - - 0 1"]


I know that if I entered this position into an engine I'd probably get the answer immediately, but to be honest as opposed to just seeing the answer, I'm more interested in how one should approach or reason about such problems in order to systematically get closer to finding the solution. So I would appreciate it if someone could flesh out how they approached the problem and step by step got to the solution, that would be incredibly helpful.
It's quite a fun problem to think about, before getting to the
calculation of long variations, try to first spot the key idea needed to crack the problem.

Here are the first observations that come to my mind which eventually
led me to spot the solution, let's break them down step by step:


a) With our bishop eyeing g7 and our doubled pawn formation on g6-g7, black will draw by stalemate as soon as they run out of pawn moves on the a file.
b) With a) in mind, try some basic moves to develop a feel for the position and nuances in terms of timing. So let's attempt to see through some of our king move options: 1.Ka4 is no good as it will end immediately in a draw after 2...a1=Q+ 3.Bxa1, similarly with 1.Kb2 a1=Q+ 2.Kxa1 a4 and the draw is trivial.
c) Count black's remaining moves: in principle there are a total of 5 pawn moves, then it's a stalemate unless we give the black king on g8 a legal move.
d) To ensure the latter, the only way is clearly to let the g7 pawn fall, as g6 cannot move anyway.
e) But how to give away the g7 pawn, while i) our bishop still eyes the promotion square (a1), and ii) afterwards not leave hanging our 2nd and only remaining pawn on g6 which is a light square pawn!
f) observations in e) basically tell us that we cannot leave the a1-h8 diagonal with our bishop or else black promotes. So in order to leave g7 unprotected, our only option is to blind the bishop by blocking the long diagonal with the king!
g) Assuming we leave our bishop on a1, then there are various options for blinding the bishop, for instance getting the king to c3 or d4 or e5, ... which is the right one?
h) We can resolve that by remembering our observation e, ii), namely that after black takes on g7 we need to be in time to protect g6, that means in the very next ply! Therefore, our only option is to block the bishop's sight via e5, let black take, and defend g6 immediately with Kf5, right on time. In fact Kf5 will unavoidably be with check as our bishop is still on the long diagonal! Once g7 is removed and g6 is defended, black has spare king moves and there are no threats of stalemate anymore. 


Summary of our discovered idea:


   
 


Now it simply remains to execute our plan correctly, which means a bit of concrete assessment of the position in order to find the right move order:


We know we want our bishop somewhere between a1-d4, so let's try the immediate 1.Ba1: 2...a4 and black draws immediately. All other bishop moves lead to the same situation after 2...a1=Q forcing Bxa1.
Let's not waste tempi at start with the bishop since it'll be naturally drawn to a1 anyhow as we let black promote. Instead, let's use all our tempi to get our king to d5 as fast as possible and prepare our Ke5-Kf5 maneuver. 


Solution:


   So let's try: 1. Kb3 a4+ 2. Kc4 a3 3. Kd5 a1=Q 4. Bxa1 a2 5. Ke5 Kxg7 6. Kf5+ kg8 the difficult bit is done! Now we just have to shoulder away the king from the promotion square (g8). 7. Ke6 Kf8 8. g7+ Kg8 9. Ke7 Kh7 10. Kf7 and the rest is trivial. 


I really recommend to either go through the above discussions without using an analysis board to try out moves, or to try and solve it on your own with mental calculations only, considering our observations a to h. As there are only few pieces in this problem, it can make for a very useful exercise of concentration and calculation.

Animated solution: