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

Theorem sadcp1 12959
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 10512 . . . . . . 7  |-  NN0  =  ( ZZ>= `  0 )
31, 2syl6eleq 2525 . . . . . 6  |-  ( ph  ->  N  e.  ( ZZ>= ` 
0 ) )
4 seqp1 11330 . . . . . 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 5721 . . . . 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 5721 . . . . . 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 6083 . . . . 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 2492 . . . 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 10252 . . . . . . 7  |-  ( N  e.  NN0  ->  ( N  +  1 )  e. 
NN0 )
12 eqeq1 2441 . . . . . . . . 9  |-  ( n  =  ( N  + 
1 )  ->  (
n  =  0  <->  ( N  +  1 )  =  0 ) )
13 oveq1 6080 . . . . . . . . 9  |-  ( n  =  ( N  + 
1 )  ->  (
n  -  1 )  =  ( ( N  +  1 )  - 
1 ) )
1412, 13ifbieq2d 3751 . . . . . . . 8  |-  ( n  =  ( N  + 
1 )  ->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) )  =  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  + 
1 )  -  1 ) ) )
15 eqid 2435 . . . . . . . 8  |-  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) )  =  ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) )
16 0ex 4331 . . . . . . . . 9  |-  (/)  e.  _V
17 ovex 6098 . . . . . . . . 9  |-  ( ( N  +  1 )  -  1 )  e. 
_V
1816, 17ifex 3789 . . . . . . . 8  |-  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  +  1 )  - 
1 ) )  e. 
_V
1914, 15, 18fvmpt 5798 . . . . . . 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 10251 . . . . . . . . 9  |-  ( N  e.  NN0  ->  ( N  +  1 )  e.  NN )
221, 21syl 16 . . . . . . . 8  |-  ( ph  ->  ( N  +  1 )  e.  NN )
2322nnne0d 10036 . . . . . . 7  |-  ( ph  ->  ( N  +  1 )  =/=  0 )
24 ifnefalse 3739 . . . . . . 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 10268 . . . . . . 7  |-  ( ph  ->  N  e.  CC )
27 ax-1cn 9040 . . . . . . . 8  |-  1  e.  CC
2827a1i 11 . . . . . . 7  |-  ( ph  ->  1  e.  CC )
2926, 28pncand 9404 . . . . . 6  |-  ( ph  ->  ( ( N  + 
1 )  -  1 )  =  N )
3020, 25, 293eqtrd 2471 . . . . 5  |-  ( ph  ->  ( ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) `  ( N  +  1
) )  =  N )
3130oveq2d 6089 . . . 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 12957 . . . . . 6  |-  ( ph  ->  C : NN0 --> 2o )
3534, 1ffvelrnd 5863 . . . . 5  |-  ( ph  ->  ( C `  N
)  e.  2o )
36 simpr 448 . . . . . . . . 9  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  y  =  N )
3736eleq1d 2501 . . . . . . . 8  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  ( y  e.  A  <->  N  e.  A ) )
3836eleq1d 2501 . . . . . . . 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 2502 . . . . . . . 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 3749 . . . . . 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 2496 . . . . . . . . 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 3749 . . . . . . 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 2495 . . . . . . . . 9  |-  ( m  =  y  ->  (
m  e.  A  <->  y  e.  A ) )
49 eleq1 2495 . . . . . . . . 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 3749 . . . . . . 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 6144 . . . . . 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 6723 . . . . . . . 8  |-  1o  e.  On
5554elexi 2957 . . . . . . 7  |-  1o  e.  _V
5655, 16ifex 3789 . . . . . 6  |-  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ,  1o ,  (/) )  e.  _V
5742, 53, 56ovmpt2a 6196 . . . . 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 2471 . . 3  |-  ( ph  ->  ( C `  ( N  +  1 ) )  =  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ,  1o ,  (/) ) )
6059eleq2d 2502 . 2  |-  ( ph  ->  ( (/)  e.  ( C `  ( N  +  1 ) )  <->  (/) 
e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) ) ,  1o ,  (/) ) ) )
61 noel 3624 . . . . 5  |-  -.  (/)  e.  (/)
62 iffalse 3738 . . . . . 6  |-  ( -. cadd
( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) )  ->  if (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) ) ,  1o ,  (/) )  =  (/) )
6362eleq2d 2502 . . . . 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 6740 . . . 4  |-  (/)  e.  1o
67 iftrue 3737 . . . 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 2522 . . 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 2598    C_ wss 3312   (/)c0 3620   ifcif 3731    e. cmpt 4258   Oncon0 4573   ` cfv 5446  (class class class)co 6073    e. cmpt2 6075   1oc1o 6709   2oc2o 6710   CCcc 8980   0cc0 8982   1c1 8983    + caddc 8985    - cmin 9283   NNcn 9992   NN0cn0 10213   ZZ>=cuz 10480    seq cseq 11315
This theorem is referenced by:  sadcaddlem  12961  sadadd2lem  12963  saddisjlem  12968
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-cnex 9038  ax-resscn 9039  ax-1cn 9040  ax-icn 9041  ax-addcl 9042  ax-addrcl 9043  ax-mulcl 9044  ax-mulrcl 9045  ax-mulcom 9046  ax-addass 9047  ax-mulass 9048  ax-distr 9049  ax-i2m1 9050  ax-1ne0 9051  ax-1rid 9052  ax-rnegex 9053  ax-rrecex 9054  ax-cnre 9055  ax-pre-lttri 9056  ax-pre-lttrn 9057  ax-pre-ltadd 9058  ax-pre-mulgt0 9059
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 2284  df-mo 2285  df-clab 2422  df-cleq 2428  df-clel 2431  df-nfc 2560  df-ne 2600  df-nel 2601  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-1st 6341  df-2nd 6342  df-riota 6541  df-recs 6625  df-rdg 6660  df-1o 6716  df-2o 6717  df-er 6897  df-en 7102  df-dom 7103  df-sdom 7104  df-pnf 9114  df-mnf 9115  df-xr 9116  df-ltxr 9117  df-le 9118  df-sub 9285  df-neg 9286  df-nn 9993  df-n0 10214  df-z 10275  df-uz 10481  df-fz 11036  df-seq 11316
  Copyright terms: Public domain W3C validator