Metamath Proof Explorer


Theorem fmtnoprmfac2lem1

Description: Lemma for fmtnoprmfac2 . (Contributed by AV, 26-Jul-2021)

Ref Expression
Assertion fmtnoprmfac2lem1 N 2 P 2 P FermatNo N 2 P 1 2 mod P = 1

Proof

Step Hyp Ref Expression
1 eluz2nn N 2 N
2 eldifi P 2 P
3 id P FermatNo N P FermatNo N
4 fmtnoprmfac1 N P P FermatNo N n P = n 2 N + 1 + 1
5 1 2 3 4 syl3an N 2 P 2 P FermatNo N n P = n 2 N + 1 + 1
6 2z 2
7 simp2 N 2 P 2 P FermatNo N P 2
8 lgsvalmod 2 P 2 2 / L P mod P = 2 P 1 2 mod P
9 8 eqcomd 2 P 2 2 P 1 2 mod P = 2 / L P mod P
10 6 7 9 sylancr N 2 P 2 P FermatNo N 2 P 1 2 mod P = 2 / L P mod P
11 10 ad2antrr N 2 P 2 P FermatNo N n P = n 2 N + 1 + 1 2 P 1 2 mod P = 2 / L P mod P
12 nncn n n
13 12 adantl N 2 n n
14 2nn 2
15 14 a1i N 2 2
16 eluzge2nn0 N 2 N 0
17 peano2nn0 N 0 N + 1 0
18 16 17 syl N 2 N + 1 0
19 15 18 nnexpcld N 2 2 N + 1
20 19 nncnd N 2 2 N + 1
21 20 adantr N 2 n 2 N + 1
22 13 21 mulcomd N 2 n n 2 N + 1 = 2 N + 1 n
23 8cn 8
24 23 a1i N 2 n 8
25 0re 0
26 8pos 0 < 8
27 25 26 gtneii 8 0
28 27 a1i N 2 n 8 0
29 21 24 28 divcan2d N 2 n 8 2 N + 1 8 = 2 N + 1
30 29 eqcomd N 2 n 2 N + 1 = 8 2 N + 1 8
31 30 oveq1d N 2 n 2 N + 1 n = 8 2 N + 1 8 n
32 23 a1i N 2 8
33 27 a1i N 2 8 0
34 20 32 33 divcld N 2 2 N + 1 8
35 34 adantr N 2 n 2 N + 1 8
36 24 35 13 mulassd N 2 n 8 2 N + 1 8 n = 8 2 N + 1 8 n
37 22 31 36 3eqtrd N 2 n n 2 N + 1 = 8 2 N + 1 8 n
38 37 oveq1d N 2 n n 2 N + 1 + 1 = 8 2 N + 1 8 n + 1
39 38 eqeq2d N 2 n P = n 2 N + 1 + 1 P = 8 2 N + 1 8 n + 1
40 oveq1 P = 8 2 N + 1 8 n + 1 P mod 8 = 8 2 N + 1 8 n + 1 mod 8
41 40 adantl N 2 n P = 8 2 N + 1 8 n + 1 P mod 8 = 8 2 N + 1 8 n + 1 mod 8
42 3m1e2 3 1 = 2
43 eluzle N 2 2 N
44 42 43 eqbrtrid N 2 3 1 N
45 3re 3
46 45 a1i N 2 3
47 1red N 2 1
48 eluzelre N 2 N
49 46 47 48 lesubaddd N 2 3 1 N 3 N + 1
50 44 49 mpbid N 2 3 N + 1
51 3nn0 3 0
52 nn0sub 3 0 N + 1 0 3 N + 1 N + 1 - 3 0
53 51 18 52 sylancr N 2 3 N + 1 N + 1 - 3 0
54 50 53 mpbid N 2 N + 1 - 3 0
55 15 54 nnexpcld N 2 2 N + 1 - 3
56 55 nnzd N 2 2 N + 1 - 3
57 oveq2 k = 2 N + 1 - 3 8 k = 8 2 N + 1 - 3
58 57 eqeq1d k = 2 N + 1 - 3 8 k = 2 N + 1 8 2 N + 1 - 3 = 2 N + 1
59 58 adantl N 2 k = 2 N + 1 - 3 8 k = 2 N + 1 8 2 N + 1 - 3 = 2 N + 1
60 cu2 2 3 = 8
61 60 eqcomi 8 = 2 3
62 61 a1i N 2 8 = 2 3
63 2cnne0 2 2 0
64 63 a1i N 2 2 2 0
65 eluzelz N 2 N
66 65 peano2zd N 2 N + 1
67 3z 3
68 67 a1i N 2 3
69 expsub 2 2 0 N + 1 3 2 N + 1 - 3 = 2 N + 1 2 3
70 64 66 68 69 syl12anc N 2 2 N + 1 - 3 = 2 N + 1 2 3
71 62 70 oveq12d N 2 8 2 N + 1 - 3 = 2 3 2 N + 1 2 3
72 nnexpcl 2 3 0 2 3
73 14 51 72 mp2an 2 3
74 73 nncni 2 3
75 74 a1i N 2 2 3
76 2cn 2
77 2ne0 2 0
78 expne0i 2 2 0 3 2 3 0
79 76 77 67 78 mp3an 2 3 0
80 79 a1i N 2 2 3 0
81 20 75 80 divcan2d N 2 2 3 2 N + 1 2 3 = 2 N + 1
82 71 81 eqtrd N 2 8 2 N + 1 - 3 = 2 N + 1
83 56 59 82 rspcedvd N 2 k 8 k = 2 N + 1
84 8nn 8
85 2nn0 2 0
86 85 a1i N 2 2 0
87 86 18 nn0expcld N 2 2 N + 1 0
88 87 nn0zd N 2 2 N + 1
89 zdiv 8 2 N + 1 k 8 k = 2 N + 1 2 N + 1 8
90 84 88 89 sylancr N 2 k 8 k = 2 N + 1 2 N + 1 8
91 83 90 mpbid N 2 2 N + 1 8
92 91 adantr N 2 n 2 N + 1 8
93 nnz n n
94 93 adantl N 2 n n
95 92 94 zmulcld N 2 n 2 N + 1 8 n
96 84 nnzi 8
97 2re 2
98 8re 8
99 2lt8 2 < 8
100 97 98 99 ltleii 2 8
101 eluz2 8 2 2 8 2 8
102 6 96 100 101 mpbir3an 8 2
103 mulp1mod1 2 N + 1 8 n 8 2 8 2 N + 1 8 n + 1 mod 8 = 1
104 95 102 103 sylancl N 2 n 8 2 N + 1 8 n + 1 mod 8 = 1
105 1nn 1
106 prid1g 1 1 1 7
107 105 106 mp1i N 2 n 1 1 7
108 104 107 eqeltrd N 2 n 8 2 N + 1 8 n + 1 mod 8 1 7
109 108 adantr N 2 n P = 8 2 N + 1 8 n + 1 8 2 N + 1 8 n + 1 mod 8 1 7
110 41 109 eqeltrd N 2 n P = 8 2 N + 1 8 n + 1 P mod 8 1 7
111 110 ex N 2 n P = 8 2 N + 1 8 n + 1 P mod 8 1 7
112 39 111 sylbid N 2 n P = n 2 N + 1 + 1 P mod 8 1 7
113 112 3ad2antl1 N 2 P 2 P FermatNo N n P = n 2 N + 1 + 1 P mod 8 1 7
114 113 imp N 2 P 2 P FermatNo N n P = n 2 N + 1 + 1 P mod 8 1 7
115 2lgs P 2 / L P = 1 P mod 8 1 7
116 2 115 syl P 2 2 / L P = 1 P mod 8 1 7
117 116 3ad2ant2 N 2 P 2 P FermatNo N 2 / L P = 1 P mod 8 1 7
118 117 ad2antrr N 2 P 2 P FermatNo N n P = n 2 N + 1 + 1 2 / L P = 1 P mod 8 1 7
119 114 118 mpbird N 2 P 2 P FermatNo N n P = n 2 N + 1 + 1 2 / L P = 1
120 119 oveq1d N 2 P 2 P FermatNo N n P = n 2 N + 1 + 1 2 / L P mod P = 1 mod P
121 prmuz2 P P 2
122 eluzelre P 2 P
123 eluz2gt1 P 2 1 < P
124 122 123 jca P 2 P 1 < P
125 121 124 syl P P 1 < P
126 1mod P 1 < P 1 mod P = 1
127 2 125 126 3syl P 2 1 mod P = 1
128 127 3ad2ant2 N 2 P 2 P FermatNo N 1 mod P = 1
129 128 ad2antrr N 2 P 2 P FermatNo N n P = n 2 N + 1 + 1 1 mod P = 1
130 11 120 129 3eqtrd N 2 P 2 P FermatNo N n P = n 2 N + 1 + 1 2 P 1 2 mod P = 1
131 130 rexlimdva2 N 2 P 2 P FermatNo N n P = n 2 N + 1 + 1 2 P 1 2 mod P = 1
132 5 131 mpd N 2 P 2 P FermatNo N 2 P 1 2 mod P = 1