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

Theorem lgsval 22637
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 461 . . . 4  |-  ( ( a  =  A  /\  m  =  N )  ->  m  =  N )
21eqeq1d 2449 . . 3  |-  ( ( a  =  A  /\  m  =  N )  ->  ( m  =  0  <-> 
N  =  0 ) )
3 simpl 457 . . . . . 6  |-  ( ( a  =  A  /\  m  =  N )  ->  a  =  A )
43oveq1d 6104 . . . . 5  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a ^ 2 )  =  ( A ^ 2 ) )
54eqeq1d 2449 . . . 4  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( a ^
2 )  =  1  <-> 
( A ^ 2 )  =  1 ) )
65ifbid 3809 . . 3  |-  ( ( a  =  A  /\  m  =  N )  ->  if ( ( a ^ 2 )  =  1 ,  1 ,  0 )  =  if ( ( A ^
2 )  =  1 ,  1 ,  0 ) )
71breq1d 4300 . . . . . 6  |-  ( ( a  =  A  /\  m  =  N )  ->  ( m  <  0  <->  N  <  0 ) )
83breq1d 4300 . . . . . 6  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a  <  0  <->  A  <  0 ) )
97, 8anbi12d 710 . . . . 5  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( m  <  0  /\  a  <  0 )  <->  ( N  <  0  /\  A  <  0 ) ) )
109ifbid 3809 . . . 4  |-  ( ( a  =  A  /\  m  =  N )  ->  if ( ( m  <  0  /\  a  <  0 ) ,  -u
1 ,  1 )  =  if ( ( N  <  0  /\  A  <  0 ) ,  -u 1 ,  1 ) )
113breq2d 4302 . . . . . . . . . . . 12  |-  ( ( a  =  A  /\  m  =  N )  ->  ( 2  ||  a  <->  2 
||  A ) )
123oveq1d 6104 . . . . . . . . . . . . . 14  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a  mod  8
)  =  ( A  mod  8 ) )
1312eleq1d 2507 . . . . . . . . . . . . 13  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( a  mod  8 )  e.  {
1 ,  7 }  <-> 
( A  mod  8
)  e.  { 1 ,  7 } ) )
1413ifbid 3809 . . . . . . . . . . . 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 3812 . . . . . . . . . . 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 6104 . . . . . . . . . . . . . 14  |-  ( ( a  =  A  /\  m  =  N )  ->  ( a ^ (
( n  -  1 )  /  2 ) )  =  ( A ^ ( ( n  -  1 )  / 
2 ) ) )
1716oveq1d 6104 . . . . . . . . . . . . 13  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( a ^
( ( n  - 
1 )  /  2
) )  +  1 )  =  ( ( A ^ ( ( n  -  1 )  /  2 ) )  +  1 ) )
1817oveq1d 6104 . . . . . . . . . . . 12  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( ( a ^ ( ( n  -  1 )  / 
2 ) )  +  1 )  mod  n
)  =  ( ( ( A ^ (
( n  -  1 )  /  2 ) )  +  1 )  mod  n ) )
1918oveq1d 6104 . . . . . . . . . . 11  |-  ( ( a  =  A  /\  m  =  N )  ->  ( ( ( ( a ^ ( ( n  -  1 )  /  2 ) )  +  1 )  mod  n )  -  1 )  =  ( ( ( ( A ^
( ( n  - 
1 )  /  2
) )  +  1 )  mod  n )  -  1 ) )
2015, 19ifeq12d 3807 . . . . . . . . . 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 6105 . . . . . . . . . 10  |-  ( ( a  =  A  /\  m  =  N )  ->  ( n  pCnt  m
)  =  ( n 
pCnt  N ) )
2220, 21oveq12d 6107 . . . . . . . . 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 3805 . . . . . . . 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 4377 . . . . . . 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 2491 . . . . . 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 11812 . . . . 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 5693 . . . . 5  |-  ( ( a  =  A  /\  m  =  N )  ->  ( abs `  m
)  =  ( abs `  N ) )
2927, 28fveq12d 5695 . . . 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 6107 . . 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 3814 . 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 22632 . 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 10593 . . . . 5  |-  1  e.  NN0
34 0nn0 10592 . . . . 5  |-  0  e.  NN0
3533, 34keepel 3855 . . . 4  |-  if ( ( A ^ 2 )  =  1 ,  1 ,  0 )  e.  NN0
3635elexi 2980 . . 3  |-  if ( ( A ^ 2 )  =  1 ,  1 ,  0 )  e.  _V
37 ovex 6114 . . 3  |-  ( if ( ( N  <  0  /\  A  <  0 ) ,  -u
1 ,  1 )  x.  (  seq 1
(  x.  ,  F
) `  ( abs `  N ) ) )  e.  _V
3836, 37ifex 3856 . 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 6219 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 setvar class
Syntax hints:    -> wi 4    /\ wa 369    = wceq 1369    e. wcel 1756   ifcif 3789   {cpr 3877   class class class wbr 4290    e. cmpt 4348   ` cfv 5416  (class class class)co 6089   0cc0 9280   1c1 9281    + caddc 9283    x. cmul 9285    < clt 9416    - cmin 9593   -ucneg 9594    / cdiv 9991   NNcn 10320   2c2 10369   7c7 10374   8c8 10375   NN0cn0 10577   ZZcz 10644    mod cmo 11706    seqcseq 11804   ^cexp 11863   abscabs 12721    || cdivides 13533   Primecprime 13761    pCnt cpc 13901    /Lclgs 22631
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-8 1758  ax-9 1760  ax-10 1775  ax-11 1780  ax-12 1792  ax-13 1943  ax-ext 2422  ax-sep 4411  ax-nul 4419  ax-pow 4468  ax-pr 4529  ax-un 6370  ax-1cn 9338  ax-icn 9339  ax-addcl 9340  ax-mulcl 9342  ax-i2m1 9348
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 966  df-3an 967  df-tru 1372  df-ex 1587  df-nf 1590  df-sb 1701  df-eu 2257  df-mo 2258  df-clab 2428  df-cleq 2434  df-clel 2437  df-nfc 2566  df-ne 2606  df-ral 2718  df-rex 2719  df-reu 2720  df-rab 2722  df-v 2972  df-sbc 3185  df-csb 3287  df-dif 3329  df-un 3331  df-in 3333  df-ss 3340  df-pss 3342  df-nul 3636  df-if 3790  df-pw 3860  df-sn 3876  df-pr 3878  df-tp 3880  df-op 3882  df-uni 4090  df-iun 4171  df-br 4291  df-opab 4349  df-mpt 4350  df-tr 4384  df-eprel 4630  df-id 4634  df-po 4639  df-so 4640  df-fr 4677  df-we 4679  df-ord 4720  df-on 4721  df-lim 4722  df-suc 4723  df-xp 4844  df-rel 4845  df-cnv 4846  df-co 4847  df-dm 4848  df-rn 4849  df-res 4850  df-ima 4851  df-iota 5379  df-fun 5418  df-fn 5419  df-f 5420  df-f1 5421  df-fo 5422  df-f1o 5423  df-fv 5424  df-ov 6092  df-oprab 6093  df-mpt2 6094  df-om 6475  df-recs 6830  df-rdg 6864  df-nn 10321  df-n0 10578  df-seq 11805  df-lgs 22632
This theorem is referenced by:  lgscllem  22640  lgsval2lem  22643  lgs0  22646  lgsval4  22653
  Copyright terms: Public domain W3C validator