MPE Home Metamath Proof Explorer < Previous   Next >
Nearby theorems
Mirrors  >  Home  >  MPE Home  >  Th. List  >  lgsval Unicode version

Theorem lgsval 20951
Description: Value of the Legendre symbol at an arbitrary integer. (Contributed by Mario Carneiro, 4-Feb-2015.)
Hypothesis
Ref Expression
lgsval.1  |-  F  =  ( n  e.  NN  |->  if ( n  e.  Prime ,  ( if ( n  =  2 ,  if ( 2  ||  A ,  0 ,  if ( ( A  mod  8 )  e.  {
1 ,  7 } ,  1 ,  -u
1 ) ) ,  ( ( ( ( A ^ ( ( n  -  1 )  /  2 ) )  +  1 )  mod  n )  -  1 ) ) ^ (
n  pCnt  N )
) ,  1 ) )
Assertion
Ref Expression
lgsval  |-  ( ( A  e.  ZZ  /\  N  e.  ZZ )  ->  ( A  / L N )  =  if ( N  =  0 ,  if ( ( A ^ 2 )  =  1 ,  1 ,  0 ) ,  ( if ( ( N  <  0  /\  A  <  0 ) ,  -u 1 ,  1 )  x.  (  seq  1 (  x.  ,  F ) `  ( abs `  N ) ) ) ) )
Distinct variable groups:    A, n    n, N
Allowed substitution hint:    F( n)

