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 = x 0 , y 0 if y = 0 x y y x mod y
eucalg.2 R = seq 0 E 1 st 0 × A
eucalgcvga.3 N = 2 nd A
Assertion eucalgcvga A 0 × 0 K N 2 nd R K = 0

Proof

Step Hyp Ref Expression
1 eucalgval.1 E = x 0 , y 0 if y = 0 x y y x mod y
2 eucalg.2 R = seq 0 E 1 st 0 × A
3 eucalgcvga.3 N = 2 nd A
4 xp2nd A 0 × 0 2 nd A 0
5 3 4 eqeltrid A 0 × 0 N 0
6 eluznn0 N 0 K N K 0
7 5 6 sylan A 0 × 0 K N K 0
8 nn0uz 0 = 0
9 0zd A 0 × 0 0
10 id A 0 × 0 A 0 × 0
11 1 eucalgf E : 0 × 0 0 × 0
12 11 a1i A 0 × 0 E : 0 × 0 0 × 0
13 8 2 9 10 12 algrf A 0 × 0 R : 0 0 × 0
14 13 ffvelrnda A 0 × 0 K 0 R K 0 × 0
15 7 14 syldan A 0 × 0 K N R K 0 × 0
16 15 fvresd A 0 × 0 K N 2 nd 0 × 0 R K = 2 nd R K
17 simpl A 0 × 0 K N A 0 × 0
18 fvres A 0 × 0 2 nd 0 × 0 A = 2 nd A
19 18 3 eqtr4di A 0 × 0 2 nd 0 × 0 A = N
20 19 fveq2d A 0 × 0 2 nd 0 × 0 A = N
21 20 eleq2d A 0 × 0 K 2 nd 0 × 0 A K N
22 21 biimpar A 0 × 0 K N K 2 nd 0 × 0 A
23 f2ndres 2 nd 0 × 0 : 0 × 0 0
24 1 eucalglt z 0 × 0 2 nd E z 0 2 nd E z < 2 nd z
25 11 ffvelrni z 0 × 0 E z 0 × 0
26 25 fvresd z 0 × 0 2 nd 0 × 0 E z = 2 nd E z
27 26 neeq1d z 0 × 0 2 nd 0 × 0 E z 0 2 nd E z 0
28 fvres z 0 × 0 2 nd 0 × 0 z = 2 nd z
29 26 28 breq12d z 0 × 0 2 nd 0 × 0 E z < 2 nd 0 × 0 z 2 nd E z < 2 nd z
30 24 27 29 3imtr4d z 0 × 0 2 nd 0 × 0 E z 0 2 nd 0 × 0 E z < 2 nd 0 × 0 z
31 eqid 2 nd 0 × 0 A = 2 nd 0 × 0 A
32 11 2 23 30 31 algcvga A 0 × 0 K 2 nd 0 × 0 A 2 nd 0 × 0 R K = 0
33 17 22 32 sylc A 0 × 0 K N 2 nd 0 × 0 R K = 0
34 16 33 eqtr3d A 0 × 0 K N 2 nd R K = 0
35 34 ex A 0 × 0 K N 2 nd R K = 0