Metamath Proof Explorer


Theorem eucalglt

Description: The second member of the state decreases with each iteration of the step function E for Euclid's Algorithm. (Contributed by Paul Chapman, 31-Mar-2011) (Revised by Mario Carneiro, 29-May-2014)

Ref Expression
Hypothesis eucalgval.1 E=x0,y0ify=0xyyxmody
Assertion eucalglt X0×02ndEX02ndEX<2ndX

Proof

Step Hyp Ref Expression
1 eucalgval.1 E=x0,y0ify=0xyyxmody
2 1 eucalgval X0×0EX=if2ndX=0X2ndXmodX
3 2 adantr X0×02ndEX0EX=if2ndX=0X2ndXmodX
4 simpr X0×02ndEX02ndEX0
5 iftrue 2ndX=0if2ndX=0X2ndXmodX=X
6 5 eqeq2d 2ndX=0EX=if2ndX=0X2ndXmodXEX=X
7 fveq2 EX=X2ndEX=2ndX
8 6 7 syl6bi 2ndX=0EX=if2ndX=0X2ndXmodX2ndEX=2ndX
9 eqeq2 2ndX=02ndEX=2ndX2ndEX=0
10 8 9 sylibd 2ndX=0EX=if2ndX=0X2ndXmodX2ndEX=0
11 3 10 syl5com X0×02ndEX02ndX=02ndEX=0
12 11 necon3ad X0×02ndEX02ndEX0¬2ndX=0
13 4 12 mpd X0×02ndEX0¬2ndX=0
14 13 iffalsed X0×02ndEX0if2ndX=0X2ndXmodX=2ndXmodX
15 3 14 eqtrd X0×02ndEX0EX=2ndXmodX
16 15 fveq2d X0×02ndEX02ndEX=2nd2ndXmodX
17 fvex 2ndXV
18 fvex modXV
19 17 18 op2nd 2nd2ndXmodX=modX
20 16 19 eqtrdi X0×02ndEX02ndEX=modX
21 1st2nd2 X0×0X=1stX2ndX
22 21 adantr X0×02ndEX0X=1stX2ndX
23 22 fveq2d X0×02ndEX0modX=mod1stX2ndX
24 df-ov 1stXmod2ndX=mod1stX2ndX
25 23 24 eqtr4di X0×02ndEX0modX=1stXmod2ndX
26 20 25 eqtrd X0×02ndEX02ndEX=1stXmod2ndX
27 xp1st X0×01stX0
28 27 adantr X0×02ndEX01stX0
29 28 nn0red X0×02ndEX01stX
30 xp2nd X0×02ndX0
31 30 adantr X0×02ndEX02ndX0
32 elnn0 2ndX02ndX2ndX=0
33 31 32 sylib X0×02ndEX02ndX2ndX=0
34 33 ord X0×02ndEX0¬2ndX2ndX=0
35 13 34 mt3d X0×02ndEX02ndX
36 35 nnrpd X0×02ndEX02ndX+
37 modlt 1stX2ndX+1stXmod2ndX<2ndX
38 29 36 37 syl2anc X0×02ndEX01stXmod2ndX<2ndX
39 26 38 eqbrtrd X0×02ndEX02ndEX<2ndX
40 39 ex X0×02ndEX02ndEX<2ndX