Metamath Proof Explorer


Theorem eucalgcvga

Description: Once Euclid's Algorithm halts after N steps, the second element of the state remains 0 . (Contributed by Paul Chapman, 22-Jun-2011) (Revised by Mario Carneiro, 29-May-2014)

Ref Expression
Hypotheses eucalgval.1 E=x0,y0ify=0xyyxmody
eucalg.2 R=seq0E1st0×A
eucalgcvga.3 N=2ndA
Assertion eucalgcvga A0×0KN2ndRK=0

Proof

Step Hyp Ref Expression
1 eucalgval.1 E=x0,y0ify=0xyyxmody
2 eucalg.2 R=seq0E1st0×A
3 eucalgcvga.3 N=2ndA
4 xp2nd A0×02ndA0
5 3 4 eqeltrid A0×0N0
6 eluznn0 N0KNK0
7 5 6 sylan A0×0KNK0
8 nn0uz 0=0
9 0zd A0×00
10 id A0×0A0×0
11 1 eucalgf E:0×00×0
12 11 a1i A0×0E:0×00×0
13 8 2 9 10 12 algrf A0×0R:00×0
14 13 ffvelcdmda A0×0K0RK0×0
15 7 14 syldan A0×0KNRK0×0
16 15 fvresd A0×0KN2nd0×0RK=2ndRK
17 simpl A0×0KNA0×0
18 fvres A0×02nd0×0A=2ndA
19 18 3 eqtr4di A0×02nd0×0A=N
20 19 fveq2d A0×02nd0×0A=N
21 20 eleq2d A0×0K2nd0×0AKN
22 21 biimpar A0×0KNK2nd0×0A
23 f2ndres 2nd0×0:0×00
24 1 eucalglt z0×02ndEz02ndEz<2ndz
25 11 ffvelcdmi z0×0Ez0×0
26 25 fvresd z0×02nd0×0Ez=2ndEz
27 26 neeq1d z0×02nd0×0Ez02ndEz0
28 fvres z0×02nd0×0z=2ndz
29 26 28 breq12d z0×02nd0×0Ez<2nd0×0z2ndEz<2ndz
30 24 27 29 3imtr4d z0×02nd0×0Ez02nd0×0Ez<2nd0×0z
31 eqid 2nd0×0A=2nd0×0A
32 11 2 23 30 31 algcvga A0×0K2nd0×0A2nd0×0RK=0
33 17 22 32 sylc A0×0KN2nd0×0RK=0
34 16 33 eqtr3d A0×0KN2ndRK=0
35 34 ex A0×0KN2ndRK=0