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

Theorem sadcp1 12662
Description: The carry sequence (which is a sequence of wffs, encoded as 
1o and  (/)) is defined recursively as the carry operation applied to the previous carry and the two current inputs. (Contributed by Mario Carneiro, 5-Sep-2016.)
Hypotheses
Ref Expression
sadval.a  |-  ( ph  ->  A  C_  NN0 )
sadval.b  |-  ( ph  ->  B  C_  NN0 )
sadval.c  |-  C  =  seq  0 ( ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c ) ,  1o ,  (/) ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) )
sadcp1.n  |-  ( ph  ->  N  e.  NN0 )
Assertion
Ref Expression
sadcp1  |-  ( ph  ->  ( (/)  e.  ( C `  ( N  +  1 ) )  <-> cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ) )
Distinct variable groups:    m, c, n    A, c, m    B, c, m    n, N
Allowed substitution hints:    ph( m, n, c)    A( n)    B( n)    C( m, n, c)    N( m, c)

Proof of Theorem sadcp1
Dummy variables  x  y are mutually distinct and distinct from all other variables.
StepHypRef Expression
1 sadcp1.n . . . . . . 7  |-  ( ph  ->  N  e.  NN0 )
2 nn0uz 10278 . . . . . . 7  |-  NN0  =  ( ZZ>= `  0 )
31, 2syl6eleq 2386 . . . . . 6  |-  ( ph  ->  N  e.  ( ZZ>= ` 
0 ) )
4 seqp1 11077 . . . . . 6  |-  ( N  e.  ( ZZ>= `  0
)  ->  (  seq  0 ( ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/) 
e.  c ) ,  1o ,  (/) ) ) ,  ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) ) `
 ( N  + 
1 ) )  =  ( (  seq  0
( ( c  e.  2o ,  m  e. 
NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/) 
e.  c ) ,  1o ,  (/) ) ) ,  ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) ) `
 N ) ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c ) ,  1o ,  (/) ) ) ( ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) `
 ( N  + 
1 ) ) ) )
53, 4syl 15 . . . . 5  |-  ( ph  ->  (  seq  0 ( ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c ) ,  1o ,  (/) ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) ) `  ( N  +  1 ) )  =  ( (  seq  0 ( ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/) 
e.  c ) ,  1o ,  (/) ) ) ,  ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) ) `
 N ) ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c ) ,  1o ,  (/) ) ) ( ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) `
 ( N  + 
1 ) ) ) )
6 sadval.c . . . . . 6  |-  C  =  seq  0 ( ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c ) ,  1o ,  (/) ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) )
76fveq1i 5542 . . . . 5  |-  ( C `
 ( N  + 
1 ) )  =  (  seq  0 ( ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c ) ,  1o ,  (/) ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) ) `  ( N  +  1 ) )
86fveq1i 5542 . . . . . 6  |-  ( C `
 N )  =  (  seq  0 ( ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c ) ,  1o ,  (/) ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) ) `  N )
