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

Theorem lgsval 20539
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 447 . . . 4  |-  ( ( a  =  A  /\  m  =  N )  ->  m  =  N )
21eqeq1d 2291 . . 3  |-  ( ( a  =  A  /\  m  =  N )  ->  ( m  =  0  <-> 
N  =  0 ) )
3 simpl 443 . . . . . 6  |-  ( ( a  =  A  /\  m  =  N )  ->  a  =  A )
43oveq1d 5873 . . . . 5  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a ^ 2 )  =  ( A ^ 2 ) )
54eqeq1d 2291 . . . 4  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( a ^
2 )  =  1  <-> 
( A ^ 2 )  =  1 ) )
65ifbid 3583 . . 3  |-  ( ( a  =  A  /\  m  =  N )  ->  if ( ( a ^ 2 )  =  1 ,  1 ,  0 )  =  if ( ( A ^
2 )  =  1 ,  1 ,  0 ) )
71breq1d 4033 . . . . . 6  |-  ( ( a  =  A  /\  m  =  N )  ->  ( m  <  0  <->  N  <  0 ) )
83breq1d 4033 . . . . . 6  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a  <  0  <->  A  <  0 ) )
97, 8anbi12d 691 . . . . 5  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( m  <  0  /\  a  <  0 )  <->  ( N  <  0  /\  A  <  0 ) ) )
109ifbid 3583 . . . 4  |-  ( ( a  =  A  /\  m  =  N )  ->  if ( ( m  <  0  /\  a  <  0 ) ,  -u
1 ,  1 )  =  if ( ( N  <  0  /\  A  <  0 ) ,  -u 1 ,  1 ) )
113breq2d 4035 . . . . . . . . . . . 12  |-  ( ( a  =  A  /\  m  =  N )  ->  ( 2  ||  a  <->  2 
||  A ) )
123oveq1d 5873 . . . . . . . . . . . . . 14  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a  mod  8
)  =  ( A  mod  8 ) )
1312eleq1d 2349 . . . . . . . . . . . . 13  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( a  mod  8 )  e.  {
1 ,  7 }  <-> 
( A  mod  8
)  e.  { 1 ,  7 } ) )
1413ifbid 3583 . . . . . . . . . . . 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 3585 . . . . . . . . . . 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 5873 . . . . . . . . . . . . . 14  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a ^ (
( n  -  1 )  /  2 ) )  =  ( A ^ ( ( n  -  1 )  / 
2 ) ) )
1716oveq1d 5873 . . . . . . . . . . . . 13  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( a ^
( ( n  - 
1 )  /  2
) )  +  1 )  =  ( ( A ^ ( ( n  -  1 )  /  2 ) )  +  1 ) )
1817oveq1d 5873 . . . . . . . . . . . 12  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( ( a ^ ( ( n  -  1 )  / 
2 ) )  +  1 )  mod  n
)  =  ( ( ( A ^ (
( n  -  1 )  /  2 ) )  +  1 )  mod  n ) )
1918oveq1d 5873 . . . . . . . . . . 11  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( ( ( a ^ ( ( n  -  1 )  /  2 ) )  +  1 )  mod  n )  -  1 )  =  ( ( ( ( A ^
( ( n  - 
1 )  /  2
) )  +  1 )  mod  n )  -  1 ) )
2015, 19ifeq12d 3581 . . . . . . . . . 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 5874 . . . . . . . . . 10  |-  ( ( a  =  A  /\  m  =  N )  ->  ( n  pCnt  m
)  =  ( n 
pCnt  N ) )
2220, 21oveq12d 5876 . . . . . . . . 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 3579 . . . . . . . 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 4107 . . . . . . 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 2333 . . . . . 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 11054 . . . . 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 5529 . . . . 5  |-  ( ( a  =  A  /\  m  =  N )  ->  ( abs `  m
)  =  ( abs `  N ) )
2927, 28fveq12d 5531 . . . 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 5876 . . 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 3587 . 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 20534 . 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 9981 . . . . 5  |-  1  e.  NN0
34 0nn0 9980 . . . . 5  |-  0  e.  NN0
3533, 34keepel 3622 . . . 4  |-  if ( ( A ^ 2 )  =  1 ,  1 ,  0 )  e.  NN0
3635elexi 2797 . . 3  |-  if ( ( A ^ 2 )  =  1 ,  1 ,  0 )  e.  _V
37 ovex 5883 . . 3  |-  ( if ( ( N  <  0  /\  A  <  0 ) ,  -u
1 ,  1 )  x.  (  seq  1
(  x.  ,  F
) `  ( abs `  N ) ) )  e.  _V
3836, 37ifex 3623 . 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 5978 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 358    = wceq 1623    e. wcel 1684   ifcif 3565   {cpr 3641   class class class wbr 4023    e. cmpt 4077   ` cfv 5255  (class class class)co 5858   0cc0 8737   1c1 8738    + caddc 8740    x. cmul 8742    < clt 8867    - cmin 9037   -ucneg 9038    / cdiv 9423   NNcn 9746   2c2 9795   7c7 9800   8c8 9801   NN0cn0 9965   ZZcz 10024    mod cmo 10973    seq cseq 11046   ^cexp 11104   abscabs 11719    || cdivides 12531   Primecprime 12758    pCnt cpc 12889    / Lclgs 20533
This theorem is referenced by:  lgscllem  20542  lgsval2lem  20545  lgs0  20548  lgsval4  20555
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1533  ax-5 1544  ax-17 1603  ax-9 1635  ax-8 1643  ax-13 1686  ax-14 1688  ax-6 1703  ax-7 1708  ax-11 1715  ax-12 1866  ax-ext 2264  ax-sep 4141  ax-nul 4149  ax-pow 4188  ax-pr 4214  ax-un 4512  ax-1cn 8795  ax-icn 8796  ax-addcl 8797  ax-mulcl 8799  ax-i2m1 8805
This theorem depends on definitions:  df-bi 177  df-or 359  df-an 360  df-3or 935  df-3an 936  df-tru 1310  df-ex 1529  df-nf 1532  df-sb 1630  df-eu 2147  df-mo 2148  df-clab 2270  df-cleq 2276  df-clel 2279  df-nfc 2408  df-ne 2448  df-ral 2548  df-rex 2549  df-reu 2550  df-rab 2552  df-v 2790  df-sbc 2992  df-csb 3082  df-dif 3155  df-un 3157  df-in 3159  df-ss 3166  df-pss 3168  df-nul 3456  df-if 3566  df-pw 3627  df-sn 3646  df-pr 3647  df-tp 3648  df-op 3649  df-uni 3828  df-iun 3907  df-br 4024  df-opab 4078  df-mpt 4079  df-tr 4114  df-eprel 4305  df-id 4309  df-po 4314  df-so 4315  df-fr 4352  df-we 4354  df-ord 4395  df-on 4396  df-lim 4397  df-suc 4398  df-om 4657  df-xp 4695  df-rel 4696  df-cnv 4697  df-co 4698  df-dm 4699  df-rn 4700  df-res 4701  df-ima 4702  df-iota 5219  df-fun 5257  df-fn 5258  df-f 5259  df-f1 5260  df-fo 5261  df-f1o 5262  df-fv 5263  df-ov 5861  df-oprab 5862  df-mpt2 5863  df-recs 6388  df-rdg 6423  df-nn 9747  df-n0 9966  df-seq 11047  df-lgs 20534
  Copyright terms: Public domain W3C validator