I know that the general strategy to do the correction of an algorithm is as follow :
- if the algorithm is recursive then prove the correctness using induction
- if the algorithm is iterative (using a for loop for example) then find an invariant
Finding an invariant is sometimes hard while induction is easy. So since every iterative algorithm can be transformed into a recursive one, why do we bother finding clever invariant while we could do :
find the recursive equivalent algorithm -> use induction
Maybe the part : "transform the iterative program into a recursive one" is hard, but for simple programs it's definitely worth it. I mean sometimes it is (at least for me) very hard to find invariant, but when doing induction everything is "easy".
So I guess I am missunderstanding something ?
Thank you !