Theorem: Vector.removeNth_insertNth'
File: Mathlib/Data/Vector/Basic.lean

tactic: dsimp [insertNth, removeNth, Fin.succAbove, Fin.predAbove]
state_before: n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
⊢ removeNth (↑(Fin.succAbove { val := j, isLt := hj }) { val := i, isLt := hi })
      (insertNth a { val := j, isLt := hj } v) =
    insertNth a (Fin.predAbove { val := i, isLt := hi } { val := j, isLt := hj }) (removeNth { val := i, isLt := hi } v)

tactic: rw [Subtype.mk_eq_mk]
state_before: n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
⊢ {
      val :=
        List.removeNth (List.insertNth j a ↑v)
          ↑(if { val := i, isLt := (_ : i < Nat.succ (n + 1)) } < { val := j, isLt := hj } then
              { val := i, isLt := (_ : i < Nat.succ (n + 1)) }
            else { val := i + 1, isLt := (_ : Nat.succ i < Nat.succ (n + 1)) }),
      property :=
        (_ :
          List.length
              (List.removeNth (List.insertNth j a ↑v)
                ↑(if { val := i, isLt := (_ : i < Nat.succ (n + 1)) } < { val := j, isLt := hj } then
                    { val := i, isLt := (_ : i < Nat.succ (n + 1)) }
                  else { val := i + 1, isLt := (_ : Nat.succ i < Nat.succ (n + 1)) })) =
            n + 1 + 1 - 1) } =
    {
      val :=
        List.insertNth
          (↑(if h : { val := i, isLt := (_ : i < Nat.succ (n + 1)) } < { val := j, isLt := hj } then
              Fin.pred { val := j, isLt := hj } (_ : { val := j, isLt := hj } ≠ 0)
            else { val := j, isLt := (_ : ↑{ val := j, isLt := hj } < n + 1) }))
          a
          ↑(match v with
            | { val := l, property := p } =>
              { val := List.removeNth l i,
                property := (_ : List.length (List.removeNth l ↑{ val := i, isLt := hi }) = n + 1 - 1) }),
      property :=
        (_ :
          List.length
              (List.insertNth
                (↑(if h : { val := i, isLt := (_ : i < Nat.succ (n + 1)) } < { val := j, isLt := hj } then
                    Fin.pred { val := j, isLt := hj } (_ : { val := j, isLt := hj } ≠ 0)
                  else { val := j, isLt := (_ : ↑{ val := j, isLt := hj } < n + 1) }))
                a
                ↑(match v with
                  | { val := l, property := p } =>
                    { val := List.removeNth l i,
                      property := (_ : List.length (List.removeNth l ↑{ val := i, isLt := hi }) = n + 1 - 1) })) =
            n + 1) }

tactic: simp only [Fin.lt_iff_val_lt_val]
state_before: n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
⊢ List.removeNth (List.insertNth j a ↑v)
      ↑(if { val := i, isLt := (_ : i < Nat.succ (n + 1)) } < { val := j, isLt := hj } then
          { val := i, isLt := (_ : i < Nat.succ (n + 1)) }
        else { val := i + 1, isLt := (_ : Nat.succ i < Nat.succ (n + 1)) }) =
    List.insertNth
      (↑(if h : { val := i, isLt := (_ : i < Nat.succ (n + 1)) } < { val := j, isLt := hj } then
          Fin.pred { val := j, isLt := hj } (_ : { val := j, isLt := hj } ≠ 0)
        else { val := j, isLt := (_ : ↑{ val := j, isLt := hj } < n + 1) }))
      a
      ↑(match v with
        | { val := l, property := p } =>
          { val := List.removeNth l i,
            property := (_ : List.length (List.removeNth l ↑{ val := i, isLt := hi }) = n + 1 - 1) })

