Metamath Proof Explorer


Theorem sadcp1

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)

Ref Expression
Hypotheses sadval.a φA0
sadval.b φB0
sadval.c C=seq0c2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1
sadcp1.n φN0
Assertion sadcp1 φCN+1caddNANBCN

Proof

Step Hyp Ref Expression
1 sadval.a φA0
2 sadval.b φB0
3 sadval.c C=seq0c2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1
4 sadcp1.n φN0
5 nn0uz 0=0
6 4 5 eleqtrdi φN0
7 seqp1 N0seq0c2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1N+1=seq0c2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1Nc2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1N+1
8 6 7 syl φseq0c2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1N+1=seq0c2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1Nc2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1N+1
9 3 fveq1i CN+1=seq0c2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1N+1
10 3 fveq1i CN=seq0c2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1N
11 10 oveq1i CNc2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1N+1=seq0c2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1Nc2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1N+1
12 8 9 11 3eqtr4g φCN+1=CNc2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1N+1
13 peano2nn0 N0N+10
14 eqeq1 n=N+1n=0N+1=0
15 oveq1 n=N+1n1=N+1-1
16 14 15 ifbieq2d n=N+1ifn=0n1=ifN+1=0N+1-1
17 eqid n0ifn=0n1=n0ifn=0n1
18 0ex V
19 ovex N+1-1V
20 18 19 ifex ifN+1=0N+1-1V
21 16 17 20 fvmpt N+10n0ifn=0n1N+1=ifN+1=0N+1-1
22 4 13 21 3syl φn0ifn=0n1N+1=ifN+1=0N+1-1
23 nn0p1nn N0N+1
24 4 23 syl φN+1
25 24 nnne0d φN+10
26 ifnefalse N+10ifN+1=0N+1-1=N+1-1
27 25 26 syl φifN+1=0N+1-1=N+1-1
28 4 nn0cnd φN
29 1cnd φ1
30 28 29 pncand φN+1-1=N
31 22 27 30 3eqtrd φn0ifn=0n1N+1=N
32 31 oveq2d φCNc2𝑜,m0ifcaddmAmBc1𝑜n0ifn=0n1N+1=CNc2𝑜,m0ifcaddmAmBc1𝑜N
33 1 2 3 sadcf φC:02𝑜
34 33 4 ffvelcdmd φCN2𝑜
35 simpr x=CNy=Ny=N
36 35 eleq1d x=CNy=NyANA
37 35 eleq1d x=CNy=NyBNB
38 simpl x=CNy=Nx=CN
39 38 eleq2d x=CNy=NxCN
40 36 37 39 cadbi123d x=CNy=NcaddyAyBxcaddNANBCN
41 40 ifbid x=CNy=NifcaddyAyBx1𝑜=ifcaddNANBCN1𝑜
42 biidd c=xmAmA
43 biidd c=xmBmB
44 eleq2w c=xcx
45 42 43 44 cadbi123d c=xcaddmAmBccaddmAmBx
46 45 ifbid c=xifcaddmAmBc1𝑜=ifcaddmAmBx1𝑜
47 eleq1w m=ymAyA
48 eleq1w m=ymByB
49 biidd m=yxx
50 47 48 49 cadbi123d m=ycaddmAmBxcaddyAyBx
51 50 ifbid m=yifcaddmAmBx1𝑜=ifcaddyAyBx1𝑜
52 46 51 cbvmpov c2𝑜,m0ifcaddmAmBc1𝑜=x2𝑜,y0ifcaddyAyBx1𝑜
53 1oex 1𝑜V
54 53 18 ifex ifcaddNANBCN1𝑜V
55 41 52 54 ovmpoa CN2𝑜N0CNc2𝑜,m0ifcaddmAmBc1𝑜N=ifcaddNANBCN1𝑜
56 34 4 55 syl2anc φCNc2𝑜,m0ifcaddmAmBc1𝑜N=ifcaddNANBCN1𝑜
57 12 32 56 3eqtrd φCN+1=ifcaddNANBCN1𝑜
58 57 eleq2d φCN+1ifcaddNANBCN1𝑜
59 noel ¬
60 iffalse ¬caddNANBCNifcaddNANBCN1𝑜=
61 60 eleq2d ¬caddNANBCNifcaddNANBCN1𝑜
62 59 61 mtbiri ¬caddNANBCN¬ifcaddNANBCN1𝑜
63 62 con4i ifcaddNANBCN1𝑜caddNANBCN
64 0lt1o 1𝑜
65 iftrue caddNANBCNifcaddNANBCN1𝑜=1𝑜
66 64 65 eleqtrrid caddNANBCNifcaddNANBCN1𝑜
67 63 66 impbii ifcaddNANBCN1𝑜caddNANBCN
68 58 67 bitrdi φCN+1caddNANBCN