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 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.)
Hypotheses
Ref Expression
sadval.c 𝐶 = seq0((𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅)), (𝑛 ∈ ℕ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 12272 . . . . . . 7 0 = (ℤ‘0)
31, 2eleqtrdi 2903 . . . . . 6 (𝜑𝑁 ∈ (ℤ‘0))
4 seqp1 13383 . . . . . 6 (𝑁 ∈ (ℤ‘0) → (seq0((𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘(𝑁 + 1)) = ((seq0((𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘𝑁)(𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅))((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1))))
53, 4syl 17 . . . . 5 (𝜑 → (seq0((𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘(𝑁 + 1)) = ((seq0((𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘𝑁)(𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅))((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1))))
6 sadval.c . . . . . 6 𝐶 = seq0((𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))
76fveq1i 6650 . . . . 5 (𝐶‘(𝑁 + 1)) = (seq0((𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘(𝑁 + 1))
86fveq1i 6650 . . . . . 6 (𝐶𝑁) = (seq0((𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘𝑁)
98oveq1i 7149 . . . . 5 ((𝐶𝑁)(𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅))((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1))) = ((seq0((𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅)), (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))))‘𝑁)(𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅))((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1)))
105, 7, 93eqtr4g 2861 . . . 4 (𝜑 → (𝐶‘(𝑁 + 1)) = ((𝐶𝑁)(𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅))((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1))))
11 peano2nn0 11929 . . . . . . 7 (𝑁 ∈ ℕ0 → (𝑁 + 1) ∈ ℕ0)
12 eqeq1 2805 . . . . . . . . 9 (𝑛 = (𝑁 + 1) → (𝑛 = 0 ↔ (𝑁 + 1) = 0))
13 oveq1 7146 . . . . . . . . 9 (𝑛 = (𝑁 + 1) → (𝑛 − 1) = ((𝑁 + 1) − 1))
1412, 13ifbieq2d 4453 . . . . . . . 8 (𝑛 = (𝑁 + 1) → if(𝑛 = 0, ∅, (𝑛 − 1)) = if((𝑁 + 1) = 0, ∅, ((𝑁 + 1) − 1)))
15 eqid 2801 . . . . . . . 8 (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1))) = (𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))
16 0ex 5178 . . . . . . . . 9 ∅ ∈ V
17 ovex 7172 . . . . . . . . 9 ((𝑁 + 1) − 1) ∈ V
1816, 17ifex 4476 . . . . . . . 8 if((𝑁 + 1) = 0, ∅, ((𝑁 + 1) − 1)) ∈ V
1914, 15, 18fvmpt 6749 . . . . . . 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 11928 . . . . . . . . 9 (𝑁 ∈ ℕ0 → (𝑁 + 1) ∈ ℕ)
221, 21syl 17 . . . . . . . 8 (𝜑 → (𝑁 + 1) ∈ ℕ)
2322nnne0d 11679 . . . . . . 7 (𝜑 → (𝑁 + 1) ≠ 0)
24 ifnefalse 4440 . . . . . . 7 ((𝑁 + 1) ≠ 0 → if((𝑁 + 1) = 0, ∅, ((𝑁 + 1) − 1)) = ((𝑁 + 1) − 1))
2523, 24syl 17 . . . . . 6 (𝜑 → if((𝑁 + 1) = 0, ∅, ((𝑁 + 1) − 1)) = ((𝑁 + 1) − 1))
261nn0cnd 11949 . . . . . . 7 (𝜑𝑁 ∈ ℂ)
27 1cnd 10629 . . . . . . 7 (𝜑 → 1 ∈ ℂ)
2826, 27pncand 10991 . . . . . 6 (𝜑 → ((𝑁 + 1) − 1) = 𝑁)
2920, 25, 283eqtrd 2840 . . . . 5 (𝜑 → ((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1)) = 𝑁)
3029oveq2d 7155 . . . 4 (𝜑 → ((𝐶𝑁)(𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅))((𝑛 ∈ ℕ0 ↦ if(𝑛 = 0, ∅, (𝑛 − 1)))‘(𝑁 + 1))) = ((𝐶𝑁)(𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅))𝑁))
31 sadval.a . . . . . . 7 (𝜑𝐴 ⊆ ℕ0)
32 sadval.b . . . . . . 7 (𝜑𝐵 ⊆ ℕ0)
3331, 32, 6sadcf 15795 . . . . . 6 (𝜑𝐶:ℕ0⟶2o)
3433, 1ffvelrnd 6833 . . . . 5 (𝜑 → (𝐶𝑁) ∈ 2o)
35 simpr 488 . . . . . . . . 9 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → 𝑦 = 𝑁)
3635eleq1d 2877 . . . . . . . 8 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → (𝑦𝐴𝑁𝐴))
3735eleq1d 2877 . . . . . . . 8 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → (𝑦𝐵𝑁𝐵))
38 simpl 486 . . . . . . . . 9 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → 𝑥 = (𝐶𝑁))
3938eleq2d 2878 . . . . . . . 8 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → (∅ ∈ 𝑥 ↔ ∅ ∈ (𝐶𝑁)))
4036, 37, 39cadbi123d 1612 . . . . . . 7 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → (cadd(𝑦𝐴, 𝑦𝐵, ∅ ∈ 𝑥) ↔ cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁))))
4140ifbid 4450 . . . . . 6 ((𝑥 = (𝐶𝑁) ∧ 𝑦 = 𝑁) → if(cadd(𝑦𝐴, 𝑦𝐵, ∅ ∈ 𝑥), 1o, ∅) = if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1o, ∅))
42 biidd 265 . . . . . . . . 9 (𝑐 = 𝑥 → (𝑚𝐴𝑚𝐴))
43 biidd 265 . . . . . . . . 9 (𝑐 = 𝑥 → (𝑚𝐵𝑚𝐵))
44 eleq2w 2876 . . . . . . . . 9 (𝑐 = 𝑥 → (∅ ∈ 𝑐 ↔ ∅ ∈ 𝑥))
4542, 43, 44cadbi123d 1612 . . . . . . . 8 (𝑐 = 𝑥 → (cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐) ↔ cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑥)))
4645ifbid 4450 . . . . . . 7 (𝑐 = 𝑥 → if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅) = if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑥), 1o, ∅))
47 eleq1w 2875 . . . . . . . . 9 (𝑚 = 𝑦 → (𝑚𝐴𝑦𝐴))
48 eleq1w 2875 . . . . . . . . 9 (𝑚 = 𝑦 → (𝑚𝐵𝑦𝐵))
49 biidd 265 . . . . . . . . 9 (𝑚 = 𝑦 → (∅ ∈ 𝑥 ↔ ∅ ∈ 𝑥))
5047, 48, 49cadbi123d 1612 . . . . . . . 8 (𝑚 = 𝑦 → (cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑥) ↔ cadd(𝑦𝐴, 𝑦𝐵, ∅ ∈ 𝑥)))
5150ifbid 4450 . . . . . . 7 (𝑚 = 𝑦 → if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑥), 1o, ∅) = if(cadd(𝑦𝐴, 𝑦𝐵, ∅ ∈ 𝑥), 1o, ∅))
5246, 51cbvmpov 7232 . . . . . 6 (𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅)) = (𝑥 ∈ 2o, 𝑦 ∈ ℕ0 ↦ if(cadd(𝑦𝐴, 𝑦𝐵, ∅ ∈ 𝑥), 1o, ∅))
53 1oex 8097 . . . . . . 7 1o ∈ V
5453, 16ifex 4476 . . . . . 6 if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1o, ∅) ∈ V
5541, 52, 54ovmpoa 7288 . . . . 5 (((𝐶𝑁) ∈ 2o𝑁 ∈ ℕ0) → ((𝐶𝑁)(𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅))𝑁) = if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1o, ∅))
5634, 1, 55syl2anc 587 . . . 4 (𝜑 → ((𝐶𝑁)(𝑐 ∈ 2o, 𝑚 ∈ ℕ0 ↦ if(cadd(𝑚𝐴, 𝑚𝐵, ∅ ∈ 𝑐), 1o, ∅))𝑁) = if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1o, ∅))
5710, 30, 563eqtrd 2840 . . 3 (𝜑 → (𝐶‘(𝑁 + 1)) = if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1o, ∅))
5857eleq2d 2878 . 2 (𝜑 → (∅ ∈ (𝐶‘(𝑁 + 1)) ↔ ∅ ∈ if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1o, ∅)))
59 noel 4250 . . . . 5 ¬ ∅ ∈ ∅
60 iffalse 4437 . . . . . 6 (¬ cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)) → if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1o, ∅) = ∅)
6160eleq2d 2878 . . . . 5 (¬ cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)) → (∅ ∈ if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1o, ∅) ↔ ∅ ∈ ∅))
6259, 61mtbiri 330 . . . 4 (¬ cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)) → ¬ ∅ ∈ if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1o, ∅))
6362con4i 114 . . 3 (∅ ∈ if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1o, ∅) → cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)))
64 0lt1o 8116 . . . 4 ∅ ∈ 1o
65 iftrue 4434 . . . 4 (cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)) → if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1o, ∅) = 1o)
6664, 65eleqtrrid 2900 . . 3 (cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)) → ∅ ∈ if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1o, ∅))
6763, 66impbii 212 . 2 (∅ ∈ if(cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)), 1o, ∅) ↔ cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁)))
6858, 67syl6bb 290 1 (𝜑 → (∅ ∈ (𝐶‘(𝑁 + 1)) ↔ cadd(𝑁𝐴, 𝑁𝐵, ∅ ∈ (𝐶𝑁))))