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 + l₁.length) l₂
state_after: α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ l₂ : List α
⊢ List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + l₁.length) 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 + l₁.length) l₂
state_after: α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ l₂ : List α
len : ℕ
e : (l₁ ++ l₂).length = len
⊢ List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + l₁.length) l₂

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

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

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

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

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

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

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

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

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

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

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

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

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 : (l₁ ++ head✝ :: tail✝).length = 0
⊢ head✝ :: tail✝ = []
state_after: case cons
α : Type u
β : Type v
f : ℕ → α → β
n : ℕ
l₁ : List α
l₁_nil : l₁ = []
head✝ : α
tail✝ : List α
h : l₁.length + (head✝ :: tail✝).length = 0
⊢ head✝ :: tail✝ = []

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

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

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

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

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 α),
    (l₁ ++ l₂).length = len →
      List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + l₁.length) l₂
n : ℕ
l₂ : List α
head : α
tail : List α
h : (head :: tail ++ l₂).length = len + 1
⊢ List.oldMapIdxCore f n (head :: tail ++ l₂) =
    List.oldMapIdxCore f n (head :: tail) ++ List.oldMapIdxCore f (n + (head :: tail).length) l₂
state_after: case succ.cons
α : Type u
β : Type v
f : ℕ → α → β
len : ℕ
ih :
  ∀ (n : ℕ) (l₁ l₂ : List α),
    (l₁ ++ l₂).length = len →
      List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + l₁.length) l₂
n : ℕ
l₂ : List α
head : α
tail : List α
h : (head :: tail ++ l₂).length = len + 1
⊢ List.oldMapIdxCore f (n + 1) (tail ++ l₂) =
    List.oldMapIdxCore f (n + 1) tail ++ List.oldMapIdxCore f (n + (tail.length + 1)) l₂

tactic: suffices n + Nat.succ (length tail) = n + 1 + tail.length by
  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 α),
    (l₁ ++ l₂).length = len →
      List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + l₁.length) l₂
n : ℕ
l₂ : List α
head : α
tail : List α
h : (head :: tail ++ l₂).length = len + 1
⊢ List.oldMapIdxCore f (n + 1) (tail ++ l₂) =
    List.oldMapIdxCore f (n + 1) tail ++ List.oldMapIdxCore f (n + (tail.length + 1)) l₂
state_after: case succ.cons
α : Type u
β : Type v
f : ℕ → α → β
len : ℕ
ih :
  ∀ (n : ℕ) (l₁ l₂ : List α),
    (l₁ ++ l₂).length = len →
      List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + l₁.length) l₂
n : ℕ
l₂ : List α
head : α
tail : List α
h : (head :: tail ++ l₂).length = len + 1
⊢ n + tail.length.succ = n + 1 + tail.length

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

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

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

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

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

tactic: simp only [length_append, h]
state_before: α : Type u
β : Type v
f : ℕ → α → β
len : ℕ
ih :
  ∀ (n : ℕ) (l₁ l₂ : List α),
    (l₁ ++ l₂).length = len →
      List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + l₁.length) l₂
n : ℕ
l₂ : List α
head : α
tail : List α
this : n + tail.length.succ = n + 1 + tail.length
h : tail.length + l₂.length = len
⊢ (tail ++ l₂).length = len
state_after: no goals