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

Theorem lgsfval 20540
Description: Value of the function  F which defines the Legendre symbol at the primes. (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
lgsfval  |-  ( M  e.  NN  ->  ( F `  M )  =  if ( M  e. 
Prime ,  ( if ( M  =  2 ,  if ( 2  ||  A ,  0 ,  if ( ( A  mod  8 )  e.  {
1 ,  7 } ,  1 ,  -u
1 ) ) ,  ( ( ( ( A ^ ( ( M  -  1 )  /  2 ) )  +  1 )  mod 
M )  -  1 ) ) ^ ( M  pCnt  N ) ) ,  1 ) )
Distinct variable groups:    A, n    n, M    n, N
Allowed substitution hint:    F( n)

Proof of Theorem lgsfval
StepHypRef Expression
1 eleq1 2343 . . 3  |-  ( n  =  M  ->  (
n  e.  Prime  <->  M  e.  Prime ) )
2 eqeq1 2289 . . . . 5  |-  ( n  =  M  ->  (
n  =  2  <->  M  =  2 ) )
3 oveq1 5865 . . . . . . . . . 10  |-  ( n  =  M  ->  (
n  -  1 )  =  ( M  - 
1 ) )
43oveq1d 5873 . . . . . . . . 9  |-  ( n  =  M  ->  (
( n  -  1 )  /  2 )  =  ( ( M  -  1 )  / 
2 ) )
54oveq2d 5874 . . . . . . . 8  |-  ( n  =  M  ->  ( A ^ ( ( n  -  1 )  / 
2 ) )  =  ( A ^ (
( M  -  1 )  /  2 ) ) )
65oveq1d 5873 . . . . . . 7  |-  ( n  =  M  ->  (
( A ^ (
( n  -  1 )  /  2 ) )  +  1 )  =  ( ( A ^ ( ( M  -  1 )  / 
2 ) )  +  1 ) )
7 id 19 . . . . . . 7  |-  ( n  =  M  ->  n  =  M )
86, 7oveq12d 5876 . . . . . 6  |-  ( n  =  M  ->  (
( ( A ^
( ( n  - 
1 )  /  2
) )  +  1 )  mod  n )  =  ( ( ( A ^ ( ( M  -  1 )  /  2 ) )  +  1 )  mod 
M ) )
98oveq1d 5873 . . . . 5  |-  ( n  =  M  ->  (
( ( ( A ^ ( ( n  -  1 )  / 
2 ) )  +  1 )  mod  n
)  -  1 )  =  ( ( ( ( A ^ (
( M  -  1 )  /  2 ) )  +  1 )  mod  M )  - 
1 ) )
102, 9ifbieq2d 3585 . . . 4  |-  ( n  =  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 ) )  =  if ( M  =  2 ,  if ( 2 
||  A ,  0 ,  if ( ( A  mod  8 )  e.  { 1 ,  7 } ,  1 ,  -u 1 ) ) ,  ( ( ( ( A ^ (
( M  -  1 )  /  2 ) )  +  1 )  mod  M )  - 
1 ) ) )
11 oveq1 5865 . . . 4  |-  ( n  =  M  ->  (
n  pCnt  N )  =  ( M  pCnt  N ) )
1210, 11oveq12d 5876 . . 3  |-  ( n  =  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
) )  =  ( if ( M  =  2 ,  if ( 2  ||  A , 
0 ,  if ( ( A  mod  8
)  e.  { 1 ,  7 } , 
1 ,  -u 1
) ) ,  ( ( ( ( A ^ ( ( M  -  1 )  / 
2 ) )  +  1 )  mod  M
)  -  1 ) ) ^ ( M 
pCnt  N ) ) )
13 eqidd 2284 . . 3  |-  ( n  =  M  ->  1  =  1 )
141, 12, 13ifbieq12d 3587 . 2  |-  ( n  =  M  ->  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 )  =  if ( M  e.  Prime ,  ( if ( M  =  2 ,  if ( 2 
||  A ,  0 ,  if ( ( A  mod  8 )  e.  { 1 ,  7 } ,  1 ,  -u 1 ) ) ,  ( ( ( ( A ^ (
( M  -  1 )  /  2 ) )  +  1 )  mod  M )  - 
1 ) ) ^
( M  pCnt  N
) ) ,  1 ) )
15 lgsval.1 . 2  |-  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 ) )
16 ovex 5883 . . 3  |-  ( if ( M  =  2 ,  if ( 2 
||  A ,  0 ,  if ( ( A  mod  8 )  e.  { 1 ,  7 } ,  1 ,  -u 1 ) ) ,  ( ( ( ( A ^ (
( M  -  1 )  /  2 ) )  +  1 )  mod  M )  - 
1 ) ) ^
( M  pCnt  N
) )  e.  _V
17 1ex 8833 . . 3  |-  1  e.  _V
1816, 17ifex 3623 . 2  |-  if ( M  e.  Prime ,  ( if ( M  =  2 ,  if ( 2  ||  A , 
0 ,  if ( ( A  mod  8
)  e.  { 1 ,  7 } , 
1 ,  -u 1
) ) ,  ( ( ( ( A ^ ( ( M  -  1 )  / 
2 ) )  +  1 )  mod  M
)  -  1 ) ) ^ ( M 
pCnt  N ) ) ,  1 )  e.  _V
1914, 15, 18fvmpt 5602 1  |-  ( M  e.  NN  ->  ( F `  M )  =  if ( M  e. 
Prime ,  ( if ( M  =  2 ,  if ( 2  ||  A ,  0 ,  if ( ( A  mod  8 )  e.  {
1 ,  7 } ,  1 ,  -u
1 ) ) ,  ( ( ( ( A ^ ( ( M  -  1 )  /  2 ) )  +  1 )  mod 
M )  -  1 ) ) ^ ( M  pCnt  N ) ) ,  1 ) )
Colors of variables: wff set class
Syntax hints:    -> wi 4    = 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    - cmin 9037   -ucneg 9038    / cdiv 9423   NNcn 9746   2c2 9795   7c7 9800   8c8 9801    mod cmo 10973   ^cexp 11104    || cdivides 12531   Primecprime 12758    pCnt cpc 12889
This theorem is referenced by:  lgsval2lem  20545
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-14 1688  ax-6 1703  ax-7 1708  ax-11 1715  ax-12 1866  ax-ext 2264  ax-sep 4141  ax-nul 4149  ax-pr 4214  ax-1cn 8795
This theorem depends on definitions:  df-bi 177  df-or 359  df-an 360  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-rab 2552  df-v 2790  df-sbc 2992  df-dif 3155  df-un 3157  df-in 3159  df-ss 3166  df-nul 3456  df-if 3566  df-sn 3646  df-pr 3647  df-op 3649  df-uni 3828  df-br 4024  df-opab 4078  df-mpt 4079  df-id 4309  df-xp 4695  df-rel 4696  df-cnv 4697  df-co 4698  df-dm 4699  df-iota 5219  df-fun 5257  df-fv 5263  df-ov 5861
  Copyright terms: Public domain W3C validator