Theorem: Levenshtein.impl_length
File: Mathlib/Data/List/EditDistance/Defs.lean

tactic: induction xs generalizing d with
| nil => rfl
| cons x xs ih =>
  dsimp [impl]
  match d, w with
  | ⟨d₁ :: d₂ :: ds, _⟩, w =>
    dsimp
    congr 1
    exact ih ⟨d₂ :: ds, (by simp)⟩ (by simpa using w)
state_before: α : Type u_1
β : Type u_2
δ : Type u_3
inst✝¹ : AddZeroClass δ
inst✝ : Min δ
C : Cost α β δ
x : α
xs : List α
y : β
d✝ : δ
ds : List δ
w✝ : 0 < (d✝ :: ds).length
d : { r // 0 < r.length }
w : d.val.length = xs.length + 1
⊢ (impl C xs y d).val.length = xs.length + 1
state_after: no goals

tactic: rfl
state_before: case nil
α : Type u_1
β : Type u_2
δ : Type u_3
inst✝¹ : AddZeroClass δ
inst✝ : Min δ
C : Cost α β δ
x : α
xs : List α
y : β
d✝ : δ
ds : List δ
w✝ : 0 < (d✝ :: ds).length
d : { r // 0 < r.length }
w : d.val.length = [].length + 1
⊢ (impl C [] y d).val.length = [].length + 1
state_after: no goals

tactic: dsimp [impl]
state_before: case cons
α : Type u_1
β : Type u_2
δ : Type u_3
inst✝¹ : AddZeroClass δ
inst✝ : Min δ
C : Cost α β δ
x✝ : α
xs✝ : List α
y : β
d✝ : δ
ds : List δ
w✝ : 0 < (d✝ :: ds).length
x : α
xs : List α
ih : ∀ (d : { r // 0 < r.length }), d.val.length = xs.length + 1 → (impl C xs y d).val.length = xs.length + 1
d : { r // 0 < r.length }
w : d.val.length = (x :: xs).length + 1
⊢ (impl C (x :: xs) y d).val.length = (x :: xs).length + 1
state_after: case cons
α : Type u_1
β : Type u_2
δ : Type u_3
inst✝¹ : AddZeroClass δ
inst✝ : Min δ
C : Cost α β δ
x✝ : α
xs✝ : List α
y : β
d✝ : δ
ds : List δ
w✝ : 0 < (d✝ :: ds).length
x : α
xs : List α
ih : ∀ (d : { r // 0 < r.length }), d.val.length = xs.length + 1 → (impl C xs y d).val.length = xs.length + 1
d : { r // 0 < r.length }
w : d.val.length = (x :: xs).length + 1
⊢ (List.foldr
          (fun x x_1 =>
            ⟨min (C.delete x.fst + x_1.val[0]) (min (C.insert y + x.2.fst) (C.substitute x.fst y + x.2.snd)) :: x_1.val,
              ⋯⟩)
          ⟨[C.insert y + d.val.getLast ⋯], impl.proof_3⟩ ((x :: xs).zip (d.val.zip d.val.tail))).val.length =
    xs.length + 1 + 1

tactic: match d, w with
| ⟨d₁ :: d₂ :: ds, _⟩, w =>
  dsimp
  congr 1
  exact ih ⟨d₂ :: ds, (by simp)⟩ (by simpa using w)
state_before: case cons
α : Type u_1
β : Type u_2
δ : Type u_3
inst✝¹ : AddZeroClass δ
inst✝ : Min δ
C : Cost α β δ
x✝ : α
xs✝ : List α
y : β
d✝ : δ
ds : List δ
w✝ : 0 < (d✝ :: ds).length
x : α
xs : List α
ih : ∀ (d : { r // 0 < r.length }), d.val.length = xs.length + 1 → (impl C xs y d).val.length = xs.length + 1
d : { r // 0 < r.length }
w : d.val.length = (x :: xs).length + 1
⊢ (List.foldr
          (fun x x_1 =>
            ⟨min (C.delete x.fst + x_1.val[0]) (min (C.insert y + x.2.fst) (C.substitute x.fst y + x.2.snd)) :: x_1.val,
              ⋯⟩)
          ⟨[C.insert y + d.val.getLast ⋯], impl.proof_3⟩ ((x :: xs).zip (d.val.zip d.val.tail))).val.length =
    xs.length + 1 + 1
state_after: no goals

tactic: dsimp
state_before: α : Type u_1
β : Type u_2
δ : Type u_3
inst✝¹ : AddZeroClass δ
inst✝ : Min δ
C : Cost α β δ
x✝ : α
xs✝ : List α
y : β
d✝ : δ
ds✝ : List δ
w✝¹ : 0 < (d✝ :: ds✝).length
x : α
xs : List α
ih : ∀ (d : { r // 0 < r.length }), d.val.length = xs.length + 1 → (impl C xs y d).val.length = xs.length + 1
d : { r // 0 < r.length }
w✝ : d.val.length = (x :: xs).length + 1
d₁ d₂ : δ
ds : List δ
property✝ : 0 < (d₁ :: d₂ :: ds).length
w : ⟨d₁ :: d₂ :: ds, property✝⟩.val.length = (x :: xs).length + 1
⊢ (List.foldr
          (fun x x_1 =>
            ⟨min (C.delete x.fst + x_1.val[0]) (min (C.insert y + x.2.fst) (C.substitute x.fst y + x.2.snd)) :: x_1.val,
              ⋯⟩)
          ⟨[C.insert y + ⟨d₁ :: d₂ :: ds, property✝⟩.val.getLast ⋯], impl.proof_3⟩
          ((x :: xs).zip (⟨d₁ :: d₂ :: ds, property✝⟩.val.zip ⟨d₁ :: d₂ :: ds, property✝⟩.val.tail))).val.length =
    xs.length + 1 + 1
state_after: α : Type u_1
β : Type u_2
δ : Type u_3
inst✝¹ : AddZeroClass δ
inst✝ : Min δ
C : Cost α β δ
x✝ : α
xs✝ : List α
y : β
d✝ : δ
ds✝ : List δ
w✝¹ : 0 < (d✝ :: ds✝).length
x : α
xs : List α
ih : ∀ (d : { r // 0 < r.length }), d.val.length = xs.length + 1 → (impl C xs y d).val.length = xs.length + 1
d : { r // 0 < r.length }
w✝ : d.val.length = (x :: xs).length + 1
d₁ d₂ : δ
ds : List δ
property✝ : 0 < (d₁ :: d₂ :: ds).length
w : ⟨d₁ :: d₂ :: ds, property✝⟩.val.length = (x :: xs).length + 1
⊢ (List.foldr
            (fun x x_1 =>
              ⟨min (C.delete x.fst + x_1.val[0]) (min (C.insert y + x.2.fst) (C.substitute x.fst y + x.2.snd)) ::
                  x_1.val,
                ⋯⟩)
            ⟨[C.insert y + (d₁ :: d₂ :: ds).getLast ⋯], impl.proof_3⟩ (xs.zip ((d₂ :: ds).zip ds))).val.length +
      1 =
    xs.length + 1 + 1

tactic: congr 1
state_before: α : Type u_1
β : Type u_2
δ : Type u_3
inst✝¹ : AddZeroClass δ
inst✝ : Min δ
C : Cost α β δ
x✝ : α
xs✝ : List α
y : β
d✝ : δ
ds✝ : List δ
w✝¹ : 0 < (d✝ :: ds✝).length
x : α
xs : List α
ih : ∀ (d : { r // 0 < r.length }), d.val.length = xs.length + 1 → (impl C xs y d).val.length = xs.length + 1
d : { r // 0 < r.length }
w✝ : d.val.length = (x :: xs).length + 1
d₁ d₂ : δ
ds : List δ
property✝ : 0 < (d₁ :: d₂ :: ds).length
w : ⟨d₁ :: d₂ :: ds, property✝⟩.val.length = (x :: xs).length + 1
⊢ (List.foldr
            (fun x x_1 =>
              ⟨min (C.delete x.fst + x_1.val[0]) (min (C.insert y + x.2.fst) (C.substitute x.fst y + x.2.snd)) ::
                  x_1.val,
                ⋯⟩)
            ⟨[C.insert y + (d₁ :: d₂ :: ds).getLast ⋯], impl.proof_3⟩ (xs.zip ((d₂ :: ds).zip ds))).val.length +
      1 =
    xs.length + 1 + 1
state_after: case e_a
α : Type u_1
β : Type u_2
δ : Type u_3
inst✝¹ : AddZeroClass δ
inst✝ : Min δ
C : Cost α β δ
x✝ : α
xs✝ : List α
y : β
d✝ : δ
ds✝ : List δ
w✝¹ : 0 < (d✝ :: ds✝).length
x : α
xs : List α
ih : ∀ (d : { r // 0 < r.length }), d.val.length = xs.length + 1 → (impl C xs y d).val.length = xs.length + 1
d : { r // 0 < r.length }
w✝ : d.val.length = (x :: xs).length + 1
d₁ d₂ : δ
ds : List δ
property✝ : 0 < (d₁ :: d₂ :: ds).length
w : ⟨d₁ :: d₂ :: ds, property✝⟩.val.length = (x :: xs).length + 1
⊢ (List.foldr
          (fun x x_1 =>
            ⟨min (C.delete x.fst + x_1.val[0]) (min (C.insert y + x.2.fst) (C.substitute x.fst y + x.2.snd)) :: x_1.val,
              ⋯⟩)
          ⟨[C.insert y + (d₁ :: d₂ :: ds).getLast ⋯], impl.proof_3⟩ (xs.zip ((d₂ :: ds).zip ds))).val.length =
    xs.length + 1

tactic: exact ih ⟨d₂ :: ds, (by simp)⟩ (by simpa using w)
state_before: case e_a
α : Type u_1
β : Type u_2
δ : Type u_3
inst✝¹ : AddZeroClass δ
inst✝ : Min δ
C : Cost α β δ
x✝ : α
xs✝ : List α
y : β
d✝ : δ
ds✝ : List δ
w✝¹ : 0 < (d✝ :: ds✝).length
x : α
xs : List α
ih : ∀ (d : { r // 0 < r.length }), d.val.length = xs.length + 1 → (impl C xs y d).val.length = xs.length + 1
d : { r // 0 < r.length }
w✝ : d.val.length = (x :: xs).length + 1
d₁ d₂ : δ
ds : List δ
property✝ : 0 < (d₁ :: d₂ :: ds).length
w : ⟨d₁ :: d₂ :: ds, property✝⟩.val.length = (x :: xs).length + 1
⊢ (List.foldr
          (fun x x_1 =>
            ⟨min (C.delete x.fst + x_1.val[0]) (min (C.insert y + x.2.fst) (C.substitute x.fst y + x.2.snd)) :: x_1.val,
              ⋯⟩)
          ⟨[C.insert y + (d₁ :: d₂ :: ds).getLast ⋯], impl.proof_3⟩ (xs.zip ((d₂ :: ds).zip ds))).val.length =
    xs.length + 1
state_after: no goals

tactic: simp
state_before: α : Type u_1
β : Type u_2
δ : Type u_3
inst✝¹ : AddZeroClass δ
inst✝ : Min δ
C : Cost α β δ
x✝ : α
xs✝ : List α
y : β
d✝ : δ
ds✝ : List δ
w✝¹ : 0 < (d✝ :: ds✝).length
x : α
xs : List α
ih : ∀ (d : { r // 0 < r.length }), d.val.length = xs.length + 1 → (impl C xs y d).val.length = xs.length + 1
d : { r // 0 < r.length }
w✝ : d.val.length = (x :: xs).length + 1
d₁ d₂ : δ
ds : List δ
property✝ : 0 < (d₁ :: d₂ :: ds).length
w : ⟨d₁ :: d₂ :: ds, property✝⟩.val.length = (x :: xs).length + 1
⊢ 0 < (d₂ :: ds).length
state_after: no goals

tactic: simpa using w
state_before: α : Type u_1
β : Type u_2
δ : Type u_3
inst✝¹ : AddZeroClass δ
inst✝ : Min δ
C : Cost α β δ
x✝ : α
xs✝ : List α
y : β
d✝ : δ
ds✝ : List δ
w✝¹ : 0 < (d✝ :: ds✝).length
x : α
xs : List α
ih : ∀ (d : { r // 0 < r.length }), d.val.length = xs.length + 1 → (impl C xs y d).val.length = xs.length + 1
d : { r // 0 < r.length }
w✝ : d.val.length = (x :: xs).length + 1
d₁ d₂ : δ
ds : List δ
property✝ : 0 < (d₁ :: d₂ :: ds).length
w : ⟨d₁ :: d₂ :: ds, property✝⟩.val.length = (x :: xs).length + 1
⊢ ⟨d₂ :: ds, ⋯⟩.val.length = xs.length + 1
state_after: no goals