The areas / V33. Data structures and computation
Mathlib.Data.List.OfFn
29 declarations. Mathlib docs · Source
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
List.get?_ofFn, which tells us the nth element of such a listList.equivSigmaTuple, which is anEquivbetween lists and the functions that generate them viaList.ofFn.
theorem List.get_ofFn E1 #
∀ {α : Type u} {n : ℕ} (f : Fin n → α) (i : Fin (List.ofFn f).length), (List.ofFn f).get i = f (Fin.cast ⋯ i)
theorem List.ofFn_comp' E1 #
∀ {α : Type u} {β : Type u_1} {n : ℕ} (f : Fin n → α) (g : α → β),
(List.ofFn fun i ↦ g (f i)) = List.map g (List.ofFn f)
Useful if rw [← map_ofFn] complains that g ∘ f is not the same as fun i => g (f i).
theorem List.ofFn_congr E1 #
∀ {α : Type u} {m n : ℕ} (h : m = n) (f : Fin m → α), List.ofFn f = List.ofFn fun i ↦ f (Fin.cast ⋯ i)
theorem List.ofFn_succ' E1 #
∀ {α : Type u} {n : ℕ} (f : Fin n.succ → α), List.ofFn f = (List.ofFn fun i ↦ f i.castSucc).concat (f (Fin.last n))
theorem List.ofFn_fin_append E0 #
∀ {α : Type u} {m n : ℕ} (a : Fin m → α) (b : Fin n → α), List.ofFn (Fin.append a b) = List.ofFn a ++ List.ofFn b
theorem List.ofFn_mul E1 #
∀ {α : Type u} {m n : ℕ} (f : Fin (m * n) → α),
List.ofFn f = (List.ofFn fun i ↦ List.ofFn fun j ↦ f ⟨↑i * n + ↑j, ⋯⟩).flatten
This breaks a list of m*n items into m groups each containing n elements.
theorem List.ofFn_mul' E1 #
∀ {α : Type u} {m n : ℕ} (f : Fin (m * n) → α),
List.ofFn f = (List.ofFn fun i ↦ List.ofFn fun j ↦ f ⟨m * ↑i + ↑j, ⋯⟩).flatten
This breaks a list of m*n items into n groups each containing m elements.
theorem List.ofFn_get E0 #
∀ {α : Type u} (l : List α), List.ofFn l.get = l
theorem List.ofFn_getElem_eq_map E0 #
∀ {α : Type u} {β : Type u_1} (l : List α) (f : α → β), (List.ofFn fun i ↦ f l[↑i]) = List.map f l
theorem List.mem_ofFn' E0 #
∀ {α : Type u} {n : ℕ} (f : Fin n → α) (a : α), a ∈ List.ofFn f ↔ a ∈ Set.range f
theorem List.forall_mem_ofFn_iff E0 #
∀ {α : Type u} {n : ℕ} {f : Fin n → α} {P : α → Prop}, (∀ i ∈ List.ofFn f, P i) ↔ ∀ (j : Fin n), P (f j)
theorem List.ofFn_const E0 #
∀ {α : Type u} (n : ℕ) (c : α), (List.ofFn fun x ↦ c) = List.replicate n c
theorem List.ofFn_fin_repeat E0 #
∀ {α : Type u} {m : ℕ} (a : Fin m → α) (n : ℕ), List.ofFn (Fin.repeat n a) = (List.replicate n (List.ofFn a)).flatten
theorem List.pairwise_ofFn E0 #
∀ {α : 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)
theorem List.getLast_ofFn_succ E1 #
∀ {α : Type u} {n : ℕ} (f : Fin n.succ → α), (List.ofFn f).getLast ⋯ = f (Fin.last n)
theorem List.ofFn_cons E1 #
∀ {α : Type u} {n : ℕ} (a : α) (f : Fin n → α), List.ofFn (Fin.cons a f) = a :: List.ofFn f
theorem List.find?_ofFn_eq_some E1 #
∀ {α : Type u} {n : ℕ} {f : Fin n → α} {p : α → Bool} {b : α},
List.find? p (List.ofFn f) = some b ↔ p b = true ∧ ∃ i, f i = b ∧ ∀ j < i, ¬p (f j) = true
theorem List.find?_ofFn_eq_some_of_injective E1 #
∀ {α : Type u} {n : ℕ} {f : Fin n → α} {p : α → Bool} {i : Fin n},
Function.Injective f → (List.find? p (List.ofFn f) = some (f i) ↔ p (f i) = true ∧ ∀ j < i, ¬p (f j) = true)
def List.equivSigmaTuple E3 #
{α : Type u} → List α ≃ (n : ℕ) × (Fin n → α)
Lists are equivalent to the sigma type of tuples of a given length.
theorem List.equivSigmaTuple_symm_apply E0 #
∀ {α : Type u} (f : (n : ℕ) × (Fin n → α)), List.equivSigmaTuple.symm f = List.ofFn f.snd
theorem List.equivSigmaTuple_apply_snd E0 #
∀ {α : Type u} (l : List α) (a : Fin l.length), (List.equivSigmaTuple l).snd a = l.get a
theorem List.equivSigmaTuple_apply_fst E0 #
∀ {α : Type u} (l : List α), (List.equivSigmaTuple l).fst = l.length
def List.ofFnRec E1 #
{α : Type u} → {C : List α → Sort u_1} → ((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.
theorem List.ofFnRec_ofFn E0 #
∀ {α : Type u} {C : List α → Sort u_1} (h : (n : ℕ) → (f : Fin n → α) → C (List.ofFn f)) {n : ℕ} (f : Fin n → α),
List.ofFnRec h (List.ofFn f) = h n f
theorem List.exists_iff_exists_tuple E1 #
∀ {α : Type u} {P : List α → Prop}, (∃ l, P l) ↔ ∃ n f, P (List.ofFn f)
theorem List.forall_iff_forall_tuple E1 #
∀ {α : Type u} {P : List α → Prop}, (∀ (l : List α), P l) ↔ ∀ (n : ℕ) (f : Fin n → α), P (List.ofFn f)
theorem List.ofFn_inj' E1 #
∀ {α : 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 E1 #
∀ {α : Type u} {n : ℕ}, Function.Injective List.ofFn
Note we can only state this when the two functions are indexed by defeq n.
theorem List.ofFn_inj E0 #
∀ {α : Type u} {n : ℕ} {f g : Fin n → α}, List.ofFn f = List.ofFn g ↔ f = g
A special case of List.ofFn_inj for when the two functions are indexed by defeq n.