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.length_ofFn
, which tells us the length of such a listList.get?_ofFn
, which tells us the nth element of such a listList.equivSigmaTuple
, which is anEquiv
between lists and the functions that generate them viaList.ofFn
.
@[simp]
The length of a list converted from a function is the size of the domain.
@[simp]
@[simp]
theorem
List.get?_ofFn
{α : Type u}
{n : ℕ}
(f : Fin n → α)
(i : ℕ)
:
List.get? (List.ofFn f) i = List.ofFnNthVal f i
The n
th element of a list
@[deprecated List.get_ofFn]
theorem
List.nthLe_ofFn
{α : Type u}
{n : ℕ}
(f : Fin n → α)
(i : Fin n)
:
List.nthLe (List.ofFn f) ↑i (_ : ↑i < List.length (List.ofFn f)) = f i
@[simp, deprecated List.get_ofFn]
theorem
List.nthLe_ofFn'
{α : Type u}
{n : ℕ}
(f : Fin n → α)
{i : ℕ}
(h : i < List.length (List.ofFn f))
:
List.nthLe (List.ofFn f) i h = f { val := i, isLt := (_ : i < n) }
theorem
List.ofFn_succ'
{α : Type u}
{n : ℕ}
(f : Fin (Nat.succ n) → α)
:
List.ofFn f = List.concat (List.ofFn fun i => f (Fin.castSucc i)) (f (Fin.last n))
theorem
List.ofFn_add
{α : Type u}
{m : ℕ}
{n : ℕ}
(f : Fin (m + n) → α)
:
List.ofFn f = (List.ofFn fun i => f (Fin.castAdd n i)) ++ List.ofFn fun j => f (Fin.natAdd m j)
Note this matches the convention of List.ofFn_succ'
, putting the Fin m
elements first.
@[deprecated List.ofFn_get]
theorem
List.ofFn_nthLe
{α : Type u}
(l : List α)
:
(List.ofFn fun i => List.nthLe l ↑i (_ : ↑i < List.length l)) = l
@[simp]
@[simp]
theorem
List.ofFn_fin_repeat
{α : Type u}
{m : ℕ}
(a : Fin m → α)
(n : ℕ)
:
List.ofFn (Fin.repeat n a) = List.join (List.replicate n (List.ofFn a))
@[simp]
theorem
List.equivSigmaTuple_apply_fst
{α : Type u}
(l : List α)
:
(↑List.equivSigmaTuple l).fst = List.length l
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
- List.ofFnRec h l = cast (_ : C (List.ofFn (List.get l)) = C l) (h (List.length l) (List.get l))
Instances For
Note we can only state this when the two functions are indexed by defeq n
.