Theorem: List.toFinsupp_append
File: Mathlib/Data/List/ToFinsupp.lean

tactic: ext n
state_before: M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
⊢ (l₁ ++ l₂).toFinsupp = l₁.toFinsupp + Finsupp.embDomain (addLeftEmbedding l₁.length) l₂.toFinsupp
state_after: case h
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n✝ : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
n : ℕ
⊢ (l₁ ++ l₂).toFinsupp n = (l₁.toFinsupp + Finsupp.embDomain (addLeftEmbedding l₁.length) l₂.toFinsupp) n

tactic: simp only [toFinsupp_apply, Finsupp.add_apply]
state_before: case h
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n✝ : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
n : ℕ
⊢ (l₁ ++ l₂).toFinsupp n = (l₁.toFinsupp + Finsupp.embDomain (addLeftEmbedding l₁.length) l₂.toFinsupp) n
state_after: case h
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n✝ : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
n : ℕ
⊢ (l₁ ++ l₂).getD n 0 = l₁.getD n 0 + (Finsupp.embDomain (addLeftEmbedding l₁.length) l₂.toFinsupp) n

tactic: cases lt_or_le n l₁.length with
| inl h =>
  rw [getD_append _ _ _ _ h, Finsupp.embDomain_notin_range, add_zero]
  rintro ⟨k, rfl : length l₁ + k = n⟩
  omega
| inr h =>
  rcases Nat.exists_eq_add_of_le h with ⟨k, rfl⟩
  rw [getD_append_right _ _ _ _ h, Nat.add_sub_cancel_left, getD_eq_default _ _ h, zero_add]
  exact Eq.symm (Finsupp.embDomain_apply _ _ _)
state_before: case h
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n✝ : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
n : ℕ
⊢ (l₁ ++ l₂).getD n 0 = l₁.getD n 0 + (Finsupp.embDomain (addLeftEmbedding l₁.length) l₂.toFinsupp) n
state_after: no goals

tactic: rw [getD_append _ _ _ _ h, Finsupp.embDomain_notin_range, add_zero]
state_before: case h.inl
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n✝ : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
n : ℕ
h : n < l₁.length
⊢ (l₁ ++ l₂).getD n 0 = l₁.getD n 0 + (Finsupp.embDomain (addLeftEmbedding l₁.length) l₂.toFinsupp) n
state_after: case h.inl.h
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n✝ : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
n : ℕ
h : n < l₁.length
⊢ n ∉ Set.range ⇑(addLeftEmbedding l₁.length)

tactic: rintro ⟨k, rfl : length l₁ + k = n⟩
state_before: case h.inl.h
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n✝ : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
n : ℕ
h : n < l₁.length
⊢ n ∉ Set.range ⇑(addLeftEmbedding l₁.length)
state_after: case h.inl.h.intro
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
k : ℕ
h : l₁.length + k < l₁.length
⊢ False

tactic: omega
state_before: case h.inl.h.intro
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
k : ℕ
h : l₁.length + k < l₁.length
⊢ False
state_after: no goals

tactic: rcases Nat.exists_eq_add_of_le h with ⟨k, rfl⟩
state_before: case h.inr
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n✝ : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
n : ℕ
h : l₁.length ≤ n
⊢ (l₁ ++ l₂).getD n 0 = l₁.getD n 0 + (Finsupp.embDomain (addLeftEmbedding l₁.length) l₂.toFinsupp) n
state_after: case h.inr.intro
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
k : ℕ
h : l₁.length ≤ l₁.length + k
⊢ (l₁ ++ l₂).getD (l₁.length + k) 0 =
    l₁.getD (l₁.length + k) 0 + (Finsupp.embDomain (addLeftEmbedding l₁.length) l₂.toFinsupp) (l₁.length + k)

tactic: rw [getD_append_right _ _ _ _ h, Nat.add_sub_cancel_left, getD_eq_default _ _ h, zero_add]
state_before: case h.inr.intro
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
k : ℕ
h : l₁.length ≤ l₁.length + k
⊢ (l₁ ++ l₂).getD (l₁.length + k) 0 =
    l₁.getD (l₁.length + k) 0 + (Finsupp.embDomain (addLeftEmbedding l₁.length) l₂.toFinsupp) (l₁.length + k)
state_after: case h.inr.intro
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
k : ℕ
h : l₁.length ≤ l₁.length + k
⊢ l₂.getD k 0 = (Finsupp.embDomain (addLeftEmbedding l₁.length) l₂.toFinsupp) (l₁.length + k)

tactic: exact Eq.symm (Finsupp.embDomain_apply _ _ _)
state_before: case h.inr.intro
M : Type u_1
inst✝⁵ : Zero M
l : List M
inst✝⁴ : DecidablePred fun x => l.getD x 0 ≠ 0
n : ℕ
R : Type u_2
inst✝³ : AddZeroClass R
l₁ l₂ : List R
inst✝² : DecidablePred fun x => (l₁ ++ l₂).getD x 0 ≠ 0
inst✝¹ : DecidablePred fun x => l₁.getD x 0 ≠ 0
inst✝ : DecidablePred fun x => l₂.getD x 0 ≠ 0
k : ℕ
h : l₁.length ≤ l₁.length + k
⊢ l₂.getD k 0 = (Finsupp.embDomain (addLeftEmbedding l₁.length) l₂.toFinsupp) (l₁.length + k)
state_after: no goals