Theorem: List.getElem?_inj
File: .lake/packages/batteries/Batteries/Data/List/Lemmas.lean

tactic: induction xs generalizing i j with
| nil => cases h₀
| cons x xs ih =>
  match i, j with
  | 0, 0 => rfl
  | i+1, j+1 => simp; cases h₁ with
    | cons ha h₁ =>
      simp only [getElem?_cons_succ] at h₂
      exact ih (Nat.lt_of_succ_lt_succ h₀) h₁ h₂
  | i+1, 0 => ?_
  | 0, j+1 => ?_
  all_goals
    simp only [get?_eq_getElem?, getElem?_cons_zero, getElem?_cons_succ] at h₂
    cases h₁; rename_i h' h
    have := h x ?_ rfl; cases this
    rw [mem_iff_get?]
    simp only [get?_eq_getElem?]
  exact ⟨_, h₂⟩; exact ⟨_ , h₂.symm⟩
state_before: i : Nat
α✝ : Type u_1
xs : List α✝
j : Nat
h₀ : i < xs.length
h₁ : xs.Nodup
h₂ : xs[i]? = xs[j]?
⊢ i = j
state_after: no goals

tactic: cases h₀
state_before: case nil
α✝ : Type u_1
i j : Nat
h₀ : i < [].length
h₁ : [].Nodup
h₂ : [][i]? = [][j]?
⊢ i = j
state_after: no goals

tactic: match i, j with
| 0, 0 => rfl
| i+1, j+1 => simp; cases h₁ with
  | cons ha h₁ =>
    simp only [getElem?_cons_succ] at h₂
    exact ih (Nat.lt_of_succ_lt_succ h₀) h₁ h₂
| i+1, 0 => ?_
| 0, j+1 => ?_
state_before: case cons
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j : Nat
h₀ : i < (x :: xs).length
h₁ : (x :: xs).Nodup
h₂ : (x :: xs)[i]? = (x :: xs)[j]?
⊢ i = j
state_after: case cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i✝ j : Nat
h₁ : (x :: xs).Nodup
i : Nat
h₀ : i + 1 < (x :: xs).length
h₂ : (x :: xs)[i + 1]? = (x :: xs)[0]?
⊢ i + 1 = 0

case cons.refine_2
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ : Nat
h₁ : (x :: xs).Nodup
j : Nat
h₀ : 0 < (x :: xs).length
h₂ : (x :: xs)[0]? = (x :: xs)[j + 1]?
⊢ 0 = j + 1

tactic: all_goals
  simp only [get?_eq_getElem?, getElem?_cons_zero, getElem?_cons_succ] at h₂
  cases h₁; rename_i h' h
  have := h x ?_ rfl; cases this
  rw [mem_iff_get?]
  simp only [get?_eq_getElem?]
state_before: case cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i✝ j : Nat
h₁ : (x :: xs).Nodup
i : Nat
h₀ : i + 1 < (x :: xs).length
h₂ : (x :: xs)[i + 1]? = (x :: xs)[0]?
⊢ i + 1 = 0

case cons.refine_2
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ : Nat
h₁ : (x :: xs).Nodup
j : Nat
h₀ : 0 < (x :: xs).length
h₂ : (x :: xs)[0]? = (x :: xs)[j + 1]?
⊢ 0 = j + 1
state_after: case cons.refine_1.cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i✝ j i : Nat
h₀ : i + 1 < (x :: xs).length
h₂ : xs[i]? = some x
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ ∃ n, xs[n]? = some x

case cons.refine_2.cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ ∃ n, xs[n]? = some x

tactic: exact ⟨_, h₂⟩
state_before: case cons.refine_1.cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i✝ j i : Nat
h₀ : i + 1 < (x :: xs).length
h₂ : xs[i]? = some x
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ ∃ n, xs[n]? = some x

case cons.refine_2.cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ ∃ n, xs[n]? = some x
state_after: case cons.refine_2.cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ ∃ n, xs[n]? = some x

tactic: exact ⟨_ , h₂.symm⟩
state_before: case cons.refine_2.cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ ∃ n, xs[n]? = some x
state_after: no goals

tactic: rfl
state_before: α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j : Nat
h₁ : (x :: xs).Nodup
h₀ : 0 < (x :: xs).length
h₂ : (x :: xs)[0]? = (x :: xs)[0]?
⊢ 0 = 0
state_after: no goals

