The areas / V33. Data structures and computation
Mathlib.Data.Vector.Basic
111 declarations. Mathlib docs · Source
theorem List.Vector.pmap.congr_simp E1 #
∀ {α : Type u_1} {β : Type u_2} {n : ℕ} {p : α → Prop} (f f_1 : (a : α) → p a → β),
f = f_1 →
∀ (v v_1 : List.Vector α n) (e_v : v = v_1) (a : ∀ x ∈ v.toList, p x),
List.Vector.pmap f v a = List.Vector.pmap f_1 v_1 ⋯
theorem List.Vector.mOfFn.match_1.congr_eq_2 E1 #
∀ {m : Type u_3 → Type u_2} {α : Type u_3} (motive : (x : ℕ) → (Fin x → m α) → Sort u_1) (x : ℕ) (x_1 : Fin x → m α)
(h_1 : (x : Fin 0 → m α) → motive 0 x) (h_2 : (n : ℕ) → (f : Fin (n + 1) → m α) → motive n.succ f) (n : ℕ)
(f : Fin (n + 1) → m α),
x = n.succ →
x_1 ≍ f →
(match x, x_1 with
| 0, x => h_1 x
| n.succ, f => h_2 n f) ≍
h_2 n f
theorem List.Vector.mOfFn.match_1.congr_eq_1 E1 #
∀ {m : Type u_3 → Type u_2} {α : Type u_3} (motive : (x : ℕ) → (Fin x → m α) → Sort u_1) (x : ℕ) (x_1 : Fin x → m α)
(h_1 : (x : Fin 0 → m α) → motive 0 x) (h_2 : (n : ℕ) → (f : Fin (n + 1) → m α) → motive n.succ f)
(x_2 : Fin 0 → m α),
x = 0 →
x_1 ≍ x_2 →
(match x, x_1 with
| 0, x => h_1 x
| n.succ, f => h_2 n f) ≍
h_1 x_2
theorem List.Vector.elim.match_3.congr_eq_1 E1 #
∀ {α : Type u_1} {n : ℕ} (motive : List.Vector α n → Sort u_2) (x : List.Vector α n)
(h_1 : (l : List α) → (h : l.length = n) → motive ⟨l, h⟩) (l : List α) (h : l.length = n),
x = ⟨l, h⟩ →
(match x with
| ⟨l, h⟩ => h_1 l h) ≍
h_1 l h
theorem List.Vector.ofFn.match_1.congr_eq_1 E1 #
∀ {α : Type u_2} (motive : (x : ℕ) → (Fin x → α) → Sort u_1) (x : ℕ) (x_1 : Fin x → α)
(h_1 : (x : Fin 0 → α) → motive 0 x) (h_2 : (n : ℕ) → (f : Fin (n + 1) → α) → motive n.succ f) (x_2 : Fin 0 → α),
x = 0 →
x_1 ≍ x_2 →
(match x, x_1 with
| 0, x => h_1 x
| n.succ, f => h_2 n f) ≍
h_1 x_2
theorem List.Vector.ofFn.match_1.congr_eq_2 E1 #
∀ {α : Type u_2} (motive : (x : ℕ) → (Fin x → α) → Sort u_1) (x : ℕ) (x_1 : Fin x → α)
(h_1 : (x : Fin 0 → α) → motive 0 x) (h_2 : (n : ℕ) → (f : Fin (n + 1) → α) → motive n.succ f) (n : ℕ)
(f : Fin (n + 1) → α),
x = n.succ →
x_1 ≍ f →
(match x, x_1 with
| 0, x => h_1 x
| n.succ, f => h_2 n f) ≍
h_2 n f
def List.Vector.«term_::ᵥ_» E1 #
Lean.TrailingParserDescr
If a : α and l : Vector α n, then cons a l, is the vector of length n + 1
whose first element is a and with l as the rest of the list.
instance List.Vector.instInhabited E0 #
{α : Type u_1} → {n : ℕ} → [Inhabited α] → Inhabited (List.Vector α n)
theorem List.Vector.toList_injective E1 #
∀ {α : Type u_1} {n : ℕ}, Function.Injective List.Vector.toList
theorem List.Vector.ext E1 #
∀ {α : Type u_1} {n : ℕ} {v w : List.Vector α n}, (∀ (m : Fin n), v.get m = w.get m) → v = w
Two v w : Vector α n are equal iff they are equal at every single index.
theorem List.Vector.ext_iff E0 #
∀ {α : Type u_1} {n : ℕ} {v w : List.Vector α n}, v = w ↔ ∀ (m : Fin n), v.get m = w.get m
instance List.Vector.zero_subsingleton E0 #
∀ {α : Type u_1}, Subsingleton (List.Vector α 0)
The empty Vector is a Subsingleton.
theorem List.Vector.cons_val E0 #
∀ {α : Type u_1} {n : ℕ} (a : α) (v : List.Vector α n), ↑(a ::ᵥ v) = a :: ↑v
theorem List.Vector.ne_cons_iff E0 #
∀ {α : Type u_1} {n : ℕ} (a : α) (v : List.Vector α n.succ) (v' : List.Vector α n),
v ≠ a ::ᵥ v' ↔ v.head ≠ a ∨ v.tail ≠ v'
theorem List.Vector.exists_eq_cons E1 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α n.succ), ∃ a as, v = a ::ᵥ as
theorem List.Vector.toList_ofFn E0 #
∀ {α : Type u_1} {n : ℕ} (f : Fin n → α), (List.Vector.ofFn f).toList = List.ofFn f
theorem List.Vector.mk_toList E0 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α n) (h : v.toList.length = n), ⟨v.toList, h⟩ = v
theorem List.Vector.length_val E0 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α n), (↑v).length = n
theorem List.Vector.pmap_cons E0 #
∀ {α : Type u_1} {β : Type u_2} {n : ℕ} {p : α → Prop} (f : (a : α) → p a → β) (a : α) (v : List.Vector α n)
(hp : ∀ x ∈ (a ::ᵥ v).toList, p x), List.Vector.pmap f (a ::ᵥ v) hp = f a ⋯ ::ᵥ List.Vector.pmap f v ⋯
theorem List.Vector.pmap_cons' E1 #
∀ {α : Type u_1} {β : Type u_2} {n : ℕ} {p : α → Prop} (f : (a : α) → p a → β) (a : α) (v : List.Vector α n) (ha : p a)
(hp : ∀ x ∈ v.toList, p x), f a ha ::ᵥ List.Vector.pmap f v hp = List.Vector.pmap f (a ::ᵥ v) ⋯
Opposite direction of Vector.pmap_cons
theorem List.Vector.toList_map E0 #
∀ {α : Type u_1} {n : ℕ} {β : Type u_6} (v : List.Vector α n) (f : α → β),
(List.Vector.map f v).toList = List.map f v.toList
theorem List.Vector.head_map E0 #
∀ {α : Type u_1} {n : ℕ} {β : Type u_6} (v : List.Vector α (n + 1)) (f : α → β), (List.Vector.map f v).head = f v.head
theorem List.Vector.tail_map E0 #
∀ {α : Type u_1} {n : ℕ} {β : Type u_6} (v : List.Vector α (n + 1)) (f : α → β),
(List.Vector.map f v).tail = List.Vector.map f v.tail
theorem List.Vector.getElem_map E0 #
∀ {α : Type u_1} {n : ℕ} {β : Type u_6} (v : List.Vector α n) (f : α → β) {i : ℕ} (hi : i < n),
(List.Vector.map f v)[i] = f v[i]
theorem List.Vector.toList_pmap E0 #
∀ {α : Type u_1} {β : Type u_2} {n : ℕ} {p : α → Prop} (f : (a : α) → p a → β) (v : List.Vector α n)
(hp : ∀ x ∈ v.toList, p x), (List.Vector.pmap f v hp).toList = List.pmap f v.toList hp
theorem List.Vector.getElem_pmap E0 #
∀ {α : Type u_1} {β : Type u_2} {n : ℕ} {p : α → Prop} (f : (a : α) → p a → β) (v : List.Vector α n)
(hp : ∀ x ∈ v.toList, p x) {i : ℕ} (hi : i < n), (List.Vector.pmap f v hp)[i] = f v[i] ⋯
theorem List.Vector.get_eq_get_toList E1 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α n) (i : Fin n), v.get i = v.toList.get (Fin.cast ⋯ i)
theorem List.Vector.get_replicate E0 #
∀ {α : Type u_1} {n : ℕ} (a : α) (i : Fin n), (List.Vector.replicate n a).get i = a
theorem List.Vector.get_map E0 #
∀ {α : Type u_1} {n : ℕ} {β : Type u_6} (v : List.Vector α n) (f : α → β) (i : Fin n),
(List.Vector.map f v).get i = f (v.get i)
theorem List.Vector.map₂_nil E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : α → β → γ),
List.Vector.map₂ f List.Vector.nil List.Vector.nil = List.Vector.nil
theorem List.Vector.map₂_cons E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {n : ℕ} (hd₁ : α) (tl₁ : List.Vector α n) (hd₂ : β)
(tl₂ : List.Vector β n) (f : α → β → γ),
List.Vector.map₂ f (hd₁ ::ᵥ tl₁) (hd₂ ::ᵥ tl₂) = f hd₁ hd₂ ::ᵥ List.Vector.map₂ f tl₁ tl₂
theorem List.Vector.get_ofFn E0 #
∀ {α : Type u_1} {n : ℕ} (f : Fin n → α) (i : Fin n), (List.Vector.ofFn f).get i = f i
theorem List.Vector.ofFn_get E0 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α n), List.Vector.ofFn v.get = v
def Equiv.vectorEquivFin E1 #
(α : Type u_6) → (n : ℕ) → List.Vector α n ≃ (Fin n → α)
The natural equivalence between length-n vectors and functions from Fin n.
theorem List.Vector.get_tail E1 #
∀ {α : Type u_1} {n : ℕ} (x : List.Vector α n) (i : Fin (n - 1)), x.tail.get i = x.get ⟨↑i + 1, ⋯⟩
theorem List.Vector.get_tail_succ E0 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α n.succ) (i : Fin n), v.tail.get i = v.get i.succ
theorem List.Vector.tail_val E0 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α n.succ), ↑v.tail = (↑v).tail
theorem List.Vector.tail_nil E0 #
∀ {α : Type u_1}, List.Vector.nil.tail = List.Vector.nil
The tail of a nil vector is nil.
theorem List.Vector.singleton_tail E0 #
∀ {α : Type u_1} (v : List.Vector α 1), v.tail = List.Vector.nil
The tail of a vector made up of one element is nil.
theorem List.Vector.tail_ofFn E0 #
∀ {α : Type u_1} {n : ℕ} (f : Fin n.succ → α), (List.Vector.ofFn f).tail = List.Vector.ofFn fun i ↦ f i.succ
theorem List.Vector.toList_tail E1 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α n), v.tail.toList = v.toList.tail
theorem List.Vector.toList_empty E0 #
∀ {α : Type u_1} (v : List.Vector α 0), v.toList = []
theorem List.Vector.toList_singleton E0 #
∀ {α : Type u_1} (v : List.Vector α 1), v.toList = [v.head]
The list that makes up a Vector made up of a single element,
retrieved via toList, is equal to the list of that single element.
theorem List.Vector.empty_toList_eq_ff E0 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α (n + 1)), v.toList.isEmpty = false
theorem List.Vector.not_empty_toList E1 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α (n + 1)), ¬v.toList.isEmpty = true
theorem List.Vector.map_id E0 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α n), List.Vector.map id v = v
Mapping under id does not change a vector.
theorem List.Vector.nodup_iff_injective_get E1 #
∀ {α : Type u_1} {n : ℕ} {v : List.Vector α n}, v.toList.Nodup ↔ Function.Injective v.get
theorem List.Vector.head?_toList E1 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α n.succ), v.toList.head? = some v.head
def List.Vector.reverse E1 #
{α : Type u_1} → {n : ℕ} → List.Vector α n → List.Vector α n
Reverse a vector.
theorem List.Vector.toList_reverse E1 #
∀ {α : Type u_1} {n : ℕ} {v : List.Vector α n}, v.reverse.toList = v.toList.reverse
The List of a vector after a reverse, retrieved by toList is equal
to the List.reverse after retrieving a vector's toList.
theorem List.Vector.reverse_reverse E0 #
∀ {α : Type u_1} {n : ℕ} {v : List.Vector α n}, v.reverse.reverse = v
theorem List.Vector.get_zero E0 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α n.succ), v.get 0 = v.head
theorem List.Vector.head_ofFn E0 #
∀ {α : Type u_1} {n : ℕ} (f : Fin n.succ → α), (List.Vector.ofFn f).head = f 0
theorem List.Vector.get_cons_zero E1 #
∀ {α : Type u_1} {n : ℕ} (a : α) (v : List.Vector α n), (a ::ᵥ v).get 0 = a
theorem List.Vector.get_cons_nil E0 #
∀ {α : Type u_1} {ix : Fin 1} (x : α), (x ::ᵥ List.Vector.nil).get ix = x
Accessing the nth element of a vector made up
of one element x : α is x itself.
theorem List.Vector.get_cons_succ E0 #
∀ {α : Type u_1} {n : ℕ} (a : α) (v : List.Vector α n) (i : Fin n), (a ::ᵥ v).get i.succ = v.get i
def List.Vector.last E1 #
{α : Type u_1} → {n : ℕ} → List.Vector α (n + 1) → α
The last element of a Vector, given that the vector is at least one element.
theorem List.Vector.last_def E0 #
∀ {α : Type u_1} {n : ℕ} {v : List.Vector α (n + 1)}, v.last = v.get (Fin.last n)
The last element of a Vector, given that the vector is at least one element.
theorem List.Vector.reverse_get_zero E1 #
∀ {α : Type u_1} {n : ℕ} {v : List.Vector α (n + 1)}, v.reverse.head = v.last
The last element of a vector is the head of the reverse vector.
def List.Vector.scanl E1 #
{α : Type u_1} → {n : ℕ} → {β : Type u_6} → (β → α → β) → β → List.Vector α n → List.Vector β (n + 1)
Construct a Vector β (n + 1) from a Vector α n by scanning f : β → α → β
from the "left", that is, from 0 to Fin.last n, using b : β as the starting value.
theorem List.Vector.scanl_nil E0 #
∀ {α : Type u_1} {β : Type u_6} (f : β → α → β) (b : β), List.Vector.scanl f b List.Vector.nil = b ::ᵥ List.Vector.nil
Providing an empty vector to scanl gives the starting value b : β.
theorem List.Vector.scanl_cons E0 #
∀ {α : Type u_1} {n : ℕ} {β : Type u_6} (f : β → α → β) (b : β) (v : List.Vector α n) (x : α),
List.Vector.scanl f b (x ::ᵥ v) = b ::ᵥ List.Vector.scanl f (f b x) v
The recursive step of scanl splits a vector x ::ᵥ v : Vector α (n + 1)
into the provided starting value b : β and the recursed scanl
f b x : β as the starting value.
This lemma is the cons version of scanl_get.
theorem List.Vector.scanl_val E0 #
∀ {α : Type u_1} {n : ℕ} {β : Type u_6} (f : β → α → β) (b : β) {v : List.Vector α n},
↑(List.Vector.scanl f b v) = List.scanl f b ↑v
The underlying List of a Vector after a scanl is the List.scanl
of the underlying List of the original Vector.
theorem List.Vector.toList_scanl E0 #
∀ {α : Type u_1} {n : ℕ} {β : Type u_6} (f : β → α → β) (b : β) (v : List.Vector α n),
(List.Vector.scanl f b v).toList = List.scanl f b v.toList
The toList of a Vector after a scanl is the List.scanl
of the toList of the original Vector.
theorem List.Vector.scanl_singleton E0 #
∀ {α : Type u_1} {β : Type u_6} (f : β → α → β) (b : β) (v : List.Vector α 1),
List.Vector.scanl f b v = b ::ᵥ f b v.head ::ᵥ List.Vector.nil
The recursive step of scanl splits a vector made up of a single element
x ::ᵥ nil : Vector α 1 into a Vector of the provided starting value b : β
and the mapped f b x : β as the last value.
theorem List.Vector.scanl_head E0 #
∀ {α : Type u_1} {n : ℕ} {β : Type u_6} (f : β → α → β) (b : β) (v : List.Vector α n),
(List.Vector.scanl f b v).head = b
The first element of scanl of a vector v : Vector α n,
retrieved via head, is the starting value b : β.
theorem List.Vector.scanl_get E0 #
∀ {α : Type u_1} {n : ℕ} {β : Type u_6} (f : β → α → β) (b : β) (v : List.Vector α n) (i : Fin n),
(List.Vector.scanl f b v).get i.succ = f ((List.Vector.scanl f b v).get i.castSucc) (v.get i)
For an index i : Fin n, the nth element of scanl of a
vector v : Vector α n at i.succ, is equal to the application
function f : β → α → β of the castSucc i element of
scanl f b v and get v i.
This lemma is the get version of scanl_cons.
def List.Vector.mOfFn E1 #
{m : Type u → Type u_6} → [Monad m] → {α : Type u} → {n : ℕ} → (Fin n → m α) → m (List.Vector α n)
Monadic analog of Vector.ofFn.
Given a monadic function on Fin n, return a Vector α n inside the monad.
theorem List.Vector.mOfFn_pure E1 #
∀ {m : Type u_6 → Type u_7} [inst : Monad m] [LawfulMonad m] {α : Type u_6} {n : ℕ} (f : Fin n → α),
(List.Vector.mOfFn fun i ↦ pure (f i)) = pure (List.Vector.ofFn f)
def List.Vector.mmap E1 #
{m : Type u → Type u_6} →
[Monad m] → {α : Type u_7} → {β : Type u} → (α → m β) → {n : ℕ} → List.Vector α n → m (List.Vector β n)
Apply a monadic function to each component of a vector, returning a vector inside the monad.
theorem List.Vector.mmap_nil E0 #
∀ {m : Type u_6 → Type u_7} [inst : Monad m] {α : Type u_8} {β : Type u_6} (f : α → m β),
List.Vector.mmap f List.Vector.nil = pure List.Vector.nil
theorem List.Vector.mmap_cons E0 #
∀ {m : Type u_6 → Type u_7} [inst : Monad m] {α : Type u_8} {β : Type u_6} (f : α → m β) (a : α) {n : ℕ}
(v : List.Vector α n),
List.Vector.mmap f (a ::ᵥ v) = do
let h' ← f a
let t' ← List.Vector.mmap f v
pure (h' ::ᵥ t')
def List.Vector.inductionOn E1 #
{α : Type u_1} →
{C : {n : ℕ} → List.Vector α n → Sort u_6} →
{n : ℕ} →
(v : List.Vector α n) → C List.Vector.nil → ({n : ℕ} → {x : α} → {w : List.Vector α n} → C w → C (x ::ᵥ w)) → C v
Define C v by induction on v : Vector α n.
This function has two arguments: nil handles the base case on C nil,
and cons defines the inductive step using ∀ x : α, C w → C (x ::ᵥ w).
It is used as the default induction principle for the induction tactic.
theorem List.Vector.inductionOn_nil E0 #
∀ {α : Type u_1} {C : {n : ℕ} → List.Vector α n → Sort u_6} (nil : C List.Vector.nil)
(cons : {n : ℕ} → {x : α} → {w : List.Vector α n} → C w → C (x ::ᵥ w)),
(List.Vector.nil.inductionOn nil fun {n} {x} {w} ↦ cons) = nil
theorem List.Vector.inductionOn_cons E0 #
∀ {α : Type u_1} {C : {n : ℕ} → List.Vector α n → Sort u_6} {n : ℕ} (x : α) (v : List.Vector α n)
(nil : C List.Vector.nil) (cons : {n : ℕ} → {x : α} → {w : List.Vector α n} → C w → C (x ::ᵥ w)),
((x ::ᵥ v).inductionOn nil fun {n} {x} {w} ↦ cons) = cons (v.inductionOn nil fun {n} {x} {w} ↦ cons)
def List.Vector.inductionOn₂ E1 #
{α : Type u_1} →
{n : ℕ} →
{β : Type u_6} →
{C : {n : ℕ} → List.Vector α n → List.Vector β n → Sort u_8} →
(v : List.Vector α n) →
(w : List.Vector β n) →
C List.Vector.nil List.Vector.nil →
({n : ℕ} →
{a : α} → {b : β} → {x : List.Vector α n} → {y : List.Vector β n} → C x y → C (a ::ᵥ x) (b ::ᵥ y)) →
C v w
Define C v w by induction on a pair of vectors v : Vector α n and w : Vector β n.
def List.Vector.inductionOn₃ E1 #
{α : Type u_1} →
{n : ℕ} →
{β : Type u_6} →
{γ : Type u_7} →
{C : {n : ℕ} → List.Vector α n → List.Vector β n → List.Vector γ n → Sort u_8} →
(u : List.Vector α n) →
(v : List.Vector β n) →
(w : List.Vector γ n) →
C List.Vector.nil List.Vector.nil List.Vector.nil →
({n : ℕ} →
{a : α} →
{b : β} →
{c : γ} →
{x : List.Vector α n} →
{y : List.Vector β n} →
{z : List.Vector γ n} → C x y z → C (a ::ᵥ x) (b ::ᵥ y) (c ::ᵥ z)) →
C u v w
Define C u v w by induction on a triplet of vectors
u : Vector α n, v : Vector β n, and w : Vector γ b.
def List.Vector.casesOn E1 #
{α : Type u_1} →
{m : ℕ} →
{motive : {n : ℕ} → List.Vector α n → Sort u_8} →
(v : List.Vector α m) →
motive List.Vector.nil → ({n : ℕ} → (hd : α) → (tl : List.Vector α n) → motive (hd ::ᵥ tl)) → motive v
Define motive v by case-analysis on v : Vector α n.
def List.Vector.casesOn₂ E1 #
{α : Type u_1} →
{m : ℕ} →
{β : Type u_6} →
{motive : {n : ℕ} → List.Vector α n → List.Vector β n → Sort u_8} →
(v₁ : List.Vector α m) →
(v₂ : List.Vector β m) →
motive List.Vector.nil List.Vector.nil →
({n : ℕ} →
(x : α) → (y : β) → (xs : List.Vector α n) → (ys : List.Vector β n) → motive (x ::ᵥ xs) (y ::ᵥ ys)) →
motive v₁ v₂
Define motive v₁ v₂ by case-analysis on v₁ : Vector α n and v₂ : Vector β n.
def List.Vector.casesOn₃ E1 #
{α : Type u_1} →
{m : ℕ} →
{β : Type u_6} →
{γ : Type u_7} →
{motive : {n : ℕ} → List.Vector α n → List.Vector β n → List.Vector γ n → Sort u_8} →
(v₁ : List.Vector α m) →
(v₂ : List.Vector β m) →
(v₃ : List.Vector γ m) →
motive List.Vector.nil List.Vector.nil List.Vector.nil →
({n : ℕ} →
(x : α) →
(y : β) →
(z : γ) →
(xs : List.Vector α n) →
(ys : List.Vector β n) →
(zs : List.Vector γ n) → motive (x ::ᵥ xs) (y ::ᵥ ys) (z ::ᵥ zs)) →
motive v₁ v₂ v₃
Define motive v₁ v₂ v₃ by case-analysis on v₁ : Vector α n, v₂ : Vector β n, and
v₃ : Vector γ n.
def List.Vector.toArray E1 #
{α : Type u_1} → {n : ℕ} → List.Vector α n → Array α
Cast a vector to an array.
def List.Vector.insertIdx E1 #
{α : Type u_1} → {n : ℕ} → α → Fin (n + 1) → List.Vector α n → List.Vector α (n + 1)
v.insertIdx a i inserts a into the vector v at position i
(and shifting later components to the right).
theorem List.Vector.insertIdx_val E0 #
∀ {α : Type u_1} {n : ℕ} {a : α} {i : Fin (n + 1)} {v : List.Vector α n},
↑(List.Vector.insertIdx a i v) = (↑v).insertIdx (↑i) a
theorem List.Vector.eraseIdx_val E0 #
∀ {α : Type u_1} {n : ℕ} {i : Fin n} {v : List.Vector α n}, ↑(List.Vector.eraseIdx i v) = (↑v).eraseIdx ↑i
theorem List.Vector.eraseIdx_insertIdx_self E1 #
∀ {α : Type u_1} {n : ℕ} {a : α} {v : List.Vector α n} {i : Fin (n + 1)},
List.Vector.eraseIdx i (List.Vector.insertIdx a i v) = v
theorem List.Vector.eraseIdx_insertIdx' E1 #
∀ {α : Type u_1} {n : ℕ} {a : α} {v : List.Vector α (n + 1)} {i : Fin (n + 1)} {j : Fin (n + 2)},
List.Vector.eraseIdx (j.succAbove i) (List.Vector.insertIdx a j v) =
List.Vector.insertIdx a (i.predAbove j) (List.Vector.eraseIdx i v)
Erasing an element after inserting an element, at different indices.
theorem List.Vector.insertIdx_comm E1 #
∀ {α : Type u_1} {n : ℕ} (a b : α) (i j : Fin (n + 1)),
i ≤ j →
∀ (v : List.Vector α n),
List.Vector.insertIdx b j.succ (List.Vector.insertIdx a i v) =
List.Vector.insertIdx a i.castSucc (List.Vector.insertIdx b j v)
def List.Vector.set E1 #
{α : Type u_1} → {n : ℕ} → List.Vector α n → Fin n → α → List.Vector α n
set v n a replaces the nth element of v with a.
theorem List.Vector.toList_set E0 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α n) (i : Fin n) (a : α), (v.set i a).toList = v.toList.set (↑i) a
theorem List.Vector.get_set_same E0 #
∀ {α : Type u_1} {n : ℕ} (v : List.Vector α n) (i : Fin n) (a : α), (v.set i a).get i = a
theorem List.Vector.get_set_of_ne E1 #
∀ {α : Type u_1} {n : ℕ} {v : List.Vector α n} {i j : Fin n}, i ≠ j → ∀ (a : α), (v.set i a).get j = v.get j
theorem List.Vector.get_set_eq_if E1 #
∀ {α : Type u_1} {n : ℕ} {v : List.Vector α n} {i j : Fin n} (a : α), (v.set i a).get j = if i = j then a else v.get j
theorem List.Vector.sum_set E1 #
∀ {α : Type u_1} {n : ℕ} [inst : AddMonoid α] (v : List.Vector α n) (i : Fin n) (a : α),
(v.set i a).toList.sum = (List.Vector.take (↑i) v).toList.sum + a + (List.Vector.drop (↑i + 1) v).toList.sum
theorem List.Vector.prod_set E1 #
∀ {α : Type u_1} {n : ℕ} [inst : Monoid α] (v : List.Vector α n) (i : Fin n) (a : α),
(v.set i a).toList.prod = (List.Vector.take (↑i) v).toList.prod * a * (List.Vector.drop (↑i + 1) v).toList.prod
theorem List.Vector.prod_set' E1 #
∀ {α : Type u_1} {n : ℕ} [inst : CommGroup α] (v : List.Vector α n) (i : Fin n) (a : α),
(v.set i a).toList.prod = v.toList.prod * (v.get i)⁻¹ * a
Variant of List.Vector.prod_set that multiplies by the inverse of the replaced element
theorem List.Vector.sum_set' E1 #
∀ {α : Type u_1} {n : ℕ} [inst : AddCommGroup α] (v : List.Vector α n) (i : Fin n) (a : α),
(v.set i a).toList.sum = v.toList.sum + -v.get i + a
Variant of List.Vector.sum_set that subtracts the inverse of the replaced element
def List.Vector.traverse E1 #
{n : ℕ} → {F : Type u → Type u} → [Applicative F] → {α β : Type u} → (α → F β) → List.Vector α n → F (List.Vector β n)
Apply an applicative function to each component of a vector.
theorem List.Vector.traverse_def E0 #
∀ {n : ℕ} {F : Type u → Type u} [inst : Applicative F] {α β : Type u} (f : α → F β) (x : α) (xs : List.Vector α n),
List.Vector.traverse f (x ::ᵥ xs) = List.Vector.cons <$> f x <*> List.Vector.traverse f xs
theorem List.Vector.id_traverse E1 #
∀ {n : ℕ} {α : Type u} (x : List.Vector α n), List.Vector.traverse pure x = pure x
theorem List.Vector.comp_traverse E1 #
∀ {n : ℕ} {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [LawfulApplicative G] {α β γ : Type u}
(f : β → F γ) (g : α → G β) (x : List.Vector α n),
List.Vector.traverse (Functor.Comp.mk ∘ Functor.map f ∘ g) x =
Functor.Comp.mk (List.Vector.traverse f <$> List.Vector.traverse g x)
theorem List.Vector.traverse_eq_map_id E1 #
∀ {n : ℕ} {α β : Type u_6} (f : α → β) (x : List.Vector α n),
List.Vector.traverse (pure ∘ f) x = pure (List.Vector.map f x)
theorem List.Vector.naturality E1 #
∀ {n : ℕ} {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [LawfulApplicative G]
[LawfulApplicative F] (η : ApplicativeTransformation F G) {α β : Type u} (f : α → F β) (x : List.Vector α n),
(fun {α} ↦ η.app α) (List.Vector.traverse f x) = List.Vector.traverse ((fun {α} ↦ η.app α) ∘ f) x
instance List.Vector.instTraversableFlipNat E0 #
{n : ℕ} → Traversable (flip List.Vector n)
instance List.Vector.instLawfulTraversableFlipNat E0 #
∀ {n : ℕ}, LawfulTraversable (flip List.Vector n)
theorem List.Vector.replicate_succ E0 #
∀ {α : Type u_1} {n : ℕ} (val : α), List.Vector.replicate (n + 1) val = val ::ᵥ List.Vector.replicate n val
theorem List.Vector.get_append_cons_zero E0 #
∀ {α : Type u_1} {m n : ℕ} {x : α} (xs : List.Vector α n) (ys : List.Vector α m), (x ::ᵥ xs ++ ys).get 0 = x
theorem List.Vector.get_append_cons_succ E0 #
∀ {α : Type u_1} {m n : ℕ} {x : α} (xs : List.Vector α n) (ys : List.Vector α m) {i : Fin (n + m)}
{h : ↑i + 1 < n.succ + m}, (x ::ᵥ xs ++ ys).get ⟨↑i + 1, h⟩ = (xs ++ ys).get i
theorem List.Vector.append_nil E0 #
∀ {α : Type u_1} {n : ℕ} (xs : List.Vector α n), xs ++ List.Vector.nil = xs
theorem List.Vector.get_map₂ E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {n : ℕ} (v₁ : List.Vector α n) (v₂ : List.Vector β n) (f : α → β → γ)
(i : Fin n), (List.Vector.map₂ f v₁ v₂).get i = f (v₁.get i) (v₂.get i)
theorem List.Vector.mapAccumr_cons E0 #
∀ {α : Type u_1} {β : Type u_2} {σ : Type u_4} {n : ℕ} {x : α} {s : σ} (xs : List.Vector α n) {f : α → σ → σ × β},
List.Vector.mapAccumr f (x ::ᵥ xs) s =
have r := List.Vector.mapAccumr f xs s;
have q := f x r.1;
(q.1, q.2 ::ᵥ r.2)
theorem List.Vector.mapAccumr₂_cons E0 #
∀ {α : Type u_1} {β : Type u_2} {σ : Type u_4} {φ : Type u_5} {n : ℕ} {x : α} {y : β} {s : σ} (xs : List.Vector α n)
(ys : List.Vector β n) {f : α → β → σ → σ × φ},
List.Vector.mapAccumr₂ f (x ::ᵥ xs) (y ::ᵥ ys) s =
have r := List.Vector.mapAccumr₂ f xs ys s;
have q := f x y r.1;
(q.1, q.2 ::ᵥ r.2)