Lemmas about List.range
and List.enum
#
Ranges and enumeration #
range' #
@[simp]
theorem
List.getLast_range'
{s : Nat}
(n : Nat)
(h : List.range' s n ≠ [])
:
(List.range' s n).getLast h = s + n - 1
theorem
List.pairwise_lt_range'
(s : Nat)
(n : Nat)
(step : optParam Nat 1)
(pos : autoParam (0 < step) _auto✝)
:
List.Pairwise (fun (x1 x2 : Nat) => x1 < x2) (List.range' s n step)
theorem
List.pairwise_le_range'
(s : Nat)
(n : Nat)
(step : optParam Nat 1)
:
List.Pairwise (fun (x1 x2 : Nat) => x1 ≤ x2) (List.range' s n step)
theorem
List.nodup_range'
(s : Nat)
(n : Nat)
(step : optParam Nat 1)
(h : autoParam (0 < step) _auto✝)
:
(List.range' s n step).Nodup
theorem
List.map_sub_range'
{step : Nat}
(a : Nat)
(s : Nat)
(n : Nat)
(h : a ≤ s)
:
List.map (fun (x : Nat) => x - a) (List.range' s n step) = List.range' (s - a) n step
theorem
List.erase_range'
{s : Nat}
{n : Nat}
{i : Nat}
:
(List.range' s n).erase i = List.range' s (min n (i - s)) ++ List.range' (max s (i + 1)) (min s (i + 1) + n - (i + 1))
range #
theorem
List.reverse_range'
(s : Nat)
(n : Nat)
:
(List.range' s n).reverse = List.map (fun (x : Nat) => s + n - 1 - x) (List.range n)
theorem
List.pairwise_lt_range
(n : Nat)
:
List.Pairwise (fun (x1 x2 : Nat) => x1 < x2) (List.range n)
theorem
List.pairwise_le_range
(n : Nat)
:
List.Pairwise (fun (x1 x2 : Nat) => x1 ≤ x2) (List.range n)
theorem
List.find?_range_eq_none
{n : Nat}
{p : Nat → Bool}
:
List.find? p (List.range n) = none ↔ ∀ (i : Nat), i < n → (!p i) = true
theorem
List.erase_range
{n : Nat}
{i : Nat}
:
(List.range n).erase i = List.range (min n i) ++ List.range' (i + 1) (n - (i + 1))
iota #
enumFrom #
@[simp]
@[simp]
theorem
List.head?_enumFrom
{α : Type u_1}
(n : Nat)
(l : List α)
:
(List.enumFrom n l).head? = Option.map (fun (a : α) => (n, a)) l.head?
@[simp]
theorem
List.getLast?_enumFrom
{α : Type u_1}
(n : Nat)
(l : List α)
:
(List.enumFrom n l).getLast? = Option.map (fun (a : α) => (n + l.length - 1, a)) l.getLast?
theorem
List.le_fst_of_mem_enumFrom
{α : Type u_1}
{x : Nat × α}
{n : Nat}
{l : List α}
(h : x ∈ List.enumFrom n l)
:
n ≤ x.fst
theorem
List.map_enumFrom
{α : Type u_1}
{β : Type u_2}
(f : α → β)
(n : Nat)
(l : List α)
:
List.map (Prod.map id f) (List.enumFrom n l) = List.enumFrom n (List.map f l)
theorem
List.snd_mem_of_mem_enumFrom
{α : Type u_1}
{x : Nat × α}
{n : Nat}
{l : List α}
(h : x ∈ List.enumFrom n l)
:
x.snd ∈ l
theorem
List.enumFrom_map
{α : Type u_1}
{β : Type u_2}
(n : Nat)
(l : List α)
(f : α → β)
:
List.enumFrom n (List.map f l) = List.map (Prod.map id f) (List.enumFrom n l)
theorem
List.enumFrom_append
{α : Type u_1}
(xs : List α)
(ys : List α)
(n : Nat)
:
List.enumFrom n (xs ++ ys) = List.enumFrom n xs ++ List.enumFrom (n + xs.length) ys
enum #
@[simp]
theorem
List.getElem?_enum
{α : Type u_1}
(l : List α)
(n : Nat)
:
l.enum[n]? = Option.map (fun (a : α) => (n, a)) l[n]?
@[simp]
theorem
List.head?_enum
{α : Type u_1}
(l : List α)
:
l.enum.head? = Option.map (fun (a : α) => (0, a)) l.head?
@[simp]
theorem
List.getLast?_enum
{α : Type u_1}
(l : List α)
:
l.enum.getLast? = Option.map (fun (a : α) => (l.length - 1, a)) l.getLast?
@[simp]
@[simp]
theorem
List.enum_map_fst
{α : Type u_1}
(l : List α)
:
List.map Prod.fst l.enum = List.range l.length
theorem
List.enum_append
{α : Type u_1}
(xs : List α)
(ys : List α)
:
(xs ++ ys).enum = xs.enum ++ List.enumFrom xs.length ys
@[simp]
theorem
List.unzip_enum_eq_prod
{α : Type u_1}
(l : List α)
:
l.enum.unzip = (List.range l.length, l)