Documentation

Batteries.Data.Array.Lemmas

theorem Array.forIn_eq_forIn_toList {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (as : Array α) (b : β) (f : αβm (ForInStep β)) :
forIn as b f = forIn as.toList b f
theorem Array.forIn_eq_forIn_toList.loop {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (as : Array α) (f : αβm (ForInStep β)) {i : Nat} {h : i as.size} {b : β} {j : Nat} :
j + i = as.sizeArray.forIn.loop as f i h b = forIn (List.drop j as.toList) b f
@[deprecated Array.forIn_eq_forIn_toList]
theorem Array.forIn_eq_forIn_data {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (as : Array α) (b : β) (f : αβm (ForInStep β)) :
forIn as b f = forIn as.toList b f

Alias of Array.forIn_eq_forIn_toList.

@[deprecated Array.forIn_eq_forIn_data]
theorem Array.forIn_eq_data_forIn {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (as : Array α) (b : β) (f : αβm (ForInStep β)) :
forIn as b f = forIn as.toList b f

Alias of Array.forIn_eq_forIn_toList.


Alias of Array.forIn_eq_forIn_toList.

zipWith / zip #

theorem Array.toList_zipWith {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : αβγ) (as : Array α) (bs : Array β) :
(as.zipWith bs f).toList = List.zipWith f as.toList bs.toList
@[irreducible]
theorem Array.toList_zipWith.loop {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : αβγ) (as : Array α) (bs : Array β) (i : Nat) (cs : Array γ) :
i as.sizei bs.size(Array.zipWithAux f as bs i cs).toList = cs.toList ++ List.zipWith f (List.drop i as.toList) (List.drop i bs.toList)
@[deprecated Array.toList_zipWith]
theorem Array.data_zipWith {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : αβγ) (as : Array α) (bs : Array β) :
(as.zipWith bs f).toList = List.zipWith f as.toList bs.toList

Alias of Array.toList_zipWith.

@[deprecated Array.data_zipWith]
theorem Array.zipWith_eq_zipWith_data {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : αβγ) (as : Array α) (bs : Array β) :
(as.zipWith bs f).toList = List.zipWith f as.toList bs.toList

Alias of Array.toList_zipWith.


Alias of Array.toList_zipWith.

@[simp]
theorem Array.size_zipWith {α : Type u_1} {β : Type u_2} {γ : Type u_3} (as : Array α) (bs : Array β) (f : αβγ) :
(as.zipWith bs f).size = min as.size bs.size
theorem Array.toList_zip {α : Type u_1} {β : Type u_2} (as : Array α) (bs : Array β) :
(as.zip bs).toList = as.toList.zip bs.toList
@[deprecated Array.toList_zip]
theorem Array.data_zip {α : Type u_1} {β : Type u_2} (as : Array α) (bs : Array β) :
(as.zip bs).toList = as.toList.zip bs.toList

Alias of Array.toList_zip.

@[deprecated Array.data_zip]
theorem Array.zip_eq_zip_data {α : Type u_1} {β : Type u_2} (as : Array α) (bs : Array β) :
(as.zip bs).toList = as.toList.zip bs.toList

Alias of Array.toList_zip.


Alias of Array.toList_zip.

@[simp]
theorem Array.size_zip {α : Type u_1} {β : Type u_2} (as : Array α) (bs : Array β) :
(as.zip bs).size = min as.size bs.size

filter #

theorem Array.size_filter_le {α : Type u_1} (p : αBool) (l : Array α) :
(Array.filter p l).size l.size

flatten #

@[deprecated Array.toList_flatten]
theorem Array.data_join {α : Type u_1} {l : Array (Array α)} :
l.flatten.toList = (List.map Array.toList l.toList).flatten

Alias of Array.toList_flatten.

@[deprecated Array.toList_flatten]
theorem Array.join_data {α : Type u_1} {l : Array (Array α)} :
l.flatten.toList = (List.map Array.toList l.toList).flatten

Alias of Array.toList_flatten.

@[deprecated Array.mem_flatten]
theorem Array.mem_join {α : Type u_1} {a : α} {L : Array (Array α)} :
a L.flatten ∃ (l : Array α), l L a l

Alias of Array.mem_flatten.

indexOf? #

theorem Array.indexOf?_toList {α : Type u_1} [BEq α] {a : α} {l : Array α} :
List.indexOf? a l.toList = Option.map Fin.val (l.indexOf? a)
@[irreducible]
theorem Array.indexOf?_toList.aux {α : Type u_1} [BEq α] {a : α} (l : Array α) (i : Nat) :
Option.map (fun (x : Nat) => x + i) (List.indexOf? a (List.drop i l.toList)) = Option.map Fin.val (l.indexOfAux a i)

erase #

@[simp]
theorem Array.eraseIdx!_eq_eraseIdx {α : Type u_1} (a : Array α) (i : Nat) :
a.eraseIdx! i = a.eraseIdx i
@[simp]
theorem Array.size_eraseIdx {α : Type u_1} (a : Array α) (i : Nat) :
(a.eraseIdx i).size = if i < a.size then a.size - 1 else a.size

shrink #

theorem Array.size_shrink_loop {α : Type u_1} (a : Array α) (n : Nat) :
(Array.shrink.loop n a).size = a.size - n
@[simp]
theorem Array.size_shrink {α : Type u_1} (a : Array α) (n : Nat) :
(a.shrink n).size = min a.size n

set #

theorem Array.size_set! {α : Type u_1} (a : Array α) (i : Nat) (v : α) :
(a.set! i v).size = a.size

swapAt #

theorem Array.size_swapAt {α : Type u_1} (a : Array α) (x : α) (i : Fin a.size) :
(a.swapAt i x).snd.size = a.size

map #

theorem Array.mapM_empty {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (f : αm β) :
Array.mapM f #[] = pure #[]
theorem Array.map_empty {α : Type u_1} {β : Type u_2} (f : αβ) :
Array.map f #[] = #[]

mem #

theorem Array.mem_singleton :
∀ {α : Type u_1} {b a : α}, a #[b] a = b

append #

theorem Array.append_empty {α : Type u_1} (as : Array α) :
as ++ #[] = as

Alias of Array.append_nil.

theorem Array.empty_append {α : Type u_1} (as : Array α) :
#[] ++ as = as

Alias of Array.nil_append.

insertAt #

@[simp]
theorem Array.size_insertAt {α : Type u_1} (as : Array α) (i : Fin (as.size + 1)) (v : α) :
(as.insertAt i v).size = as.size + 1
theorem Array.getElem_insertAt_lt {α : Type u_1} (as : Array α) (i : Fin (as.size + 1)) (v : α) (k : Nat) (hlt : k < i) {hk : k < (as.insertAt i v).size} {hk' : k < as.size} :
(as.insertAt i v)[k] = as[k]
theorem Array.getElem_insertAt_gt {α : Type u_1} (as : Array α) (i : Fin (as.size + 1)) (v : α) (k : Nat) (hgt : k > i) {hk : k < (as.insertAt i v).size} {hk' : k - 1 < as.size} :
(as.insertAt i v)[k] = as[k - 1]
theorem Array.getElem_insertAt_eq {α : Type u_1} (as : Array α) (i : Fin (as.size + 1)) (v : α) (k : Nat) (heq : i = k) {hk : k < (as.insertAt i v).size} :
(as.insertAt i v)[k] = v