The areas / V33. Data structures and computation
Mathlib.Data.List.InsertIdx
16 declarations. Mathlib docs · Source
insertIdx
Proves various lemmas about List.insertIdx.
theorem List.sublist_insertIdx E0 #
∀ {α : Type u} (l : List α) (n : ℕ) (a : α), l.Sublist (l.insertIdx n a)
theorem List.subset_insertIdx E0 #
∀ {α : Type u} (l : List α) (n : ℕ) (a : α), l ⊆ l.insertIdx n a
theorem List.insertIdx_eraseIdx_self E0 #
∀ {α : Type u} {l : List α} {n : ℕ}, n ≠ l.length → ∀ (a : α), (l.eraseIdx n).insertIdx n a = l.set n a
Erasing nth element of a list, then inserting a at the same place
is the same as setting nth element to a.
We assume that n ≠ length l, because otherwise LHS equals l ++ [a] while RHS equals l.
theorem List.insertIdx_eraseIdx_getElem E1 #
∀ {α : Type u} {l : List α} {n : ℕ} (hn : n < l.length), (l.eraseIdx n).insertIdx n l[n] = l
theorem List.insertIdx_subset_cons E1 #
∀ {α : Type u} (n : ℕ) (a : α) (l : List α), l.insertIdx n a ⊆ a :: l
theorem List.insertIdx_pmap E1 #
∀ {α : Type u} {β : Type v} {p : α → Prop} (f : (a : α) → p a → β) {l : List α} {a : α} {n : ℕ} (hl : ∀ x ∈ l, p x)
(ha : p a), (List.pmap f l hl).insertIdx n (f a ha) = List.pmap f (l.insertIdx n a) ⋯
theorem List.map_insertIdx E0 #
∀ {α : Type u} {β : Type v} (f : α → β) (l : List α) (n : ℕ) (a : α),
List.map f (l.insertIdx n a) = (List.map f l).insertIdx n (f a)
theorem List.eraseIdx_pmap E1 #
∀ {α : Type u} {β : Type v} {p : α → Prop} (f : (a : α) → p a → β) {l : List α} (hl : ∀ a ∈ l, p a) (n : ℕ),
(List.pmap f l hl).eraseIdx n = List.pmap f (l.eraseIdx n) ⋯
theorem List.eraseIdx_map E1 #
∀ {α : Type u} {β : Type v} (f : α → β) (l : List α) (n : ℕ), (List.map f l).eraseIdx n = List.map f (l.eraseIdx n)
Erasing an index commutes with List.map.
theorem List.get_insertIdx_of_lt E1 #
∀ {α : Type u} (l : List α) (x : α) (n k : ℕ),
k < n →
∀ (hk : k < l.length) (hk' : autoParam (k < (l.insertIdx n x).length) List.get_insertIdx_of_lt._auto_1),
(l.insertIdx n x).get ⟨k, hk'⟩ = l.get ⟨k, hk⟩
theorem List.get_insertIdx_self E1 #
∀ {α : Type u} (l : List α) (x : α) (n : ℕ) (hn : n ≤ l.length) (hn' : optParam (n < (l.insertIdx n x).length) ⋯),
(l.insertIdx n x).get ⟨n, hn'⟩ = x
theorem List.getElem_insertIdx_add_succ E1 #
∀ {α : Type u} (l : List α) (x : α) (n k : ℕ) (hk' : n + k < l.length)
(hk : optParam (n + k + 1 < (l.insertIdx n x).length) ⋯), (l.insertIdx n x)[n + k + 1] = l[n + k]
theorem List.get_insertIdx_add_succ E1 #
∀ {α : Type u} (l : List α) (x : α) (n k : ℕ) (hk' : n + k < l.length)
(hk : optParam (n + k + 1 < (l.insertIdx n x).length) ⋯), (l.insertIdx n x).get ⟨n + k + 1, hk⟩ = l.get ⟨n + k, hk'⟩
theorem List.insertIdx_injective E1 #
∀ {α : Type u} (n : ℕ) (x : α), Function.Injective fun l ↦ l.insertIdx n x
theorem List.take_insertIdx_eq_take_of_le E1 #
∀ {α : Type u} (l : List α) (x : α) (i j : ℕ), i ≤ j → List.take i (l.insertIdx j x) = List.take i l
theorem List.take_eraseIdx_eq_take_of_le E1 #
∀ {α : Type u} (l : List α) (i j : ℕ), i ≤ j → List.take i (l.eraseIdx j) = List.take i l