MPE Home Metamath Proof Explorer < Previous   Next >
Nearby theorems
Mirrors  >  Home  >  MPE Home  >  Th. List  >  sadadd Structured version   Visualization version   GIF version

Theorem sadadd 16413
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 1587 and df-cad 1600.

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.)

Assertion
Ref Expression
sadadd ((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) β†’ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) = (bitsβ€˜(𝐴 + 𝐡)))

Proof of Theorem sadadd
Dummy variables π‘˜ 𝑐 π‘š 𝑛 are mutually distinct and distinct from all other variables.
StepHypRef Expression
1 bitsss 16372 . . . . . 6 (bitsβ€˜π΄) βŠ† β„•0
2 bitsss 16372 . . . . . 6 (bitsβ€˜π΅) βŠ† β„•0
3 sadcl 16408 . . . . . 6 (((bitsβ€˜π΄) βŠ† β„•0 ∧ (bitsβ€˜π΅) βŠ† β„•0) β†’ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) βŠ† β„•0)
41, 2, 3mp2an 689 . . . . 5 ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) βŠ† β„•0
54sseli 3973 . . . 4 (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) β†’ π‘˜ ∈ β„•0)
65a1i 11 . . 3 ((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) β†’ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) β†’ π‘˜ ∈ β„•0))
7 bitsss 16372 . . . . 5 (bitsβ€˜(𝐴 + 𝐡)) βŠ† β„•0
87sseli 3973 . . . 4 (π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)) β†’ π‘˜ ∈ β„•0)
98a1i 11 . . 3 ((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) β†’ (π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)) β†’ π‘˜ ∈ β„•0))
10 eqid 2726 . . . . . . . . 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 2726 . . . . . . . . 9 β—‘(bits β†Ύ β„•0) = β—‘(bits β†Ύ β„•0)
12 simpll 764 . . . . . . . . 9 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ 𝐴 ∈ β„€)
13 simplr 766 . . . . . . . . 9 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ 𝐡 ∈ β„€)
14 simpr 484 . . . . . . . . . 10 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ π‘˜ ∈ β„•0)
15 1nn0 12489 . . . . . . . . . . 11 1 ∈ β„•0
1615a1i 11 . . . . . . . . . 10 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ 1 ∈ β„•0)
1714, 16nn0addcld 12537 . . . . . . . . 9 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (π‘˜ + 1) ∈ β„•0)
1810, 11, 12, 13, 17sadaddlem 16412 . . . . . . . 8 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∩ (0..^(π‘˜ + 1))) = (bitsβ€˜((𝐴 + 𝐡) mod (2↑(π‘˜ + 1)))))
1912, 13zaddcld 12671 . . . . . . . . 9 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (𝐴 + 𝐡) ∈ β„€)
20 bitsmod 16382 . . . . . . . . 9 (((𝐴 + 𝐡) ∈ β„€ ∧ (π‘˜ + 1) ∈ β„•0) β†’ (bitsβ€˜((𝐴 + 𝐡) mod (2↑(π‘˜ + 1)))) = ((bitsβ€˜(𝐴 + 𝐡)) ∩ (0..^(π‘˜ + 1))))
2119, 17, 20syl2anc 583 . . . . . . . 8 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (bitsβ€˜((𝐴 + 𝐡) mod (2↑(π‘˜ + 1)))) = ((bitsβ€˜(𝐴 + 𝐡)) ∩ (0..^(π‘˜ + 1))))
2218, 21eqtrd 2766 . . . . . . 7 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∩ (0..^(π‘˜ + 1))) = ((bitsβ€˜(𝐴 + 𝐡)) ∩ (0..^(π‘˜ + 1))))
2322eleq2d 2813 . . . . . 6 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (π‘˜ ∈ (((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∩ (0..^(π‘˜ + 1))) ↔ π‘˜ ∈ ((bitsβ€˜(𝐴 + 𝐡)) ∩ (0..^(π‘˜ + 1)))))
24 elin 3959 . . . . . 6 (π‘˜ ∈ (((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∩ (0..^(π‘˜ + 1))) ↔ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∧ π‘˜ ∈ (0..^(π‘˜ + 1))))
25 elin 3959 . . . . . 6 (π‘˜ ∈ ((bitsβ€˜(𝐴 + 𝐡)) ∩ (0..^(π‘˜ + 1))) ↔ (π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)) ∧ π‘˜ ∈ (0..^(π‘˜ + 1))))
2623, 24, 253bitr3g 313 . . . . 5 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ ((π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∧ π‘˜ ∈ (0..^(π‘˜ + 1))) ↔ (π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)) ∧ π‘˜ ∈ (0..^(π‘˜ + 1)))))
27 nn0uz 12865 . . . . . . . . 9 β„•0 = (β„€β‰₯β€˜0)
2814, 27eleqtrdi 2837 . . . . . . . 8 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ π‘˜ ∈ (β„€β‰₯β€˜0))
29 eluzfz2 13512 . . . . . . . 8 (π‘˜ ∈ (β„€β‰₯β€˜0) β†’ π‘˜ ∈ (0...π‘˜))
3028, 29syl 17 . . . . . . 7 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ π‘˜ ∈ (0...π‘˜))
3114nn0zd 12585 . . . . . . . 8 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ π‘˜ ∈ β„€)
32 fzval3 13704 . . . . . . . 8 (π‘˜ ∈ β„€ β†’ (0...π‘˜) = (0..^(π‘˜ + 1)))
3331, 32syl 17 . . . . . . 7 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (0...π‘˜) = (0..^(π‘˜ + 1)))
3430, 33eleqtrd 2829 . . . . . 6 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ π‘˜ ∈ (0..^(π‘˜ + 1)))
3534biantrud 531 . . . . 5 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ↔ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∧ π‘˜ ∈ (0..^(π‘˜ + 1)))))
3634biantrud 531 . . . . 5 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)) ↔ (π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)) ∧ π‘˜ ∈ (0..^(π‘˜ + 1)))))
3726, 35, 363bitr4d 311 . . . 4 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ↔ π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡))))
3837ex 412 . . 3 ((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) β†’ (π‘˜ ∈ β„•0 β†’ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ↔ π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)))))
396, 9, 38pm5.21ndd 379 . 2 ((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) β†’ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ↔ π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡))))
4039eqrdv 2724 1 ((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) β†’ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) = (bitsβ€˜(𝐴 + 𝐡)))
Colors of variables: wff setvar class
Syntax hints:   β†’ wi 4   ↔ wb 205   ∧ wa 395   = wceq 1533  caddwcad 1599   ∈ wcel 2098   ∩ cin 3942   βŠ† wss 3943  βˆ…c0 4317  ifcif 4523   ↦ cmpt 5224  β—‘ccnv 5668   β†Ύ cres 5671  β€˜cfv 6536  (class class class)co 7404   ∈ cmpo 7406  1oc1o 8457  2oc2o 8458  0cc0 11109  1c1 11110   + caddc 11112   βˆ’ cmin 11445  2c2 12268  β„•0cn0 12473  β„€cz 12559  β„€β‰₯cuz 12823  ...cfz 13487  ..^cfzo 13630   mod cmo 13837  seqcseq 13969  β†‘cexp 14030  bitscbits 16365   sadd csad 16366
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1789  ax-4 1803  ax-5 1905  ax-6 1963  ax-7 2003  ax-8 2100  ax-9 2108  ax-10 2129  ax-11 2146  ax-12 2163  ax-ext 2697  ax-rep 5278  ax-sep 5292  ax-nul 5299  ax-pow 5356  ax-pr 5420  ax-un 7721  ax-inf2 9635  ax-cnex 11165  ax-resscn 11166  ax-1cn 11167  ax-icn 11168  ax-addcl 11169  ax-addrcl 11170  ax-mulcl 11171  ax-mulrcl 11172  ax-mulcom 11173  ax-addass 11174  ax-mulass 11175  ax-distr 11176  ax-i2m1 11177  ax-1ne0 11178  ax-1rid 11179  ax-rnegex 11180  ax-rrecex 11181  ax-cnre 11182  ax-pre-lttri 11183  ax-pre-lttrn 11184  ax-pre-ltadd 11185  ax-pre-mulgt0 11186  ax-pre-sup 11187
This theorem depends on definitions:  df-bi 206  df-an 396  df-or 845  df-3or 1085  df-3an 1086  df-xor 1505  df-tru 1536  df-fal 1546  df-had 1587  df-cad 1600  df-ex 1774  df-nf 1778  df-sb 2060  df-mo 2528  df-eu 2557  df-clab 2704  df-cleq 2718  df-clel 2804  df-nfc 2879  df-ne 2935  df-nel 3041  df-ral 3056  df-rex 3065  df-rmo 3370  df-reu 3371  df-rab 3427  df-v 3470  df-sbc 3773  df-csb 3889  df-dif 3946  df-un 3948  df-in 3950  df-ss 3960  df-pss 3962  df-nul 4318  df-if 4524  df-pw 4599  df-sn 4624  df-pr 4626  df-op 4630  df-uni 4903  df-int 4944  df-iun 4992  df-disj 5107  df-br 5142  df-opab 5204  df-mpt 5225  df-tr 5259  df-id 5567  df-eprel 5573  df-po 5581  df-so 5582  df-fr 5624  df-se 5625  df-we 5626  df-xp 5675  df-rel 5676  df-cnv 5677  df-co 5678  df-dm 5679  df-rn 5680  df-res 5681  df-ima 5682  df-pred 6293  df-ord 6360  df-on 6361  df-lim 6362  df-suc 6363  df-iota 6488  df-fun 6538  df-fn 6539  df-f 6540  df-f1 6541  df-fo 6542  df-f1o 6543  df-fv 6544  df-isom 6545  df-riota 7360  df-ov 7407  df-oprab 7408  df-mpo 7409  df-om 7852  df-1st 7971  df-2nd 7972  df-frecs 8264  df-wrecs 8295  df-recs 8369  df-rdg 8408  df-1o 8464  df-2o 8465  df-oadd 8468  df-er 8702  df-map 8821  df-pm 8822  df-en 8939  df-dom 8940  df-sdom 8941  df-fin 8942  df-sup 9436  df-inf 9437  df-oi 9504  df-dju 9895  df-card 9933  df-pnf 11251  df-mnf 11252  df-xr 11253  df-ltxr 11254  df-le 11255  df-sub 11447  df-neg 11448  df-div 11873  df-nn 12214  df-2 12276  df-3 12277  df-n0 12474  df-xnn0 12546  df-z 12560  df-uz 12824  df-rp 12978  df-fz 13488  df-fzo 13631  df-fl 13760  df-mod 13838  df-seq 13970  df-exp 14031  df-hash 14294  df-cj 15050  df-re 15051  df-im 15052  df-sqrt 15186  df-abs 15187  df-clim 15436  df-sum 15637  df-dvds 16203  df-bits 16368  df-sad 16397
This theorem is referenced by:  bitsres  16419  smumullem  16438
  Copyright terms: Public domain W3C validator