Lemmas about List.range
and List.enum
#
Most of the results are deferred to Data.Init.List.Nat.Range
, where more results about
natural arithmetic are available.
Ranges and enumeration #
range' #
theorem
List.range'_succ
(s n step : Nat)
:
List.range' s (n + 1) step = s :: List.range' (s + step) n step
@[simp]
theorem
List.tail_range'
{s step : Nat}
(n : Nat)
:
(List.range' s n step).tail = List.range' (s + step) (n - 1) step
@[simp]
theorem
List.range'_inj
{s n s' n' : Nat}
:
List.range' s n = List.range' s' n' ↔ n = n' ∧ (n = 0 ∨ s = s')
@[simp]
theorem
List.getElem_range'
{n m step : Nat}
(i : Nat)
(H : i < (List.range' n m step).length)
:
(List.range' n m step)[i] = n + step * i
theorem
List.head?_range'
{s : Nat}
(n : Nat)
:
(List.range' s n).head? = if n = 0 then none else some s
@[simp]
theorem
List.head_range'
{s : Nat}
(n : Nat)
(h : List.range' s n ≠ [])
:
(List.range' s n).head h = s
@[simp]
theorem
List.map_add_range'
(a s n step : Nat)
:
List.map (fun (x : Nat) => a + x) (List.range' s n step) = List.range' (a + s) n step
theorem
List.range'_append
(s m n 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 m n : Nat)
:
List.range' s m ++ List.range' (s + m) n = List.range' s (n + m)
theorem
List.range'_sublist_right
{step s m n : Nat}
:
(List.range' s m step).Sublist (List.range' s n step) ↔ m ≤ n
theorem
List.range'_subset_right
{step s m n : Nat}
(step0 : 0 < step)
:
List.range' s m step ⊆ List.range' s n step ↔ m ≤ n
theorem
List.range'_concat
{step : Nat}
(s n : Nat)
:
List.range' s (n + 1) step = List.range' s n step ++ [s + step * n]
range #
theorem
List.range_loop_range'
(s n : Nat)
:
List.range.loop s (List.range' s n) = List.range' 0 (n + s)
@[simp]
theorem
List.getElem_range
{n : Nat}
(m : Nat)
(h : m < (List.range n).length)
:
(List.range n)[m] = m
theorem
List.range_succ_eq_map
(n : Nat)
:
List.range (n + 1) = 0 :: List.map Nat.succ (List.range n)
theorem
List.range'_eq_map_range
(s n : Nat)
:
List.range' s n = List.map (fun (x : Nat) => s + x) (List.range n)
theorem
List.range_add
(a b : Nat)
:
List.range (a + b) = List.range a ++ List.map (fun (x : Nat) => a + x) (List.range b)
theorem
List.getLast?_range
(n : Nat)
:
(List.range n).getLast? = if n = 0 then none else some (n - 1)
@[simp]
enumFrom #
@[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 i : Nat)
(h : i < (List.enumFrom n l).length)
:
(List.enumFrom n l)[i] = (n + i, l[i])
@[simp]
theorem
List.tail_enumFrom
{α : Type u_1}
(l : List α)
(n : Nat)
:
(List.enumFrom n l).tail = List.enumFrom (n + 1) l.tail
theorem
List.map_fst_add_enumFrom_eq_enumFrom
{α : Type u_1}
(l : List α)
(n 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)
@[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.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 #
theorem
List.enum_cons
{α✝ : Type u_1}
{a : α✝}
{as : List α✝}
:
(a :: as).enum = (0, a) :: List.enumFrom 1 as