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

Theorem sadcp1 13643
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 10887 . . . . . . 7  |-  NN0  =  ( ZZ>= `  0 )
31, 2syl6eleq 2528 . . . . . 6  |-  ( ph  ->  N  e.  ( ZZ>= ` 
0 ) )
4 seqp1 11813 . . . . . 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 5687 . . . . 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 5687 . . . . . 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 6096 . . . . 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 2495 . . . 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 10612 . . . . . . 7  |-  ( N  e.  NN0  ->  ( N  +  1 )  e. 
NN0 )
12 eqeq1 2444 . . . . . . . . 9  |-  ( n  =  ( N  + 
1 )  ->  (
n  =  0  <->  ( N  +  1 )  =  0 ) )
13 oveq1 6093 . . . . . . . . 9  |-  ( n  =  ( N  + 
1 )  ->  (
n  -  1 )  =  ( ( N  +  1 )  - 
1 ) )
1412, 13ifbieq2d 3809 . . . . . . . 8  |-  ( n  =  ( N  + 
1 )  ->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) )  =  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  + 
1 )  -  1 ) ) )
15 eqid 2438 . . . . . . . 8  |-  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) )  =  ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) )
16 0ex 4417 . . . . . . . . 9  |-  (/)  e.  _V
17 ovex 6111 . . . . . . . . 9  |-  ( ( N  +  1 )  -  1 )  e. 
_V
1816, 17ifex 3853 . . . . . . . 8  |-  if ( ( N  +  1 )  =  0 ,  (/) ,  ( ( N  +  1 )  - 
1 ) )  e. 
_V
1914, 15, 18fvmpt 5769 . . . . . . 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 20 . . . . . 6  |-  ( ph  ->  ( ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) `  ( N  +  1
) )  =  if ( ( N  + 
1 )  =  0 ,  (/) ,  ( ( N  +  1 )  -  1 ) ) )
21 nn0p1nn 10611 . . . . . . . . 9  |-  ( N  e.  NN0  ->  ( N  +  1 )  e.  NN )
221, 21syl 16 . . . . . . . 8  |-  ( ph  ->  ( N  +  1 )  e.  NN )
2322nnne0d 10358 . . . . . . 7  |-  ( ph  ->  ( N  +  1 )  =/=  0 )
24 ifnefalse 3796 . . . . . . 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 10630 . . . . . . 7  |-  ( ph  ->  N  e.  CC )
27 ax-1cn 9332 . . . . . . . 8  |-  1  e.  CC
2827a1i 11 . . . . . . 7  |-  ( ph  ->  1  e.  CC )
2926, 28pncand 9712 . . . . . 6  |-  ( ph  ->  ( ( N  + 
1 )  -  1 )  =  N )
3020, 25, 293eqtrd 2474 . . . . 5  |-  ( ph  ->  ( ( n  e. 
NN0  |->  if ( n  =  0 ,  (/) ,  ( n  -  1 ) ) ) `  ( N  +  1
) )  =  N )
3130oveq2d 6102 . . . 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 13641 . . . . . 6  |-  ( ph  ->  C : NN0 --> 2o )
3534, 1ffvelrnd 5839 . . . . 5  |-  ( ph  ->  ( C `  N
)  e.  2o )
36 simpr 461 . . . . . . . . 9  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  y  =  N )
3736eleq1d 2504 . . . . . . . 8  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  ( y  e.  A  <->  N  e.  A ) )
3836eleq1d 2504 . . . . . . . 8  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  ( y  e.  B  <->  N  e.  B ) )
39 simpl 457 . . . . . . . . 9  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  x  =  ( C `
 N ) )