tactic: split_ifs with hij
state_before: n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
⊢ List.removeNth (List.insertNth j a ↑v)
      ↑(if i < j then { val := i, isLt := (_ : i < Nat.succ (n + 1)) }
        else { val := i + 1, isLt := (_ : Nat.succ i < Nat.succ (n + 1)) }) =
    List.insertNth
      (↑(if h : i < j then Fin.pred { val := j, isLt := hj } (_ : { val := j, isLt := hj } ≠ 0)
        else { val := j, isLt := (_ : ↑{ val := j, isLt := hj } < n + 1) }))
      a
      ↑(match v with
        | { val := l, property := p } =>
          { val := List.removeNth l i,
            property := (_ : List.length (List.removeNth l ↑{ val := i, isLt := hi }) = n + 1 - 1) })

tactic: rcases Nat.exists_eq_succ_of_ne_zero
  (Nat.pos_iff_ne_zero.1 (lt_of_le_of_lt (Nat.zero_le _) hij)) with ⟨j, rfl⟩
state_before: case inl
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
hij : i < j
⊢ List.removeNth (List.insertNth j a ↑v) ↑{ val := i, isLt := (_ : i < Nat.succ (n + 1)) } =
    List.insertNth (↑(Fin.pred { val := j, isLt := hj } (_ : { val := j, isLt := hj } ≠ 0))) a
      ↑(match v with
        | { val := l, property := p } =>
          { val := List.removeNth l i,
            property := (_ : List.length (List.removeNth l ↑{ val := i, isLt := hi }) = n + 1 - 1) })

tactic: rw [← List.insertNth_removeNth_of_ge]
state_before: case inl.intro
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : Nat.succ j < n + 2
hij : i < Nat.succ j
⊢ List.removeNth (List.insertNth (Nat.succ j) a ↑v) ↑{ val := i, isLt := (_ : i < Nat.succ (n + 1)) } =
    List.insertNth (↑(Fin.pred { val := Nat.succ j, isLt := hj } (_ : { val := Nat.succ j, isLt := hj } ≠ 0))) a
      ↑(match v with
        | { val := l, property := p } =>
          { val := List.removeNth l i,
            property := (_ : List.length (List.removeNth l ↑{ val := i, isLt := hi }) = n + 1 - 1) })

tactic: . simp; rfl
state_before: case inl.intro
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : Nat.succ j < n + 2
hij : i < Nat.succ j
⊢ List.insertNth j a (List.removeNth ↑v ↑{ val := i, isLt := (_ : i < Nat.succ (n + 1)) }) =
    List.insertNth (↑(Fin.pred { val := Nat.succ j, isLt := hj } (_ : { val := Nat.succ j, isLt := hj } ≠ 0))) a
      ↑(match v with
        | { val := l, property := p } =>
          { val := List.removeNth l i,
            property := (_ : List.length (List.removeNth l ↑{ val := i, isLt := hi }) = n + 1 - 1) })

case inl.intro.a
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : Nat.succ j < n + 2
hij : i < Nat.succ j
⊢ ↑{ val := i, isLt := (_ : i < Nat.succ (n + 1)) } < List.length ↑v

case inl.intro.a
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : Nat.succ j < n + 2
hij : i < Nat.succ j
⊢ ↑{ val := i, isLt := (_ : i < Nat.succ (n + 1)) } ≤ j

tactic: . simpa
state_before: case inl.intro.a
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : Nat.succ j < n + 2
hij : i < Nat.succ j
⊢ ↑{ val := i, isLt := (_ : i < Nat.succ (n + 1)) } < List.length ↑v

case inl.intro.a
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : Nat.succ j < n + 2
hij : i < Nat.succ j
⊢ ↑{ val := i, isLt := (_ : i < Nat.succ (n + 1)) } ≤ j

tactic: . simpa [Nat.lt_succ_iff] using hij
state_before: case inl.intro.a
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : Nat.succ j < n + 2
hij : i < Nat.succ j
⊢ ↑{ val := i, isLt := (_ : i < Nat.succ (n + 1)) } ≤ j

