Metamath Proof Explorer |
< Previous
Next >
Nearby theorems |
||
Mirrors > Home > MPE Home > Th. List > sadadd | Structured version Visualization version GIF version |
Description: For sequences that
correspond to valid integers, the adder sequence
function produces the sequence for the sum. This is effectively a proof
of the correctness of the ripple carry adder, implemented with logic
gates corresponding to df-had 1600 and df-cad 1614.
It is interesting to consider in what sense the sadd function can be said to be "adding" things outside the range of the bits function, that is, when adding sequences that are not eventually constant and so do not denote any integer. The correct interpretation is that the sequences are representations of 2-adic integers, which have a natural ring structure. (Contributed by Mario Carneiro, 9-Sep-2016.) |
Ref | Expression |
---|---|
sadadd | ⊢ ((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) → ((bits‘𝐴) sadd (bits‘𝐵)) = (bits‘(𝐴 + 𝐵))) |
Step | Hyp | Ref | Expression |
---|---|---|---|
1 | bitsss 15948 | . . . . . 6 ⊢ (bits‘𝐴) ⊆ ℕ0 | |
2 | bitsss 15948 | . . . . . 6 ⊢ (bits‘𝐵) ⊆ ℕ0 | |
3 | sadcl 15984 | . . . . . 6 ⊢ (((bits‘𝐴) ⊆ ℕ0 ∧ (bits‘𝐵) ⊆ ℕ0) → ((bits‘𝐴) sadd (bits‘𝐵)) ⊆ ℕ0) | |
4 | 1, 2, 3 | mp2an 692 | . . . . 5 ⊢ ((bits‘𝐴) sadd (bits‘𝐵)) ⊆ ℕ0 |
5 | 4 | sseli 3883 | . . . 4 ⊢ (𝑘 ∈ ((bits‘𝐴) sadd (bits‘𝐵)) → 𝑘 ∈ ℕ0) |
6 | 5 | a1i 11 | . . 3 ⊢ ((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) → (𝑘 ∈ ((bits‘𝐴) sadd (bits‘𝐵)) → 𝑘 ∈ ℕ0)) |
7 | bitsss 15948 | . . . . 5 ⊢ (bits‘(𝐴 + 𝐵)) ⊆ ℕ0 | |
8 | 7 | sseli 3883 | . . . 4 ⊢ (𝑘 ∈ (bits‘(𝐴 + 𝐵)) → 𝑘 ∈ ℕ0) |
9 | 8 | a1i 11 | . . 3 ⊢ ((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) → (𝑘 ∈ (bits‘(𝐴 + 𝐵)) → 𝑘 ∈ ℕ0)) |
10 | eqid 2736 | . . . . . . . . 9 ⊢ seq0((𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚 ∈ (bits‘𝐴), 𝑚 ∈ (bits‘𝐵), ∅ ∈ 𝑐), 1o, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))) = seq0((𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚 ∈ (bits‘𝐴), 𝑚 ∈ (bits‘𝐵), ∅ ∈ 𝑐), 1o, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))) | |
11 | eqid 2736 | . . . . . . . . 9 ⊢ ◡(bits ↾ ℕ0) = ◡(bits ↾ ℕ0) | |
12 | simpll 767 | . . . . . . . . 9 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → 𝐴 ∈ ℤ) | |
13 | simplr 769 | . . . . . . . . 9 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → 𝐵 ∈ ℤ) | |
14 | simpr 488 | . . . . . . . . . 10 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → 𝑘 ∈ ℕ0) | |
15 | 1nn0 12071 | . . . . . . . . . . 11 ⊢ 1 ∈ ℕ0 | |
16 | 15 | a1i 11 | . . . . . . . . . 10 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → 1 ∈ ℕ0) |
17 | 14, 16 | nn0addcld 12119 | . . . . . . . . 9 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → (𝑘 + 1) ∈ ℕ0) |
18 | 10, 11, 12, 13, 17 | sadaddlem 15988 | . . . . . . . 8 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → (((bits‘𝐴) sadd (bits‘𝐵)) ∩ (0..^(𝑘 + 1))) = (bits‘((𝐴 + 𝐵) mod (2↑(𝑘 + 1))))) |
19 | 12, 13 | zaddcld 12251 | . . . . . . . . 9 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → (𝐴 + 𝐵) ∈ ℤ) |
20 | bitsmod 15958 | . . . . . . . . 9 ⊢ (((𝐴 + 𝐵) ∈ ℤ ∧ (𝑘 + 1) ∈ ℕ0) → (bits‘((𝐴 + 𝐵) mod (2↑(𝑘 + 1)))) = ((bits‘(𝐴 + 𝐵)) ∩ (0..^(𝑘 + 1)))) | |
21 | 19, 17, 20 | syl2anc 587 | . . . . . . . 8 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → (bits‘((𝐴 + 𝐵) mod (2↑(𝑘 + 1)))) = ((bits‘(𝐴 + 𝐵)) ∩ (0..^(𝑘 + 1)))) |
22 | 18, 21 | eqtrd 2771 | . . . . . . 7 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → (((bits‘𝐴) sadd (bits‘𝐵)) ∩ (0..^(𝑘 + 1))) = ((bits‘(𝐴 + 𝐵)) ∩ (0..^(𝑘 + 1)))) |
23 | 22 | eleq2d 2816 | . . . . . 6 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → (𝑘 ∈ (((bits‘𝐴) sadd (bits‘𝐵)) ∩ (0..^(𝑘 + 1))) ↔ 𝑘 ∈ ((bits‘(𝐴 + 𝐵)) ∩ (0..^(𝑘 + 1))))) |
24 | elin 3869 | . . . . . 6 ⊢ (𝑘 ∈ (((bits‘𝐴) sadd (bits‘𝐵)) ∩ (0..^(𝑘 + 1))) ↔ (𝑘 ∈ ((bits‘𝐴) sadd (bits‘𝐵)) ∧ 𝑘 ∈ (0..^(𝑘 + 1)))) | |
25 | elin 3869 | . . . . . 6 ⊢ (𝑘 ∈ ((bits‘(𝐴 + 𝐵)) ∩ (0..^(𝑘 + 1))) ↔ (𝑘 ∈ (bits‘(𝐴 + 𝐵)) ∧ 𝑘 ∈ (0..^(𝑘 + 1)))) | |
26 | 23, 24, 25 | 3bitr3g 316 | . . . . 5 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → ((𝑘 ∈ ((bits‘𝐴) sadd (bits‘𝐵)) ∧ 𝑘 ∈ (0..^(𝑘 + 1))) ↔ (𝑘 ∈ (bits‘(𝐴 + 𝐵)) ∧ 𝑘 ∈ (0..^(𝑘 + 1))))) |
27 | nn0uz 12441 | . . . . . . . . 9 ⊢ ℕ0 = (ℤ≥‘0) | |
28 | 14, 27 | eleqtrdi 2841 | . . . . . . . 8 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → 𝑘 ∈ (ℤ≥‘0)) |
29 | eluzfz2 13085 | . . . . . . . 8 ⊢ (𝑘 ∈ (ℤ≥‘0) → 𝑘 ∈ (0...𝑘)) | |
30 | 28, 29 | syl 17 | . . . . . . 7 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → 𝑘 ∈ (0...𝑘)) |
31 | 14 | nn0zd 12245 | . . . . . . . 8 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → 𝑘 ∈ ℤ) |
32 | fzval3 13276 | . . . . . . . 8 ⊢ (𝑘 ∈ ℤ → (0...𝑘) = (0..^(𝑘 + 1))) | |
33 | 31, 32 | syl 17 | . . . . . . 7 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → (0...𝑘) = (0..^(𝑘 + 1))) |
34 | 30, 33 | eleqtrd 2833 | . . . . . 6 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → 𝑘 ∈ (0..^(𝑘 + 1))) |
35 | 34 | biantrud 535 | . . . . 5 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → (𝑘 ∈ ((bits‘𝐴) sadd (bits‘𝐵)) ↔ (𝑘 ∈ ((bits‘𝐴) sadd (bits‘𝐵)) ∧ 𝑘 ∈ (0..^(𝑘 + 1))))) |
36 | 34 | biantrud 535 | . . . . 5 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → (𝑘 ∈ (bits‘(𝐴 + 𝐵)) ↔ (𝑘 ∈ (bits‘(𝐴 + 𝐵)) ∧ 𝑘 ∈ (0..^(𝑘 + 1))))) |
37 | 26, 35, 36 | 3bitr4d 314 | . . . 4 ⊢ (((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) ∧ 𝑘 ∈ ℕ0) → (𝑘 ∈ ((bits‘𝐴) sadd (bits‘𝐵)) ↔ 𝑘 ∈ (bits‘(𝐴 + 𝐵)))) |
38 | 37 | ex 416 | . . 3 ⊢ ((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) → (𝑘 ∈ ℕ0 → (𝑘 ∈ ((bits‘𝐴) sadd (bits‘𝐵)) ↔ 𝑘 ∈ (bits‘(𝐴 + 𝐵))))) |
39 | 6, 9, 38 | pm5.21ndd 384 | . 2 ⊢ ((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) → (𝑘 ∈ ((bits‘𝐴) sadd (bits‘𝐵)) ↔ 𝑘 ∈ (bits‘(𝐴 + 𝐵)))) |
40 | 39 | eqrdv 2734 | 1 ⊢ ((𝐴 ∈ ℤ ∧ 𝐵 ∈ ℤ) → ((bits‘𝐴) sadd (bits‘𝐵)) = (bits‘(𝐴 + 𝐵))) |
Colors of variables: wff setvar class |
Syntax hints: → wi 4 ↔ wb 209 ∧ wa 399 = wceq 1543 caddwcad 1613 ∈ wcel 2112 ∩ cin 3852 ⊆ wss 3853 ∅c0 4223 ifcif 4425 ↦ cmpt 5120 ◡ccnv 5535 ↾ cres 5538 ‘cfv 6358 (class class class)co 7191 ∈ cmpo 7193 1oc1o 8173 2oc2o 8174 0cc0 10694 1c1 10695 + caddc 10697 − cmin 11027 2c2 11850 ℕ0cn0 12055 ℤcz 12141 ℤ≥cuz 12403 ...cfz 13060 ..^cfzo 13203 mod cmo 13407 seqcseq 13539 ↑cexp 13600 bitscbits 15941 sadd csad 15942 |
This theorem was proved from axioms: ax-mp 5 ax-1 6 ax-2 7 ax-3 8 ax-gen 1803 ax-4 1817 ax-5 1918 ax-6 1976 ax-7 2018 ax-8 2114 ax-9 2122 ax-10 2143 ax-11 2160 ax-12 2177 ax-ext 2708 ax-rep 5164 ax-sep 5177 ax-nul 5184 ax-pow 5243 ax-pr 5307 ax-un 7501 ax-inf2 9234 ax-cnex 10750 ax-resscn 10751 ax-1cn 10752 ax-icn 10753 ax-addcl 10754 ax-addrcl 10755 ax-mulcl 10756 ax-mulrcl 10757 ax-mulcom 10758 ax-addass 10759 ax-mulass 10760 ax-distr 10761 ax-i2m1 10762 ax-1ne0 10763 ax-1rid 10764 ax-rnegex 10765 ax-rrecex 10766 ax-cnre 10767 ax-pre-lttri 10768 ax-pre-lttrn 10769 ax-pre-ltadd 10770 ax-pre-mulgt0 10771 ax-pre-sup 10772 |
This theorem depends on definitions: df-bi 210 df-an 400 df-or 848 df-3or 1090 df-3an 1091 df-xor 1508 df-tru 1546 df-fal 1556 df-had 1600 df-cad 1614 df-ex 1788 df-nf 1792 df-sb 2073 df-mo 2539 df-eu 2568 df-clab 2715 df-cleq 2728 df-clel 2809 df-nfc 2879 df-ne 2933 df-nel 3037 df-ral 3056 df-rex 3057 df-reu 3058 df-rmo 3059 df-rab 3060 df-v 3400 df-sbc 3684 df-csb 3799 df-dif 3856 df-un 3858 df-in 3860 df-ss 3870 df-pss 3872 df-nul 4224 df-if 4426 df-pw 4501 df-sn 4528 df-pr 4530 df-tp 4532 df-op 4534 df-uni 4806 df-int 4846 df-iun 4892 df-disj 5005 df-br 5040 df-opab 5102 df-mpt 5121 df-tr 5147 df-id 5440 df-eprel 5445 df-po 5453 df-so 5454 df-fr 5494 df-se 5495 df-we 5496 df-xp 5542 df-rel 5543 df-cnv 5544 df-co 5545 df-dm 5546 df-rn 5547 df-res 5548 df-ima 5549 df-pred 6140 df-ord 6194 df-on 6195 df-lim 6196 df-suc 6197 df-iota 6316 df-fun 6360 df-fn 6361 df-f 6362 df-f1 6363 df-fo 6364 df-f1o 6365 df-fv 6366 df-isom 6367 df-riota 7148 df-ov 7194 df-oprab 7195 df-mpo 7196 df-om 7623 df-1st 7739 df-2nd 7740 df-wrecs 8025 df-recs 8086 df-rdg 8124 df-1o 8180 df-2o 8181 df-oadd 8184 df-er 8369 df-map 8488 df-pm 8489 df-en 8605 df-dom 8606 df-sdom 8607 df-fin 8608 df-sup 9036 df-inf 9037 df-oi 9104 df-dju 9482 df-card 9520 df-pnf 10834 df-mnf 10835 df-xr 10836 df-ltxr 10837 df-le 10838 df-sub 11029 df-neg 11030 df-div 11455 df-nn 11796 df-2 11858 df-3 11859 df-n0 12056 df-xnn0 12128 df-z 12142 df-uz 12404 df-rp 12552 df-fz 13061 df-fzo 13204 df-fl 13332 df-mod 13408 df-seq 13540 df-exp 13601 df-hash 13862 df-cj 14627 df-re 14628 df-im 14629 df-sqrt 14763 df-abs 14764 df-clim 15014 df-sum 15215 df-dvds 15779 df-bits 15944 df-sad 15973 |
This theorem is referenced by: bitsres 15995 smumullem 16014 |
Copyright terms: Public domain | W3C validator |