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

Theorem lgsfval 22652
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 2503 . . 3  |-  ( n  =  M  ->  (
n  e.  Prime  <->  M  e.  Prime ) )
2 eqeq1 2449 . . . . 5  |-  ( n  =  M  ->  (
n  =  2  <->  M  =  2 ) )
3 oveq1 6110 . . . . . . . . . 10  |-  ( n  =  M  ->  (
n  -  1 )  =  ( M  - 
1 ) )
43oveq1d 6118 . . . . . . . . 9  |-  ( n  =  M  ->  (
( n  -  1 )  /  2 )  =  ( ( M  -  1 )  / 
2 ) )
54oveq2d 6119 . . . . . . . 8  |-  ( n  =  M  ->  ( A ^ ( ( n  -  1 )  / 
2 ) )  =  ( A ^ (
( M  -  1 )  /  2 ) ) )
65oveq1d 6118 . . . . . . 7  |-  ( n  =  M  ->  (
( A ^ (
( n  -  1 )  /  2 ) )  +  1 )  =  ( ( A ^ ( ( M  -  1 )  / 
2 ) )  +  1 ) )
7 id 22 . . . . . . 7  |-  ( n  =  M  ->  n  =  M )
86, 7oveq12d 6121 . . . . . 6  |-  ( n  =  M  ->  (
( ( A ^
( ( n  - 
1 )  /  2
) )  +  1 )  mod  n )  =  ( ( ( A ^ ( ( M  -  1 )  /  2 ) )  +  1 )  mod 
M ) )
98oveq1d 6118 . . . . 5  |-  ( n  =  M  ->  (
( ( ( A ^ ( ( n  -  1 )  / 
2 ) )  +  1 )  mod  n
)  -  1 )  =  ( ( ( ( A ^ (
( M  -  1 )  /  2 ) )  +  1 )  mod  M )  - 
1 ) )
102, 9ifbieq2d 3826 . . . 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 6110 . . . 4  |-  ( n  =  M  ->  (
n  pCnt  N )  =  ( M  pCnt  N ) )
1210, 11oveq12d 6121 . . 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 ) ) )
131, 12ifbieq1d 3824 . 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 ) )
14 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 ) )
15 ovex 6128 . . 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
16 1ex 9393 . . 3  |-  1  e.  _V
1715, 16ifex 3870 . 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
1813, 14, 17fvmpt 5786 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 setvar class
Syntax hints:    -> wi 4    = wceq 1369    e. wcel 1756   ifcif 3803   {cpr 3891   class class class wbr 4304    e. cmpt 4362   ` cfv 5430  (class class class)co 6103   0cc0 9294   1c1 9295    + caddc 9297    - cmin 9607   -ucneg 9608    / cdiv 10005   NNcn 10334   2c2 10383   7c7 10388   8c8 10389    mod cmo 11720   ^cexp 11877    || cdivides 13547   Primecprime 13775    pCnt cpc 13915
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1591  ax-4 1602  ax-5 1670  ax-6 1708  ax-7 1728  ax-9 1760  ax-10 1775  ax-11 1780  ax-12 1792  ax-13 1943  ax-ext 2423  ax-sep 4425  ax-nul 4433  ax-pr 4543  ax-1cn 9352
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3an 967  df-tru 1372  df-ex 1587  df-nf 1590  df-sb 1701  df-eu 2257  df-mo 2258  df-clab 2430  df-cleq 2436  df-clel 2439  df-nfc 2577  df-ne 2620  df-ral 2732  df-rex 2733  df-rab 2736  df-v 2986  df-sbc 3199  df-dif 3343  df-un 3345  df-in 3347  df-ss 3354  df-nul 3650  df-if 3804  df-sn 3890  df-pr 3892  df-op 3896  df-uni 4104  df-br 4305  df-opab 4363  df-mpt 4364  df-id 4648  df-xp 4858  df-rel 4859  df-cnv 4860  df-co 4861  df-dm 4862  df-iota 5393  df-fun 5432  df-fv 5438  df-ov 6106
This theorem is referenced by:  lgsval2lem  22657
  Copyright terms: Public domain W3C validator