Documentation

Mathlib.Data.List.OfFn

Lists from functions #

Theorems and lemmas for dealing with List.ofFn, which converts a function on Fin n to a list of length n.

Main Statements #

The main statements pertain to lists generated using List.ofFn

theorem List.get_ofFn {α : Type u} {n : ℕ} (f : Fin n → α) (i : Fin (List.ofFn f).length) :
(List.ofFn f).get i = f (Fin.cast ⋯ i)
theorem List.get?_ofFn {α : Type u} {n : ℕ} (f : Fin n → α) (i : ℕ) :
(List.ofFn f).get? i = List.ofFnNthVal f i

The nth element of a list

@[simp]
theorem List.map_ofFn {α : Type u} {β : Type u_1} {n : ℕ} (f : Fin n → α) (g : α → β) :
theorem List.ofFn_congr {α : Type u} {m : ℕ} {n : ℕ} (h : m = n) (f : Fin m → α) :
List.ofFn f = List.ofFn fun (i : Fin n) => f (Fin.cast ⋯ i)
@[simp]
theorem List.ofFn_zero {α : Type u} (f : Fin 0 → α) :

ofFn on an empty domain is the empty list.

@[simp]
theorem List.ofFn_succ {α : Type u} {n : ℕ} (f : Fin n.succ → α) :
List.ofFn f = f 0 :: List.ofFn fun (i : Fin n) => f i.succ
theorem List.ofFn_succ' {α : Type u} {n : ℕ} (f : Fin n.succ → α) :
List.ofFn f = (List.ofFn fun (i : Fin n) => f i.castSucc).concat (f (Fin.last n))
@[simp]
theorem List.ofFn_eq_nil_iff {α : Type u} {n : ℕ} {f : Fin n → α} :
List.ofFn f = [] ↔ n = 0
theorem List.last_ofFn {α : Type u} {n : ℕ} (f : Fin n → α) (h : List.ofFn f ≠ []) (hn : optParam (n - 1 < n) ⋯) :
(List.ofFn f).getLast h = f ⟨n - 1, hn⟩
theorem List.last_ofFn_succ {α : Type u} {n : ℕ} (f : Fin n.succ → α) (h : optParam (List.ofFn f ≠ []) ⋯) :
(List.ofFn f).getLast h = f (Fin.last n)
theorem List.ofFn_add {α : Type u} {m : ℕ} {n : ℕ} (f : Fin (m + n) → α) :
List.ofFn f = (List.ofFn fun (i : Fin m) => f (Fin.castAdd n i)) ++ List.ofFn fun (j : Fin n) => f (Fin.natAdd m j)

Note this matches the convention of List.ofFn_succ', putting the Fin m elements first.

@[simp]
theorem List.ofFn_fin_append {α : Type u} {m : ℕ} {n : ℕ} (a : Fin m → α) (b : Fin n → α) :
theorem List.ofFn_mul {α : Type u} {m : ℕ} {n : ℕ} (f : Fin (m * n) → α) :
List.ofFn f = (List.ofFn fun (i : Fin m) => List.ofFn fun (j : Fin n) => f ⟨↑i * n + ↑j, ⋯⟩).join

This breaks a list of m*n items into m groups each containing n elements.

theorem List.ofFn_mul' {α : Type u} {m : ℕ} {n : ℕ} (f : Fin (m * n) → α) :
List.ofFn f = (List.ofFn fun (i : Fin n) => List.ofFn fun (j : Fin m) => f ⟨m * ↑i + ↑j, ⋯⟩).join

This breaks a list of m*n items into n groups each containing m elements.

