let n be Nat; :: thesis: ( 3 |^ (((Fermat n) -' 1) div 2), - 1 are_congruent_mod Fermat n implies Fermat n is prime )
per cases ( n = 0 or n > 0 ) ;
suppose n = 0 ; :: thesis: ( 3 |^ (((Fermat n) -' 1) div 2), - 1 are_congruent_mod Fermat n implies Fermat n is prime )
hence ( 3 |^ (((Fermat n) -' 1) div 2), - 1 are_congruent_mod Fermat n implies Fermat n is prime ) by Th41, Th50; :: thesis: verum
end;
suppose A1: n > 0 ; :: thesis: ( 3 |^ (((Fermat n) -' 1) div 2), - 1 are_congruent_mod Fermat n implies Fermat n is prime )
Fermat n > 2 by Th55;
then consider p being Element of NAT such that
A2: p is prime and
A3: p divides Fermat n by INT_2:31;
set d = order (3,p);
consider i being Nat such that
A4: Fermat n = p * i by A3, NAT_D:def 3;
A5: p > 2
proof
assume p <= 2 ; :: thesis: contradiction
then ( p = 2 or p < 1 + 1 ) by XXREAL_0:1;
then A6: ( p = 2 or p <= 1 ) by NAT_1:13;
A7: p <> 0 by A2, INT_2:def 4;
Fermat n is odd by Lm16;
then (Fermat n) mod p = 1 by A2, A6, INT_2:def 4, NAT_2:22;
hence contradiction by A3, A7, Th6; :: thesis: verum
end;
A8: (Fermat n) - 1 >= 0 ;
assume A9: 3 |^ (((Fermat n) -' 1) div 2), - 1 are_congruent_mod Fermat n ; :: thesis: Fermat n is prime
then A10: (3 |^ (((Fermat n) -' 1) div 2)) ^2 ,(- 1) ^2 are_congruent_mod Fermat n by INT_1:18;
((Fermat n) -' 1) mod 2 = 0 by Lm13;
then A11: 3 |^ ((Fermat n) -' 1),(- 1) ^2 are_congruent_mod Fermat n by A10, Th27;
set 2N = 2 |^ (2 |^ n);
assume A12: not Fermat n is prime ; :: thesis: contradiction
reconsider i = i as Element of NAT by ORDINAL1:def 12;
A13: 1 < p by A2, INT_2:def 4;
A14: p <> 3 then order (3,p) divides p -' 1 by A2, Th41, Th49, INT_2:30;
then consider x being Nat such that
A16: p -' 1 = (order (3,p)) * x by NAT_D:def 3;
A17: 3 |^ (((Fermat n) -' 1) div 2), - 1 are_congruent_mod p by A9, A4, INT_1:20;
A18: not order (3,p) divides ((Fermat n) -' 1) div 2
proof
assume order (3,p) divides ((Fermat n) -' 1) div 2 ; :: thesis: contradiction
then (3 |^ (((Fermat n) -' 1) div 2)) mod p = 1 by A2, A14, A13, Th41, Th48, INT_2:30;
then 3 |^ (((Fermat n) -' 1) div 2),1 are_congruent_mod p by A13, Th39;
then 1, - 1 are_congruent_mod p by A17, Th40;
then p divides 1 - (- 1) ;
hence contradiction by A5, NAT_D:7; :: thesis: verum
end;
then A19: not order (3,p) divides (2 |^ (2 |^ n)) div 2 by A8, XREAL_0:def 2;
A20: 3,p are_coprime by A2, A14, Th41, INT_2:30;
then A21: order (3,p) <> 0 by A13, Def2;
A22: order (3,p) > 1
proof
assume A23: order (3,p) <= 1 ; :: thesis: contradiction
now :: thesis: contradiction
per cases ( order (3,p) < 1 or order (3,p) = 1 ) by A23, XXREAL_0:1;
end;
end;
hence contradiction ; :: thesis: verum
end;
3 |^ ((Fermat n) -' 1) > 1 by Lm14, Th25;
then (3 |^ ((Fermat n) -' 1)) mod p = 1 by A4, A13, A11, Lm11, INT_1:20;
then order (3,p) divides (Fermat n) -' 1 by A20, A13, Th47;
then order (3,p) divides 2 |^ (2 |^ n) by A8, XREAL_0:def 2;
then order (3,p) = 2 |^ (2 |^ n) by A19, A22, Th38, INT_2:28
.= (Fermat n) -' 1 by A8, XREAL_0:def 2 ;
then A24: order (3,p) = 2 |^ (2 |^ n) by A8, XREAL_0:def 2;
A25: (p * i) mod (2 |^ (2 |^ n)) = 1 by A4, Lm15;
p - 1 > 1 - 1 by A13, XREAL_1:9;
then A26: p - 1 = x * (order (3,p)) by A16, XREAL_0:def 2;
then A27: p = (x * (2 |^ (2 |^ n))) + 1 by A24;
then p mod (2 |^ (2 |^ n)) = 1 mod (2 |^ (2 |^ n)) by NAT_D:21
.= 1 by Lm2, NAT_D:24 ;
then (1 * i) mod (2 |^ (2 |^ n)) = 1 by A25, EULER_2:8;
then consider y being Nat such that
A28: i = ((2 |^ (2 |^ n)) * y) + 1 and
1 < 2 |^ (2 |^ n) by NAT_D:def 2;
A29: 2 |^ (2 |^ n) <> 0 by Lm2;
A30: x >= 1
proof
assume x < 1 ; :: thesis: contradiction
then p = (0 * (2 |^ (2 |^ n))) + 1 by A27, NAT_1:14;
hence contradiction by A2, INT_2:def 4; :: thesis: verum
end;
reconsider y = y as Element of NAT by ORDINAL1:def 12;
Fermat n = ((x * (2 |^ (2 |^ n))) + 1) * ((y * (2 |^ (2 |^ n))) + 1) by A4, A24, A26, A28
.= ((2 |^ (2 |^ n)) * ((((x * y) * (2 |^ (2 |^ n))) + x) + y)) + 1 ;
then A31: 1 = ((2 |^ (2 |^ n)) * ((((x * y) * (2 |^ (2 |^ n))) + x) + y)) div (2 |^ (2 |^ n)) by A29, Th44
.= (((x * y) * (2 |^ (2 |^ n))) + x) + y by A29, NAT_D:18 ;
2 |^ (2 |^ n) > 1 by Lm2;
then p = (1 * (2 |^ (2 |^ n))) + 1 by A27, A30, A31, Lm1
.= Fermat n ;
hence contradiction by A12, A2; :: thesis: verum
end;
end;