98oveq1i 5884 . . . . 5  |-  ( ( C `  N ) ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c ) ,  1o ,  (/) ) ) ( ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) `
 ( N  + 
1 ) ) )  =  ( (  seq  0 ( ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/) 
e.  c ) ,  1o ,  (/) ) ) ,  ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) ) `
 N ) ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c ) ,  1o ,  (/) ) ) ( ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) `
 ( N  + 
1 ) ) )
105, 7, 93eqtr4g 2353 . . . 4  |-  ( ph  ->  ( C `  ( N  +  1 ) )  =  ( ( C `  N ) ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c ) ,  1o ,  (/) ) ) ( ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) `
 ( N  + 
1 ) ) ) )
11 peano2nn0 10020 . . . . . . . 8  |-  ( N  e.  NN0  ->  ( N  +  1 )  e. 
NN0 )
121, 11syl 15 . . . . . . 7  |-  ( ph  ->  ( N  +  1 )  e.  NN0 )
13 eqeq1 2302 . . . . . . . . 9  |-  ( n  =  ( N  + 
1 )  ->  (
n  =  0  <->  ( N  +  1 )  =  0 ) )
14 oveq1 5881 . . . . . . . . 9  |-  ( n  =  ( N  + 
1 )  ->  (
n  -  1 )  =  ( ( N  +  1 )  - 
1 ) )
1513, 14ifbieq2d 3598 . . . . . . . 8  |-  ( n  =  ( N  + 
1 )  ->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) )  =  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  + 
1 )  -  1 ) ) )
16 eqid 2296 . . . . . . . 8  |-  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) )  =  ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) )
17 0ex 4166 . . . . . . . . 9  |-  (/)  e.  _V
18 ovex 5899 . . . . . . . . 9  |-  ( ( N  +  1 )  -  1 )  e. 
_V
1917, 18ifex 3636 . . . . . . . 8  |-  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  +  1 )  - 
1 ) )  e. 
_V
2015, 16, 19fvmpt 5618 . . . . . . 7  |-  ( ( N  +  1 )  e.  NN0  ->  ( ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) `
 ( N  + 
1 ) )  =  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  +  1 )  -  1 ) ) )
2112, 20syl 15 . . . . . 6  |-  ( ph  ->  ( ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) `  ( N  +  1
) )  =  if ( ( N  + 
1 )  =  0 ,  (/) ,  ( ( N  +  1 )  -  1 ) ) )
22 nn0p1nn 10019 . . . . . . . . 9  |-  ( N  e.  NN0  ->  ( N  +  1 )  e.  NN )
231, 22syl 15 . . . . . . . 8  |-  ( ph  ->  ( N  +  1 )  e.  NN )
2423nnne0d 9806 . . . . . . 7  |-  ( ph  ->  ( N  +  1 )  =/=  0 )
25 ifnefalse 3586 . . . . . . 7  |-  ( ( N  +  1 )  =/=  0  ->  if ( ( N  + 
1 )  =  0 ,  (/) ,  ( ( N  +  1 )  -  1 ) )  =  ( ( N  +  1 )  - 
1 ) )
2624, 25syl 15 . . . . . 6  |-  ( ph  ->  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  +  1 )  -  1 ) )  =  ( ( N  +  1 )  -  1 ) )
271nn0cnd 10036 . . . . . . 7  |-  ( ph  ->  N  e.  CC )
28 ax-1cn 8811 . . . . . . . 8  |-  1  e.  CC
2928a1i 10 . . . . . . 7  |-  ( ph  ->  1  e.  CC )
3027, 29pncand 9174 . . . . . 6  |-  ( ph  ->  ( ( N  + 
1 )  -  1 )  =  N )
3121, 26, 303eqtrd 2332 . . . . 5  |-  ( ph  ->  ( ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) `  ( N  +  1
) )  =  N )
3231oveq2d 5890 . . . 4  |-  ( ph  ->  ( ( C `  N ) ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/) 
e.  c ) ,  1o ,  (/) ) ) ( ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) `  ( N  +  1
) ) )  =  ( ( C `  N ) ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/) 
e.  c ) ,  1o ,  (/) ) ) N ) )
33 sadval.a . . . . . . 7  |-  ( ph  ->  A  C_  NN0 )
34 sadval.b . . . . . . 7  |-  ( ph  ->  B  C_  NN0 )
3533, 34, 6sadcf 12660 . . . . . 6  |-  ( ph  ->  C : NN0 --> 2o )
36 ffvelrn 5679 . . . . . 6  |-  ( ( C : NN0 --> 2o  /\  N  e.  NN0 )  -> 
( C `  N
)  e.  2o )
3735, 1, 36syl2anc 642 . . . . 5  |-  ( ph  ->  ( C `  N
)  e.  2o )
38 simpr 447 . . . . . . . . 9  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  y  =  N )
3938eleq1d 2362 . . . . . . . 8  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  ( y  e.  A  <->  N  e.  A ) )
4038eleq1d 2362 . . . . . . . 8  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  ( y  e.  B  <->  N  e.  B ) )
41 simpl 443 . . . . . . . . 9  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  x  =  ( C `
 N ) )
4241eleq2d 2363 . . . . . . . 8  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  ( (/)  e.  x  <->  (/)  e.  ( C `  N
) ) )
4339, 40, 42cadbi123d 1373 . . . . . . 7  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  (cadd ( y  e.  A ,  y  e.  B ,  (/)  e.  x
)  <-> cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ) )
4443ifbid 3596 . . . . . 6  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  if (cadd ( y  e.  A ,  y  e.  B ,  (/)  e.  x ) ,  1o ,  (/) )  =  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `  N ) ) ,  1o ,  (/) ) )
45 biidd 228 . . . . . . . . 9  |-  ( c  =  x  ->  (
m  e.  A  <->  m  e.  A ) )
46 biidd 228 . . . . . . . . 9  |-  ( c  =  x  ->  (
m  e.  B  <->  m  e.  B ) )
47 eleq2 2357 . . . . . . . . 9  |-  ( c  =  x  ->  ( (/) 
e.  c  <->  (/)  e.  x
) )
4845, 46, 47cadbi123d 1373 . . . . . . . 8  |-  ( c  =  x  ->  (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c )  <-> cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  x ) ) )
4948ifbid 3596 . . . . . . 7  |-  ( c  =  x  ->  if (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c ) ,  1o ,  (/) )  =  if (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  x ) ,  1o ,  (/) ) )
50 eleq1 2356 . . . . . . . . 9  |-  ( m  =  y  ->  (
m  e.  A  <->  y  e.  A ) )
51 eleq1 2356 . . . . . . . . 9  |-  ( m  =  y  ->  (
m  e.  B  <->  y  e.  B ) )
52 biidd 228 . . . . . . . . 9  |-  ( m  =  y  ->  ( (/) 
e.  x  <->  (/)  e.  x
) )
5350, 51, 52cadbi123d 1373 . . . . . . . 8  |-  ( m  =  y  ->  (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  x )  <-> cadd ( y  e.  A ,  y  e.  B ,  (/)  e.  x ) ) )
5453ifbid 3596 . . . . . . 7  |-  ( m  =  y  ->  if (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  x ) ,  1o ,  (/) )  =  if (cadd ( y  e.  A ,  y  e.  B ,  (/)  e.  x ) ,  1o ,  (/) ) )
5549, 54cbvmpt2v 5942 . . . . . 6  |-  ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/) 
e.  c ) ,  1o ,  (/) ) )  =  ( x  e.  2o ,  y  e. 
NN0  |->  if (cadd ( y  e.  A , 
y  e.  B ,  (/) 
e.  x ) ,  1o ,  (/) ) )
56 1on 6502 . . . . . . . 8  |-  1o  e.  On
5756elexi 2810 . . . . . . 7  |-  1o  e.  _V
5857, 17ifex 3636 . . . . . 6  |-  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ,  1o ,  (/) )  e.  _V
5944, 55, 58ovmpt2a 5994 . . . . 5  |-  ( ( ( C `  N
)  e.  2o  /\  N  e.  NN0 )  -> 
( ( C `  N ) ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/) 
e.  c ) ,  1o ,  (/) ) ) N )  =  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `  N ) ) ,  1o ,  (/) ) )
6037, 1, 59syl2anc 642 . . . 4  |-  ( ph  ->  ( ( C `  N ) ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  A ,  m  e.  B ,  (/) 
e.  c ) ,  1o ,  (/) ) ) N )  =  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `  N ) ) ,  1o ,  (/) ) )
6110, 32, 603eqtrd 2332 . . 3  |-  ( ph  ->  ( C `  ( N  +  1 ) )  =  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ,  1o ,  (/) ) )
6261eleq2d 2363 . 2  |-  ( ph  ->  ( (/)  e.  ( C `  ( N  +  1 ) )  <->  (/) 
e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) ) ,  1o ,  (/) ) ) )
63 noel 3472 . . . . 5  |-  -.  (/)  e.  (/)
64 iffalse 3585 . . . . . 6  |-  ( -. cadd
( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) )  ->  if (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) ) ,  1o ,  (/) )  =  (/) )
6564eleq2d 2363 . . . . 5  |-  ( -. cadd
( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) )  ->  ( (/)  e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ,  1o ,  (/) ) 
<->  (/)  e.  (/) ) )
6663, 65mtbiri 294 . . . 4  |-  ( -. cadd
( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) )  ->  -.  (/)  e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ,  1o ,  (/) ) )
6766con4i 122 . . 3  |-  ( (/)  e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `  N ) ) ,  1o ,  (/) )  -> cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `  N ) ) )
68 0lt1o 6519 . . . 4  |-  (/)  e.  1o
69 iftrue 3584 . . . 4  |-  (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) )  ->  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `  N ) ) ,  1o ,  (/) )  =  1o )
7068, 69syl5eleqr 2383 . . 3  |-  (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) )  ->  (/) 
e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) ) ,  1o ,  (/) ) )
7167, 70impbii 180 . 2  |-  ( (/)  e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `  N ) ) ,  1o ,  (/) )  <-> cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) )
7262, 71syl6bb 252 1  |-  ( ph  ->  ( (/)  e.  ( C `  ( N  +  1 ) )  <-> cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ) )
Colors of variables: wff set class
Syntax hints:   -. wn 3    -> wi 4    <-> wb 176    /\ wa 358  caddwcad 1369    = wceq 1632    e. wcel 1696    =/= wne 2459    C_ wss 3165   (/)c0 3468   ifcif 3578    e. cmpt 4093   Oncon0 4408   -->wf 5267   ` cfv 5271  (class class class)co 5874    e. cmpt2 5876   1oc1o 6488   2oc2o 6489   CCcc 8751   0cc0 8753   1c1 8754    + caddc 8756    - cmin 9053   NNcn 9762   NN0cn0 9981   ZZ>=cuz 10246    seq cseq 11062
This theorem is referenced by:  sadcaddlem  12664  sadadd2lem  12666  saddisjlem  12671
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1536  ax-5 1547  ax-17 1606  ax-9 1644  ax-8 1661  ax-13 1698  ax-14 1700  ax-6 1715  ax-7 1720  ax-11 1727  ax-12 1878  ax-ext 2277  ax-sep 4157  ax-nul 4165  ax-pow 4204  ax-pr 4230  ax-un 4528  ax-cnex 8809  ax-resscn 8810  ax-1cn 8811  ax-icn 8812  ax-addcl 8813  ax-addrcl 8814  ax-mulcl 8815  ax-mulrcl 8816  ax-mulcom 8817  ax-addass 8818  ax-mulass 8819  ax-distr 8820  ax-i2m1 8821  ax-1ne0 8822  ax-1rid 8823  ax-rnegex 8824  ax-rrecex 8825  ax-cnre 8826  ax-pre-lttri 8827  ax-pre-lttrn 8828  ax-pre-ltadd 8829  ax-pre-mulgt0 8830
This theorem depends on definitions:  df-bi 177  df-or 359  df-an 360  df-3or 935  df-3an 936  df-xor 1296  df-tru 1310  df-cad 1371  df-ex 1532  df-nf 1535  df-sb 1639  df-eu 2160  df-mo 2161  df-clab 2283  df-cleq 2289  df-clel 2292  df-nfc 2421  df-ne 2461  df-nel 2462  df-ral 2561  df-rex 2562  df-reu 2563  df-rab 2565  df-v 2803  df-sbc 3005  df-csb 3095  df-dif 3168  df-un 3170  df-in 3172  df-ss 3179  df-pss 3181  df-nul 3469  df-if 3579  df-pw 3640  df-sn 3659  df-pr 3660  df-tp 3661  df-op 3662  df-uni 3844  df-iun 3923  df-br 4040  df-opab 4094  df-mpt 4095  df-tr 4130  df-eprel 4321  df-id 4325  df-po 4330  df-so 4331  df-fr 4368  df-we 4370  df-ord 4411  df-on 4412  df-lim 4413  df-suc 4414  df-om 4673  df-xp 4711  df-rel 4712  df-cnv 4713  df-co 4714  df-dm 4715  df-rn 4716  df-res 4717  df-ima 4718  df-iota 5235  df-fun 5273  df-fn 5274  df-f 5275  df-f1 5276  df-fo 5277  df-f1o 5278  df-fv 5279  df-ov 5877  df-oprab 5878  df-mpt2 5879  df-1st 6138  df-2nd 6139  df-riota 6320  df-recs 6404  df-rdg 6439  df-1o 6495  df-2o 6496  df-er 6676  df-en 6880  df-dom 6881  df-sdom 6882  df-pnf 8885  df-mnf 8886  df-xr 8887  df-ltxr 8888  df-le 8889  df-sub 9055  df-neg 9056  df-nn 9763  df-n0 9982  df-z 10041  df-uz 10247  df-fz 10799  df-seq 11063
  Copyright terms: Public domain W3C validator