<s>[INST] How to prove that a length is equal to the inradius of a triangle $D$ is the midpoint of the side $BC$ of the triangle $ABC$. The line joining $D$ and the incentre $I$ of the triangle intersects altitude $AA'$ at the point $P$.
Prove that the length of $AP$ is equal to the radius of the incircle of the triangle..

 [/INST] Let $E$ be a tangency point with side $BC$ and  let $c>b$.
Hence, 
$$DE=BE-BD=\frac{a+c-b}{2}-\frac{a}{2}=\frac{c-b}{2},$$
$$BA_1=c\cos\beta=c\cdot\frac{a^2+c^2-b^2}{2ac}=\frac{a^2+c^2-b^2}{2a}.$$
Thus, $$DA_1=BA_1-BD=\frac{a^2+c^2-b^2}{2a}-\frac{a}{2}=\frac{c^2-b^2}{2a}.$$
Now, since $\Delta DIE\sim\Delta DPA_1,$ we obtain:
$$\frac{PA_1}{IE}=\frac{DA_1}{AE}$$ or
$$\frac{PA_1}{r}=\frac{\frac{c^2-b^2}{2a}}{\frac{c-b}{2}}$$ or
$$PA_1=\frac{r(b+c)}{a}.$$
In another hand, $$S_{\Delta ABC}=pr=\frac{(a+b+c)r}{2}=\frac{1}{2}ah_a.$$
Thus, $$AA_1=h_a=\frac{(a+b+c)r}{a},$$
which gives $$AP=AA_1-PA_1=\frac{(a+b+c)r}{a}-\frac{(b+c)r}{a}=r$$
and we are done!
</s>