Solution:
Let ω1 and ω2 be the two incircles, centered at I1 and I2 respectively. We first introduce the points R1 and S1 on ω1 such that XR1 and XS1 are tangent to ω1, with the condition that S1 is on the line AP. Similarly, we introduce the points R2 and S2 on ω2 such that XR2 and XS2 are tangent to ω2, with the condition that S2 is on the line AP. Finally, let T1 and T2 be the contact points of ω1 and ω2 on the line BC. Noting that I1,I2 are on the angle bisectors of ∠R1XP,∠PXR2, respectively, we find that
∠R1XR2=∠R1XP+∠PXR2=2⋅(∠I1XP+∠PXI2)=2⋅90∘=180∘
so that R1R2 is a common tangent of ω1 and ω2. Note that, by reflection over I1I2, we have R1R2=T1T2. Moreover, as tangents from a point have the same length, we can observe that
R1R2=R1X+XR2=XS1+XS2=S2S1+2⋅XS2
and
T1T2=T1P+PT2=PS1+PS2=S2S1+2⋅PS1
so that XS2=PS1, and we can calculate
AX=AS2−XS2=AS2−PS1
However, these last lengths can be computed as distances from a vertex of a triangle to a contact point of its incircle. Hence,
AX=AS2−PS1=2AB+AP−BP−2AP+PC−AC=2AB+AC−BC
which is independent from the choice of P.