Definition egcdGI (x y : GI) :=
if ('N y <= 'N x)%N then
egcdGI_rec ('N x) x y else
let e := egcdGI_rec ('N y) y x in (e.2, e.1).

Lemma egcdGI_recP :
forall n x y,  y != 0 -> ('N y <= n)%N -> ('N y <= 'N x)%N ->
forall (e := egcdGI_rec n x y), gcdGI_rec n x y = e.1 * x + e.2 * y.