Documentation

Init.Data.List.ToArray

Lemmas about List.toArray. #

We prefer to pull List.toArray outwards past Array operations.

theorem List.toArray_inj {α : Type u_1} {a b : List α} (h : a.toArray = b.toArray) :
a = b
@[simp]
theorem List.size_toArrayAux {α : Type u_1} {a : List α} {b : Array α} :
(a.toArrayAux b).size = b.size + a.length
theorem List.toArray_cons {α : Type u_1} (a : α) (l : List α) :
(a :: l).toArray = #[a] ++ l.toArray
@[simp]
theorem List.push_toArray {α : Type u_1} (l : List α) (a : α) :
l.toArray.push a = (l ++ [a]).toArray
@[simp]
theorem List.push_toArray_fun {α : Type u_1} (l : List α) :
l.toArray.push = fun (a : α) => (l ++ [a]).toArray

Unapplied variant of push_toArray, useful for monadic reasoning.

@[simp]
theorem List.isEmpty_toArray {α : Type u_1} (l : List α) :
l.toArray.isEmpty = l.isEmpty
@[simp]
theorem List.toArray_singleton {α : Type u_1} (a : α) :
@[simp]
theorem List.back!_toArray {α : Type u_1} [Inhabited α] (l : List α) :
l.toArray.back! = l.getLast!
@[simp]
theorem List.back?_toArray {α : Type u_1} (l : List α) :
l.toArray.back? = l.getLast?
@[simp]
theorem List.set_toArray {α : Type u_1} (l : List α) (i : Nat) (a : α) (h : i < l.length) :
l.toArray.set i a h = (l.set i a).toArray
@[simp]
theorem List.forIn'_loop_toArray {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (l : List α) (f : (a : α) → a l.toArrayβm (ForInStep β)) (i : Nat) (h : i l.length) (b : β) :
Array.forIn'.loop l.toArray f i h b = forIn' (List.drop (l.length - i) l) b fun (a : α) (m : a List.drop (l.length - i) l) (b : β) => f a b
@[simp]
theorem List.forIn'_toArray {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (l : List α) (b : β) (f : (a : α) → a l.toArrayβm (ForInStep β)) :
forIn' l.toArray b f = forIn' l b fun (a : α) (m : a l) (b : β) => f a b
@[simp]
theorem List.forIn_toArray {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (l : List α) (b : β) (f : αβm (ForInStep β)) :
forIn l.toArray b f = forIn l b f
theorem List.foldrM_toArray {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (f : αβm β) (init : β) (l : List α) :
Array.foldrM f init l.toArray = List.foldrM f init l
theorem List.foldlM_toArray {m : Type u_1 → Type u_2} {β : Type u_1} {α : Type u_3} [Monad m] (f : βαm β) (init : β) (l : List α) :
Array.foldlM f init l.toArray = List.foldlM f init l
theorem List.foldr_toArray {α : Type u_1} {β : Type u_2} (f : αββ) (init : β) (l : List α) :
Array.foldr f init l.toArray = List.foldr f init l
theorem List.foldl_toArray {β : Type u_1} {α : Type u_2} (f : βαβ) (init : β) (l : List α) :
Array.foldl f init l.toArray = List.foldl f init l
@[simp]
theorem List.foldrM_toArray' {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} {start : Nat} [Monad m] (f : αβm β) (init : β) (l : List α) (h : start = l.toArray.size) :
Array.foldrM f init l.toArray start = List.foldrM f init l

Variant of foldrM_toArray with a side condition for the start argument.

@[simp]
theorem List.foldlM_toArray' {m : Type u_1 → Type u_2} {β : Type u_1} {α : Type u_3} {stop : Nat} [Monad m] (f : βαm β) (init : β) (l : List α) (h : stop = l.toArray.size) :
Array.foldlM f init l.toArray 0 stop = List.foldlM f init l

Variant of foldlM_toArray with a side condition for the stop argument.

@[simp]
theorem List.forM_toArray' {m : Type u_1 → Type u_2} {α : Type u_3} {stop : Nat} [Monad m] (l : List α) (f : αm PUnit) (h : stop = l.toArray.size) :
Array.forM f l.toArray 0 stop = l.forM f

Variant of forM_toArray with a side condition for the stop argument.

theorem List.forM_toArray {m : Type u_1 → Type u_2} {α : Type u_3} [Monad m] (l : List α) (f : αm PUnit) :
Array.forM f l.toArray = l.forM f
@[simp]
theorem List.foldr_toArray' {α : Type u_1} {β : Type u_2} {start : Nat} (f : αββ) (init : β) (l : List α) (h : start = l.toArray.size) :
Array.foldr f init l.toArray start = List.foldr f init l

Variant of foldr_toArray with a side condition for the start argument.

@[simp]
theorem List.foldl_toArray' {β : Type u_1} {α : Type u_2} {stop : Nat} (f : βαβ) (init : β) (l : List α) (h : stop = l.toArray.size) :
Array.foldl f init l.toArray 0 stop = List.foldl f init l

Variant of foldl_toArray with a side condition for the stop argument.

@[simp]
theorem List.append_toArray {α : Type u_1} (l₁ l₂ : List α) :
l₁.toArray ++ l₂.toArray = (l₁ ++ l₂).toArray
@[simp]
theorem List.push_append_toArray {α : Type u_1} {as : Array α} {a : α} {bs : List α} :
as.push a ++ bs.toArray = as ++ (a :: bs).toArray
@[simp]
theorem List.foldl_push {α : Type u_1} {l : List α} {as : Array α} :
List.foldl Array.push as l = as ++ l.toArray
@[simp]
theorem List.foldr_push {α : Type u_1} {l : List α} {as : Array α} :
List.foldr (fun (a : α) (b : Array α) => b.push a) as l = as ++ l.reverse.toArray
@[simp]
theorem List.findSomeM?_toArray {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] [LawfulMonad m] (f : αm (Option β)) (l : List α) :
theorem List.findSomeRevM?_find_toArray {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] [LawfulMonad m] (f : αm (Option β)) (l : List α) (i : Nat) (h : i l.toArray.size) :
Array.findSomeRevM?.find f l.toArray i h = List.findSomeM? f (List.take i l).reverse
theorem List.findSomeRevM?_toArray {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] [LawfulMonad m] (f : αm (Option β)) (l : List α) :
Array.findSomeRevM? f l.toArray = List.findSomeM? f l.reverse
theorem List.findRevM?_toArray {m : TypeType u_1} {α : Type} [Monad m] [LawfulMonad m] (f : αm Bool) (l : List α) :
Array.findRevM? f l.toArray = List.findM? f l.reverse
@[simp]
theorem List.findM?_toArray {m : TypeType} {α : Type} [Monad m] [LawfulMonad m] (f : αm Bool) (l : List α) :
Array.findM? f l.toArray = List.findM? f l
@[simp]
theorem List.findSome?_toArray {α : Type u_1} {β : Type u_2} (f : αOption β) (l : List α) :
@[simp]
theorem List.find?_toArray {α : Type u_1} (f : αBool) (l : List α) :
Array.find? f l.toArray = List.find? f l
@[irreducible]
theorem List.isPrefixOfAux_toArray_succ {α : Type u_1} [BEq α] (l₁ l₂ : List α) (hle : l₁.length l₂.length) (i : Nat) :
l₁.toArray.isPrefixOfAux l₂.toArray hle (i + 1) = l₁.tail.toArray.isPrefixOfAux l₂.tail.toArray i
theorem List.isPrefixOfAux_toArray_succ' {α : Type u_1} [BEq α] (l₁ l₂ : List α) (hle : l₁.length l₂.length) (i : Nat) :
l₁.toArray.isPrefixOfAux l₂.toArray hle (i + 1) = (List.drop (i + 1) l₁).toArray.isPrefixOfAux (List.drop (i + 1) l₂).toArray 0
theorem List.isPrefixOfAux_toArray_zero {α : Type u_1} [BEq α] (l₁ l₂ : List α) (hle : l₁.length l₂.length) :
l₁.toArray.isPrefixOfAux l₂.toArray hle 0 = l₁.isPrefixOf l₂
@[simp]
theorem List.isPrefixOf_toArray {α : Type u_1} [BEq α] (l₁ l₂ : List α) :
l₁.toArray.isPrefixOf l₂.toArray = l₁.isPrefixOf l₂
@[irreducible]
theorem List.zipWithAux_toArray_succ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (as : List α) (bs : List β) (f : αβγ) (i : Nat) (cs : Array γ) :
as.toArray.zipWithAux bs.toArray f (i + 1) cs = as.tail.toArray.zipWithAux bs.tail.toArray f i cs
theorem List.zipWithAux_toArray_succ' {α : Type u_1} {β : Type u_2} {γ : Type u_3} (as : List α) (bs : List β) (f : αβγ) (i : Nat) (cs : Array γ) :
as.toArray.zipWithAux bs.toArray f (i + 1) cs = (List.drop (i + 1) as).toArray.zipWithAux (List.drop (i + 1) bs).toArray f 0 cs
theorem List.zipWithAux_toArray_zero {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : αβγ) (as : List α) (bs : List β) (cs : Array γ) :
as.toArray.zipWithAux bs.toArray f 0 cs = cs ++ (List.zipWith f as bs).toArray
@[simp]
theorem List.zipWith_toArray {α : Type u_1} {β : Type u_2} {γ : Type u_3} (as : List α) (bs : List β) (f : αβγ) :
as.toArray.zipWith bs.toArray f = (List.zipWith f as bs).toArray
@[simp]
theorem List.zip_toArray {α : Type u_1} {β : Type u_2} (as : List α) (bs : List β) :
as.toArray.zip bs.toArray = (as.zip bs).toArray
@[irreducible]
theorem List.zipWithAll_go_toArray {α : Type u_1} {β : Type u_2} {γ : Type u_3} (as : List α) (bs : List β) (f : Option αOption βγ) (i : Nat) (cs : Array γ) :
Array.zipWithAll.go f as.toArray bs.toArray i cs = cs ++ (List.zipWithAll f (List.drop i as) (List.drop i bs)).toArray
@[simp]
theorem List.zipWithAll_toArray {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : Option αOption βγ) (as : List α) (bs : List β) :
as.toArray.zipWithAll bs.toArray f = (List.zipWithAll f as bs).toArray
@[simp]
theorem List.toArray_appendList {α : Type u_1} (l₁ l₂ : List α) :
l₁.toArray ++ l₂ = (l₁ ++ l₂).toArray
@[simp]
theorem List.pop_toArray {α : Type u_1} (l : List α) :
l.toArray.pop = l.dropLast.toArray
@[irreducible]
theorem List.takeWhile_go_succ {α : Type u_1} {r : Array α} (p : αBool) (a : α) (l : List α) (i : Nat) :
Array.takeWhile.go p (a :: l).toArray (i + 1) r = Array.takeWhile.go p l.toArray i r
theorem List.takeWhile_go_toArray {α : Type u_1} {r : Array α} (p : αBool) (l : List α) (i : Nat) :
Array.takeWhile.go p l.toArray i r = r ++ (List.takeWhile p (List.drop i l)).toArray
@[simp]
theorem List.takeWhile_toArray {α : Type u_1} (p : αBool) (l : List α) :
Array.takeWhile p l.toArray = (List.takeWhile p l).toArray
@[simp]
theorem List.setIfInBounds_toArray {α : Type u_1} (l : List α) (i : Nat) (a : α) :
l.toArray.setIfInBounds i a = (l.set i a).toArray
@[simp]
theorem List.toArray_replicate {α : Type u_1} (n : Nat) (v : α) :
(List.replicate n v).toArray = mkArray n v
@[reducible, inline, deprecated List.toArray_replicate (since := "2024-12-13")]
abbrev Array.mkArray_eq_toArray_replicate {α : Type u_1} (n : Nat) (v : α) :
(List.replicate n v).toArray = mkArray n v
Equations
Instances For