tactic: simp
state_before: α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i✝ j✝ : Nat
h₁ : (x :: xs).Nodup
i j : Nat
h₀ : i + 1 < (x :: xs).length
h₂ : (x :: xs)[i + 1]? = (x :: xs)[j + 1]?
⊢ i + 1 = j + 1
state_after: α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i✝ j✝ : Nat
h₁ : (x :: xs).Nodup
i j : Nat
h₀ : i + 1 < (x :: xs).length
h₂ : (x :: xs)[i + 1]? = (x :: xs)[j + 1]?
⊢ i = j

tactic: cases h₁ with
| cons ha h₁ =>
simp only [getElem?_cons_succ] at h₂
exact ih (Nat.lt_of_succ_lt_succ h₀) h₁ h₂
state_before: α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i✝ j✝ : Nat
h₁ : (x :: xs).Nodup
i j : Nat
h₀ : i + 1 < (x :: xs).length
h₂ : (x :: xs)[i + 1]? = (x :: xs)[j + 1]?
⊢ i = j
state_after: no goals

tactic: simp only [getElem?_cons_succ] at h₂
state_before: case cons
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i✝ j✝ i j : Nat
h₀ : i + 1 < (x :: xs).length
h₂ : (x :: xs)[i + 1]? = (x :: xs)[j + 1]?
h₁ : Pairwise (fun x x_1 => x ≠ x_1) xs
ha : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ i = j
state_after: case cons
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i✝ j✝ i j : Nat
h₀ : i + 1 < (x :: xs).length
h₁ : Pairwise (fun x x_1 => x ≠ x_1) xs
ha : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
h₂ : xs[i]? = xs[j]?
⊢ i = j

tactic: exact ih (Nat.lt_of_succ_lt_succ h₀) h₁ h₂
state_before: case cons
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i✝ j✝ i j : Nat
h₀ : i + 1 < (x :: xs).length
h₁ : Pairwise (fun x x_1 => x ≠ x_1) xs
ha : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
h₂ : xs[i]? = xs[j]?
⊢ i = j
state_after: no goals

tactic: simp only [get?_eq_getElem?, getElem?_cons_zero, getElem?_cons_succ] at h₂
state_before: case cons.refine_2
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ : Nat
h₁ : (x :: xs).Nodup
j : Nat
h₀ : 0 < (x :: xs).length
h₂ : (x :: xs)[0]? = (x :: xs)[j + 1]?
⊢ 0 = j + 1
state_after: case cons.refine_2
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ : Nat
h₁ : (x :: xs).Nodup
j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
⊢ 0 = j + 1

tactic: cases h₁
state_before: case cons.refine_2
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ : Nat
h₁ : (x :: xs).Nodup
j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
⊢ 0 = j + 1
state_after: case cons.refine_2.cons
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
a✝¹ : Pairwise (fun x x_1 => x ≠ x_1) xs
a✝ : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ 0 = j + 1

tactic: rename_i h' h
state_before: case cons.refine_2.cons
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
a✝¹ : Pairwise (fun x x_1 => x ≠ x_1) xs
a✝ : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ 0 = j + 1
state_after: case cons.refine_2.cons
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ 0 = j + 1

tactic: have := h x ?_ rfl
state_before: case cons.refine_2.cons
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ 0 = j + 1
state_after: case cons.refine_2.cons.refine_2
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
this : False
⊢ 0 = j + 1

case cons.refine_2.cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ x ∈ xs

tactic: cases this
state_before: case cons.refine_2.cons.refine_2
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
this : False
⊢ 0 = j + 1

case cons.refine_2.cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ x ∈ xs
state_after: case cons.refine_2.cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ x ∈ xs

tactic: rw [mem_iff_get?]
state_before: case cons.refine_2.cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ x ∈ xs
state_after: case cons.refine_2.cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ ∃ n, xs.get? n = some x

tactic: simp only [get?_eq_getElem?]
state_before: case cons.refine_2.cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ ∃ n, xs.get? n = some x
state_after: case cons.refine_2.cons.refine_1
α✝ : Type u_1
x : α✝
xs : List α✝
ih : ∀ {i j : Nat}, i < xs.length → xs.Nodup → xs[i]? = xs[j]? → i = j
i j✝ j : Nat
h₀ : 0 < (x :: xs).length
h₂ : some x = xs[j]?
h' : Pairwise (fun x x_1 => x ≠ x_1) xs
h : ∀ (a' : α✝), a' ∈ xs → x ≠ a'
⊢ ∃ n, xs[n]? = some x