Documentation

Mathlib.Data.List.Lemmas

Some lemmas about lists involving sets #

Split out from Data.List.Basic to reduce its dependencies.

@[deprecated List.getElem_reverse]
theorem List.getElem_reverse' {α : Type u_1} {l : List α} {i : } (h : i < l.reverse.length) :
l.reverse[i] = l[l.length - 1 - i]

Alias of List.getElem_reverse.

theorem List.tail_reverse_eq_reverse_dropLast {α : Type u_1} (l : List α) :
l.reverse.tail = l.dropLast.reverse
theorem List.getLast_tail {α : Type u_1} (l : List α) (hl : l.tail []) :
l.tail.getLast hl = l.getLast
@[deprecated List.getElem_tail]
theorem List.nthLe_tail {α : Type u_1} {n : } (l : List α) (h : n < l.tail.length) :
l.tail[n] = l[n + 1]

Alias of List.getElem_tail.

theorem List.injOn_insertNth_index_of_not_mem {α : Type u_1} (l : List α) (x : α) (hx : xl) :
Set.InjOn (fun (k : ) => List.insertNth k x l) {n : | n l.length}
theorem List.foldr_range_subset_of_range_subset {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : βαα} {g : γαα} (hfg : Set.range f Set.range g) (a : α) :
theorem List.foldl_range_subset_of_range_subset {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : αβα} {g : αγα} (hfg : (Set.range fun (a : β) (c : α) => f c a) Set.range fun (b : γ) (c : α) => g c b) (a : α) :
theorem List.foldr_range_eq_of_range_eq {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : βαα} {g : γαα} (hfg : Set.range f = Set.range g) (a : α) :
theorem List.foldl_range_eq_of_range_eq {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : αβα} {g : αγα} (hfg : (Set.range fun (a : β) (c : α) => f c a) = Set.range fun (b : γ) (c : α) => g c b) (a : α) :

MapAccumr and Foldr #

Some lemmas relation mapAccumr and foldr

theorem List.mapAccumr_eq_foldr {α : Type u_1} {β : Type u_2} {σ : Type u_4} (f : ασσ × β) (as : List α) (s : σ) :
List.mapAccumr f as s = List.foldr (fun (a : α) (s : σ × List β) => let r := f a s.1; (r.1, r.2 :: s.2)) (s, []) as
theorem List.mapAccumr₂_eq_foldr {α : Type u_1} {β : Type u_2} {σ : Type u_4} {φ : Type u_5} (f : αβσσ × φ) (as : List α) (bs : List β) (s : σ) :
List.mapAccumr₂ f as bs s = List.foldr (fun (ab : α × β) (s : σ × List φ) => let r := f ab.1 ab.2 s.1; (r.1, r.2 :: s.2)) (s, []) (as.zip bs)