Documentation

Init.Data.Vector.OfFn

Theorems about Vector.ofFn #

@[simp]
theorem Vector.getElem_ofFn {i : Nat} {α : Type u_1} {n : Nat} {f : Fin nα} (h : i < n) :
(ofFn f)[i] = f i, h
theorem Vector.getElem?_ofFn {i : Nat} {α : Type u_1} {n : Nat} {f : Fin nα} :
(ofFn f)[i]? = if h : i < n then some (f i, h) else none
@[simp]
theorem Vector.mem_ofFn {α : Type u_1} {n : Nat} {f : Fin nα} {a : α} :
a ofFn f (i : Fin n), f i = a
theorem Vector.back_ofFn {α : Type u_1} {n : Nat} [NeZero n] {f : Fin nα} :
(ofFn f).back = f n - 1,
theorem Vector.ofFn_succ {n : Nat} {α : Type u_1} {f : Fin (n + 1)α} :
ofFn f = (ofFn fun (i : Fin n) => f i.castSucc).push (f n, )
theorem Vector.ofFn_add {α : Type u_1} {n m : Nat} {f : Fin (n + m)α} :
ofFn f = (ofFn fun (i : Fin n) => f (Fin.castLE i)) ++ ofFn fun (i : Fin m) => f (Fin.natAdd n i)
theorem Vector.ofFn_succ' {n : Nat} {α : Type u_1} {f : Fin (n + 1)α} :
ofFn f = Vector.cast ({ toArray := #[f 0], size_toArray := } ++ ofFn fun (i : Fin n) => f i.succ)

ofFnM #

def Vector.ofFnM {m : Type u_1 → Type u_2} {α : Type u_1} {n : Nat} [Monad m] (f : Fin nm α) :
m (Vector α n)

Construct (in a monadic context) a vector by applying a monadic function to each index.

Equations
Instances For
    @[irreducible]
    def Vector.ofFnM.go {m : Type u_1 → Type u_2} {α : Type u_1} {n : Nat} [Monad m] (f : Fin nm α) (i : Nat) (h' : i n) (acc : Array α) (w : acc.size = i) :
    m (Vector α n)

    Auxiliary for ofFn. ofFn.go f i acc = acc ++ #v[f i, ..., f(n - 1)]

    Equations
    Instances For
      @[simp]
      theorem Vector.ofFnM_zero {m : Type u_1 → Type u_2} {α : Type u_1} [Monad m] {f : Fin 0m α} :
      ofFnM f = pure { toArray := #[], size_toArray := }
      theorem Vector.ofFnM_succ {m : Type u_1 → Type u_2} {α : Type u_1} {n : Nat} [Monad m] [LawfulMonad m] {f : Fin (n + 1)m α} :
      ofFnM f = do let asofFnM fun (i : Fin n) => f i.castSucc let af (Fin.last n) pure (as.push a)
      theorem Vector.ofFnM_add {k : Nat} {α : Type u_1} {n : Nat} {m : Type u_1 → Type u_2} [Monad m] [LawfulMonad m] {f : Fin (n + k)m α} :
      ofFnM f = do let asofFnM fun (i : Fin n) => f (Fin.castLE i) let bsofFnM fun (i : Fin k) => f (Fin.natAdd n i) pure (as ++ bs)
      @[simp]
      theorem Vector.toArray_ofFnM {m : Type u_1 → Type u_2} {n : Nat} {α : Type u_1} [Monad m] [LawfulMonad m] {f : Fin nm α} :
      @[simp]
      theorem Vector.toList_ofFnM {m : Type u_1 → Type u_2} {n : Nat} {α : Type u_1} [Monad m] [LawfulMonad m] {f : Fin nm α} :
      theorem Vector.ofFnM_succ' {m : Type u_1 → Type u_2} {α : Type u_1} {n : Nat} [Monad m] [LawfulMonad m] {f : Fin (n + 1)m α} :
      ofFnM f = do let af 0 let asofFnM fun (i : Fin n) => f i.succ pure (Vector.cast ({ toArray := #[a], size_toArray := } ++ as))
      @[simp]
      theorem Vector.ofFnM_pure_comp {m : Type u_1 → Type u_2} {α : Type u_1} [Monad m] [LawfulMonad m] {n : Nat} {f : Fin nα} :
      theorem Vector.ofFnM_pure {m : Type u_1 → Type u_2} {α : Type u_1} [Monad m] [LawfulMonad m] {n : Nat} {f : Fin nα} :
      (ofFnM fun (i : Fin n) => pure (f i)) = pure (ofFn f)
      @[simp]
      theorem Vector.idRun_ofFnM {n : Nat} {α : Type u_1} {f : Fin nId α} :
      (ofFnM f).run = ofFn fun (i : Fin n) => (f i).run