let m, n be Nat; :: thesis: ( m > 1 & n > 1 & m,n are_relative_prime implies Euler (m * n) = (Euler m) * (Euler n) )
assume A1: ( m > 1 & n > 1 & m,n are_relative_prime ) ; :: thesis: Euler (m * n) = (Euler m) * (Euler n)
then A2: m * n <> 1 by NAT_1:15;
A3: m * n <> 0 by A1, XCMPLX_1:6;
A4: m * n >= 1 by A1, NAT_1:14, XCMPLX_1:6;
set A = { i where i is Element of NAT : ( n,i are_relative_prime & i >= 1 & i <= n ) } ;
set B = { i where i is Element of NAT : ( m,i are_relative_prime & i >= 1 & i <= m ) } ;
set C = { i where i is Element of NAT : ex x, y being Integer st
( i = ((m * y) + (n * x)) mod (m * n) & m * n,i are_relative_prime & y <= n & x <= m & i >= 0 )
}
;
set X = { i where i is Element of NAT : ( m * n,i are_relative_prime & i >= 1 & i <= m * n ) } ;
A5: { i where i is Element of NAT : ( n,i are_relative_prime & i >= 1 & i <= n ) } c= Seg n
proof
let x be set ; :: according to TARSKI:def 3 :: thesis: ( not x in { i where i is Element of NAT : ( n,i are_relative_prime & i >= 1 & i <= n ) } or x in Seg n )
assume x in { i where i is Element of NAT : ( n,i are_relative_prime & i >= 1 & i <= n ) } ; :: thesis: x in Seg n
then consider i being Element of NAT such that
A6: i = x and
n,i are_relative_prime and
A7: ( i >= 1 & i <= n ) ;
thus x in Seg n by A6, A7, FINSEQ_1:3; :: thesis: verum
end;
then reconsider A = { i where i is Element of NAT : ( n,i are_relative_prime & i >= 1 & i <= n ) } as finite set ;
A8: { i where i is Element of NAT : ( m,i are_relative_prime & i >= 1 & i <= m ) } c= Seg m
proof
let x be set ; :: according to TARSKI:def 3 :: thesis: ( not x in { i where i is Element of NAT : ( m,i are_relative_prime & i >= 1 & i <= m ) } or x in Seg m )
assume x in { i where i is Element of NAT : ( m,i are_relative_prime & i >= 1 & i <= m ) } ; :: thesis: x in Seg m
then consider i being Element of NAT such that
A9: i = x and
m,i are_relative_prime and
A10: ( i >= 1 & i <= m ) ;
thus x in Seg m by A9, A10, FINSEQ_1:3; :: thesis: verum
end;
then reconsider B = { i where i is Element of NAT : ( m,i are_relative_prime & i >= 1 & i <= m ) } as finite set ;
A11: { i where i is Element of NAT : ex x, y being Integer st
( i = ((m * y) + (n * x)) mod (m * n) & m * n,i are_relative_prime & y <= n & x <= m & i >= 0 ) } c= (Seg (m * n)) \/ {0 }
proof
let z be set ; :: according to TARSKI:def 3 :: thesis: ( not z in { i where i is Element of NAT : ex x, y being Integer st
( i = ((m * y) + (n * x)) mod (m * n) & m * n,i are_relative_prime & y <= n & x <= m & i >= 0 )
}
or z in (Seg (m * n)) \/ {0 } )