tactic: simp
state_before: case inl.intro
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : Nat.succ j < n + 2
hij : i < Nat.succ j
⊢ List.insertNth j a (List.removeNth ↑v ↑{ val := i, isLt := (_ : i < Nat.succ (n + 1)) }) =
    List.insertNth (↑(Fin.pred { val := Nat.succ j, isLt := hj } (_ : { val := Nat.succ j, isLt := hj } ≠ 0))) a
      ↑(match v with
        | { val := l, property := p } =>
          { val := List.removeNth l i,
            property := (_ : List.length (List.removeNth l ↑{ val := i, isLt := hi }) = n + 1 - 1) })

tactic: rfl
state_before: case inl.intro
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : Nat.succ j < n + 2
hij : i < Nat.succ j
⊢ List.insertNth j a (List.removeNth (↑v) i) =
    List.insertNth j a
      ↑(match v with
        | { val := l, property := p } =>
          { val := List.removeNth l i,
            property := (_ : List.length (List.removeNth l ↑{ val := i, isLt := hi }) = n + 1 - 1) })

tactic: simpa
state_before: case inl.intro.a
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : Nat.succ j < n + 2
hij : i < Nat.succ j
⊢ ↑{ val := i, isLt := (_ : i < Nat.succ (n + 1)) } < List.length ↑v

tactic: simpa [Nat.lt_succ_iff] using hij
state_before: case inl.intro.a
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : Nat.succ j < n + 2
hij : i < Nat.succ j
⊢ ↑{ val := i, isLt := (_ : i < Nat.succ (n + 1)) } ≤ j

tactic: dsimp
state_before: case inr
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
hij : ¬i < j
⊢ List.removeNth (List.insertNth j a ↑v) ↑{ val := i + 1, isLt := (_ : Nat.succ i < Nat.succ (n + 1)) } =
    List.insertNth (↑{ val := j, isLt := (_ : ↑{ val := j, isLt := hj } < n + 1) }) a
      ↑(match v with
        | { val := l, property := p } =>
          { val := List.removeNth l i,
            property := (_ : List.length (List.removeNth l ↑{ val := i, isLt := hi }) = n + 1 - 1) })

tactic: rw [← List.insertNth_removeNth_of_le i j _ _ _]
state_before: case inr
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
hij : ¬i < j
⊢ List.removeNth (List.insertNth j a ↑v) (i + 1) =
    List.insertNth j a
      ↑(match v with
        | { val := l, property := p } =>
          { val := List.removeNth l i,
            property := (_ : List.length (List.removeNth l ↑{ val := i, isLt := hi }) = n + 1 - 1) })

tactic: . rfl
state_before: case inr
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
hij : ¬i < j
⊢ List.insertNth j a (List.removeNth (↑v) i) =
    List.insertNth j a
      ↑(match v with
        | { val := l, property := p } =>
          { val := List.removeNth l i,
            property := (_ : List.length (List.removeNth l ↑{ val := i, isLt := hi }) = n + 1 - 1) })

n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
hij : ¬i < j
⊢ i < List.length ↑v

n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
hij : ¬i < j
⊢ j ≤ i

tactic: . simpa
state_before: n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
hij : ¬i < j
⊢ i < List.length ↑v

n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
hij : ¬i < j
⊢ j ≤ i

tactic: . simpa [not_lt] using hij
state_before: n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
hij : ¬i < j
⊢ j ≤ i

tactic: rfl
state_before: case inr
n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
hij : ¬i < j
⊢ List.insertNth j a (List.removeNth (↑v) i) =
    List.insertNth j a
      ↑(match v with
        | { val := l, property := p } =>
          { val := List.removeNth l i,
            property := (_ : List.length (List.removeNth l ↑{ val := i, isLt := hi }) = n + 1 - 1) })

tactic: simpa
state_before: n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
hij : ¬i < j
⊢ i < List.length ↑v

tactic: simpa [not_lt] using hij
state_before: n : ℕ
α : Type u_1
β : Type ?u.51726
γ : Type ?u.51729
a : α
v : Vector α (n + 1)
i : ℕ
hi : i < n + 1
j : ℕ
hj : j < n + 2
hij : ¬i < j
⊢ j ≤ i