Metamath Proof Explorer


Theorem lgsval2lem

Description: Lemma for lgsval2 . (Contributed by Mario Carneiro, 4-Feb-2015)

Ref Expression
Hypothesis lgsval.1 F = n if n if n = 2 if 2 A 0 if A mod 8 1 7 1 1 A n 1 2 + 1 mod n 1 n pCnt N 1
Assertion lgsval2lem A N A / L N = if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1

Proof

Step Hyp Ref Expression
1 lgsval.1 F = n if n if n = 2 if 2 A 0 if A mod 8 1 7 1 1 A n 1 2 + 1 mod n 1 n pCnt N 1
2 prmz N N
3 1 lgsval A N A / L N = if N = 0 if A 2 = 1 1 0 if N < 0 A < 0 1 1 seq 1 × F N
4 2 3 sylan2 A N A / L N = if N = 0 if A 2 = 1 1 0 if N < 0 A < 0 1 1 seq 1 × F N
5 prmnn N N
6 5 adantl A N N
7 6 nnne0d A N N 0
8 7 neneqd A N ¬ N = 0
9 8 iffalsed A N if N = 0 if A 2 = 1 1 0 if N < 0 A < 0 1 1 seq 1 × F N = if N < 0 A < 0 1 1 seq 1 × F N
10 6 nnnn0d A N N 0
11 10 nn0ge0d A N 0 N
12 0re 0
13 6 nnred A N N
14 lenlt 0 N 0 N ¬ N < 0
15 12 13 14 sylancr A N 0 N ¬ N < 0
16 11 15 mpbid A N ¬ N < 0
17 16 intnanrd A N ¬ N < 0 A < 0
18 17 iffalsed A N if N < 0 A < 0 1 1 = 1
19 13 11 absidd A N N = N
20 19 fveq2d A N seq 1 × F N = seq 1 × F N
21 1z 1
22 prmuz2 N N 2
23 22 adantl A N N 2
24 df-2 2 = 1 + 1
25 24 fveq2i 2 = 1 + 1
26 23 25 eleqtrdi A N N 1 + 1
27 seqm1 1 N 1 + 1 seq 1 × F N = seq 1 × F N 1 F N
28 21 26 27 sylancr A N seq 1 × F N = seq 1 × F N 1 F N
29 1t1e1 1 1 = 1
30 29 a1i A N 1 1 = 1
31 uz2m1nn N 2 N 1
32 23 31 syl A N N 1
33 nnuz = 1
34 32 33 eleqtrdi A N N 1 1
35 elfznn x 1 N 1 x
36 35 adantl A N x 1 N 1 x
37 1 lgsfval x F x = if x if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1 x pCnt N 1
38 36 37 syl A N x 1 N 1 F x = if x if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1 x pCnt N 1
39 elfzelz N 1 N 1 N
40 39 zred N 1 N 1 N
41 40 ltm1d N 1 N 1 N 1 < N
42 peano2rem N N 1
43 40 42 syl N 1 N 1 N 1
44 elfzle2 N 1 N 1 N N 1
45 40 43 44 lensymd N 1 N 1 ¬ N 1 < N
46 41 45 pm2.65i ¬ N 1 N 1
47 eleq1 x = N x 1 N 1 N 1 N 1
48 46 47 mtbiri x = N ¬ x 1 N 1
49 48 con2i x 1 N 1 ¬ x = N
50 49 ad2antlr A N x 1 N 1 x ¬ x = N
51 prmuz2 x x 2
52 simpllr A N x 1 N 1 x N
53 dvdsprm x 2 N x N x = N
54 51 52 53 syl2an2 A N x 1 N 1 x x N x = N
55 50 54 mtbird A N x 1 N 1 x ¬ x N
56 simpr A N x 1 N 1 x x
57 6 ad2antrr A N x 1 N 1 x N
58 pceq0 x N x pCnt N = 0 ¬ x N
59 56 57 58 syl2anc A N x 1 N 1 x x pCnt N = 0 ¬ x N
60 55 59 mpbird A N x 1 N 1 x x pCnt N = 0
61 60 oveq2d A N x 1 N 1 x if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1 x pCnt N = if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1 0
62 0z 0
63 neg1z 1
64 21 63 ifcli if A mod 8 1 7 1 1
65 62 64 ifcli if 2 A 0 if A mod 8 1 7 1 1
66 65 a1i A N x x = 2 if 2 A 0 if A mod 8 1 7 1 1
67 simpl A N A
68 67 ad2antrr A N x ¬ x = 2 A
69 simplr A N x ¬ x = 2 x
70 simpr A N x ¬ x = 2 ¬ x = 2
71 70 neqned A N x ¬ x = 2 x 2
72 eldifsn x 2 x x 2
73 69 71 72 sylanbrc A N x ¬ x = 2 x 2
74 oddprm x 2 x 1 2
75 73 74 syl A N x ¬ x = 2 x 1 2
76 75 nnnn0d A N x ¬ x = 2 x 1 2 0
77 zexpcl A x 1 2 0 A x 1 2
78 68 76 77 syl2anc A N x ¬ x = 2 A x 1 2
79 78 peano2zd A N x ¬ x = 2 A x 1 2 + 1
80 prmnn x x
81 80 ad2antlr A N x ¬ x = 2 x
82 79 81 zmodcld A N x ¬ x = 2 A x 1 2 + 1 mod x 0
83 82 nn0zd A N x ¬ x = 2 A x 1 2 + 1 mod x
84 peano2zm A x 1 2 + 1 mod x A x 1 2 + 1 mod x 1
85 83 84 syl A N x ¬ x = 2 A x 1 2 + 1 mod x 1
86 66 85 ifclda A N x if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1
87 86 zcnd A N x if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1
88 87 adantlr A N x 1 N 1 x if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1
89 88 exp0d A N x 1 N 1 x if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1 0 = 1
90 61 89 eqtrd A N x 1 N 1 x if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1 x pCnt N = 1
91 90 ifeq1da A N x 1 N 1 if x if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1 x pCnt N 1 = if x 1 1
92 ifid if x 1 1 = 1
93 91 92 eqtrdi A N x 1 N 1 if x if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1 x pCnt N 1 = 1
94 38 93 eqtrd A N x 1 N 1 F x = 1
95 30 34 94 seqid3 A N seq 1 × F N 1 = 1
96 95 oveq1d A N seq 1 × F N 1 F N = 1 F N
97 2 adantl A N N
98 1 lgsfcl A N N 0 F :
99 67 97 7 98 syl3anc A N F :
100 99 6 ffvelrnd A N F N
101 100 zcnd A N F N
102 101 mulid2d A N 1 F N = F N
103 28 96 102 3eqtrd A N seq 1 × F N = F N
104 20 103 eqtrd A N seq 1 × F N = F N
105 18 104 oveq12d A N if N < 0 A < 0 1 1 seq 1 × F N = 1 F N
106 1 lgsfval N F N = if N if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1 N pCnt N 1
107 6 106 syl A N F N = if N if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1 N pCnt N 1
108 iftrue N if N if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1 N pCnt N 1 = if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1 N pCnt N
109 108 adantl A N if N if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1 N pCnt N 1 = if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1 N pCnt N
110 6 nncnd A N N
111 110 exp1d A N N 1 = N
112 111 oveq2d A N N pCnt N 1 = N pCnt N
113 simpr A N N
114 pcid N 1 N pCnt N 1 = 1
115 113 21 114 sylancl A N N pCnt N 1 = 1
116 112 115 eqtr3d A N N pCnt N = 1
117 116 oveq2d A N if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1 N pCnt N = if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1 1
118 eqeq1 x = N x = 2 N = 2
119 oveq1 x = N x 1 = N 1
120 119 oveq1d x = N x 1 2 = N 1 2
121 120 oveq2d x = N A x 1 2 = A N 1 2
122 121 oveq1d x = N A x 1 2 + 1 = A N 1 2 + 1
123 id x = N x = N
124 122 123 oveq12d x = N A x 1 2 + 1 mod x = A N 1 2 + 1 mod N
125 124 oveq1d x = N A x 1 2 + 1 mod x 1 = A N 1 2 + 1 mod N 1
126 118 125 ifbieq2d x = N if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1 = if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1
127 126 eleq1d x = N if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1 if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1
128 87 ralrimiva A N x if x = 2 if 2 A 0 if A mod 8 1 7 1 1 A x 1 2 + 1 mod x 1
129 127 128 113 rspcdva A N if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1
130 129 exp1d A N if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1 1 = if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1
131 117 130 eqtrd A N if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1 N pCnt N = if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1
132 107 109 131 3eqtrd A N F N = if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1
133 105 102 132 3eqtrd A N if N < 0 A < 0 1 1 seq 1 × F N = if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1
134 4 9 133 3eqtrd A N A / L N = if N = 2 if 2 A 0 if A mod 8 1 7 1 1 A N 1 2 + 1 mod N 1