assume z in { i where i is Element of NAT : ex x, y being Integer st
( i = ((m * y) + (n * x)) mod (m * n) & m * n,i are_relative_prime & y <= n & x <= m & i >= 0 )
}
; :: thesis: z in (Seg (m * n)) \/ {0 }
then consider i being Element of NAT such that
A12: i = z and
A13: ex x, y being Integer st
( i = ((m * y) + (n * x)) mod (m * n) & m * n,i are_relative_prime & y <= n & x <= m & i >= 0 ) ;
consider x, y being Integer such that
A14: i = ((m * y) + (n * x)) mod (m * n) and
m * n,i are_relative_prime and
( y <= n & x <= m & i >= 0 ) by A13;
per cases ( i > 0 or i = 0 ) ;
suppose i > 0 ; :: thesis: z in (Seg (m * n)) \/ {0 }
then A15: i >= 1 by NAT_1:14;
((m * y) + (n * x)) mod (m * n) <= m * n
proof
set i1 = (m * y) + (n * x);
set i2 = m * n;
A16: ((m * y) + (n * x)) mod (m * n) = ((m * y) + (n * x)) - ((((m * y) + (n * x)) div (m * n)) * (m * n)) by A3, INT_1:def 8
.= ((m * y) + (n * x)) - ([\(((m * y) + (n * x)) / (m * n))/] * (m * n)) by INT_1:def 7 ;
[\(((m * y) + (n * x)) / (m * n))/] + 1 >= ((m * y) + (n * x)) / (m * n) by INT_1:52;
hence ((m * y) + (n * x)) mod (m * n) <= m * n by A1, A16, Lm1, XCMPLX_1:6; :: thesis: verum
end;
then z in Seg (m * n) by A12, A14, A15, FINSEQ_1:3;
hence z in (Seg (m * n)) \/ {0 } by XBOOLE_0:def 3; :: thesis: verum
end;
end;
end;
then reconsider C = { i where i is Element of NAT : ex x, y being Integer st
( i = ((m * y) + (n * x)) mod (m * n) & m * n,i are_relative_prime & y <= n & x <= m & i >= 0 )
}
as finite set ;
A18: C = { i where i is Element of NAT : ( m * n,i are_relative_prime & i >= 1 & i <= m * n ) }
proof
thus C c= { i where i is Element of NAT : ( m * n,i are_relative_prime & i >= 1 & i <= m * n ) } :: according to XBOOLE_0:def 10 :: thesis: { i where i is Element of NAT : ( m * n,i are_relative_prime & i >= 1 & i <= m * n ) } c= C
proof
let z be set ; :: according to TARSKI:def 3 :: thesis: ( not z in C or z in { i where i is Element of NAT : ( m * n,i are_relative_prime & i >= 1 & i <= m * n ) } )
assume z in C ; :: thesis: z in { i where i is Element of NAT : ( m * n,i are_relative_prime & i >= 1 & i <= m * n ) }
then consider i being Element of NAT such that
A19: i = z and
A20: ex x, y being Integer st
( i = ((m * y) + (n * x)) mod (m * n) & m * n,i are_relative_prime & y <= n & x <= m & i >= 0 ) ;
consider x, y being Integer such that
A21: i = ((m * y) + (n * x)) mod (m * n) and
A22: m * n,i are_relative_prime and
( y <= n & x <= m & i >= 0 ) by A20;
A23: ((m * y) + (n * x)) mod (m * n) <= m * n
proof
set i1 = (m * y) + (n * x);
set i2 = m * n;
A24: ((m * y) + (n * x)) mod (m * n) = ((m * y) + (n * x)) - ((((m * y) + (n * x)) div (m * n)) * (m * n)) by A3, INT_1:def 8
.= ((m * y) + (n * x)) - ([\(((m * y) + (n * x)) / (m * n))/] * (m * n)) by INT_1:def 7 ;
[\(((m * y) + (n * x)) / (m * n))/] + 1 >= ((m * y) + (n * x)) / (m * n) by INT_1:52;
hence ((m * y) + (n * x)) mod (m * n) <= m * n by A1, A24, Lm1, XCMPLX_1:6; :: thesis: verum
end;
per cases ( i > 0 or i = 0 ) ;
suppose i > 0 ; :: thesis: z in { i where i is Element of NAT : ( m * n,i are_relative_prime & i >= 1 & i <= m * n ) }
then i >= 1 by NAT_1:14;
hence z in { i where i is Element of NAT : ( m * n,i are_relative_prime & i >= 1 & i <= m * n ) } by A19, A21, A22, A23; :: thesis: verum
end;
suppose i = 0 ; :: thesis: z in { i where i is Element of NAT : ( m * n,i are_relative_prime & i >= 1 & i <= m * n ) }
then (m * n) gcd 0 = 1 by A22, INT_2:def 4;
hence z in { i where i is Element of NAT : ( m * n,i are_relative_prime & i >= 1 & i <= m * n ) } by A2, NEWTON:65; :: thesis: verum
end;
end;
end;
let z be set ; :: according to TARSKI:def 3 :: thesis: ( not z in { i where i is Element of NAT : ( m * n,i are_relative_prime & i >= 1 & i <= m * n ) } or z in C )
assume z in { i where i is Element of NAT : ( m * n,i are_relative_prime & i >= 1 & i <= m * n ) } ; :: thesis: z in C
then consider i being Element of NAT such that
A25: i = z and
A26: m * n,i are_relative_prime and
A27: ( i >= 1 & i <= m * n ) ;
i <> m * n
proof
assume i = m * n ; :: thesis: contradiction
then (m * n) gcd (m * n) = 1 by A26, INT_2:def 4;
then m * n = 1 by NAT_D:32;
hence contradiction by A1, NAT_1:15; :: thesis: verum
end;
then A28: i < m * n by A27, XXREAL_0:1;
consider y0, x0 being Integer such that
A29: (y0 * m) + (x0 * n) = i by A1, Th11;
consider x1, y1 being Integer such that
A30: x1 = x0 mod m and
A31: y1 = y0 mod n ;
A32: x0 mod m = x0 - ((x0 div m) * m) by A1, INT_1:def 8;
set j = x0 div m;
A33: x1 = x0 - ((x0 div m) * m) by A1, A30, INT_1:def 8
.= x0 - ([\(x0 / m)/] * m) by INT_1:def 7 ;
[\(x0 / m)/] + 1 >= x0 / m by INT_1:52;
then A34: x1 <= m by A1, A33, Lm1;
A35: y0 mod n = y0 - ((y0 div n) * n) by A1, INT_1:def 8;
set k = y0 div n;
A36: y1 = y0 - ((y0 div n) * n) by A1, A31, INT_1:def 8
.= y0 - ([\(y0 / n)/] * n) by INT_1:def 7 ;
[\(y0 / n)/] + 1 >= y0 / n by INT_1:52;
then A37: y1 <= n by A1, A36, Lm1;
A38: (m * y0) + (n * x0) = ((m * y1) + (n * x1)) + ((m * n) * ((y0 div n) + (x0 div m))) by A30, A31, A32, A35;
((m * y0) + (n * x0)) mod (m * n) = ((m * y0) + (n * x0)) - ((((m * y0) + (n * x0)) div (m * n)) * (m * n)) by A3, INT_1:def 8
.= ((m * y0) + (n * x0)) - (0 * (m * n)) by A28, A29, PRE_FF:4
.= (m * y0) + (n * x0) ;
then (m * y0) + (n * x0) = ((m * y1) + (n * x1)) mod (m * n) by A38, Th13;
hence z in C by A25, A26, A29, A34, A37; :: thesis: verum
end;
A39: for a being Nat st a = 1 holds
a in A
proof
let a be Nat; :: thesis: ( a = 1 implies a in A )
assume A40: a = 1 ; :: thesis: a in A
then n gcd a = 1 by NEWTON:64;
then n,a are_relative_prime by INT_2:def 4;
hence a in A by A1, A40; :: thesis: verum
end;
A41: for b being Nat st b = 1 holds
b in B
proof
let b be Nat; :: thesis: ( b = 1 implies b in B )
assume A42: b = 1 ; :: thesis: b in B
then m gcd b = 1 by NEWTON:64;
then m,b are_relative_prime by INT_2:def 4;
hence b in B by A1, A42; :: thesis: verum
end;
A43: for y, x being Integer st y = 1 & x = 1 holds
((m * y) + (n * x)) mod (m * n) in C
proof
let y, x be Integer; :: thesis: ( y = 1 & x = 1 implies ((m * y) + (n * x)) mod (m * n) in C )
assume A44: ( y = 1 & x = 1 ) ; :: thesis: ((m * y) + (n * x)) mod (m * n) in C
then reconsider y' = y, x' = x as Element of NAT ;
((m * y') + (n * x')) mod (m * n) = ((m * y) + (n * x)) mod (m * n) ;
then consider t being Element of NAT such that
A45: t = ((m * y) + (n * x)) mod (m * n) ;
A46: m gcd n = 1 by A1, INT_2:def 4;
then (m + n) gcd n = 1 by Th8;
then A47: n,m + n are_relative_prime by INT_2:def 4;
(m + n) gcd m = 1 by A46, Th8;
then A48: m,m + n are_relative_prime by INT_2:def 4;
m * n,m + n are_relative_prime by A1, A47, A48, Th15;
then A49: (m * n) gcd (m + n) = 1 by INT_2:def 4;
consider d being Nat such that
A50: m + n = ((m * n) * d) + ((m + n) mod (m * n)) and
(m + n) mod (m * n) < m * n by A3, NAT_D:def 2;
((m + n) mod (m * n)) gcd (m * n) = 1 by A49, A50, Th9;
then m * n,t are_relative_prime by A44, A45, INT_2:def 4;
hence ((m * y) + (n * x)) mod (m * n) in C by A1, A44, A45; :: thesis: verum
end;
{0 } c= NAT by ZFMISC_1:37;
then (Seg (m * n)) \/ {0 } c= NAT by XBOOLE_1:8;
then reconsider A = A, B = B, C = C as non empty finite Subset of NAT by A5, A8, A11, A39, A41, A43, XBOOLE_1:1;
deffunc H1( Element of A, Element of B) -> Element of NAT = ((m * $1) + (n * $2)) mod (m * n);
A51: for y being Element of A
for x being Element of B holds H1(y,x) in C
proof
let y be Element of A; :: thesis: for x being Element of B holds H1(y,x) in C
let x be Element of B; :: thesis: H1(y,x) in C
y in A ;
then consider i being Element of NAT such that
A52: i = y and
A53: n,i are_relative_prime and
A54: i >= 1 and
A55: i <= n ;
x in B ;
then consider j being Element of NAT such that
A56: j = x and
A57: m,j are_relative_prime and
A58: j >= 1 and
A59: j <= m ;
reconsider ii = i, jj = j as Integer ;
((m * ii) + (n * jj)) mod (m * n) = ((m * i) + (n * j)) mod (m * n) ;
then consider q being Element of NAT such that
A60: q = ((m * ii) + (n * jj)) mod (m * n) ;
i * m,n are_relative_prime by A1, A53, A54, Th15;
then A61: (i * m) gcd n = 1 by INT_2:def 4;
j * n,m are_relative_prime by A1, A57, A58, Th15;
then A62: (j * n) gcd m = 1 by INT_2:def 4;
((m * i) + (n * j)) gcd n = 1 by A61, Th9;
then A63: n,(m * i) + (n * j) are_relative_prime by INT_2:def 4;
((m * i) + (n * j)) gcd m = 1 by A62, Th9;
then A64: m,(m * i) + (n * j) are_relative_prime by INT_2:def 4;
( i * m <> 0 * m & j * n <> 0 * n ) by A1, A54, A58, XCMPLX_1:5;
then (m * i) + (n * j) <> 0 ;
then n * m,(m * i) + (n * j) are_relative_prime by A1, A63, A64, Th15;
then A65: (n * m) gcd ((m * i) + (n * j)) = 1 by INT_2:def 4;
consider t being Nat such that
A66: (m * i) + (n * j) = ((n * m) * t) + (((m * i) + (n * j)) mod (n * m)) and
((m * i) + (n * j)) mod (n * m) < n * m by A3, NAT_D:def 2;
set l = n * m;
(((m * i) + (n * j)) mod (n * m)) gcd (n * m) = 1 by A65, A66, Th9;
then n * m,q are_relative_prime by A60, INT_2:def 4;
hence H1(y,x) in C by A52, A55, A56, A59, A60; :: thesis: verum
end;
consider f being Function of [:A,B:],C such that
A67: for y being Element of A
for x being Element of B holds f . y,x = H1(y,x) from FUNCT_7:sch 1(A51);
A68: f is one-to-one
proof
let x, y be set ; :: according to FUNCT_1:def 8 :: thesis: ( not x in dom f or not y in dom f or not f . x = f . y or x = y )
A69: dom f = [:A,B:] by FUNCT_2:def 1;
assume x in dom f ; :: thesis: ( not y in dom f or not f . x = f . y or x = y )
then consider xx1 being Element of A, xx2 being Element of B such that
A70: x = [xx1,xx2] by A69, DOMAIN_1:9;
xx1 in A ;
then consider x1 being Element of NAT such that
A71: xx1 = x1 and
n,x1 are_relative_prime and
A72: x1 >= 1 and
A73: x1 <= n ;
xx2 in B ;
then consider x2 being Element of NAT such that
A74: xx2 = x2 and
m,x2 are_relative_prime and
A75: x2 >= 1 and
A76: x2 <= m ;
assume y in dom f ; :: thesis: ( not f . x = f . y or x = y )
then consider yy1 being Element of A, yy2 being Element of B such that
A77: y = [yy1,yy2] by A69, DOMAIN_1:9;
yy1 in A ;
then consider y1 being Element of NAT such that
A78: yy1 = y1 and
n,y1 are_relative_prime and
A79: y1 >= 1 and
A80: y1 <= n ;
yy2 in B ;
then consider y2 being Element of NAT such that
A81: yy2 = y2 and
m,y2 are_relative_prime and
A82: y2 >= 1 and
A83: y2 <= m ;
assume A84: f . x = f . y ; :: thesis: x = y
A85: ((x1 * m) + (x2 * n)) mod (m * n) = f . xx1,xx2 by A67, A71, A74
.= f . yy1,yy2 by A70, A77, A84
.= ((y1 * m) + (y2 * n)) mod (m * n) by A67, A78, A81 ;
reconsider y1 = y1, y2 = y2, x1 = x1, x2 = x2 as Element of NAT ;
set k = ((x1 * m) + (x2 * n)) mod (m * n);
A86: (y1 * m) + (y2 * n) = (((x1 * m) + (x2 * n)) mod (m * n)) + ((((y1 * m) + (y2 * n)) div (m * n)) * (m * n)) by A4, A85, NAT_D:2;
A87: ((x1 * m) + (x2 * n)) - ((y1 * m) + (y2 * n)) = (m * (x1 - y1)) + (n * (x2 - y2)) ;
A88: ((((x1 * m) + (x2 * n)) mod (m * n)) + ((((x1 * m) + (x2 * n)) div (m * n)) * (m * n))) - ((((x1 * m) + (x2 * n)) mod (m * n)) + ((((y1 * m) + (y2 * n)) div (m * n)) * (m * n))) = (m * n) * ((((x1 * m) + (x2 * n)) div (m * n)) - (((y1 * m) + (y2 * n)) div (m * n))) ;
set w = (((x1 * m) + (x2 * n)) div (m * n)) - (((y1 * m) + (y2 * n)) div (m * n));
consider p being Integer such that
A89: p = m ;
A90: (m * (x1 - y1)) + (n * (x2 - y2)) = (m * n) * ((((x1 * m) + (x2 * n)) div (m * n)) - (((y1 * m) + (y2 * n)) div (m * n))) by A4, A86, A87, A88, NAT_D:2;
then n * (x2 - y2) = m * ((n * ((((x1 * m) + (x2 * n)) div (m * n)) - (((y1 * m) + (y2 * n)) div (m * n)))) - (x1 - y1)) ;
then A91: p divides n * (x2 - y2) by A89, INT_1:def 9;
then A92: m divides x2 - y2 by A1, A89, INT_2:40;
A93: x2 - y2 = 0
proof
per cases ( 0 <= x2 - y2 or x2 - y2 <= 0 ) ;
suppose A94: 0 <= x2 - y2 ; :: thesis: x2 - y2 = 0
consider k being Integer such that
A95: k = x2 - y2 ;
reconsider k = k as Element of NAT by A94, A95, INT_1:16;
k = 0
proof
assume k <> 0 ; :: thesis: contradiction
then A96: 0 < k ;
- y2 <= - 1 by A82, XREAL_1:26;
then A97: x2 + (- y2) <= m + (- 1) by A76, XREAL_1:9;
set b = m + (- 1);
m + (- 1) is Element of NAT by A94, A97, INT_1:16;
then k < (m + (- 1)) + 1 by A95, A97, NAT_1:13;
hence contradiction by A1, A89, A91, A95, A96, INT_2:40, NAT_D:7; :: thesis: verum
end;
hence x2 - y2 = 0 by A95; :: thesis: verum
end;
suppose A98: x2 - y2 <= 0 ; :: thesis: x2 - y2 = 0
consider k being Integer such that
A99: k = - (x2 - y2) ;
A100: m divides k by A92, A99, INT_2:14;
A101: - 0 <= k by A98, A99;
then reconsider k = k as Element of NAT by INT_1:16;
k = 0
proof
assume k <> 0 ; :: thesis: contradiction
then A102: 0 < k ;
- x2 <= - 1 by A75, XREAL_1:26;
then A103: (- x2) + y2 <= m + (- 1) by A83, XREAL_1:9;
set b = m + (- 1);
m + (- 1) is Element of NAT by A99, A101, A103, INT_1:16;
then k < (m + (- 1)) + 1 by A99, A103, NAT_1:13;
hence contradiction by A100, A102, NAT_D:7; :: thesis: verum
end;
hence x2 - y2 = 0 by A99; :: thesis: verum
end;
end;
end;
consider p being Integer such that
A104: p = n ;
m * (x1 - y1) = n * ((m * ((((x1 * m) + (x2 * n)) div (m * n)) - (((y1 * m) + (y2 * n)) div (m * n)))) - (x2 - y2)) by A90;
then A105: p divides m * (x1 - y1) by A104, INT_1:def 9;
then A106: n divides x1 - y1 by A1, A104, INT_2:40;
x1 - y1 = 0
proof
per cases ( 0 <= x1 - y1 or x1 - y1 <= 0 ) ;
suppose A107: 0 <= x1 - y1 ; :: thesis: x1 - y1 = 0
consider k being Integer such that
A108: k = x1 - y1 ;
reconsider k = k as Element of NAT by A107, A108, INT_1:16;
k = 0
proof
assume k <> 0 ; :: thesis: contradiction
then A109: 0 < k ;
- y1 <= - 1 by A79, XREAL_1:26;
then A110: x1 + (- y1) <= n + (- 1) by A73, XREAL_1:9;
set b = n + (- 1);
n + (- 1) is Element of NAT by A107, A110, INT_1:16;
then k < (n + (- 1)) + 1 by A108, A110, NAT_1:13;
hence contradiction by A1, A104, A105, A108, A109, INT_2:40, NAT_D:7; :: thesis: verum
end;
hence x1 - y1 = 0 by A108; :: thesis: verum
end;
suppose A111: x1 - y1 <= 0 ; :: thesis: x1 - y1 = 0
consider k being Integer such that
A112: k = - (x1 - y1) ;
A113: n divides k by A106, A112, INT_2:14;
A114: - 0 <= k by A111, A112;
then reconsider k = k as Element of NAT by INT_1:16;
k = 0
proof
assume k <> 0 ; :: thesis: contradiction
then A115: 0 < k ;
- x1 <= - 1 by A72, XREAL_1:26;
then A116: (- x1) + y1 <= n + (- 1) by A80, XREAL_1:9;
set b = n + (- 1);
n + (- 1) is Element of NAT by A112, A114, A116, INT_1:16;
then k < (n + (- 1)) + 1 by A112, A116, NAT_1:13;
hence contradiction by A113, A115, NAT_D:7; :: thesis: verum
end;
hence x1 - y1 = 0 by A112; :: thesis: verum
end;
end;
end;
hence x = y by A70, A71, A74, A77, A78, A81, A93; :: thesis: verum
end;
f is onto
proof
thus rng f c= C by RELAT_1:def 19; :: according to FUNCT_2:def 3,XBOOLE_0:def 10 :: thesis: C c= rng f
let z be set ; :: according to TARSKI:def 3 :: thesis: ( not z in C or z in rng f )
assume z in C ; :: thesis: z in rng f
then consider i being Element of NAT such that
A117: i = z and
A118: ex x0, y0 being Integer st
( i = ((m * y0) + (n * x0)) mod (m * n) & m * n,i are_relative_prime & y0 <= n & x0 <= m & i >= 0 ) ;
consider x0, y0 being Integer such that
A119: i = ((m * y0) + (n * x0)) mod (m * n) and
A120: m * n,i are_relative_prime and
( y0 <= n & x0 <= m & i >= 0 ) by A118;
consider x, y being Integer such that
A121: x = x0 mod m and
A122: y = y0 mod n ;
A123: ( x <= m & y <= n ) by A1, A121, A122, NEWTON:79;
A126: ((m * y) + (n * x)) mod (m * n) = ((m * y0) + (n * x0)) mod (m * n)
proof
A127: x0 mod m = x0 - ((x0 div m) * m) by A1, INT_1:def 8;
set j = x0 div m;
A128: y0 mod n = y0 - ((y0 div n) * n) by A1, INT_1:def 8;
set k = y0 div n;
(m * y0) + (n * x0) = ((m * y) + (n * x)) + ((m * n) * ((y0 div n) + (x0 div m))) by A121, A122, A127, A128;
hence ((m * y) + (n * x)) mod (m * n) = ((m * y0) + (n * x0)) mod (m * n) by Th13; :: thesis: verum
end;
A129: m,x0 are_relative_prime
proof
set p = m gcd x0;
m gcd x0 divides m by INT_2:31;
then consider i1 being Integer such that
A130: m = (m gcd x0) * i1 by INT_1:def 9;
( m gcd x0 <> 0 & i1 <> 0 ) by A1, A130;
then A131: m gcd x0 > 0 ;
m gcd x0 divides x0 by INT_2:32;
then consider i2 being Integer such that
A132: x0 = (m gcd x0) * i2 by INT_1:def 9;
A133: ((m * y0) + (n * x0)) mod (m * n) = ((((m gcd x0) * i1) * y0) + (n * ((m gcd x0) * i2))) - ((((((m gcd x0) * i1) * y0) + (n * ((m gcd x0) * i2))) div (((m gcd x0) * i1) * n)) * (((m gcd x0) * i1) * n)) by A3, A130, A132, INT_1:def 8;
set k = ((((m gcd x0) * i1) * y0) + (n * ((m gcd x0) * i2))) div (((m gcd x0) * i1) * n);
A134: ((((m gcd x0) * i1) * y0) + (n * ((m gcd x0) * i2))) - ((((((m gcd x0) * i1) * y0) + (n * ((m gcd x0) * i2))) div (((m gcd x0) * i1) * n)) * (((m gcd x0) * i1) * n)) = (m gcd x0) * (((i1 * y0) + (n * i2)) - ((i1 * (((((m gcd x0) * i1) * y0) + (n * ((m gcd x0) * i2))) div (((m gcd x0) * i1) * n))) * n)) ;
set j = ((i1 * y0) + (n * i2)) - ((i1 * (((((m gcd x0) * i1) * y0) + (n * ((m gcd x0) * i2))) div (((m gcd x0) * i1) * n))) * n);
not ((i1 * y0) + (n * i2)) - ((i1 * (((((m gcd x0) * i1) * y0) + (n * ((m gcd x0) * i2))) div (((m gcd x0) * i1) * n))) * n) < 0
proof
assume ((i1 * y0) + (n * i2)) - ((i1 * (((((m gcd x0) * i1) * y0) + (n * ((m gcd x0) * i2))) div (((m gcd x0) * i1) * n))) * n) < 0 ; :: thesis: contradiction
then (m gcd x0) * (((i1 * y0) + (n * i2)) - ((i1 * (((((m gcd x0) * i1) * y0) + (n * ((m gcd x0) * i2))) div (((m gcd x0) * i1) * n))) * n)) < 0 * (((i1 * y0) + (n * i2)) - ((i1 * (((((m gcd x0) * i1) * y0) + (n * ((m gcd x0) * i2))) div (((m gcd x0) * i1) * n))) * n)) by A131, XREAL_1:71;
hence contradiction by A3, A119, A130, A132, A134, INT_1:def 8; :: thesis: verum
end;
then reconsider p = m gcd x0, j = ((i1 * y0) + (n * i2)) - ((i1 * (((((m gcd x0) * i1) * y0) + (n * ((m gcd x0) * i2))) div (((m gcd x0) * i1) * n))) * n) as Element of NAT by INT_1:16;
A135: m * n = p * (i1 * n) by A130;
set jj = i1 * n;
not i1 * n < 0
proof
assume i1 * n < 0 ; :: thesis: contradiction
then p * (i1 * n) < 0 * (i1 * n) by A131, XREAL_1:71;
hence contradiction by A3, A130; :: thesis: verum
end;
then reconsider jj = i1 * n as Element of NAT by INT_1:16;
now
per cases ( ( p <> 0 & jj <> 0 & j <> 0 ) or ( p <> 0 & jj <> 0 & j = 0 ) ) by A1, A135, XCMPLX_1:6;
suppose A136: ( p <> 0 & jj <> 0 & j <> 0 ) ; :: thesis: p = 1
(p * jj) gcd (p * j) = 1 by A119, A120, A130, A133, INT_2:def 4;
then p * (jj gcd j) = 1 by A136, Th16;
hence p = 1 by NAT_1:15; :: thesis: verum
end;
end;
end;
hence m,x0 are_relative_prime by INT_2:def 4; :: thesis: verum
end;
A138: n,y0 are_relative_prime
proof
set p = n gcd y0;
n gcd y0 divides n by INT_2:31;
then consider i1 being Integer such that
A139: n = (n gcd y0) * i1 by INT_1:def 9;
( n gcd y0 <> 0 & i1 <> 0 ) by A1, A139;
then A140: n gcd y0 > 0 ;
n gcd y0 divides y0 by INT_2:32;
then consider i2 being Integer such that
A141: y0 = (n gcd y0) * i2 by INT_1:def 9;
A142: ((m * y0) + (n * x0)) mod (m * n) = ((m * ((n gcd y0) * i2)) + (((n gcd y0) * i1) * x0)) - ((((m * ((n gcd y0) * i2)) + (((n gcd y0) * i1) * x0)) div (m * ((n gcd y0) * i1))) * (m * ((n gcd y0) * i1))) by A3, A139, A141, INT_1:def 8;
set k = ((m * ((n gcd y0) * i2)) + (((n gcd y0) * i1) * x0)) div (m * ((n gcd y0) * i1));
A143: ((m * ((n gcd y0) * i2)) + (((n gcd y0) * i1) * x0)) - ((((m * ((n gcd y0) * i2)) + (((n gcd y0) * i1) * x0)) div (m * ((n gcd y0) * i1))) * (m * ((n gcd y0) * i1))) = (n gcd y0) * (((m * i2) + (i1 * x0)) - ((i1 * (((m * ((n gcd y0) * i2)) + (((n gcd y0) * i1) * x0)) div (m * ((n gcd y0) * i1)))) * m)) ;
set j = ((m * i2) + (i1 * x0)) - ((i1 * (((m * ((n gcd y0) * i2)) + (((n gcd y0) * i1) * x0)) div (m * ((n gcd y0) * i1)))) * m);
((m * i2) + (i1 * x0)) - ((i1 * (((m * ((n gcd y0) * i2)) + (((n gcd y0) * i1) * x0)) div (m * ((n gcd y0) * i1)))) * m) >= 0
proof
assume ((m * i2) + (i1 * x0)) - ((i1 * (((m * ((n gcd y0) * i2)) + (((n gcd y0) * i1) * x0)) div (m * ((n gcd y0) * i1)))) * m) < 0 ; :: thesis: contradiction
then (n gcd y0) * (((m * i2) + (i1 * x0)) - ((i1 * (((m * ((n gcd y0) * i2)) + (((n gcd y0) * i1) * x0)) div (m * ((n gcd y0) * i1)))) * m)) < 0 * (((m * i2) + (i1 * x0)) - ((i1 * (((m * ((n gcd y0) * i2)) + (((n gcd y0) * i1) * x0)) div (m * ((n gcd y0) * i1)))) * m)) by A140, XREAL_1:71;
hence contradiction by A3, A119, A139, A141, A143, INT_1:def 8; :: thesis: verum
end;
then reconsider p = n gcd y0, j = ((m * i2) + (i1 * x0)) - ((i1 * (((m * ((n gcd y0) * i2)) + (((n gcd y0) * i1) * x0)) div (m * ((n gcd y0) * i1)))) * m) as Element of NAT by INT_1:16;
A144: m * n = p * (i1 * m) by A139;
set jj = i1 * m;
not i1 * m < 0
proof
assume i1 * m < 0 ; :: thesis: contradiction
then p * (i1 * m) < 0 * (i1 * m) by A140, XREAL_1:71;
hence contradiction by A3, A139; :: thesis: verum
end;
then reconsider jj = i1 * m as Element of NAT by INT_1:16;
now
per cases ( ( p <> 0 & jj <> 0 & j <> 0 ) or ( p <> 0 & jj <> 0 & j = 0 ) ) by A1, A144, XCMPLX_1:6;
suppose A145: ( p <> 0 & jj <> 0 & j <> 0 ) ; :: thesis: p = 1
(p * jj) gcd (p * j) = 1 by A119, A120, A139, A142, INT_2:def 4;
then p * (jj gcd j) = 1 by A145, Th16;
hence p = 1 by NAT_1:15; :: thesis: verum
end;
end;
end;
hence n,y0 are_relative_prime by INT_2:def 4; :: thesis: verum
end;
reconsider x = x, y = y as Element of NAT by A121, A122, INT_1:16, NEWTON:78;
A147: x <> 0
proof
assume x = 0 ; :: thesis: contradiction
then A148: x0 - ((x0 div m) * m) = 0 by A1, A121, INT_1:def 8;
set j = x0 div m;
A149: ((m * y0) + (n * x0)) mod (m * n) = (m * (y0 + (n * (x0 div m)))) - (((m * (y0 + (n * (x0 div m)))) div (m * n)) * (m * n)) by A3, A148, INT_1:def 8
.= m * ((y0 + (n * (x0 div m))) - (n * ((m * (y0 + (n * (x0 div m)))) div (m * n)))) ;
set jj = (y0 + (n * (x0 div m))) - (n * ((m * (y0 + (n * (x0 div m)))) div (m * n)));
reconsider g = m * ((y0 + (n * (x0 div m))) - (n * ((m * (y0 + (n * (x0 div m)))) div (m * n)))) as Element of NAT by A119, A149;
A150: ( g > 0 or g = 0 ) ;
A151: not (y0 + (n * (x0 div m))) - (n * ((m * (y0 + (n * (x0 div m)))) div (m * n))) < 0
proof
assume (y0 + (n * (x0 div m))) - (n * ((m * (y0 + (n * (x0 div m)))) div (m * n))) < 0 ; :: thesis: contradiction
then m * ((y0 + (n * (x0 div m))) - (n * ((m * (y0 + (n * (x0 div m)))) div (m * n)))) < 0 * ((y0 + (n * (x0 div m))) - (n * ((m * (y0 + (n * (x0 div m)))) div (m * n)))) by A1, XREAL_1:71;
hence contradiction by A150; :: thesis: verum
end;
A152: (m * n) gcd (m * ((y0 + (n * (x0 div m))) - (n * ((m * (y0 + (n * (x0 div m)))) div (m * n))))) = 1 by A119, A120, A149, INT_2:def 4;
reconsider jj = (y0 + (n * (x0 div m))) - (n * ((m * (y0 + (n * (x0 div m)))) div (m * n))) as Element of NAT by A151, INT_1:16;
jj = 0
proof
assume not jj = 0 ; :: thesis: contradiction
then m * (n gcd jj) = 1 by A1, A152, Th16;
hence contradiction by A1, NAT_1:15; :: thesis: verum
end;
then (m * n) gcd 0 = 1 by A119, A120, A149, INT_2:def 4;
hence contradiction by A2, NEWTON:65; :: thesis: verum
end;
then A153: x >= 0 + 1 by INT_1:20;
A154: y <> 0
proof
assume y = 0 ; :: thesis: contradiction
then A155: y0 - ((y0 div n) * n) = 0 by A1, A122, INT_1:def 8;
set j = y0 div n;
A156: ((m * y0) + (n * x0)) mod (m * n) = (n * ((m * (y0 div n)) + x0)) - (((n * ((m * (y0 div n)) + x0)) div (m * n)) * (m * n)) by A3, A155, INT_1:def 8
.= n * (((m * (y0 div n)) + x0) - (m * ((n * ((m * (y0 div n)) + x0)) div (m * n)))) ;
set jj = ((m * (y0 div n)) + x0) - (m * ((n * ((m * (y0 div n)) + x0)) div (m * n)));
reconsider g = n * (((m * (y0 div n)) + x0) - (m * ((n * ((m * (y0 div n)) + x0)) div (m * n)))) as Element of NAT by A119, A156;
A157: ( g > 0 or g = 0 ) ;
A158: not ((m * (y0 div n)) + x0) - (m * ((n * ((m * (y0 div n)) + x0)) div (m * n))) < 0
proof
assume ((m * (y0 div n)) + x0) - (m * ((n * ((m * (y0 div n)) + x0)) div (m * n))) < 0 ; :: thesis: contradiction
then n * (((m * (y0 div n)) + x0) - (m * ((n * ((m * (y0 div n)) + x0)) div (m * n)))) < 0 * (((m * (y0 div n)) + x0) - (m * ((n * ((m * (y0 div n)) + x0)) div (m * n)))) by A1, XREAL_1:71;
hence contradiction by A157; :: thesis: verum
end;
A159: (m * n) gcd (n * (((m * (y0 div n)) + x0) - (m * ((n * ((m * (y0 div n)) + x0)) div (m * n))))) = 1 by A119, A120, A156, INT_2:def 4;
reconsider jj = ((m * (y0 div n)) + x0) - (m * ((n * ((m * (y0 div n)) + x0)) div (m * n))) as Element of NAT by A158, INT_1:16;
jj = 0
proof
assume not jj = 0 ; :: thesis: contradiction
then n * (m gcd jj) = 1 by A1, A159, Th16;
hence contradiction by A1, NAT_1:15; :: thesis: verum
end;
then (m * n) gcd 0 = 1 by A119, A120, A156, INT_2:def 4;
hence contradiction by A2, NEWTON:65; :: thesis: verum
end;
then A160: y >= 0 + 1 by INT_1:20;
A161: m,x are_relative_prime
proof
x = x0 - ((x0 div m) * m) by A1, A121, INT_1:def 8;
then x0 gcd m = (x + ((x0 div m) * m)) gcd m ;
then x0 gcd m = x gcd m by A1, A147, Th17;
then m gcd x = 1 by A129, INT_2:def 4;
hence m,x are_relative_prime by INT_2:def 4; :: thesis: verum
end;
A162: n,y are_relative_prime
proof
y = y0 - ((y0 div n) * n) by A1, A122, INT_1:def 8;
then y0 gcd n = (y + ((y0 div n) * n)) gcd n ;
then A163: y0 gcd n = y gcd n by A1, A154, Th17;
y0 gcd n = 1 by A138, INT_2:def 4;
hence n,y are_relative_prime by A163, INT_2:def 4; :: thesis: verum
end;
x in B by A123, A153, A161;
then reconsider x = x as Element of B ;
y in A by A123, A160, A162;
then reconsider y = y as Element of A ;
A164: dom f = [:A,B:] by FUNCT_2:def 1;
consider w being set such that
A165: w = [y,x] ;
A166: w in dom f by A164, A165, ZFMISC_1:106;
i = f . y,x by A67, A119, A126;
hence z in rng f by A117, A165, A166, FUNCT_1:def 5; :: thesis: verum
end;
then card [:A,B:] = card C by A68, Th12;
hence Euler (m * n) = (Euler m) * (Euler n) by A18, CARD_2:65; :: thesis: verum