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

Theorem sadcp1 12646
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 10262 . . . . . . 7  |-  NN0  =  ( ZZ>= `  0 )
31, 2syl6eleq 2373 . . . . . 6  |-  ( ph  ->  N  e.  ( ZZ>= ` 
0 ) )
4 seqp1 11061 . . . . . 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 5526 . . . . 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 5526 . . . . . 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 5868 . . . . 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 2340 . . . 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 10004 . . . . . . . 8  |-  ( N  e.  NN0  ->  ( N  +  1 )  e. 
NN0 )
121, 11syl 15 . . . . . . 7  |-  ( ph  ->  ( N  +  1 )  e.  NN0 )
13 eqeq1 2289 . . . . . . . . 9  |-  ( n  =  ( N  + 
1 )  ->  (
n  =  0  <->  ( N  +  1 )  =  0 ) )
14 oveq1 5865 . . . . . . . . 9  |-  ( n  =  ( N  + 
1 )  ->  (
n  -  1 )  =  ( ( N  +  1 )  - 
1 ) )
1513, 14ifbieq2d 3585 . . . . . . . 8  |-  ( n  =  ( N  + 
1 )  ->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) )  =  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  + 
1 )  -  1 ) ) )
16 eqid 2283 . . . . . . . 8  |-  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) )  =  ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) )
17 0ex 4150 . . . . . . . . 9  |-  (/)  e.  _V
18 ovex 5883 . . . . . . . . 9  |-  ( ( N  +  1 )  -  1 )  e. 
_V
1917, 18ifex 3623 . . . . . . . 8  |-  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  +  1 )  - 
1 ) )  e. 
_V
2015, 16, 19fvmpt 5602 . . . . . . 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 10003 . . . . . . . . 9  |-  ( N  e.  NN0  ->  ( N  +  1 )  e.  NN )
231, 22syl 15 . . . . . . . 8  |-  ( ph  ->  ( N  +  1 )  e.  NN )
2423nnne0d 9790 . . . . . . 7  |-  ( ph  ->  ( N  +  1 )  =/=  0 )
25 ifnefalse 3573 . . . . . . 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 10020 . . . . . . 7  |-  ( ph  ->  N  e.  CC )
28 ax-1cn 8795 . . . . . . . 8  |-  1  e.  CC
2928a1i 10 . . . . . . 7  |-  ( ph  ->  1  e.  CC )
3027, 29pncand 9158 . . . . . 6  |-  ( ph  ->  ( ( N  + 
1 )  -  1 )  =  N )
3121, 26, 303eqtrd 2319 . . . . 5  |-  ( ph  ->  ( ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) `  ( N  +  1
) )  =  N )
3231oveq2d 5874 . . . 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 12644 . . . . . 6  |-  ( ph  ->  C : NN0 --> 2o )
36 ffvelrn 5663 . . . . . 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 2349 . . . . . . . 8  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  ( y  e.  A  <->  N  e.  A ) )
4038eleq1d 2349 . . . . . . . 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 2350 . . . . . . . 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 3583 . . . . . 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 2344 . . . . . . . . 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 3583 . . . . . . 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 2343 . . . . . . . . 9  |-  ( m  =  y  ->  (
m  e.  A  <->  y  e.  A ) )
51 eleq1 2343 . . . . . . . . 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 3583 . . . . . . 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 5926 . . . . . 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 6486 . . . . . . . 8  |-  1o  e.  On
5756elexi 2797 . . . . . . 7  |-  1o  e.  _V
5857, 17ifex 3623 . . . . . 6  |-  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ,  1o ,  (/) )  e.  _V
5944, 55, 58ovmpt2a 5978 . . . . 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 2319 . . 3  |-  ( ph  ->  ( C `  ( N  +  1 ) )  =  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ,  1o ,  (/) ) )
6261eleq2d 2350 . 2  |-  ( ph  ->  ( (/)  e.  ( C `  ( N  +  1 ) )  <->  (/) 
e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) ) ,  1o ,  (/) ) ) )
63 noel 3459 . . . . 5  |-  -.  (/)  e.  (/)
64 iffalse 3572 . . . . . 6  |-  ( -. cadd
( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) )  ->  if (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) ) ,  1o ,  (/) )  =  (/) )
6564eleq2d 2350 . . . . 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 6503 . . . 4  |-  (/)  e.  1o
69 iftrue 3571 . . . 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 2370 . . 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 1623    e. wcel 1684    =/= wne 2446    C_ wss 3152   (/)c0 3455   ifcif 3565    e. cmpt 4077   Oncon0 4392   -->wf 5251   ` cfv 5255  (class class class)co 5858    e. cmpt2 5860   1oc1o 6472   2oc2o 6473   CCcc 8735   0cc0 8737   1c1 8738    + caddc 8740    - cmin 9037   NNcn 9746   NN0cn0 9965   ZZ>=cuz 10230    seq cseq 11046
This theorem is referenced by:  sadcaddlem  12648  sadadd2lem  12650  saddisjlem  12655
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-13 1686  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-pow 4188  ax-pr 4214  ax-un 4512  ax-cnex 8793  ax-resscn 8794  ax-1cn 8795  ax-icn 8796  ax-addcl 8797  ax-addrcl 8798  ax-mulcl 8799  ax-mulrcl 8800  ax-mulcom 8801  ax-addass 8802  ax-mulass 8803  ax-distr 8804  ax-i2m1 8805  ax-1ne0 8806  ax-1rid 8807  ax-rnegex 8808  ax-rrecex 8809  ax-cnre 8810  ax-pre-lttri 8811  ax-pre-lttrn 8812  ax-pre-ltadd 8813  ax-pre-mulgt0 8814
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 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-nel 2449  df-ral 2548  df-rex 2549  df-reu 2550  df-rab 2552  df-v 2790  df-sbc 2992  df-csb 3082  df-dif 3155  df-un 3157  df-in 3159  df-ss 3166  df-pss 3168  df-nul 3456  df-if 3566  df-pw 3627  df-sn 3646  df-pr 3647  df-tp 3648  df-op 3649  df-uni 3828  df-iun 3907  df-br 4024  df-opab 4078  df-mpt 4079  df-tr 4114  df-eprel 4305  df-id 4309  df-po 4314  df-so 4315  df-fr 4352  df-we 4354  df-ord 4395  df-on 4396  df-lim 4397  df-suc 4398  df-om 4657  df-xp 4695  df-rel 4696  df-cnv 4697  df-co 4698  df-dm 4699  df-rn 4700  df-res 4701  df-ima 4702  df-iota 5219  df-fun 5257  df-fn 5258  df-f 5259  df-f1 5260  df-fo 5261  df-f1o 5262  df-fv 5263  df-ov 5861  df-oprab 5862  df-mpt2 5863  df-1st 6122  df-2nd 6123  df-riota 6304  df-recs 6388  df-rdg 6423  df-1o 6479  df-2o 6480  df-er 6660  df-en 6864  df-dom 6865  df-sdom 6866  df-pnf 8869  df-mnf 8870  df-xr 8871  df-ltxr 8872  df-le 8873  df-sub 9039  df-neg 9040  df-nn 9747  df-n0 9966  df-z 10025  df-uz 10231  df-fz 10783  df-seq 11047
  Copyright terms: Public domain W3C validator