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

Theorem sadcp1 12967
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 10520 . . . . . . 7  |-  NN0  =  ( ZZ>= `  0 )
31, 2syl6eleq 2526 . . . . . 6  |-  ( ph  ->  N  e.  ( ZZ>= ` 
0 ) )
4 seqp1 11338 . . . . . 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 16 . . . . 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 5729 . . . . 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 5729 . . . . . 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 6091 . . . . 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 2493 . . . 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 10260 . . . . . . 7  |-  ( N  e.  NN0  ->  ( N  +  1 )  e. 
NN0 )
12 eqeq1 2442 . . . . . . . . 9  |-  ( n  =  ( N  + 
1 )  ->  (
n  =  0  <->  ( N  +  1 )  =  0 ) )
13 oveq1 6088 . . . . . . . . 9  |-  ( n  =  ( N  + 
1 )  ->  (
n  -  1 )  =  ( ( N  +  1 )  - 
1 ) )
1412, 13ifbieq2d 3759 . . . . . . . 8  |-  ( n  =  ( N  + 
1 )  ->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) )  =  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  + 
1 )  -  1 ) ) )
15 eqid 2436 . . . . . . . 8  |-  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) )  =  ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) )
16 0ex 4339 . . . . . . . . 9  |-  (/)  e.  _V
17 ovex 6106 . . . . . . . . 9  |-  ( ( N  +  1 )  -  1 )  e. 
_V
1816, 17ifex 3797 . . . . . . . 8  |-  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  +  1 )  - 
1 ) )  e. 
_V
1914, 15, 18fvmpt 5806 . . . . . . 7  |-  ( ( N  +  1 )  e.  NN0  ->  ( ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) `
 ( N  + 
1 ) )  =  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  +  1 )  -  1 ) ) )
201, 11, 193syl 19 . . . . . 6  |-  ( ph  ->  ( ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) `  ( N  +  1
) )  =  if ( ( N  + 
1 )  =  0 ,  (/) ,  ( ( N  +  1 )  -  1 ) ) )
21 nn0p1nn 10259 . . . . . . . . 9  |-  ( N  e.  NN0  ->  ( N  +  1 )  e.  NN )
221, 21syl 16 . . . . . . . 8  |-  ( ph  ->  ( N  +  1 )  e.  NN )
2322nnne0d 10044 . . . . . . 7  |-  ( ph  ->  ( N  +  1 )  =/=  0 )
24 ifnefalse 3747 . . . . . . 7  |-  ( ( N  +  1 )  =/=  0  ->  if ( ( N  + 
1 )  =  0 ,  (/) ,  ( ( N  +  1 )  -  1 ) )  =  ( ( N  +  1 )  - 
1 ) )
2523, 24syl 16 . . . . . 6  |-  ( ph  ->  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  +  1 )  -  1 ) )  =  ( ( N  +  1 )  -  1 ) )
261nn0cnd 10276 . . . . . . 7  |-  ( ph  ->  N  e.  CC )
27 ax-1cn 9048 . . . . . . . 8  |-  1  e.  CC
2827a1i 11 . . . . . . 7  |-  ( ph  ->  1  e.  CC )
2926, 28pncand 9412 . . . . . 6  |-  ( ph  ->  ( ( N  + 
1 )  -  1 )  =  N )
3020, 25, 293eqtrd 2472 . . . . 5  |-  ( ph  ->  ( ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) `  ( N  +  1
) )  =  N )
3130oveq2d 6097 . . . 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 ) )
32 sadval.a . . . . . . 7  |-  ( ph  ->  A  C_  NN0 )
33 sadval.b . . . . . . 7  |-  ( ph  ->  B  C_  NN0 )
3432, 33, 6sadcf 12965 . . . . . 6  |-  ( ph  ->  C : NN0 --> 2o )
3534, 1ffvelrnd 5871 . . . . 5  |-  ( ph  ->  ( C `  N
)  e.  2o )
36 simpr 448 . . . . . . . . 9  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  y  =  N )
3736eleq1d 2502 . . . . . . . 8  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  ( y  e.  A  <->  N  e.  A ) )
3836eleq1d 2502 . . . . . . . 8  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  ( y  e.  B  <->  N  e.  B ) )
39 simpl 444 . . . . . . . . 9  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  x  =  ( C `
 N ) )
4039eleq2d 2503 . . . . . . . 8  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  ( (/)  e.  x  <->  (/)  e.  ( C `  N
) ) )
4137, 38, 40cadbi123d 1392 . . . . . . 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 ) ) ) )
4241ifbid 3757 . . . . . 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 ,  (/) ) )
43 biidd 229 . . . . . . . . 9  |-  ( c  =  x  ->  (
m  e.  A  <->  m  e.  A ) )
44 biidd 229 . . . . . . . . 9  |-  ( c  =  x  ->  (
m  e.  B  <->  m  e.  B ) )
45 eleq2 2497 . . . . . . . . 9  |-  ( c  =  x  ->  ( (/) 
e.  c  <->  (/)  e.  x
) )
4643, 44, 45cadbi123d 1392 . . . . . . . 8  |-  ( c  =  x  ->  (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c )  <-> cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  x ) ) )
4746ifbid 3757 . . . . . . 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 ,  (/) ) )
48 eleq1 2496 . . . . . . . . 9  |-  ( m  =  y  ->  (
m  e.  A  <->  y  e.  A ) )
49 eleq1 2496 . . . . . . . . 9  |-  ( m  =  y  ->  (
m  e.  B  <->  y  e.  B ) )
50 biidd 229 . . . . . . . . 9  |-  ( m  =  y  ->  ( (/) 
e.  x  <->  (/)  e.  x
) )
5148, 49, 50cadbi123d 1392 . . . . . . . 8  |-  ( m  =  y  ->  (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  x )  <-> cadd ( y  e.  A ,  y  e.  B ,  (/)  e.  x ) ) )
5251ifbid 3757 . . . . . . 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 ,  (/) ) )
5347, 52cbvmpt2v 6152 . . . . . 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 ,  (/) ) )
54 1on 6731 . . . . . . . 8  |-  1o  e.  On
5554elexi 2965 . . . . . . 7  |-  1o  e.  _V
5655, 16ifex 3797 . . . . . 6  |-  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ,  1o ,  (/) )  e.  _V
5742, 53, 56ovmpt2a 6204 . . . . 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 ,  (/) ) )
5835, 1, 57syl2anc 643 . . . 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 ,  (/) ) )
5910, 31, 583eqtrd 2472 . . 3  |-  ( ph  ->  ( C `  ( N  +  1 ) )  =  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ,  1o ,  (/) ) )
6059eleq2d 2503 . 2  |-  ( ph  ->  ( (/)  e.  ( C `  ( N  +  1 ) )  <->  (/) 
e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) ) ,  1o ,  (/) ) ) )
61 noel 3632 . . . . 5  |-  -.  (/)  e.  (/)
62 iffalse 3746 . . . . . 6  |-  ( -. cadd
( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) )  ->  if (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) ) ,  1o ,  (/) )  =  (/) )
6362eleq2d 2503 . . . . 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.  (/) ) )
6461, 63mtbiri 295 . . . 4  |-  ( -. cadd
( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) )  ->  -.  (/)  e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ,  1o ,  (/) ) )
6564con4i 124 . . 3  |-  ( (/)  e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `  N ) ) ,  1o ,  (/) )  -> cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `  N ) ) )
66 0lt1o 6748 . . . 4  |-  (/)  e.  1o
67 iftrue 3745 . . . 4  |-  (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) )  ->  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `  N ) ) ,  1o ,  (/) )  =  1o )
6866, 67syl5eleqr 2523 . . 3  |-  (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) )  ->  (/) 
e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) ) ,  1o ,  (/) ) )
6965, 68impbii 181 . 2  |-  ( (/)  e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `  N ) ) ,  1o ,  (/) )  <-> cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) )
7060, 69syl6bb 253 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 177    /\ wa 359  caddwcad 1388    = wceq 1652    e. wcel 1725    =/= wne 2599    C_ wss 3320   (/)c0 3628   ifcif 3739    e. cmpt 4266   Oncon0 4581   ` cfv 5454  (class class class)co 6081    e. cmpt2 6083   1oc1o 6717   2oc2o 6718   CCcc 8988   0cc0 8990   1c1 8991    + caddc 8993    - cmin 9291   NNcn 10000   NN0cn0 10221   ZZ>=cuz 10488    seq cseq 11323
This theorem is referenced by:  sadcaddlem  12969  sadadd2lem  12971  saddisjlem  12976
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 2417  ax-sep 4330  ax-nul 4338  ax-pow 4377  ax-pr 4403  ax-un 4701  ax-cnex 9046  ax-resscn 9047  ax-1cn 9048  ax-icn 9049  ax-addcl 9050  ax-addrcl 9051  ax-mulcl 9052  ax-mulrcl 9053  ax-mulcom 9054  ax-addass 9055  ax-mulass 9056  ax-distr 9057  ax-i2m1 9058  ax-1ne0 9059  ax-1rid 9060  ax-rnegex 9061  ax-rrecex 9062  ax-cnre 9063  ax-pre-lttri 9064  ax-pre-lttrn 9065  ax-pre-ltadd 9066  ax-pre-mulgt0 9067
This theorem depends on definitions:  df-bi 178  df-or 360  df-an 361  df-3or 937  df-3an 938  df-xor 1314  df-tru 1328  df-cad 1390  df-ex 1551  df-nf 1554  df-sb 1659  df-eu 2285  df-mo 2286  df-clab 2423  df-cleq 2429  df-clel 2432  df-nfc 2561  df-ne 2601  df-nel 2602  df-ral 2710  df-rex 2711  df-reu 2712  df-rab 2714  df-v 2958  df-sbc 3162  df-csb 3252  df-dif 3323  df-un 3325  df-in 3327  df-ss 3334  df-pss 3336  df-nul 3629  df-if 3740  df-pw 3801  df-sn 3820  df-pr 3821  df-tp 3822  df-op 3823  df-uni 4016  df-iun 4095  df-br 4213  df-opab 4267  df-mpt 4268  df-tr 4303  df-eprel 4494  df-id 4498  df-po 4503  df-so 4504  df-fr 4541  df-we 4543  df-ord 4584  df-on 4585  df-lim 4586  df-suc 4587  df-om 4846  df-xp 4884  df-rel 4885  df-cnv 4886  df-co 4887  df-dm 4888  df-rn 4889  df-res 4890  df-ima 4891  df-iota 5418  df-fun 5456  df-fn 5457  df-f 5458  df-f1 5459  df-fo 5460  df-f1o 5461  df-fv 5462  df-ov 6084  df-oprab 6085  df-mpt2 6086  df-1st 6349  df-2nd 6350  df-riota 6549  df-recs 6633  df-rdg 6668  df-1o 6724  df-2o 6725  df-er 6905  df-en 7110  df-dom 7111  df-sdom 7112  df-pnf 9122  df-mnf 9123  df-xr 9124  df-ltxr 9125  df-le 9126  df-sub 9293  df-neg 9294  df-nn 10001  df-n0 10222  df-z 10283  df-uz 10489  df-fz 11044  df-seq 11324
  Copyright terms: Public domain W3C validator