Theorem: List.oldMapIdxCore_append
File: Mathlib/Data/List/Indexes.lean

tactic: intros f n l₁ l₂
state_before: α : Type u
β : Type v
⊢ ∀ (f : ℕ → α → β) (n : ℕ) (l₁ l₂ : List α),
    List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂

tactic: generalize e : (l₁ ++ l₂).length = len
state_before: α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ l₂ : List α
⊢ List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂

tactic: revert n l₁ l₂
state_before: α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ l₂ : List α
len : ℕ
e : length (l₁ ++ l₂) = len
⊢ List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂

tactic: induction' len with len ih <;> intros n l₁ l₂ h
state_before: α : Type u
β : Type v
f : ℕ → α → β
len : ℕ
⊢ ∀ (n : ℕ) (l₁ l₂ : List α),
    length (l₁ ++ l₂) = len →
      List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂

tactic: have l₁_nil : l₁ = [] := by cases l₁; rfl; contradiction
state_before: case zero
α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ l₂ : List α
h : length (l₁ ++ l₂) = Nat.zero
⊢ List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂

tactic: have l₂_nil : l₂ = [] := by cases l₂; rfl; rw [List.length_append] at h; contradiction
state_before: case zero
α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ l₂ : List α
h : length (l₁ ++ l₂) = Nat.zero
l₁_nil : l₁ = []
⊢ List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂

tactic: simp only [l₁_nil, l₂_nil]
state_before: case zero
α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ l₂ : List α
h : length (l₁ ++ l₂) = Nat.zero
l₁_nil : l₁ = []
l₂_nil : l₂ = []
⊢ List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂

tactic: rfl
state_before: case zero
α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ l₂ : List α
h : length (l₁ ++ l₂) = Nat.zero
l₁_nil : l₁ = []
l₂_nil : l₂ = []
⊢ List.oldMapIdxCore f n ([] ++ []) = List.oldMapIdxCore f n [] ++ List.oldMapIdxCore f (n + length []) []

tactic: cases l₁
state_before: α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ l₂ : List α
h : length (l₁ ++ l₂) = Nat.zero
⊢ l₁ = []

tactic: rfl
state_before: case nil
α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₂ : List α
h : length ([] ++ l₂) = Nat.zero
⊢ [] = []

case cons
α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₂ : List α
head✝ : α
tail✝ : List α
h : length (head✝ :: tail✝ ++ l₂) = Nat.zero
⊢ head✝ :: tail✝ = []

tactic: contradiction
state_before: case cons
α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₂ : List α
head✝ : α
tail✝ : List α
h : length (head✝ :: tail✝ ++ l₂) = Nat.zero
⊢ head✝ :: tail✝ = []

tactic: cases l₂
state_before: α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ l₂ : List α
h : length (l₁ ++ l₂) = Nat.zero
l₁_nil : l₁ = []
⊢ l₂ = []

tactic: rfl
state_before: case nil
α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ : List α
l₁_nil : l₁ = []
h : length (l₁ ++ []) = Nat.zero
⊢ [] = []

case cons
α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ : List α
l₁_nil : l₁ = []
head✝ : α
tail✝ : List α
h : length (l₁ ++ head✝ :: tail✝) = Nat.zero
⊢ head✝ :: tail✝ = []

tactic: rw [List.length_append] at h
state_before: case cons
α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ : List α
l₁_nil : l₁ = []
head✝ : α
tail✝ : List α
h : length (l₁ ++ head✝ :: tail✝) = Nat.zero
⊢ head✝ :: tail✝ = []

tactic: contradiction
state_before: case cons
α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ : List α
l₁_nil : l₁ = []
head✝ : α
tail✝ : List α
h : length l₁ + length (head✝ :: tail✝) = Nat.zero
⊢ head✝ :: tail✝ = []

tactic: cases' l₁ with head tail
state_before: case succ
α : Type u
β : Type v
f : ℕ → α → β
len : ℕ
ih :
  ∀ (n : ℕ) (l₁ l₂ : List α),
    length (l₁ ++ l₂) = len →
      List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂
