Metamath Proof Explorer


Theorem gcdval

Description: The value of the gcd operator. ( M gcd N ) is the greatest common divisor of M and N . If M and N are both 0 , the result is defined conventionally as 0 . (Contributed by Paul Chapman, 21-Mar-2011) (Revised by Mario Carneiro, 10-Nov-2013)

Ref Expression
Assertion gcdval MNMgcdN=ifM=0N=00supn|nMnN<

Proof

Step Hyp Ref Expression
1 eqeq1 x=Mx=0M=0
2 1 anbi1d x=Mx=0y=0M=0y=0
3 breq2 x=MnxnM
4 3 anbi1d x=MnxnynMny
5 4 rabbidv x=Mn|nxny=n|nMny
6 5 supeq1d x=Msupn|nxny<=supn|nMny<
7 2 6 ifbieq2d x=Mifx=0y=00supn|nxny<=ifM=0y=00supn|nMny<
8 eqeq1 y=Ny=0N=0
9 8 anbi2d y=NM=0y=0M=0N=0
10 breq2 y=NnynN
11 10 anbi2d y=NnMnynMnN
12 11 rabbidv y=Nn|nMny=n|nMnN
13 12 supeq1d y=Nsupn|nMny<=supn|nMnN<
14 9 13 ifbieq2d y=NifM=0y=00supn|nMny<=ifM=0N=00supn|nMnN<
15 df-gcd gcd=x,yifx=0y=00supn|nxny<
16 c0ex 0V
17 ltso <Or
18 17 supex supn|nMnN<V
19 16 18 ifex ifM=0N=00supn|nMnN<V
20 7 14 15 19 ovmpo MNMgcdN=ifM=0N=00supn|nMnN<