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

 Description: The carry sequence (which is a sequence of wffs, encoded as 1𝑜 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.c 𝐶 = seq0((𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))
Assertion
Ref Expression
sadcp1 (𝜑 → (∅ ∈ (𝐶‘(𝑁 + 1)) ↔ cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁))))
Distinct variable groups:   𝑚,𝑐,𝑛   𝐴,𝑐,𝑚   𝐵,𝑐,𝑚   𝑛,𝑁
Allowed substitution hints:   𝜑(𝑚,𝑛,𝑐)   𝐴(𝑛)   𝐵(𝑛)   𝐶(𝑚,𝑛,𝑐)   𝑁(𝑚,𝑐)

Dummy variables 𝑥 𝑦 are mutually distinct and distinct from all other variables.
StepHypRef Expression
1 sadcp1.n . . . . . . 7 (𝜑𝑁 ∈ ℕ0)
2 nn0uz 11760 . . . . . . 7 0 = (ℤ‘0)
31, 2syl6eleq 2740 . . . . . 6 (𝜑𝑁 ∈ (ℤ‘0))
4 seqp1 12856 . . . . . 6 (𝑁 ∈ (ℤ‘0) → (seq0((𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘(𝑁 + 1)) = ((seq0((𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘𝑁)(𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅))((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1))))
53, 4syl 17 . . . . 5 (𝜑 → (seq0((𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘(𝑁 + 1)) = ((seq0((𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘𝑁)(𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅))((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1))))
6 sadval.c . . . . . 6 𝐶 = seq0((𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))
76fveq1i 6230 . . . . 5 (𝐶‘(𝑁 + 1)) = (seq0((𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘(𝑁 + 1))
86fveq1i 6230 . . . . . 6 (𝐶𝑁) = (seq0((𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘𝑁)
98oveq1i 6700 . . . . 5 ((𝐶𝑁)(𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅))((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1))) = ((seq0((𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘𝑁)(𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅))((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1)))
105, 7, 93eqtr4g 2710 . . . 4 (𝜑 → (𝐶‘(𝑁 + 1)) = ((𝐶𝑁)(𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅))((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1))))
11 peano2nn0 11371 . . . . . . 7 (𝑁 ∈ ℕ0 → (𝑁 + 1) ∈ ℕ0)
12 eqeq1 2655 . . . . . . . . 9 (𝑛 = (𝑁 + 1) → (𝑛 = 0 ↔ (𝑁 + 1) = 0))
13 oveq1 6697 . . . . . . . . 9 (𝑛 = (𝑁 + 1) → (𝑛 − 1) = ((𝑁 + 1) − 1))
1412, 13ifbieq2d 4144 . . . . . . . 8 (𝑛 = (𝑁 + 1) → if(𝑛 = 0, ∅, (𝑛 − 1)) = if((𝑁 + 1) = 0, ∅, ((𝑁 + 1) − 1)))
15 eqid 2651 . . . . . . . 8 (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))) = (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))
16 0ex 4823 . . . . . . . . 9 ∅ ∈ V
17 ovex 6718 . . . . . . . . 9 ((𝑁 + 1) − 1) ∈ V
1816, 17ifex 4189 . . . . . . . 8 if((𝑁 + 1) = 0, ∅, ((𝑁 + 1) − 1)) ∈ V
1914, 15, 18fvmpt 6321 . . . . . . 7 ((𝑁 + 1) ∈ ℕ0 → ((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1)) = if((𝑁 + 1) = 0, ∅, ((𝑁 + 1) − 1)))
201, 11, 193syl 18 . . . . . 6 (𝜑 → ((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1)) = if((𝑁 + 1) = 0, ∅, ((𝑁 + 1) − 1)))
21 nn0p1nn 11370 . . . . . . . . 9 (𝑁 ∈ ℕ0 → (𝑁 + 1) ∈ ℕ)
221, 21syl 17 . . . . . . . 8 (𝜑 → (𝑁 + 1) ∈ ℕ)
2322nnne0d 11103 . . . . . . 7 (𝜑 → (𝑁 + 1) ≠ 0)
24 ifnefalse 4131 . . . . . . 7 ((𝑁 + 1) ≠ 0 → if((𝑁 + 1) = 0, ∅, ((𝑁 + 1) − 1)) = ((𝑁 + 1) − 1))
2523, 24syl 17 . . . . . 6 (𝜑 → if((𝑁 + 1) = 0, ∅, ((𝑁 + 1) − 1)) = ((𝑁 + 1) − 1))
261nn0cnd 11391 . . . . . . 7 (𝜑𝑁 ∈ ℂ)
27 1cnd 10094 . . . . . . 7 (𝜑 → 1 ∈ ℂ)
2826, 27pncand 10431 . . . . . 6 (𝜑 → ((𝑁 + 1) − 1) = 𝑁)
2920, 25, 283eqtrd 2689 . . . . 5 (𝜑 → ((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1)) = 𝑁)
3029oveq2d 6706 . . . 4 (𝜑 → ((𝐶𝑁)(𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅))((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1))) = ((𝐶𝑁)(𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅))𝑁))
31 sadval.a . . . . . . 7 (𝜑𝐴 ⊆ ℕ0)
32 sadval.b . . . . . . 7 (𝜑𝐵 ⊆ ℕ0)
3331, 32, 6sadcf 15222 . . . . . 6 (𝜑𝐶:ℕ0⟶2𝑜)
3433, 1ffvelrnd 6400 . . . . 5 (𝜑 → (𝐶𝑁) ∈ 2𝑜)
35 simpr 476 . . . . . . . . 9 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → 𝑦 = 𝑁)
3635eleq1d 2715 . . . . . . . 8 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → (𝑦𝐴𝑁𝐴))
3735eleq1d 2715 . . . . . . . 8 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → (𝑦𝐵𝑁𝐵))
38 simpl 472 . . . . . . . . 9 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → 𝑥 = (𝐶𝑁))
3938eleq2d 2716 . . . . . . . 8 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → (∅ ∈ 𝑥 ↔ ∅ ∈ (𝐶𝑁)))
4036, 37, 39cadbi123d 1589 . . . . . . 7 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → (cadd(𝑦𝐴, 𝑦𝐵, ∅ ∈ 𝑥) ↔ cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁))))
4140ifbid 4141 . . . . . 6 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → if(cadd(𝑦𝐴, 𝑦𝐵, ∅ ∈ 𝑥), 1𝑜, ∅) = if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1𝑜, ∅))
42 biidd 252 . . . . . . . . 9 (𝑐 = 𝑥 → (𝑚𝐴𝑚𝐴))
43 biidd 252 . . . . . . . . 9 (𝑐 = 𝑥 → (𝑚𝐵𝑚𝐵))
44 eleq2 2719 . . . . . . . . 9 (𝑐 = 𝑥 → (∅ ∈ 𝑐 ↔ ∅ ∈ 𝑥))
4542, 43, 44cadbi123d 1589 . . . . . . . 8 (𝑐 = 𝑥 → (cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐) ↔ cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑥)))
4645ifbid 4141 . . . . . . 7 (𝑐 = 𝑥 → if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅) = if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑥), 1𝑜, ∅))
47 eleq1 2718 . . . . . . . . 9 (𝑚 = 𝑦 → (𝑚𝐴𝑦𝐴))
48 eleq1 2718 . . . . . . . . 9 (𝑚 = 𝑦 → (𝑚𝐵𝑦𝐵))
49 biidd 252 . . . . . . . . 9 (𝑚 = 𝑦 → (∅ ∈ 𝑥 ↔ ∅ ∈ 𝑥))
5047, 48, 49cadbi123d 1589 . . . . . . . 8 (𝑚 = 𝑦 → (cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑥) ↔ cadd(𝑦𝐴, 𝑦𝐵, ∅ ∈ 𝑥)))
5150ifbid 4141 . . . . . . 7 (𝑚 = 𝑦 → if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑥), 1𝑜, ∅) = if(cadd(𝑦𝐴, 𝑦𝐵, ∅ ∈ 𝑥), 1𝑜, ∅))
5246, 51cbvmpt2v 6777 . . . . . 6 (𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅)) = (𝑥 ∈ 2𝑜, 𝑦 ∈ ℕ0 ↦ if(cadd(𝑦𝐴, 𝑦𝐵, ∅ ∈ 𝑥), 1𝑜, ∅))
53 1on 7612 . . . . . . . 8 1𝑜 ∈ On
5453elexi 3244 . . . . . . 7 1𝑜 ∈ V
5554, 16ifex 4189 . . . . . 6 if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1𝑜, ∅) ∈ V
5641, 52, 55ovmpt2a 6833 . . . . 5 (((𝐶𝑁) ∈ 2𝑜𝑁 ∈ ℕ0) → ((𝐶𝑁)(𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅))𝑁) = if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1𝑜, ∅))
5734, 1, 56syl2anc 694 . . . 4 (𝜑 → ((𝐶𝑁)(𝑐 ∈ 2𝑜, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1𝑜, ∅))𝑁) = if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1𝑜, ∅))
5810, 30, 573eqtrd 2689 . . 3 (𝜑 → (𝐶‘(𝑁 + 1)) = if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1𝑜, ∅))
5958eleq2d 2716 . 2 (𝜑 → (∅ ∈ (𝐶‘(𝑁 + 1)) ↔ ∅ ∈ if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1𝑜, ∅)))
60 noel 3952 . . . . 5 ¬ ∅ ∈ ∅
61 iffalse 4128 . . . . . 6 (¬ cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)) → if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1𝑜, ∅) = ∅)
6261eleq2d 2716 . . . . 5 (¬ cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)) → (∅ ∈ if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1𝑜, ∅) ↔ ∅ ∈ ∅))
6360, 62mtbiri 316 . . . 4 (¬ cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)) → ¬ ∅ ∈ if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1𝑜, ∅))
6463con4i 113 . . 3 (∅ ∈ if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1𝑜, ∅) → cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)))
65 0lt1o 7629 . . . 4 ∅ ∈ 1𝑜
66 iftrue 4125 . . . 4 (cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)) → if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1𝑜, ∅) = 1𝑜)
6765, 66syl5eleqr 2737 . . 3 (cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)) → ∅ ∈ if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1𝑜, ∅))
6864, 67impbii 199 . 2 (∅ ∈ if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1𝑜, ∅) ↔ cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)))
6959, 68syl6bb 276 1 (𝜑 → (∅ ∈ (𝐶‘(𝑁 + 1)) ↔ cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁))))