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

Theorem sadadd 16449
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 16408 . . . . . 6 (bitsβ€˜π΄) βŠ† β„•0
2 bitsss 16408 . . . . . 6 (bitsβ€˜π΅) βŠ† β„•0
3 sadcl 16444 . . . . . 6 (((bitsβ€˜π΄) βŠ† β„•0 ∧ (bitsβ€˜π΅) βŠ† β„•0) β†’ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) βŠ† β„•0)
41, 2, 3mp2an 690 . . . . 5 ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) βŠ† β„•0
54sseli 3978 . . . 4 (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) β†’ π‘˜ ∈ β„•0)
65a1i 11 . . 3 ((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) β†’ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) β†’ π‘˜ ∈ β„•0))
7 bitsss 16408 . . . . 5 (bitsβ€˜(𝐴 + 𝐡)) βŠ† β„•0
87sseli 3978 . . . 4 (π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)) β†’ π‘˜ ∈ β„•0)
98a1i 11 . . 3 ((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) β†’ (π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)) β†’ π‘˜ ∈ β„•0))
10 eqid 2728 . . . . . . . . 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 2728 . . . . . . . . 9 β—‘(bits β†Ύ β„•0) = β—‘(bits β†Ύ β„•0)
12 simpll 765 . . . . . . . . 9 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ 𝐴 ∈ β„€)
13 simplr 767 . . . . . . . . 9 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ 𝐡 ∈ β„€)
14 simpr 483 . . . . . . . . . 10 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ π‘˜ ∈ β„•0)
15 1nn0 12526 . . . . . . . . . . 11 1 ∈ β„•0
1615a1i 11 . . . . . . . . . 10 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ 1 ∈ β„•0)
1714, 16nn0addcld 12574 . . . . . . . . 9 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (π‘˜ + 1) ∈ β„•0)
1810, 11, 12, 13, 17sadaddlem 16448 . . . . . . . 8 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∩ (0..^(π‘˜ + 1))) = (bitsβ€˜((𝐴 + 𝐡) mod (2↑(π‘˜ + 1)))))
1912, 13zaddcld 12708 . . . . . . . . 9 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (𝐴 + 𝐡) ∈ β„€)
20 bitsmod 16418 . . . . . . . . 9 (((𝐴 + 𝐡) ∈ β„€ ∧ (π‘˜ + 1) ∈ β„•0) β†’ (bitsβ€˜((𝐴 + 𝐡) mod (2↑(π‘˜ + 1)))) = ((bitsβ€˜(𝐴 + 𝐡)) ∩ (0..^(π‘˜ + 1))))
2119, 17, 20syl2anc 582 . . . . . . . 8 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (bitsβ€˜((𝐴 + 𝐡) mod (2↑(π‘˜ + 1)))) = ((bitsβ€˜(𝐴 + 𝐡)) ∩ (0..^(π‘˜ + 1))))
2218, 21eqtrd 2768 . . . . . . 7 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∩ (0..^(π‘˜ + 1))) = ((bitsβ€˜(𝐴 + 𝐡)) ∩ (0..^(π‘˜ + 1))))
2322eleq2d 2815 . . . . . 6 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (π‘˜ ∈ (((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∩ (0..^(π‘˜ + 1))) ↔ π‘˜ ∈ ((bitsβ€˜(𝐴 + 𝐡)) ∩ (0..^(π‘˜ + 1)))))
24 elin 3965 . . . . . 6 (π‘˜ ∈ (((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∩ (0..^(π‘˜ + 1))) ↔ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∧ π‘˜ ∈ (0..^(π‘˜ + 1))))
25 elin 3965 . . . . . 6 (π‘˜ ∈ ((bitsβ€˜(𝐴 + 𝐡)) ∩ (0..^(π‘˜ + 1))) ↔ (π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)) ∧ π‘˜ ∈ (0..^(π‘˜ + 1))))
2623, 24, 253bitr3g 312 . . . . 5 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ ((π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∧ π‘˜ ∈ (0..^(π‘˜ + 1))) ↔ (π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)) ∧ π‘˜ ∈ (0..^(π‘˜ + 1)))))
27 nn0uz 12902 . . . . . . . . 9 β„•0 = (β„€β‰₯β€˜0)
2814, 27eleqtrdi 2839 . . . . . . . 8 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ π‘˜ ∈ (β„€β‰₯β€˜0))
29 eluzfz2 13549 . . . . . . . 8 (π‘˜ ∈ (β„€β‰₯β€˜0) β†’ π‘˜ ∈ (0...π‘˜))
3028, 29syl 17 . . . . . . 7 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ π‘˜ ∈ (0...π‘˜))
3114nn0zd 12622 . . . . . . . 8 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ π‘˜ ∈ β„€)
32 fzval3 13741 . . . . . . . 8 (π‘˜ ∈ β„€ β†’ (0...π‘˜) = (0..^(π‘˜ + 1)))
3331, 32syl 17 . . . . . . 7 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (0...π‘˜) = (0..^(π‘˜ + 1)))
3430, 33eleqtrd 2831 . . . . . 6 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ π‘˜ ∈ (0..^(π‘˜ + 1)))
3534biantrud 530 . . . . 5 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ↔ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ∧ π‘˜ ∈ (0..^(π‘˜ + 1)))))
3634biantrud 530 . . . . 5 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)) ↔ (π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)) ∧ π‘˜ ∈ (0..^(π‘˜ + 1)))))
3726, 35, 363bitr4d 310 . . . 4 (((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) ∧ π‘˜ ∈ β„•0) β†’ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ↔ π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡))))
3837ex 411 . . 3 ((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) β†’ (π‘˜ ∈ β„•0 β†’ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ↔ π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡)))))
396, 9, 38pm5.21ndd 378 . 2 ((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) β†’ (π‘˜ ∈ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) ↔ π‘˜ ∈ (bitsβ€˜(𝐴 + 𝐡))))
4039eqrdv 2726 1 ((𝐴 ∈ β„€ ∧ 𝐡 ∈ β„€) β†’ ((bitsβ€˜π΄) sadd (bitsβ€˜π΅)) = (bitsβ€˜(𝐴 + 𝐡)))
Colors of variables: wff setvar class
Syntax hints:   β†’ wi 4   ↔ wb 205   ∧ wa 394   = wceq 1533  caddwcad 1599   ∈ wcel 2098   ∩ cin 3948   βŠ† wss 3949  βˆ…c0 4326  ifcif 4532   ↦ cmpt 5235  β—‘ccnv 5681   β†Ύ cres 5684  β€˜cfv 6553  (class class class)co 7426   ∈ cmpo 7428  1oc1o 8486  2oc2o 8487  0cc0 11146  1c1 11147   + caddc 11149   βˆ’ cmin 11482  2c2 12305  β„•0cn0 12510  β„€cz 12596  β„€β‰₯cuz 12860  ...cfz 13524  ..^cfzo 13667   mod cmo 13874  seqcseq 14006  β†‘cexp 14066  bitscbits 16401   sadd csad 16402
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 2166  ax-ext 2699  ax-rep 5289  ax-sep 5303  ax-nul 5310  ax-pow 5369  ax-pr 5433  ax-un 7746  ax-inf2 9672  ax-cnex 11202  ax-resscn 11203  ax-1cn 11204  ax-icn 11205  ax-addcl 11206  ax-addrcl 11207  ax-mulcl 11208  ax-mulrcl 11209  ax-mulcom 11210  ax-addass 11211  ax-mulass 11212  ax-distr 11213  ax-i2m1 11214  ax-1ne0 11215  ax-1rid 11216  ax-rnegex 11217  ax-rrecex 11218  ax-cnre 11219  ax-pre-lttri 11220  ax-pre-lttrn 11221  ax-pre-ltadd 11222  ax-pre-mulgt0 11223  ax-pre-sup 11224
This theorem depends on definitions:  df-bi 206  df-an 395  df-or 846  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 2529  df-eu 2558  df-clab 2706  df-cleq 2720  df-clel 2806  df-nfc 2881  df-ne 2938  df-nel 3044  df-ral 3059  df-rex 3068  df-rmo 3374  df-reu 3375  df-rab 3431  df-v 3475  df-sbc 3779  df-csb 3895  df-dif 3952  df-un 3954  df-in 3956  df-ss 3966  df-pss 3968  df-nul 4327  df-if 4533  df-pw 4608  df-sn 4633  df-pr 4635  df-op 4639  df-uni 4913  df-int 4954  df-iun 5002  df-disj 5118  df-br 5153  df-opab 5215  df-mpt 5236  df-tr 5270  df-id 5580  df-eprel 5586  df-po 5594  df-so 5595  df-fr 5637  df-se 5638  df-we 5639  df-xp 5688  df-rel 5689  df-cnv 5690  df-co 5691  df-dm 5692  df-rn 5693  df-res 5694  df-ima 5695  df-pred 6310  df-ord 6377  df-on 6378  df-lim 6379  df-suc 6380  df-iota 6505  df-fun 6555  df-fn 6556  df-f 6557  df-f1 6558  df-fo 6559  df-f1o 6560  df-fv 6561  df-isom 6562  df-riota 7382  df-ov 7429  df-oprab 7430  df-mpo 7431  df-om 7877  df-1st 7999  df-2nd 8000  df-frecs 8293  df-wrecs 8324  df-recs 8398  df-rdg 8437  df-1o 8493  df-2o 8494  df-oadd 8497  df-er 8731  df-map 8853  df-pm 8854  df-en 8971  df-dom 8972  df-sdom 8973  df-fin 8974  df-sup 9473  df-inf 9474  df-oi 9541  df-dju 9932  df-card 9970  df-pnf 11288  df-mnf 11289  df-xr 11290  df-ltxr 11291  df-le 11292  df-sub 11484  df-neg 11485  df-div 11910  df-nn 12251  df-2 12313  df-3 12314  df-n0 12511  df-xnn0 12583  df-z 12597  df-uz 12861  df-rp 13015  df-fz 13525  df-fzo 13668  df-fl 13797  df-mod 13875  df-seq 14007  df-exp 14067  df-hash 14330  df-cj 15086  df-re 15087  df-im 15088  df-sqrt 15222  df-abs 15223  df-clim 15472  df-sum 15673  df-dvds 16239  df-bits 16404  df-sad 16433
This theorem is referenced by:  bitsres  16455  smumullem  16474
  Copyright terms: Public domain W3C validator