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

Theorem lgsval 21076
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 2443 . . 3  |-  ( ( a  =  A  /\  m  =  N )  ->  ( m  =  0  <-> 
N  =  0 ) )
3 simpl 444 . . . . . 6  |-  ( ( a  =  A  /\  m  =  N )  ->  a  =  A )
43oveq1d 6088 . . . . 5  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a ^ 2 )  =  ( A ^ 2 ) )
54eqeq1d 2443 . . . 4  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( a ^
2 )  =  1  <-> 
( A ^ 2 )  =  1 ) )
65ifbid 3749 . . 3  |-  ( ( a  =  A  /\  m  =  N )  ->  if ( ( a ^ 2 )  =  1 ,  1 ,  0 )  =  if ( ( A ^
2 )  =  1 ,  1 ,  0 ) )
71breq1d 4214 . . . . . 6  |-  ( ( a  =  A  /\  m  =  N )  ->  ( m  <  0  <->  N  <  0 ) )
83breq1d 4214 . . . . . 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 3749 . . . 4  |-  ( ( a  =  A  /\  m  =  N )  ->  if ( ( m  <  0  /\  a  <  0 ) ,  -u
1 ,  1 )  =  if ( ( N  <  0  /\  A  <  0 ) ,  -u 1 ,  1 ) )
113breq2d 4216 . . . . . . . . . . . 12  |-  ( ( a  =  A  /\  m  =  N )  ->  ( 2  ||  a  <->  2 
||  A ) )
123oveq1d 6088 . . . . . . . . . . . . . 14  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a  mod  8
)  =  ( A  mod  8 ) )
1312eleq1d 2501 . . . . . . . . . . . . 13  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( a  mod  8 )  e.  {
1 ,  7 }  <-> 
( A  mod  8
)  e.  { 1 ,  7 } ) )
1413ifbid 3749 . . . . . . . . . . . 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 3751 . . . . . . . . . . 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 6088 . . . . . . . . . . . . . 14  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a ^ (
( n  -  1 )  /  2 ) )  =  ( A ^ ( ( n  -  1 )  / 
2 ) ) )
1716oveq1d 6088 . . . . . . . . . . . . 13  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( a ^
( ( n  - 
1 )  /  2
) )  +  1 )  =  ( ( A ^ ( ( n  -  1 )  /  2 ) )  +  1 ) )
1817oveq1d 6088 . . . . . . . . . . . 12  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( ( a ^ ( ( n  -  1 )  / 
2 ) )  +  1 )  mod  n
)  =  ( ( ( A ^ (
( n  -  1 )  /  2 ) )  +  1 )  mod  n ) )
1918oveq1d 6088 . . . . . . . . . . 11  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( ( ( a ^ ( ( n  -  1 )  /  2 ) )  +  1 )  mod  n )  -  1 )  =  ( ( ( ( A ^
( ( n  - 
1 )  /  2
) )  +  1 )  mod  n )  -  1 ) )
2015, 19ifeq12d 3747 . . . . . . . . . 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 6089 . . . . . . . . . 10  |-  ( ( a  =  A  /\  m  =  N )  ->  ( n  pCnt  m
)  =  ( n 
pCnt  N ) )
2220, 21oveq12d 6091 . . . . . . . . 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 3745 . . . . . . . 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 4288 . . . . . . 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 2485 . . . . . 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 11323 . . . . 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 5724 . . . . 5  |-  ( ( a  =  A  /\  m  =  N )  ->  ( abs `  m
)  =  ( abs `  N ) )
2927, 28fveq12d 5726 . . . 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 6091 . . 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 3753 . 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 21071 . 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 10229 . . . . 5  |-  1  e.  NN0
34 0nn0 10228 . . . . 5  |-  0  e.  NN0
3533, 34keepel 3788 . . . 4  |-  if ( ( A ^ 2 )  =  1 ,  1 ,  0 )  e.  NN0
3635elexi 2957 . . 3  |-  if ( ( A ^ 2 )  =  1 ,  1 ,  0 )  e.  _V
37 ovex 6098 . . 3  |-  ( if ( ( N  <  0  /\  A  <  0 ) ,  -u
1 ,  1 )  x.  (  seq  1
(  x.  ,  F
) `  ( abs `  N ) ) )  e.  _V
3836, 37ifex 3789 . 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 6196 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 1652    e. wcel 1725   ifcif 3731   {cpr 3807   class class class wbr 4204    e. cmpt 4258   ` cfv 5446  (class class class)co 6073   0cc0 8982   1c1 8983    + caddc 8985    x. cmul 8987    < clt 9112    - cmin 9283   -ucneg 9284    / cdiv 9669   NNcn 9992   2c2 10041   7c7 10046   8c8 10047   NN0cn0 10213   ZZcz 10274    mod cmo 11242    seq cseq 11315   ^cexp 11374   abscabs 12031    || cdivides 12844   Primecprime 13071    pCnt cpc 13202    / Lclgs 21070
This theorem is referenced by:  lgscllem  21079  lgsval2lem  21082  lgs0  21085  lgsval4  21092
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1555  ax-5 1566  ax-17 1626  ax-9 1666  ax-8 1687  ax-13 1727  ax-14 1729  ax-6 1744  ax-7 1749  ax-11 1761  ax-12 1950  ax-ext 2416  ax-sep 4322  ax-nul 4330  ax-pow 4369  ax-pr 4395  ax-un 4693  ax-1cn 9040  ax-icn 9041  ax-addcl 9042  ax-mulcl 9044  ax-i2m1 9050
This theorem depends on definitions:  df-bi 178  df-or 360  df-an 361  df-3or 937  df-3an 938  df-tru 1328  df-ex 1551  df-nf 1554  df-sb 1659  df-eu 2284  df-mo 2285  df-clab 2422  df-cleq 2428  df-clel 2431  df-nfc 2560  df-ne 2600  df-ral 2702  df-rex 2703  df-reu 2704  df-rab 2706  df-v 2950  df-sbc 3154  df-csb 3244  df-dif 3315  df-un 3317  df-in 3319  df-ss 3326  df-pss 3328  df-nul 3621  df-if 3732  df-pw 3793  df-sn 3812  df-pr 3813  df-tp 3814  df-op 3815  df-uni 4008  df-iun 4087  df-br 4205  df-opab 4259  df-mpt 4260  df-tr 4295  df-eprel 4486  df-id 4490  df-po 4495  df-so 4496  df-fr 4533  df-we 4535  df-ord 4576  df-on 4577  df-lim 4578  df-suc 4579  df-om 4838  df-xp 4876  df-rel 4877  df-cnv 4878  df-co 4879  df-dm 4880  df-rn 4881  df-res 4882  df-ima 4883  df-iota 5410  df-fun 5448  df-fn 5449  df-f 5450  df-f1 5451  df-fo 5452  df-f1o 5453  df-fv 5454  df-ov 6076  df-oprab 6077  df-mpt2 6078  df-recs 6625  df-rdg 6660  df-nn 9993  df-n0 10214  df-seq 11316  df-lgs 21071
  Copyright terms: Public domain W3C validator