4039eleq2d 2505 . . . . . . . 8  |-  ( ( x  =  ( C `
 N )  /\  y  =  N )  ->  ( (/)  e.  x  <->  (/)  e.  ( C `  N
) ) )
4137, 38, 40cadbi123d 1424 . . . . . . 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 3806 . . . . . 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 237 . . . . . . . . 9  |-  ( c  =  x  ->  (
m  e.  A  <->  m  e.  A ) )
44 biidd 237 . . . . . . . . 9  |-  ( c  =  x  ->  (
m  e.  B  <->  m  e.  B ) )
45 eleq2 2499 . . . . . . . . 9  |-  ( c  =  x  ->  ( (/) 
e.  c  <->  (/)  e.  x
) )
4643, 44, 45cadbi123d 1424 . . . . . . . 8  |-  ( c  =  x  ->  (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  c )  <-> cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  x ) ) )
4746ifbid 3806 . . . . . . 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 2498 . . . . . . . . 9  |-  ( m  =  y  ->  (
m  e.  A  <->  y  e.  A ) )
49 eleq1 2498 . . . . . . . . 9  |-  ( m  =  y  ->  (
m  e.  B  <->  y  e.  B ) )
50 biidd 237 . . . . . . . . 9  |-  ( m  =  y  ->  ( (/) 
e.  x  <->  (/)  e.  x
) )
5148, 49, 50cadbi123d 1424 . . . . . . . 8  |-  ( m  =  y  ->  (cadd ( m  e.  A ,  m  e.  B ,  (/)  e.  x )  <-> cadd ( y  e.  A ,  y  e.  B ,  (/)  e.  x ) ) )
5251ifbid 3806 . . . . . . 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 6161 . . . . . 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 6919 . . . . . . . 8  |-  1o  e.  On
5554elexi 2977 . . . . . . 7  |-  1o  e.  _V
5655, 16ifex 3853 . . . . . 6  |-  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ,  1o ,  (/) )  e.  _V
5742, 53, 56ovmpt2a 6216 . . . . 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 661 . . . 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 2474 . . 3  |-  ( ph  ->  ( C `  ( N  +  1 ) )  =  if (cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ,  1o ,  (/) ) )
6059eleq2d 2505 . 2  |-  ( ph  ->  ( (/)  e.  ( C `  ( N  +  1 ) )  <->  (/) 
e.  if (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) ) ,  1o ,  (/) ) ) )
61 noel 3636 . . . . 5  |-  -.  (/)  e.  (/)
62 iffalse 3794 . . . . . 6  |-  ( -. cadd
( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) )  ->  if (cadd ( N  e.  A ,  N  e.  B ,  (/) 
e.  ( C `  N ) ) ,  1o ,  (/) )  =  (/) )
6362eleq2d 2505 . . . . 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 303 . . . 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 130 . . 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 6936 . . . 4  |-  (/)  e.  1o
67 iftrue 3792 . . . 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 2525 . . 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 188 . 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 261 1  |-  ( ph  ->  ( (/)  e.  ( C `  ( N  +  1 ) )  <-> cadd ( N  e.  A ,  N  e.  B ,  (/)  e.  ( C `
 N ) ) ) )
Colors of variables: wff setvar class
Syntax hints:   -. wn 3    -> wi 4    <-> wb 184    /\ wa 369    = wceq 1369  caddwcad 1420    e. wcel 1756    =/= wne 2601    C_ wss 3323   (/)c0 3632   ifcif 3786    e. cmpt 4345   Oncon0 4714   ` cfv 5413  (class class class)co 6086    e. cmpt2 6088   1oc1o 6905   2oc2o 6906   CCcc 9272   0cc0 9274   1c1 9275    + caddc 9277    - cmin 9587   NNcn 10314   NN0cn0 10571   ZZ>=cuz 10853    seqcseq 11798
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 2419  ax-sep 4408  ax-nul 4416  ax-pow 4465  ax-pr 4526  ax-un 6367  ax-cnex 9330  ax-resscn 9331  ax-1cn 9332  ax-icn 9333  ax-addcl 9334  ax-addrcl 9335  ax-mulcl 9336  ax-mulrcl 9337  ax-mulcom 9338  ax-addass 9339  ax-mulass 9340  ax-distr 9341  ax-i2m1 9342  ax-1ne0 9343  ax-1rid 9344  ax-rnegex 9345  ax-rrecex 9346  ax-cnre 9347  ax-pre-lttri 9348  ax-pre-lttrn 9349  ax-pre-ltadd 9350  ax-pre-mulgt0 9351
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 966  df-3an 967  df-xor 1351  df-tru 1372  df-cad 1422  df-ex 1587  df-nf 1590  df-sb 1701  df-eu 2256  df-mo 2257  df-clab 2425  df-cleq 2431  df-clel 2434  df-nfc 2563  df-ne 2603  df-nel 2604  df-ral 2715  df-rex 2716  df-reu 2717  df-rab 2719  df-v 2969  df-sbc 3182  df-csb 3284  df-dif 3326  df-un 3328  df-in 3330  df-ss 3337  df-pss 3339  df-nul 3633  df-if 3787  df-pw 3857  df-sn 3873  df-pr 3875  df-tp 3877  df-op 3879  df-uni 4087  df-iun 4168  df-br 4288  df-opab 4346  df-mpt 4347  df-tr 4381  df-eprel 4627  df-id 4631  df-po 4636  df-so 4637  df-fr 4674  df-we 4676  df-ord 4717  df-on 4718  df-lim 4719  df-suc 4720  df-xp 4841  df-rel 4842  df-cnv 4843  df-co 4844  df-dm 4845  df-rn 4846  df-res 4847  df-ima 4848  df-iota 5376  df-fun 5415  df-fn 5416  df-f 5417  df-f1 5418  df-fo 5419  df-f1o 5420  df-fv 5421  df-riota 6047  df-ov 6089  df-oprab 6090  df-mpt2 6091  df-om 6472  df-1st 6572  df-2nd 6573  df-recs 6824  df-rdg 6858  df-1o 6912  df-2o 6913  df-er 7093  df-en 7303  df-dom 7304  df-sdom 7305  df-pnf 9412  df-mnf 9413  df-xr 9414  df-ltxr 9415  df-le 9416  df-sub 9589  df-neg 9590  df-nn 10315  df-n0 10572  df-z 10639  df-uz 10854  df-fz 11430  df-seq 11799
This theorem is referenced by:  sadcaddlem  13645  sadadd2lem  13647  saddisjlem  13652
  Copyright terms: Public domain W3C validator