n : ℕ
l₁ l₂ : List α
h : length (l₁ ++ l₂) = Nat.succ len
⊢ List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂

tactic: rfl
state_before: case succ.nil
α : Type u
β : Type v
f : ℕ → α → β
len : ℕ
ih :
  ∀ (n : ℕ) (l₁ l₂ : List α),
    length (l₁ ++ l₂) = len →
      List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂
n : ℕ
l₂ : List α
h : length ([] ++ l₂) = Nat.succ len
⊢ List.oldMapIdxCore f n ([] ++ l₂) = List.oldMapIdxCore f n [] ++ List.oldMapIdxCore f (n + length []) l₂

tactic: simp only [List.oldMapIdxCore, List.append_eq, length_cons, cons_append,cons.injEq, true_and]
state_before: case succ.cons
α : Type u
β : Type v
f : ℕ → α → β
len : ℕ
ih :
  ∀ (n : ℕ) (l₁ l₂ : List α),
    length (l₁ ++ l₂) = len →
      List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂
n : ℕ
l₂ : List α
head : α
tail : List α
h : length (head :: tail ++ l₂) = Nat.succ len
⊢ List.oldMapIdxCore f n (head :: tail ++ l₂) =
    List.oldMapIdxCore f n (head :: tail) ++ List.oldMapIdxCore f (n + length (head :: tail)) l₂

tactic: suffices : n + Nat.succ (length tail) = n + 1 + tail.length
state_before: case succ.cons
α : Type u
β : Type v
f : ℕ → α → β
len : ℕ
ih :
  ∀ (n : ℕ) (l₁ l₂ : List α),
    length (l₁ ++ l₂) = len →
      List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂
n : ℕ
l₂ : List α
head : α
tail : List α
h : length (head :: tail ++ l₂) = Nat.succ len
⊢ List.oldMapIdxCore f (n + 1) (tail ++ l₂) =
    List.oldMapIdxCore f (n + 1) tail ++ List.oldMapIdxCore f (n + Nat.succ (length tail)) l₂

tactic: { rw [this]
  apply ih (n + 1) _ _ _
  simp only [cons_append, length_cons, length_append, Nat.succ.injEq] at h
  simp only [length_append, h] }
state_before: case succ.cons
α : Type u
β : Type v
f : ℕ → α → β
len : ℕ
ih :
  ∀ (n : ℕ) (l₁ l₂ : List α),
    length (l₁ ++ l₂) = len →
      List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂
n : ℕ
l₂ : List α
head : α
tail : List α
h : length (head :: tail ++ l₂) = Nat.succ len
this : n + Nat.succ (length tail) = n + 1 + length tail
⊢ List.oldMapIdxCore f (n + 1) (tail ++ l₂) =
    List.oldMapIdxCore f (n + 1) tail ++ List.oldMapIdxCore f (n + Nat.succ (length tail)) l₂

case this
α : Type u
β : Type v
f : ℕ → α → β
len : ℕ
ih :
  ∀ (n : ℕ) (l₁ l₂ : List α),
    length (l₁ ++ l₂) = len →
      List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂
n : ℕ
l₂ : List α
head : α
tail : List α
h : length (head :: tail ++ l₂) = Nat.succ len
⊢ n + Nat.succ (length tail) = n + 1 + length tail

tactic: { rw [Nat.add_assoc]; simp only [Nat.add_comm] }
state_before: case this
α : Type u
β : Type v
f : ℕ → α → β
len : ℕ
ih :
  ∀ (n : ℕ) (l₁ l₂ : List α),
    length (l₁ ++ l₂) = len →
      List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + length l₁) l₂
n : ℕ
l₂ : List α
head : α
tail : List α
h : length (head :: tail ++ l₂) = Nat.succ len
⊢ n + Nat.succ (length tail) = n + 1 + length tail