Lemmas about List.range
and List.enum
#
Ranges and enumeration #
range' #
theorem
List.range'_succ
(s : Nat)
(n : Nat)
(step : Nat)
:
List.range' s (n + 1) step = s :: List.range' (s + step) n step
@[simp]
@[simp]
theorem
List.pairwise_lt_range'
(s : Nat)
(n : Nat)
(step : optParam Nat 1)
(pos : autoParam (0 < step) _auto✝)
:
List.Pairwise (fun (x x_1 : Nat) => x < x_1) (List.range' s n step)
theorem
List.pairwise_le_range'
(s : Nat)
(n : Nat)
(step : optParam Nat 1)
:
List.Pairwise (fun (x x_1 : Nat) => x ≤ x_1) (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
@[simp]
theorem
List.map_add_range'
(a : Nat)
(s : Nat)
(n : Nat)
(step : Nat)
:
List.map (fun (x : Nat) => a + x) (List.range' s n step) = List.range' (a + s) n step
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.range'_append
(s : Nat)
(m : Nat)
(n : Nat)
(step : Nat)
:
List.range' s m step ++ List.range' (s + step * m) n step = List.range' s (n + m) step
@[simp]
theorem
List.range'_append_1
(s : Nat)
(m : Nat)
(n : Nat)
:
List.range' s m ++ List.range' (s + m) n = List.range' s (n + m)
theorem
List.range'_sublist_right
{step : Nat}
{s : Nat}
{m : Nat}
{n : Nat}
:
(List.range' s m step).Sublist (List.range' s n step) ↔ m ≤ n
theorem
List.range'_subset_right
{step : Nat}
{s : Nat}
{m : Nat}
{n : Nat}
(step0 : 0 < step)
:
List.range' s m step ⊆ List.range' s n step ↔ m ≤ n
theorem
List.range'_subset_right_1
{s : Nat}
{m : Nat}
{n : Nat}
:
List.range' s m ⊆ List.range' s n ↔ m ≤ n
@[simp]
theorem
List.getElem_range'
{n : Nat}
{m : Nat}
{step : Nat}
(i : Nat)
(H : i < (List.range' n m step).length)
:
(List.range' n m step)[i] = n + step * i
theorem
List.range'_concat
{step : Nat}
(s : Nat)
(n : Nat)
:
List.range' s (n + 1) step = List.range' s n step ++ [s + step * n]
theorem
List.range'_1_concat
(s : Nat)
(n : Nat)
:
List.range' s (n + 1) = List.range' s n ++ [s + n]
range #
theorem
List.range_loop_range'
(s : Nat)
(n : Nat)
:
List.range.loop s (List.range' s n) = List.range' 0 (n + s)
theorem
List.range_succ_eq_map
(n : Nat)
:
List.range (n + 1) = 0 :: List.map Nat.succ (List.range n)
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.range'_eq_map_range
(s : Nat)
(n : Nat)
:
List.range' s n = List.map (fun (x : Nat) => s + x) (List.range n)
@[simp]
theorem
List.pairwise_lt_range
(n : Nat)
:
List.Pairwise (fun (x x_1 : Nat) => x < x_1) (List.range n)
theorem
List.pairwise_le_range
(n : Nat)
:
List.Pairwise (fun (x x_1 : Nat) => x ≤ x_1) (List.range n)
@[simp]
theorem
List.getElem_range
{n : Nat}
(m : Nat)
(h : m < (List.range n).length)
:
(List.range n)[m] = m
theorem
List.range_add
(a : Nat)
(b : Nat)
:
List.range (a + b) = List.range a ++ List.map (fun (x : Nat) => a + x) (List.range b)
iota #
enumFrom #
@[simp]
@[simp]
@[simp]
theorem
List.enumFrom_length
{α : Type u_1}
{n : Nat}
{l : List α}
:
(List.enumFrom n l).length = l.length
@[simp]
theorem
List.getElem?_enumFrom
{α : Type u_1}
(n : Nat)
(l : List α)
(m : Nat)
:
(List.enumFrom n l)[m]? = Option.map (fun (a : α) => (n + m, a)) l[m]?
@[simp]
theorem
List.getElem_enumFrom
{α : Type u_1}
(l : List α)
(n : Nat)
(i : Nat)
(h : i < (List.enumFrom n l).length)
:
(List.enumFrom n l)[i] = (n + i, l[i])
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)
@[simp]
theorem
List.enumFrom_map_fst
{α : Type u_1}
(n : Nat)
(l : List α)
:
List.map Prod.fst (List.enumFrom n l) = List.range' n l.length
@[simp]
theorem
List.enumFrom_map_snd
{α : Type u_1}
(n : Nat)
(l : List α)
:
List.map Prod.snd (List.enumFrom n l) = 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.map_fst_add_enumFrom_eq_enumFrom
{α : Type u_1}
(l : List α)
(n : Nat)
(k : Nat)
:
List.map (Prod.map (fun (x : Nat) => x + n) id) (List.enumFrom k l) = List.enumFrom (n + k) l
theorem
List.enumFrom_cons'
{α : Type u_1}
(n : Nat)
(x : α)
(xs : List α)
:
List.enumFrom n (x :: xs) = (n, x) :: List.map (Prod.map (fun (x : Nat) => x + 1) id) (List.enumFrom n xs)
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
theorem
List.enumFrom_eq_zip_range'
{α : Type u_1}
(l : List α)
{n : Nat}
:
List.enumFrom n l = (List.range' n l.length).zip l
@[simp]
theorem
List.unzip_enumFrom_eq_prod
{α : Type u_1}
(l : List α)
{n : Nat}
:
(List.enumFrom n l).unzip = (List.range' n l.length, l)
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.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)