Proof of Theorem lgsval
Dummy variables  a  m are mutually distinct and distinct from all other variables.
StepHypRef Expression
1 simpr 448 . . . 4  |-  ( ( a  =  A  /\  m  =  N )  ->  m  =  N )
21eqeq1d 2395 . . 3  |-  ( ( a  =  A  /\  m  =  N )  ->  ( m  =  0  <-> 
N  =  0 ) )
3 simpl 444 . . . . . 6  |-  ( ( a  =  A  /\  m  =  N )  ->  a  =  A )
43oveq1d 6035 . . . . 5  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a ^ 2 )  =  ( A ^ 2 ) )
54eqeq1d 2395 . . . 4  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( a ^
2 )  =  1  <-> 
( A ^ 2 )  =  1 ) )
65ifbid 3700 . . 3  |-  ( ( a  =  A  /\  m  =  N )  ->  if ( ( a ^ 2 )  =  1 ,  1 ,  0 )  =  if ( ( A ^
2 )  =  1 ,  1 ,  0 ) )
71breq1d 4163 . . . . . 6  |-  ( ( a  =  A  /\  m  =  N )  ->  ( m  <  0  <->  N  <  0 ) )
83breq1d 4163 . . . . . 6  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a  <  0  <->  A  <  0 ) )
97, 8anbi12d 692 . . . . 5  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( m  <  0  /\  a  <  0 )  <->  ( N  <  0  /\  A  <  0 ) ) )
109ifbid 3700 . . . 4  |-  ( ( a  =  A  /\  m  =  N )  ->  if ( ( m  <  0  /\  a  <  0 ) ,  -u
1 ,  1 )  =  if ( ( N  <  0  /\  A  <  0 ) ,  -u 1 ,  1 ) )
113breq2d 4165 . . . . . . . . . . . 12  |-  ( ( a  =  A  /\  m  =  N )  ->  ( 2  ||  a  <->  2 
||  A ) )
123oveq1d 6035 . . . . . . . . . . . . . 14  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a  mod  8
)  =  ( A  mod  8 ) )
1312eleq1d 2453 . . . . . . . . . . . . 13  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( a  mod  8 )  e.  {
1 ,  7 }  <-> 
( A  mod  8
)  e.  { 1 ,  7 } ) )
1413ifbid 3700 . . . . . . . . . . . 12  |-  ( ( a  =  A  /\  m  =  N )  ->  if ( ( a  mod  8 )  e. 
{ 1 ,  7 } ,  1 , 
-u 1 )  =  if ( ( A  mod  8 )  e. 
{ 1 ,  7 } ,  1 , 
-u 1 ) )
1511, 14ifbieq2d 3702 . . . . . . . . . . 11  |-  ( ( a  =  A  /\  m  =  N )  ->  if ( 2  ||  a ,  0 ,  if ( ( a  mod  8 )  e.  {
1 ,  7 } ,  1 ,  -u
1 ) )  =  if ( 2  ||  A ,  0 ,  if ( ( A  mod  8 )  e.  {
1 ,  7 } ,  1 ,  -u
1 ) ) )
163oveq1d 6035 . . . . . . . . . . . . . 14  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a ^ (
( n  -  1 )  /  2 ) )  =  ( A ^ ( ( n  -  1 )  / 
2 ) ) )
1716oveq1d 6035 . . . . . . . . . . . . 13  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( a ^
( ( n  - 
1 )  /  2
) )  +  1 )  =  ( ( A ^ ( ( n  -  1 )  /  2 ) )  +  1 ) )
1817oveq1d 6035 . . . . . . . . . . . 12  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( ( a ^ ( ( n  -  1 )  / 
2 ) )  +  1 )  mod  n
)  =  ( ( ( A ^ (
( n  -  1 )  /  2 ) )  +  1 )  mod  n ) )
1918oveq1d 6035 . . . . . . . . . . 11  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( ( ( a ^ ( ( n  -  1 )  /  2 ) )  +  1 )  mod  n )  -  1 )  =  ( ( ( ( A ^
( ( n  - 
1 )  /  2
) )  +  1 )  mod  n )  -  1 ) )
2015, 19ifeq12d 3698 . . . . . . . . . 10  |-  ( ( a  =  A  /\  m  =  N )  ->  if ( n  =  2 ,  if ( 2  ||  a ,  0 ,  if ( ( a  mod  8
)  e.  { 1 ,  7 } , 
1 ,  -u 1
) ) ,  ( ( ( ( a ^ ( ( n  -  1 )  / 
2 ) )  +  1 )  mod  n
)  -  1 ) )  =  if ( n  =  2 ,  if ( 2  ||  A ,  0 ,  if ( ( A  mod  8 )  e.  {
1 ,  7 } ,  1 ,  -u
1 ) ) ,  ( ( ( ( A ^ ( ( n  -  1 )  /  2 ) )  +  1 )  mod  n )  -  1 ) ) )
211oveq2d 6036 . . . . . . . . . 10  |-  ( ( a  =  A  /\  m  =  N )  ->  ( n  pCnt  m
)  =  ( n 
pCnt  N ) )
2220, 21oveq12d 6038 . . . . . . . . 9  |-  ( ( a  =  A  /\  m  =  N )  ->  ( if ( n  =  2 ,  if ( 2  ||  a ,  0 ,  if ( ( a  mod  8 )  e.  {
1 ,  7 } ,  1 ,  -u
1 ) ) ,  ( ( ( ( a ^ ( ( n  -  1 )  /  2 ) )  +  1 )  mod  n )  -  1 ) ) ^ (
n  pCnt  m )
)  =  ( if ( n  =  2 ,  if ( 2 
||  A ,  0 ,  if ( ( A  mod  8 )  e.  { 1 ,  7 } ,  1 ,  -u 1 ) ) ,  ( ( ( ( A ^ (
( n  -  1 )  /  2 ) )  +  1 )  mod  n )  - 
1 ) ) ^
( n  pCnt  N
) ) )
2322ifeq1d 3696 . . . . . . . 8  |-  ( ( a  =  A  /\  m  =  N )  ->  if ( n  e. 
Prime ,  ( if ( n  =  2 ,  if ( 2  ||  a ,  0 ,  if ( ( a  mod  8 )  e.  {
1 ,  7 } ,  1 ,  -u
1 ) ) ,  ( ( ( ( a ^ ( ( n  -  1 )  /  2 ) )  +  1 )  mod  n )  -  1 ) ) ^ (
n  pCnt  m )
) ,  1 )  =  if ( n  e.  Prime ,  ( if ( n  =  2 ,  if ( 2 
||  A ,  0 ,  if ( ( A  mod  8 )  e.  { 1 ,  7 } ,  1 ,  -u 1 ) ) ,  ( ( ( ( A ^ (
( n  -  1 )  /  2 ) )  +  1 )  mod  n )  - 
1 ) ) ^
( n  pCnt  N
) ) ,  1 ) )
2423mpteq2dv 4237 . . . . . . 7  |-  ( ( a  =  A  /\  m  =  N )  ->  ( n  e.  NN  |->  if ( n  e.  Prime ,  ( if ( n  =  2 ,  if ( 2  ||  a ,  0 ,  if ( ( a  mod  8 )  e.  {
1 ,  7 } ,  1 ,  -u
1 ) ) ,  ( ( ( ( a ^ ( ( n  -  1 )  /  2 ) )  +  1 )  mod  n )  -  1 ) ) ^ (
n  pCnt  m )
) ,  1 ) )  =  ( n  e.  NN  |->  if ( n  e.  Prime ,  ( if ( n  =  2 ,  if ( 2  ||  A , 
0 ,  if ( ( A  mod  8
)  e.  { 1 ,  7 } , 
1 ,  -u 1
) ) ,  ( ( ( ( A ^ ( ( n  -  1 )  / 
2 ) )  +  1 )  mod  n
)  -  1 ) ) ^ ( n 
pCnt  N ) ) ,  1 ) ) )
25 lgsval.1 . . . . . . 7  |-  F  =  ( n  e.  NN  |->  if ( n  e.  Prime ,  ( if ( n  =  2 ,  if ( 2  ||  A ,  0 ,  if ( ( A  mod  8 )  e.  {
1 ,  7 } ,  1 ,  -u
1 ) ) ,  ( ( ( ( A ^ ( ( n  -  1 )  /  2 ) )  +  1 )  mod  n )  -  1 ) ) ^ (
n  pCnt  N )
) ,  1 ) )
2624, 25syl6eqr 2437 . . . . . 6  |-  ( ( a  =  A  /\  m  =  N )  ->  ( n  e.  NN  |->  if ( n  e.  Prime ,  ( if ( n  =  2 ,  if ( 2  ||  a ,  0 ,  if ( ( a  mod  8 )  e.  {
1 ,  7 } ,  1 ,  -u
1 ) ) ,  ( ( ( ( a ^ ( ( n  -  1 )  /  2 ) )  +  1 )  mod  n )  -  1 ) ) ^ (
n  pCnt  m )
) ,  1 ) )  =  F )
2726seqeq3d 11258 . . . . 5  |-  ( ( a  =  A  /\  m  =  N )  ->  seq  1 (  x.  ,  ( n  e.  NN  |->  if ( n  e.  Prime ,  ( if ( n  =  2 ,  if ( 2 
||  a ,  0 ,  if ( ( a  mod  8 )  e.  { 1 ,  7 } ,  1 ,  -u 1 ) ) ,  ( ( ( ( a ^ (
( n  -  1 )  /  2 ) )  +  1 )  mod  n )  - 
1 ) ) ^
( n  pCnt  m
) ) ,  1 ) ) )  =  seq  1 (  x.  ,  F ) )
281fveq2d 5672 . . . . 5  |-  ( ( a  =  A  /\  m  =  N )  ->  ( abs `  m
)  =  ( abs `  N ) )
2927, 28fveq12d 5674 . . . 4  |-  ( ( a  =  A  /\  m  =  N )  ->  (  seq  1 (  x.  ,  ( n  e.  NN  |->  if ( n  e.  Prime ,  ( if ( n  =  2 ,  if ( 2  ||  a ,  0 ,  if ( ( a  mod  8
)  e.  { 1 ,  7 } , 
1 ,  -u 1
) ) ,  ( ( ( ( a ^ ( ( n  -  1 )  / 
2 ) )  +  1 )  mod  n
)  -  1 ) ) ^ ( n 
pCnt  m ) ) ,  1 ) ) ) `
 ( abs `  m
) )  =  (  seq  1 (  x.  ,  F ) `  ( abs `  N ) ) )
3010, 29oveq12d 6038 . . 3  |-  ( ( a  =  A  /\  m  =  N )  ->  ( if ( ( m  <  0  /\  a  <  0 ) ,  -u 1 ,  1 )  x.  (  seq  1 (  x.  , 
( n  e.  NN  |->  if ( n  e.  Prime ,  ( if ( n  =  2 ,  if ( 2  ||  a ,  0 ,  if ( ( a  mod  8 )  e.  {
1 ,  7 } ,  1 ,  -u
1 ) ) ,  ( ( ( ( a ^ ( ( n  -  1 )  /  2 ) )  +  1 )  mod  n )  -  1 ) ) ^ (
n  pCnt  m )
) ,  1 ) ) ) `  ( abs `  m ) ) )  =  ( if ( ( N  <  0  /\  A  <  0 ) ,  -u
1 ,  1 )  x.  (  seq  1
(  x.  ,  F
) `  ( abs `  N ) ) ) )
312, 6, 30ifbieq12d 3704 . 2  |-  ( ( a  =  A  /\  m  =  N )  ->  if ( m  =  0 ,  if ( ( a ^ 2 )  =  1 ,  1 ,  0 ) ,  ( if ( ( m  <  0  /\  a  <  0
) ,  -u 1 ,  1 )  x.  (  seq  1 (  x.  ,  ( n  e.  NN  |->  if ( n  e.  Prime ,  ( if ( n  =  2 ,  if ( 2  ||  a ,  0 ,  if ( ( a  mod  8
)  e.  { 1 ,  7 } , 
1 ,  -u 1
) ) ,  ( ( ( ( a ^ ( ( n  -  1 )  / 
2 ) )  +  1 )  mod  n
)  -  1 ) ) ^ ( n 
pCnt  m ) ) ,  1 ) ) ) `
 ( abs `  m
) ) ) )  =  if ( N  =  0 ,  if ( ( A ^
2 )  =  1 ,  1 ,  0 ) ,  ( if ( ( N  <  0  /\  A  <  0 ) ,  -u
1 ,  1 )  x.  (  seq  1
(  x.  ,  F
) `  ( abs `  N ) ) ) ) )
32 df-lgs 20946 . 2  |-  / L  =  ( a  e.  ZZ ,  m  e.  ZZ  |->  if ( m  =  0 ,  if ( ( a ^
2 )  =  1 ,  1 ,  0 ) ,  ( if ( ( m  <  0  /\  a  <  0 ) ,  -u
1 ,  1 )  x.  (  seq  1
(  x.  ,  ( n  e.  NN  |->  if ( n  e.  Prime ,  ( if ( n  =  2 ,  if ( 2  ||  a ,  0 ,  if ( ( a  mod  8 )  e.  {
1 ,  7 } ,  1 ,  -u
1 ) ) ,  ( ( ( ( a ^ ( ( n  -  1 )  /  2 ) )  +  1 )  mod  n )  -  1 ) ) ^ (
n  pCnt  m )
) ,  1 ) ) ) `  ( abs `  m ) ) ) ) )
33 1nn0 10169 . . . . 5  |-  1  e.  NN0
34 0nn0 10168 . . . . 5  |-  0  e.  NN0
3533, 34keepel 3739 . . . 4  |-  if ( ( A ^ 2 )  =  1 ,  1 ,  0 )  e.  NN0
3635elexi 2908 . . 3  |-  if ( ( A ^ 2 )  =  1 ,  1 ,  0 )  e.  _V
37 ovex 6045 . . 3  |-  ( if ( ( N  <  0  /\  A  <  0 ) ,  -u
1 ,  1 )  x.  (  seq  1
(  x.  ,  F
) `  ( abs `  N ) ) )  e.  _V
3836, 37ifex 3740 . 2  |-  if ( N  =  0 ,  if ( ( A ^ 2 )  =  1 ,  1 ,  0 ) ,  ( if ( ( N  <  0  /\  A  <  0 ) ,  -u
1 ,  1 )  x.  (  seq  1
(  x.  ,  F
) `  ( abs `  N ) ) ) )  e.  _V
3931, 32, 38ovmpt2a 6143 1  |-  ( ( A  e.  ZZ  /\  N  e.  ZZ )  ->  ( A  / L N )  =  if ( N  =  0 ,  if ( ( A ^ 2 )  =  1 ,  1 ,  0 ) ,  ( if ( ( N  <  0  /\  A  <  0 ) ,  -u 1 ,  1 )  x.  (  seq  1 (  x.  ,  F ) `  ( abs `  N ) ) ) ) )
Colors of variables: wff set class
Syntax hints:    -> wi 4    /\ wa 359    = wceq 1649    e. wcel 1717   ifcif 3682   {cpr 3758   class class class wbr 4153    e. cmpt 4207   ` cfv 5394  (class class class)co 6020   0cc0 8923   1c1 8924    + caddc 8926    x. cmul 8928    < clt 9053    - cmin 9223   -ucneg 9224    / cdiv 9609   NNcn 9932   2c2 9981   7c7 9986   8c8 9987   NN0cn0 10153   ZZcz 10214    mod cmo 11177    seq cseq 11250   ^cexp 11309   abscabs 11966    || cdivides 12779   Primecprime 13006    pCnt cpc 13137    / Lclgs 20945
This theorem is referenced by:  lgscllem  20954  lgsval2lem  20957  lgs0  20960  lgsval4  20967
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1552  ax-5 1563  ax-17 1623  ax-9 1661  ax-8 1682  ax-13 1719  ax-14 1721  ax-6 1736  ax-7 1741  ax-11 1753  ax-12 1939  ax-ext 2368  ax-sep 4271  ax-nul 4279  ax-pow 4318  ax-pr 4344  ax-un 4641  ax-1cn 8981  ax-icn 8982  ax-addcl 8983  ax-mulcl 8985  ax-i2m1 8991
This theorem depends on definitions:  df-bi 178  df-or 360  df-an 361  df-3or 937  df-3an 938  df-tru 1325  df-ex 1548  df-nf 1551  df-sb 1656  df-eu 2242  df-mo 2243  df-clab 2374  df-cleq 2380  df-clel 2383  df-nfc 2512  df-ne 2552  df-ral 2654  df-rex 2655  df-reu 2656  df-rab 2658  df-v 2901  df-sbc 3105  df-csb 3195  df-dif 3266  df-un 3268  df-in 3270  df-ss 3277  df-pss 3279  df-nul 3572  df-if 3683  df-pw 3744  df-sn 3763  df-pr 3764  df-tp 3765  df-op 3766  df-uni 3958  df-iun 4037  df-br 4154  df-opab 4208  df-mpt 4209  df-tr 4244  df-eprel 4435  df-id 4439  df-po 4444  df-so 4445  df-fr 4482  df-we 4484  df-ord 4525  df-on 4526  df-lim 4527  df-suc 4528  df-om 4786  df-xp 4824  df-rel 4825  df-cnv 4826  df-co 4827  df-dm 4828  df-rn 4829  df-res 4830  df-ima 4831  df-iota 5358  df-fun 5396  df-fn 5397  df-f 5398  df-f1 5399  df-fo 5400  df-f1o 5401  df-fv 5402  df-ov 6023  df-oprab 6024  df-mpt2 6025  df-recs 6569  df-rdg 6604  df-nn 9933  df-n0 10154  df-seq 11251  df-lgs 20946
  Copyright terms: Public domain W3C validator