@[simp]
theorem List.ofFn_get {α : Type u} (l : List α) :
List.ofFn l.get = l
@[simp]
theorem List.ofFn_getElem {α : Type u} (l : List α) :
(List.ofFn fun (i : Fin l.length) => l[↑i]) = l
@[simp]
theorem List.ofFn_getElem_eq_map {α : Type u} {β : Type u_1} (l : List α) (f : α → β) :
(List.ofFn fun (i : Fin l.length) => f l[↑i]) = List.map f l
@[deprecated List.ofFn_getElem_eq_map]
theorem List.ofFn_get_eq_map {α : Type u} {β : Type u_1} (l : List α) (f : α → β) :
(List.ofFn fun (x : Fin l.length) => f (l.get x)) = List.map f l
theorem List.mem_ofFn {α : Type u} {n : ℕ} (f : Fin n → α) (a : α) :
@[simp]
theorem List.forall_mem_ofFn_iff {α : Type u} {n : ℕ} {f : Fin n → α} {P : α → Prop} :
(∀ i ∈ List.ofFn f, P i) ↔ ∀ (j : Fin n), P (f j)
@[simp]
theorem List.ofFn_const {α : Type u} (n : ℕ) (c : α) :
(List.ofFn fun (x : Fin n) => c) = List.replicate n c
@[simp]
theorem List.ofFn_fin_repeat {α : Type u} {m : ℕ} (a : Fin m → α) (n : ℕ) :
@[simp]
theorem List.pairwise_ofFn {α : Type u} {R : α → α → Prop} {n : ℕ} {f : Fin n → α} :
List.Pairwise R (List.ofFn f) ↔ ∀ ⦃i j : Fin n⦄, i < j → R (f i) (f j)
@[simp]
theorem List.equivSigmaTuple_apply_fst {α : Type u} (l : List α) :
(List.equivSigmaTuple l).fst = l.length
@[simp]
theorem List.equivSigmaTuple_symm_apply {α : Type u} (f : (n : ℕ) × (Fin n → α)) :
List.equivSigmaTuple.symm f = List.ofFn f.snd
@[simp]
theorem List.equivSigmaTuple_apply_snd {α : Type u} (l : List α) :
∀ (a : Fin l.length), (List.equivSigmaTuple l).snd a = l.get a
def List.equivSigmaTuple {α : Type u} :
List α ≃ (n : ℕ) × (Fin n → α)

Lists are equivalent to the sigma type of tuples of a given length.

Equations
  • List.equivSigmaTuple = { toFun := fun (l : List α) => ⟨l.length, l.get⟩, invFun := fun (f : (n : ℕ) × (Fin n → α)) => List.ofFn f.snd, left_inv := ⋯, right_inv := ⋯ }
Instances For
    def List.ofFnRec {α : Type u} {C : List α → Sort u_1} (h : (n : ℕ) → (f : Fin n → α) → C (List.ofFn f)) (l : List α) :
    C l

    A recursor for lists that expands a list into a function mapping to its elements.

    This can be used with induction l using List.ofFnRec.

    Equations
    Instances For
      @[simp]
      theorem List.ofFnRec_ofFn {α : Type u} {C : List α → Sort u_1} (h : (n : ℕ) → (f : Fin n → α) → C (List.ofFn f)) {n : ℕ} (f : Fin n → α) :
      theorem List.exists_iff_exists_tuple {α : Type u} {P : List α → Prop} :
      (∃ (l : List α), P l) ↔ ∃ (n : ℕ) (f : Fin n → α), P (List.ofFn f)
      theorem List.forall_iff_forall_tuple {α : Type u} {P : List α → Prop} :
      (∀ (l : List α), P l) ↔ ∀ (n : ℕ) (f : Fin n → α), P (List.ofFn f)
      theorem List.ofFn_inj' {α : Type u} {m : ℕ} {n : ℕ} {f : Fin m → α} {g : Fin n → α} :
      List.ofFn f = List.ofFn g ↔ ⟨m, f⟩ = ⟨n, g⟩

      Fin.sigma_eq_iff_eq_comp_cast may be useful to work with the RHS of this expression.

      theorem List.ofFn_injective {α : Type u} {n : ℕ} :

      Note we can only state this when the two functions are indexed by defeq n.

      @[simp]
      theorem List.ofFn_inj {α : Type u} {n : ℕ} {f : Fin n → α} {g : Fin n → α} :

      A special case of List.ofFn_inj for when the two functions are indexed by defeq n.